react-query-firebase 2.14.0 → 2.15.1
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/react-native/auth/index.d.ts +1 -0
- package/dist/react-native/auth/index.js +1 -0
- package/dist/react-native/auth/useSignInWithCredentialMutation.d.ts +2 -2
- package/dist/react-native/auth/useSignInWithCredentialMutation.js +2 -2
- package/dist/react-native/auth/useSignInWithCustomToken.d.ts +40 -0
- package/dist/react-native/auth/useSignInWithCustomToken.js +35 -0
- package/dist/web/auth/index.d.ts +1 -0
- package/dist/web/auth/index.js +1 -0
- package/dist/web/auth/useSignInWithCustomToken.d.ts +40 -0
- package/dist/web/auth/useSignInWithCustomToken.js +35 -0
- package/package.json +5 -5
|
@@ -11,6 +11,7 @@ export * from "./useIdToken.js";
|
|
|
11
11
|
export * from "./useReauthenticateWitCredentialMutation.js";
|
|
12
12
|
export * from "./useReauthenticateWitRedirectMutation.js";
|
|
13
13
|
export * from "./useAuthStateReady.js";
|
|
14
|
+
export * from "./useSignInWithCustomToken.js";
|
|
14
15
|
export * from "./useSignInAnonymouslyMutation.js";
|
|
15
16
|
export * from "./useEmailAuthProviderCredential.js";
|
|
16
17
|
export * from "./useFacebookAuthProviderCredential.js";
|
|
@@ -11,6 +11,7 @@ export * from "./useIdToken.js";
|
|
|
11
11
|
export * from "./useReauthenticateWitCredentialMutation.js";
|
|
12
12
|
export * from "./useReauthenticateWitRedirectMutation.js";
|
|
13
13
|
export * from "./useAuthStateReady.js";
|
|
14
|
+
export * from "./useSignInWithCustomToken.js";
|
|
14
15
|
export * from "./useSignInAnonymouslyMutation.js";
|
|
15
16
|
export * from "./useEmailAuthProviderCredential.js";
|
|
16
17
|
export * from "./useFacebookAuthProviderCredential.js";
|
|
@@ -7,7 +7,7 @@ export type UseSignInWithCredentialMutationVariables = {
|
|
|
7
7
|
/**
|
|
8
8
|
* Custom hook for handling sign in using credential
|
|
9
9
|
* This hook utilizes the `useMutation` mechanism to perform the sign-in operation.
|
|
10
|
-
* @param {Omit<UseMutationOptions<FirebaseAuthTypes.UserCredential,
|
|
11
|
-
* @returns {UseMutationResult<FirebaseAuthTypes.UserCredential,
|
|
10
|
+
* @param {Omit<UseMutationOptions<FirebaseAuthTypes.UserCredential, ReactNativeFirebase.NativeFirebaseError, UseSignInWithCredentialMutationVariables, TContext>, "mutationKey" | "mutationFn">} options - Optional configurations for the mutation, omitting the mutationKey and mutationFn properties.
|
|
11
|
+
* @returns {UseMutationResult<FirebaseAuthTypes.UserCredential, ReactNativeFirebase.NativeFirebaseError, UseSignInWithCredentialMutationVariables, TContext>} The result object from the useMutation hook, containing the mutation function and its current state.
|
|
12
12
|
*/
|
|
13
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>;
|
|
@@ -5,8 +5,8 @@ import { useAuth } from "./useAuth.js";
|
|
|
5
5
|
/**
|
|
6
6
|
* Custom hook for handling sign in using credential
|
|
7
7
|
* This hook utilizes the `useMutation` mechanism to perform the sign-in operation.
|
|
8
|
-
* @param {Omit<UseMutationOptions<FirebaseAuthTypes.UserCredential,
|
|
9
|
-
* @returns {UseMutationResult<FirebaseAuthTypes.UserCredential,
|
|
8
|
+
* @param {Omit<UseMutationOptions<FirebaseAuthTypes.UserCredential, ReactNativeFirebase.NativeFirebaseError, UseSignInWithCredentialMutationVariables, TContext>, "mutationKey" | "mutationFn">} options - Optional configurations for the mutation, omitting the mutationKey and mutationFn properties.
|
|
9
|
+
* @returns {UseMutationResult<FirebaseAuthTypes.UserCredential, ReactNativeFirebase.NativeFirebaseError, UseSignInWithCredentialMutationVariables, TContext>} The result object from the useMutation hook, containing the mutation function and its current state.
|
|
10
10
|
*/
|
|
11
11
|
export const useSignInWithCredentialMutation = (options = {}) => {
|
|
12
12
|
const auth = useAuth();
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { UseMutationOptions } from "@tanstack/react-query";
|
|
2
|
+
import { FirebaseAuthTypes } from "@react-native-firebase/auth";
|
|
3
|
+
import { ReactNativeFirebase } from "@react-native-firebase/app";
|
|
4
|
+
/**
|
|
5
|
+
* @inline
|
|
6
|
+
*/
|
|
7
|
+
export type UseSignInWithCustomTokenMutationOptions = {
|
|
8
|
+
/**
|
|
9
|
+
* Options for useMutation hook excluding mutationFn. MutationKey will be equal to reference.path by default.
|
|
10
|
+
*/
|
|
11
|
+
options?: Omit<UseMutationOptions<FirebaseAuthTypes.UserCredential, ReactNativeFirebase.NativeFirebaseError, {
|
|
12
|
+
customToken: string;
|
|
13
|
+
}>, "mutationFn">;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Executes a mutation and returns users credentials
|
|
17
|
+
*
|
|
18
|
+
* @group Hook
|
|
19
|
+
*
|
|
20
|
+
* @param {useSignInWithCustomTokenMutation} options - Configuration options for the mutation.
|
|
21
|
+
*
|
|
22
|
+
* @returns {UseMutationResult<AppModelType, Error, UseAddDocMutationValues<AppModelType>, TContext>} A mutation result
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```jsx
|
|
26
|
+
* export const MyComponent = () => {
|
|
27
|
+
* const {mutate} = useSignInWithCustomTokenMutation({
|
|
28
|
+
* options: {
|
|
29
|
+
* },
|
|
30
|
+
* });
|
|
31
|
+
*
|
|
32
|
+
* // ....
|
|
33
|
+
* mutate();
|
|
34
|
+
* // ....
|
|
35
|
+
* };
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export declare const useSignInWithCustomTokenMutation: ({ options }?: UseSignInWithCustomTokenMutationOptions) => import("@tanstack/react-query").UseMutationResult<FirebaseAuthTypes.UserCredential, ReactNativeFirebase.NativeFirebaseError, {
|
|
39
|
+
customToken: string;
|
|
40
|
+
}, unknown>;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { useMutation } from "@tanstack/react-query";
|
|
2
|
+
import { signInWithCustomToken } from "@react-native-firebase/auth";
|
|
3
|
+
import { useAuth } from "./useAuth.js";
|
|
4
|
+
import { SIGN_IN_ANONYMOUSLY_MUTATION_KEY } from "./mutation-keys.js";
|
|
5
|
+
/**
|
|
6
|
+
* Executes a mutation and returns users credentials
|
|
7
|
+
*
|
|
8
|
+
* @group Hook
|
|
9
|
+
*
|
|
10
|
+
* @param {useSignInWithCustomTokenMutation} options - Configuration options for the mutation.
|
|
11
|
+
*
|
|
12
|
+
* @returns {UseMutationResult<AppModelType, Error, UseAddDocMutationValues<AppModelType>, TContext>} A mutation result
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```jsx
|
|
16
|
+
* export const MyComponent = () => {
|
|
17
|
+
* const {mutate} = useSignInWithCustomTokenMutation({
|
|
18
|
+
* options: {
|
|
19
|
+
* },
|
|
20
|
+
* });
|
|
21
|
+
*
|
|
22
|
+
* // ....
|
|
23
|
+
* mutate();
|
|
24
|
+
* // ....
|
|
25
|
+
* };
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export const useSignInWithCustomTokenMutation = ({ options = {} } = {}) => {
|
|
29
|
+
const firebaseAuth = useAuth();
|
|
30
|
+
return useMutation({
|
|
31
|
+
...options,
|
|
32
|
+
mutationKey: SIGN_IN_ANONYMOUSLY_MUTATION_KEY,
|
|
33
|
+
mutationFn: async ({ customToken }) => signInWithCustomToken(firebaseAuth, customToken)
|
|
34
|
+
});
|
|
35
|
+
};
|
package/dist/web/auth/index.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export * from "./useIdToken.js";
|
|
|
12
12
|
export * from "./useReauthenticateWitCredentialMutation.js";
|
|
13
13
|
export * from "./useReauthenticateWitRedirectMutation.js";
|
|
14
14
|
export * from "./useSignInAnonymouslyMutation.js";
|
|
15
|
+
export * from "./useSignInWithCustomToken.js";
|
|
15
16
|
export * from "./useEmailAuthProviderCredential.js";
|
|
16
17
|
export * from "./useFacebookAuthProviderCredential.js";
|
|
17
18
|
export * from "./useAppleAuthProviderCredential.js";
|
package/dist/web/auth/index.js
CHANGED
|
@@ -12,6 +12,7 @@ export * from "./useIdToken.js";
|
|
|
12
12
|
export * from "./useReauthenticateWitCredentialMutation.js";
|
|
13
13
|
export * from "./useReauthenticateWitRedirectMutation.js";
|
|
14
14
|
export * from "./useSignInAnonymouslyMutation.js";
|
|
15
|
+
export * from "./useSignInWithCustomToken.js";
|
|
15
16
|
export * from "./useEmailAuthProviderCredential.js";
|
|
16
17
|
export * from "./useFacebookAuthProviderCredential.js";
|
|
17
18
|
export * from "./useAppleAuthProviderCredential.js";
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { UseMutationOptions } from "@tanstack/react-query";
|
|
2
|
+
import { UserCredential } from "firebase/auth";
|
|
3
|
+
import { FirebaseError } from "firebase/app";
|
|
4
|
+
/**
|
|
5
|
+
* @inline
|
|
6
|
+
*/
|
|
7
|
+
export type UseSignInWithCustomTokenMutationOptions = {
|
|
8
|
+
/**
|
|
9
|
+
* Options for useMutation hook excluding mutationFn. MutationKey will be equal to reference.path by default.
|
|
10
|
+
*/
|
|
11
|
+
options?: Omit<UseMutationOptions<UserCredential, FirebaseError, {
|
|
12
|
+
customToken: string;
|
|
13
|
+
}>, "mutationFn">;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Executes a mutation and returns users credentials
|
|
17
|
+
*
|
|
18
|
+
* @group Hook
|
|
19
|
+
*
|
|
20
|
+
* @param {useSignInWithCustomTokenMutation} options - Configuration options for the mutation.
|
|
21
|
+
*
|
|
22
|
+
* @returns {UseMutationResult<AppModelType, Error, UseAddDocMutationValues<AppModelType>, TContext>} A mutation result
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```jsx
|
|
26
|
+
* export const MyComponent = () => {
|
|
27
|
+
* const {mutate} = useSignInWithCustomTokenMutation({
|
|
28
|
+
* options: {
|
|
29
|
+
* },
|
|
30
|
+
* });
|
|
31
|
+
*
|
|
32
|
+
* // ....
|
|
33
|
+
* mutate();
|
|
34
|
+
* // ....
|
|
35
|
+
* };
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export declare const useSignInWithCustomTokenMutation: ({ options }?: UseSignInWithCustomTokenMutationOptions) => import("@tanstack/react-query").UseMutationResult<UserCredential, FirebaseError, {
|
|
39
|
+
customToken: string;
|
|
40
|
+
}, unknown>;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { useMutation } from "@tanstack/react-query";
|
|
2
|
+
import { signInWithCustomToken } from "firebase/auth";
|
|
3
|
+
import { useAuth } from "./useAuth.js";
|
|
4
|
+
import { SIGN_IN_ANONYMOUSLY_MUTATION_KEY } from "./mutation-keys.js";
|
|
5
|
+
/**
|
|
6
|
+
* Executes a mutation and returns users credentials
|
|
7
|
+
*
|
|
8
|
+
* @group Hook
|
|
9
|
+
*
|
|
10
|
+
* @param {useSignInWithCustomTokenMutation} options - Configuration options for the mutation.
|
|
11
|
+
*
|
|
12
|
+
* @returns {UseMutationResult<AppModelType, Error, UseAddDocMutationValues<AppModelType>, TContext>} A mutation result
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```jsx
|
|
16
|
+
* export const MyComponent = () => {
|
|
17
|
+
* const {mutate} = useSignInWithCustomTokenMutation({
|
|
18
|
+
* options: {
|
|
19
|
+
* },
|
|
20
|
+
* });
|
|
21
|
+
*
|
|
22
|
+
* // ....
|
|
23
|
+
* mutate();
|
|
24
|
+
* // ....
|
|
25
|
+
* };
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export const useSignInWithCustomTokenMutation = ({ options = {} } = {}) => {
|
|
29
|
+
const firebaseAuth = useAuth();
|
|
30
|
+
return useMutation({
|
|
31
|
+
...options,
|
|
32
|
+
mutationKey: SIGN_IN_ANONYMOUSLY_MUTATION_KEY,
|
|
33
|
+
mutationFn: async ({ customToken }) => signInWithCustomToken(firebaseAuth, customToken)
|
|
34
|
+
});
|
|
35
|
+
};
|
package/package.json
CHANGED
|
@@ -31,15 +31,15 @@
|
|
|
31
31
|
"@react-native-firebase/remote-config": "^23.7.0",
|
|
32
32
|
"@tanstack/react-query": "^5.90.12",
|
|
33
33
|
"@types/react": "^19.2.7",
|
|
34
|
-
"eslint": "^9.39.
|
|
34
|
+
"eslint": "^9.39.2",
|
|
35
35
|
"eslint-config-prettier": "^10.1.8",
|
|
36
36
|
"eslint-plugin-import": "^2.32.0",
|
|
37
|
-
"eslint-plugin-jest": "^29.
|
|
37
|
+
"eslint-plugin-jest": "^29.5.0",
|
|
38
38
|
"eslint-plugin-jsonc": "^2.21.0",
|
|
39
39
|
"eslint-plugin-prettier": "^5.5.4",
|
|
40
40
|
"eslint-plugin-react": "^7.37.5",
|
|
41
41
|
"eslint-plugin-react-hooks": "^7.0.1",
|
|
42
|
-
"firebase": "^12.
|
|
42
|
+
"firebase": "^12.7.0",
|
|
43
43
|
"husky": "^9.1.7",
|
|
44
44
|
"lint-staged": "^16.2.7",
|
|
45
45
|
"prettier": "^3.7.4",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"typedoc-plugin-markdown": "^4.9.0",
|
|
49
49
|
"typedoc-vitepress-theme": "^1.1.2",
|
|
50
50
|
"typescript": "^5.9.3",
|
|
51
|
-
"typescript-eslint": "^8.
|
|
51
|
+
"typescript-eslint": "^8.50.0",
|
|
52
52
|
"vitepress": "^1.6.4"
|
|
53
53
|
},
|
|
54
54
|
"homepage": "https://github.com/vpishuk/react-query-firebase",
|
|
@@ -104,5 +104,5 @@
|
|
|
104
104
|
"docs:build": "vitepress build docs",
|
|
105
105
|
"docs:preview": "vitepress preview docs"
|
|
106
106
|
},
|
|
107
|
-
"version": "2.
|
|
107
|
+
"version": "2.15.1"
|
|
108
108
|
}
|