@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,31 +0,0 @@
|
|
|
1
|
-
import { useAuth } from "../../components/auth/auth-provider"
|
|
2
|
-
import type { AuthClient } from "../../lib/auth-client"
|
|
3
|
-
import { type UseAuthQueryOptions, useAuthQuery } from "../auth/use-auth-query"
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Retrieve provider-specific account info for a given account ID.
|
|
7
|
-
*
|
|
8
|
-
* Uses the `accountInfo` API endpoint to fetch detailed information
|
|
9
|
-
* from the social provider. The provider is automatically detected
|
|
10
|
-
* from the account ID.
|
|
11
|
-
*
|
|
12
|
-
* @param accountId - The provider-given account ID to fetch info for
|
|
13
|
-
* @param options - Optional react-query options forwarded to `useQuery`
|
|
14
|
-
* @returns The react-query result containing account info data, loading state, and error state
|
|
15
|
-
*/
|
|
16
|
-
export function useAccountInfo(
|
|
17
|
-
accountId?: string,
|
|
18
|
-
options?: Partial<UseAuthQueryOptions<AuthClient["accountInfo"]>>
|
|
19
|
-
) {
|
|
20
|
-
const { authClient } = useAuth()
|
|
21
|
-
|
|
22
|
-
return useAuthQuery({
|
|
23
|
-
authFn: authClient.accountInfo,
|
|
24
|
-
params: { query: { accountId } },
|
|
25
|
-
options: {
|
|
26
|
-
queryKey: ["auth", "accountInfo", accountId],
|
|
27
|
-
enabled: !!accountId,
|
|
28
|
-
...options
|
|
29
|
-
}
|
|
30
|
-
})
|
|
31
|
-
}
|
|
@@ -1,32 +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 "../auth/use-auth-mutation"
|
|
7
|
-
import { useListUserPasskeys } from "./use-list-user-passkeys"
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Hook that creates a mutation for adding a new passkey.
|
|
11
|
-
*
|
|
12
|
-
* Refetches the passkeys list on success.
|
|
13
|
-
*
|
|
14
|
-
* @returns The `useMutation` result.
|
|
15
|
-
*/
|
|
16
|
-
export function useAddPasskey(
|
|
17
|
-
options?: UseAuthMutationOptions<AuthClient["passkey"]["addPasskey"]>
|
|
18
|
-
) {
|
|
19
|
-
const { authClient } = useAuth()
|
|
20
|
-
const { refetch } = useListUserPasskeys()
|
|
21
|
-
|
|
22
|
-
return useAuthMutation({
|
|
23
|
-
authFn: authClient.passkey.addPasskey,
|
|
24
|
-
options: {
|
|
25
|
-
...options,
|
|
26
|
-
onSuccess: async (...args) => {
|
|
27
|
-
await refetch()
|
|
28
|
-
await options?.onSuccess?.(...args)
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
})
|
|
32
|
-
}
|
|
@@ -1,33 +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 "../auth/use-auth-mutation"
|
|
7
|
-
import { useSession } from "../auth/use-session"
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Hook that creates a mutation for changing the current user's email address.
|
|
11
|
-
*
|
|
12
|
-
* The mutation sends an email-change request and shows success or error toasts.
|
|
13
|
-
* On success the callback URL is set to the account settings view.
|
|
14
|
-
*
|
|
15
|
-
* @returns The `useMutation` result.
|
|
16
|
-
*/
|
|
17
|
-
export function useChangeEmail(
|
|
18
|
-
options?: UseAuthMutationOptions<AuthClient["changeEmail"]>
|
|
19
|
-
) {
|
|
20
|
-
const { authClient } = useAuth()
|
|
21
|
-
const { refetch } = useSession({ refetchOnMount: false })
|
|
22
|
-
|
|
23
|
-
return useAuthMutation({
|
|
24
|
-
authFn: authClient.changeEmail,
|
|
25
|
-
options: {
|
|
26
|
-
...options,
|
|
27
|
-
onSuccess: async (...args) => {
|
|
28
|
-
refetch()
|
|
29
|
-
await options?.onSuccess?.(...args)
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
})
|
|
33
|
-
}
|
|
@@ -1,19 +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 "../auth/use-auth-mutation"
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Hook that creates a mutation for changing the authenticated user's password.
|
|
10
|
-
*
|
|
11
|
-
* @returns The `useMutation` result.
|
|
12
|
-
*/
|
|
13
|
-
export function useChangePassword(
|
|
14
|
-
options?: UseAuthMutationOptions<AuthClient["changePassword"]>
|
|
15
|
-
) {
|
|
16
|
-
const { authClient } = useAuth()
|
|
17
|
-
|
|
18
|
-
return useAuthMutation({ authFn: authClient.changePassword, options })
|
|
19
|
-
}
|
|
@@ -1,32 +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 "../auth/use-auth-mutation"
|
|
7
|
-
import { useListUserPasskeys } from "./use-list-user-passkeys"
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Hook that creates a mutation for deleting a passkey.
|
|
11
|
-
*
|
|
12
|
-
* Refetches the passkeys list on success.
|
|
13
|
-
*
|
|
14
|
-
* @returns The `useMutation` result.
|
|
15
|
-
*/
|
|
16
|
-
export function useDeletePasskey(
|
|
17
|
-
options?: UseAuthMutationOptions<AuthClient["passkey"]["deletePasskey"]>
|
|
18
|
-
) {
|
|
19
|
-
const { authClient } = useAuth()
|
|
20
|
-
const { refetch } = useListUserPasskeys()
|
|
21
|
-
|
|
22
|
-
return useAuthMutation({
|
|
23
|
-
authFn: authClient.passkey.deletePasskey,
|
|
24
|
-
options: {
|
|
25
|
-
...options,
|
|
26
|
-
onSuccess: async (...args) => {
|
|
27
|
-
await refetch()
|
|
28
|
-
await options?.onSuccess?.(...args)
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
})
|
|
32
|
-
}
|
|
@@ -1,19 +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 "../auth/use-auth-mutation"
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Hook that creates a mutation for deleting the authenticated user account.
|
|
10
|
-
*
|
|
11
|
-
* @returns The `useMutation` result.
|
|
12
|
-
*/
|
|
13
|
-
export function useDeleteUser(
|
|
14
|
-
options?: UseAuthMutationOptions<AuthClient["deleteUser"]>
|
|
15
|
-
) {
|
|
16
|
-
const { authClient } = useAuth()
|
|
17
|
-
|
|
18
|
-
return useAuthMutation({ authFn: authClient.deleteUser, options })
|
|
19
|
-
}
|
|
@@ -1,19 +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 "../auth/use-auth-mutation"
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Hook that creates a mutation for linking a social provider to the current user.
|
|
10
|
-
*
|
|
11
|
-
* @returns The `useMutation` result.
|
|
12
|
-
*/
|
|
13
|
-
export function useLinkSocial(
|
|
14
|
-
options?: UseAuthMutationOptions<AuthClient["linkSocial"]>
|
|
15
|
-
) {
|
|
16
|
-
const { authClient } = useAuth()
|
|
17
|
-
|
|
18
|
-
return useAuthMutation({ authFn: authClient.linkSocial, options })
|
|
19
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { useAuth } from "../../components/auth/auth-provider"
|
|
2
|
-
import type { AuthClient } from "../../lib/auth-client"
|
|
3
|
-
import { type UseAuthQueryOptions, useAuthQuery } from "../auth/use-auth-query"
|
|
4
|
-
import { useSession } from "../auth/use-session"
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Retrieve the current user's linked social accounts.
|
|
8
|
-
*
|
|
9
|
-
* The query runs only when at least one social provider is configured and a session exists.
|
|
10
|
-
* The provided `options` are forwarded to both `useSession` and `useQuery`, allowing customization of initial data and query behavior.
|
|
11
|
-
*
|
|
12
|
-
* @param options - Optional react-query / initial-data options forwarded to `useSession` and `useQuery`
|
|
13
|
-
* @returns The react-query result containing linked accounts data, loading state, and error state
|
|
14
|
-
*/
|
|
15
|
-
export function useListAccounts(
|
|
16
|
-
options?: Partial<UseAuthQueryOptions<AuthClient["listAccounts"]>>
|
|
17
|
-
) {
|
|
18
|
-
const { authClient } = useAuth()
|
|
19
|
-
const { data: session } = useSession({ refetchOnMount: false })
|
|
20
|
-
|
|
21
|
-
return useAuthQuery({
|
|
22
|
-
authFn: authClient.listAccounts,
|
|
23
|
-
options: {
|
|
24
|
-
queryKey: ["auth", "listAccounts", session?.user.id],
|
|
25
|
-
enabled: !!session,
|
|
26
|
-
...options
|
|
27
|
-
}
|
|
28
|
-
})
|
|
29
|
-
}
|
|
@@ -1,34 +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 "../auth/use-auth-query"
|
|
8
|
-
import { useSession } from "../auth/use-session"
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Retrieve device sessions for multi-session account switching.
|
|
12
|
-
*
|
|
13
|
-
* The query is enabled only when `multiSession` is true and session data is available.
|
|
14
|
-
*
|
|
15
|
-
* @param options - Optional React Query options to customize the query behavior.
|
|
16
|
-
* @returns The React Query result for the device sessions list; `data` is the array of device session objects and includes loading and error states.
|
|
17
|
-
*/
|
|
18
|
-
export function useListDeviceSessions(
|
|
19
|
-
options?: Partial<
|
|
20
|
-
UseAuthQueryOptions<AuthClient["multiSession"]["listDeviceSessions"]>
|
|
21
|
-
>
|
|
22
|
-
): UseAuthQueryResult<AuthClient["multiSession"]["listDeviceSessions"]> {
|
|
23
|
-
const { authClient } = useAuth()
|
|
24
|
-
const { data: session } = useSession({ refetchOnMount: false })
|
|
25
|
-
|
|
26
|
-
return useAuthQuery({
|
|
27
|
-
authFn: authClient.multiSession.listDeviceSessions,
|
|
28
|
-
options: {
|
|
29
|
-
queryKey: ["auth", "multiSession", "listDeviceSessions"],
|
|
30
|
-
enabled: !!session,
|
|
31
|
-
...options
|
|
32
|
-
}
|
|
33
|
-
})
|
|
34
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { useAuth } from "../../components/auth/auth-provider"
|
|
2
|
-
import type { AuthClient } from "../../lib/auth-client"
|
|
3
|
-
import { type UseAuthQueryOptions, useAuthQuery } from "../auth/use-auth-query"
|
|
4
|
-
import { useSession } from "../auth/use-session"
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Retrieve the active sessions (devices where the current user is signed in).
|
|
8
|
-
*
|
|
9
|
-
* The underlying query is enabled only when session data is available.
|
|
10
|
-
*
|
|
11
|
-
* @param options - Optional React Query options to customize the query behavior.
|
|
12
|
-
* @returns The React Query result for the sessions list; `data` is the array of session objects, and the result includes loading and error states.
|
|
13
|
-
*/
|
|
14
|
-
export function useListSessions(
|
|
15
|
-
options?: Partial<UseAuthQueryOptions<AuthClient["listSessions"]>>
|
|
16
|
-
) {
|
|
17
|
-
const { authClient } = useAuth()
|
|
18
|
-
const { data: session } = useSession({ refetchOnMount: false })
|
|
19
|
-
|
|
20
|
-
return useAuthQuery({
|
|
21
|
-
authFn: authClient.listSessions,
|
|
22
|
-
options: {
|
|
23
|
-
queryKey: ["auth", "listSessions", session?.user.id],
|
|
24
|
-
enabled: !!session,
|
|
25
|
-
...options
|
|
26
|
-
}
|
|
27
|
-
})
|
|
28
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { useAuth } from "../../components/auth/auth-provider"
|
|
2
|
-
import type { AuthClient } from "../../lib/auth-client"
|
|
3
|
-
import { type UseAuthQueryOptions, useAuthQuery } from "../auth/use-auth-query"
|
|
4
|
-
import { useSession } from "../auth/use-session"
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Retrieve the passkeys registered for the current user.
|
|
8
|
-
*
|
|
9
|
-
* The underlying query is enabled only when session data is available.
|
|
10
|
-
*
|
|
11
|
-
* @param options - Optional React Query options to customize the query behavior.
|
|
12
|
-
* @returns The React Query result for the passkeys list.
|
|
13
|
-
*/
|
|
14
|
-
export function useListUserPasskeys(
|
|
15
|
-
options?: Partial<
|
|
16
|
-
UseAuthQueryOptions<AuthClient["passkey"]["listUserPasskeys"]>
|
|
17
|
-
>
|
|
18
|
-
) {
|
|
19
|
-
const { authClient } = useAuth()
|
|
20
|
-
const { data: session } = useSession({ refetchOnMount: false })
|
|
21
|
-
|
|
22
|
-
return useAuthQuery({
|
|
23
|
-
authFn: authClient.passkey.listUserPasskeys,
|
|
24
|
-
options: {
|
|
25
|
-
queryKey: ["auth", "listUserPasskeys", session?.user.id],
|
|
26
|
-
enabled: !!session,
|
|
27
|
-
...options
|
|
28
|
-
}
|
|
29
|
-
})
|
|
30
|
-
}
|
|
@@ -1,30 +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 "../auth/use-auth-mutation"
|
|
7
|
-
import { useListDeviceSessions } from "./use-list-device-sessions"
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Hook that creates a mutation for revoking a device session in multi-session mode.
|
|
11
|
-
*
|
|
12
|
-
* @returns The `useMutation` result.
|
|
13
|
-
*/
|
|
14
|
-
export function useRevokeMultiSession(
|
|
15
|
-
options?: UseAuthMutationOptions<AuthClient["multiSession"]["revoke"]>
|
|
16
|
-
) {
|
|
17
|
-
const { authClient } = useAuth()
|
|
18
|
-
const { refetch } = useListDeviceSessions({ refetchOnMount: false })
|
|
19
|
-
|
|
20
|
-
return useAuthMutation({
|
|
21
|
-
authFn: authClient.multiSession.revoke,
|
|
22
|
-
options: {
|
|
23
|
-
...options,
|
|
24
|
-
onSuccess: async (...args) => {
|
|
25
|
-
await refetch()
|
|
26
|
-
await options?.onSuccess?.(...args)
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
})
|
|
30
|
-
}
|
|
@@ -1,30 +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 "../auth/use-auth-mutation"
|
|
7
|
-
import { useListSessions } from "./use-list-sessions"
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Hook that creates a mutation for revoking a user session.
|
|
11
|
-
*
|
|
12
|
-
* @returns The `useMutation` result.
|
|
13
|
-
*/
|
|
14
|
-
export function useRevokeSession(
|
|
15
|
-
options?: UseAuthMutationOptions<AuthClient["revokeSession"]>
|
|
16
|
-
) {
|
|
17
|
-
const { authClient } = useAuth()
|
|
18
|
-
const { refetch } = useListSessions({ refetchOnMount: false })
|
|
19
|
-
|
|
20
|
-
return useAuthMutation({
|
|
21
|
-
authFn: authClient.revokeSession,
|
|
22
|
-
options: {
|
|
23
|
-
...options,
|
|
24
|
-
onSuccess: async (...args) => {
|
|
25
|
-
await refetch()
|
|
26
|
-
await options?.onSuccess?.(...args)
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
})
|
|
30
|
-
}
|
|
@@ -1,47 +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 "../auth/use-auth-mutation"
|
|
9
|
-
import { useSession } from "../auth/use-session"
|
|
10
|
-
import { useListDeviceSessions } from "./use-list-device-sessions"
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Hook that sets an active device session in multi-session mode.
|
|
14
|
-
*
|
|
15
|
-
* @returns The `useMutation` result.
|
|
16
|
-
*/
|
|
17
|
-
export function useSetActiveSession(
|
|
18
|
-
options?: UseAuthMutationOptions<AuthClient["multiSession"]["setActive"]>
|
|
19
|
-
) {
|
|
20
|
-
const queryClient = useQueryClient()
|
|
21
|
-
const { authClient } = useAuth()
|
|
22
|
-
|
|
23
|
-
const { refetch: refetchSession } = useSession({ refetchOnMount: false })
|
|
24
|
-
const { data: deviceSessions, refetch: refetchDeviceSessions } =
|
|
25
|
-
useListDeviceSessions({ refetchOnMount: false })
|
|
26
|
-
|
|
27
|
-
return useAuthMutation({
|
|
28
|
-
authFn: authClient.multiSession.setActive,
|
|
29
|
-
options: {
|
|
30
|
-
...options,
|
|
31
|
-
onSuccess: async (data, { sessionToken }, ...args) => {
|
|
32
|
-
const deviceSession = deviceSessions?.find(
|
|
33
|
-
(session) => session.session.token === sessionToken
|
|
34
|
-
)
|
|
35
|
-
|
|
36
|
-
if (deviceSession)
|
|
37
|
-
queryClient.setQueryData(["auth", "getSession"], deviceSession)
|
|
38
|
-
|
|
39
|
-
window.scrollTo({ top: 0 })
|
|
40
|
-
|
|
41
|
-
await refetchSession()
|
|
42
|
-
await refetchDeviceSessions()
|
|
43
|
-
await options?.onSuccess?.(data, { sessionToken }, ...args)
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
})
|
|
47
|
-
}
|
|
@@ -1,30 +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 "../auth/use-auth-mutation"
|
|
7
|
-
import { useListAccounts } from "./use-list-accounts"
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Hook that creates a mutation for unlinking a social provider from the current user.
|
|
11
|
-
*
|
|
12
|
-
* @returns The `useMutation` result.
|
|
13
|
-
*/
|
|
14
|
-
export function useUnlinkAccount(
|
|
15
|
-
options?: UseAuthMutationOptions<AuthClient["unlinkAccount"]>
|
|
16
|
-
) {
|
|
17
|
-
const { authClient } = useAuth()
|
|
18
|
-
const { refetch } = useListAccounts({ refetchOnMount: false })
|
|
19
|
-
|
|
20
|
-
return useAuthMutation({
|
|
21
|
-
authFn: authClient.unlinkAccount,
|
|
22
|
-
options: {
|
|
23
|
-
...options,
|
|
24
|
-
onSuccess: async (...args) => {
|
|
25
|
-
await refetch()
|
|
26
|
-
await options?.onSuccess?.(...args)
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
})
|
|
30
|
-
}
|
|
@@ -1,43 +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
|
-
type UseAuthMutationResult,
|
|
8
|
-
useAuthMutation
|
|
9
|
-
} from "../auth/use-auth-mutation"
|
|
10
|
-
import { useSession } from "../auth/use-session"
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Hook that creates a mutation for updating the authenticated user's profile.
|
|
14
|
-
*
|
|
15
|
-
* The mutation submits the name update, refetches the session on success,
|
|
16
|
-
* and displays success or error toasts.
|
|
17
|
-
*
|
|
18
|
-
* @returns The `useMutation` result.
|
|
19
|
-
*/
|
|
20
|
-
export function useUpdateUser(
|
|
21
|
-
options?: UseAuthMutationOptions<AuthClient["updateUser"]>
|
|
22
|
-
): UseAuthMutationResult<AuthClient["updateUser"]> {
|
|
23
|
-
const { authClient } = useAuth()
|
|
24
|
-
const { data: session, refetch } = useSession({ refetchOnMount: false })
|
|
25
|
-
const queryClient = useQueryClient()
|
|
26
|
-
|
|
27
|
-
return useAuthMutation({
|
|
28
|
-
authFn: authClient.updateUser,
|
|
29
|
-
options: {
|
|
30
|
-
...options,
|
|
31
|
-
onSuccess: async (data, variables, ...rest) => {
|
|
32
|
-
queryClient.setQueryData(["auth", "getSession"], {
|
|
33
|
-
...session,
|
|
34
|
-
user: { ...session?.user, ...variables }
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
refetch()
|
|
38
|
-
|
|
39
|
-
await options?.onSuccess?.(data, variables, ...rest)
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
})
|
|
43
|
-
}
|
package/src/lib/auth-config.ts
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import type { AuthConfig as BaseAuthConfig } from "@better-auth-ui/core"
|
|
2
|
-
import type { ComponentType, PropsWithChildren } from "react"
|
|
3
|
-
import type { AnyAuthClient, AuthClient } from "./auth-client"
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Extends the base AuthConfig with React-specific requirements including
|
|
7
|
-
* an authClient instance and a Link component for navigation.
|
|
8
|
-
*
|
|
9
|
-
* Users can augment this interface to provide their own auth client type:
|
|
10
|
-
* @example
|
|
11
|
-
* ```ts
|
|
12
|
-
* declare module "@better-auth-ui/react" {
|
|
13
|
-
* interface AuthConfig {
|
|
14
|
-
* AuthClient: typeof authClient
|
|
15
|
-
* }
|
|
16
|
-
* }
|
|
17
|
-
* ```
|
|
18
|
-
*/
|
|
19
|
-
export interface AuthConfig extends BaseAuthConfig {
|
|
20
|
-
authClient: AuthClient
|
|
21
|
-
/**
|
|
22
|
-
* React component for rendering links
|
|
23
|
-
* @remarks `LinkComponent`
|
|
24
|
-
*/
|
|
25
|
-
Link: ComponentType<
|
|
26
|
-
PropsWithChildren<{ className?: string; href: string; to?: string }>
|
|
27
|
-
>
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// biome-ignore lint/suspicious/noExplicitAny: required for generic utility type
|
|
31
|
-
type DeepPartial<T> = T extends (...args: any[]) => any
|
|
32
|
-
? T
|
|
33
|
-
: T extends object
|
|
34
|
-
? {
|
|
35
|
-
[P in keyof T]?: DeepPartial<T[P]>
|
|
36
|
-
}
|
|
37
|
-
: T
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Partial AuthConfig with any Better Auth client instance.
|
|
41
|
-
*/
|
|
42
|
-
export type AnyAuthConfig = DeepPartial<Omit<AuthConfig, "authClient">> & {
|
|
43
|
-
/**
|
|
44
|
-
* Better Auth client instance
|
|
45
|
-
* @remarks `AuthClient`
|
|
46
|
-
*/
|
|
47
|
-
authClient?: AnyAuthClient
|
|
48
|
-
}
|
package/src/lib/auth-context.ts
DELETED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|