@better-auth-ui/react 1.6.2 → 1.6.3
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/hooks/auth/use-authenticate.d.ts +30 -6
- package/dist/hooks/auth/use-is-username-available.d.ts +12 -11
- package/dist/hooks/auth/use-is-username-available.js +8 -7
- package/dist/hooks/auth/use-request-password-reset.d.ts +11 -15
- package/dist/hooks/auth/use-request-password-reset.js +8 -7
- package/dist/hooks/auth/use-reset-password.d.ts +13 -29
- package/dist/hooks/auth/use-reset-password.js +8 -7
- package/dist/hooks/auth/use-send-verification-email.d.ts +10 -14
- package/dist/hooks/auth/use-send-verification-email.js +8 -7
- package/dist/hooks/auth/use-session.d.ts +30 -4
- package/dist/hooks/auth/use-session.js +11 -10
- package/dist/hooks/auth/use-sign-in-email.d.ts +11 -37
- package/dist/hooks/auth/use-sign-in-email.js +11 -12
- package/dist/hooks/auth/use-sign-in-magic-link.d.ts +14 -18
- package/dist/hooks/auth/use-sign-in-magic-link.js +8 -7
- package/dist/hooks/auth/use-sign-in-passkey.d.ts +10 -47
- package/dist/hooks/auth/use-sign-in-passkey.js +11 -12
- package/dist/hooks/auth/use-sign-in-social.d.ts +30 -59
- package/dist/hooks/auth/use-sign-in-social.js +8 -7
- package/dist/hooks/auth/use-sign-in-username.d.ts +12 -40
- package/dist/hooks/auth/use-sign-in-username.js +11 -12
- package/dist/hooks/auth/use-sign-out.d.ts +10 -10
- package/dist/hooks/auth/use-sign-out.js +10 -12
- package/dist/hooks/auth/use-sign-up-email.d.ts +18 -101
- package/dist/hooks/auth/use-sign-up-email.js +11 -12
- package/dist/hooks/auth/use-user.d.ts +7 -5
- package/dist/hooks/settings/use-account-info.d.ts +9 -9
- package/dist/hooks/settings/use-account-info.js +13 -16
- package/dist/hooks/settings/use-add-passkey.d.ts +8 -30
- package/dist/hooks/settings/use-add-passkey.js +10 -11
- package/dist/hooks/settings/use-change-email.d.ts +11 -14
- package/dist/hooks/settings/use-change-email.js +11 -12
- package/dist/hooks/settings/use-change-password.d.ts +11 -43
- package/dist/hooks/settings/use-change-password.js +8 -7
- package/dist/hooks/settings/use-delete-passkey.d.ts +10 -12
- package/dist/hooks/settings/use-delete-passkey.js +11 -12
- package/dist/hooks/settings/use-delete-user.d.ts +13 -30
- package/dist/hooks/settings/use-delete-user.js +8 -7
- package/dist/hooks/settings/use-link-social.d.ts +22 -25
- package/dist/hooks/settings/use-link-social.js +8 -7
- package/dist/hooks/settings/use-list-accounts.d.ts +8 -6
- package/dist/hooks/settings/use-list-accounts.js +10 -16
- package/dist/hooks/settings/use-list-device-sessions.d.ts +29 -6
- package/dist/hooks/settings/use-list-device-sessions.js +10 -16
- package/dist/hooks/settings/use-list-sessions.d.ts +8 -5
- package/dist/hooks/settings/use-list-sessions.js +10 -16
- package/dist/hooks/settings/use-list-user-passkeys.d.ts +8 -5
- package/dist/hooks/settings/use-list-user-passkeys.js +10 -16
- package/dist/hooks/settings/use-revoke-multi-session.d.ts +11 -11
- package/dist/hooks/settings/use-revoke-multi-session.js +11 -12
- package/dist/hooks/settings/use-revoke-session.d.ts +11 -11
- package/dist/hooks/settings/use-revoke-session.js +11 -12
- package/dist/hooks/settings/use-set-active-session.d.ts +12 -29
- package/dist/hooks/settings/use-set-active-session.js +12 -13
- package/dist/hooks/settings/use-unlink-account.d.ts +12 -12
- package/dist/hooks/settings/use-unlink-account.js +11 -12
- package/dist/hooks/settings/use-update-user.d.ts +1178 -4
- package/dist/hooks/settings/use-update-user.js +17 -18
- package/dist/hooks/use-auth-mutation.d.ts +12 -0
- package/dist/hooks/use-auth-mutation.js +11 -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 +2 -2
- package/dist/index.js +33 -33
- package/dist/mutations/auth/is-username-available-options.d.ts +19 -0
- package/dist/mutations/auth/is-username-available-options.js +7 -0
- package/dist/mutations/auth/request-password-reset-options.d.ts +15 -0
- package/dist/mutations/auth/request-password-reset-options.js +7 -0
- package/dist/mutations/auth/reset-password-options.d.ts +17 -0
- package/dist/mutations/auth/reset-password-options.js +7 -0
- package/dist/mutations/auth/send-verification-email-options.d.ts +15 -0
- package/dist/mutations/auth/send-verification-email-options.js +7 -0
- package/dist/mutations/auth/sign-in-email-options.d.ts +23 -0
- package/dist/mutations/auth/sign-in-email-options.js +11 -0
- package/dist/mutations/auth/sign-in-magic-link-options.d.ts +23 -0
- package/dist/mutations/auth/sign-in-magic-link-options.js +11 -0
- package/dist/mutations/auth/sign-in-passkey-options.d.ts +15 -0
- package/dist/mutations/auth/sign-in-passkey-options.js +11 -0
- package/dist/mutations/auth/sign-in-social-options.d.ts +61 -0
- package/dist/mutations/auth/sign-in-social-options.js +11 -0
- package/dist/mutations/auth/sign-in-username-options.d.ts +19 -0
- package/dist/mutations/auth/sign-in-username-options.js +11 -0
- package/dist/mutations/auth/sign-out-options.d.ts +12 -0
- package/dist/mutations/auth/sign-out-options.js +7 -0
- package/dist/mutations/auth/sign-up-email-options.d.ts +1180 -0
- package/dist/mutations/auth/sign-up-email-options.js +11 -0
- package/dist/mutations/auth-mutation-options.d.ts +25 -0
- package/dist/mutations/auth-mutation-options.js +19 -0
- package/dist/mutations/settings/add-passkey-options.d.ts +15 -0
- package/dist/mutations/settings/add-passkey-options.js +11 -0
- package/dist/mutations/settings/change-email-options.d.ts +15 -0
- package/dist/mutations/settings/change-email-options.js +7 -0
- package/dist/mutations/settings/change-password-options.d.ts +17 -0
- package/dist/mutations/settings/change-password-options.js +7 -0
- package/dist/mutations/settings/delete-passkey-options.d.ts +13 -0
- package/dist/mutations/settings/delete-passkey-options.js +11 -0
- package/dist/mutations/settings/delete-user-options.d.ts +20 -0
- package/dist/mutations/settings/delete-user-options.js +7 -0
- package/dist/mutations/settings/link-social-options.d.ts +39 -0
- package/dist/mutations/settings/link-social-options.js +7 -0
- package/dist/mutations/settings/revoke-multi-session-options.d.ts +13 -0
- package/dist/mutations/settings/revoke-multi-session-options.js +11 -0
- package/dist/mutations/settings/revoke-session-options.d.ts +13 -0
- package/dist/mutations/settings/revoke-session-options.js +7 -0
- package/dist/mutations/settings/set-active-session-options.d.ts +13 -0
- package/dist/mutations/settings/set-active-session-options.js +11 -0
- package/dist/mutations/settings/unlink-account-options.d.ts +15 -0
- package/dist/mutations/settings/unlink-account-options.js +7 -0
- package/dist/mutations/settings/update-user-options.d.ts +1182 -0
- package/dist/mutations/settings/update-user-options.js +7 -0
- package/dist/queries/auth/session-options.d.ts +110 -0
- package/dist/queries/auth/session-options.js +7 -0
- package/dist/queries/auth-query-options.d.ts +29 -0
- package/dist/queries/auth-query-options.js +17 -0
- package/dist/queries/settings/account-info-options.d.ts +32 -0
- package/dist/queries/settings/account-info-options.js +12 -0
- package/dist/queries/settings/list-accounts-options.d.ts +53 -0
- package/dist/queries/settings/list-accounts-options.js +12 -0
- package/dist/queries/settings/list-device-sessions-options.d.ts +99 -0
- package/dist/queries/settings/list-device-sessions-options.js +12 -0
- package/dist/queries/settings/list-sessions-options.d.ts +54 -0
- package/dist/queries/settings/list-sessions-options.js +12 -0
- package/dist/queries/settings/list-user-passkeys-options.d.ts +18 -0
- package/dist/queries/settings/list-user-passkeys-options.js +12 -0
- package/package.json +1 -1
- package/src/hooks/auth/use-authenticate.ts +7 -10
- package/src/hooks/auth/use-is-username-available.ts +17 -8
- package/src/hooks/auth/use-request-password-reset.ts +19 -8
- package/src/hooks/auth/use-reset-password.ts +19 -9
- package/src/hooks/auth/use-send-verification-email.ts +18 -8
- package/src/hooks/auth/use-session.ts +20 -16
- package/src/hooks/auth/use-sign-in-email.ts +23 -16
- package/src/hooks/auth/use-sign-in-magic-link.ts +18 -10
- package/src/hooks/auth/use-sign-in-passkey.ts +24 -18
- package/src/hooks/auth/use-sign-in-social.ts +18 -8
- package/src/hooks/auth/use-sign-in-username.ts +24 -18
- package/src/hooks/auth/use-sign-out.ts +18 -17
- package/src/hooks/auth/use-sign-up-email.ts +24 -18
- package/src/hooks/auth/use-user.ts +7 -8
- package/src/hooks/settings/use-account-info.ts +29 -20
- package/src/hooks/settings/use-add-passkey.ts +22 -17
- package/src/hooks/settings/use-change-email.ts +21 -17
- package/src/hooks/settings/use-change-password.ts +18 -8
- package/src/hooks/settings/use-delete-passkey.ts +21 -16
- package/src/hooks/settings/use-delete-user.ts +18 -8
- package/src/hooks/settings/use-link-social.ts +18 -8
- package/src/hooks/settings/use-list-accounts.ts +25 -15
- package/src/hooks/settings/use-list-device-sessions.ts +26 -21
- package/src/hooks/settings/use-list-sessions.ts +25 -14
- package/src/hooks/settings/use-list-user-passkeys.ts +25 -16
- package/src/hooks/settings/use-revoke-multi-session.ts +25 -16
- package/src/hooks/settings/use-revoke-session.ts +25 -16
- package/src/hooks/settings/use-set-active-session.ts +35 -24
- package/src/hooks/settings/use-unlink-account.ts +22 -15
- package/src/hooks/settings/use-update-user.ts +29 -22
- package/src/hooks/use-auth-mutation.ts +29 -0
- package/src/hooks/use-auth-query.ts +36 -0
- package/src/index.ts +2 -2
- package/src/mutations/auth/is-username-available-options.ts +18 -0
- package/src/mutations/auth/request-password-reset-options.ts +14 -0
- package/src/mutations/auth/reset-password-options.ts +14 -0
- package/src/mutations/auth/send-verification-email-options.ts +14 -0
- package/src/mutations/auth/sign-in-email-options.ts +19 -0
- package/src/mutations/auth/sign-in-magic-link-options.ts +15 -0
- package/src/mutations/auth/sign-in-passkey-options.ts +15 -0
- package/src/mutations/auth/sign-in-social-options.ts +19 -0
- package/src/mutations/auth/sign-in-username-options.ts +15 -0
- package/src/mutations/auth/sign-out-options.ts +11 -0
- package/src/mutations/auth/sign-up-email-options.ts +15 -0
- package/src/mutations/auth-mutation-options.ts +49 -0
- package/src/mutations/settings/add-passkey-options.ts +15 -0
- package/src/mutations/settings/change-email-options.ts +11 -0
- package/src/mutations/settings/change-password-options.ts +14 -0
- package/src/mutations/settings/delete-passkey-options.ts +15 -0
- package/src/mutations/settings/delete-user-options.ts +11 -0
- package/src/mutations/settings/link-social-options.ts +11 -0
- package/src/mutations/settings/revoke-multi-session-options.ts +15 -0
- package/src/mutations/settings/revoke-session-options.ts +14 -0
- package/src/mutations/settings/set-active-session-options.ts +15 -0
- package/src/mutations/settings/unlink-account-options.ts +14 -0
- package/src/mutations/settings/update-user-options.ts +15 -0
- package/src/queries/auth/session-options.ts +18 -0
- package/src/queries/auth-query-options.ts +34 -0
- package/src/queries/settings/account-info-options.ts +25 -0
- package/src/queries/settings/list-accounts-options.ts +26 -0
- package/src/queries/settings/list-device-sessions-options.ts +24 -0
- package/src/queries/settings/list-sessions-options.ts +23 -0
- package/src/queries/settings/list-user-passkeys-options.ts +23 -0
- 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/src/hooks/auth/use-auth-mutation.ts +0 -56
- package/src/hooks/auth/use-auth-query.ts +0 -50
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { AuthClient } from '../../lib/auth-client';
|
|
2
|
+
/**
|
|
3
|
+
* Query options factory for the current session.
|
|
4
|
+
*
|
|
5
|
+
* Access `.queryKey` on the returned options for cache seeding or
|
|
6
|
+
* invalidation: `queryClient.setQueryData(sessionOptions(authClient).queryKey, session)`.
|
|
7
|
+
*
|
|
8
|
+
* @param authClient - The Better Auth client.
|
|
9
|
+
* @param params - Parameters forwarded to `authClient.getSession`.
|
|
10
|
+
*/
|
|
11
|
+
export declare function sessionOptions(authClient: AuthClient, params?: Parameters<AuthClient["getSession"]>[0]): import('@tanstack/react-query').OmitKeyof<import('@tanstack/react-query').UseQueryOptions<{
|
|
12
|
+
user: import('better-auth').StripEmptyObjects<{
|
|
13
|
+
id: string;
|
|
14
|
+
createdAt: Date;
|
|
15
|
+
updatedAt: Date;
|
|
16
|
+
email: string;
|
|
17
|
+
emailVerified: boolean;
|
|
18
|
+
name: string;
|
|
19
|
+
image?: string | null | undefined;
|
|
20
|
+
} & {} & {
|
|
21
|
+
username?: string | null | undefined;
|
|
22
|
+
displayUsername?: string | null | undefined;
|
|
23
|
+
}>;
|
|
24
|
+
session: import('better-auth').StripEmptyObjects<{
|
|
25
|
+
id: string;
|
|
26
|
+
createdAt: Date;
|
|
27
|
+
updatedAt: Date;
|
|
28
|
+
userId: string;
|
|
29
|
+
expiresAt: Date;
|
|
30
|
+
token: string;
|
|
31
|
+
ipAddress?: string | null | undefined;
|
|
32
|
+
userAgent?: string | null | undefined;
|
|
33
|
+
}>;
|
|
34
|
+
} | null, import('better-auth/client').BetterFetchError, {
|
|
35
|
+
user: import('better-auth').StripEmptyObjects<{
|
|
36
|
+
id: string;
|
|
37
|
+
createdAt: Date;
|
|
38
|
+
updatedAt: Date;
|
|
39
|
+
email: string;
|
|
40
|
+
emailVerified: boolean;
|
|
41
|
+
name: string;
|
|
42
|
+
image?: string | null | undefined;
|
|
43
|
+
} & {} & {
|
|
44
|
+
username?: string | null | undefined;
|
|
45
|
+
displayUsername?: string | null | undefined;
|
|
46
|
+
}>;
|
|
47
|
+
session: import('better-auth').StripEmptyObjects<{
|
|
48
|
+
id: string;
|
|
49
|
+
createdAt: Date;
|
|
50
|
+
updatedAt: Date;
|
|
51
|
+
userId: string;
|
|
52
|
+
expiresAt: Date;
|
|
53
|
+
token: string;
|
|
54
|
+
ipAddress?: string | null | undefined;
|
|
55
|
+
userAgent?: string | null | undefined;
|
|
56
|
+
}>;
|
|
57
|
+
} | null, readonly unknown[]>, "queryFn"> & {
|
|
58
|
+
queryFn?: import('@tanstack/react-query').QueryFunction<{
|
|
59
|
+
user: import('better-auth').StripEmptyObjects<{
|
|
60
|
+
id: string;
|
|
61
|
+
createdAt: Date;
|
|
62
|
+
updatedAt: Date;
|
|
63
|
+
email: string;
|
|
64
|
+
emailVerified: boolean;
|
|
65
|
+
name: string;
|
|
66
|
+
image?: string | null | undefined;
|
|
67
|
+
} & {} & {
|
|
68
|
+
username?: string | null | undefined;
|
|
69
|
+
displayUsername?: string | null | undefined;
|
|
70
|
+
}>;
|
|
71
|
+
session: import('better-auth').StripEmptyObjects<{
|
|
72
|
+
id: string;
|
|
73
|
+
createdAt: Date;
|
|
74
|
+
updatedAt: Date;
|
|
75
|
+
userId: string;
|
|
76
|
+
expiresAt: Date;
|
|
77
|
+
token: string;
|
|
78
|
+
ipAddress?: string | null | undefined;
|
|
79
|
+
userAgent?: string | null | undefined;
|
|
80
|
+
}>;
|
|
81
|
+
} | null, readonly unknown[], never> | undefined;
|
|
82
|
+
} & {
|
|
83
|
+
queryKey: readonly unknown[] & {
|
|
84
|
+
[dataTagSymbol]: {
|
|
85
|
+
user: import('better-auth').StripEmptyObjects<{
|
|
86
|
+
id: string;
|
|
87
|
+
createdAt: Date;
|
|
88
|
+
updatedAt: Date;
|
|
89
|
+
email: string;
|
|
90
|
+
emailVerified: boolean;
|
|
91
|
+
name: string;
|
|
92
|
+
image?: string | null | undefined;
|
|
93
|
+
} & {} & {
|
|
94
|
+
username?: string | null | undefined;
|
|
95
|
+
displayUsername?: string | null | undefined;
|
|
96
|
+
}>;
|
|
97
|
+
session: import('better-auth').StripEmptyObjects<{
|
|
98
|
+
id: string;
|
|
99
|
+
createdAt: Date;
|
|
100
|
+
updatedAt: Date;
|
|
101
|
+
userId: string;
|
|
102
|
+
expiresAt: Date;
|
|
103
|
+
token: string;
|
|
104
|
+
ipAddress?: string | null | undefined;
|
|
105
|
+
userAgent?: string | null | undefined;
|
|
106
|
+
}>;
|
|
107
|
+
} | null;
|
|
108
|
+
[dataTagErrorSymbol]: import('better-auth/client').BetterFetchError;
|
|
109
|
+
};
|
|
110
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { QueryKey } from '@tanstack/react-query';
|
|
2
|
+
import { BetterFetchError, BetterFetchOption } from 'better-auth/client';
|
|
3
|
+
export type AuthFn<TData = unknown> = (params: {
|
|
4
|
+
query?: Record<string, unknown>;
|
|
5
|
+
fetchOptions?: BetterFetchOption;
|
|
6
|
+
}) => Promise<{
|
|
7
|
+
data: TData;
|
|
8
|
+
}>;
|
|
9
|
+
type AuthFnData<TFn> = TFn extends AuthFn<infer TData> ? TData : never;
|
|
10
|
+
/**
|
|
11
|
+
* Build `queryOptions` for a Better Auth endpoint.
|
|
12
|
+
*
|
|
13
|
+
* Appends `params.query` (or `null`) to the supplied `queryKey` so cache
|
|
14
|
+
* identity tracks endpoint inputs. Wires `throw: true` and the React Query
|
|
15
|
+
* `AbortSignal` into `fetchOptions`.
|
|
16
|
+
*
|
|
17
|
+
* @param authFn - Better Auth client method (e.g. `authClient.getSession`).
|
|
18
|
+
* @param queryKey - Scope prefix for the key. `params.query` is appended automatically.
|
|
19
|
+
* @param params - Parameters forwarded to `authFn`.
|
|
20
|
+
*/
|
|
21
|
+
export declare function authQueryOptions<TFn extends AuthFn, const TQueryKey extends QueryKey>(authFn: TFn, queryKey: TQueryKey, params?: Parameters<TFn>[0]): import('@tanstack/react-query').OmitKeyof<import('@tanstack/react-query').UseQueryOptions<AuthFnData<TFn>, BetterFetchError, AuthFnData<TFn>, readonly unknown[]>, "queryFn"> & {
|
|
22
|
+
queryFn?: import('@tanstack/react-query').QueryFunction<AuthFnData<TFn>, readonly unknown[], never> | undefined;
|
|
23
|
+
} & {
|
|
24
|
+
queryKey: readonly unknown[] & {
|
|
25
|
+
[dataTagSymbol]: AuthFnData<TFn>;
|
|
26
|
+
[dataTagErrorSymbol]: BetterFetchError;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { queryOptions as e } from "@tanstack/react-query";
|
|
2
|
+
//#region src/queries/auth-query-options.ts
|
|
3
|
+
function t(t, n, r) {
|
|
4
|
+
return e({
|
|
5
|
+
queryKey: [...n, r?.query ?? null],
|
|
6
|
+
queryFn: ({ signal: e }) => t({
|
|
7
|
+
...r,
|
|
8
|
+
fetchOptions: {
|
|
9
|
+
...r?.fetchOptions,
|
|
10
|
+
signal: e,
|
|
11
|
+
throw: !0
|
|
12
|
+
}
|
|
13
|
+
})
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
//#endregion
|
|
17
|
+
export { t as authQueryOptions };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { AuthClient } from '../../lib/auth-client';
|
|
2
|
+
/**
|
|
3
|
+
* Query options factory for provider-specific account info.
|
|
4
|
+
*
|
|
5
|
+
* Keyed per-user. `userId` and `params` are both optional so the factory can
|
|
6
|
+
* build stable options before either is known — the consumer swaps `queryFn`
|
|
7
|
+
* for `skipToken` until ready.
|
|
8
|
+
*
|
|
9
|
+
* @param authClient - The Better Auth client.
|
|
10
|
+
* @param userId - The current signed in user's ID.
|
|
11
|
+
* @param params - Parameters forwarded to `authClient.accountInfo`.
|
|
12
|
+
*/
|
|
13
|
+
export declare function accountInfoOptions(authClient: AuthClient, userId?: string, params?: Parameters<AuthClient["accountInfo"]>[0]): import('@tanstack/react-query').OmitKeyof<import('@tanstack/react-query').UseQueryOptions<{
|
|
14
|
+
user: import('better-auth').OAuth2UserInfo;
|
|
15
|
+
data: Record<string, any>;
|
|
16
|
+
} | null, import('better-auth/client').BetterFetchError, {
|
|
17
|
+
user: import('better-auth').OAuth2UserInfo;
|
|
18
|
+
data: Record<string, any>;
|
|
19
|
+
} | null, readonly unknown[]>, "queryFn"> & {
|
|
20
|
+
queryFn?: import('@tanstack/react-query').QueryFunction<{
|
|
21
|
+
user: import('better-auth').OAuth2UserInfo;
|
|
22
|
+
data: Record<string, any>;
|
|
23
|
+
} | null, readonly unknown[], never> | undefined;
|
|
24
|
+
} & {
|
|
25
|
+
queryKey: readonly unknown[] & {
|
|
26
|
+
[dataTagSymbol]: {
|
|
27
|
+
user: import('better-auth').OAuth2UserInfo;
|
|
28
|
+
data: Record<string, any>;
|
|
29
|
+
} | null;
|
|
30
|
+
[dataTagErrorSymbol]: import('better-auth/client').BetterFetchError;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { authQueryOptions as e } from "../auth-query-options.js";
|
|
2
|
+
//#region src/queries/settings/account-info-options.ts
|
|
3
|
+
function t(t, n, r) {
|
|
4
|
+
return e(t.accountInfo, [
|
|
5
|
+
"auth",
|
|
6
|
+
"user",
|
|
7
|
+
n,
|
|
8
|
+
"accountInfo"
|
|
9
|
+
], r);
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { t as accountInfoOptions };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { AuthClient } from '../../lib/auth-client';
|
|
2
|
+
/**
|
|
3
|
+
* Query options factory for a user's linked social accounts.
|
|
4
|
+
*
|
|
5
|
+
* Keyed per-user (enables offline account switching with a persister).
|
|
6
|
+
* `userId` is optional so the factory can build stable options before the
|
|
7
|
+
* active session resolves — the consumer swaps `queryFn` for `skipToken`
|
|
8
|
+
* until ready.
|
|
9
|
+
*
|
|
10
|
+
* @param authClient - The Better Auth client.
|
|
11
|
+
* @param userId - The current signed in user's ID.
|
|
12
|
+
* @param params - Parameters forwarded to `authClient.listAccounts`.
|
|
13
|
+
*/
|
|
14
|
+
export declare function listAccountsOptions(authClient: AuthClient, userId?: string, params?: Parameters<AuthClient["listAccounts"]>[0]): import('@tanstack/react-query').OmitKeyof<import('@tanstack/react-query').UseQueryOptions<{
|
|
15
|
+
scopes: string[];
|
|
16
|
+
id: string;
|
|
17
|
+
createdAt: Date;
|
|
18
|
+
updatedAt: Date;
|
|
19
|
+
userId: string;
|
|
20
|
+
providerId: string;
|
|
21
|
+
accountId: string;
|
|
22
|
+
}[] | null, import('better-auth/client').BetterFetchError, {
|
|
23
|
+
scopes: string[];
|
|
24
|
+
id: string;
|
|
25
|
+
createdAt: Date;
|
|
26
|
+
updatedAt: Date;
|
|
27
|
+
userId: string;
|
|
28
|
+
providerId: string;
|
|
29
|
+
accountId: string;
|
|
30
|
+
}[] | null, readonly unknown[]>, "queryFn"> & {
|
|
31
|
+
queryFn?: import('@tanstack/react-query').QueryFunction<{
|
|
32
|
+
scopes: string[];
|
|
33
|
+
id: string;
|
|
34
|
+
createdAt: Date;
|
|
35
|
+
updatedAt: Date;
|
|
36
|
+
userId: string;
|
|
37
|
+
providerId: string;
|
|
38
|
+
accountId: string;
|
|
39
|
+
}[] | null, readonly unknown[], never> | undefined;
|
|
40
|
+
} & {
|
|
41
|
+
queryKey: readonly unknown[] & {
|
|
42
|
+
[dataTagSymbol]: {
|
|
43
|
+
scopes: string[];
|
|
44
|
+
id: string;
|
|
45
|
+
createdAt: Date;
|
|
46
|
+
updatedAt: Date;
|
|
47
|
+
userId: string;
|
|
48
|
+
providerId: string;
|
|
49
|
+
accountId: string;
|
|
50
|
+
}[] | null;
|
|
51
|
+
[dataTagErrorSymbol]: import('better-auth/client').BetterFetchError;
|
|
52
|
+
};
|
|
53
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { authQueryOptions as e } from "../auth-query-options.js";
|
|
2
|
+
//#region src/queries/settings/list-accounts-options.ts
|
|
3
|
+
function t(t, n, r) {
|
|
4
|
+
return e(t.listAccounts, [
|
|
5
|
+
"auth",
|
|
6
|
+
"user",
|
|
7
|
+
n,
|
|
8
|
+
"listAccounts"
|
|
9
|
+
], r);
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { t as listAccountsOptions };
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { AuthClient } from '../../lib/auth-client';
|
|
2
|
+
/**
|
|
3
|
+
* Query options factory for the current user's device sessions
|
|
4
|
+
* (multi-session account switcher).
|
|
5
|
+
*
|
|
6
|
+
* Keyed per-user (enables offline account switching with a persister).
|
|
7
|
+
*
|
|
8
|
+
* @param authClient - The Better Auth client.
|
|
9
|
+
* @param userId - The current signed in user's ID.
|
|
10
|
+
* @param params - Parameters forwarded to `authClient.multiSession.listDeviceSessions`.
|
|
11
|
+
*/
|
|
12
|
+
export declare function listDeviceSessionsOptions(authClient: AuthClient, userId?: string, params?: Parameters<AuthClient["multiSession"]["listDeviceSessions"]>[0]): import('@tanstack/react-query').OmitKeyof<import('@tanstack/react-query').UseQueryOptions<{
|
|
13
|
+
session: {
|
|
14
|
+
id: string;
|
|
15
|
+
createdAt: Date;
|
|
16
|
+
updatedAt: Date;
|
|
17
|
+
userId: string;
|
|
18
|
+
expiresAt: Date;
|
|
19
|
+
token: string;
|
|
20
|
+
ipAddress?: string | null | undefined;
|
|
21
|
+
userAgent?: string | null | undefined;
|
|
22
|
+
};
|
|
23
|
+
user: {
|
|
24
|
+
id: string;
|
|
25
|
+
createdAt: Date;
|
|
26
|
+
updatedAt: Date;
|
|
27
|
+
email: string;
|
|
28
|
+
emailVerified: boolean;
|
|
29
|
+
name: string;
|
|
30
|
+
image?: string | null | undefined;
|
|
31
|
+
};
|
|
32
|
+
}[] | null, import('better-auth/client').BetterFetchError, {
|
|
33
|
+
session: {
|
|
34
|
+
id: string;
|
|
35
|
+
createdAt: Date;
|
|
36
|
+
updatedAt: Date;
|
|
37
|
+
userId: string;
|
|
38
|
+
expiresAt: Date;
|
|
39
|
+
token: string;
|
|
40
|
+
ipAddress?: string | null | undefined;
|
|
41
|
+
userAgent?: string | null | undefined;
|
|
42
|
+
};
|
|
43
|
+
user: {
|
|
44
|
+
id: string;
|
|
45
|
+
createdAt: Date;
|
|
46
|
+
updatedAt: Date;
|
|
47
|
+
email: string;
|
|
48
|
+
emailVerified: boolean;
|
|
49
|
+
name: string;
|
|
50
|
+
image?: string | null | undefined;
|
|
51
|
+
};
|
|
52
|
+
}[] | null, readonly unknown[]>, "queryFn"> & {
|
|
53
|
+
queryFn?: import('@tanstack/react-query').QueryFunction<{
|
|
54
|
+
session: {
|
|
55
|
+
id: string;
|
|
56
|
+
createdAt: Date;
|
|
57
|
+
updatedAt: Date;
|
|
58
|
+
userId: string;
|
|
59
|
+
expiresAt: Date;
|
|
60
|
+
token: string;
|
|
61
|
+
ipAddress?: string | null | undefined;
|
|
62
|
+
userAgent?: string | null | undefined;
|
|
63
|
+
};
|
|
64
|
+
user: {
|
|
65
|
+
id: string;
|
|
66
|
+
createdAt: Date;
|
|
67
|
+
updatedAt: Date;
|
|
68
|
+
email: string;
|
|
69
|
+
emailVerified: boolean;
|
|
70
|
+
name: string;
|
|
71
|
+
image?: string | null | undefined;
|
|
72
|
+
};
|
|
73
|
+
}[] | null, readonly unknown[], never> | undefined;
|
|
74
|
+
} & {
|
|
75
|
+
queryKey: readonly unknown[] & {
|
|
76
|
+
[dataTagSymbol]: {
|
|
77
|
+
session: {
|
|
78
|
+
id: string;
|
|
79
|
+
createdAt: Date;
|
|
80
|
+
updatedAt: Date;
|
|
81
|
+
userId: string;
|
|
82
|
+
expiresAt: Date;
|
|
83
|
+
token: string;
|
|
84
|
+
ipAddress?: string | null | undefined;
|
|
85
|
+
userAgent?: string | null | undefined;
|
|
86
|
+
};
|
|
87
|
+
user: {
|
|
88
|
+
id: string;
|
|
89
|
+
createdAt: Date;
|
|
90
|
+
updatedAt: Date;
|
|
91
|
+
email: string;
|
|
92
|
+
emailVerified: boolean;
|
|
93
|
+
name: string;
|
|
94
|
+
image?: string | null | undefined;
|
|
95
|
+
};
|
|
96
|
+
}[] | null;
|
|
97
|
+
[dataTagErrorSymbol]: import('better-auth/client').BetterFetchError;
|
|
98
|
+
};
|
|
99
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { authQueryOptions as e } from "../auth-query-options.js";
|
|
2
|
+
//#region src/queries/settings/list-device-sessions-options.ts
|
|
3
|
+
function t(t, n, r) {
|
|
4
|
+
return e(t.multiSession.listDeviceSessions, [
|
|
5
|
+
"auth",
|
|
6
|
+
"user",
|
|
7
|
+
n,
|
|
8
|
+
"listDeviceSessions"
|
|
9
|
+
], r);
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { t as listDeviceSessionsOptions };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { AuthClient } from '../../lib/auth-client';
|
|
2
|
+
/**
|
|
3
|
+
* Query options factory for the current user's active sessions.
|
|
4
|
+
*
|
|
5
|
+
* Keyed per-user (enables offline account switching with a persister).
|
|
6
|
+
*
|
|
7
|
+
* @param authClient - The Better Auth client.
|
|
8
|
+
* @param userId - The current signed in user's ID.
|
|
9
|
+
* @param params - Parameters forwarded to `authClient.listSessions`.
|
|
10
|
+
*/
|
|
11
|
+
export declare function listSessionsOptions(authClient: AuthClient, userId?: string, params?: Parameters<AuthClient["listSessions"]>[0]): import('@tanstack/react-query').OmitKeyof<import('@tanstack/react-query').UseQueryOptions<import('better-auth').Prettify<{
|
|
12
|
+
id: string;
|
|
13
|
+
createdAt: Date;
|
|
14
|
+
updatedAt: Date;
|
|
15
|
+
userId: string;
|
|
16
|
+
expiresAt: Date;
|
|
17
|
+
token: string;
|
|
18
|
+
ipAddress?: string | null | undefined | undefined;
|
|
19
|
+
userAgent?: string | null | undefined | undefined;
|
|
20
|
+
}>[] | null, import('better-auth/client').BetterFetchError, import('better-auth').Prettify<{
|
|
21
|
+
id: string;
|
|
22
|
+
createdAt: Date;
|
|
23
|
+
updatedAt: Date;
|
|
24
|
+
userId: string;
|
|
25
|
+
expiresAt: Date;
|
|
26
|
+
token: string;
|
|
27
|
+
ipAddress?: string | null | undefined | undefined;
|
|
28
|
+
userAgent?: string | null | undefined | undefined;
|
|
29
|
+
}>[] | null, readonly unknown[]>, "queryFn"> & {
|
|
30
|
+
queryFn?: import('@tanstack/react-query').QueryFunction<import('better-auth').Prettify<{
|
|
31
|
+
id: string;
|
|
32
|
+
createdAt: Date;
|
|
33
|
+
updatedAt: Date;
|
|
34
|
+
userId: string;
|
|
35
|
+
expiresAt: Date;
|
|
36
|
+
token: string;
|
|
37
|
+
ipAddress?: string | null | undefined | undefined;
|
|
38
|
+
userAgent?: string | null | undefined | undefined;
|
|
39
|
+
}>[] | null, readonly unknown[], never> | undefined;
|
|
40
|
+
} & {
|
|
41
|
+
queryKey: readonly unknown[] & {
|
|
42
|
+
[dataTagSymbol]: import('better-auth').Prettify<{
|
|
43
|
+
id: string;
|
|
44
|
+
createdAt: Date;
|
|
45
|
+
updatedAt: Date;
|
|
46
|
+
userId: string;
|
|
47
|
+
expiresAt: Date;
|
|
48
|
+
token: string;
|
|
49
|
+
ipAddress?: string | null | undefined | undefined;
|
|
50
|
+
userAgent?: string | null | undefined | undefined;
|
|
51
|
+
}>[] | null;
|
|
52
|
+
[dataTagErrorSymbol]: import('better-auth/client').BetterFetchError;
|
|
53
|
+
};
|
|
54
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { authQueryOptions as e } from "../auth-query-options.js";
|
|
2
|
+
//#region src/queries/settings/list-sessions-options.ts
|
|
3
|
+
function t(t, n, r) {
|
|
4
|
+
return e(t.listSessions, [
|
|
5
|
+
"auth",
|
|
6
|
+
"user",
|
|
7
|
+
n,
|
|
8
|
+
"listSessions"
|
|
9
|
+
], r);
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { t as listSessionsOptions };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { AuthClient } from '../../lib/auth-client';
|
|
2
|
+
/**
|
|
3
|
+
* Query options factory for the current user's passkeys.
|
|
4
|
+
*
|
|
5
|
+
* Keyed per-user (enables offline account switching with a persister).
|
|
6
|
+
*
|
|
7
|
+
* @param authClient - The Better Auth client.
|
|
8
|
+
* @param userId - The current signed in user's ID.
|
|
9
|
+
* @param params - Parameters forwarded to `authClient.passkey.listUserPasskeys`.
|
|
10
|
+
*/
|
|
11
|
+
export declare function listUserPasskeysOptions(authClient: AuthClient, userId?: string, params?: Parameters<AuthClient["passkey"]["listUserPasskeys"]>[0]): import('@tanstack/react-query').OmitKeyof<import('@tanstack/react-query').UseQueryOptions<import('@better-auth/passkey/client').Passkey[] | null, import('better-auth/client').BetterFetchError, import('@better-auth/passkey/client').Passkey[] | null, readonly unknown[]>, "queryFn"> & {
|
|
12
|
+
queryFn?: import('@tanstack/react-query').QueryFunction<import('@better-auth/passkey/client').Passkey[] | null, readonly unknown[], never> | undefined;
|
|
13
|
+
} & {
|
|
14
|
+
queryKey: readonly unknown[] & {
|
|
15
|
+
[dataTagSymbol]: import('@better-auth/passkey/client').Passkey[] | null;
|
|
16
|
+
[dataTagErrorSymbol]: import('better-auth/client').BetterFetchError;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { authQueryOptions as e } from "../auth-query-options.js";
|
|
2
|
+
//#region src/queries/settings/list-user-passkeys-options.ts
|
|
3
|
+
function t(t, n, r) {
|
|
4
|
+
return e(t.passkey.listUserPasskeys, [
|
|
5
|
+
"auth",
|
|
6
|
+
"user",
|
|
7
|
+
n,
|
|
8
|
+
"listUserPasskeys"
|
|
9
|
+
], r);
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { t as listUserPasskeysOptions };
|
package/package.json
CHANGED
|
@@ -1,19 +1,16 @@
|
|
|
1
1
|
import { useEffect } from "react"
|
|
2
|
-
|
|
3
2
|
import { useAuth } from "../../components/auth/auth-provider"
|
|
4
|
-
import type
|
|
5
|
-
import type { UseAuthQueryOptions, UseAuthQueryResult } from "./use-auth-query"
|
|
6
|
-
import { useSession } from "./use-session"
|
|
3
|
+
import { type UseSessionOptions, useSession } from "./use-session"
|
|
7
4
|
|
|
8
5
|
/**
|
|
9
|
-
*
|
|
6
|
+
* Calls `useSession` and redirects unauthenticated users to the sign-in page,
|
|
7
|
+
* preserving the current URL as a `redirectTo` query param.
|
|
10
8
|
*
|
|
11
|
-
* @param options -
|
|
12
|
-
*
|
|
9
|
+
* @param options - Better Auth params (`query`, `fetchOptions`) and React
|
|
10
|
+
* Query options forwarded to `useQuery`.
|
|
11
|
+
* @returns React Query result for the session.
|
|
13
12
|
*/
|
|
14
|
-
export function useAuthenticate(
|
|
15
|
-
options?: Partial<UseAuthQueryOptions<AuthClient["getSession"]>>
|
|
16
|
-
): UseAuthQueryResult<AuthClient["getSession"]> {
|
|
13
|
+
export function useAuthenticate(options?: UseSessionOptions) {
|
|
17
14
|
const { basePaths, viewPaths, navigate } = useAuth()
|
|
18
15
|
const session = useSession(options)
|
|
19
16
|
|
|
@@ -1,22 +1,31 @@
|
|
|
1
|
+
import { useMutation } from "@tanstack/react-query"
|
|
2
|
+
|
|
1
3
|
import { useAuth } from "../../components/auth/auth-provider"
|
|
2
4
|
import type { AuthClient } from "../../lib/auth-client"
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
import { isUsernameAvailableOptions } from "../../mutations/auth/is-username-available-options"
|
|
6
|
+
|
|
7
|
+
export type UseIsUsernameAvailableParams = NonNullable<
|
|
8
|
+
Parameters<AuthClient["isUsernameAvailable"]>[0]
|
|
9
|
+
>
|
|
10
|
+
|
|
11
|
+
export type UseIsUsernameAvailableOptions = Omit<
|
|
12
|
+
ReturnType<typeof isUsernameAvailableOptions>,
|
|
13
|
+
"mutationKey" | "mutationFn"
|
|
14
|
+
>
|
|
7
15
|
|
|
8
16
|
/**
|
|
9
17
|
* Hook that creates a mutation to check if a username is available.
|
|
10
18
|
*
|
|
19
|
+
* @param options - React Query options forwarded to `useMutation`.
|
|
11
20
|
* @returns The `useMutation` result where data contains `{ available: boolean }`.
|
|
12
21
|
*/
|
|
13
22
|
export function useIsUsernameAvailable(
|
|
14
|
-
options?:
|
|
23
|
+
options?: UseIsUsernameAvailableOptions
|
|
15
24
|
) {
|
|
16
25
|
const { authClient } = useAuth()
|
|
17
26
|
|
|
18
|
-
return
|
|
19
|
-
|
|
20
|
-
options
|
|
27
|
+
return useMutation({
|
|
28
|
+
...isUsernameAvailableOptions(authClient),
|
|
29
|
+
...options
|
|
21
30
|
})
|
|
22
31
|
}
|
|
@@ -1,22 +1,33 @@
|
|
|
1
|
+
import { useMutation } from "@tanstack/react-query"
|
|
2
|
+
|
|
1
3
|
import { useAuth } from "../../components/auth/auth-provider"
|
|
2
4
|
import type { AuthClient } from "../../lib/auth-client"
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
import { requestPasswordResetOptions } from "../../mutations/auth/request-password-reset-options"
|
|
6
|
+
|
|
7
|
+
export type UseRequestPasswordResetParams = NonNullable<
|
|
8
|
+
Parameters<AuthClient["requestPasswordReset"]>[0]
|
|
9
|
+
>
|
|
10
|
+
|
|
11
|
+
export type UseRequestPasswordResetOptions = Omit<
|
|
12
|
+
ReturnType<typeof requestPasswordResetOptions>,
|
|
13
|
+
"mutationKey" | "mutationFn"
|
|
14
|
+
>
|
|
7
15
|
|
|
8
16
|
/**
|
|
9
17
|
* Hook that creates a mutation for the forgot-password flow.
|
|
10
18
|
*
|
|
11
|
-
*
|
|
12
|
-
* and navigates to the sign-in view on success.
|
|
19
|
+
* Sends a password reset email for the provided address.
|
|
13
20
|
*
|
|
21
|
+
* @param options - React Query options forwarded to `useMutation`.
|
|
14
22
|
* @returns The `useMutation` result.
|
|
15
23
|
*/
|
|
16
24
|
export function useRequestPasswordReset(
|
|
17
|
-
options?:
|
|
25
|
+
options?: UseRequestPasswordResetOptions
|
|
18
26
|
) {
|
|
19
27
|
const { authClient } = useAuth()
|
|
20
28
|
|
|
21
|
-
return
|
|
29
|
+
return useMutation({
|
|
30
|
+
...requestPasswordResetOptions(authClient),
|
|
31
|
+
...options
|
|
32
|
+
})
|
|
22
33
|
}
|
|
@@ -1,21 +1,31 @@
|
|
|
1
|
+
import { useMutation } from "@tanstack/react-query"
|
|
2
|
+
|
|
1
3
|
import { useAuth } from "../../components/auth/auth-provider"
|
|
2
4
|
import type { AuthClient } from "../../lib/auth-client"
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
import { resetPasswordOptions } from "../../mutations/auth/reset-password-options"
|
|
6
|
+
|
|
7
|
+
export type UseResetPasswordParams = NonNullable<
|
|
8
|
+
Parameters<AuthClient["resetPassword"]>[0]
|
|
9
|
+
>
|
|
10
|
+
|
|
11
|
+
export type UseResetPasswordOptions = Omit<
|
|
12
|
+
ReturnType<typeof resetPasswordOptions>,
|
|
13
|
+
"mutationKey" | "mutationFn"
|
|
14
|
+
>
|
|
7
15
|
|
|
8
16
|
/**
|
|
9
17
|
* Hook that creates a mutation for the reset-password flow.
|
|
10
18
|
*
|
|
11
|
-
*
|
|
19
|
+
* Resets the user's password using the provided token and new password.
|
|
12
20
|
*
|
|
21
|
+
* @param options - React Query options forwarded to `useMutation`.
|
|
13
22
|
* @returns The `useMutation` result.
|
|
14
23
|
*/
|
|
15
|
-
export function useResetPassword(
|
|
16
|
-
options?: UseAuthMutationOptions<AuthClient["resetPassword"]>
|
|
17
|
-
) {
|
|
24
|
+
export function useResetPassword(options?: UseResetPasswordOptions) {
|
|
18
25
|
const { authClient } = useAuth()
|
|
19
26
|
|
|
20
|
-
return
|
|
27
|
+
return useMutation({
|
|
28
|
+
...resetPasswordOptions(authClient),
|
|
29
|
+
...options
|
|
30
|
+
})
|
|
21
31
|
}
|