react-query-firebase 2.0.0-rc6 → 2.0.0-rc7

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.
Files changed (274) hide show
  1. package/package.json +16 -13
  2. package/web/analytics/index.d.ts +3 -0
  3. package/web/analytics/index.js +3 -0
  4. package/web/analytics/index.ts +3 -0
  5. package/web/analytics/useAnalytics.d.ts +5 -0
  6. package/web/analytics/useAnalytics.js +10 -0
  7. package/web/analytics/useAnalytics.ts +12 -0
  8. package/web/analytics/useLogEvent.d.ts +17 -0
  9. package/web/analytics/useLogEvent.js +21 -0
  10. package/web/analytics/useLogEvent.ts +34 -0
  11. package/web/analytics/useSetAnalyticsCollectionEnabled.d.ts +10 -0
  12. package/web/analytics/useSetAnalyticsCollectionEnabled.js +16 -0
  13. package/web/analytics/useSetAnalyticsCollectionEnabled.ts +22 -0
  14. package/web/auth/index.d.ts +13 -0
  15. package/web/auth/index.js +13 -0
  16. package/web/auth/index.ts +13 -0
  17. package/web/auth/mutation-keys.d.ts +7 -0
  18. package/web/auth/mutation-keys.js +19 -0
  19. package/web/auth/mutation-keys.ts +19 -0
  20. package/web/auth/useAuth.d.ts +5 -0
  21. package/web/auth/useAuth.js +10 -0
  22. package/web/auth/useAuth.ts +12 -0
  23. package/web/auth/useAuthStateReady.d.ts +6 -0
  24. package/web/auth/useAuthStateReady.js +19 -0
  25. package/web/auth/useAuthStateReady.ts +24 -0
  26. package/web/auth/useCreateUserWitEmailAndPasswordMutation.d.ts +15 -0
  27. package/web/auth/useCreateUserWitEmailAndPasswordMutation.js +19 -0
  28. package/web/auth/useCreateUserWitEmailAndPasswordMutation.ts +33 -0
  29. package/web/auth/useCurrentUser.d.ts +6 -0
  30. package/web/auth/useCurrentUser.js +20 -0
  31. package/web/auth/useCurrentUser.ts +24 -0
  32. package/web/auth/useIdToken.d.ts +30 -0
  33. package/web/auth/useIdToken.js +66 -0
  34. package/web/auth/useIdToken.ts +83 -0
  35. package/web/auth/useReauthenticateWitCredentialMutation.d.ts +16 -0
  36. package/web/auth/useReauthenticateWitCredentialMutation.js +18 -0
  37. package/web/auth/useReauthenticateWitCredentialMutation.ts +31 -0
  38. package/web/auth/useReauthenticateWitRedirectMutation.d.ts +17 -0
  39. package/web/auth/useReauthenticateWitRedirectMutation.js +18 -0
  40. package/web/auth/useReauthenticateWitRedirectMutation.ts +37 -0
  41. package/web/auth/useSendEmailVerificationMutation.d.ts +13 -0
  42. package/web/auth/useSendEmailVerificationMutation.js +16 -0
  43. package/web/auth/useSendEmailVerificationMutation.ts +28 -0
  44. package/web/auth/useSignInWitEmailAndPasswordMutation.d.ts +15 -0
  45. package/web/auth/useSignInWitEmailAndPasswordMutation.js +19 -0
  46. package/web/auth/useSignInWitEmailAndPasswordMutation.ts +34 -0
  47. package/web/auth/useSignInWitRedirectMutation.d.ts +14 -0
  48. package/web/auth/useSignInWitRedirectMutation.js +18 -0
  49. package/web/auth/useSignInWitRedirectMutation.ts +33 -0
  50. package/web/auth/useSignOutMutation.d.ts +10 -0
  51. package/web/auth/useSignOutMutation.js +19 -0
  52. package/web/auth/useSignOutMutation.ts +25 -0
  53. package/web/auth/useUpdateProfileMutation.d.ts +15 -0
  54. package/web/auth/useUpdateProfileMutation.js +17 -0
  55. package/web/auth/useUpdateProfileMutation.ts +30 -0
  56. package/web/context/FirebaseContext.d.ts +19 -0
  57. package/web/context/FirebaseContext.js +8 -0
  58. package/web/context/FirebaseContext.ts +25 -0
  59. package/web/context/FirebaseContextProvider.d.ts +127 -0
  60. package/web/context/FirebaseContextProvider.js +100 -0
  61. package/web/context/FirebaseContextProvider.tsx +231 -0
  62. package/web/context/index.d.ts +1 -0
  63. package/web/context/index.js +1 -0
  64. package/web/context/index.ts +1 -0
  65. package/web/firestore/index.d.ts +16 -0
  66. package/web/firestore/index.js +16 -0
  67. package/web/firestore/index.ts +16 -0
  68. package/web/firestore/useAddDocMutation.d.ts +23 -0
  69. package/web/firestore/useAddDocMutation.js +26 -0
  70. package/web/firestore/useAddDocMutation.ts +62 -0
  71. package/web/firestore/useBatchWrite.d.ts +15 -0
  72. package/web/firestore/useBatchWrite.js +21 -0
  73. package/web/firestore/useBatchWrite.ts +31 -0
  74. package/web/firestore/useCollectionReference.d.ts +18 -0
  75. package/web/firestore/useCollectionReference.js +24 -0
  76. package/web/firestore/useCollectionReference.ts +37 -0
  77. package/web/firestore/useCompositeFilter.d.ts +30 -0
  78. package/web/firestore/useCompositeFilter.js +43 -0
  79. package/web/firestore/useCompositeFilter.ts +86 -0
  80. package/web/firestore/useCountQuery.d.ts +23 -0
  81. package/web/firestore/useCountQuery.js +30 -0
  82. package/web/firestore/useCountQuery.ts +65 -0
  83. package/web/firestore/useDeleteDocMutation.d.ts +18 -0
  84. package/web/firestore/useDeleteDocMutation.js +23 -0
  85. package/web/firestore/useDeleteDocMutation.ts +47 -0
  86. package/web/firestore/useDocReference.d.ts +19 -0
  87. package/web/firestore/useDocReference.js +45 -0
  88. package/web/firestore/useDocReference.ts +68 -0
  89. package/web/firestore/useDocReferences.d.ts +23 -0
  90. package/web/firestore/useDocReferences.js +31 -0
  91. package/web/firestore/useDocReferences.ts +44 -0
  92. package/web/firestore/useFirestore.d.ts +7 -0
  93. package/web/firestore/useFirestore.js +12 -0
  94. package/web/firestore/useFirestore.ts +13 -0
  95. package/web/firestore/useGetDocData.d.ts +18 -0
  96. package/web/firestore/useGetDocData.js +18 -0
  97. package/web/firestore/useGetDocData.ts +41 -0
  98. package/web/firestore/useGetRealtimeDocData.d.ts +57 -0
  99. package/web/firestore/useGetRealtimeDocData.js +56 -0
  100. package/web/firestore/useGetRealtimeDocData.ts +104 -0
  101. package/web/firestore/useInfiniteQuery.d.ts +18 -0
  102. package/web/firestore/useInfiniteQuery.js +28 -0
  103. package/web/firestore/useInfiniteQuery.ts +91 -0
  104. package/web/firestore/useQuery.d.ts +25 -0
  105. package/web/firestore/useQuery.js +34 -0
  106. package/web/firestore/useQuery.ts +72 -0
  107. package/web/firestore/useRunTransaction.d.ts +15 -0
  108. package/web/firestore/useRunTransaction.js +19 -0
  109. package/web/firestore/useRunTransaction.ts +31 -0
  110. package/web/firestore/useSetDocMutation.d.ts +20 -0
  111. package/web/firestore/useSetDocMutation.js +25 -0
  112. package/web/firestore/useSetDocMutation.ts +52 -0
  113. package/web/firestore/useUpdateDocMutation.d.ts +31 -0
  114. package/web/firestore/useUpdateDocMutation.js +37 -0
  115. package/web/firestore/useUpdateDocMutation.ts +74 -0
  116. package/web/firestore/utils/getDocData.d.ts +18 -0
  117. package/web/firestore/utils/getDocData.js +22 -0
  118. package/web/firestore/utils/getDocData.ts +39 -0
  119. package/web/firestore/utils/getDocRef.d.ts +19 -0
  120. package/web/firestore/utils/getDocRef.js +25 -0
  121. package/web/firestore/utils/getDocRef.ts +46 -0
  122. package/web/firestore/utils/getDocSnap.d.ts +20 -0
  123. package/web/firestore/utils/getDocSnap.js +25 -0
  124. package/web/firestore/utils/getDocSnap.ts +41 -0
  125. package/web/index.d.ts +5 -0
  126. package/web/index.js +5 -0
  127. package/web/index.ts +5 -0
  128. package/web/remoteConfig/index.d.ts +3 -0
  129. package/web/remoteConfig/index.js +3 -0
  130. package/web/remoteConfig/index.ts +3 -0
  131. package/web/remoteConfig/useFetchAndActivate.d.ts +11 -0
  132. package/web/remoteConfig/useFetchAndActivate.js +31 -0
  133. package/web/remoteConfig/useFetchAndActivate.ts +36 -0
  134. package/web/remoteConfig/useGetValue.d.ts +7 -0
  135. package/web/remoteConfig/useGetValue.js +15 -0
  136. package/web/remoteConfig/useGetValue.ts +16 -0
  137. package/web/remoteConfig/useRemoteConfig.d.ts +5 -0
  138. package/web/remoteConfig/useRemoteConfig.js +10 -0
  139. package/web/remoteConfig/useRemoteConfig.ts +11 -0
  140. /package/{dist/src → react-native}/analytics/index.d.ts +0 -0
  141. /package/{dist/src → react-native}/analytics/index.js +0 -0
  142. /package/{src → react-native}/analytics/index.ts +0 -0
  143. /package/{dist/src → react-native}/analytics/useAnalytics.d.ts +0 -0
  144. /package/{dist/src → react-native}/analytics/useAnalytics.js +0 -0
  145. /package/{src → react-native}/analytics/useAnalytics.ts +0 -0
  146. /package/{dist/src → react-native}/analytics/useLogEvent.d.ts +0 -0
  147. /package/{dist/src → react-native}/analytics/useLogEvent.js +0 -0
  148. /package/{src → react-native}/analytics/useLogEvent.ts +0 -0
  149. /package/{dist/src → react-native}/analytics/useSetAnalyticsCollectionEnabled.d.ts +0 -0
  150. /package/{dist/src → react-native}/analytics/useSetAnalyticsCollectionEnabled.js +0 -0
  151. /package/{src → react-native}/analytics/useSetAnalyticsCollectionEnabled.ts +0 -0
  152. /package/{dist/src → react-native}/auth/index.d.ts +0 -0
  153. /package/{dist/src → react-native}/auth/index.js +0 -0
  154. /package/{src → react-native}/auth/index.ts +0 -0
  155. /package/{dist/src → react-native}/auth/mutation-keys.d.ts +0 -0
  156. /package/{dist/src → react-native}/auth/mutation-keys.js +0 -0
  157. /package/{src → react-native}/auth/mutation-keys.ts +0 -0
  158. /package/{dist/src → react-native}/auth/useAuth.d.ts +0 -0
  159. /package/{dist/src → react-native}/auth/useAuth.js +0 -0
  160. /package/{src → react-native}/auth/useAuth.ts +0 -0
  161. /package/{dist/src → react-native}/auth/useCreateUserWitEmailAndPasswordMutation.d.ts +0 -0
  162. /package/{dist/src → react-native}/auth/useCreateUserWitEmailAndPasswordMutation.js +0 -0
  163. /package/{src → react-native}/auth/useCreateUserWitEmailAndPasswordMutation.ts +0 -0
  164. /package/{dist/src → react-native}/auth/useCurrentUser.d.ts +0 -0
  165. /package/{dist/src → react-native}/auth/useCurrentUser.js +0 -0
  166. /package/{src → react-native}/auth/useCurrentUser.ts +0 -0
  167. /package/{dist/src → react-native}/auth/useIdToken.d.ts +0 -0
  168. /package/{dist/src → react-native}/auth/useIdToken.js +0 -0
  169. /package/{src → react-native}/auth/useIdToken.ts +0 -0
  170. /package/{dist/src → react-native}/auth/useReauthenticateWitCredentialMutation.d.ts +0 -0
  171. /package/{dist/src → react-native}/auth/useReauthenticateWitCredentialMutation.js +0 -0
  172. /package/{src → react-native}/auth/useReauthenticateWitCredentialMutation.ts +0 -0
  173. /package/{dist/src → react-native}/auth/useReauthenticateWitRedirectMutation.d.ts +0 -0
  174. /package/{dist/src → react-native}/auth/useReauthenticateWitRedirectMutation.js +0 -0
  175. /package/{src → react-native}/auth/useReauthenticateWitRedirectMutation.ts +0 -0
  176. /package/{dist/src → react-native}/auth/useSendEmailVerificationMutation.d.ts +0 -0
  177. /package/{dist/src → react-native}/auth/useSendEmailVerificationMutation.js +0 -0
  178. /package/{src → react-native}/auth/useSendEmailVerificationMutation.ts +0 -0
  179. /package/{dist/src → react-native}/auth/useSignInWitEmailAndPasswordMutation.d.ts +0 -0
  180. /package/{dist/src → react-native}/auth/useSignInWitEmailAndPasswordMutation.js +0 -0
  181. /package/{src → react-native}/auth/useSignInWitEmailAndPasswordMutation.ts +0 -0
  182. /package/{dist/src → react-native}/auth/useSignInWitRedirectMutation.d.ts +0 -0
  183. /package/{dist/src → react-native}/auth/useSignInWitRedirectMutation.js +0 -0
  184. /package/{src → react-native}/auth/useSignInWitRedirectMutation.ts +0 -0
  185. /package/{dist/src → react-native}/auth/useSignOutMutation.d.ts +0 -0
  186. /package/{dist/src → react-native}/auth/useSignOutMutation.js +0 -0
  187. /package/{src → react-native}/auth/useSignOutMutation.ts +0 -0
  188. /package/{dist/src → react-native}/auth/useUpdateProfileMutation.d.ts +0 -0
  189. /package/{dist/src → react-native}/auth/useUpdateProfileMutation.js +0 -0
  190. /package/{src → react-native}/auth/useUpdateProfileMutation.ts +0 -0
  191. /package/{dist/src → react-native}/context/FirebaseContext.d.ts +0 -0
  192. /package/{dist/src → react-native}/context/FirebaseContext.js +0 -0
  193. /package/{src → react-native}/context/FirebaseContext.ts +0 -0
  194. /package/{dist/src → react-native}/context/FirebaseContextProvider.d.ts +0 -0
  195. /package/{dist/src → react-native}/context/FirebaseContextProvider.js +0 -0
  196. /package/{src → react-native}/context/FirebaseContextProvider.tsx +0 -0
  197. /package/{dist/src → react-native}/context/index.d.ts +0 -0
  198. /package/{dist/src → react-native}/context/index.js +0 -0
  199. /package/{src → react-native}/context/index.ts +0 -0
  200. /package/{dist/src → react-native}/firestore/index.d.ts +0 -0
  201. /package/{dist/src → react-native}/firestore/index.js +0 -0
  202. /package/{src → react-native}/firestore/index.ts +0 -0
  203. /package/{dist/src → react-native}/firestore/useAddDocMutation.d.ts +0 -0
  204. /package/{dist/src → react-native}/firestore/useAddDocMutation.js +0 -0
  205. /package/{src → react-native}/firestore/useAddDocMutation.ts +0 -0
  206. /package/{dist/src → react-native}/firestore/useBatchWrite.d.ts +0 -0
  207. /package/{dist/src → react-native}/firestore/useBatchWrite.js +0 -0
  208. /package/{src → react-native}/firestore/useBatchWrite.ts +0 -0
  209. /package/{dist/src → react-native}/firestore/useCollectionReference.d.ts +0 -0
  210. /package/{dist/src → react-native}/firestore/useCollectionReference.js +0 -0
  211. /package/{src → react-native}/firestore/useCollectionReference.ts +0 -0
  212. /package/{dist/src → react-native}/firestore/useCompositeFilter.d.ts +0 -0
  213. /package/{dist/src → react-native}/firestore/useCompositeFilter.js +0 -0
  214. /package/{src → react-native}/firestore/useCompositeFilter.ts +0 -0
  215. /package/{dist/src → react-native}/firestore/useCountQuery.d.ts +0 -0
  216. /package/{dist/src → react-native}/firestore/useCountQuery.js +0 -0
  217. /package/{src → react-native}/firestore/useCountQuery.ts +0 -0
  218. /package/{dist/src → react-native}/firestore/useDeleteDocMutation.d.ts +0 -0
  219. /package/{dist/src → react-native}/firestore/useDeleteDocMutation.js +0 -0
  220. /package/{src → react-native}/firestore/useDeleteDocMutation.ts +0 -0
  221. /package/{dist/src → react-native}/firestore/useDocReference.d.ts +0 -0
  222. /package/{dist/src → react-native}/firestore/useDocReference.js +0 -0
  223. /package/{src → react-native}/firestore/useDocReference.ts +0 -0
  224. /package/{dist/src → react-native}/firestore/useDocReferences.d.ts +0 -0
  225. /package/{dist/src → react-native}/firestore/useDocReferences.js +0 -0
  226. /package/{src → react-native}/firestore/useDocReferences.ts +0 -0
  227. /package/{dist/src → react-native}/firestore/useFirestore.d.ts +0 -0
  228. /package/{dist/src → react-native}/firestore/useFirestore.js +0 -0
  229. /package/{src → react-native}/firestore/useFirestore.ts +0 -0
  230. /package/{dist/src → react-native}/firestore/useGetDocData.d.ts +0 -0
  231. /package/{dist/src → react-native}/firestore/useGetDocData.js +0 -0
  232. /package/{src → react-native}/firestore/useGetDocData.ts +0 -0
  233. /package/{dist/src → react-native}/firestore/useGetRealtimeDocData.d.ts +0 -0
  234. /package/{dist/src → react-native}/firestore/useGetRealtimeDocData.js +0 -0
  235. /package/{src → react-native}/firestore/useGetRealtimeDocData.ts +0 -0
  236. /package/{dist/src → react-native}/firestore/useInfiniteQuery.d.ts +0 -0
  237. /package/{dist/src → react-native}/firestore/useInfiniteQuery.js +0 -0
  238. /package/{src → react-native}/firestore/useInfiniteQuery.ts +0 -0
  239. /package/{dist/src → react-native}/firestore/useQuery.d.ts +0 -0
  240. /package/{dist/src → react-native}/firestore/useQuery.js +0 -0
  241. /package/{src → react-native}/firestore/useQuery.ts +0 -0
  242. /package/{dist/src → react-native}/firestore/useRunTransaction.d.ts +0 -0
  243. /package/{dist/src → react-native}/firestore/useRunTransaction.js +0 -0
  244. /package/{src → react-native}/firestore/useRunTransaction.ts +0 -0
  245. /package/{dist/src → react-native}/firestore/useSetDocMutation.d.ts +0 -0
  246. /package/{dist/src → react-native}/firestore/useSetDocMutation.js +0 -0
  247. /package/{src → react-native}/firestore/useSetDocMutation.ts +0 -0
  248. /package/{dist/src → react-native}/firestore/useUpdateDocMutation.d.ts +0 -0
  249. /package/{dist/src → react-native}/firestore/useUpdateDocMutation.js +0 -0
  250. /package/{src → react-native}/firestore/useUpdateDocMutation.ts +0 -0
  251. /package/{dist/src → react-native}/firestore/utils/getDocData.d.ts +0 -0
  252. /package/{dist/src → react-native}/firestore/utils/getDocData.js +0 -0
  253. /package/{src → react-native}/firestore/utils/getDocData.ts +0 -0
  254. /package/{dist/src → react-native}/firestore/utils/getDocRef.d.ts +0 -0
  255. /package/{dist/src → react-native}/firestore/utils/getDocRef.js +0 -0
  256. /package/{src → react-native}/firestore/utils/getDocRef.ts +0 -0
  257. /package/{dist/src → react-native}/firestore/utils/getDocSnap.d.ts +0 -0
  258. /package/{dist/src → react-native}/firestore/utils/getDocSnap.js +0 -0
  259. /package/{src → react-native}/firestore/utils/getDocSnap.ts +0 -0
  260. /package/{dist/src → react-native}/index.d.ts +0 -0
  261. /package/{dist/src → react-native}/index.js +0 -0
  262. /package/{src → react-native}/index.ts +0 -0
  263. /package/{dist/src → react-native}/remoteConfig/index.d.ts +0 -0
  264. /package/{dist/src → react-native}/remoteConfig/index.js +0 -0
  265. /package/{src → react-native}/remoteConfig/index.ts +0 -0
  266. /package/{dist/src → react-native}/remoteConfig/useFetchAndActivate.d.ts +0 -0
  267. /package/{dist/src → react-native}/remoteConfig/useFetchAndActivate.js +0 -0
  268. /package/{src → react-native}/remoteConfig/useFetchAndActivate.ts +0 -0
  269. /package/{dist/src → react-native}/remoteConfig/useGetValue.d.ts +0 -0
  270. /package/{dist/src → react-native}/remoteConfig/useGetValue.js +0 -0
  271. /package/{src → react-native}/remoteConfig/useGetValue.ts +0 -0
  272. /package/{dist/src → react-native}/remoteConfig/useRemoteConfig.d.ts +0 -0
  273. /package/{dist/src → react-native}/remoteConfig/useRemoteConfig.js +0 -0
  274. /package/{src → react-native}/remoteConfig/useRemoteConfig.ts +0 -0
@@ -0,0 +1,83 @@
1
+ import { useCallback, useEffect, useState } from "react";
2
+ import { useCurrentUser } from "./useCurrentUser";
3
+ import { onIdTokenChanged } from "firebase/auth";
4
+ import { useAuth } from "./useAuth";
5
+
6
+ /**
7
+ * @inline
8
+ */
9
+ export type UseIdTokenResult = {
10
+ idToken: string;
11
+ refresh: () => Promise<string | undefined>;
12
+ };
13
+
14
+ /**
15
+ * A hook to manage the ID token.
16
+ * It monitors changes to the ID token and provides the token itself along with a refresh method to update the token when needed.
17
+ *
18
+ * @group Hook
19
+ *
20
+ * @returns {UseIdTokenResult}
21
+ *
22
+ * @example
23
+ * ```jsx
24
+ * export const MyComponent = () => {
25
+ * const result = useIdToken();
26
+ * useEffect(() => {
27
+ * const timeout = setTimeout(() => {
28
+ * result.refresh();
29
+ * }, 5000);
30
+ * return () => clearTimeout();
31
+ * }, [])
32
+ * console.log(resilt.idToken);
33
+ * };
34
+ * ```
35
+ */
36
+ export const useIdToken = (): UseIdTokenResult => {
37
+ const auth = useAuth();
38
+
39
+ const currentUser = useCurrentUser();
40
+ const [idToken, setIdToken] = useState("");
41
+
42
+ const callback = useCallback(async () => {
43
+ if (!currentUser) {
44
+ setIdToken("");
45
+ return;
46
+ }
47
+
48
+ const idToken = await currentUser.getIdToken();
49
+ setIdToken(idToken);
50
+ }, [currentUser, idToken]);
51
+
52
+ const refresh = useCallback(async () => {
53
+ if (!currentUser) {
54
+ return;
55
+ }
56
+
57
+ const idToken = await currentUser.getIdToken(true);
58
+ return idToken;
59
+ }, [currentUser, idToken]);
60
+
61
+ useEffect(() => {
62
+ callback();
63
+ }, [currentUser?.uid ?? ""]);
64
+
65
+ useEffect(() => {
66
+ const unsubscribe = onIdTokenChanged(auth, (user) => {
67
+ if (user) {
68
+ user.getIdToken().then((idToken) => {
69
+ setIdToken(idToken);
70
+ });
71
+ } else {
72
+ setIdToken("");
73
+ }
74
+ });
75
+
76
+ return () => unsubscribe();
77
+ }, [idToken]);
78
+
79
+ return {
80
+ idToken,
81
+ refresh
82
+ };
83
+ };
@@ -0,0 +1,16 @@
1
+ import { UseMutationOptions } from "@tanstack/react-query";
2
+ import { User, AuthCredential, UserCredential } from "firebase/auth";
3
+ import { FirebaseError } from "firebase/app";
4
+ export type UseReauthenticateWitCredentialMutationVariables = {
5
+ credential: AuthCredential;
6
+ user: User;
7
+ };
8
+ /**
9
+ * Custom hook to create a mutation for re-authenticating a user with a given credential.
10
+ * This hook utilizes useMutation from React Query to manage the asynchronous re-authentication
11
+ * process with Firebase credentials. It omits the default "mutationKey" and "mutationFn" options.
12
+ *
13
+ * @param {Omit<UseMutationOptions<UserCredential, FirebaseError, UseReauthenticateWitCredentialMutationVariables, TContext>, "mutationKey" | "mutationFn">} options - Optional mutation options excluding "mutationKey" and "mutationFn".
14
+ * @returns {UseMutationResult<UserCredential, FirebaseError, UseReauthenticateWitCredentialMutationVariables, TContext>} A useMutation result object managing the loading, error, and result state of the re-authentication mutation.
15
+ */
16
+ export declare const useReauthenticateWitCredentialMutation: <TContext = unknown>(options?: Omit<UseMutationOptions<UserCredential, FirebaseError, UseReauthenticateWitCredentialMutationVariables, TContext>, "mutationKey" | "mutationFn">) => import("@tanstack/react-query").UseMutationResult<UserCredential, FirebaseError, UseReauthenticateWitCredentialMutationVariables, TContext>;
@@ -0,0 +1,18 @@
1
+ import { useMutation } from "@tanstack/react-query";
2
+ import { reauthenticateWithCredential } from "firebase/auth";
3
+ import { REAUTHENTICATE_WITH_CREDENTIAL_MUTATION_KEY } from "./mutation-keys";
4
+ /**
5
+ * Custom hook to create a mutation for re-authenticating a user with a given credential.
6
+ * This hook utilizes useMutation from React Query to manage the asynchronous re-authentication
7
+ * process with Firebase credentials. It omits the default "mutationKey" and "mutationFn" options.
8
+ *
9
+ * @param {Omit<UseMutationOptions<UserCredential, FirebaseError, UseReauthenticateWitCredentialMutationVariables, TContext>, "mutationKey" | "mutationFn">} options - Optional mutation options excluding "mutationKey" and "mutationFn".
10
+ * @returns {UseMutationResult<UserCredential, FirebaseError, UseReauthenticateWitCredentialMutationVariables, TContext>} A useMutation result object managing the loading, error, and result state of the re-authentication mutation.
11
+ */
12
+ export const useReauthenticateWitCredentialMutation = (options = {}) => {
13
+ return useMutation({
14
+ ...options,
15
+ mutationFn: async ({ credential, user }) => reauthenticateWithCredential(user, credential),
16
+ mutationKey: REAUTHENTICATE_WITH_CREDENTIAL_MUTATION_KEY
17
+ });
18
+ };
@@ -0,0 +1,31 @@
1
+ import { useMutation, UseMutationOptions } from "@tanstack/react-query";
2
+ import { reauthenticateWithCredential, User, AuthCredential, UserCredential } from "firebase/auth";
3
+ import { REAUTHENTICATE_WITH_CREDENTIAL_MUTATION_KEY } from "./mutation-keys";
4
+ import { FirebaseError } from "firebase/app";
5
+
6
+ export type UseReauthenticateWitCredentialMutationVariables = {
7
+ credential: AuthCredential;
8
+ user: User;
9
+ };
10
+
11
+ /**
12
+ * Custom hook to create a mutation for re-authenticating a user with a given credential.
13
+ * This hook utilizes useMutation from React Query to manage the asynchronous re-authentication
14
+ * process with Firebase credentials. It omits the default "mutationKey" and "mutationFn" options.
15
+ *
16
+ * @param {Omit<UseMutationOptions<UserCredential, FirebaseError, UseReauthenticateWitCredentialMutationVariables, TContext>, "mutationKey" | "mutationFn">} options - Optional mutation options excluding "mutationKey" and "mutationFn".
17
+ * @returns {UseMutationResult<UserCredential, FirebaseError, UseReauthenticateWitCredentialMutationVariables, TContext>} A useMutation result object managing the loading, error, and result state of the re-authentication mutation.
18
+ */
19
+ export const useReauthenticateWitCredentialMutation = <TContext = unknown>(
20
+ options: Omit<
21
+ UseMutationOptions<UserCredential, FirebaseError, UseReauthenticateWitCredentialMutationVariables, TContext>,
22
+ "mutationKey" | "mutationFn"
23
+ > = {}
24
+ ) => {
25
+ return useMutation({
26
+ ...options,
27
+ mutationFn: async ({ credential, user }: UseReauthenticateWitCredentialMutationVariables) =>
28
+ reauthenticateWithCredential(user, credential),
29
+ mutationKey: REAUTHENTICATE_WITH_CREDENTIAL_MUTATION_KEY
30
+ });
31
+ };
@@ -0,0 +1,17 @@
1
+ import { UseMutationOptions } from "@tanstack/react-query";
2
+ import { AuthProvider, PopupRedirectResolver, User } from "firebase/auth";
3
+ import { FirebaseError } from "firebase/app";
4
+ export type UseReauthenticateWitRedirectMutationVariables = {
5
+ authProvider: AuthProvider;
6
+ popupRedirectResolver?: PopupRedirectResolver;
7
+ user: User;
8
+ };
9
+ /**
10
+ * Custom hook that provides a mutation to reauthenticate a user with a given authentication provider using redirection.
11
+ * This hook uses the `useMutation` hook from the React Query library to handle async mutation logic.
12
+ *
13
+ * @param {Omit<UseMutationOptions<void, FirebaseError, UseReauthenticateWitRedirectMutationVariables, TContext>, "mutationKey" | "mutationFn">} options - Optional configuration object for the mutation. It provides the ability to pass options to customize the behavior of the mutation.
14
+ * @template TContext - The type of any additional context you wish to pass to the mutation.
15
+ * @returns {UseMutationResult<void, FirebaseError, UseReauthenticateWitRedirectMutationVariables, TContext>} A mutation result object containing methods and state of the mutation.
16
+ */
17
+ export declare const useReauthenticateWitRedirectMutation: <TContext = unknown>(options?: Omit<UseMutationOptions<void, FirebaseError, UseReauthenticateWitRedirectMutationVariables, TContext>, "mutationKey" | "mutationFn">) => import("@tanstack/react-query").UseMutationResult<void, FirebaseError, UseReauthenticateWitRedirectMutationVariables, TContext>;
@@ -0,0 +1,18 @@
1
+ import { useMutation } from "@tanstack/react-query";
2
+ import { reauthenticateWithRedirect } from "firebase/auth";
3
+ import { REAUTHENTICATE_WITH_REDIRECT_MUTATION_KEY } from "./mutation-keys";
4
+ /**
5
+ * Custom hook that provides a mutation to reauthenticate a user with a given authentication provider using redirection.
6
+ * This hook uses the `useMutation` hook from the React Query library to handle async mutation logic.
7
+ *
8
+ * @param {Omit<UseMutationOptions<void, FirebaseError, UseReauthenticateWitRedirectMutationVariables, TContext>, "mutationKey" | "mutationFn">} options - Optional configuration object for the mutation. It provides the ability to pass options to customize the behavior of the mutation.
9
+ * @template TContext - The type of any additional context you wish to pass to the mutation.
10
+ * @returns {UseMutationResult<void, FirebaseError, UseReauthenticateWitRedirectMutationVariables, TContext>} A mutation result object containing methods and state of the mutation.
11
+ */
12
+ export const useReauthenticateWitRedirectMutation = (options = {}) => {
13
+ return useMutation({
14
+ ...options,
15
+ mutationFn: async ({ authProvider, user, popupRedirectResolver }) => reauthenticateWithRedirect(user, authProvider, popupRedirectResolver),
16
+ mutationKey: REAUTHENTICATE_WITH_REDIRECT_MUTATION_KEY
17
+ });
18
+ };
@@ -0,0 +1,37 @@
1
+ import { useMutation, UseMutationOptions } from "@tanstack/react-query";
2
+ import { reauthenticateWithRedirect, AuthProvider, PopupRedirectResolver, User } from "firebase/auth";
3
+
4
+ import { REAUTHENTICATE_WITH_REDIRECT_MUTATION_KEY } from "./mutation-keys";
5
+ import { FirebaseError } from "firebase/app";
6
+
7
+ export type UseReauthenticateWitRedirectMutationVariables = {
8
+ authProvider: AuthProvider;
9
+ popupRedirectResolver?: PopupRedirectResolver;
10
+ user: User;
11
+ };
12
+
13
+ /**
14
+ * Custom hook that provides a mutation to reauthenticate a user with a given authentication provider using redirection.
15
+ * This hook uses the `useMutation` hook from the React Query library to handle async mutation logic.
16
+ *
17
+ * @param {Omit<UseMutationOptions<void, FirebaseError, UseReauthenticateWitRedirectMutationVariables, TContext>, "mutationKey" | "mutationFn">} options - Optional configuration object for the mutation. It provides the ability to pass options to customize the behavior of the mutation.
18
+ * @template TContext - The type of any additional context you wish to pass to the mutation.
19
+ * @returns {UseMutationResult<void, FirebaseError, UseReauthenticateWitRedirectMutationVariables, TContext>} A mutation result object containing methods and state of the mutation.
20
+ */
21
+ export const useReauthenticateWitRedirectMutation = <TContext = unknown>(
22
+ options: Omit<
23
+ UseMutationOptions<void, FirebaseError, UseReauthenticateWitRedirectMutationVariables, TContext>,
24
+ "mutationKey" | "mutationFn"
25
+ > = {}
26
+ ) => {
27
+ return useMutation({
28
+ ...options,
29
+ mutationFn: async ({
30
+ authProvider,
31
+ user,
32
+ popupRedirectResolver
33
+ }: UseReauthenticateWitRedirectMutationVariables) =>
34
+ reauthenticateWithRedirect(user, authProvider, popupRedirectResolver),
35
+ mutationKey: REAUTHENTICATE_WITH_REDIRECT_MUTATION_KEY
36
+ });
37
+ };
@@ -0,0 +1,13 @@
1
+ import { UseMutationOptions } from "@tanstack/react-query";
2
+ import { User } from "firebase/auth";
3
+ import { FirebaseError } from "firebase/app";
4
+ export type UseSendEmailVerificationMutationVariables = {
5
+ user: User;
6
+ };
7
+ /**
8
+ * A custom hook to create a mutation for sending an email verification to a user using Firebase.
9
+ * This uses the `useMutation` hook from a query library and wraps it with specific configuration options.
10
+ * @param {Omit<UseMutationOptions<void, FirebaseError, UseSendEmailVerificationMutationVariables, TContext>, "queryKey" | "queryFn">} options - Configuration options for the mutation, excluding `queryKey` and `queryFn`.
11
+ * @returns {UseMutationResult<void, FirebaseError, UseSendEmailVerificationMutationVariables, TContext>} An object containing mutation state and functions for managing the mutation lifecycle.
12
+ */
13
+ export declare const useSendEmailVerificationMutation: <TContext = unknown>(options?: Omit<UseMutationOptions<void, FirebaseError, UseSendEmailVerificationMutationVariables, TContext>, "queryKey" | "queryFn">) => import("@tanstack/react-query").UseMutationResult<void, FirebaseError, UseSendEmailVerificationMutationVariables, TContext>;
@@ -0,0 +1,16 @@
1
+ import { useMutation } from "@tanstack/react-query";
2
+ import { sendEmailVerification } from "firebase/auth";
3
+ import { SEND_EMAIL_VERIFICATION_MUTATION_KEY } from "./mutation-keys";
4
+ /**
5
+ * A custom hook to create a mutation for sending an email verification to a user using Firebase.
6
+ * This uses the `useMutation` hook from a query library and wraps it with specific configuration options.
7
+ * @param {Omit<UseMutationOptions<void, FirebaseError, UseSendEmailVerificationMutationVariables, TContext>, "queryKey" | "queryFn">} options - Configuration options for the mutation, excluding `queryKey` and `queryFn`.
8
+ * @returns {UseMutationResult<void, FirebaseError, UseSendEmailVerificationMutationVariables, TContext>} An object containing mutation state and functions for managing the mutation lifecycle.
9
+ */
10
+ export const useSendEmailVerificationMutation = (options = {}) => {
11
+ return useMutation({
12
+ ...options,
13
+ mutationFn: async ({ user }) => await sendEmailVerification(user),
14
+ mutationKey: SEND_EMAIL_VERIFICATION_MUTATION_KEY
15
+ });
16
+ };
@@ -0,0 +1,28 @@
1
+ import { useMutation, UseMutationOptions } from "@tanstack/react-query";
2
+ import { sendEmailVerification, User } from "firebase/auth";
3
+
4
+ import { SEND_EMAIL_VERIFICATION_MUTATION_KEY } from "./mutation-keys";
5
+ import { FirebaseError } from "firebase/app";
6
+
7
+ export type UseSendEmailVerificationMutationVariables = {
8
+ user: User;
9
+ };
10
+
11
+ /**
12
+ * A custom hook to create a mutation for sending an email verification to a user using Firebase.
13
+ * This uses the `useMutation` hook from a query library and wraps it with specific configuration options.
14
+ * @param {Omit<UseMutationOptions<void, FirebaseError, UseSendEmailVerificationMutationVariables, TContext>, "queryKey" | "queryFn">} options - Configuration options for the mutation, excluding `queryKey` and `queryFn`.
15
+ * @returns {UseMutationResult<void, FirebaseError, UseSendEmailVerificationMutationVariables, TContext>} An object containing mutation state and functions for managing the mutation lifecycle.
16
+ */
17
+ export const useSendEmailVerificationMutation = <TContext = unknown>(
18
+ options: Omit<
19
+ UseMutationOptions<void, FirebaseError, UseSendEmailVerificationMutationVariables, TContext>,
20
+ "queryKey" | "queryFn"
21
+ > = {}
22
+ ) => {
23
+ return useMutation({
24
+ ...options,
25
+ mutationFn: async ({ user }) => await sendEmailVerification(user),
26
+ mutationKey: SEND_EMAIL_VERIFICATION_MUTATION_KEY
27
+ });
28
+ };
@@ -0,0 +1,15 @@
1
+ import { UseMutationOptions } from "@tanstack/react-query";
2
+ import { UserCredential } from "firebase/auth";
3
+ import { FirebaseError } from "firebase/app";
4
+ export type UseSignInWitEmailAndPasswordMutationVariables = {
5
+ email: string;
6
+ password: string;
7
+ };
8
+ /**
9
+ * Custom hook to perform a sign-in operation using email and password with Firebase Authentication.
10
+ * It utilizes the `useMutation` hook to manage the asynchronous operation and its state.
11
+ *
12
+ * @param {Omit<UseMutationOptions<UserCredential, FirebaseError, UseSignInWitEmailAndPasswordMutationVariables, TContext>, 'mutationKey' | 'mutationFn'>} options - Options to configure the mutation, excluding 'mutationKey' and 'mutationFn'.
13
+ * @returns {MutationResult} A mutation object containing the result of the sign-in process and helper functions.
14
+ */
15
+ export declare const useSignInWitEmailAndPasswordMutation: <TContext = unknown>(options?: Omit<UseMutationOptions<UserCredential, FirebaseError, UseSignInWitEmailAndPasswordMutationVariables, TContext>, "mutationKey" | "mutationFn">) => import("@tanstack/react-query").UseMutationResult<UserCredential, FirebaseError, UseSignInWitEmailAndPasswordMutationVariables, TContext>;
@@ -0,0 +1,19 @@
1
+ import { useMutation } from "@tanstack/react-query";
2
+ import { signInWithEmailAndPassword } from "firebase/auth";
3
+ import { useAuth } from "./useAuth";
4
+ import { SIGN_IN_WITH_EMAIL_AND_PASSWORD_MUTATION_KEY } from "./mutation-keys";
5
+ /**
6
+ * Custom hook to perform a sign-in operation using email and password with Firebase Authentication.
7
+ * It utilizes the `useMutation` hook to manage the asynchronous operation and its state.
8
+ *
9
+ * @param {Omit<UseMutationOptions<UserCredential, FirebaseError, UseSignInWitEmailAndPasswordMutationVariables, TContext>, 'mutationKey' | 'mutationFn'>} options - Options to configure the mutation, excluding 'mutationKey' and 'mutationFn'.
10
+ * @returns {MutationResult} A mutation object containing the result of the sign-in process and helper functions.
11
+ */
12
+ export const useSignInWitEmailAndPasswordMutation = (options = {}) => {
13
+ const firebaseAuth = useAuth();
14
+ return useMutation({
15
+ ...options,
16
+ mutationFn: async ({ email, password }) => signInWithEmailAndPassword(firebaseAuth, email, password),
17
+ mutationKey: SIGN_IN_WITH_EMAIL_AND_PASSWORD_MUTATION_KEY
18
+ });
19
+ };
@@ -0,0 +1,34 @@
1
+ import { useMutation, UseMutationOptions } from "@tanstack/react-query";
2
+ import { signInWithEmailAndPassword, UserCredential } from "firebase/auth";
3
+
4
+ import { useAuth } from "./useAuth";
5
+ import { SIGN_IN_WITH_EMAIL_AND_PASSWORD_MUTATION_KEY } from "./mutation-keys";
6
+ import { FirebaseError } from "firebase/app";
7
+
8
+ export type UseSignInWitEmailAndPasswordMutationVariables = {
9
+ email: string;
10
+ password: string;
11
+ };
12
+
13
+ /**
14
+ * Custom hook to perform a sign-in operation using email and password with Firebase Authentication.
15
+ * It utilizes the `useMutation` hook to manage the asynchronous operation and its state.
16
+ *
17
+ * @param {Omit<UseMutationOptions<UserCredential, FirebaseError, UseSignInWitEmailAndPasswordMutationVariables, TContext>, 'mutationKey' | 'mutationFn'>} options - Options to configure the mutation, excluding 'mutationKey' and 'mutationFn'.
18
+ * @returns {MutationResult} A mutation object containing the result of the sign-in process and helper functions.
19
+ */
20
+ export const useSignInWitEmailAndPasswordMutation = <TContext = unknown>(
21
+ options: Omit<
22
+ UseMutationOptions<UserCredential, FirebaseError, UseSignInWitEmailAndPasswordMutationVariables, TContext>,
23
+ "mutationKey" | "mutationFn"
24
+ > = {}
25
+ ) => {
26
+ const firebaseAuth = useAuth();
27
+
28
+ return useMutation({
29
+ ...options,
30
+ mutationFn: async ({ email, password }: UseSignInWitEmailAndPasswordMutationVariables) =>
31
+ signInWithEmailAndPassword(firebaseAuth, email, password),
32
+ mutationKey: SIGN_IN_WITH_EMAIL_AND_PASSWORD_MUTATION_KEY
33
+ });
34
+ };
@@ -0,0 +1,14 @@
1
+ import { UseMutationOptions } from "@tanstack/react-query";
2
+ import { AuthProvider, PopupRedirectResolver } from "firebase/auth";
3
+ import { FirebaseError } from "firebase/app";
4
+ export type UseSignInWitRedirectMutationVariables = {
5
+ authProvider: AuthProvider;
6
+ popupRedirectResolver?: PopupRedirectResolver;
7
+ };
8
+ /**
9
+ * Custom hook for handling Firebase authentication using sign-in with redirect functionality.
10
+ * This hook utilizes the `useMutation` mechanism to perform the sign-in operation.
11
+ * @param {Omit<UseMutationOptions<void, FirebaseError, UseSignInWitRedirectMutationVariables, TContext>, "mutationKey" | "mutationFn">} options - Optional configurations for the mutation, omitting the mutationKey and mutationFn properties.
12
+ * @returns {UseMutationResult<void, FirebaseError, UseSignInWitRedirectMutationVariables, TContext>} The result object from the useMutation hook, containing the mutation function and its current state.
13
+ */
14
+ export declare const useSignInWitRedirectMutation: <TContext = unknown>(options?: Omit<UseMutationOptions<void, FirebaseError, UseSignInWitRedirectMutationVariables, TContext>, "mutationKey" | "mutationFn">) => import("@tanstack/react-query").UseMutationResult<void, FirebaseError, UseSignInWitRedirectMutationVariables, TContext>;
@@ -0,0 +1,18 @@
1
+ import { useMutation } from "@tanstack/react-query";
2
+ import { signInWithRedirect } from "firebase/auth";
3
+ import { useAuth } from "./useAuth";
4
+ import { SIGN_IN_WITH_REDIRECT_MUTATION_KEY } from "./mutation-keys";
5
+ /**
6
+ * Custom hook for handling Firebase authentication using sign-in with redirect functionality.
7
+ * This hook utilizes the `useMutation` mechanism to perform the sign-in operation.
8
+ * @param {Omit<UseMutationOptions<void, FirebaseError, UseSignInWitRedirectMutationVariables, TContext>, "mutationKey" | "mutationFn">} options - Optional configurations for the mutation, omitting the mutationKey and mutationFn properties.
9
+ * @returns {UseMutationResult<void, FirebaseError, UseSignInWitRedirectMutationVariables, TContext>} The result object from the useMutation hook, containing the mutation function and its current state.
10
+ */
11
+ export const useSignInWitRedirectMutation = (options = {}) => {
12
+ const firebaseAuth = useAuth();
13
+ return useMutation({
14
+ ...options,
15
+ mutationFn: async ({ authProvider, popupRedirectResolver }) => signInWithRedirect(firebaseAuth, authProvider, popupRedirectResolver),
16
+ mutationKey: SIGN_IN_WITH_REDIRECT_MUTATION_KEY
17
+ });
18
+ };
@@ -0,0 +1,33 @@
1
+ import { useMutation, UseMutationOptions } from "@tanstack/react-query";
2
+ import { signInWithRedirect, AuthProvider, PopupRedirectResolver } from "firebase/auth";
3
+
4
+ import { useAuth } from "./useAuth";
5
+ import { SIGN_IN_WITH_REDIRECT_MUTATION_KEY } from "./mutation-keys";
6
+ import { FirebaseError } from "firebase/app";
7
+
8
+ export type UseSignInWitRedirectMutationVariables = {
9
+ authProvider: AuthProvider;
10
+ popupRedirectResolver?: PopupRedirectResolver;
11
+ };
12
+
13
+ /**
14
+ * Custom hook for handling Firebase authentication using sign-in with redirect functionality.
15
+ * This hook utilizes the `useMutation` mechanism to perform the sign-in operation.
16
+ * @param {Omit<UseMutationOptions<void, FirebaseError, UseSignInWitRedirectMutationVariables, TContext>, "mutationKey" | "mutationFn">} options - Optional configurations for the mutation, omitting the mutationKey and mutationFn properties.
17
+ * @returns {UseMutationResult<void, FirebaseError, UseSignInWitRedirectMutationVariables, TContext>} The result object from the useMutation hook, containing the mutation function and its current state.
18
+ */
19
+ export const useSignInWitRedirectMutation = <TContext = unknown>(
20
+ options: Omit<
21
+ UseMutationOptions<void, FirebaseError, UseSignInWitRedirectMutationVariables, TContext>,
22
+ "mutationKey" | "mutationFn"
23
+ > = {}
24
+ ) => {
25
+ const firebaseAuth = useAuth();
26
+
27
+ return useMutation({
28
+ ...options,
29
+ mutationFn: async ({ authProvider, popupRedirectResolver }: UseSignInWitRedirectMutationVariables) =>
30
+ signInWithRedirect(firebaseAuth, authProvider, popupRedirectResolver),
31
+ mutationKey: SIGN_IN_WITH_REDIRECT_MUTATION_KEY
32
+ });
33
+ };
@@ -0,0 +1,10 @@
1
+ import { UseMutationOptions } from "@tanstack/react-query";
2
+ import { FirebaseError } from "firebase/app";
3
+ /**
4
+ * Custom hook for handling the sign-out mutation using Firebase authentication.
5
+ * It wraps the useMutation hook to provide a sign-out function with Firebase.
6
+ *
7
+ * @param {Omit<UseMutationOptions<void, FirebaseError, void, TContext>, "queryKey" | "queryFn">} options - Configuration options for the mutation, excluding "queryKey" and "queryFn".
8
+ * @returns {UseMutationResult<void, FirebaseError, void, TContext>} A mutation object for handling the sign-out process, including methods for mutating and state tracking.
9
+ */
10
+ export declare const useSignOutMutation: <TContext = unknown>(options?: Omit<UseMutationOptions<void, FirebaseError, void, TContext>, "queryKey" | "queryFn">) => import("@tanstack/react-query").UseMutationResult<void, FirebaseError, void, TContext>;
@@ -0,0 +1,19 @@
1
+ import { useMutation } from "@tanstack/react-query";
2
+ import { signOut } from "firebase/auth";
3
+ import { SIGN_OUT_MUTATION_KEY } from "./mutation-keys";
4
+ import { useAuth } from "./useAuth";
5
+ /**
6
+ * Custom hook for handling the sign-out mutation using Firebase authentication.
7
+ * It wraps the useMutation hook to provide a sign-out function with Firebase.
8
+ *
9
+ * @param {Omit<UseMutationOptions<void, FirebaseError, void, TContext>, "queryKey" | "queryFn">} options - Configuration options for the mutation, excluding "queryKey" and "queryFn".
10
+ * @returns {UseMutationResult<void, FirebaseError, void, TContext>} A mutation object for handling the sign-out process, including methods for mutating and state tracking.
11
+ */
12
+ export const useSignOutMutation = (options = {}) => {
13
+ const firebaseAuth = useAuth();
14
+ return useMutation({
15
+ ...options,
16
+ mutationFn: async () => await signOut(firebaseAuth),
17
+ mutationKey: SIGN_OUT_MUTATION_KEY
18
+ });
19
+ };
@@ -0,0 +1,25 @@
1
+ import { useMutation, UseMutationOptions } from "@tanstack/react-query";
2
+ import { signOut } from "firebase/auth";
3
+
4
+ import { SIGN_OUT_MUTATION_KEY } from "./mutation-keys";
5
+ import { FirebaseError } from "firebase/app";
6
+ import { useAuth } from "./useAuth";
7
+
8
+ /**
9
+ * Custom hook for handling the sign-out mutation using Firebase authentication.
10
+ * It wraps the useMutation hook to provide a sign-out function with Firebase.
11
+ *
12
+ * @param {Omit<UseMutationOptions<void, FirebaseError, void, TContext>, "queryKey" | "queryFn">} options - Configuration options for the mutation, excluding "queryKey" and "queryFn".
13
+ * @returns {UseMutationResult<void, FirebaseError, void, TContext>} A mutation object for handling the sign-out process, including methods for mutating and state tracking.
14
+ */
15
+ export const useSignOutMutation = <TContext = unknown>(
16
+ options: Omit<UseMutationOptions<void, FirebaseError, void, TContext>, "queryKey" | "queryFn"> = {}
17
+ ) => {
18
+ const firebaseAuth = useAuth();
19
+
20
+ return useMutation({
21
+ ...options,
22
+ mutationFn: async () => await signOut(firebaseAuth),
23
+ mutationKey: SIGN_OUT_MUTATION_KEY
24
+ });
25
+ };
@@ -0,0 +1,15 @@
1
+ import { UseMutationOptions } from "@tanstack/react-query";
2
+ import { User } from "firebase/auth";
3
+ import { FirebaseError } from "firebase/app";
4
+ export type UseUpdateProfileMutationVariables = {
5
+ displayName?: string;
6
+ user: User;
7
+ };
8
+ /**
9
+ * Custom hook to manage the mutation for updating a user's profile.
10
+ * Utilizes Firebase for updating the user's display name.
11
+ *
12
+ * @param {Omit<UseMutationOptions<void, FirebaseError, UseUpdateProfileMutationVariables, TContext>, "mutationKey" | "mutationFn">} options - Configuration options for the mutation, excluding mutationKey and mutationFn.
13
+ * @returns {UseMutationResult<void, FirebaseError, UseUpdateProfileMutationVariables, TContext>} The result of the mutation operation including statuses, data, and error information.
14
+ */
15
+ export declare const useUpdateProfileMutation: <TContext = unknown>(options?: Omit<UseMutationOptions<void, FirebaseError, UseUpdateProfileMutationVariables, TContext>, "mutationKey" | "mutationFn">) => import("@tanstack/react-query").UseMutationResult<void, FirebaseError, UseUpdateProfileMutationVariables, TContext>;
@@ -0,0 +1,17 @@
1
+ import { useMutation } from "@tanstack/react-query";
2
+ import { updateProfile } from "firebase/auth";
3
+ import { CREATE_USER_WITH_EMAIL_AND_PASSWORD_MUTATION_KEY } from "./mutation-keys";
4
+ /**
5
+ * Custom hook to manage the mutation for updating a user's profile.
6
+ * Utilizes Firebase for updating the user's display name.
7
+ *
8
+ * @param {Omit<UseMutationOptions<void, FirebaseError, UseUpdateProfileMutationVariables, TContext>, "mutationKey" | "mutationFn">} options - Configuration options for the mutation, excluding mutationKey and mutationFn.
9
+ * @returns {UseMutationResult<void, FirebaseError, UseUpdateProfileMutationVariables, TContext>} The result of the mutation operation including statuses, data, and error information.
10
+ */
11
+ export const useUpdateProfileMutation = (options = {}) => {
12
+ return useMutation({
13
+ ...options,
14
+ mutationFn: async ({ displayName, user }) => await updateProfile(user, { displayName }),
15
+ mutationKey: CREATE_USER_WITH_EMAIL_AND_PASSWORD_MUTATION_KEY
16
+ });
17
+ };
@@ -0,0 +1,30 @@
1
+ import { useMutation, UseMutationOptions } from "@tanstack/react-query";
2
+ import { updateProfile, User } from "firebase/auth";
3
+ import { FirebaseError } from "firebase/app";
4
+ import { CREATE_USER_WITH_EMAIL_AND_PASSWORD_MUTATION_KEY } from "./mutation-keys";
5
+
6
+ export type UseUpdateProfileMutationVariables = {
7
+ displayName?: string;
8
+ user: User;
9
+ };
10
+
11
+ /**
12
+ * Custom hook to manage the mutation for updating a user's profile.
13
+ * Utilizes Firebase for updating the user's display name.
14
+ *
15
+ * @param {Omit<UseMutationOptions<void, FirebaseError, UseUpdateProfileMutationVariables, TContext>, "mutationKey" | "mutationFn">} options - Configuration options for the mutation, excluding mutationKey and mutationFn.
16
+ * @returns {UseMutationResult<void, FirebaseError, UseUpdateProfileMutationVariables, TContext>} The result of the mutation operation including statuses, data, and error information.
17
+ */
18
+ export const useUpdateProfileMutation = <TContext = unknown>(
19
+ options: Omit<
20
+ UseMutationOptions<void, FirebaseError, UseUpdateProfileMutationVariables, TContext>,
21
+ "mutationKey" | "mutationFn"
22
+ > = {}
23
+ ) => {
24
+ return useMutation({
25
+ ...options,
26
+ mutationFn: async ({ displayName, user }: UseUpdateProfileMutationVariables) =>
27
+ await updateProfile(user, { displayName }),
28
+ mutationKey: CREATE_USER_WITH_EMAIL_AND_PASSWORD_MUTATION_KEY
29
+ });
30
+ };
@@ -0,0 +1,19 @@
1
+ import { Auth } from "firebase/auth";
2
+ import { Analytics } from "firebase/analytics";
3
+ import { Firestore } from "firebase/firestore";
4
+ import { FirebaseApp } from "firebase/app";
5
+ import { RemoteConfig } from "firebase/remote-config";
6
+ type FirebaseContextValue = {
7
+ auth: Auth;
8
+ analytics: Analytics;
9
+ firebase: FirebaseApp;
10
+ remoteConfig: RemoteConfig;
11
+ firestore: Firestore;
12
+ };
13
+ /**
14
+ * FirebaseContext is a shared context across children that provides access to firebase features
15
+ *
16
+ * @internal
17
+ */
18
+ export declare const FirebaseContext: import("react").Context<FirebaseContextValue>;
19
+ export {};
@@ -0,0 +1,8 @@
1
+ "use client";
2
+ import { createContext } from "react";
3
+ /**
4
+ * FirebaseContext is a shared context across children that provides access to firebase features
5
+ *
6
+ * @internal
7
+ */
8
+ export const FirebaseContext = createContext({});
@@ -0,0 +1,25 @@
1
+ "use client";
2
+
3
+ import { createContext } from "react";
4
+
5
+ import { Auth } from "firebase/auth";
6
+ import { Analytics } from "firebase/analytics";
7
+ import { Firestore } from "firebase/firestore";
8
+ import { FirebaseApp } from "firebase/app";
9
+ import { RemoteConfig } from "firebase/remote-config";
10
+
11
+ type FirebaseContextValue = {
12
+ auth: Auth;
13
+ analytics: Analytics;
14
+ firebase: FirebaseApp;
15
+ remoteConfig: RemoteConfig;
16
+ firestore: Firestore;
17
+ };
18
+
19
+ /**
20
+ * FirebaseContext is a shared context across children that provides access to firebase features
21
+ *
22
+ * @internal
23
+ */
24
+
25
+ export const FirebaseContext = createContext<FirebaseContextValue>({} as FirebaseContextValue);