@umituz/react-native-firebase 1.13.34 → 1.13.36
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-firebase",
|
|
3
|
-
"version": "1.13.
|
|
3
|
+
"version": "1.13.36",
|
|
4
4
|
"description": "Unified Firebase package for React Native apps - Auth and Firestore services using Firebase JS SDK (no native modules).",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"types": "./src/index.ts",
|
package/src/auth/index.ts
CHANGED
|
@@ -43,13 +43,13 @@ export type {
|
|
|
43
43
|
export {
|
|
44
44
|
checkAuthState,
|
|
45
45
|
isAuthenticated,
|
|
46
|
-
|
|
46
|
+
isAnonymous,
|
|
47
47
|
getCurrentUserId,
|
|
48
48
|
getCurrentUser,
|
|
49
49
|
getCurrentUserIdFromGlobal,
|
|
50
50
|
getCurrentUserFromGlobal,
|
|
51
51
|
isCurrentUserAuthenticated,
|
|
52
|
-
|
|
52
|
+
isCurrentUserAnonymous,
|
|
53
53
|
verifyUserId,
|
|
54
54
|
getSafeUserId,
|
|
55
55
|
isValidUser,
|
|
@@ -21,7 +21,6 @@ function isAnonymousUser(user: User): boolean {
|
|
|
21
21
|
export interface AuthCheckResult {
|
|
22
22
|
isAuthenticated: boolean;
|
|
23
23
|
isAnonymous: boolean;
|
|
24
|
-
isGuest: boolean;
|
|
25
24
|
currentUser: User | null;
|
|
26
25
|
userId: string | null;
|
|
27
26
|
}
|
|
@@ -35,7 +34,6 @@ export function checkAuthState(auth: Auth | null): AuthCheckResult {
|
|
|
35
34
|
return {
|
|
36
35
|
isAuthenticated: false,
|
|
37
36
|
isAnonymous: false,
|
|
38
|
-
isGuest: false,
|
|
39
37
|
currentUser: null,
|
|
40
38
|
userId: null,
|
|
41
39
|
};
|
|
@@ -47,18 +45,14 @@ export function checkAuthState(auth: Auth | null): AuthCheckResult {
|
|
|
47
45
|
return {
|
|
48
46
|
isAuthenticated: false,
|
|
49
47
|
isAnonymous: false,
|
|
50
|
-
isGuest: false,
|
|
51
48
|
currentUser: null,
|
|
52
49
|
userId: null,
|
|
53
50
|
};
|
|
54
51
|
}
|
|
55
52
|
|
|
56
|
-
const anonymous = isAnonymousUser(currentUser);
|
|
57
|
-
|
|
58
53
|
return {
|
|
59
54
|
isAuthenticated: true,
|
|
60
|
-
isAnonymous:
|
|
61
|
-
isGuest: anonymous,
|
|
55
|
+
isAnonymous: isAnonymousUser(currentUser),
|
|
62
56
|
currentUser,
|
|
63
57
|
userId: currentUser.uid,
|
|
64
58
|
};
|
|
@@ -72,10 +66,10 @@ export function isAuthenticated(auth: Auth | null): boolean {
|
|
|
72
66
|
}
|
|
73
67
|
|
|
74
68
|
/**
|
|
75
|
-
* Check if user is
|
|
69
|
+
* Check if user is anonymous
|
|
76
70
|
*/
|
|
77
|
-
export function
|
|
78
|
-
return checkAuthState(auth).
|
|
71
|
+
export function isAnonymous(auth: Auth | null): boolean {
|
|
72
|
+
return checkAuthState(auth).isAnonymous;
|
|
79
73
|
}
|
|
80
74
|
|
|
81
75
|
/**
|
|
@@ -120,12 +114,12 @@ export function isCurrentUserAuthenticated(): boolean {
|
|
|
120
114
|
}
|
|
121
115
|
|
|
122
116
|
/**
|
|
123
|
-
* Check if current user is
|
|
117
|
+
* Check if current user is anonymous
|
|
124
118
|
* Convenience function that uses getFirebaseAuth()
|
|
125
119
|
*/
|
|
126
|
-
export function
|
|
120
|
+
export function isCurrentUserAnonymous(): boolean {
|
|
127
121
|
const auth = getFirebaseAuth();
|
|
128
|
-
return
|
|
122
|
+
return isAnonymous(auth);
|
|
129
123
|
}
|
|
130
124
|
|
|
131
125
|
/**
|
|
@@ -44,7 +44,7 @@ export interface FirestoreQueryResult {
|
|
|
44
44
|
readonly shouldSkip: boolean;
|
|
45
45
|
readonly reason?: FirestoreQuerySkipReason;
|
|
46
46
|
readonly userId: string | null;
|
|
47
|
-
readonly
|
|
47
|
+
readonly isAnonymous: boolean;
|
|
48
48
|
readonly isAuthenticated: boolean;
|
|
49
49
|
}
|
|
50
50
|
|
|
@@ -70,7 +70,7 @@ export function shouldSkipFirestoreQuery(
|
|
|
70
70
|
shouldSkip: true,
|
|
71
71
|
reason: "no_auth",
|
|
72
72
|
userId: null,
|
|
73
|
-
|
|
73
|
+
isAnonymous: false,
|
|
74
74
|
isAuthenticated: false,
|
|
75
75
|
};
|
|
76
76
|
}
|
|
@@ -85,20 +85,20 @@ export function shouldSkipFirestoreQuery(
|
|
|
85
85
|
shouldSkip: true,
|
|
86
86
|
reason: "not_authenticated",
|
|
87
87
|
userId: null,
|
|
88
|
-
|
|
88
|
+
isAnonymous: false,
|
|
89
89
|
isAuthenticated: false,
|
|
90
90
|
};
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
-
//
|
|
95
|
-
if (authState.
|
|
94
|
+
// Anonymous user
|
|
95
|
+
if (authState.isAnonymous) {
|
|
96
96
|
if (skipForGuest) {
|
|
97
97
|
return {
|
|
98
98
|
shouldSkip: true,
|
|
99
99
|
reason: "is_guest",
|
|
100
100
|
userId: authState.userId,
|
|
101
|
-
|
|
101
|
+
isAnonymous: true,
|
|
102
102
|
isAuthenticated: false,
|
|
103
103
|
};
|
|
104
104
|
}
|
|
@@ -111,7 +111,7 @@ export function shouldSkipFirestoreQuery(
|
|
|
111
111
|
shouldSkip: true,
|
|
112
112
|
reason: "user_id_mismatch",
|
|
113
113
|
userId: authState.userId,
|
|
114
|
-
|
|
114
|
+
isAnonymous: authState.isAnonymous,
|
|
115
115
|
isAuthenticated: authState.isAuthenticated,
|
|
116
116
|
};
|
|
117
117
|
}
|
|
@@ -121,7 +121,7 @@ export function shouldSkipFirestoreQuery(
|
|
|
121
121
|
return {
|
|
122
122
|
shouldSkip: false,
|
|
123
123
|
userId: authState.userId,
|
|
124
|
-
|
|
124
|
+
isAnonymous: authState.isAnonymous,
|
|
125
125
|
isAuthenticated: authState.isAuthenticated,
|
|
126
126
|
};
|
|
127
127
|
} catch (error) {
|
|
@@ -134,7 +134,7 @@ export function shouldSkipFirestoreQuery(
|
|
|
134
134
|
shouldSkip: true,
|
|
135
135
|
reason: "invalid_options",
|
|
136
136
|
userId: null,
|
|
137
|
-
|
|
137
|
+
isAnonymous: false,
|
|
138
138
|
isAuthenticated: false,
|
|
139
139
|
};
|
|
140
140
|
}
|
|
@@ -63,7 +63,6 @@ export function useAnonymousAuth(auth: Auth | null): UseAnonymousAuthResult {
|
|
|
63
63
|
setAuthState({
|
|
64
64
|
isAuthenticated: false,
|
|
65
65
|
isAnonymous: false,
|
|
66
|
-
isGuest: false,
|
|
67
66
|
currentUser: null,
|
|
68
67
|
userId: null,
|
|
69
68
|
});
|
|
@@ -72,7 +71,6 @@ export function useAnonymousAuth(auth: Auth | null): UseAnonymousAuthResult {
|
|
|
72
71
|
setAuthState({
|
|
73
72
|
isAuthenticated: true,
|
|
74
73
|
isAnonymous: anonymous,
|
|
75
|
-
isGuest: anonymous,
|
|
76
74
|
currentUser: user,
|
|
77
75
|
userId: user.uid,
|
|
78
76
|
});
|
|
@@ -104,7 +102,6 @@ export function useAnonymousAuth(auth: Auth | null): UseAnonymousAuthResult {
|
|
|
104
102
|
setAuthState({
|
|
105
103
|
isAuthenticated: false,
|
|
106
104
|
isAnonymous: false,
|
|
107
|
-
isGuest: false,
|
|
108
105
|
currentUser: null,
|
|
109
106
|
userId: null,
|
|
110
107
|
});
|