@umituz/react-native-auth 4.3.47 → 4.3.49
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.49",
|
|
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",
|
package/src/index.ts
CHANGED
|
@@ -37,7 +37,7 @@ export { SECURITY_LIMITS, sanitizeEmail, sanitizePassword, sanitizeName } from '
|
|
|
37
37
|
export type { SecurityLimitKey } from './infrastructure/utils/validation/sanitization';
|
|
38
38
|
export { isEmpty, isEmptyEmail, isEmptyPassword, isEmptyName, isNotEmpty, hasContent } from './infrastructure/utils/validation/validationHelpers';
|
|
39
39
|
export { safeCallback, safeCallbackSync } from './infrastructure/utils/safeCallback';
|
|
40
|
-
|
|
40
|
+
|
|
41
41
|
|
|
42
42
|
// =============================================================================
|
|
43
43
|
// PRESENTATION LAYER - Hooks
|
|
@@ -18,7 +18,6 @@ import {
|
|
|
18
18
|
selectUserType,
|
|
19
19
|
selectIsAnonymous,
|
|
20
20
|
selectIsAuthReady,
|
|
21
|
-
selectIsRegisteredUser,
|
|
22
21
|
} from "../stores/auth.selectors";
|
|
23
22
|
import type { UserType } from "../../types/auth-store.types";
|
|
24
23
|
import {
|
|
@@ -38,7 +37,6 @@ export interface UseAuthResult {
|
|
|
38
37
|
isAnonymous: boolean;
|
|
39
38
|
isAuthenticated: boolean;
|
|
40
39
|
hasFirebaseUser: boolean;
|
|
41
|
-
isRegisteredUser: boolean;
|
|
42
40
|
error: string | null;
|
|
43
41
|
signUp: (email: string, password: string, displayName?: string) => Promise<void>;
|
|
44
42
|
signIn: (email: string, password: string) => Promise<void>;
|
|
@@ -57,7 +55,6 @@ export function useAuth(): UseAuthResult {
|
|
|
57
55
|
const userType = useAuthStore(selectUserType);
|
|
58
56
|
const isAnonymous = useAuthStore(selectIsAnonymous);
|
|
59
57
|
const isAuthReady = useAuthStore(selectIsAuthReady);
|
|
60
|
-
const isRegisteredUser = useAuthStore(selectIsRegisteredUser);
|
|
61
58
|
const setLoading = useAuthStore(selectSetLoading);
|
|
62
59
|
const setError = useAuthStore(selectSetError);
|
|
63
60
|
const setIsAnonymous = useAuthStore(selectSetIsAnonymous);
|
|
@@ -133,7 +130,7 @@ export function useAuth(): UseAuthResult {
|
|
|
133
130
|
}, [setIsAnonymous, setLoading, setError, anonymousModeMutation]);
|
|
134
131
|
|
|
135
132
|
return {
|
|
136
|
-
user, userId, userType, loading, isAuthReady, isAnonymous, isAuthenticated, hasFirebaseUser,
|
|
133
|
+
user, userId, userType, loading, isAuthReady, isAnonymous, isAuthenticated, hasFirebaseUser, error,
|
|
137
134
|
signUp, signIn, signOut, continueAnonymously, setError,
|
|
138
135
|
};
|
|
139
136
|
}
|
|
@@ -23,11 +23,6 @@ export const selectUser = (state: AuthStore): AuthUser | null => state.user;
|
|
|
23
23
|
*/
|
|
24
24
|
export const selectLoading = (state: AuthStore): boolean => state.loading;
|
|
25
25
|
|
|
26
|
-
/**
|
|
27
|
-
* Select anonymous mode (state flag)
|
|
28
|
-
*/
|
|
29
|
-
export const selectIsAnonymousState = (state: AuthStore): boolean => state.isAnonymous;
|
|
30
|
-
|
|
31
26
|
/**
|
|
32
27
|
* Select error
|
|
33
28
|
*/
|
|
@@ -118,11 +113,3 @@ export const selectIsAuthReady = (state: AuthStore): boolean => {
|
|
|
118
113
|
return state.initialized && !state.loading;
|
|
119
114
|
};
|
|
120
115
|
|
|
121
|
-
/**
|
|
122
|
-
* Check if user is a registered user (authenticated AND not anonymous)
|
|
123
|
-
* Use this for feature gating - only registered users can access premium features
|
|
124
|
-
*/
|
|
125
|
-
export const selectIsRegisteredUser = (state: AuthStore): boolean => {
|
|
126
|
-
if (!state.initialized) return false;
|
|
127
|
-
return selectIsAuthenticated(state);
|
|
128
|
-
};
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { PersistentDeviceIdService } from '@umituz/react-native-design-system/device';
|
|
2
|
-
import { getFirebaseAuth } from '@umituz/react-native-firebase';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Get the effective user ID for services that need to track user data
|
|
6
|
-
*
|
|
7
|
-
* Returns:
|
|
8
|
-
* - Firebase Auth UID if user is authenticated (not anonymous)
|
|
9
|
-
* - Device ID if user is anonymous or not logged in
|
|
10
|
-
*
|
|
11
|
-
* This ensures:
|
|
12
|
-
* - Each authenticated user has their own data (subscriptions, credits, etc.)
|
|
13
|
-
* - Anonymous users are tracked by device
|
|
14
|
-
* - Multiple accounts on same device don't share data
|
|
15
|
-
*
|
|
16
|
-
* @returns Promise<string> User ID for service identification
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
* ```typescript
|
|
20
|
-
* const userId = await getEffectiveUserId();
|
|
21
|
-
* // Authenticated user: "firebase_uid_123"
|
|
22
|
-
* // Anonymous user: "device_abc456"
|
|
23
|
-
* ```
|
|
24
|
-
*/
|
|
25
|
-
export async function getEffectiveUserId(): Promise<string> {
|
|
26
|
-
const auth = getFirebaseAuth();
|
|
27
|
-
const currentUser = auth?.currentUser;
|
|
28
|
-
|
|
29
|
-
if (currentUser && !currentUser.isAnonymous) {
|
|
30
|
-
return currentUser.uid;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return PersistentDeviceIdService.getDeviceId();
|
|
34
|
-
}
|