react-query-firebase 2.9.3 → 2.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/react-native/auth/index.d.ts +1 -0
- package/react-native/auth/index.js +1 -0
- package/react-native/auth/index.ts +1 -0
- package/react-native/auth/mutation-keys.d.ts +1 -0
- package/react-native/auth/mutation-keys.js +1 -0
- package/react-native/auth/mutation-keys.ts +1 -0
- package/react-native/auth/useLinkWithCredentialMutation.d.ts +4 -4
- package/react-native/auth/useLinkWithCredentialMutation.js +2 -2
- package/react-native/auth/useLinkWithCredentialMutation.ts +5 -5
- package/react-native/auth/useSignInWithCredentialMutation.d.ts +13 -0
- package/react-native/auth/useSignInWithCredentialMutation.js +18 -0
- package/react-native/auth/useSignInWithCredentialMutation.ts +36 -0
- package/web/auth/index.d.ts +1 -0
- package/web/auth/index.js +1 -0
- package/web/auth/index.ts +1 -0
- package/web/auth/mutation-keys.d.ts +1 -0
- package/web/auth/mutation-keys.js +1 -0
- package/web/auth/mutation-keys.ts +1 -0
- package/web/auth/useLinkWithCredentialMutation.d.ts +4 -4
- package/web/auth/useLinkWithCredentialMutation.js +2 -2
- package/web/auth/useLinkWithCredentialMutation.ts +5 -5
- package/web/auth/useSignInWithCredentialMutation.d.ts +13 -0
- package/web/auth/useSignInWithCredentialMutation.js +18 -0
- package/web/auth/useSignInWithCredentialMutation.ts +31 -0
package/package.json
CHANGED
|
@@ -3,6 +3,7 @@ export declare const SEND_EMAIL_VERIFICATION_MUTATION_KEY: readonly ["FIREBASE",
|
|
|
3
3
|
export declare const SIGN_IN_ANONYMOUSLY_MUTATION_KEY: readonly ["FIREBASE", "AUTH", "SIGN_IN_ANONYMOUSLY_MUTATION"];
|
|
4
4
|
export declare const SIGN_IN_WITH_EMAIL_AND_PASSWORD_MUTATION_KEY: readonly ["FIREBASE", "AUTH", "SIGN_IN_WITH_EMAIL_AND_PASSWORD_MUTATION"];
|
|
5
5
|
export declare const SIGN_IN_WITH_REDIRECT_MUTATION_KEY: readonly ["FIREBASE", "AUTH", "SIGN_IN_WITH_REDIRECT_MUTATION"];
|
|
6
|
+
export declare const SIGN_IN_WITH_CREDENTIAL_MUTATION_KEY: readonly ["FIREBASE", "AUTH", "SIGN_IN_WITH_CREDENTIAL_MUTATION"];
|
|
6
7
|
export declare const LINK_WITH_CREDENTIAL_MUTATION_KEY: readonly ["FIREBASE", "AUTH", "LINK_WITH_CREDENTIAL_MUTATION"];
|
|
7
8
|
export declare const SIGN_OUT_MUTATION_KEY: readonly ["FIREBASE", "AUTH", "SIGN_OUT"];
|
|
8
9
|
export declare const REAUTHENTICATE_WITH_REDIRECT_MUTATION_KEY: readonly ["FIREBASE", "AUTH", "REAUTHENTICATE_WITH_REDIRECT"];
|
|
@@ -11,6 +11,7 @@ export const SIGN_IN_WITH_EMAIL_AND_PASSWORD_MUTATION_KEY = [
|
|
|
11
11
|
"SIGN_IN_WITH_EMAIL_AND_PASSWORD_MUTATION"
|
|
12
12
|
];
|
|
13
13
|
export const SIGN_IN_WITH_REDIRECT_MUTATION_KEY = ["FIREBASE", "AUTH", "SIGN_IN_WITH_REDIRECT_MUTATION"];
|
|
14
|
+
export const SIGN_IN_WITH_CREDENTIAL_MUTATION_KEY = ["FIREBASE", "AUTH", "SIGN_IN_WITH_CREDENTIAL_MUTATION"];
|
|
14
15
|
export const LINK_WITH_CREDENTIAL_MUTATION_KEY = ["FIREBASE", "AUTH", "LINK_WITH_CREDENTIAL_MUTATION"];
|
|
15
16
|
export const SIGN_OUT_MUTATION_KEY = ["FIREBASE", "AUTH", "SIGN_OUT"];
|
|
16
17
|
export const REAUTHENTICATE_WITH_REDIRECT_MUTATION_KEY = ["FIREBASE", "AUTH", "REAUTHENTICATE_WITH_REDIRECT"];
|
|
@@ -11,6 +11,7 @@ export const SIGN_IN_WITH_EMAIL_AND_PASSWORD_MUTATION_KEY = [
|
|
|
11
11
|
"SIGN_IN_WITH_EMAIL_AND_PASSWORD_MUTATION"
|
|
12
12
|
] as const;
|
|
13
13
|
export const SIGN_IN_WITH_REDIRECT_MUTATION_KEY = ["FIREBASE", "AUTH", "SIGN_IN_WITH_REDIRECT_MUTATION"] as const;
|
|
14
|
+
export const SIGN_IN_WITH_CREDENTIAL_MUTATION_KEY = ["FIREBASE", "AUTH", "SIGN_IN_WITH_CREDENTIAL_MUTATION"] as const;
|
|
14
15
|
export const LINK_WITH_CREDENTIAL_MUTATION_KEY = ["FIREBASE", "AUTH", "LINK_WITH_CREDENTIAL_MUTATION"] as const;
|
|
15
16
|
export const SIGN_OUT_MUTATION_KEY = ["FIREBASE", "AUTH", "SIGN_OUT"] as const;
|
|
16
17
|
export const REAUTHENTICATE_WITH_REDIRECT_MUTATION_KEY = ["FIREBASE", "AUTH", "REAUTHENTICATE_WITH_REDIRECT"] as const;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { UseMutationOptions } from "@tanstack/react-query";
|
|
2
2
|
import { FirebaseAuthTypes } from "@react-native-firebase/auth";
|
|
3
3
|
import { ReactNativeFirebase } from "@react-native-firebase/app";
|
|
4
|
-
export type
|
|
4
|
+
export type UseLinkWitCredentialMutationVariables = {
|
|
5
5
|
user: FirebaseAuthTypes.User;
|
|
6
6
|
credential: FirebaseAuthTypes.AuthCredential;
|
|
7
7
|
};
|
|
8
8
|
/**
|
|
9
9
|
* Custom hook for handling linking of Firebase account to auth provider using credential
|
|
10
10
|
* This hook utilizes the `useMutation` mechanism to perform the sign-in operation.
|
|
11
|
-
* @param {Omit<UseMutationOptions<FirebaseAuthTypes.UserCredential, ReactNativeFirebase.NativeFirebaseError,
|
|
12
|
-
* @returns {UseMutationResult<FirebaseAuthTypes.UserCredential, ReactNativeFirebase.NativeFirebaseError,
|
|
11
|
+
* @param {Omit<UseMutationOptions<FirebaseAuthTypes.UserCredential, ReactNativeFirebase.NativeFirebaseError, UseLinkWitCredentialMutationVariables, TContext>, "mutationKey" | "mutationFn">} options - Optional configurations for the mutation, omitting the mutationKey and mutationFn properties.
|
|
12
|
+
* @returns {UseMutationResult<FirebaseAuthTypes.UserCredential, ReactNativeFirebase.NativeFirebaseError, UseLinkWitCredentialMutationVariables, TContext>} The result object from the useMutation hook, containing the mutation function and its current state.
|
|
13
13
|
*/
|
|
14
|
-
export declare const useLinkWithCredentialMutation: <TContext = unknown>(options?: Omit<UseMutationOptions<FirebaseAuthTypes.UserCredential, ReactNativeFirebase.NativeFirebaseError,
|
|
14
|
+
export declare const useLinkWithCredentialMutation: <TContext = unknown>(options?: Omit<UseMutationOptions<FirebaseAuthTypes.UserCredential, ReactNativeFirebase.NativeFirebaseError, UseLinkWitCredentialMutationVariables, TContext>, "mutationKey" | "mutationFn">) => import("@tanstack/react-query").UseMutationResult<FirebaseAuthTypes.UserCredential, ReactNativeFirebase.NativeFirebaseError, UseLinkWitCredentialMutationVariables, TContext>;
|
|
@@ -4,8 +4,8 @@ import { LINK_WITH_CREDENTIAL_MUTATION_KEY } from "./mutation-keys";
|
|
|
4
4
|
/**
|
|
5
5
|
* Custom hook for handling linking of Firebase account to auth provider using credential
|
|
6
6
|
* This hook utilizes the `useMutation` mechanism to perform the sign-in operation.
|
|
7
|
-
* @param {Omit<UseMutationOptions<FirebaseAuthTypes.UserCredential, ReactNativeFirebase.NativeFirebaseError,
|
|
8
|
-
* @returns {UseMutationResult<FirebaseAuthTypes.UserCredential, ReactNativeFirebase.NativeFirebaseError,
|
|
7
|
+
* @param {Omit<UseMutationOptions<FirebaseAuthTypes.UserCredential, ReactNativeFirebase.NativeFirebaseError, UseLinkWitCredentialMutationVariables, TContext>, "mutationKey" | "mutationFn">} options - Optional configurations for the mutation, omitting the mutationKey and mutationFn properties.
|
|
8
|
+
* @returns {UseMutationResult<FirebaseAuthTypes.UserCredential, ReactNativeFirebase.NativeFirebaseError, UseLinkWitCredentialMutationVariables, TContext>} The result object from the useMutation hook, containing the mutation function and its current state.
|
|
9
9
|
*/
|
|
10
10
|
export const useLinkWithCredentialMutation = (options = {}) => {
|
|
11
11
|
return useMutation({
|
|
@@ -4,7 +4,7 @@ import { linkWithCredential, FirebaseAuthTypes } from "@react-native-firebase/au
|
|
|
4
4
|
import { LINK_WITH_CREDENTIAL_MUTATION_KEY } from "./mutation-keys";
|
|
5
5
|
import { ReactNativeFirebase } from "@react-native-firebase/app";
|
|
6
6
|
|
|
7
|
-
export type
|
|
7
|
+
export type UseLinkWitCredentialMutationVariables = {
|
|
8
8
|
user: FirebaseAuthTypes.User;
|
|
9
9
|
credential: FirebaseAuthTypes.AuthCredential;
|
|
10
10
|
};
|
|
@@ -12,15 +12,15 @@ export type UseLinkWitRedirectMutationVariables = {
|
|
|
12
12
|
/**
|
|
13
13
|
* Custom hook for handling linking of Firebase account to auth provider using credential
|
|
14
14
|
* This hook utilizes the `useMutation` mechanism to perform the sign-in operation.
|
|
15
|
-
* @param {Omit<UseMutationOptions<FirebaseAuthTypes.UserCredential, ReactNativeFirebase.NativeFirebaseError,
|
|
16
|
-
* @returns {UseMutationResult<FirebaseAuthTypes.UserCredential, ReactNativeFirebase.NativeFirebaseError,
|
|
15
|
+
* @param {Omit<UseMutationOptions<FirebaseAuthTypes.UserCredential, ReactNativeFirebase.NativeFirebaseError, UseLinkWitCredentialMutationVariables, TContext>, "mutationKey" | "mutationFn">} options - Optional configurations for the mutation, omitting the mutationKey and mutationFn properties.
|
|
16
|
+
* @returns {UseMutationResult<FirebaseAuthTypes.UserCredential, ReactNativeFirebase.NativeFirebaseError, UseLinkWitCredentialMutationVariables, TContext>} The result object from the useMutation hook, containing the mutation function and its current state.
|
|
17
17
|
*/
|
|
18
18
|
export const useLinkWithCredentialMutation = <TContext = unknown>(
|
|
19
19
|
options: Omit<
|
|
20
20
|
UseMutationOptions<
|
|
21
21
|
FirebaseAuthTypes.UserCredential,
|
|
22
22
|
ReactNativeFirebase.NativeFirebaseError,
|
|
23
|
-
|
|
23
|
+
UseLinkWitCredentialMutationVariables,
|
|
24
24
|
TContext
|
|
25
25
|
>,
|
|
26
26
|
"mutationKey" | "mutationFn"
|
|
@@ -28,7 +28,7 @@ export const useLinkWithCredentialMutation = <TContext = unknown>(
|
|
|
28
28
|
) => {
|
|
29
29
|
return useMutation({
|
|
30
30
|
...options,
|
|
31
|
-
mutationFn: async ({ user, credential }:
|
|
31
|
+
mutationFn: async ({ user, credential }: UseLinkWitCredentialMutationVariables) =>
|
|
32
32
|
linkWithCredential(user, credential),
|
|
33
33
|
mutationKey: LINK_WITH_CREDENTIAL_MUTATION_KEY
|
|
34
34
|
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { UseMutationOptions } from "@tanstack/react-query";
|
|
2
|
+
import { FirebaseAuthTypes } from "@react-native-firebase/auth";
|
|
3
|
+
import { ReactNativeFirebase } from "@react-native-firebase/app";
|
|
4
|
+
export type UseSignInWithCredentialMutationVariables = {
|
|
5
|
+
credential: FirebaseAuthTypes.AuthCredential;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Custom hook for handling sign in using credential
|
|
9
|
+
* This hook utilizes the `useMutation` mechanism to perform the sign-in operation.
|
|
10
|
+
* @param {Omit<UseMutationOptions<FirebaseAuthTypes.UserCredential, FirebaseError, UseSignInWithCredentialMutationVariables, TContext>, "mutationKey" | "mutationFn">} options - Optional configurations for the mutation, omitting the mutationKey and mutationFn properties.
|
|
11
|
+
* @returns {UseMutationResult<FirebaseAuthTypes.UserCredential, FirebaseError, UseSignInWithCredentialMutationVariables, TContext>} The result object from the useMutation hook, containing the mutation function and its current state.
|
|
12
|
+
*/
|
|
13
|
+
export declare const useSignInWithCredentialMutation: <TContext = unknown>(options?: Omit<UseMutationOptions<FirebaseAuthTypes.UserCredential, ReactNativeFirebase.NativeFirebaseError, UseSignInWithCredentialMutationVariables, TContext>, "mutationKey" | "mutationFn">) => import("@tanstack/react-query").UseMutationResult<FirebaseAuthTypes.UserCredential, ReactNativeFirebase.NativeFirebaseError, UseSignInWithCredentialMutationVariables, TContext>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { useMutation } from "@tanstack/react-query";
|
|
2
|
+
import { signInWithCredential } from "@react-native-firebase/auth";
|
|
3
|
+
import { SIGN_IN_WITH_CREDENTIAL_MUTATION_KEY } from "./mutation-keys";
|
|
4
|
+
import { useAuth } from "./useAuth";
|
|
5
|
+
/**
|
|
6
|
+
* Custom hook for handling sign in using credential
|
|
7
|
+
* This hook utilizes the `useMutation` mechanism to perform the sign-in operation.
|
|
8
|
+
* @param {Omit<UseMutationOptions<FirebaseAuthTypes.UserCredential, FirebaseError, UseSignInWithCredentialMutationVariables, TContext>, "mutationKey" | "mutationFn">} options - Optional configurations for the mutation, omitting the mutationKey and mutationFn properties.
|
|
9
|
+
* @returns {UseMutationResult<FirebaseAuthTypes.UserCredential, FirebaseError, UseSignInWithCredentialMutationVariables, TContext>} The result object from the useMutation hook, containing the mutation function and its current state.
|
|
10
|
+
*/
|
|
11
|
+
export const useSignInWithCredentialMutation = (options = {}) => {
|
|
12
|
+
const auth = useAuth();
|
|
13
|
+
return useMutation({
|
|
14
|
+
...options,
|
|
15
|
+
mutationFn: async ({ credential }) => signInWithCredential(auth, credential),
|
|
16
|
+
mutationKey: SIGN_IN_WITH_CREDENTIAL_MUTATION_KEY
|
|
17
|
+
});
|
|
18
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { useMutation, UseMutationOptions } from "@tanstack/react-query";
|
|
2
|
+
import { FirebaseAuthTypes, signInWithCredential } from "@react-native-firebase/auth";
|
|
3
|
+
|
|
4
|
+
import { SIGN_IN_WITH_CREDENTIAL_MUTATION_KEY } from "./mutation-keys";
|
|
5
|
+
import { useAuth } from "./useAuth";
|
|
6
|
+
import { ReactNativeFirebase } from "@react-native-firebase/app";
|
|
7
|
+
|
|
8
|
+
export type UseSignInWithCredentialMutationVariables = {
|
|
9
|
+
credential: FirebaseAuthTypes.AuthCredential;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Custom hook for handling sign in using credential
|
|
14
|
+
* This hook utilizes the `useMutation` mechanism to perform the sign-in operation.
|
|
15
|
+
* @param {Omit<UseMutationOptions<FirebaseAuthTypes.UserCredential, FirebaseError, UseSignInWithCredentialMutationVariables, TContext>, "mutationKey" | "mutationFn">} options - Optional configurations for the mutation, omitting the mutationKey and mutationFn properties.
|
|
16
|
+
* @returns {UseMutationResult<FirebaseAuthTypes.UserCredential, FirebaseError, UseSignInWithCredentialMutationVariables, TContext>} The result object from the useMutation hook, containing the mutation function and its current state.
|
|
17
|
+
*/
|
|
18
|
+
export const useSignInWithCredentialMutation = <TContext = unknown>(
|
|
19
|
+
options: Omit<
|
|
20
|
+
UseMutationOptions<
|
|
21
|
+
FirebaseAuthTypes.UserCredential,
|
|
22
|
+
ReactNativeFirebase.NativeFirebaseError,
|
|
23
|
+
UseSignInWithCredentialMutationVariables,
|
|
24
|
+
TContext
|
|
25
|
+
>,
|
|
26
|
+
"mutationKey" | "mutationFn"
|
|
27
|
+
> = {}
|
|
28
|
+
) => {
|
|
29
|
+
const auth = useAuth();
|
|
30
|
+
return useMutation({
|
|
31
|
+
...options,
|
|
32
|
+
mutationFn: async ({ credential }: UseSignInWithCredentialMutationVariables) =>
|
|
33
|
+
signInWithCredential(auth, credential),
|
|
34
|
+
mutationKey: SIGN_IN_WITH_CREDENTIAL_MUTATION_KEY
|
|
35
|
+
});
|
|
36
|
+
};
|
package/web/auth/index.d.ts
CHANGED
package/web/auth/index.js
CHANGED
package/web/auth/index.ts
CHANGED
|
@@ -3,6 +3,7 @@ export declare const SEND_EMAIL_VERIFICATION_MUTATION_KEY: readonly ["FIREBASE",
|
|
|
3
3
|
export declare const SIGN_IN_ANONYMOUSLY_MUTATION_KEY: readonly ["FIREBASE", "AUTH", "SIGN_IN_ANONYMOUSLY_MUTATION"];
|
|
4
4
|
export declare const SIGN_IN_WITH_EMAIL_AND_PASSWORD_MUTATION_KEY: readonly ["FIREBASE", "AUTH", "SIGN_IN_WITH_EMAIL_AND_PASSWORD_MUTATION"];
|
|
5
5
|
export declare const SIGN_IN_WITH_REDIRECT_MUTATION_KEY: readonly ["FIREBASE", "AUTH", "SIGN_IN_WITH_REDIRECT_MUTATION"];
|
|
6
|
+
export declare const SIGN_IN_WITH_CREDENTIAL_MUTATION_KEY: readonly ["FIREBASE", "AUTH", "SIGN_IN_WITH_CREDENTIAL_MUTATION"];
|
|
6
7
|
export declare const LINK_WITH_CREDENTIAL_MUTATION_KEY: readonly ["FIREBASE", "AUTH", "LINK_WITH_CREDENTIAL_MUTATION"];
|
|
7
8
|
export declare const SIGN_OUT_MUTATION_KEY: readonly ["FIREBASE", "AUTH", "SIGN_OUT"];
|
|
8
9
|
export declare const REAUTHENTICATE_WITH_REDIRECT_MUTATION_KEY: readonly ["FIREBASE", "AUTH", "REAUTHENTICATE_WITH_REDIRECT"];
|
|
@@ -11,6 +11,7 @@ export const SIGN_IN_WITH_EMAIL_AND_PASSWORD_MUTATION_KEY = [
|
|
|
11
11
|
"SIGN_IN_WITH_EMAIL_AND_PASSWORD_MUTATION"
|
|
12
12
|
];
|
|
13
13
|
export const SIGN_IN_WITH_REDIRECT_MUTATION_KEY = ["FIREBASE", "AUTH", "SIGN_IN_WITH_REDIRECT_MUTATION"];
|
|
14
|
+
export const SIGN_IN_WITH_CREDENTIAL_MUTATION_KEY = ["FIREBASE", "AUTH", "SIGN_IN_WITH_CREDENTIAL_MUTATION"];
|
|
14
15
|
export const LINK_WITH_CREDENTIAL_MUTATION_KEY = ["FIREBASE", "AUTH", "LINK_WITH_CREDENTIAL_MUTATION"];
|
|
15
16
|
export const SIGN_OUT_MUTATION_KEY = ["FIREBASE", "AUTH", "SIGN_OUT"];
|
|
16
17
|
export const REAUTHENTICATE_WITH_REDIRECT_MUTATION_KEY = ["FIREBASE", "AUTH", "REAUTHENTICATE_WITH_REDIRECT"];
|
|
@@ -11,6 +11,7 @@ export const SIGN_IN_WITH_EMAIL_AND_PASSWORD_MUTATION_KEY = [
|
|
|
11
11
|
"SIGN_IN_WITH_EMAIL_AND_PASSWORD_MUTATION"
|
|
12
12
|
] as const;
|
|
13
13
|
export const SIGN_IN_WITH_REDIRECT_MUTATION_KEY = ["FIREBASE", "AUTH", "SIGN_IN_WITH_REDIRECT_MUTATION"] as const;
|
|
14
|
+
export const SIGN_IN_WITH_CREDENTIAL_MUTATION_KEY = ["FIREBASE", "AUTH", "SIGN_IN_WITH_CREDENTIAL_MUTATION"] as const;
|
|
14
15
|
export const LINK_WITH_CREDENTIAL_MUTATION_KEY = ["FIREBASE", "AUTH", "LINK_WITH_CREDENTIAL_MUTATION"] as const;
|
|
15
16
|
export const SIGN_OUT_MUTATION_KEY = ["FIREBASE", "AUTH", "SIGN_OUT"] as const;
|
|
16
17
|
export const REAUTHENTICATE_WITH_REDIRECT_MUTATION_KEY = ["FIREBASE", "AUTH", "REAUTHENTICATE_WITH_REDIRECT"] as const;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { UseMutationOptions } from "@tanstack/react-query";
|
|
2
2
|
import { User, AuthCredential, UserCredential } from "firebase/auth";
|
|
3
3
|
import { FirebaseError } from "firebase/app";
|
|
4
|
-
export type
|
|
4
|
+
export type UseLinkWitCredentialMutationVariables = {
|
|
5
5
|
user: User;
|
|
6
6
|
credential: AuthCredential;
|
|
7
7
|
};
|
|
8
8
|
/**
|
|
9
9
|
* Custom hook for handling linking of Firebase account to auth provider using credential
|
|
10
10
|
* This hook utilizes the `useMutation` mechanism to perform the sign-in operation.
|
|
11
|
-
* @param {Omit<UseMutationOptions<UserCredential, FirebaseError,
|
|
12
|
-
* @returns {UseMutationResult<UserCredential, FirebaseError,
|
|
11
|
+
* @param {Omit<UseMutationOptions<UserCredential, FirebaseError, UseLinkWitCredentialMutationVariables, TContext>, "mutationKey" | "mutationFn">} options - Optional configurations for the mutation, omitting the mutationKey and mutationFn properties.
|
|
12
|
+
* @returns {UseMutationResult<UserCredential, FirebaseError, UseLinkWitCredentialMutationVariables, TContext>} The result object from the useMutation hook, containing the mutation function and its current state.
|
|
13
13
|
*/
|
|
14
|
-
export declare const useLinkWithCredentialMutation: <TContext = unknown>(options?: Omit<UseMutationOptions<UserCredential, FirebaseError,
|
|
14
|
+
export declare const useLinkWithCredentialMutation: <TContext = unknown>(options?: Omit<UseMutationOptions<UserCredential, FirebaseError, UseLinkWitCredentialMutationVariables, TContext>, "mutationKey" | "mutationFn">) => import("@tanstack/react-query").UseMutationResult<UserCredential, FirebaseError, UseLinkWitCredentialMutationVariables, TContext>;
|
|
@@ -4,8 +4,8 @@ import { LINK_WITH_CREDENTIAL_MUTATION_KEY } from "./mutation-keys";
|
|
|
4
4
|
/**
|
|
5
5
|
* Custom hook for handling linking of Firebase account to auth provider using credential
|
|
6
6
|
* This hook utilizes the `useMutation` mechanism to perform the sign-in operation.
|
|
7
|
-
* @param {Omit<UseMutationOptions<UserCredential, FirebaseError,
|
|
8
|
-
* @returns {UseMutationResult<UserCredential, FirebaseError,
|
|
7
|
+
* @param {Omit<UseMutationOptions<UserCredential, FirebaseError, UseLinkWitCredentialMutationVariables, TContext>, "mutationKey" | "mutationFn">} options - Optional configurations for the mutation, omitting the mutationKey and mutationFn properties.
|
|
8
|
+
* @returns {UseMutationResult<UserCredential, FirebaseError, UseLinkWitCredentialMutationVariables, TContext>} The result object from the useMutation hook, containing the mutation function and its current state.
|
|
9
9
|
*/
|
|
10
10
|
export const useLinkWithCredentialMutation = (options = {}) => {
|
|
11
11
|
return useMutation({
|
|
@@ -4,7 +4,7 @@ import { linkWithCredential, User, AuthCredential, UserCredential } from "fireba
|
|
|
4
4
|
import { LINK_WITH_CREDENTIAL_MUTATION_KEY } from "./mutation-keys";
|
|
5
5
|
import { FirebaseError } from "firebase/app";
|
|
6
6
|
|
|
7
|
-
export type
|
|
7
|
+
export type UseLinkWitCredentialMutationVariables = {
|
|
8
8
|
user: User;
|
|
9
9
|
credential: AuthCredential;
|
|
10
10
|
};
|
|
@@ -12,18 +12,18 @@ export type UseLinkWitRedirectMutationVariables = {
|
|
|
12
12
|
/**
|
|
13
13
|
* Custom hook for handling linking of Firebase account to auth provider using credential
|
|
14
14
|
* This hook utilizes the `useMutation` mechanism to perform the sign-in operation.
|
|
15
|
-
* @param {Omit<UseMutationOptions<UserCredential, FirebaseError,
|
|
16
|
-
* @returns {UseMutationResult<UserCredential, FirebaseError,
|
|
15
|
+
* @param {Omit<UseMutationOptions<UserCredential, FirebaseError, UseLinkWitCredentialMutationVariables, TContext>, "mutationKey" | "mutationFn">} options - Optional configurations for the mutation, omitting the mutationKey and mutationFn properties.
|
|
16
|
+
* @returns {UseMutationResult<UserCredential, FirebaseError, UseLinkWitCredentialMutationVariables, TContext>} The result object from the useMutation hook, containing the mutation function and its current state.
|
|
17
17
|
*/
|
|
18
18
|
export const useLinkWithCredentialMutation = <TContext = unknown>(
|
|
19
19
|
options: Omit<
|
|
20
|
-
UseMutationOptions<UserCredential, FirebaseError,
|
|
20
|
+
UseMutationOptions<UserCredential, FirebaseError, UseLinkWitCredentialMutationVariables, TContext>,
|
|
21
21
|
"mutationKey" | "mutationFn"
|
|
22
22
|
> = {}
|
|
23
23
|
) => {
|
|
24
24
|
return useMutation({
|
|
25
25
|
...options,
|
|
26
|
-
mutationFn: async ({ user, credential }:
|
|
26
|
+
mutationFn: async ({ user, credential }: UseLinkWitCredentialMutationVariables) =>
|
|
27
27
|
linkWithCredential(user, credential),
|
|
28
28
|
mutationKey: LINK_WITH_CREDENTIAL_MUTATION_KEY
|
|
29
29
|
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { UseMutationOptions } from "@tanstack/react-query";
|
|
2
|
+
import { AuthCredential, UserCredential } from "firebase/auth";
|
|
3
|
+
import { FirebaseError } from "firebase/app";
|
|
4
|
+
export type UseSignInWithCredentialMutationVariables = {
|
|
5
|
+
credential: AuthCredential;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Custom hook for handling sign in using credential
|
|
9
|
+
* This hook utilizes the `useMutation` mechanism to perform the sign-in operation.
|
|
10
|
+
* @param {Omit<UseMutationOptions<UserCredential, FirebaseError, UseSignInWithCredentialMutationVariables, TContext>, "mutationKey" | "mutationFn">} options - Optional configurations for the mutation, omitting the mutationKey and mutationFn properties.
|
|
11
|
+
* @returns {UseMutationResult<UserCredential, FirebaseError, UseSignInWithCredentialMutationVariables, TContext>} The result object from the useMutation hook, containing the mutation function and its current state.
|
|
12
|
+
*/
|
|
13
|
+
export declare const useSignInWithCredentialMutation: <TContext = unknown>(options?: Omit<UseMutationOptions<UserCredential, FirebaseError, UseSignInWithCredentialMutationVariables, TContext>, "mutationKey" | "mutationFn">) => import("@tanstack/react-query").UseMutationResult<UserCredential, FirebaseError, UseSignInWithCredentialMutationVariables, TContext>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { useMutation } from "@tanstack/react-query";
|
|
2
|
+
import { signInWithCredential } from "firebase/auth";
|
|
3
|
+
import { SIGN_IN_WITH_CREDENTIAL_MUTATION_KEY } from "./mutation-keys";
|
|
4
|
+
import { useAuth } from "./useAuth";
|
|
5
|
+
/**
|
|
6
|
+
* Custom hook for handling sign in using credential
|
|
7
|
+
* This hook utilizes the `useMutation` mechanism to perform the sign-in operation.
|
|
8
|
+
* @param {Omit<UseMutationOptions<UserCredential, FirebaseError, UseSignInWithCredentialMutationVariables, TContext>, "mutationKey" | "mutationFn">} options - Optional configurations for the mutation, omitting the mutationKey and mutationFn properties.
|
|
9
|
+
* @returns {UseMutationResult<UserCredential, FirebaseError, UseSignInWithCredentialMutationVariables, TContext>} The result object from the useMutation hook, containing the mutation function and its current state.
|
|
10
|
+
*/
|
|
11
|
+
export const useSignInWithCredentialMutation = (options = {}) => {
|
|
12
|
+
const auth = useAuth();
|
|
13
|
+
return useMutation({
|
|
14
|
+
...options,
|
|
15
|
+
mutationFn: async ({ credential }) => signInWithCredential(auth, credential),
|
|
16
|
+
mutationKey: SIGN_IN_WITH_CREDENTIAL_MUTATION_KEY
|
|
17
|
+
});
|
|
18
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { useMutation, UseMutationOptions } from "@tanstack/react-query";
|
|
2
|
+
import { AuthCredential, UserCredential, signInWithCredential } from "firebase/auth";
|
|
3
|
+
|
|
4
|
+
import { SIGN_IN_WITH_CREDENTIAL_MUTATION_KEY } from "./mutation-keys";
|
|
5
|
+
import { FirebaseError } from "firebase/app";
|
|
6
|
+
import { useAuth } from "./useAuth";
|
|
7
|
+
|
|
8
|
+
export type UseSignInWithCredentialMutationVariables = {
|
|
9
|
+
credential: AuthCredential;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Custom hook for handling sign in using credential
|
|
14
|
+
* This hook utilizes the `useMutation` mechanism to perform the sign-in operation.
|
|
15
|
+
* @param {Omit<UseMutationOptions<UserCredential, FirebaseError, UseSignInWithCredentialMutationVariables, TContext>, "mutationKey" | "mutationFn">} options - Optional configurations for the mutation, omitting the mutationKey and mutationFn properties.
|
|
16
|
+
* @returns {UseMutationResult<UserCredential, FirebaseError, UseSignInWithCredentialMutationVariables, TContext>} The result object from the useMutation hook, containing the mutation function and its current state.
|
|
17
|
+
*/
|
|
18
|
+
export const useSignInWithCredentialMutation = <TContext = unknown>(
|
|
19
|
+
options: Omit<
|
|
20
|
+
UseMutationOptions<UserCredential, FirebaseError, UseSignInWithCredentialMutationVariables, TContext>,
|
|
21
|
+
"mutationKey" | "mutationFn"
|
|
22
|
+
> = {}
|
|
23
|
+
) => {
|
|
24
|
+
const auth = useAuth();
|
|
25
|
+
return useMutation({
|
|
26
|
+
...options,
|
|
27
|
+
mutationFn: async ({ credential }: UseSignInWithCredentialMutationVariables) =>
|
|
28
|
+
signInWithCredential(auth, credential),
|
|
29
|
+
mutationKey: SIGN_IN_WITH_CREDENTIAL_MUTATION_KEY
|
|
30
|
+
});
|
|
31
|
+
};
|