@better-auth-ui/react 1.6.8 → 1.6.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/auth/auth-context.d.ts +3 -0
- package/dist/components/auth/auth-context.js +4 -0
- package/dist/components/auth/auth-provider.d.ts +4 -4
- package/dist/components/auth/auth-provider.js +65 -41
- package/dist/components/auth/email/email-changed.d.ts +2 -2
- package/dist/components/auth/email/email-changed.js +68 -154
- package/dist/components/auth/email/email-localization.d.ts +11 -3
- package/dist/components/auth/email/email-localization.js +25 -18
- package/dist/components/auth/email/email-styles.js +77 -52
- package/dist/components/auth/email/email-verification.d.ts +2 -2
- package/dist/components/auth/email/email-verification.js +73 -138
- package/dist/components/auth/email/index.d.ts +10 -9
- package/dist/components/auth/email/index.js +10 -9
- package/dist/components/auth/email/magic-link.d.ts +2 -2
- package/dist/components/auth/email/magic-link.js +70 -139
- package/dist/components/auth/email/new-device.d.ts +2 -2
- package/dist/components/auth/email/new-device.js +88 -221
- package/dist/components/auth/email/organization-invitation.d.ts +121 -0
- package/dist/components/auth/email/organization-invitation.js +110 -0
- package/dist/components/auth/email/otp-email.d.ts +2 -2
- package/dist/components/auth/email/otp-email.js +63 -127
- package/dist/components/auth/email/password-changed.d.ts +2 -2
- package/dist/components/auth/email/password-changed.js +74 -157
- package/dist/components/auth/email/reset-password.d.ts +2 -2
- package/dist/components/auth/email/reset-password.js +66 -138
- package/dist/components/auth/fetch-options-provider.d.ts +1 -1
- package/dist/components/auth/fetch-options-provider.js +28 -27
- package/dist/components/icons/apple.d.ts +1 -1
- package/dist/components/icons/apple.js +9 -16
- package/dist/components/icons/atlassian.d.ts +1 -1
- package/dist/components/icons/atlassian.js +13 -38
- package/dist/components/icons/cognito.d.ts +1 -1
- package/dist/components/icons/cognito.js +9 -19
- package/dist/components/icons/discord.d.ts +1 -1
- package/dist/components/icons/discord.js +9 -16
- package/dist/components/icons/dropbox.d.ts +1 -1
- package/dist/components/icons/dropbox.js +9 -16
- package/dist/components/icons/facebook.d.ts +1 -1
- package/dist/components/icons/facebook.js +11 -19
- package/dist/components/icons/figma.d.ts +1 -1
- package/dist/components/icons/figma.js +12 -34
- package/dist/components/icons/github.d.ts +1 -1
- package/dist/components/icons/github.js +11 -16
- package/dist/components/icons/gitlab.d.ts +1 -1
- package/dist/components/icons/gitlab.js +9 -30
- package/dist/components/icons/google.d.ts +1 -1
- package/dist/components/icons/google.js +9 -39
- package/dist/components/icons/huggingface.d.ts +1 -1
- package/dist/components/icons/huggingface.js +9 -38
- package/dist/components/icons/index.d.ts +35 -35
- package/dist/components/icons/index.js +35 -35
- package/dist/components/icons/kakao.d.ts +1 -1
- package/dist/components/icons/kakao.js +11 -16
- package/dist/components/icons/kick.d.ts +1 -1
- package/dist/components/icons/kick.js +11 -20
- package/dist/components/icons/line.d.ts +1 -1
- package/dist/components/icons/line.js +9 -16
- package/dist/components/icons/linear.d.ts +1 -1
- package/dist/components/icons/linear.js +9 -16
- package/dist/components/icons/linkedin.d.ts +1 -1
- package/dist/components/icons/linkedin.js +9 -33
- package/dist/components/icons/microsoft.d.ts +1 -1
- package/dist/components/icons/microsoft.js +9 -30
- package/dist/components/icons/naver.d.ts +1 -1
- package/dist/components/icons/naver.js +9 -16
- package/dist/components/icons/notion.d.ts +1 -1
- package/dist/components/icons/notion.js +9 -16
- package/dist/components/icons/paybin.d.ts +1 -1
- package/dist/components/icons/paybin.js +8 -32
- package/dist/components/icons/paypal.d.ts +1 -1
- package/dist/components/icons/paypal.js +9 -30
- package/dist/components/icons/polar.d.ts +1 -1
- package/dist/components/icons/polar.js +9 -24
- package/dist/components/icons/railway.d.ts +1 -1
- package/dist/components/icons/railway.js +9 -16
- package/dist/components/icons/reddit.d.ts +1 -1
- package/dist/components/icons/reddit.js +9 -21
- package/dist/components/icons/roblox.d.ts +1 -1
- package/dist/components/icons/roblox.js +12 -17
- package/dist/components/icons/salesforce.d.ts +1 -1
- package/dist/components/icons/salesforce.js +9 -16
- package/dist/components/icons/slack.d.ts +1 -1
- package/dist/components/icons/slack.js +9 -30
- package/dist/components/icons/spotify.d.ts +1 -1
- package/dist/components/icons/spotify.js +9 -16
- package/dist/components/icons/tiktok.d.ts +1 -1
- package/dist/components/icons/tiktok.js +10 -23
- package/dist/components/icons/twitch.d.ts +1 -1
- package/dist/components/icons/twitch.js +12 -43
- package/dist/components/icons/vercel.d.ts +1 -1
- package/dist/components/icons/vercel.js +9 -16
- package/dist/components/icons/vk.d.ts +1 -1
- package/dist/components/icons/vk.js +9 -16
- package/dist/components/icons/wechat.d.ts +1 -1
- package/dist/components/icons/wechat.js +9 -16
- package/dist/components/icons/x.d.ts +1 -1
- package/dist/components/icons/x.js +9 -16
- package/dist/components/icons/zoom.d.ts +1 -1
- package/dist/components/icons/zoom.js +11 -69
- package/dist/components/mutation-invalidator.d.ts +1 -0
- package/dist/components/mutation-invalidator.js +31 -0
- package/dist/components/settings/account/theme-preview.js +7 -286
- package/dist/email.d.ts +1 -1
- package/dist/email.js +1 -11
- package/dist/hooks/auth/use-authenticate.d.ts +3 -3
- package/dist/hooks/auth/use-authenticate.js +28 -22
- package/dist/hooks/auth/use-user.d.ts +34 -34
- package/dist/hooks/auth/use-user.js +14 -10
- package/dist/hooks/use-auth-mutation.d.ts +4 -4
- package/dist/hooks/use-auth-mutation.js +18 -10
- package/dist/hooks/use-auth-plugin.d.ts +1 -1
- package/dist/hooks/use-auth-plugin.js +26 -8
- package/dist/hooks/use-auth-query.d.ts +3 -3
- package/dist/hooks/use-auth-query.js +20 -14
- package/dist/index.d.ts +48 -45
- package/dist/index.js +47 -79
- package/dist/lib/auth-client.d.ts +7 -4
- package/dist/lib/auth-client.js +1 -0
- package/dist/lib/auth-plugin.d.ts +19 -3
- package/dist/lib/auth-plugin.js +1 -0
- package/dist/lib/auth-server.d.ts +10 -3
- package/dist/lib/auth-server.js +1 -0
- package/dist/lib/provider-icons.d.ts +2 -2
- package/dist/lib/provider-icons.js +47 -75
- package/dist/lib/settings-tab.d.ts +19 -0
- package/dist/lib/settings-tab.js +1 -0
- package/dist/lib/utils.d.ts +1 -1
- package/dist/lib/utils.js +4 -7
- package/dist/mutations/api-key/create-api-key-mutation.d.ts +9 -7
- package/dist/mutations/api-key/create-api-key-mutation.js +37 -27
- package/dist/mutations/api-key/delete-api-key-mutation.d.ts +10 -6
- package/dist/mutations/api-key/delete-api-key-mutation.js +37 -27
- package/dist/mutations/auth/request-password-reset-mutation.d.ts +4 -4
- package/dist/mutations/auth/request-password-reset-mutation.js +31 -22
- package/dist/mutations/auth/reset-password-mutation.d.ts +4 -4
- package/dist/mutations/auth/reset-password-mutation.js +32 -22
- package/dist/mutations/auth/send-verification-email-mutation.d.ts +4 -4
- package/dist/mutations/auth/send-verification-email-mutation.js +31 -22
- package/dist/mutations/auth/sign-in-email-mutation.d.ts +10 -10
- package/dist/mutations/auth/sign-in-email-mutation.js +38 -27
- package/dist/mutations/auth/sign-in-social-mutation.d.ts +6 -6
- package/dist/mutations/auth/sign-in-social-mutation.js +36 -22
- package/dist/mutations/auth/sign-out-mutation.d.ts +9 -7
- package/dist/mutations/auth/sign-out-mutation.js +39 -26
- package/dist/mutations/auth/sign-up-email-mutation.d.ts +12 -12
- package/dist/mutations/auth/sign-up-email-mutation.js +34 -27
- package/dist/mutations/auth-mutation-options.d.ts +2 -2
- package/dist/mutations/auth-mutation-options.js +22 -18
- package/dist/mutations/magic-link/sign-in-magic-link-mutation.d.ts +4 -4
- package/dist/mutations/magic-link/sign-in-magic-link-mutation.js +31 -22
- package/dist/mutations/multi-session/revoke-multi-session-mutation.d.ts +8 -8
- package/dist/mutations/multi-session/revoke-multi-session-mutation.js +37 -27
- package/dist/mutations/multi-session/set-active-session-mutation.d.ts +8 -9
- package/dist/mutations/multi-session/set-active-session-mutation.js +38 -29
- package/dist/mutations/organization/accept-invitation-mutation.d.ts +43 -0
- package/dist/mutations/organization/accept-invitation-mutation.js +32 -0
- package/dist/mutations/organization/cancel-invitation-mutation.d.ts +25 -0
- package/dist/mutations/organization/cancel-invitation-mutation.js +28 -0
- package/dist/mutations/organization/check-slug-mutation.d.ts +21 -0
- package/dist/mutations/organization/check-slug-mutation.js +30 -0
- package/dist/mutations/organization/create-organization-mutation.d.ts +39 -0
- package/dist/mutations/organization/create-organization-mutation.js +29 -0
- package/dist/mutations/organization/delete-organization-mutation.d.ts +21 -0
- package/dist/mutations/organization/delete-organization-mutation.js +29 -0
- package/dist/mutations/organization/index.d.ts +12 -0
- package/dist/mutations/organization/index.js +12 -0
- package/dist/mutations/organization/invite-member-mutation.d.ts +43 -0
- package/dist/mutations/organization/invite-member-mutation.js +35 -0
- package/dist/mutations/organization/leave-organization-mutation.d.ts +65 -0
- package/dist/mutations/organization/leave-organization-mutation.js +32 -0
- package/dist/mutations/organization/reject-invitation-mutation.d.ts +31 -0
- package/dist/mutations/organization/reject-invitation-mutation.js +25 -0
- package/dist/mutations/organization/remove-member-mutation.d.ts +35 -0
- package/dist/mutations/organization/remove-member-mutation.js +29 -0
- package/dist/mutations/organization/set-active-organization-mutation.d.ts +71 -0
- package/dist/mutations/organization/set-active-organization-mutation.js +72 -0
- package/dist/mutations/organization/update-member-role-mutation.d.ts +31 -0
- package/dist/mutations/organization/update-member-role-mutation.js +36 -0
- package/dist/mutations/organization/update-organization-mutation.d.ts +21 -0
- package/dist/mutations/organization/update-organization-mutation.js +36 -0
- package/dist/mutations/passkey/add-passkey-mutation.d.ts +16 -16
- package/dist/mutations/passkey/add-passkey-mutation.js +38 -27
- package/dist/mutations/passkey/delete-passkey-mutation.d.ts +8 -8
- package/dist/mutations/passkey/delete-passkey-mutation.js +37 -27
- package/dist/mutations/passkey/sign-in-passkey-mutation.d.ts +24 -24
- package/dist/mutations/passkey/sign-in-passkey-mutation.js +36 -27
- package/dist/mutations/settings/change-email-mutation.d.ts +9 -8
- package/dist/mutations/settings/change-email-mutation.js +35 -27
- package/dist/mutations/settings/change-password-mutation.d.ts +6 -6
- package/dist/mutations/settings/change-password-mutation.js +31 -22
- package/dist/mutations/settings/delete-user-mutation.d.ts +4 -4
- package/dist/mutations/settings/delete-user-mutation.js +31 -22
- package/dist/mutations/settings/link-social-mutation.d.ts +4 -4
- package/dist/mutations/settings/link-social-mutation.js +31 -22
- package/dist/mutations/settings/revoke-session-mutation.d.ts +8 -8
- package/dist/mutations/settings/revoke-session-mutation.js +37 -27
- package/dist/mutations/settings/unlink-account-mutation.d.ts +8 -8
- package/dist/mutations/settings/unlink-account-mutation.js +37 -27
- package/dist/mutations/settings/update-user-mutation.d.ts +8 -8
- package/dist/mutations/settings/update-user-mutation.js +34 -33
- package/dist/mutations/username/is-username-available-mutation.d.ts +4 -4
- package/dist/mutations/username/is-username-available-mutation.js +34 -22
- package/dist/mutations/username/sign-in-username-mutation.d.ts +10 -10
- package/dist/mutations/username/sign-in-username-mutation.js +35 -27
- package/dist/plugins/captcha-plugin.d.ts +3 -3
- package/dist/plugins/captcha-plugin.js +31 -26
- package/dist/plugins.d.ts +1 -1
- package/dist/plugins.js +1 -2
- package/dist/queries/api-key/list-api-keys-query.d.ts +20 -11
- package/dist/queries/api-key/list-api-keys-query.js +52 -29
- package/dist/queries/auth/session-query.d.ts +6 -6
- package/dist/queries/auth/session-query.js +70 -28
- package/dist/queries/auth-query-options.d.ts +2 -2
- package/dist/queries/auth-query-options.js +20 -16
- package/dist/queries/multi-session/list-device-sessions-query.d.ts +8 -8
- package/dist/queries/multi-session/list-device-sessions-query.js +83 -29
- package/dist/queries/organization/active-organization-query.d.ts +39 -0
- package/dist/queries/organization/active-organization-query.js +37 -0
- package/dist/queries/organization/full-organization-query.d.ts +37 -0
- package/dist/queries/organization/full-organization-query.js +31 -0
- package/dist/queries/organization/has-permission-query.d.ts +21 -0
- package/dist/queries/organization/has-permission-query.js +38 -0
- package/dist/queries/organization/index.d.ts +7 -0
- package/dist/queries/organization/index.js +7 -0
- package/dist/queries/organization/list-invitations-query.d.ts +29 -0
- package/dist/queries/organization/list-invitations-query.js +37 -0
- package/dist/queries/organization/list-members-query.d.ts +61 -0
- package/dist/queries/organization/list-members-query.js +37 -0
- package/dist/queries/organization/list-organizations-query.d.ts +22 -0
- package/dist/queries/organization/list-organizations-query.js +31 -0
- package/dist/queries/organization/list-user-invitations-query.d.ts +29 -0
- package/dist/queries/organization/list-user-invitations-query.js +31 -0
- package/dist/queries/passkey/list-passkeys-query.d.ts +8 -8
- package/dist/queries/passkey/list-passkeys-query.js +81 -29
- package/dist/queries/settings/account-info-query.d.ts +6 -6
- package/dist/queries/settings/account-info-query.js +85 -29
- package/dist/queries/settings/list-accounts-query.d.ts +6 -6
- package/dist/queries/settings/list-accounts-query.js +83 -29
- package/dist/queries/settings/list-sessions-query.d.ts +6 -6
- package/dist/queries/settings/list-sessions-query.js +81 -29
- package/dist/server/queries/api-key/list-api-keys-query.d.ts +83 -0
- package/dist/server/queries/api-key/list-api-keys-query.js +49 -0
- package/dist/server/queries/auth/session-query.d.ts +5 -5
- package/dist/server/queries/auth/session-query.js +50 -12
- package/dist/server/queries/multi-session/list-device-sessions-query.d.ts +7 -7
- package/dist/server/queries/multi-session/list-device-sessions-query.js +53 -11
- package/dist/server/queries/organization/active-organization-query.d.ts +61 -0
- package/dist/server/queries/organization/active-organization-query.js +25 -0
- package/dist/server/queries/organization/full-organization-query.d.ts +42 -0
- package/dist/server/queries/organization/full-organization-query.js +21 -0
- package/dist/server/queries/organization/has-permission-query.d.ts +66 -0
- package/dist/server/queries/organization/has-permission-query.js +23 -0
- package/dist/server/queries/organization/list-invitations-query.d.ts +34 -0
- package/dist/server/queries/organization/list-invitations-query.js +21 -0
- package/dist/server/queries/organization/list-members-query.d.ts +66 -0
- package/dist/server/queries/organization/list-members-query.js +21 -0
- package/dist/server/queries/organization/list-organizations-query.d.ts +27 -0
- package/dist/server/queries/organization/list-organizations-query.js +21 -0
- package/dist/server/queries/organization/list-user-invitations-query.d.ts +34 -0
- package/dist/server/queries/organization/list-user-invitations-query.js +21 -0
- package/dist/server/queries/passkey/list-passkeys-query.d.ts +7 -7
- package/dist/server/queries/passkey/list-passkeys-query.js +53 -11
- package/dist/server/queries/settings/account-info-query.d.ts +5 -5
- package/dist/server/queries/settings/account-info-query.js +53 -11
- package/dist/server/queries/settings/list-accounts-query.d.ts +5 -5
- package/dist/server/queries/settings/list-accounts-query.js +53 -11
- package/dist/server/queries/settings/list-sessions-query.d.ts +5 -5
- package/dist/server/queries/settings/list-sessions-query.js +53 -11
- package/dist/server.d.ts +15 -7
- package/dist/server.js +14 -7
- package/package.json +20 -17
- package/src/components/auth/auth-context.tsx +7 -0
- package/src/components/auth/auth-provider.tsx +19 -31
- package/src/components/auth/email/email-localization.tsx +5 -3
- package/src/components/auth/email/index.ts +1 -0
- package/src/components/auth/email/organization-invitation.tsx +454 -0
- package/src/components/mutation-invalidator.tsx +67 -0
- package/src/index.ts +3 -0
- package/src/lib/auth-client.ts +7 -0
- package/src/lib/auth-plugin.ts +17 -0
- package/src/lib/auth-server.ts +17 -1
- package/src/lib/settings-tab.ts +21 -0
- package/src/mutations/api-key/create-api-key-mutation.ts +34 -19
- package/src/mutations/api-key/delete-api-key-mutation.ts +36 -19
- package/src/mutations/auth/sign-in-email-mutation.ts +18 -22
- package/src/mutations/auth/sign-out-mutation.ts +19 -13
- package/src/mutations/auth/sign-up-email-mutation.ts +18 -22
- package/src/mutations/multi-session/revoke-multi-session-mutation.ts +31 -20
- package/src/mutations/multi-session/set-active-session-mutation.ts +25 -44
- package/src/mutations/organization/accept-invitation-mutation.ts +71 -0
- package/src/mutations/organization/cancel-invitation-mutation.ts +67 -0
- package/src/mutations/organization/check-slug-mutation.ts +55 -0
- package/src/mutations/organization/create-organization-mutation.ts +71 -0
- package/src/mutations/organization/delete-organization-mutation.ts +71 -0
- package/src/mutations/organization/index.ts +12 -0
- package/src/mutations/organization/invite-member-mutation.ts +81 -0
- package/src/mutations/organization/leave-organization-mutation.ts +74 -0
- package/src/mutations/organization/reject-invitation-mutation.ts +64 -0
- package/src/mutations/organization/remove-member-mutation.ts +67 -0
- package/src/mutations/organization/set-active-organization-mutation.ts +142 -0
- package/src/mutations/organization/update-member-role-mutation.ts +81 -0
- package/src/mutations/organization/update-organization-mutation.ts +84 -0
- package/src/mutations/passkey/add-passkey-mutation.ts +28 -17
- package/src/mutations/passkey/delete-passkey-mutation.ts +27 -17
- package/src/mutations/passkey/sign-in-passkey-mutation.ts +18 -21
- package/src/mutations/settings/change-email-mutation.ts +22 -18
- package/src/mutations/settings/delete-user-mutation.ts +2 -2
- package/src/mutations/settings/revoke-session-mutation.ts +24 -19
- package/src/mutations/settings/unlink-account-mutation.ts +24 -17
- package/src/mutations/settings/update-user-mutation.ts +18 -30
- package/src/mutations/username/is-username-available-mutation.ts +2 -2
- package/src/mutations/username/sign-in-username-mutation.ts +20 -23
- package/src/queries/api-key/list-api-keys-query.ts +20 -8
- package/src/queries/multi-session/list-device-sessions-query.ts +2 -2
- package/src/queries/organization/active-organization-query.ts +140 -0
- package/src/queries/organization/full-organization-query.ts +113 -0
- package/src/queries/organization/has-permission-query.ts +124 -0
- package/src/queries/organization/index.ts +7 -0
- package/src/queries/organization/list-invitations-query.ts +133 -0
- package/src/queries/organization/list-members-query.ts +133 -0
- package/src/queries/organization/list-organizations-query.ts +122 -0
- package/src/queries/organization/list-user-invitations-query.ts +122 -0
- package/src/queries/passkey/list-passkeys-query.ts +2 -2
- package/src/server/queries/api-key/list-api-keys-query.ts +94 -0
- package/src/server/queries/multi-session/list-device-sessions-query.ts +2 -2
- package/src/server/queries/organization/active-organization-query.ts +92 -0
- package/src/server/queries/organization/full-organization-query.ts +64 -0
- package/src/server/queries/organization/has-permission-query.ts +66 -0
- package/src/server/queries/organization/list-invitations-query.ts +81 -0
- package/src/server/queries/organization/list-members-query.ts +75 -0
- package/src/server/queries/organization/list-organizations-query.ts +67 -0
- package/src/server/queries/organization/list-user-invitations-query.ts +68 -0
- package/src/server/queries/passkey/list-passkeys-query.ts +2 -2
- package/src/server.ts +8 -0
|
@@ -1,24 +1,33 @@
|
|
|
1
|
-
import { authMutationKeys
|
|
2
|
-
import { mutationOptions
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
import { authMutationKeys } from "@better-auth-ui/core";
|
|
2
|
+
import { mutationOptions, useMutation } from "@tanstack/react-query";
|
|
3
|
+
/**
|
|
4
|
+
* Mutation options factory for linking a social provider to the current user.
|
|
5
|
+
*
|
|
6
|
+
* @param authClient - The Better Auth client.
|
|
7
|
+
*/
|
|
8
|
+
export function linkSocialOptions(authClient) {
|
|
9
|
+
const mutationKey = authMutationKeys.linkSocial;
|
|
10
|
+
const mutationFn = (params) => authClient.linkSocial({
|
|
11
|
+
...params,
|
|
12
|
+
fetchOptions: { ...params?.fetchOptions, throw: true }
|
|
13
|
+
});
|
|
14
|
+
return mutationOptions({
|
|
15
|
+
mutationKey,
|
|
16
|
+
mutationFn
|
|
17
|
+
});
|
|
16
18
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
/**
|
|
20
|
+
* Create a mutation for linking a social provider to the current user.
|
|
21
|
+
*
|
|
22
|
+
* Wraps `authClient.linkSocial` to initiate a provider redirect and forwards
|
|
23
|
+
* React Query mutation options such as `onSuccess`, `onError`, and `retry`.
|
|
24
|
+
*
|
|
25
|
+
* @param authClient - The Better Auth client.
|
|
26
|
+
* @param options - React Query options forwarded to `useMutation`.
|
|
27
|
+
*/
|
|
28
|
+
export function useLinkSocial(authClient, options) {
|
|
29
|
+
return useMutation({
|
|
30
|
+
...linkSocialOptions(authClient),
|
|
31
|
+
...options
|
|
32
|
+
});
|
|
22
33
|
}
|
|
23
|
-
//#endregion
|
|
24
|
-
export { r as linkSocialOptions, i as useLinkSocial };
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { type QueryClient } from "@tanstack/react-query";
|
|
2
|
+
import type { BetterFetchError } from "better-auth/react";
|
|
3
|
+
import type { AuthClient } from "../../lib/auth-client";
|
|
3
4
|
export type RevokeSessionParams<TAuthClient extends AuthClient> = Parameters<TAuthClient["revokeSession"]>[0];
|
|
4
|
-
export type RevokeSessionOptions<TAuthClient extends AuthClient> = Omit<ReturnType<typeof revokeSessionOptions<TAuthClient>>, "mutationKey" | "mutationFn">;
|
|
5
|
+
export type RevokeSessionOptions<TAuthClient extends AuthClient> = Omit<ReturnType<typeof revokeSessionOptions<TAuthClient>>, "mutationKey" | "mutationFn" | "meta">;
|
|
5
6
|
/**
|
|
6
7
|
* Mutation options factory for revoking a user session.
|
|
7
8
|
*
|
|
8
9
|
* @param authClient - The Better Auth client.
|
|
9
10
|
*/
|
|
10
|
-
export declare function revokeSessionOptions<TAuthClient extends AuthClient>(authClient: TAuthClient): import(
|
|
11
|
+
export declare function revokeSessionOptions<TAuthClient extends AuthClient>(authClient: TAuthClient): import("@tanstack/react-query").WithRequired<import("@tanstack/react-query").UseMutationOptions<{
|
|
11
12
|
status: boolean;
|
|
12
13
|
}, BetterFetchError, RevokeSessionParams<TAuthClient>, unknown>, "mutationKey">;
|
|
13
14
|
/**
|
|
14
15
|
* Create a mutation for revoking a user session.
|
|
15
16
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* and `retry`.
|
|
17
|
+
* On success, `MutationInvalidator` awaits invalidation of the sessions
|
|
18
|
+
* list (see `meta.awaits`).
|
|
19
19
|
*
|
|
20
20
|
* @param authClient - The Better Auth client.
|
|
21
21
|
* @param options - React Query options forwarded to `useMutation`.
|
|
22
22
|
*/
|
|
23
|
-
export declare function useRevokeSession<TAuthClient extends AuthClient>(authClient: TAuthClient, options?: RevokeSessionOptions<TAuthClient
|
|
23
|
+
export declare function useRevokeSession<TAuthClient extends AuthClient>(authClient: TAuthClient, options?: RevokeSessionOptions<TAuthClient>, queryClient?: QueryClient): import("@tanstack/react-query").UseMutationResult<{
|
|
24
24
|
status: boolean;
|
|
25
25
|
}, BetterFetchError, RevokeSessionParams<TAuthClient>, unknown>;
|
|
@@ -1,29 +1,39 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
import { authMutationKeys, authQueryKeys } from "@better-auth-ui/core";
|
|
2
|
+
import { mutationOptions, useMutation } from "@tanstack/react-query";
|
|
3
|
+
import { useSession } from "../../queries/auth/session-query";
|
|
4
|
+
/**
|
|
5
|
+
* Mutation options factory for revoking a user session.
|
|
6
|
+
*
|
|
7
|
+
* @param authClient - The Better Auth client.
|
|
8
|
+
*/
|
|
9
|
+
export function revokeSessionOptions(authClient) {
|
|
10
|
+
const mutationKey = authMutationKeys.revokeSession;
|
|
11
|
+
const mutationFn = (params) => authClient.revokeSession({
|
|
12
|
+
...params,
|
|
13
|
+
fetchOptions: { ...params?.fetchOptions, throw: true }
|
|
14
|
+
});
|
|
15
|
+
return mutationOptions({
|
|
16
|
+
mutationKey,
|
|
17
|
+
mutationFn
|
|
18
|
+
});
|
|
17
19
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
/**
|
|
21
|
+
* Create a mutation for revoking a user session.
|
|
22
|
+
*
|
|
23
|
+
* On success, `MutationInvalidator` awaits invalidation of the sessions
|
|
24
|
+
* list (see `meta.awaits`).
|
|
25
|
+
*
|
|
26
|
+
* @param authClient - The Better Auth client.
|
|
27
|
+
* @param options - React Query options forwarded to `useMutation`.
|
|
28
|
+
*/
|
|
29
|
+
export function useRevokeSession(authClient, options, queryClient) {
|
|
30
|
+
const { data: session } = useSession(authClient, undefined, queryClient);
|
|
31
|
+
const userId = session?.user.id;
|
|
32
|
+
return useMutation({
|
|
33
|
+
...revokeSessionOptions(authClient),
|
|
34
|
+
...options,
|
|
35
|
+
meta: {
|
|
36
|
+
awaits: [authQueryKeys.listSessions(userId)]
|
|
37
|
+
}
|
|
38
|
+
}, queryClient);
|
|
27
39
|
}
|
|
28
|
-
//#endregion
|
|
29
|
-
export { i as revokeSessionOptions, a as useRevokeSession };
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { type QueryClient } from "@tanstack/react-query";
|
|
2
|
+
import type { BetterFetchError } from "better-auth/react";
|
|
3
|
+
import type { AuthClient } from "../../lib/auth-client";
|
|
3
4
|
export type UnlinkAccountParams<TAuthClient extends AuthClient> = Parameters<TAuthClient["unlinkAccount"]>[0];
|
|
4
|
-
export type UnlinkAccountOptions<TAuthClient extends AuthClient> = Omit<ReturnType<typeof unlinkAccountOptions<TAuthClient>>, "mutationKey" | "mutationFn">;
|
|
5
|
+
export type UnlinkAccountOptions<TAuthClient extends AuthClient> = Omit<ReturnType<typeof unlinkAccountOptions<TAuthClient>>, "mutationKey" | "mutationFn" | "meta">;
|
|
5
6
|
/**
|
|
6
7
|
* Mutation options factory for unlinking a social provider from the current user.
|
|
7
8
|
*
|
|
8
9
|
* @param authClient - The Better Auth client.
|
|
9
10
|
*/
|
|
10
|
-
export declare function unlinkAccountOptions<TAuthClient extends AuthClient>(authClient: TAuthClient): import(
|
|
11
|
+
export declare function unlinkAccountOptions<TAuthClient extends AuthClient>(authClient: TAuthClient): import("@tanstack/react-query").WithRequired<import("@tanstack/react-query").UseMutationOptions<{
|
|
11
12
|
status: boolean;
|
|
12
13
|
}, BetterFetchError, UnlinkAccountParams<TAuthClient>, unknown>, "mutationKey">;
|
|
13
14
|
/**
|
|
14
15
|
* Create a mutation for unlinking a social provider from the current user.
|
|
15
16
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* `onError`, and `retry`.
|
|
17
|
+
* On success, `MutationInvalidator` awaits invalidation of the linked
|
|
18
|
+
* accounts list (see `meta.awaits`).
|
|
19
19
|
*
|
|
20
20
|
* @param authClient - The Better Auth client.
|
|
21
21
|
* @param options - React Query options forwarded to `useMutation`.
|
|
22
22
|
*/
|
|
23
|
-
export declare function useUnlinkAccount<TAuthClient extends AuthClient>(authClient: TAuthClient, options?: UnlinkAccountOptions<TAuthClient
|
|
23
|
+
export declare function useUnlinkAccount<TAuthClient extends AuthClient>(authClient: TAuthClient, options?: UnlinkAccountOptions<TAuthClient>, queryClient?: QueryClient): import("@tanstack/react-query").UseMutationResult<{
|
|
24
24
|
status: boolean;
|
|
25
25
|
}, BetterFetchError, UnlinkAccountParams<TAuthClient>, unknown>;
|
|
@@ -1,29 +1,39 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
import { authMutationKeys, authQueryKeys } from "@better-auth-ui/core";
|
|
2
|
+
import { mutationOptions, useMutation } from "@tanstack/react-query";
|
|
3
|
+
import { useSession } from "../../queries/auth/session-query";
|
|
4
|
+
/**
|
|
5
|
+
* Mutation options factory for unlinking a social provider from the current user.
|
|
6
|
+
*
|
|
7
|
+
* @param authClient - The Better Auth client.
|
|
8
|
+
*/
|
|
9
|
+
export function unlinkAccountOptions(authClient) {
|
|
10
|
+
const mutationKey = authMutationKeys.unlinkAccount;
|
|
11
|
+
const mutationFn = (params) => authClient.unlinkAccount({
|
|
12
|
+
...params,
|
|
13
|
+
fetchOptions: { ...params?.fetchOptions, throw: true }
|
|
14
|
+
});
|
|
15
|
+
return mutationOptions({
|
|
16
|
+
mutationKey,
|
|
17
|
+
mutationFn
|
|
18
|
+
});
|
|
17
19
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
/**
|
|
21
|
+
* Create a mutation for unlinking a social provider from the current user.
|
|
22
|
+
*
|
|
23
|
+
* On success, `MutationInvalidator` awaits invalidation of the linked
|
|
24
|
+
* accounts list (see `meta.awaits`).
|
|
25
|
+
*
|
|
26
|
+
* @param authClient - The Better Auth client.
|
|
27
|
+
* @param options - React Query options forwarded to `useMutation`.
|
|
28
|
+
*/
|
|
29
|
+
export function useUnlinkAccount(authClient, options, queryClient) {
|
|
30
|
+
const { data: session } = useSession(authClient, undefined, queryClient);
|
|
31
|
+
const userId = session?.user.id;
|
|
32
|
+
return useMutation({
|
|
33
|
+
...unlinkAccountOptions(authClient),
|
|
34
|
+
...options,
|
|
35
|
+
meta: {
|
|
36
|
+
awaits: [authQueryKeys.listAccounts(userId)]
|
|
37
|
+
}
|
|
38
|
+
}, queryClient);
|
|
27
39
|
}
|
|
28
|
-
//#endregion
|
|
29
|
-
export { i as unlinkAccountOptions, a as useUnlinkAccount };
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { type QueryClient } from "@tanstack/react-query";
|
|
2
|
+
import type { BetterFetchError } from "better-auth/react";
|
|
3
|
+
import type { AuthClient } from "../../lib/auth-client";
|
|
3
4
|
export type UpdateUserParams<TAuthClient extends AuthClient> = Parameters<TAuthClient["updateUser"]>[0];
|
|
4
|
-
export type UpdateUserOptions<TAuthClient extends AuthClient> = Omit<ReturnType<typeof updateUserOptions<TAuthClient>>, "mutationKey" | "mutationFn">;
|
|
5
|
+
export type UpdateUserOptions<TAuthClient extends AuthClient> = Omit<ReturnType<typeof updateUserOptions<TAuthClient>>, "mutationKey" | "mutationFn" | "meta">;
|
|
5
6
|
/**
|
|
6
7
|
* Mutation options factory for updating the authenticated user's profile.
|
|
7
8
|
*
|
|
8
9
|
* @param authClient - The Better Auth client.
|
|
9
10
|
*/
|
|
10
|
-
export declare function updateUserOptions<TAuthClient extends AuthClient>(authClient: TAuthClient): import(
|
|
11
|
+
export declare function updateUserOptions<TAuthClient extends AuthClient>(authClient: TAuthClient): import("@tanstack/react-query").WithRequired<import("@tanstack/react-query").UseMutationOptions<{
|
|
11
12
|
status: boolean;
|
|
12
13
|
}, BetterFetchError, UpdateUserParams<TAuthClient>, unknown>, "mutationKey">;
|
|
13
14
|
/**
|
|
14
15
|
* Create a mutation for updating the authenticated user's profile.
|
|
15
16
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* mutation options such as `onSuccess`, `onError`, and `retry`.
|
|
17
|
+
* On success, `MutationInvalidator` awaits invalidation of the session
|
|
18
|
+
* query so the updated user fields are reflected (see `meta.awaits`).
|
|
19
19
|
*
|
|
20
20
|
* @param authClient - The Better Auth client.
|
|
21
21
|
* @param options - React Query options forwarded to `useMutation`.
|
|
22
22
|
*/
|
|
23
|
-
export declare function useUpdateUser<TAuthClient extends AuthClient>(authClient: TAuthClient, options?: UpdateUserOptions<TAuthClient
|
|
23
|
+
export declare function useUpdateUser<TAuthClient extends AuthClient>(authClient: TAuthClient, options?: UpdateUserOptions<TAuthClient>, queryClient?: QueryClient): import("@tanstack/react-query").UseMutationResult<{
|
|
24
24
|
status: boolean;
|
|
25
25
|
}, BetterFetchError, UpdateUserParams<TAuthClient>, unknown>;
|
|
@@ -1,35 +1,36 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
import { authMutationKeys, authQueryKeys } from "@better-auth-ui/core";
|
|
2
|
+
import { mutationOptions, useMutation } from "@tanstack/react-query";
|
|
3
|
+
/**
|
|
4
|
+
* Mutation options factory for updating the authenticated user's profile.
|
|
5
|
+
*
|
|
6
|
+
* @param authClient - The Better Auth client.
|
|
7
|
+
*/
|
|
8
|
+
export function updateUserOptions(authClient) {
|
|
9
|
+
const mutationKey = authMutationKeys.updateUser;
|
|
10
|
+
const mutationFn = (params) => authClient.updateUser({
|
|
11
|
+
...params,
|
|
12
|
+
fetchOptions: { ...params?.fetchOptions, throw: true }
|
|
13
|
+
});
|
|
14
|
+
return mutationOptions({
|
|
15
|
+
mutationKey,
|
|
16
|
+
mutationFn
|
|
17
|
+
});
|
|
17
18
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
19
|
+
/**
|
|
20
|
+
* Create a mutation for updating the authenticated user's profile.
|
|
21
|
+
*
|
|
22
|
+
* On success, `MutationInvalidator` awaits invalidation of the session
|
|
23
|
+
* query so the updated user fields are reflected (see `meta.awaits`).
|
|
24
|
+
*
|
|
25
|
+
* @param authClient - The Better Auth client.
|
|
26
|
+
* @param options - React Query options forwarded to `useMutation`.
|
|
27
|
+
*/
|
|
28
|
+
export function useUpdateUser(authClient, options, queryClient) {
|
|
29
|
+
return useMutation({
|
|
30
|
+
...updateUserOptions(authClient),
|
|
31
|
+
...options,
|
|
32
|
+
meta: {
|
|
33
|
+
awaits: [authQueryKeys.session]
|
|
34
|
+
}
|
|
35
|
+
}, queryClient);
|
|
33
36
|
}
|
|
34
|
-
//#endregion
|
|
35
|
-
export { o as updateUserOptions, s as useUpdateUser };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { BetterFetchError } from
|
|
2
|
-
import { UsernameAuthClient } from
|
|
1
|
+
import type { BetterFetchError } from "better-auth/react";
|
|
2
|
+
import type { UsernameAuthClient } from "../../lib/auth-client";
|
|
3
3
|
export type IsUsernameAvailableParams<TAuthClient extends UsernameAuthClient> = Parameters<TAuthClient["isUsernameAvailable"]>[0];
|
|
4
4
|
export type IsUsernameAvailableOptions<TAuthClient extends UsernameAuthClient> = Omit<ReturnType<typeof isUsernameAvailableOptions<TAuthClient>>, "mutationKey" | "mutationFn">;
|
|
5
5
|
/**
|
|
@@ -10,7 +10,7 @@ export type IsUsernameAvailableOptions<TAuthClient extends UsernameAuthClient> =
|
|
|
10
10
|
*
|
|
11
11
|
* @param authClient - The Better Auth client.
|
|
12
12
|
*/
|
|
13
|
-
export declare function isUsernameAvailableOptions<TAuthClient extends UsernameAuthClient>(authClient: TAuthClient): import(
|
|
13
|
+
export declare function isUsernameAvailableOptions<TAuthClient extends UsernameAuthClient>(authClient: TAuthClient): import("@tanstack/react-query").WithRequired<import("@tanstack/react-query").UseMutationOptions<{
|
|
14
14
|
available: boolean;
|
|
15
15
|
}, BetterFetchError, IsUsernameAvailableParams<TAuthClient>, unknown>, "mutationKey">;
|
|
16
16
|
/**
|
|
@@ -22,6 +22,6 @@ export declare function isUsernameAvailableOptions<TAuthClient extends UsernameA
|
|
|
22
22
|
* @param authClient - The Better Auth client with the username plugin.
|
|
23
23
|
* @param options - React Query options forwarded to `useMutation`.
|
|
24
24
|
*/
|
|
25
|
-
export declare function useIsUsernameAvailable<TAuthClient extends UsernameAuthClient>(authClient: TAuthClient, options?: IsUsernameAvailableOptions<TAuthClient>): import(
|
|
25
|
+
export declare function useIsUsernameAvailable<TAuthClient extends UsernameAuthClient>(authClient: TAuthClient, options?: IsUsernameAvailableOptions<TAuthClient>): import("@tanstack/react-query").UseMutationResult<{
|
|
26
26
|
available: boolean;
|
|
27
27
|
}, BetterFetchError, IsUsernameAvailableParams<TAuthClient>, unknown>;
|
|
@@ -1,24 +1,36 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { mutationOptions
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
import { usernameMutationKeys } from "@better-auth-ui/core/plugins";
|
|
2
|
+
import { mutationOptions, useMutation } from "@tanstack/react-query";
|
|
3
|
+
/**
|
|
4
|
+
* Mutation options factory for checking username availability.
|
|
5
|
+
*
|
|
6
|
+
* Modeled as a mutation because callers typically trigger the check on
|
|
7
|
+
* user action (debounced input, form submit) rather than on mount.
|
|
8
|
+
*
|
|
9
|
+
* @param authClient - The Better Auth client.
|
|
10
|
+
*/
|
|
11
|
+
export function isUsernameAvailableOptions(authClient) {
|
|
12
|
+
const mutationKey = usernameMutationKeys.isUsernameAvailable;
|
|
13
|
+
const mutationFn = (params) => authClient.isUsernameAvailable({
|
|
14
|
+
...params,
|
|
15
|
+
fetchOptions: { ...params?.fetchOptions, throw: true }
|
|
16
|
+
});
|
|
17
|
+
return mutationOptions({
|
|
18
|
+
mutationKey,
|
|
19
|
+
mutationFn
|
|
20
|
+
});
|
|
16
21
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
+
/**
|
|
23
|
+
* Create a mutation for checking whether a username is available.
|
|
24
|
+
*
|
|
25
|
+
* Wraps `authClient.isUsernameAvailable` and forwards React Query mutation
|
|
26
|
+
* options such as `onSuccess`, `onError`, and `retry`.
|
|
27
|
+
*
|
|
28
|
+
* @param authClient - The Better Auth client with the username plugin.
|
|
29
|
+
* @param options - React Query options forwarded to `useMutation`.
|
|
30
|
+
*/
|
|
31
|
+
export function useIsUsernameAvailable(authClient, options) {
|
|
32
|
+
return useMutation({
|
|
33
|
+
...isUsernameAvailableOptions(authClient),
|
|
34
|
+
...options
|
|
35
|
+
});
|
|
22
36
|
}
|
|
23
|
-
//#endregion
|
|
24
|
-
export { r as isUsernameAvailableOptions, i as useIsUsernameAvailable };
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { type QueryClient } from "@tanstack/react-query";
|
|
2
|
+
import type { BetterFetchError } from "better-auth/react";
|
|
3
|
+
import type { UsernameAuthClient } from "../../lib/auth-client";
|
|
3
4
|
export type SignInUsernameParams<TAuthClient extends UsernameAuthClient> = Parameters<TAuthClient["signIn"]["username"]>[0];
|
|
4
|
-
export type SignInUsernameOptions<TAuthClient extends UsernameAuthClient> = Omit<ReturnType<typeof signInUsernameOptions<TAuthClient>>, "mutationKey" | "mutationFn">;
|
|
5
|
+
export type SignInUsernameOptions<TAuthClient extends UsernameAuthClient> = Omit<ReturnType<typeof signInUsernameOptions<TAuthClient>>, "mutationKey" | "mutationFn" | "meta">;
|
|
5
6
|
/**
|
|
6
7
|
* Mutation options factory for username/password sign-in.
|
|
7
8
|
*
|
|
8
9
|
* @param authClient - The Better Auth client.
|
|
9
10
|
*/
|
|
10
|
-
export declare function signInUsernameOptions<TAuthClient extends UsernameAuthClient>(authClient: TAuthClient): import(
|
|
11
|
+
export declare function signInUsernameOptions<TAuthClient extends UsernameAuthClient>(authClient: TAuthClient): import("@tanstack/react-query").WithRequired<import("@tanstack/react-query").UseMutationOptions<Omit<{
|
|
11
12
|
redirect: boolean;
|
|
12
13
|
token: string;
|
|
13
14
|
url: string | undefined;
|
|
@@ -24,7 +25,7 @@ export declare function signInUsernameOptions<TAuthClient extends UsernameAuthCl
|
|
|
24
25
|
displayUsername: string;
|
|
25
26
|
};
|
|
26
27
|
}, "user"> & {
|
|
27
|
-
user: import(
|
|
28
|
+
user: import("better-auth").StripEmptyObjects<{
|
|
28
29
|
id: string;
|
|
29
30
|
createdAt: Date;
|
|
30
31
|
updatedAt: Date;
|
|
@@ -40,14 +41,13 @@ export declare function signInUsernameOptions<TAuthClient extends UsernameAuthCl
|
|
|
40
41
|
/**
|
|
41
42
|
* Create a mutation for username/password sign-in.
|
|
42
43
|
*
|
|
43
|
-
*
|
|
44
|
-
* the new session is refetched
|
|
45
|
-
* such as `onSuccess`, `onError`, and `retry`.
|
|
44
|
+
* On success, `MutationInvalidator` awaits invalidation of the session
|
|
45
|
+
* query so the new session is refetched (see `meta.awaits`).
|
|
46
46
|
*
|
|
47
47
|
* @param authClient - The Better Auth client with the username plugin.
|
|
48
48
|
* @param options - React Query options forwarded to `useMutation`.
|
|
49
49
|
*/
|
|
50
|
-
export declare function useSignInUsername<TAuthClient extends UsernameAuthClient>(authClient: TAuthClient, options?: SignInUsernameOptions<TAuthClient
|
|
50
|
+
export declare function useSignInUsername<TAuthClient extends UsernameAuthClient>(authClient: TAuthClient, options?: SignInUsernameOptions<TAuthClient>, queryClient?: QueryClient): import("@tanstack/react-query").UseMutationResult<Omit<{
|
|
51
51
|
redirect: boolean;
|
|
52
52
|
token: string;
|
|
53
53
|
url: string | undefined;
|
|
@@ -64,7 +64,7 @@ export declare function useSignInUsername<TAuthClient extends UsernameAuthClient
|
|
|
64
64
|
displayUsername: string;
|
|
65
65
|
};
|
|
66
66
|
}, "user"> & {
|
|
67
|
-
user: import(
|
|
67
|
+
user: import("better-auth").StripEmptyObjects<{
|
|
68
68
|
id: string;
|
|
69
69
|
createdAt: Date;
|
|
70
70
|
updatedAt: Date;
|
|
@@ -1,29 +1,37 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { mutationOptions
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
import { authQueryKeys } from "@better-auth-ui/core";
|
|
2
|
+
import { usernameMutationKeys } from "@better-auth-ui/core/plugins";
|
|
3
|
+
import { mutationOptions, useMutation } from "@tanstack/react-query";
|
|
4
|
+
/**
|
|
5
|
+
* Mutation options factory for username/password sign-in.
|
|
6
|
+
*
|
|
7
|
+
* @param authClient - The Better Auth client.
|
|
8
|
+
*/
|
|
9
|
+
export function signInUsernameOptions(authClient) {
|
|
10
|
+
const mutationKey = usernameMutationKeys.signIn;
|
|
11
|
+
const mutationFn = (params) => authClient.signIn.username({
|
|
12
|
+
...params,
|
|
13
|
+
fetchOptions: { ...params?.fetchOptions, throw: true }
|
|
14
|
+
});
|
|
15
|
+
return mutationOptions({
|
|
16
|
+
mutationKey,
|
|
17
|
+
mutationFn
|
|
18
|
+
});
|
|
17
19
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
/**
|
|
21
|
+
* Create a mutation for username/password sign-in.
|
|
22
|
+
*
|
|
23
|
+
* On success, `MutationInvalidator` awaits invalidation of the session
|
|
24
|
+
* query so the new session is refetched (see `meta.awaits`).
|
|
25
|
+
*
|
|
26
|
+
* @param authClient - The Better Auth client with the username plugin.
|
|
27
|
+
* @param options - React Query options forwarded to `useMutation`.
|
|
28
|
+
*/
|
|
29
|
+
export function useSignInUsername(authClient, options, queryClient) {
|
|
30
|
+
return useMutation({
|
|
31
|
+
...signInUsernameOptions(authClient),
|
|
32
|
+
...options,
|
|
33
|
+
meta: {
|
|
34
|
+
awaits: [authQueryKeys.session]
|
|
35
|
+
}
|
|
36
|
+
}, queryClient);
|
|
27
37
|
}
|
|
28
|
-
//#endregion
|
|
29
|
-
export { a as signInUsernameOptions, o as useSignInUsername };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ComponentType } from
|
|
1
|
+
import { type ComponentType } from "react";
|
|
2
2
|
/** Props passed to the consumer's `render` component. */
|
|
3
3
|
export type CaptchaRenderProps = {
|
|
4
4
|
/** Call once the user solves the captcha. */
|
|
@@ -19,10 +19,10 @@ export type CaptchaPluginOptions = {
|
|
|
19
19
|
* Provider-agnostic captcha plugin. Forwards the resolved token via the
|
|
20
20
|
* `x-captcha-response` header on Better Auth requests.
|
|
21
21
|
*/
|
|
22
|
-
export declare const captchaPlugin: ((args_0: CaptchaPluginOptions) =>
|
|
22
|
+
export declare const captchaPlugin: ((args_0: CaptchaPluginOptions) => {
|
|
23
23
|
render: ComponentType<CaptchaRenderProps>;
|
|
24
24
|
captchaComponent: import("react/jsx-runtime").JSX.Element;
|
|
25
|
-
}
|
|
25
|
+
} & {
|
|
26
26
|
id: "captcha";
|
|
27
27
|
}) & {
|
|
28
28
|
id: "captcha";
|