@better-auth-ui/react 1.6.0
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-provider.d.ts +32 -0
- package/dist/components/auth/auth-provider.js +44 -0
- package/dist/components/email/email-changed.d.ts +97 -0
- package/dist/components/email/email-changed.js +70 -0
- package/dist/components/email/email-localization.d.ts +61 -0
- package/dist/components/email/email-localization.js +24 -0
- package/dist/components/email/email-styles.d.ts +89 -0
- package/dist/components/email/email-styles.js +129 -0
- package/dist/components/email/email-verification.d.ts +97 -0
- package/dist/components/email/email-verification.js +75 -0
- package/dist/components/email/index.d.ts +9 -0
- package/dist/components/email/index.js +9 -0
- package/dist/components/email/magic-link.d.ts +93 -0
- package/dist/components/email/magic-link.js +72 -0
- package/dist/components/email/new-device.d.ts +123 -0
- package/dist/components/email/new-device.js +90 -0
- package/dist/components/email/otp-email.d.ts +88 -0
- package/dist/components/email/otp-email.js +65 -0
- package/dist/components/email/password-changed.d.ts +96 -0
- package/dist/components/email/password-changed.js +76 -0
- package/dist/components/email/reset-password.d.ts +90 -0
- package/dist/components/email/reset-password.js +68 -0
- package/dist/components/icons/apple.d.ts +8 -0
- package/dist/components/icons/apple.js +10 -0
- package/dist/components/icons/atlassian.d.ts +10 -0
- package/dist/components/icons/atlassian.js +14 -0
- package/dist/components/icons/cognito.d.ts +8 -0
- package/dist/components/icons/cognito.js +10 -0
- package/dist/components/icons/discord.d.ts +8 -0
- package/dist/components/icons/discord.js +10 -0
- package/dist/components/icons/dropbox.d.ts +8 -0
- package/dist/components/icons/dropbox.js +10 -0
- package/dist/components/icons/facebook.d.ts +10 -0
- package/dist/components/icons/facebook.js +12 -0
- package/dist/components/icons/figma.d.ts +11 -0
- package/dist/components/icons/figma.js +13 -0
- package/dist/components/icons/github.d.ts +10 -0
- package/dist/components/icons/github.js +12 -0
- package/dist/components/icons/gitlab.d.ts +8 -0
- package/dist/components/icons/gitlab.js +10 -0
- package/dist/components/icons/google.d.ts +8 -0
- package/dist/components/icons/google.js +10 -0
- package/dist/components/icons/huggingface.d.ts +8 -0
- package/dist/components/icons/huggingface.js +10 -0
- package/dist/components/icons/index.d.ts +35 -0
- package/dist/components/icons/index.js +35 -0
- package/dist/components/icons/kakao.d.ts +10 -0
- package/dist/components/icons/kakao.js +12 -0
- package/dist/components/icons/kick.d.ts +10 -0
- package/dist/components/icons/kick.js +12 -0
- package/dist/components/icons/line.d.ts +8 -0
- package/dist/components/icons/line.js +10 -0
- package/dist/components/icons/linear.d.ts +8 -0
- package/dist/components/icons/linear.js +10 -0
- package/dist/components/icons/linkedin.d.ts +8 -0
- package/dist/components/icons/linkedin.js +10 -0
- package/dist/components/icons/microsoft.d.ts +8 -0
- package/dist/components/icons/microsoft.js +10 -0
- package/dist/components/icons/naver.d.ts +8 -0
- package/dist/components/icons/naver.js +10 -0
- package/dist/components/icons/notion.d.ts +8 -0
- package/dist/components/icons/notion.js +10 -0
- package/dist/components/icons/paybin.d.ts +7 -0
- package/dist/components/icons/paybin.js +9 -0
- package/dist/components/icons/paypal.d.ts +8 -0
- package/dist/components/icons/paypal.js +10 -0
- package/dist/components/icons/polar.d.ts +8 -0
- package/dist/components/icons/polar.js +10 -0
- package/dist/components/icons/railway.d.ts +8 -0
- package/dist/components/icons/railway.js +10 -0
- package/dist/components/icons/reddit.d.ts +8 -0
- package/dist/components/icons/reddit.js +10 -0
- package/dist/components/icons/roblox.d.ts +11 -0
- package/dist/components/icons/roblox.js +13 -0
- package/dist/components/icons/salesforce.d.ts +8 -0
- package/dist/components/icons/salesforce.js +10 -0
- package/dist/components/icons/slack.d.ts +8 -0
- package/dist/components/icons/slack.js +10 -0
- package/dist/components/icons/spotify.d.ts +8 -0
- package/dist/components/icons/spotify.js +10 -0
- package/dist/components/icons/tiktok.d.ts +9 -0
- package/dist/components/icons/tiktok.js +11 -0
- package/dist/components/icons/twitch.d.ts +8 -0
- package/dist/components/icons/twitch.js +13 -0
- package/dist/components/icons/vercel.d.ts +8 -0
- package/dist/components/icons/vercel.js +10 -0
- package/dist/components/icons/vk.d.ts +8 -0
- package/dist/components/icons/vk.js +10 -0
- package/dist/components/icons/wechat.d.ts +8 -0
- package/dist/components/icons/wechat.js +10 -0
- package/dist/components/icons/x.d.ts +8 -0
- package/dist/components/icons/x.js +10 -0
- package/dist/components/icons/zoom.d.ts +8 -0
- package/dist/components/icons/zoom.js +12 -0
- package/dist/components/settings/account/theme-preview.d.ts +3 -0
- package/dist/components/settings/account/theme-preview.js +10 -0
- package/dist/core.d.ts +1 -0
- package/dist/core.js +1 -0
- package/dist/hooks/auth/use-auth-mutation.d.ts +18 -0
- package/dist/hooks/auth/use-auth-mutation.js +10 -0
- package/dist/hooks/auth/use-auth-query.d.ts +24 -0
- package/dist/hooks/auth/use-auth-query.js +10 -0
- package/dist/hooks/auth/use-authenticate.d.ts +9 -0
- package/dist/hooks/auth/use-authenticate.js +28 -0
- package/dist/hooks/auth/use-forgot-password.d.ts +20 -0
- package/dist/hooks/auth/use-forgot-password.js +14 -0
- package/dist/hooks/auth/use-request-password-reset.d.ts +26 -0
- package/dist/hooks/auth/use-request-password-reset.js +14 -0
- package/dist/hooks/auth/use-reset-password.d.ts +40 -0
- package/dist/hooks/auth/use-reset-password.js +13 -0
- package/dist/hooks/auth/use-send-verification-email.d.ts +24 -0
- package/dist/hooks/auth/use-send-verification-email.js +13 -0
- package/dist/hooks/auth/use-session.d.ts +9 -0
- package/dist/hooks/auth/use-session.js +18 -0
- package/dist/hooks/auth/use-sign-in-email.d.ts +53 -0
- package/dist/hooks/auth/use-sign-in-email.js +24 -0
- package/dist/hooks/auth/use-sign-in-magic-link.d.ts +32 -0
- package/dist/hooks/auth/use-sign-in-magic-link.js +13 -0
- package/dist/hooks/auth/use-sign-in-social.d.ts +93 -0
- package/dist/hooks/auth/use-sign-in-social.js +13 -0
- package/dist/hooks/auth/use-sign-out.d.ts +19 -0
- package/dist/hooks/auth/use-sign-out.js +24 -0
- package/dist/hooks/auth/use-sign-up-email.d.ts +526 -0
- package/dist/hooks/auth/use-sign-up-email.js +24 -0
- package/dist/hooks/auth/use-user.d.ts +513 -0
- package/dist/hooks/auth/use-user.js +14 -0
- package/dist/hooks/settings/use-account-info.d.ts +17 -0
- package/dist/hooks/settings/use-account-info.js +25 -0
- package/dist/hooks/settings/use-change-email.d.ts +24 -0
- package/dist/hooks/settings/use-change-email.js +23 -0
- package/dist/hooks/settings/use-change-password.d.ts +54 -0
- package/dist/hooks/settings/use-change-password.js +11 -0
- package/dist/hooks/settings/use-delete-user.d.ts +42 -0
- package/dist/hooks/settings/use-delete-user.js +11 -0
- package/dist/hooks/settings/use-link-social.d.ts +46 -0
- package/dist/hooks/settings/use-link-social.js +10 -0
- package/dist/hooks/settings/use-list-accounts.d.ts +20 -0
- package/dist/hooks/settings/use-list-accounts.js +23 -0
- package/dist/hooks/settings/use-list-device-sessions.d.ts +11 -0
- package/dist/hooks/settings/use-list-device-sessions.js +22 -0
- package/dist/hooks/settings/use-list-sessions.d.ts +20 -0
- package/dist/hooks/settings/use-list-sessions.js +22 -0
- package/dist/hooks/settings/use-revoke-multi-session.d.ts +19 -0
- package/dist/hooks/settings/use-revoke-multi-session.js +20 -0
- package/dist/hooks/settings/use-revoke-session.d.ts +19 -0
- package/dist/hooks/settings/use-revoke-session.js +21 -0
- package/dist/hooks/settings/use-set-active-session.d.ts +37 -0
- package/dist/hooks/settings/use-set-active-session.js +28 -0
- package/dist/hooks/settings/use-unlink-account.d.ts +21 -0
- package/dist/hooks/settings/use-unlink-account.js +21 -0
- package/dist/hooks/settings/use-update-user.d.ts +11 -0
- package/dist/hooks/settings/use-update-user.js +29 -0
- package/dist/hooks/use-hydrated.d.ts +6 -0
- package/dist/hooks/use-hydrated.js +18 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.js +33 -0
- package/dist/lib/auth-client.d.ts +1979 -0
- package/dist/lib/auth-client.js +5 -0
- package/dist/lib/auth-config.d.ts +43 -0
- package/dist/lib/auth-config.js +1 -0
- package/dist/lib/auth-context.d.ts +2 -0
- package/dist/lib/auth-context.js +3 -0
- package/dist/lib/auth-hook-options.d.ts +8 -0
- package/dist/lib/auth-hook-options.js +1 -0
- package/dist/lib/provider-icons.d.ts +13 -0
- package/dist/lib/provider-icons.js +48 -0
- package/dist/lib/utils.d.ts +2 -0
- package/dist/lib/utils.js +5 -0
- package/package.json +64 -0
- package/src/components/auth/auth-provider.tsx +82 -0
- package/src/components/email/email-changed.tsx +381 -0
- package/src/components/email/email-localization.tsx +33 -0
- package/src/components/email/email-styles.tsx +175 -0
- package/src/components/email/email-verification.tsx +350 -0
- package/src/components/email/index.ts +9 -0
- package/src/components/email/magic-link.tsx +349 -0
- package/src/components/email/new-device.tsx +452 -0
- package/src/components/email/otp-email.tsx +321 -0
- package/src/components/email/password-changed.tsx +380 -0
- package/src/components/email/reset-password.tsx +343 -0
- package/src/components/icons/apple.tsx +24 -0
- package/src/components/icons/atlassian.tsx +43 -0
- package/src/components/icons/cognito.tsx +25 -0
- package/src/components/icons/discord.tsx +24 -0
- package/src/components/icons/dropbox.tsx +24 -0
- package/src/components/icons/facebook.tsx +30 -0
- package/src/components/icons/figma.tsx +43 -0
- package/src/components/icons/github.tsx +26 -0
- package/src/components/icons/gitlab.tsx +36 -0
- package/src/components/icons/google.tsx +42 -0
- package/src/components/icons/huggingface.tsx +44 -0
- package/src/components/icons/index.ts +35 -0
- package/src/components/icons/kakao.tsx +26 -0
- package/src/components/icons/kick.tsx +30 -0
- package/src/components/icons/line.tsx +24 -0
- package/src/components/icons/linear.tsx +24 -0
- package/src/components/icons/linkedin.tsx +28 -0
- package/src/components/icons/microsoft.tsx +24 -0
- package/src/components/icons/naver.tsx +24 -0
- package/src/components/icons/notion.tsx +25 -0
- package/src/components/icons/paybin.tsx +37 -0
- package/src/components/icons/paypal.tsx +36 -0
- package/src/components/icons/polar.tsx +31 -0
- package/src/components/icons/railway.tsx +24 -0
- package/src/components/icons/reddit.tsx +25 -0
- package/src/components/icons/roblox.tsx +28 -0
- package/src/components/icons/salesforce.tsx +24 -0
- package/src/components/icons/slack.tsx +36 -0
- package/src/components/icons/spotify.tsx +24 -0
- package/src/components/icons/tiktok.tsx +32 -0
- package/src/components/icons/twitch.tsx +50 -0
- package/src/components/icons/vercel.tsx +21 -0
- package/src/components/icons/vk.tsx +24 -0
- package/src/components/icons/wechat.tsx +24 -0
- package/src/components/icons/x.tsx +24 -0
- package/src/components/icons/zoom.tsx +48 -0
- package/src/components/settings/account/theme-preview.tsx +271 -0
- package/src/core.ts +1 -0
- package/src/hooks/auth/use-auth-mutation.ts +56 -0
- package/src/hooks/auth/use-auth-query.ts +50 -0
- package/src/hooks/auth/use-authenticate.ts +35 -0
- package/src/hooks/auth/use-request-password-reset.ts +24 -0
- package/src/hooks/auth/use-reset-password.ts +23 -0
- package/src/hooks/auth/use-send-verification-email.ts +23 -0
- package/src/hooks/auth/use-session.ts +26 -0
- package/src/hooks/auth/use-sign-in-email.ts +35 -0
- package/src/hooks/auth/use-sign-in-magic-link.ts +23 -0
- package/src/hooks/auth/use-sign-in-social.ts +23 -0
- package/src/hooks/auth/use-sign-out.ts +34 -0
- package/src/hooks/auth/use-sign-up-email.ts +35 -0
- package/src/hooks/auth/use-user.ts +21 -0
- package/src/hooks/settings/use-account-info.ts +30 -0
- package/src/hooks/settings/use-change-email.ts +33 -0
- package/src/hooks/settings/use-change-password.ts +21 -0
- package/src/hooks/settings/use-delete-user.ts +21 -0
- package/src/hooks/settings/use-link-social.ts +19 -0
- package/src/hooks/settings/use-list-accounts.ts +27 -0
- package/src/hooks/settings/use-list-device-sessions.ts +32 -0
- package/src/hooks/settings/use-list-sessions.ts +26 -0
- package/src/hooks/settings/use-revoke-multi-session.ts +30 -0
- package/src/hooks/settings/use-revoke-session.ts +31 -0
- package/src/hooks/settings/use-set-active-session.ts +46 -0
- package/src/hooks/settings/use-unlink-account.ts +31 -0
- package/src/hooks/settings/use-update-user.ts +44 -0
- package/src/index.ts +34 -0
- package/src/lib/auth-client.ts +37 -0
- package/src/lib/auth-config.ts +48 -0
- package/src/lib/auth-context.ts +6 -0
- package/src/lib/provider-icons.ts +90 -0
- package/src/lib/utils.ts +6 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Renders the Vercel logo as an SVG icon.
|
|
4
|
+
*
|
|
5
|
+
* @param props - Props forwarded to the root `<svg>` element (e.g., className, style, width, height, aria-*).
|
|
6
|
+
* @returns An SVG element representing the Vercel logo.
|
|
7
|
+
*/
|
|
8
|
+
export function Vercel(props) {
|
|
9
|
+
return (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", role: "img", "aria-label": "Vercel", ...props, children: _jsx("path", { fill: "currentColor", d: "M23 21.648H1L12 2.352z" }) }));
|
|
10
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ComponentPropsWithRef } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Render the VK social icon as an SVG element.
|
|
4
|
+
*
|
|
5
|
+
* @param props - SVG attributes and ref forwarded to the root `<svg>` element
|
|
6
|
+
* @returns An `<svg>` element containing the VK icon path
|
|
7
|
+
*/
|
|
8
|
+
export declare function VK(props: ComponentPropsWithRef<"svg">): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Render the VK social icon as an SVG element.
|
|
4
|
+
*
|
|
5
|
+
* @param props - SVG attributes and ref forwarded to the root `<svg>` element
|
|
6
|
+
* @returns An `<svg>` element containing the VK icon path
|
|
7
|
+
*/
|
|
8
|
+
export function VK(props) {
|
|
9
|
+
return (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 576 512", role: "img", "aria-label": "VK", ...props, children: _jsx("path", { fill: "#0076FF", d: "M545 117.7c3.7-12.5 0-21.7-17.8-21.7h-58.9c-15 0-21.9 7.9-25.6 16.7c0 0-30 73.1-72.4 120.5c-13.7 13.7-20 18.1-27.5 18.1c-3.7 0-9.4-4.4-9.4-16.9V117.7c0-15-4.2-21.7-16.6-21.7h-92.6c-9.4 0-15 7-15 13.5c0 14.2 21.2 17.5 23.4 57.5v86.8c0 19-3.4 22.5-10.9 22.5c-20 0-68.6-73.4-97.4-157.4c-5.8-16.3-11.5-22.9-26.6-22.9H38.8c-16.8 0-20.2 7.9-20.2 16.7c0 15.6 20 93.1 93.1 195.5C160.4 378.1 229 416 291.4 416c37.5 0 42.1-8.4 42.1-22.9c0-66.8-3.4-73.1 15.4-73.1c8.7 0 23.7 4.4 58.7 38.1c40 40 46.6 57.9 69 57.9h58.9c16.8 0 25.3-8.4 20.4-25c-11.2-34.9-86.9-106.7-90.3-111.5c-8.7-11.2-6.2-16.2 0-26.2c.1-.1 72-101.3 79.4-135.6" }) }));
|
|
10
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ComponentPropsWithRef } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Renders an "X" icon as an SVG React component.
|
|
4
|
+
*
|
|
5
|
+
* @param props - Props to spread onto the underlying `svg` element (e.g., className, style, ref).
|
|
6
|
+
* @returns The SVG element representing the "X" icon with its path filled by `currentColor`.
|
|
7
|
+
*/
|
|
8
|
+
export declare function WeChat(props: ComponentPropsWithRef<"svg">): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Renders an "X" icon as an SVG React component.
|
|
4
|
+
*
|
|
5
|
+
* @param props - Props to spread onto the underlying `svg` element (e.g., className, style, ref).
|
|
6
|
+
* @returns The SVG element representing the "X" icon with its path filled by `currentColor`.
|
|
7
|
+
*/
|
|
8
|
+
export function WeChat(props) {
|
|
9
|
+
return (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", role: "img", "aria-label": "WeChat", ...props, children: _jsx("path", { fill: "currentColor", d: "M9.5 4C5.36 4 2 6.69 2 10c0 1.89 1.08 3.56 2.78 4.66L4 17l2.5-1.5c.89.31 1.87.5 2.91.5A5.2 5.2 0 0 1 9 14c0-3.31 3.13-6 7-6c.19 0 .38 0 .56.03C15.54 5.69 12.78 4 9.5 4m-3 2.5a1 1 0 0 1 1 1a1 1 0 0 1-1 1a1 1 0 0 1-1-1a1 1 0 0 1 1-1m5 0a1 1 0 0 1 1 1a1 1 0 0 1-1 1a1 1 0 0 1-1-1a1 1 0 0 1 1-1M16 9c-3.31 0-6 2.24-6 5s2.69 5 6 5c.67 0 1.31-.08 1.91-.25L20 20l-.62-1.87C20.95 17.22 22 15.71 22 14c0-2.76-2.69-5-6-5m-2 2.5a1 1 0 0 1 1 1a1 1 0 0 1-1 1a1 1 0 0 1-1-1a1 1 0 0 1 1-1m4 0a1 1 0 0 1 1 1a1 1 0 0 1-1 1a1 1 0 0 1-1-1a1 1 0 0 1 1-1" }) }));
|
|
10
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ComponentPropsWithRef } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Renders an "X" icon as an SVG React component.
|
|
4
|
+
*
|
|
5
|
+
* @param props - Props to spread onto the underlying `svg` element (e.g., className, style, ref).
|
|
6
|
+
* @returns The SVG element representing the "X" icon with its path filled by `currentColor`.
|
|
7
|
+
*/
|
|
8
|
+
export declare function X(props: ComponentPropsWithRef<"svg">): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Renders an "X" icon as an SVG React component.
|
|
4
|
+
*
|
|
5
|
+
* @param props - Props to spread onto the underlying `svg` element (e.g., className, style, ref).
|
|
6
|
+
* @returns The SVG element representing the "X" icon with its path filled by `currentColor`.
|
|
7
|
+
*/
|
|
8
|
+
export function X(props) {
|
|
9
|
+
return (_jsx("svg", { viewBox: "0 0 512 512", xmlns: "http://www.w3.org/2000/svg", role: "img", "aria-label": "X", ...props, children: _jsx("path", { d: "M389.2 48h70.6L305.6 224.2L487 464H345L233.7 318.6L106.5 464H35.8l164.9-188.5L26.8 48h145.6l100.5 132.9zm-24.8 373.8h39.1L151.1 88h-42z", fill: "currentColor" }) }));
|
|
10
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type ComponentPropsWithRef } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Renders a stylized "Zoom" SVG icon featuring a blue multi-stop gradient and a white interior highlight.
|
|
4
|
+
*
|
|
5
|
+
* @param props - Props are forwarded to the root `<svg>` element (e.g., className, style, width, height, aria-*).
|
|
6
|
+
* @returns The SVG element for the Zoom icon.
|
|
7
|
+
*/
|
|
8
|
+
export declare function Zoom(props: ComponentPropsWithRef<"svg">): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useId } from "react";
|
|
3
|
+
/**
|
|
4
|
+
* Renders a stylized "Zoom" SVG icon featuring a blue multi-stop gradient and a white interior highlight.
|
|
5
|
+
*
|
|
6
|
+
* @param props - Props are forwarded to the root `<svg>` element (e.g., className, style, width, height, aria-*).
|
|
7
|
+
* @returns The SVG element for the Zoom icon.
|
|
8
|
+
*/
|
|
9
|
+
export function Zoom(props) {
|
|
10
|
+
const gradientId = useId();
|
|
11
|
+
return (_jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 256 256", role: "img", "aria-label": "Zoom", ...props, children: [_jsx("defs", { children: _jsxs("linearGradient", { id: gradientId, x1: "23.666%", x2: "76.334%", y1: "95.612%", y2: "4.388%", children: [_jsx("stop", { offset: "0%", stopColor: "#0845bf" }), _jsx("stop", { offset: "19.11%", stopColor: "#0950de" }), _jsx("stop", { offset: "38.23%", stopColor: "#0b59f6" }), _jsx("stop", { offset: "50%", stopColor: "#0b5cff" }), _jsx("stop", { offset: "67.32%", stopColor: "#0e5efe" }), _jsx("stop", { offset: "77.74%", stopColor: "#1665fc" }), _jsx("stop", { offset: "86.33%", stopColor: "#246ff9" }), _jsx("stop", { offset: "93.88%", stopColor: "#387ff4" }), _jsx("stop", { offset: "100%", stopColor: "#4f90ee" })] }) }), _jsx("path", { fill: `url(#${gradientId})`, d: "M256 128c0 13.568-1.024 27.136-3.328 40.192c-6.912 43.264-41.216 77.568-84.48 84.48C155.136 254.976 141.568 256 128 256s-27.136-1.024-40.192-3.328c-43.264-6.912-77.568-41.216-84.48-84.48C1.024 155.136 0 141.568 0 128s1.024-27.136 3.328-40.192c6.912-43.264 41.216-77.568 84.48-84.48C100.864 1.024 114.432 0 128 0s27.136 1.024 40.192 3.328c43.264 6.912 77.568 41.216 84.48 84.48C254.976 100.864 256 114.432 256 128" }), _jsx("path", { fill: "#fff", d: "M204.032 207.872H75.008c-8.448 0-16.64-4.608-20.48-12.032c-4.608-8.704-2.816-19.2 4.096-26.112l89.856-89.856H83.968c-17.664 0-32-14.336-32-32h118.784c8.448 0 16.64 4.608 20.48 12.032c4.608 8.704 2.816 19.2-4.096 26.112l-89.6 90.112h74.496c17.664 0 32 14.08 32 31.744" })] }));
|
|
12
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare function ThemePreviewSystem(props: React.SVGProps<SVGSVGElement>): import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
export declare function ThemePreviewLight(props: React.SVGProps<SVGSVGElement>): import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
export declare function ThemePreviewDark(props: React.SVGProps<SVGSVGElement>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
export function ThemePreviewSystem(props) {
|
|
3
|
+
return (_jsxs("svg", { fill: "none", viewBox: "0 0 240 117", xmlns: "http://www.w3.org/2000/svg", role: "img", "aria-label": "System theme preview", ...props, children: [_jsxs("defs", { children: [_jsx("clipPath", { id: "systemDiagonalLight", children: _jsx("polygon", { points: "0,0 240,0 0,117" }) }), _jsx("clipPath", { id: "systemDiagonalDark", children: _jsx("polygon", { points: "240,0 240,117 0,117" }) })] }), _jsxs("g", { clipPath: "url(#systemDiagonalLight)", children: [_jsx("path", { d: "M12 0.5H228C234.351 0.5 239.5 5.64873 239.5 12V105C239.5 111.351 234.351 116.5 228 116.5H12C5.64873 116.5 0.5 111.351 0.5 105V12C0.5 5.64873 5.64873 0.5 12 0.5Z", fill: "white" }), _jsx("path", { d: "M12 0.5H228C234.351 0.5 239.5 5.64873 239.5 12V105C239.5 111.351 234.351 116.5 228 116.5H12C5.64873 116.5 0.5 111.351 0.5 105V12C0.5 5.64873 5.64873 0.5 12 0.5Z", stroke: "#E4E4E7" }), _jsx("path", { d: "M32 48.5C32 45.4624 34.4624 43 37.5 43H67.5C70.5376 43 73 45.4624 73 48.5C73 51.5376 70.5376 54 67.5 54H37.5C34.4624 54 32 51.5376 32 48.5Z", fill: "#F4F4F5" }), _jsx("path", { d: "M17 105C17 101.686 19.6863 99 23 99H67C70.3137 99 73 101.686 73 105C73 108.314 70.3137 111 67 111H23C19.6863 111 17 108.314 17 105Z", fill: "#F4F4F5" }), _jsx("path", { d: "M88 25.5C88 22.4624 90.4624 20 93.5 20H207.5C210.538 20 213 22.4624 213 25.5C213 28.5376 210.538 31 207.5 31H93.5C90.4624 31 88 28.5376 88 25.5Z", fill: "#E4E4E7" }), _jsx("path", { d: "M88 105C88 101.686 90.6863 99 94 99H189C192.314 99 195 101.686 195 105C195 108.314 192.314 111 189 111H94C90.6863 111 88 108.314 88 105Z", fill: "#F4F4F5" }), _jsx("path", { d: "M88 51C88 46.5817 91.5817 43 96 43H221C225.418 43 229 46.5817 229 51V85C229 89.4183 225.418 93 221 93H96C91.5817 93 88 89.4183 88 85V51Z", fill: "#F4F4F5" }), _jsx("path", { d: "M17 48.5C17 45.4624 19.4624 43 22.5 43C25.5376 43 28 45.4624 28 48.5C28 51.5376 25.5376 54 22.5 54C19.4624 54 17 51.5376 17 48.5Z", fill: "#F4F4F5" }), _jsx("path", { d: "M17 66.5C17 63.4624 19.4624 61 22.5 61C25.5376 61 28 63.4624 28 66.5C28 69.5376 25.5376 72 22.5 72C19.4624 72 17 69.5376 17 66.5Z", fill: "#F4F4F5" }), _jsx("path", { d: "M17 86.5C17 83.4624 19.4624 81 22.5 81C25.5376 81 28 83.4624 28 86.5V87.5C28 90.5376 25.5376 93 22.5 93C19.4624 93 17 90.5376 17 87.5V86.5Z", fill: "#F4F4F5" }), _jsx("path", { d: "M32 25.5C32 22.4624 34.4624 20 37.5 20H67.5C70.5376 20 73 22.4624 73 25.5C73 28.5376 70.5376 31 67.5 31H37.5C34.4624 31 32 28.5376 32 25.5Z", fill: "#E4E4E7" }), _jsx("path", { d: "M32 66.5C32 63.4624 34.4624 61 37.5 61H67.5C70.5376 61 73 63.4624 73 66.5C73 69.5376 70.5376 72 67.5 72H37.5C34.4624 72 32 69.5376 32 66.5Z", fill: "#F4F4F5" }), _jsx("path", { d: "M32 87C32 83.6863 34.6863 81 38 81H67C70.3137 81 73 83.6863 73 87C73 90.3137 70.3137 93 67 93H38C34.6863 93 32 90.3137 32 87Z", fill: "#F4F4F5" }), _jsx("circle", { cx: "22.5", cy: "25.5", fill: "#E4E4E7", r: "5.5" })] }), _jsxs("g", { clipPath: "url(#systemDiagonalDark)", children: [_jsx("path", { d: "M12 0.5H228C234.351 0.5 239.5 5.64873 239.5 12V105C239.5 111.351 234.351 116.5 228 116.5H12C5.64873 116.5 0.5 111.351 0.5 105V12C0.5 5.64873 5.64873 0.5 12 0.5Z", fill: "black" }), _jsx("path", { d: "M12 0.5H228C234.351 0.5 239.5 5.64873 239.5 12V105C239.5 111.351 234.351 116.5 228 116.5H12C5.64873 116.5 0.5 111.351 0.5 105V12C0.5 5.64873 5.64873 0.5 12 0.5Z", stroke: "#3F3F46" }), _jsx("path", { d: "M32 48.5C32 45.4624 34.4624 43 37.5 43H67.5C70.5376 43 73 45.4624 73 48.5C73 51.5376 70.5376 54 67.5 54H37.5C34.4624 54 32 51.5376 32 48.5Z", fill: "#27272A" }), _jsx("path", { d: "M17 105C17 101.686 19.6863 99 23 99H67C70.3137 99 73 101.686 73 105C73 108.314 70.3137 111 67 111H23C19.6863 111 17 108.314 17 105Z", fill: "#27272A" }), _jsx("path", { d: "M88 25.5C88 22.4624 90.4624 20 93.5 20H207.5C210.538 20 213 22.4624 213 25.5C213 28.5376 210.538 31 207.5 31H93.5C90.4624 31 88 28.5376 88 25.5Z", fill: "#3F3F46" }), _jsx("path", { d: "M88 105C88 101.686 90.6863 99 94 99H189C192.314 99 195 101.686 195 105C195 108.314 192.314 111 189 111H94C90.6863 111 88 108.314 88 105Z", fill: "#27272A" }), _jsx("path", { d: "M88 51C88 46.5817 91.5817 43 96 43H221C225.418 43 229 46.5817 229 51V85C229 89.4183 225.418 93 221 93H96C91.5817 93 88 89.4183 88 85V51Z", fill: "#27272A" }), _jsx("path", { d: "M17 48.5C17 45.4624 19.4624 43 22.5 43C25.5376 43 28 45.4624 28 48.5C28 51.5376 25.5376 54 22.5 54C19.4624 54 17 51.5376 17 48.5Z", fill: "#27272A" }), _jsx("path", { d: "M17 66.5C17 63.4624 19.4624 61 22.5 61C25.5376 61 28 63.4624 28 66.5C28 69.5376 25.5376 72 22.5 72C19.4624 72 17 69.5376 17 66.5Z", fill: "#27272A" }), _jsx("path", { d: "M17 86.5C17 83.4624 19.4624 81 22.5 81C25.5376 81 28 83.4624 28 86.5V87.5C28 90.5376 25.5376 93 22.5 93C19.4624 93 17 90.5376 17 87.5V86.5Z", fill: "#27272A" }), _jsx("path", { d: "M32 25.5C32 22.4624 34.4624 20 37.5 20H67.5C70.5376 20 73 22.4624 73 25.5C73 28.5376 70.5376 31 67.5 31H37.5C34.4624 31 32 28.5376 32 25.5Z", fill: "#3F3F46" }), _jsx("path", { d: "M32 66.5C32 63.4624 34.4624 61 37.5 61H67.5C70.5376 61 73 63.4624 73 66.5C73 69.5376 70.5376 72 67.5 72H37.5C34.4624 72 32 69.5376 32 66.5Z", fill: "#27272A" }), _jsx("path", { d: "M32 87C32 83.6863 34.6863 81 38 81H67C70.3137 81 73 83.6863 73 87C73 90.3137 70.3137 93 67 93H38C34.6863 93 32 90.3137 32 87Z", fill: "#27272A" }), _jsx("circle", { cx: "22.5", cy: "25.5", fill: "#3F3F46", r: "5.5" })] })] }));
|
|
4
|
+
}
|
|
5
|
+
export function ThemePreviewLight(props) {
|
|
6
|
+
return (_jsxs("svg", { fill: "none", viewBox: "0 0 240 117", xmlns: "http://www.w3.org/2000/svg", role: "img", "aria-label": "Light", ...props, children: [_jsx("path", { d: "M12 0.5H228C234.351 0.5 239.5 5.64873 239.5 12V105C239.5 111.351 234.351 116.5 228 116.5H12C5.64873 116.5 0.5 111.351 0.5 105V12C0.5 5.64873 5.64873 0.5 12 0.5Z", fill: "white" }), _jsx("path", { d: "M12 0.5H228C234.351 0.5 239.5 5.64873 239.5 12V105C239.5 111.351 234.351 116.5 228 116.5H12C5.64873 116.5 0.5 111.351 0.5 105V12C0.5 5.64873 5.64873 0.5 12 0.5Z", stroke: "#E4E4E7" }), _jsx("path", { d: "M32 48.5C32 45.4624 34.4624 43 37.5 43H67.5C70.5376 43 73 45.4624 73 48.5C73 51.5376 70.5376 54 67.5 54H37.5C34.4624 54 32 51.5376 32 48.5Z", fill: "#F4F4F5" }), _jsx("path", { d: "M17 105C17 101.686 19.6863 99 23 99H67C70.3137 99 73 101.686 73 105C73 108.314 70.3137 111 67 111H23C19.6863 111 17 108.314 17 105Z", fill: "#F4F4F5" }), _jsx("path", { d: "M88 25.5C88 22.4624 90.4624 20 93.5 20H207.5C210.538 20 213 22.4624 213 25.5C213 28.5376 210.538 31 207.5 31H93.5C90.4624 31 88 28.5376 88 25.5Z", fill: "#E4E4E7" }), _jsx("path", { d: "M88 105C88 101.686 90.6863 99 94 99H189C192.314 99 195 101.686 195 105C195 108.314 192.314 111 189 111H94C90.6863 111 88 108.314 88 105Z", fill: "#F4F4F5" }), _jsx("path", { d: "M88 51C88 46.5817 91.5817 43 96 43H221C225.418 43 229 46.5817 229 51V85C229 89.4183 225.418 93 221 93H96C91.5817 93 88 89.4183 88 85V51Z", fill: "#F4F4F5" }), _jsx("path", { d: "M17 48.5C17 45.4624 19.4624 43 22.5 43C25.5376 43 28 45.4624 28 48.5C28 51.5376 25.5376 54 22.5 54C19.4624 54 17 51.5376 17 48.5Z", fill: "#F4F4F5" }), _jsx("path", { d: "M17 66.5C17 63.4624 19.4624 61 22.5 61C25.5376 61 28 63.4624 28 66.5C28 69.5376 25.5376 72 22.5 72C19.4624 72 17 69.5376 17 66.5Z", fill: "#F4F4F5" }), _jsx("path", { d: "M17 86.5C17 83.4624 19.4624 81 22.5 81C25.5376 81 28 83.4624 28 86.5V87.5C28 90.5376 25.5376 93 22.5 93C19.4624 93 17 90.5376 17 87.5V86.5Z", fill: "#F4F4F5" }), _jsx("path", { d: "M32 25.5C32 22.4624 34.4624 20 37.5 20H67.5C70.5376 20 73 22.4624 73 25.5C73 28.5376 70.5376 31 67.5 31H37.5C34.4624 31 32 28.5376 32 25.5Z", fill: "#E4E4E7" }), _jsx("path", { d: "M32 66.5C32 63.4624 34.4624 61 37.5 61H67.5C70.5376 61 73 63.4624 73 66.5C73 69.5376 70.5376 72 67.5 72H37.5C34.4624 72 32 69.5376 32 66.5Z", fill: "#F4F4F5" }), _jsx("path", { d: "M32 87C32 83.6863 34.6863 81 38 81H67C70.3137 81 73 83.6863 73 87C73 90.3137 70.3137 93 67 93H38C34.6863 93 32 90.3137 32 87Z", fill: "#F4F4F5" }), _jsx("circle", { cx: "22.5", cy: "25.5", fill: "#E4E4E7", r: "5.5" })] }));
|
|
7
|
+
}
|
|
8
|
+
export function ThemePreviewDark(props) {
|
|
9
|
+
return (_jsxs("svg", { fill: "none", viewBox: "0 0 240 117", xmlns: "http://www.w3.org/2000/svg", role: "img", "aria-label": "Dark", ...props, children: [_jsx("path", { d: "M12 0.5H228C234.351 0.5 239.5 5.64873 239.5 12V105C239.5 111.351 234.351 116.5 228 116.5H12C5.64873 116.5 0.5 111.351 0.5 105V12C0.5 5.64873 5.64873 0.5 12 0.5Z", fill: "black" }), _jsx("path", { d: "M12 0.5H228C234.351 0.5 239.5 5.64873 239.5 12V105C239.5 111.351 234.351 116.5 228 116.5H12C5.64873 116.5 0.5 111.351 0.5 105V12C0.5 5.64873 5.64873 0.5 12 0.5Z", stroke: "#3F3F46" }), _jsx("path", { d: "M32 48.5C32 45.4624 34.4624 43 37.5 43H67.5C70.5376 43 73 45.4624 73 48.5C73 51.5376 70.5376 54 67.5 54H37.5C34.4624 54 32 51.5376 32 48.5Z", fill: "#27272A" }), _jsx("path", { d: "M17 105C17 101.686 19.6863 99 23 99H67C70.3137 99 73 101.686 73 105C73 108.314 70.3137 111 67 111H23C19.6863 111 17 108.314 17 105Z", fill: "#27272A" }), _jsx("path", { d: "M88 25.5C88 22.4624 90.4624 20 93.5 20H207.5C210.538 20 213 22.4624 213 25.5C213 28.5376 210.538 31 207.5 31H93.5C90.4624 31 88 28.5376 88 25.5Z", fill: "#3F3F46" }), _jsx("path", { d: "M88 105C88 101.686 90.6863 99 94 99H189C192.314 99 195 101.686 195 105C195 108.314 192.314 111 189 111H94C90.6863 111 88 108.314 88 105Z", fill: "#27272A" }), _jsx("path", { d: "M88 51C88 46.5817 91.5817 43 96 43H221C225.418 43 229 46.5817 229 51V85C229 89.4183 225.418 93 221 93H96C91.5817 93 88 89.4183 88 85V51Z", fill: "#27272A" }), _jsx("path", { d: "M17 48.5C17 45.4624 19.4624 43 22.5 43C25.5376 43 28 45.4624 28 48.5C28 51.5376 25.5376 54 22.5 54C19.4624 54 17 51.5376 17 48.5Z", fill: "#27272A" }), _jsx("path", { d: "M17 66.5C17 63.4624 19.4624 61 22.5 61C25.5376 61 28 63.4624 28 66.5C28 69.5376 25.5376 72 22.5 72C19.4624 72 17 69.5376 17 66.5Z", fill: "#27272A" }), _jsx("path", { d: "M17 86.5C17 83.4624 19.4624 81 22.5 81C25.5376 81 28 83.4624 28 86.5V87.5C28 90.5376 25.5376 93 22.5 93C19.4624 93 17 90.5376 17 87.5V86.5Z", fill: "#27272A" }), _jsx("path", { d: "M32 25.5C32 22.4624 34.4624 20 37.5 20H67.5C70.5376 20 73 22.4624 73 25.5C73 28.5376 70.5376 31 67.5 31H37.5C34.4624 31 32 28.5376 32 25.5Z", fill: "#3F3F46" }), _jsx("path", { d: "M32 66.5C32 63.4624 34.4624 61 37.5 61H67.5C70.5376 61 73 63.4624 73 66.5C73 69.5376 70.5376 72 67.5 72H37.5C34.4624 72 32 69.5376 32 66.5Z", fill: "#27272A" }), _jsx("path", { d: "M32 87C32 83.6863 34.6863 81 38 81H67C70.3137 81 73 83.6863 73 87C73 90.3137 70.3137 93 67 93H38C34.6863 93 32 90.3137 32 87Z", fill: "#27272A" }), _jsx("circle", { cx: "22.5", cy: "25.5", fill: "#3F3F46", r: "5.5" })] }));
|
|
10
|
+
}
|
package/dist/core.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@better-auth-ui/core";
|
package/dist/core.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@better-auth-ui/core";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type UseMutationOptions, type UseMutationResult } from "@tanstack/react-query";
|
|
2
|
+
import type { BetterFetchError } from "better-auth/react";
|
|
3
|
+
type AuthFn = (...args: any) => Promise<any>;
|
|
4
|
+
type MutationParams<TFn extends AuthFn> = undefined extends Parameters<TFn>[0] ? // biome-ignore lint/suspicious/noConfusingVoidType: void is needed for mutations with optional params
|
|
5
|
+
void | Omit<NonNullable<Parameters<TFn>[0]>, "fetchOptions"> : Omit<Parameters<TFn>[0], "fetchOptions">;
|
|
6
|
+
type InferMutationData<TFn extends AuthFn> = TFn extends (...args: infer _A) => infer R ? Extract<Awaited<R>, {
|
|
7
|
+
error: null;
|
|
8
|
+
}> extends {
|
|
9
|
+
data: infer D;
|
|
10
|
+
} ? D : Awaited<R> : Awaited<ReturnType<TFn>>;
|
|
11
|
+
export type UseAuthMutationOptions<TFn extends AuthFn> = Omit<UseMutationOptions<InferMutationData<TFn>, BetterFetchError, MutationParams<TFn>>, "mutationFn">;
|
|
12
|
+
export type UseAuthMutationResult<TFn extends AuthFn> = UseMutationResult<InferMutationData<TFn>, BetterFetchError, MutationParams<TFn>>;
|
|
13
|
+
type UseAuthMutationProps<TFn extends AuthFn> = {
|
|
14
|
+
authFn: TFn;
|
|
15
|
+
options?: UseAuthMutationOptions<TFn>;
|
|
16
|
+
};
|
|
17
|
+
export declare function useAuthMutation<TFn extends AuthFn>({ authFn, options }: UseAuthMutationProps<TFn>): UseAuthMutationResult<TFn>;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type UseQueryOptions, type UseQueryResult } from "@tanstack/react-query";
|
|
2
|
+
import type { BetterFetchError, BetterFetchOption } from "better-auth/react";
|
|
3
|
+
type BetterFetchFn = (options: {
|
|
4
|
+
fetchOptions?: BetterFetchOption;
|
|
5
|
+
}) => Promise<{
|
|
6
|
+
data: unknown;
|
|
7
|
+
}>;
|
|
8
|
+
type InferData<TFn> = TFn extends (options: {
|
|
9
|
+
fetchOptions?: BetterFetchOption;
|
|
10
|
+
}) => Promise<{
|
|
11
|
+
data: infer TData;
|
|
12
|
+
}> ? TData : never;
|
|
13
|
+
type OmitFetchOptions<T> = {
|
|
14
|
+
[K in keyof T as K extends "fetchOptions" ? never : K]: T[K];
|
|
15
|
+
};
|
|
16
|
+
export type UseAuthQueryOptions<TFn extends BetterFetchFn> = Omit<UseQueryOptions<InferData<TFn>, BetterFetchError>, "queryFn">;
|
|
17
|
+
export type UseAuthQueryResult<TFn extends BetterFetchFn> = UseQueryResult<InferData<TFn>, BetterFetchError>;
|
|
18
|
+
type UseAuthQueryProps<TFn extends BetterFetchFn> = {
|
|
19
|
+
authFn: TFn;
|
|
20
|
+
params?: OmitFetchOptions<Parameters<TFn>[0]>;
|
|
21
|
+
options: UseAuthQueryOptions<TFn>;
|
|
22
|
+
};
|
|
23
|
+
export declare function useAuthQuery<TFn extends BetterFetchFn>({ authFn, params, options }: UseAuthQueryProps<TFn>): UseQueryResult<import("@tanstack/react-query").NoInfer<InferData<TFn>>, BetterFetchError>;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { useQuery } from "@tanstack/react-query";
|
|
2
|
+
export function useAuthQuery({ authFn, params, options }) {
|
|
3
|
+
return useQuery({
|
|
4
|
+
queryFn: async () => {
|
|
5
|
+
const result = await authFn({ ...params, fetchOptions: { throw: true } });
|
|
6
|
+
return result;
|
|
7
|
+
},
|
|
8
|
+
...options
|
|
9
|
+
});
|
|
10
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type AuthClient } from "@better-auth-ui/react";
|
|
2
|
+
import type { UseAuthQueryOptions, UseAuthQueryResult } from "./use-auth-query";
|
|
3
|
+
/**
|
|
4
|
+
* Redirects unauthenticated users to the sign-in page while preserving the current URL and exposes the active auth session state.
|
|
5
|
+
*
|
|
6
|
+
* @param options - Query options forwarded to the session query hook
|
|
7
|
+
* @returns An object containing `data` (the current session or `undefined`), `isPending` (whether the session query is in progress), and other session query state
|
|
8
|
+
*/
|
|
9
|
+
export declare function useAuthenticate(options?: Partial<UseAuthQueryOptions<AuthClient["getSession"]>>): UseAuthQueryResult<AuthClient["getSession"]>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { useAuth } from "@better-auth-ui/react";
|
|
2
|
+
import { useEffect } from "react";
|
|
3
|
+
import { useSession } from "./use-session";
|
|
4
|
+
/**
|
|
5
|
+
* Redirects unauthenticated users to the sign-in page while preserving the current URL and exposes the active auth session state.
|
|
6
|
+
*
|
|
7
|
+
* @param options - Query options forwarded to the session query hook
|
|
8
|
+
* @returns An object containing `data` (the current session or `undefined`), `isPending` (whether the session query is in progress), and other session query state
|
|
9
|
+
*/
|
|
10
|
+
export function useAuthenticate(options) {
|
|
11
|
+
const { basePaths, viewPaths, navigate } = useAuth();
|
|
12
|
+
const session = useSession(options);
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
if (session.data || session.isPending)
|
|
15
|
+
return;
|
|
16
|
+
const currentURL = window.location.pathname + window.location.search;
|
|
17
|
+
const redirectTo = encodeURIComponent(currentURL);
|
|
18
|
+
const signInPath = `${basePaths.auth}/${viewPaths.auth.signIn}?redirectTo=${redirectTo}`;
|
|
19
|
+
navigate({ to: signInPath, replace: true });
|
|
20
|
+
}, [
|
|
21
|
+
basePaths.auth,
|
|
22
|
+
session.data,
|
|
23
|
+
session.isPending,
|
|
24
|
+
viewPaths.auth.signIn,
|
|
25
|
+
navigate
|
|
26
|
+
]);
|
|
27
|
+
return session;
|
|
28
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type AuthClient } from "@better-auth-ui/react";
|
|
2
|
+
import type { UseAuthMutationOptions } from "./use-auth-mutation";
|
|
3
|
+
export { useAuthMutation } from "./use-auth-mutation";
|
|
4
|
+
/**
|
|
5
|
+
* Hook that creates a mutation for the forgot-password flow.
|
|
6
|
+
*
|
|
7
|
+
* The mutation sends a password reset request for the submitted email,
|
|
8
|
+
* and navigates to the sign-in view on success.
|
|
9
|
+
*
|
|
10
|
+
* @returns The `useMutation` result.
|
|
11
|
+
*/
|
|
12
|
+
export declare function useRequestPasswordReset(options?: UseAuthMutationOptions<AuthClient["requestPasswordReset"]>): import("@tanstack/react-query").UseMutationResult<any, import("better-auth/react").BetterFetchError, Omit<import("better-auth").Prettify<{
|
|
13
|
+
email: string;
|
|
14
|
+
redirectTo?: string | undefined;
|
|
15
|
+
} & {
|
|
16
|
+
fetchOptions?: import("better-auth").ClientFetchOption<Partial<{
|
|
17
|
+
email: string;
|
|
18
|
+
redirectTo?: string | undefined;
|
|
19
|
+
}> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined> | undefined;
|
|
20
|
+
}>, "fetchOptions">>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { useAuth, useAuthMutation } from "@better-auth-ui/react";
|
|
2
|
+
export { useAuthMutation } from "./use-auth-mutation";
|
|
3
|
+
/**
|
|
4
|
+
* Hook that creates a mutation for the forgot-password flow.
|
|
5
|
+
*
|
|
6
|
+
* The mutation sends a password reset request for the submitted email,
|
|
7
|
+
* and navigates to the sign-in view on success.
|
|
8
|
+
*
|
|
9
|
+
* @returns The `useMutation` result.
|
|
10
|
+
*/
|
|
11
|
+
export function useRequestPasswordReset(options) {
|
|
12
|
+
const { authClient } = useAuth();
|
|
13
|
+
return useAuthMutation(authClient.requestPasswordReset, options);
|
|
14
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type AuthClient } from "@better-auth-ui/react";
|
|
2
|
+
import type { UseAuthMutationOptions } from "./use-auth-mutation";
|
|
3
|
+
export { useAuthMutation } from "./use-auth-mutation";
|
|
4
|
+
/**
|
|
5
|
+
* Hook that creates a mutation for the forgot-password flow.
|
|
6
|
+
*
|
|
7
|
+
* The mutation sends a password reset request for the submitted email,
|
|
8
|
+
* and navigates to the sign-in view on success.
|
|
9
|
+
*
|
|
10
|
+
* @returns The `useMutation` result.
|
|
11
|
+
*/
|
|
12
|
+
export declare function useRequestPasswordReset(options?: UseAuthMutationOptions<AuthClient["requestPasswordReset"]>): import("./use-auth-mutation").UseAuthMutationResult<(<FetchOptions extends import("better-auth").ClientFetchOption<Partial<{
|
|
13
|
+
email: string;
|
|
14
|
+
redirectTo?: string | undefined;
|
|
15
|
+
}> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0: import("better-auth").Prettify<{
|
|
16
|
+
email: string;
|
|
17
|
+
redirectTo?: string | undefined;
|
|
18
|
+
} & {
|
|
19
|
+
fetchOptions?: FetchOptions | undefined;
|
|
20
|
+
}>, data_1?: FetchOptions | undefined) => Promise<import("better-auth/react").BetterFetchResponse<{
|
|
21
|
+
status: boolean;
|
|
22
|
+
message: string;
|
|
23
|
+
}, {
|
|
24
|
+
code?: string | undefined;
|
|
25
|
+
message?: string | undefined;
|
|
26
|
+
}, FetchOptions["throw"] extends true ? true : false>>)>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { useAuth, useAuthMutation } from "@better-auth-ui/react";
|
|
2
|
+
export { useAuthMutation } from "./use-auth-mutation";
|
|
3
|
+
/**
|
|
4
|
+
* Hook that creates a mutation for the forgot-password flow.
|
|
5
|
+
*
|
|
6
|
+
* The mutation sends a password reset request for the submitted email,
|
|
7
|
+
* and navigates to the sign-in view on success.
|
|
8
|
+
*
|
|
9
|
+
* @returns The `useMutation` result.
|
|
10
|
+
*/
|
|
11
|
+
export function useRequestPasswordReset(options) {
|
|
12
|
+
const { authClient } = useAuth();
|
|
13
|
+
return useAuthMutation({ authFn: authClient.requestPasswordReset, options });
|
|
14
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { type AuthClient } from "@better-auth-ui/react";
|
|
2
|
+
import type { UseAuthMutationOptions } from "./use-auth-mutation";
|
|
3
|
+
export { useAuthMutation } from "./use-auth-mutation";
|
|
4
|
+
/**
|
|
5
|
+
* Hook that creates a mutation for the reset-password flow.
|
|
6
|
+
*
|
|
7
|
+
* The mutation resets the user's password using the provided token and new password.
|
|
8
|
+
*
|
|
9
|
+
* @returns The `useMutation` result.
|
|
10
|
+
*/
|
|
11
|
+
export declare function useResetPassword(options?: UseAuthMutationOptions<AuthClient["resetPassword"]>): import("./use-auth-mutation").UseAuthMutationResult<(<FetchOptions extends import("better-auth").ClientFetchOption<Partial<{
|
|
12
|
+
newPassword: string;
|
|
13
|
+
token?: string | undefined;
|
|
14
|
+
}> & Record<string, any>, Partial<{
|
|
15
|
+
token?: string | undefined;
|
|
16
|
+
}> & Record<string, any>, Record<string, any> | undefined>>(data_0: import("better-auth").Prettify<{
|
|
17
|
+
newPassword: string;
|
|
18
|
+
token?: string | undefined;
|
|
19
|
+
} & {
|
|
20
|
+
fetchOptions?: FetchOptions | undefined;
|
|
21
|
+
}>, data_1?: FetchOptions | undefined) => Promise<import("better-auth/react").BetterFetchResponse<{
|
|
22
|
+
status: boolean;
|
|
23
|
+
}, {
|
|
24
|
+
code?: string | undefined;
|
|
25
|
+
message?: string | undefined;
|
|
26
|
+
}, FetchOptions["throw"] extends true ? true : false>>) & {
|
|
27
|
+
":token": <FetchOptions extends import("better-auth").ClientFetchOption<never, Partial<{
|
|
28
|
+
callbackURL: string;
|
|
29
|
+
}> & Record<string, any>, {
|
|
30
|
+
token: string;
|
|
31
|
+
}>>(data_0: import("better-auth").Prettify<{
|
|
32
|
+
query: {
|
|
33
|
+
callbackURL: string;
|
|
34
|
+
};
|
|
35
|
+
fetchOptions?: FetchOptions | undefined;
|
|
36
|
+
}>, data_1?: FetchOptions | undefined) => Promise<import("better-auth/react").BetterFetchResponse<never, {
|
|
37
|
+
code?: string | undefined;
|
|
38
|
+
message?: string | undefined;
|
|
39
|
+
}, FetchOptions["throw"] extends true ? true : false>>;
|
|
40
|
+
}>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { useAuth, useAuthMutation } from "@better-auth-ui/react";
|
|
2
|
+
export { useAuthMutation } from "./use-auth-mutation";
|
|
3
|
+
/**
|
|
4
|
+
* Hook that creates a mutation for the reset-password flow.
|
|
5
|
+
*
|
|
6
|
+
* The mutation resets the user's password using the provided token and new password.
|
|
7
|
+
*
|
|
8
|
+
* @returns The `useMutation` result.
|
|
9
|
+
*/
|
|
10
|
+
export function useResetPassword(options) {
|
|
11
|
+
const { authClient } = useAuth();
|
|
12
|
+
return useAuthMutation({ authFn: authClient.resetPassword, options });
|
|
13
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type AuthClient } from "@better-auth-ui/react";
|
|
2
|
+
import type { UseAuthMutationOptions } from "./use-auth-mutation";
|
|
3
|
+
export { useAuthMutation } from "./use-auth-mutation";
|
|
4
|
+
/**
|
|
5
|
+
* Hook that creates a mutation to send a verification email.
|
|
6
|
+
*
|
|
7
|
+
* The mutation sends a verification email to the specified email address.
|
|
8
|
+
*
|
|
9
|
+
* @returns The `useMutation` result.
|
|
10
|
+
*/
|
|
11
|
+
export declare function useSendVerificationEmail(options?: UseAuthMutationOptions<AuthClient["sendVerificationEmail"]>): import("./use-auth-mutation").UseAuthMutationResult<(<FetchOptions extends import("better-auth").ClientFetchOption<Partial<{
|
|
12
|
+
email: string;
|
|
13
|
+
callbackURL?: string | undefined;
|
|
14
|
+
}> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0: import("better-auth").Prettify<{
|
|
15
|
+
email: string;
|
|
16
|
+
callbackURL?: string | undefined;
|
|
17
|
+
} & {
|
|
18
|
+
fetchOptions?: FetchOptions | undefined;
|
|
19
|
+
}>, data_1?: FetchOptions | undefined) => Promise<import("better-auth/react").BetterFetchResponse<{
|
|
20
|
+
status: boolean;
|
|
21
|
+
}, {
|
|
22
|
+
code?: string | undefined;
|
|
23
|
+
message?: string | undefined;
|
|
24
|
+
}, FetchOptions["throw"] extends true ? true : false>>)>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { useAuth, useAuthMutation } from "@better-auth-ui/react";
|
|
2
|
+
export { useAuthMutation } from "./use-auth-mutation";
|
|
3
|
+
/**
|
|
4
|
+
* Hook that creates a mutation to send a verification email.
|
|
5
|
+
*
|
|
6
|
+
* The mutation sends a verification email to the specified email address.
|
|
7
|
+
*
|
|
8
|
+
* @returns The `useMutation` result.
|
|
9
|
+
*/
|
|
10
|
+
export function useSendVerificationEmail(options) {
|
|
11
|
+
const { authClient } = useAuth();
|
|
12
|
+
return useAuthMutation({ authFn: authClient.sendVerificationEmail, options });
|
|
13
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type AuthClient } from "@better-auth-ui/react";
|
|
2
|
+
import { type UseAuthQueryOptions, type UseAuthQueryResult } from "./use-auth-query";
|
|
3
|
+
/**
|
|
4
|
+
* Retrieve the current authentication session.
|
|
5
|
+
*
|
|
6
|
+
* @param options - Options to merge into the React Query configuration for the session query.
|
|
7
|
+
* @returns The React Query result for the session query: `data` contains session information, `isLoading`/`isFetching` indicate loading state, and `error` contains any fetch error.
|
|
8
|
+
*/
|
|
9
|
+
export declare function useSession(options?: Partial<UseAuthQueryOptions<AuthClient["getSession"]>>): UseAuthQueryResult<AuthClient["getSession"]>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { useAuth } from "@better-auth-ui/react";
|
|
2
|
+
import { useAuthQuery } from "./use-auth-query";
|
|
3
|
+
/**
|
|
4
|
+
* Retrieve the current authentication session.
|
|
5
|
+
*
|
|
6
|
+
* @param options - Options to merge into the React Query configuration for the session query.
|
|
7
|
+
* @returns The React Query result for the session query: `data` contains session information, `isLoading`/`isFetching` indicate loading state, and `error` contains any fetch error.
|
|
8
|
+
*/
|
|
9
|
+
export function useSession(options) {
|
|
10
|
+
const { authClient } = useAuth();
|
|
11
|
+
return useAuthQuery({
|
|
12
|
+
authFn: authClient.getSession,
|
|
13
|
+
options: {
|
|
14
|
+
queryKey: ["auth", "getSession"],
|
|
15
|
+
...options
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { type AuthClient } from "@better-auth-ui/react";
|
|
2
|
+
import type { UseAuthMutationOptions } from "./use-auth-mutation";
|
|
3
|
+
export { useAuthMutation } from "./use-auth-mutation";
|
|
4
|
+
/**
|
|
5
|
+
* Hook that creates a mutation for email/password sign-in.
|
|
6
|
+
*
|
|
7
|
+
* The mutation sends an email/password sign-in request and
|
|
8
|
+
* refetches the session on completion.
|
|
9
|
+
*
|
|
10
|
+
* @returns The `useMutation` result.
|
|
11
|
+
*/
|
|
12
|
+
export declare function useSignInEmail(options?: UseAuthMutationOptions<AuthClient["signIn"]["email"]>): import("./use-auth-mutation").UseAuthMutationResult<(<FetchOptions extends import("better-auth").ClientFetchOption<Partial<{
|
|
13
|
+
email: string;
|
|
14
|
+
password: string;
|
|
15
|
+
callbackURL?: string | undefined;
|
|
16
|
+
rememberMe?: boolean | undefined;
|
|
17
|
+
}> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0: import("better-auth").Prettify<{
|
|
18
|
+
email: string;
|
|
19
|
+
password: string;
|
|
20
|
+
callbackURL?: string | undefined;
|
|
21
|
+
rememberMe?: boolean | undefined;
|
|
22
|
+
} & {
|
|
23
|
+
fetchOptions?: FetchOptions | undefined;
|
|
24
|
+
}>, data_1?: FetchOptions | undefined) => Promise<import("better-auth/react").BetterFetchResponse<Omit<{
|
|
25
|
+
redirect: boolean;
|
|
26
|
+
token: string;
|
|
27
|
+
url?: string | undefined;
|
|
28
|
+
user: {
|
|
29
|
+
id: string;
|
|
30
|
+
createdAt: Date;
|
|
31
|
+
updatedAt: Date;
|
|
32
|
+
email: string;
|
|
33
|
+
emailVerified: boolean;
|
|
34
|
+
name: string;
|
|
35
|
+
image?: string | null | undefined | undefined;
|
|
36
|
+
};
|
|
37
|
+
}, "user"> & {
|
|
38
|
+
user: import("better-auth").StripEmptyObjects<{
|
|
39
|
+
id: string;
|
|
40
|
+
createdAt: Date;
|
|
41
|
+
updatedAt: Date;
|
|
42
|
+
email: string;
|
|
43
|
+
emailVerified: boolean;
|
|
44
|
+
name: string;
|
|
45
|
+
image?: string | null | undefined;
|
|
46
|
+
} & {} & {
|
|
47
|
+
username?: string | null | undefined;
|
|
48
|
+
displayUsername?: string | null | undefined;
|
|
49
|
+
}>;
|
|
50
|
+
}, {
|
|
51
|
+
code?: string | undefined;
|
|
52
|
+
message?: string | undefined;
|
|
53
|
+
}, FetchOptions["throw"] extends true ? true : false>>)>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { useAuth, useAuthMutation, useSession } from "@better-auth-ui/react";
|
|
2
|
+
export { useAuthMutation } from "./use-auth-mutation";
|
|
3
|
+
/**
|
|
4
|
+
* Hook that creates a mutation for email/password sign-in.
|
|
5
|
+
*
|
|
6
|
+
* The mutation sends an email/password sign-in request and
|
|
7
|
+
* refetches the session on completion.
|
|
8
|
+
*
|
|
9
|
+
* @returns The `useMutation` result.
|
|
10
|
+
*/
|
|
11
|
+
export function useSignInEmail(options) {
|
|
12
|
+
const { authClient } = useAuth();
|
|
13
|
+
const { refetch } = useSession({ refetchOnMount: false });
|
|
14
|
+
return useAuthMutation({
|
|
15
|
+
authFn: authClient.signIn.email,
|
|
16
|
+
options: {
|
|
17
|
+
...options,
|
|
18
|
+
onSuccess: async (...args) => {
|
|
19
|
+
await refetch();
|
|
20
|
+
await options?.onSuccess?.(...args);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { type AuthClient } from "@better-auth-ui/react";
|
|
2
|
+
import type { UseAuthMutationOptions } from "./use-auth-mutation";
|
|
3
|
+
export { useAuthMutation } from "./use-auth-mutation";
|
|
4
|
+
/**
|
|
5
|
+
* Hook that creates a mutation for magic-link sign-in.
|
|
6
|
+
*
|
|
7
|
+
* The mutation sends a magic-link sign-in email to the specified address.
|
|
8
|
+
*
|
|
9
|
+
* @returns The `useMutation` result.
|
|
10
|
+
*/
|
|
11
|
+
export declare function useSignInMagicLink(options?: UseAuthMutationOptions<AuthClient["signIn"]["magicLink"]>): import("./use-auth-mutation").UseAuthMutationResult<(<FetchOptions extends import("better-auth").ClientFetchOption<Partial<{
|
|
12
|
+
email: string;
|
|
13
|
+
name?: string | undefined;
|
|
14
|
+
callbackURL?: string | undefined;
|
|
15
|
+
newUserCallbackURL?: string | undefined;
|
|
16
|
+
errorCallbackURL?: string | undefined;
|
|
17
|
+
metadata?: Record<string, any> | undefined;
|
|
18
|
+
}> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0: import("better-auth").Prettify<{
|
|
19
|
+
email: string;
|
|
20
|
+
name?: string | undefined;
|
|
21
|
+
callbackURL?: string | undefined;
|
|
22
|
+
newUserCallbackURL?: string | undefined;
|
|
23
|
+
errorCallbackURL?: string | undefined;
|
|
24
|
+
metadata?: Record<string, any> | undefined;
|
|
25
|
+
} & {
|
|
26
|
+
fetchOptions?: FetchOptions | undefined;
|
|
27
|
+
}>, data_1?: FetchOptions | undefined) => Promise<import("better-auth/react").BetterFetchResponse<{
|
|
28
|
+
status: boolean;
|
|
29
|
+
}, {
|
|
30
|
+
code?: string | undefined;
|
|
31
|
+
message?: string | undefined;
|
|
32
|
+
}, FetchOptions["throw"] extends true ? true : false>>)>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { useAuth, useAuthMutation } from "@better-auth-ui/react";
|
|
2
|
+
export { useAuthMutation } from "./use-auth-mutation";
|
|
3
|
+
/**
|
|
4
|
+
* Hook that creates a mutation for magic-link sign-in.
|
|
5
|
+
*
|
|
6
|
+
* The mutation sends a magic-link sign-in email to the specified address.
|
|
7
|
+
*
|
|
8
|
+
* @returns The `useMutation` result.
|
|
9
|
+
*/
|
|
10
|
+
export function useSignInMagicLink(options) {
|
|
11
|
+
const { authClient } = useAuth();
|
|
12
|
+
return useAuthMutation({ authFn: authClient.signIn.magicLink, options });
|
|
13
|
+
}
|