@umituz/react-native-auth 4.3.63 → 4.3.65
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/react-native-auth",
|
|
3
|
-
"version": "4.3.
|
|
3
|
+
"version": "4.3.65",
|
|
4
4
|
"description": "Authentication service for React Native apps - Secure, type-safe, and production-ready. Provider-agnostic design with dependency injection, configurable validation, and comprehensive error handling.",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"types": "./src/index.ts",
|
|
@@ -7,10 +7,17 @@
|
|
|
7
7
|
import { useCallback } from "react";
|
|
8
8
|
import { useAuthStore } from "../stores/authStore";
|
|
9
9
|
import {
|
|
10
|
-
selectAuthState,
|
|
11
10
|
selectSetLoading,
|
|
12
11
|
selectSetError,
|
|
13
12
|
} from "../stores/auth.selectors";
|
|
13
|
+
import {
|
|
14
|
+
calculateUserId,
|
|
15
|
+
calculateHasFirebaseUser,
|
|
16
|
+
calculateIsAnonymous,
|
|
17
|
+
calculateIsAuthenticated,
|
|
18
|
+
calculateUserType,
|
|
19
|
+
calculateIsAuthReady,
|
|
20
|
+
} from "../../infrastructure/utils/calculators/authStateCalculator";
|
|
14
21
|
import type { UserType } from "../../types/auth-store.types";
|
|
15
22
|
import {
|
|
16
23
|
useSignInMutation,
|
|
@@ -38,9 +45,14 @@ export interface UseAuthResult {
|
|
|
38
45
|
}
|
|
39
46
|
|
|
40
47
|
export function useAuth(): UseAuthResult {
|
|
41
|
-
// PERFORMANCE:
|
|
42
|
-
// This
|
|
43
|
-
const
|
|
48
|
+
// PERFORMANCE: Individual selectors instead of selectAuthState to avoid unstable object references
|
|
49
|
+
// This fixes the 'getSnapshot should be cached' warning in React 19
|
|
50
|
+
const user = useAuthStore((s) => s.user);
|
|
51
|
+
const loading = useAuthStore((s) => s.loading);
|
|
52
|
+
const error = useAuthStore((s) => s.error);
|
|
53
|
+
const firebaseUser = useAuthStore((s) => s.firebaseUser);
|
|
54
|
+
const initialized = useAuthStore((s) => s.initialized);
|
|
55
|
+
|
|
44
56
|
const setLoading = useAuthStore(selectSetLoading);
|
|
45
57
|
const setError = useAuthStore(selectSetError);
|
|
46
58
|
|
|
@@ -110,8 +122,28 @@ export function useAuth(): UseAuthResult {
|
|
|
110
122
|
}
|
|
111
123
|
}, [setLoading, setError, anonymousModeMutation.mutateAsync]);
|
|
112
124
|
|
|
125
|
+
// Derive state (same logic as in selectAuthState but stable within this hook)
|
|
126
|
+
const userId = calculateUserId(firebaseUser);
|
|
127
|
+
const isAuthenticated = calculateIsAuthenticated(firebaseUser);
|
|
128
|
+
const isAnonymous = calculateIsAnonymous(firebaseUser);
|
|
129
|
+
const userType = calculateUserType(firebaseUser);
|
|
130
|
+
const isAuthReady = calculateIsAuthReady(initialized, loading);
|
|
131
|
+
const hasFirebaseUser = calculateHasFirebaseUser(firebaseUser);
|
|
132
|
+
|
|
113
133
|
return {
|
|
114
|
-
|
|
115
|
-
|
|
134
|
+
user,
|
|
135
|
+
userId,
|
|
136
|
+
userType,
|
|
137
|
+
loading,
|
|
138
|
+
isAuthReady,
|
|
139
|
+
isAnonymous,
|
|
140
|
+
isAuthenticated,
|
|
141
|
+
hasFirebaseUser,
|
|
142
|
+
error,
|
|
143
|
+
signUp,
|
|
144
|
+
signIn,
|
|
145
|
+
signOut,
|
|
146
|
+
continueAnonymously,
|
|
147
|
+
setError,
|
|
116
148
|
};
|
|
117
149
|
}
|
|
@@ -128,7 +128,7 @@ export function useAuthBottomSheet(params: UseAuthBottomSheetParams = {}) {
|
|
|
128
128
|
}
|
|
129
129
|
}, [onAppleSignIn, signInWithApple]);
|
|
130
130
|
|
|
131
|
-
return {
|
|
131
|
+
return useMemo(() => ({
|
|
132
132
|
modalRef,
|
|
133
133
|
googleLoading,
|
|
134
134
|
appleLoading,
|
|
@@ -140,5 +140,17 @@ export function useAuthBottomSheet(params: UseAuthBottomSheetParams = {}) {
|
|
|
140
140
|
handleNavigateToLogin,
|
|
141
141
|
handleGoogleSignIn,
|
|
142
142
|
handleAppleSignIn,
|
|
143
|
-
}
|
|
143
|
+
}), [
|
|
144
|
+
modalRef,
|
|
145
|
+
googleLoading,
|
|
146
|
+
appleLoading,
|
|
147
|
+
mode,
|
|
148
|
+
providers,
|
|
149
|
+
handleDismiss,
|
|
150
|
+
handleClose,
|
|
151
|
+
handleNavigateToRegister,
|
|
152
|
+
handleNavigateToLogin,
|
|
153
|
+
handleGoogleSignIn,
|
|
154
|
+
handleAppleSignIn,
|
|
155
|
+
]);
|
|
144
156
|
}
|