@better-auth-ui/react 1.6.2 → 1.6.4
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 +23 -8
- package/dist/components/auth/auth-provider.js +32 -17
- package/dist/components/{email → auth/email}/email-changed.js +2 -2
- package/dist/components/{email → auth/email}/email-localization.js +1 -1
- package/dist/components/{email → auth/email}/email-styles.js +1 -1
- package/dist/components/{email → auth/email}/email-verification.js +2 -2
- package/dist/components/{email → auth/email}/magic-link.js +2 -2
- package/dist/components/{email → auth/email}/new-device.js +2 -2
- package/dist/components/{email → auth/email}/otp-email.js +2 -2
- package/dist/components/{email → auth/email}/password-changed.js +2 -2
- package/dist/components/{email → auth/email}/reset-password.js +2 -2
- package/dist/email.d.ts +1 -0
- package/dist/email.js +11 -0
- package/dist/hooks/auth/use-authenticate.d.ts +6 -5
- package/dist/hooks/auth/use-authenticate.js +12 -12
- package/dist/hooks/auth/use-user.d.ts +18 -311
- package/dist/hooks/auth/use-user.js +5 -5
- package/dist/hooks/use-auth-mutation.d.ts +17 -0
- package/dist/hooks/use-auth-mutation.js +11 -0
- package/dist/hooks/use-auth-plugin.d.ts +31 -0
- package/dist/hooks/use-auth-plugin.js +10 -0
- package/dist/hooks/use-auth-query.d.ts +14 -0
- package/dist/hooks/use-auth-query.js +15 -0
- package/dist/index.d.ts +35 -34
- package/dist/index.js +74 -83
- package/dist/lib/auth-client.d.ts +23 -3687
- package/dist/lib/auth-plugin.d.ts +59 -0
- package/dist/lib/auth-server.d.ts +16 -0
- package/dist/mutations/auth/request-password-reset-mutation.d.ts +26 -0
- package/dist/mutations/auth/request-password-reset-mutation.js +24 -0
- package/dist/mutations/auth/reset-password-mutation.d.ts +25 -0
- package/dist/mutations/auth/reset-password-mutation.js +24 -0
- package/dist/mutations/auth/send-verification-email-mutation.d.ts +24 -0
- package/dist/mutations/auth/send-verification-email-mutation.js +24 -0
- package/dist/mutations/auth/sign-in-email-mutation.d.ts +71 -0
- package/dist/mutations/auth/sign-in-email-mutation.js +29 -0
- package/dist/mutations/auth/sign-in-social-mutation.d.ts +77 -0
- package/dist/mutations/auth/sign-in-social-mutation.js +24 -0
- package/dist/mutations/auth/sign-out-mutation.d.ts +25 -0
- package/dist/mutations/auth/sign-out-mutation.js +28 -0
- package/dist/mutations/auth/sign-up-email-mutation.d.ts +105 -0
- package/dist/mutations/auth/sign-up-email-mutation.js +29 -0
- package/dist/mutations/auth-mutation-options.d.ts +42 -0
- package/dist/mutations/auth-mutation-options.js +19 -0
- package/dist/mutations/magic-link/sign-in-magic-link-mutation.d.ts +24 -0
- package/dist/mutations/magic-link/sign-in-magic-link-mutation.js +24 -0
- package/dist/mutations/multi-session/revoke-multi-session-mutation.d.ts +25 -0
- package/dist/mutations/multi-session/revoke-multi-session-mutation.js +29 -0
- package/dist/mutations/multi-session/set-active-session-mutation.d.ts +62 -0
- package/dist/mutations/multi-session/set-active-session-mutation.js +31 -0
- package/dist/mutations/passkey/add-passkey-mutation.d.ts +71 -0
- package/dist/mutations/passkey/add-passkey-mutation.js +29 -0
- package/dist/mutations/passkey/delete-passkey-mutation.d.ts +25 -0
- package/dist/mutations/passkey/delete-passkey-mutation.js +29 -0
- package/dist/mutations/passkey/sign-in-passkey-mutation.d.ts +105 -0
- package/dist/mutations/passkey/sign-in-passkey-mutation.js +29 -0
- package/dist/mutations/settings/change-email-mutation.d.ts +25 -0
- package/dist/mutations/settings/change-email-mutation.js +29 -0
- package/dist/mutations/settings/change-password-mutation.d.ts +78 -0
- package/dist/mutations/settings/change-password-mutation.js +24 -0
- package/dist/mutations/settings/delete-user-mutation.d.ts +26 -0
- package/dist/mutations/settings/delete-user-mutation.js +24 -0
- package/dist/mutations/settings/link-social-mutation.d.ts +26 -0
- package/dist/mutations/settings/link-social-mutation.js +24 -0
- package/dist/mutations/settings/revoke-session-mutation.d.ts +25 -0
- package/dist/mutations/settings/revoke-session-mutation.js +29 -0
- package/dist/mutations/settings/unlink-account-mutation.d.ts +25 -0
- package/dist/mutations/settings/unlink-account-mutation.js +29 -0
- package/dist/mutations/settings/update-user-mutation.d.ts +25 -0
- package/dist/mutations/settings/update-user-mutation.js +35 -0
- package/dist/mutations/username/is-username-available-mutation.d.ts +27 -0
- package/dist/mutations/username/is-username-available-mutation.js +24 -0
- package/dist/mutations/username/sign-in-username-mutation.d.ts +75 -0
- package/dist/mutations/username/sign-in-username-mutation.js +29 -0
- package/dist/queries/auth/session-query.d.ts +71 -0
- package/dist/queries/auth/session-query.js +30 -0
- package/dist/queries/auth-query-options.d.ts +40 -0
- package/dist/queries/auth-query-options.js +17 -0
- package/dist/queries/multi-session/list-device-sessions-query.d.ts +76 -0
- package/dist/queries/multi-session/list-device-sessions-query.js +31 -0
- package/dist/queries/passkey/list-passkeys-query.d.ts +74 -0
- package/dist/queries/passkey/list-passkeys-query.js +31 -0
- package/dist/queries/settings/account-info-query.d.ts +85 -0
- package/dist/queries/settings/account-info-query.js +31 -0
- package/dist/queries/settings/list-accounts-query.d.ts +76 -0
- package/dist/queries/settings/list-accounts-query.js +31 -0
- package/dist/queries/settings/list-sessions-query.d.ts +74 -0
- package/dist/queries/settings/list-sessions-query.js +31 -0
- package/dist/server/queries/auth/session-query.d.ts +57 -0
- package/dist/server/queries/auth/session-query.js +13 -0
- package/dist/server/queries/multi-session/list-device-sessions-query.d.ts +60 -0
- package/dist/server/queries/multi-session/list-device-sessions-query.js +12 -0
- package/dist/server/queries/passkey/list-passkeys-query.d.ts +60 -0
- package/dist/server/queries/passkey/list-passkeys-query.js +12 -0
- package/dist/server/queries/settings/account-info-query.d.ts +68 -0
- package/dist/server/queries/settings/account-info-query.js +12 -0
- package/dist/server/queries/settings/list-accounts-query.d.ts +60 -0
- package/dist/server/queries/settings/list-accounts-query.js +12 -0
- package/dist/server/queries/settings/list-sessions-query.d.ts +60 -0
- package/dist/server/queries/settings/list-sessions-query.js +12 -0
- package/dist/server.d.ts +7 -0
- package/dist/server.js +7 -0
- package/package.json +24 -22
- package/src/components/auth/auth-provider.tsx +87 -24
- package/src/components/{email → auth/email}/email-changed.tsx +1 -1
- package/src/components/{email → auth/email}/email-verification.tsx +1 -1
- package/src/components/{email → auth/email}/magic-link.tsx +1 -1
- package/src/components/{email → auth/email}/new-device.tsx +1 -1
- package/src/components/{email → auth/email}/otp-email.tsx +1 -1
- package/src/components/{email → auth/email}/password-changed.tsx +1 -1
- package/src/components/{email → auth/email}/reset-password.tsx +1 -1
- package/src/email.ts +1 -0
- package/src/hooks/auth/use-authenticate.ts +13 -10
- package/src/hooks/auth/use-user.ts +12 -8
- package/src/hooks/use-auth-mutation.ts +47 -0
- package/src/hooks/use-auth-plugin.ts +50 -0
- package/src/hooks/use-auth-query.ts +40 -0
- package/src/index.ts +35 -34
- package/src/lib/auth-client.ts +33 -31
- package/src/lib/auth-plugin.ts +75 -0
- package/src/lib/auth-server.ts +30 -0
- package/src/mutations/auth/request-password-reset-mutation.ts +58 -0
- package/src/mutations/auth/reset-password-mutation.ts +60 -0
- package/src/mutations/auth/send-verification-email-mutation.ts +58 -0
- package/src/mutations/auth/sign-in-email-mutation.ts +78 -0
- package/src/mutations/auth/sign-in-social-mutation.ts +64 -0
- package/src/mutations/auth/sign-out-mutation.ts +71 -0
- package/src/mutations/auth/sign-up-email-mutation.ts +74 -0
- package/src/mutations/auth-mutation-options.ts +94 -0
- package/src/mutations/magic-link/sign-in-magic-link-mutation.ts +59 -0
- package/src/mutations/multi-session/revoke-multi-session-mutation.ts +70 -0
- package/src/mutations/multi-session/set-active-session-mutation.ts +98 -0
- package/src/mutations/passkey/add-passkey-mutation.ts +66 -0
- package/src/mutations/passkey/delete-passkey-mutation.ts +66 -0
- package/src/mutations/passkey/sign-in-passkey-mutation.ts +74 -0
- package/src/mutations/settings/change-email-mutation.ts +67 -0
- package/src/mutations/settings/change-password-mutation.ts +59 -0
- package/src/mutations/settings/delete-user-mutation.ts +59 -0
- package/src/mutations/settings/link-social-mutation.ts +59 -0
- package/src/mutations/settings/revoke-session-mutation.ts +69 -0
- package/src/mutations/settings/unlink-account-mutation.ts +67 -0
- package/src/mutations/settings/update-user-mutation.ts +82 -0
- package/src/mutations/username/is-username-available-mutation.ts +62 -0
- package/src/mutations/username/sign-in-username-mutation.ts +74 -0
- package/src/queries/auth/session-query.ts +135 -0
- package/src/queries/auth-query-options.ts +83 -0
- package/src/queries/multi-session/list-device-sessions-query.ts +177 -0
- package/src/queries/passkey/list-passkeys-query.ts +154 -0
- package/src/queries/settings/account-info-query.ts +158 -0
- package/src/queries/settings/list-accounts-query.ts +156 -0
- package/src/queries/settings/list-sessions-query.ts +154 -0
- package/src/server/queries/auth/session-query.ts +94 -0
- package/src/server/queries/multi-session/list-device-sessions-query.ts +102 -0
- package/src/server/queries/passkey/list-passkeys-query.ts +100 -0
- package/src/server/queries/settings/account-info-query.ts +101 -0
- package/src/server/queries/settings/list-accounts-query.ts +101 -0
- package/src/server/queries/settings/list-sessions-query.ts +101 -0
- package/src/server.ts +7 -0
- package/dist/core.d.ts +0 -1
- package/dist/core.js +0 -1
- package/dist/hooks/auth/use-auth-mutation.d.ts +0 -18
- package/dist/hooks/auth/use-auth-mutation.js +0 -13
- package/dist/hooks/auth/use-auth-query.d.ts +0 -24
- package/dist/hooks/auth/use-auth-query.js +0 -13
- package/dist/hooks/auth/use-is-username-available.d.ts +0 -19
- package/dist/hooks/auth/use-is-username-available.js +0 -12
- package/dist/hooks/auth/use-request-password-reset.d.ts +0 -25
- package/dist/hooks/auth/use-request-password-reset.js +0 -12
- package/dist/hooks/auth/use-reset-password.d.ts +0 -39
- package/dist/hooks/auth/use-reset-password.js +0 -12
- package/dist/hooks/auth/use-send-verification-email.d.ts +0 -23
- package/dist/hooks/auth/use-send-verification-email.js +0 -12
- package/dist/hooks/auth/use-session.d.ts +0 -9
- package/dist/hooks/auth/use-session.js +0 -15
- package/dist/hooks/auth/use-sign-in-email.d.ts +0 -52
- package/dist/hooks/auth/use-sign-in-email.js +0 -18
- package/dist/hooks/auth/use-sign-in-magic-link.d.ts +0 -31
- package/dist/hooks/auth/use-sign-in-magic-link.js +0 -12
- package/dist/hooks/auth/use-sign-in-passkey.d.ts +0 -58
- package/dist/hooks/auth/use-sign-in-passkey.js +0 -18
- package/dist/hooks/auth/use-sign-in-social.d.ts +0 -92
- package/dist/hooks/auth/use-sign-in-social.js +0 -12
- package/dist/hooks/auth/use-sign-in-username.d.ts +0 -53
- package/dist/hooks/auth/use-sign-in-username.js +0 -18
- package/dist/hooks/auth/use-sign-out.d.ts +0 -18
- package/dist/hooks/auth/use-sign-out.js +0 -18
- package/dist/hooks/auth/use-sign-up-email.d.ts +0 -1269
- package/dist/hooks/auth/use-sign-up-email.js +0 -18
- package/dist/hooks/settings/use-account-info.d.ts +0 -17
- package/dist/hooks/settings/use-account-info.js +0 -21
- package/dist/hooks/settings/use-add-passkey.d.ts +0 -43
- package/dist/hooks/settings/use-add-passkey.js +0 -18
- package/dist/hooks/settings/use-change-email.d.ts +0 -24
- package/dist/hooks/settings/use-change-email.js +0 -18
- package/dist/hooks/settings/use-change-password.d.ts +0 -53
- package/dist/hooks/settings/use-change-password.js +0 -12
- package/dist/hooks/settings/use-delete-passkey.d.ts +0 -21
- package/dist/hooks/settings/use-delete-passkey.js +0 -18
- package/dist/hooks/settings/use-delete-user.d.ts +0 -41
- package/dist/hooks/settings/use-delete-user.js +0 -12
- package/dist/hooks/settings/use-link-social.d.ts +0 -46
- package/dist/hooks/settings/use-link-social.js +0 -12
- package/dist/hooks/settings/use-list-accounts.d.ts +0 -20
- package/dist/hooks/settings/use-list-accounts.js +0 -21
- package/dist/hooks/settings/use-list-device-sessions.d.ts +0 -11
- package/dist/hooks/settings/use-list-device-sessions.js +0 -21
- package/dist/hooks/settings/use-list-sessions.d.ts +0 -20
- package/dist/hooks/settings/use-list-sessions.js +0 -21
- package/dist/hooks/settings/use-list-user-passkeys.d.ts +0 -11
- package/dist/hooks/settings/use-list-user-passkeys.js +0 -21
- package/dist/hooks/settings/use-revoke-multi-session.d.ts +0 -19
- package/dist/hooks/settings/use-revoke-multi-session.js +0 -18
- package/dist/hooks/settings/use-revoke-session.d.ts +0 -19
- package/dist/hooks/settings/use-revoke-session.js +0 -18
- package/dist/hooks/settings/use-set-active-session.d.ts +0 -37
- package/dist/hooks/settings/use-set-active-session.js +0 -21
- package/dist/hooks/settings/use-unlink-account.d.ts +0 -21
- package/dist/hooks/settings/use-unlink-account.js +0 -18
- package/dist/hooks/settings/use-update-user.d.ts +0 -11
- package/dist/hooks/settings/use-update-user.js +0 -25
- package/dist/lib/auth-client.js +0 -11
- package/dist/lib/auth-config.d.ts +0 -43
- package/dist/lib/auth-context.d.ts +0 -2
- package/dist/lib/auth-context.js +0 -6
- package/src/core.ts +0 -1
- package/src/hooks/auth/use-auth-mutation.ts +0 -56
- package/src/hooks/auth/use-auth-query.ts +0 -50
- package/src/hooks/auth/use-is-username-available.ts +0 -22
- package/src/hooks/auth/use-request-password-reset.ts +0 -22
- package/src/hooks/auth/use-reset-password.ts +0 -21
- package/src/hooks/auth/use-send-verification-email.ts +0 -21
- package/src/hooks/auth/use-session.ts +0 -27
- package/src/hooks/auth/use-sign-in-email.ts +0 -34
- package/src/hooks/auth/use-sign-in-magic-link.ts +0 -21
- package/src/hooks/auth/use-sign-in-passkey.ts +0 -34
- package/src/hooks/auth/use-sign-in-social.ts +0 -21
- package/src/hooks/auth/use-sign-in-username.ts +0 -34
- package/src/hooks/auth/use-sign-out.ts +0 -33
- package/src/hooks/auth/use-sign-up-email.ts +0 -34
- package/src/hooks/settings/use-account-info.ts +0 -31
- package/src/hooks/settings/use-add-passkey.ts +0 -32
- package/src/hooks/settings/use-change-email.ts +0 -33
- package/src/hooks/settings/use-change-password.ts +0 -19
- package/src/hooks/settings/use-delete-passkey.ts +0 -32
- package/src/hooks/settings/use-delete-user.ts +0 -19
- package/src/hooks/settings/use-link-social.ts +0 -19
- package/src/hooks/settings/use-list-accounts.ts +0 -29
- package/src/hooks/settings/use-list-device-sessions.ts +0 -34
- package/src/hooks/settings/use-list-sessions.ts +0 -28
- package/src/hooks/settings/use-list-user-passkeys.ts +0 -30
- package/src/hooks/settings/use-revoke-multi-session.ts +0 -30
- package/src/hooks/settings/use-revoke-session.ts +0 -30
- package/src/hooks/settings/use-set-active-session.ts +0 -47
- package/src/hooks/settings/use-unlink-account.ts +0 -30
- package/src/hooks/settings/use-update-user.ts +0 -43
- package/src/lib/auth-config.ts +0 -48
- package/src/lib/auth-context.ts +0 -6
- /package/dist/components/{email → auth/email}/email-changed.d.ts +0 -0
- /package/dist/components/{email → auth/email}/email-localization.d.ts +0 -0
- /package/dist/components/{email → auth/email}/email-styles.d.ts +0 -0
- /package/dist/components/{email → auth/email}/email-verification.d.ts +0 -0
- /package/dist/components/{email → auth/email}/index.d.ts +0 -0
- /package/dist/components/{email → auth/email}/index.js +0 -0
- /package/dist/components/{email → auth/email}/magic-link.d.ts +0 -0
- /package/dist/components/{email → auth/email}/new-device.d.ts +0 -0
- /package/dist/components/{email → auth/email}/otp-email.d.ts +0 -0
- /package/dist/components/{email → auth/email}/password-changed.d.ts +0 -0
- /package/dist/components/{email → auth/email}/reset-password.d.ts +0 -0
- /package/src/components/{email → auth/email}/email-localization.tsx +0 -0
- /package/src/components/{email → auth/email}/email-styles.tsx +0 -0
- /package/src/components/{email → auth/email}/index.ts +0 -0
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { AuthClient } from '../../lib/auth-client';
|
|
2
|
-
import { UseAuthMutationOptions } from '../auth/use-auth-mutation';
|
|
3
|
-
/**
|
|
4
|
-
* Hook that sets an active device session in multi-session mode.
|
|
5
|
-
*
|
|
6
|
-
* @returns The `useMutation` result.
|
|
7
|
-
*/
|
|
8
|
-
export declare function useSetActiveSession(options?: UseAuthMutationOptions<AuthClient["multiSession"]["setActive"]>): import('../..').UseAuthMutationResult<(<FetchOptions extends import('better-auth').ClientFetchOption<Partial<{
|
|
9
|
-
sessionToken: string;
|
|
10
|
-
}> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0: import('better-auth').Prettify<{
|
|
11
|
-
sessionToken: string;
|
|
12
|
-
} & {
|
|
13
|
-
fetchOptions?: FetchOptions | undefined;
|
|
14
|
-
}>, data_1?: FetchOptions | undefined) => Promise<import('better-auth/client').BetterFetchResponse<{
|
|
15
|
-
session: {
|
|
16
|
-
id: string;
|
|
17
|
-
createdAt: Date;
|
|
18
|
-
updatedAt: Date;
|
|
19
|
-
userId: string;
|
|
20
|
-
expiresAt: Date;
|
|
21
|
-
token: string;
|
|
22
|
-
ipAddress?: string | null | undefined;
|
|
23
|
-
userAgent?: string | null | undefined;
|
|
24
|
-
} & Record<string, any>;
|
|
25
|
-
user: {
|
|
26
|
-
id: string;
|
|
27
|
-
createdAt: Date;
|
|
28
|
-
updatedAt: Date;
|
|
29
|
-
email: string;
|
|
30
|
-
emailVerified: boolean;
|
|
31
|
-
name: string;
|
|
32
|
-
image?: string | null | undefined;
|
|
33
|
-
} & Record<string, any>;
|
|
34
|
-
}, {
|
|
35
|
-
code?: string | undefined;
|
|
36
|
-
message?: string | undefined;
|
|
37
|
-
}, FetchOptions["throw"] extends true ? true : false>>)>;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { useAuth as e } from "../../components/auth/auth-provider.js";
|
|
2
|
-
import { useAuthMutation as t } from "../auth/use-auth-mutation.js";
|
|
3
|
-
import { useSession as n } from "../auth/use-session.js";
|
|
4
|
-
import { useListDeviceSessions as r } from "./use-list-device-sessions.js";
|
|
5
|
-
import { useQueryClient as i } from "@tanstack/react-query";
|
|
6
|
-
//#region src/hooks/settings/use-set-active-session.ts
|
|
7
|
-
function a(a) {
|
|
8
|
-
let o = i(), { authClient: s } = e(), { refetch: c } = n({ refetchOnMount: !1 }), { data: l, refetch: u } = r({ refetchOnMount: !1 });
|
|
9
|
-
return t({
|
|
10
|
-
authFn: s.multiSession.setActive,
|
|
11
|
-
options: {
|
|
12
|
-
...a,
|
|
13
|
-
onSuccess: async (e, { sessionToken: t }, ...n) => {
|
|
14
|
-
let r = l?.find((e) => e.session.token === t);
|
|
15
|
-
r && o.setQueryData(["auth", "getSession"], r), window.scrollTo({ top: 0 }), await c(), await u(), await a?.onSuccess?.(e, { sessionToken: t }, ...n);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
//#endregion
|
|
21
|
-
export { a as useSetActiveSession };
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { AuthClient } from '../../lib/auth-client';
|
|
2
|
-
import { UseAuthMutationOptions } from '../auth/use-auth-mutation';
|
|
3
|
-
/**
|
|
4
|
-
* Hook that creates a mutation for unlinking a social provider from the current user.
|
|
5
|
-
*
|
|
6
|
-
* @returns The `useMutation` result.
|
|
7
|
-
*/
|
|
8
|
-
export declare function useUnlinkAccount(options?: UseAuthMutationOptions<AuthClient["unlinkAccount"]>): import('../..').UseAuthMutationResult<(<FetchOptions extends import('better-auth').ClientFetchOption<Partial<{
|
|
9
|
-
providerId: string;
|
|
10
|
-
accountId?: string | undefined;
|
|
11
|
-
}> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0: import('better-auth').Prettify<{
|
|
12
|
-
providerId: string;
|
|
13
|
-
accountId?: string | undefined;
|
|
14
|
-
} & {
|
|
15
|
-
fetchOptions?: FetchOptions | undefined;
|
|
16
|
-
}>, data_1?: FetchOptions | undefined) => Promise<import('better-auth/client').BetterFetchResponse<{
|
|
17
|
-
status: boolean;
|
|
18
|
-
}, {
|
|
19
|
-
code?: string | undefined;
|
|
20
|
-
message?: string | undefined;
|
|
21
|
-
}, FetchOptions["throw"] extends true ? true : false>>)>;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { useAuth as e } from "../../components/auth/auth-provider.js";
|
|
2
|
-
import { useAuthMutation as t } from "../auth/use-auth-mutation.js";
|
|
3
|
-
import { useListAccounts as n } from "./use-list-accounts.js";
|
|
4
|
-
//#region src/hooks/settings/use-unlink-account.ts
|
|
5
|
-
function r(r) {
|
|
6
|
-
let { authClient: i } = e(), { refetch: a } = n({ refetchOnMount: !1 });
|
|
7
|
-
return t({
|
|
8
|
-
authFn: i.unlinkAccount,
|
|
9
|
-
options: {
|
|
10
|
-
...r,
|
|
11
|
-
onSuccess: async (...e) => {
|
|
12
|
-
await a(), await r?.onSuccess?.(...e);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
//#endregion
|
|
18
|
-
export { r as useUnlinkAccount };
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { AuthClient } from '../../lib/auth-client';
|
|
2
|
-
import { UseAuthMutationOptions, UseAuthMutationResult } from '../auth/use-auth-mutation';
|
|
3
|
-
/**
|
|
4
|
-
* Hook that creates a mutation for updating the authenticated user's profile.
|
|
5
|
-
*
|
|
6
|
-
* The mutation submits the name update, refetches the session on success,
|
|
7
|
-
* and displays success or error toasts.
|
|
8
|
-
*
|
|
9
|
-
* @returns The `useMutation` result.
|
|
10
|
-
*/
|
|
11
|
-
export declare function useUpdateUser(options?: UseAuthMutationOptions<AuthClient["updateUser"]>): UseAuthMutationResult<AuthClient["updateUser"]>;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { useAuth as e } from "../../components/auth/auth-provider.js";
|
|
2
|
-
import { useAuthMutation as t } from "../auth/use-auth-mutation.js";
|
|
3
|
-
import { useSession as n } from "../auth/use-session.js";
|
|
4
|
-
import { useQueryClient as r } from "@tanstack/react-query";
|
|
5
|
-
//#region src/hooks/settings/use-update-user.ts
|
|
6
|
-
function i(i) {
|
|
7
|
-
let { authClient: a } = e(), { data: o, refetch: s } = n({ refetchOnMount: !1 }), c = r();
|
|
8
|
-
return t({
|
|
9
|
-
authFn: a.updateUser,
|
|
10
|
-
options: {
|
|
11
|
-
...i,
|
|
12
|
-
onSuccess: async (e, t, ...n) => {
|
|
13
|
-
c.setQueryData(["auth", "getSession"], {
|
|
14
|
-
...o,
|
|
15
|
-
user: {
|
|
16
|
-
...o?.user,
|
|
17
|
-
...t
|
|
18
|
-
}
|
|
19
|
-
}), s(), await i?.onSuccess?.(e, t, ...n);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
//#endregion
|
|
25
|
-
export { i as useUpdateUser };
|
package/dist/lib/auth-client.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { passkeyClient as e } from "@better-auth/passkey/client";
|
|
2
|
-
import { magicLinkClient as t, multiSessionClient as n, usernameClient as r } from "better-auth/client/plugins";
|
|
3
|
-
import { createAuthClient as i } from "better-auth/react";
|
|
4
|
-
//#region src/lib/auth-client.ts
|
|
5
|
-
i({ plugins: [
|
|
6
|
-
t(),
|
|
7
|
-
n(),
|
|
8
|
-
e(),
|
|
9
|
-
r()
|
|
10
|
-
] });
|
|
11
|
-
//#endregion
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { AuthConfig as BaseAuthConfig } from '@better-auth-ui/core';
|
|
2
|
-
import { ComponentType, PropsWithChildren } from 'react';
|
|
3
|
-
import { AnyAuthClient, AuthClient } from './auth-client';
|
|
4
|
-
/**
|
|
5
|
-
* Extends the base AuthConfig with React-specific requirements including
|
|
6
|
-
* an authClient instance and a Link component for navigation.
|
|
7
|
-
*
|
|
8
|
-
* Users can augment this interface to provide their own auth client type:
|
|
9
|
-
* @example
|
|
10
|
-
* ```ts
|
|
11
|
-
* declare module "@better-auth-ui/react" {
|
|
12
|
-
* interface AuthConfig {
|
|
13
|
-
* AuthClient: typeof authClient
|
|
14
|
-
* }
|
|
15
|
-
* }
|
|
16
|
-
* ```
|
|
17
|
-
*/
|
|
18
|
-
export interface AuthConfig extends BaseAuthConfig {
|
|
19
|
-
authClient: AuthClient;
|
|
20
|
-
/**
|
|
21
|
-
* React component for rendering links
|
|
22
|
-
* @remarks `LinkComponent`
|
|
23
|
-
*/
|
|
24
|
-
Link: ComponentType<PropsWithChildren<{
|
|
25
|
-
className?: string;
|
|
26
|
-
href: string;
|
|
27
|
-
to?: string;
|
|
28
|
-
}>>;
|
|
29
|
-
}
|
|
30
|
-
type DeepPartial<T> = T extends (...args: any[]) => any ? T : T extends object ? {
|
|
31
|
-
[P in keyof T]?: DeepPartial<T[P]>;
|
|
32
|
-
} : T;
|
|
33
|
-
/**
|
|
34
|
-
* Partial AuthConfig with any Better Auth client instance.
|
|
35
|
-
*/
|
|
36
|
-
export type AnyAuthConfig = DeepPartial<Omit<AuthConfig, "authClient">> & {
|
|
37
|
-
/**
|
|
38
|
-
* Better Auth client instance
|
|
39
|
-
* @remarks `AuthClient`
|
|
40
|
-
*/
|
|
41
|
-
authClient?: AnyAuthClient;
|
|
42
|
-
};
|
|
43
|
-
export {};
|
package/dist/lib/auth-context.js
DELETED
package/src/core.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "@better-auth-ui/core"
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type UseMutationOptions,
|
|
3
|
-
type UseMutationResult,
|
|
4
|
-
useMutation
|
|
5
|
-
} from "@tanstack/react-query"
|
|
6
|
-
import type { BetterFetchError } from "better-auth/react"
|
|
7
|
-
|
|
8
|
-
// biome-ignore lint/suspicious/noExplicitAny: any
|
|
9
|
-
type AuthFn = (...args: any) => Promise<any>
|
|
10
|
-
|
|
11
|
-
type MutationParams<TFn extends AuthFn> = undefined extends Parameters<TFn>[0]
|
|
12
|
-
? // biome-ignore lint/suspicious/noConfusingVoidType: void is needed for mutations with optional params
|
|
13
|
-
void | Omit<NonNullable<Parameters<TFn>[0]>, "fetchOptions">
|
|
14
|
-
: Omit<Parameters<TFn>[0], "fetchOptions">
|
|
15
|
-
|
|
16
|
-
type InferMutationData<TFn extends AuthFn> = TFn extends (
|
|
17
|
-
...args: infer _A
|
|
18
|
-
) => infer R
|
|
19
|
-
? Extract<Awaited<R>, { error: null }> extends { data: infer D }
|
|
20
|
-
? D
|
|
21
|
-
: Awaited<R>
|
|
22
|
-
: Awaited<ReturnType<TFn>>
|
|
23
|
-
|
|
24
|
-
export type UseAuthMutationOptions<TFn extends AuthFn> = Omit<
|
|
25
|
-
UseMutationOptions<
|
|
26
|
-
InferMutationData<TFn>,
|
|
27
|
-
BetterFetchError,
|
|
28
|
-
MutationParams<TFn>
|
|
29
|
-
>,
|
|
30
|
-
"mutationFn"
|
|
31
|
-
>
|
|
32
|
-
|
|
33
|
-
export type UseAuthMutationResult<TFn extends AuthFn> = UseMutationResult<
|
|
34
|
-
InferMutationData<TFn>,
|
|
35
|
-
BetterFetchError,
|
|
36
|
-
MutationParams<TFn>
|
|
37
|
-
>
|
|
38
|
-
|
|
39
|
-
type UseAuthMutationProps<TFn extends AuthFn> = {
|
|
40
|
-
authFn: TFn
|
|
41
|
-
options?: UseAuthMutationOptions<TFn>
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export function useAuthMutation<TFn extends AuthFn>({
|
|
45
|
-
authFn,
|
|
46
|
-
options
|
|
47
|
-
}: UseAuthMutationProps<TFn>): UseAuthMutationResult<TFn> {
|
|
48
|
-
return useMutation({
|
|
49
|
-
mutationFn: (params) =>
|
|
50
|
-
authFn({
|
|
51
|
-
...params,
|
|
52
|
-
fetchOptions: { throw: true }
|
|
53
|
-
}),
|
|
54
|
-
...options
|
|
55
|
-
})
|
|
56
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type UseQueryOptions,
|
|
3
|
-
type UseQueryResult,
|
|
4
|
-
useQuery
|
|
5
|
-
} from "@tanstack/react-query"
|
|
6
|
-
import type { BetterFetchError, BetterFetchOption } from "better-auth/react"
|
|
7
|
-
|
|
8
|
-
type BetterFetchFn = (options: {
|
|
9
|
-
fetchOptions?: BetterFetchOption
|
|
10
|
-
}) => Promise<{ data: unknown }>
|
|
11
|
-
|
|
12
|
-
type InferData<TFn> = TFn extends (options: {
|
|
13
|
-
fetchOptions?: BetterFetchOption
|
|
14
|
-
}) => Promise<{ data: infer TData }>
|
|
15
|
-
? TData
|
|
16
|
-
: never
|
|
17
|
-
|
|
18
|
-
type OmitFetchOptions<T> = {
|
|
19
|
-
[K in keyof T as K extends "fetchOptions" ? never : K]: T[K]
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export type UseAuthQueryOptions<TFn extends BetterFetchFn> = Omit<
|
|
23
|
-
UseQueryOptions<InferData<TFn>, BetterFetchError>,
|
|
24
|
-
"queryFn"
|
|
25
|
-
>
|
|
26
|
-
|
|
27
|
-
export type UseAuthQueryResult<TFn extends BetterFetchFn> = UseQueryResult<
|
|
28
|
-
InferData<TFn>,
|
|
29
|
-
BetterFetchError
|
|
30
|
-
>
|
|
31
|
-
|
|
32
|
-
type UseAuthQueryProps<TFn extends BetterFetchFn> = {
|
|
33
|
-
authFn: TFn
|
|
34
|
-
params?: OmitFetchOptions<Parameters<TFn>[0]>
|
|
35
|
-
options: UseAuthQueryOptions<TFn>
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export function useAuthQuery<TFn extends BetterFetchFn>({
|
|
39
|
-
authFn,
|
|
40
|
-
params,
|
|
41
|
-
options
|
|
42
|
-
}: UseAuthQueryProps<TFn>) {
|
|
43
|
-
return useQuery<InferData<TFn>, BetterFetchError>({
|
|
44
|
-
queryFn: async () => {
|
|
45
|
-
const result = await authFn({ ...params, fetchOptions: { throw: true } })
|
|
46
|
-
return result as InferData<TFn>
|
|
47
|
-
},
|
|
48
|
-
...options
|
|
49
|
-
})
|
|
50
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { useAuth } from "../../components/auth/auth-provider"
|
|
2
|
-
import type { AuthClient } from "../../lib/auth-client"
|
|
3
|
-
import {
|
|
4
|
-
type UseAuthMutationOptions,
|
|
5
|
-
useAuthMutation
|
|
6
|
-
} from "./use-auth-mutation"
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Hook that creates a mutation to check if a username is available.
|
|
10
|
-
*
|
|
11
|
-
* @returns The `useMutation` result where data contains `{ available: boolean }`.
|
|
12
|
-
*/
|
|
13
|
-
export function useIsUsernameAvailable(
|
|
14
|
-
options?: UseAuthMutationOptions<AuthClient["isUsernameAvailable"]>
|
|
15
|
-
) {
|
|
16
|
-
const { authClient } = useAuth()
|
|
17
|
-
|
|
18
|
-
return useAuthMutation({
|
|
19
|
-
authFn: authClient.isUsernameAvailable,
|
|
20
|
-
options
|
|
21
|
-
})
|
|
22
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { useAuth } from "../../components/auth/auth-provider"
|
|
2
|
-
import type { AuthClient } from "../../lib/auth-client"
|
|
3
|
-
import {
|
|
4
|
-
type UseAuthMutationOptions,
|
|
5
|
-
useAuthMutation
|
|
6
|
-
} from "./use-auth-mutation"
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Hook that creates a mutation for the forgot-password flow.
|
|
10
|
-
*
|
|
11
|
-
* The mutation sends a password reset request for the submitted email,
|
|
12
|
-
* and navigates to the sign-in view on success.
|
|
13
|
-
*
|
|
14
|
-
* @returns The `useMutation` result.
|
|
15
|
-
*/
|
|
16
|
-
export function useRequestPasswordReset(
|
|
17
|
-
options?: UseAuthMutationOptions<AuthClient["requestPasswordReset"]>
|
|
18
|
-
) {
|
|
19
|
-
const { authClient } = useAuth()
|
|
20
|
-
|
|
21
|
-
return useAuthMutation({ authFn: authClient.requestPasswordReset, options })
|
|
22
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { useAuth } from "../../components/auth/auth-provider"
|
|
2
|
-
import type { AuthClient } from "../../lib/auth-client"
|
|
3
|
-
import {
|
|
4
|
-
type UseAuthMutationOptions,
|
|
5
|
-
useAuthMutation
|
|
6
|
-
} from "./use-auth-mutation"
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Hook that creates a mutation for the reset-password flow.
|
|
10
|
-
*
|
|
11
|
-
* The mutation resets the user's password using the provided token and new password.
|
|
12
|
-
*
|
|
13
|
-
* @returns The `useMutation` result.
|
|
14
|
-
*/
|
|
15
|
-
export function useResetPassword(
|
|
16
|
-
options?: UseAuthMutationOptions<AuthClient["resetPassword"]>
|
|
17
|
-
) {
|
|
18
|
-
const { authClient } = useAuth()
|
|
19
|
-
|
|
20
|
-
return useAuthMutation({ authFn: authClient.resetPassword, options })
|
|
21
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { useAuth } from "../../components/auth/auth-provider"
|
|
2
|
-
import type { AuthClient } from "../../lib/auth-client"
|
|
3
|
-
import {
|
|
4
|
-
type UseAuthMutationOptions,
|
|
5
|
-
useAuthMutation
|
|
6
|
-
} from "./use-auth-mutation"
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Hook that creates a mutation to send a verification email.
|
|
10
|
-
*
|
|
11
|
-
* The mutation sends a verification email to the specified email address.
|
|
12
|
-
*
|
|
13
|
-
* @returns The `useMutation` result.
|
|
14
|
-
*/
|
|
15
|
-
export function useSendVerificationEmail(
|
|
16
|
-
options?: UseAuthMutationOptions<AuthClient["sendVerificationEmail"]>
|
|
17
|
-
) {
|
|
18
|
-
const { authClient } = useAuth()
|
|
19
|
-
|
|
20
|
-
return useAuthMutation({ authFn: authClient.sendVerificationEmail, options })
|
|
21
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { useAuth } from "../../components/auth/auth-provider"
|
|
2
|
-
import type { AuthClient } from "../../lib/auth-client"
|
|
3
|
-
import {
|
|
4
|
-
type UseAuthQueryOptions,
|
|
5
|
-
type UseAuthQueryResult,
|
|
6
|
-
useAuthQuery
|
|
7
|
-
} from "./use-auth-query"
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Retrieve the current authentication session.
|
|
11
|
-
*
|
|
12
|
-
* @param options - Options to merge into the React Query configuration for the session query.
|
|
13
|
-
* @returns The React Query result for the session query: `data` contains session information, `isLoading`/`isFetching` indicate loading state, and `error` contains any fetch error.
|
|
14
|
-
*/
|
|
15
|
-
export function useSession(
|
|
16
|
-
options?: Partial<UseAuthQueryOptions<AuthClient["getSession"]>>
|
|
17
|
-
): UseAuthQueryResult<AuthClient["getSession"]> {
|
|
18
|
-
const { authClient } = useAuth()
|
|
19
|
-
|
|
20
|
-
return useAuthQuery({
|
|
21
|
-
authFn: authClient.getSession,
|
|
22
|
-
options: {
|
|
23
|
-
queryKey: ["auth", "getSession"],
|
|
24
|
-
...options
|
|
25
|
-
}
|
|
26
|
-
})
|
|
27
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { useQueryClient } from "@tanstack/react-query"
|
|
2
|
-
|
|
3
|
-
import { useAuth } from "../../components/auth/auth-provider"
|
|
4
|
-
import type { AuthClient } from "../../lib/auth-client"
|
|
5
|
-
import {
|
|
6
|
-
type UseAuthMutationOptions,
|
|
7
|
-
useAuthMutation
|
|
8
|
-
} from "./use-auth-mutation"
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Hook that creates a mutation for email/password sign-in.
|
|
12
|
-
*
|
|
13
|
-
* The mutation sends an email/password sign-in request and
|
|
14
|
-
* refetches the session on completion.
|
|
15
|
-
*
|
|
16
|
-
* @returns The `useMutation` result.
|
|
17
|
-
*/
|
|
18
|
-
export function useSignInEmail(
|
|
19
|
-
options?: UseAuthMutationOptions<AuthClient["signIn"]["email"]>
|
|
20
|
-
) {
|
|
21
|
-
const { authClient } = useAuth()
|
|
22
|
-
const queryClient = useQueryClient()
|
|
23
|
-
|
|
24
|
-
return useAuthMutation({
|
|
25
|
-
authFn: authClient.signIn.email,
|
|
26
|
-
options: {
|
|
27
|
-
...options,
|
|
28
|
-
onSuccess: async (...args) => {
|
|
29
|
-
queryClient.resetQueries({ queryKey: ["auth", "getSession"] })
|
|
30
|
-
await options?.onSuccess?.(...args)
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
})
|
|
34
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { useAuth } from "../../components/auth/auth-provider"
|
|
2
|
-
import type { AuthClient } from "../../lib/auth-client"
|
|
3
|
-
import {
|
|
4
|
-
type UseAuthMutationOptions,
|
|
5
|
-
useAuthMutation
|
|
6
|
-
} from "./use-auth-mutation"
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Hook that creates a mutation for magic-link sign-in.
|
|
10
|
-
*
|
|
11
|
-
* The mutation sends a magic-link sign-in email to the specified address.
|
|
12
|
-
*
|
|
13
|
-
* @returns The `useMutation` result.
|
|
14
|
-
*/
|
|
15
|
-
export function useSignInMagicLink(
|
|
16
|
-
options?: UseAuthMutationOptions<AuthClient["signIn"]["magicLink"]>
|
|
17
|
-
) {
|
|
18
|
-
const { authClient } = useAuth()
|
|
19
|
-
|
|
20
|
-
return useAuthMutation({ authFn: authClient.signIn.magicLink, options })
|
|
21
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { useQueryClient } from "@tanstack/react-query"
|
|
2
|
-
|
|
3
|
-
import { useAuth } from "../../components/auth/auth-provider"
|
|
4
|
-
import type { AuthClient } from "../../lib/auth-client"
|
|
5
|
-
import {
|
|
6
|
-
type UseAuthMutationOptions,
|
|
7
|
-
useAuthMutation
|
|
8
|
-
} from "./use-auth-mutation"
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Hook that creates a mutation for passkey sign-in.
|
|
12
|
-
*
|
|
13
|
-
* The mutation sends a passkey sign-in request and
|
|
14
|
-
* refetches the session on completion.
|
|
15
|
-
*
|
|
16
|
-
* @returns The `useMutation` result.
|
|
17
|
-
*/
|
|
18
|
-
export function useSignInPasskey(
|
|
19
|
-
options?: UseAuthMutationOptions<AuthClient["signIn"]["passkey"]>
|
|
20
|
-
) {
|
|
21
|
-
const { authClient } = useAuth()
|
|
22
|
-
const queryClient = useQueryClient()
|
|
23
|
-
|
|
24
|
-
return useAuthMutation({
|
|
25
|
-
authFn: authClient.signIn.passkey,
|
|
26
|
-
options: {
|
|
27
|
-
...options,
|
|
28
|
-
onSuccess: async (...args) => {
|
|
29
|
-
queryClient.resetQueries({ queryKey: ["auth", "getSession"] })
|
|
30
|
-
await options?.onSuccess?.(...args)
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
})
|
|
34
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { useAuth } from "../../components/auth/auth-provider"
|
|
2
|
-
import type { AuthClient } from "../../lib/auth-client"
|
|
3
|
-
import {
|
|
4
|
-
type UseAuthMutationOptions,
|
|
5
|
-
useAuthMutation
|
|
6
|
-
} from "./use-auth-mutation"
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Hook that creates a mutation for social sign-in.
|
|
10
|
-
*
|
|
11
|
-
* The mutation initiates a social sign-in flow with the specified provider.
|
|
12
|
-
*
|
|
13
|
-
* @returns The `useMutation` result.
|
|
14
|
-
*/
|
|
15
|
-
export function useSignInSocial(
|
|
16
|
-
options?: UseAuthMutationOptions<AuthClient["signIn"]["social"]>
|
|
17
|
-
) {
|
|
18
|
-
const { authClient } = useAuth()
|
|
19
|
-
|
|
20
|
-
return useAuthMutation({ authFn: authClient.signIn.social, options })
|
|
21
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { useQueryClient } from "@tanstack/react-query"
|
|
2
|
-
|
|
3
|
-
import { useAuth } from "../../components/auth/auth-provider"
|
|
4
|
-
import type { AuthClient } from "../../lib/auth-client"
|
|
5
|
-
import {
|
|
6
|
-
type UseAuthMutationOptions,
|
|
7
|
-
useAuthMutation
|
|
8
|
-
} from "./use-auth-mutation"
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Hook that creates a mutation for username/password sign-in.
|
|
12
|
-
*
|
|
13
|
-
* The mutation sends a username/password sign-in request and
|
|
14
|
-
* refetches the session on completion.
|
|
15
|
-
*
|
|
16
|
-
* @returns The `useMutation` result.
|
|
17
|
-
*/
|
|
18
|
-
export function useSignInUsername(
|
|
19
|
-
options?: UseAuthMutationOptions<AuthClient["signIn"]["username"]>
|
|
20
|
-
) {
|
|
21
|
-
const { authClient } = useAuth()
|
|
22
|
-
const queryClient = useQueryClient()
|
|
23
|
-
|
|
24
|
-
return useAuthMutation({
|
|
25
|
-
authFn: authClient.signIn.username,
|
|
26
|
-
options: {
|
|
27
|
-
...options,
|
|
28
|
-
onSuccess: async (...args) => {
|
|
29
|
-
queryClient.resetQueries({ queryKey: ["auth", "getSession"] })
|
|
30
|
-
await options?.onSuccess?.(...args)
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
})
|
|
34
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { useQueryClient } from "@tanstack/react-query"
|
|
2
|
-
|
|
3
|
-
import { useAuth } from "../../components/auth/auth-provider"
|
|
4
|
-
import type { AuthClient } from "../../lib/auth-client"
|
|
5
|
-
import {
|
|
6
|
-
type UseAuthMutationOptions,
|
|
7
|
-
useAuthMutation
|
|
8
|
-
} from "./use-auth-mutation"
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Hook that creates a mutation for signing out.
|
|
12
|
-
*
|
|
13
|
-
* The mutation signs out the current user and removes auth queries from cache.
|
|
14
|
-
*
|
|
15
|
-
* @returns The `useMutation` result.
|
|
16
|
-
*/
|
|
17
|
-
export function useSignOut(
|
|
18
|
-
options?: UseAuthMutationOptions<AuthClient["signOut"]>
|
|
19
|
-
) {
|
|
20
|
-
const { authClient } = useAuth()
|
|
21
|
-
const queryClient = useQueryClient()
|
|
22
|
-
|
|
23
|
-
return useAuthMutation({
|
|
24
|
-
authFn: authClient.signOut,
|
|
25
|
-
options: {
|
|
26
|
-
...options,
|
|
27
|
-
onSuccess: async (...args) => {
|
|
28
|
-
queryClient.removeQueries({ queryKey: ["auth"] })
|
|
29
|
-
await options?.onSuccess?.(...args)
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
})
|
|
33
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { useQueryClient } from "@tanstack/react-query"
|
|
2
|
-
|
|
3
|
-
import { useAuth } from "../../components/auth/auth-provider"
|
|
4
|
-
import type { AuthClient } from "../../lib/auth-client"
|
|
5
|
-
import {
|
|
6
|
-
type UseAuthMutationOptions,
|
|
7
|
-
useAuthMutation
|
|
8
|
-
} from "./use-auth-mutation"
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Hook that creates a mutation for email/password sign-up.
|
|
12
|
-
*
|
|
13
|
-
* The mutation sends an email/password sign-up request and
|
|
14
|
-
* refetches the session on success.
|
|
15
|
-
*
|
|
16
|
-
* @returns The `useMutation` result.
|
|
17
|
-
*/
|
|
18
|
-
export function useSignUpEmail(
|
|
19
|
-
options?: UseAuthMutationOptions<AuthClient["signUp"]["email"]>
|
|
20
|
-
) {
|
|
21
|
-
const { authClient } = useAuth()
|
|
22
|
-
const queryClient = useQueryClient()
|
|
23
|
-
|
|
24
|
-
return useAuthMutation({
|
|
25
|
-
authFn: authClient.signUp.email,
|
|
26
|
-
options: {
|
|
27
|
-
...options,
|
|
28
|
-
onSuccess: async (...args) => {
|
|
29
|
-
queryClient.resetQueries({ queryKey: ["auth", "getSession"] })
|
|
30
|
-
await options?.onSuccess?.(...args)
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
})
|
|
34
|
-
}
|