@umituz/react-native-auth 1.6.6 → 1.6.8

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": "1.6.6",
3
+ "version": "1.6.8",
4
4
  "description": "Authentication service for React Native apps - Secure, type-safe, and production-ready. Provider-agnostic design supports Firebase Auth and can be adapted for Supabase or other providers.",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
@@ -238,6 +238,10 @@ export class AuthService implements IAuthService {
238
238
  * Sign in an existing user
239
239
  */
240
240
  async signIn(params: SignInParams): Promise<User> {
241
+ /* eslint-disable-next-line no-console */
242
+ if (__DEV__) {
243
+ console.log("[AuthService] signIn called with email:", params.email);
244
+ }
241
245
  const auth = this.getAuth();
242
246
  if (!auth) {
243
247
  throw new AuthInitializationError("Auth service is not initialized");
@@ -254,27 +258,48 @@ export class AuthService implements IAuthService {
254
258
  }
255
259
 
256
260
  try {
261
+ /* eslint-disable-next-line no-console */
262
+ if (__DEV__) {
263
+ console.log("[AuthService] Calling signInWithEmailAndPassword");
264
+ }
257
265
  const userCredential = await signInWithEmailAndPassword(
258
266
  auth,
259
267
  params.email.trim(),
260
268
  params.password
261
269
  );
262
270
 
271
+ /* eslint-disable-next-line no-console */
272
+ if (__DEV__) {
273
+ console.log("[AuthService] signInWithEmailAndPassword successful, user:", userCredential.user.uid);
274
+ }
275
+
263
276
  // Clear guest mode when user signs in
264
277
  if (this.isGuestMode) {
265
278
  this.isGuestMode = false;
266
279
  try {
267
280
  await storageRepository.removeItem(GUEST_MODE_KEY);
281
+ /* eslint-disable-next-line no-console */
282
+ if (__DEV__) {
283
+ console.log("[AuthService] Guest mode cleared from storage");
284
+ }
268
285
  } catch (error) {
269
286
  // Ignore storage errors
270
287
  }
271
288
  }
272
289
 
273
290
  // Emit event for AppNavigator to handle navigation
291
+ /* eslint-disable-next-line no-console */
292
+ if (__DEV__) {
293
+ console.log("[AuthService] Emitting user-authenticated event");
294
+ }
274
295
  DeviceEventEmitter.emit("user-authenticated", { userId: userCredential.user.uid });
275
296
 
276
297
  return userCredential.user;
277
298
  } catch (error: any) {
299
+ /* eslint-disable-next-line no-console */
300
+ if (__DEV__) {
301
+ console.error("[AuthService] signIn error:", error);
302
+ }
278
303
  throw mapFirebaseAuthError(error);
279
304
  }
280
305
  }
@@ -47,6 +47,10 @@ export const LoginForm: React.FC<LoginFormProps> = ({
47
47
  };
48
48
 
49
49
  const handleSignIn = async () => {
50
+ /* eslint-disable-next-line no-console */
51
+ if (__DEV__) {
52
+ console.log("[LoginForm] handleSignIn called");
53
+ }
50
54
  setEmailError(null);
51
55
  setPasswordError(null);
52
56
  setLocalError(null);
@@ -69,11 +73,29 @@ export const LoginForm: React.FC<LoginFormProps> = ({
69
73
  hasError = true;
70
74
  }
71
75
 
72
- if (hasError) return;
76
+ if (hasError) {
77
+ /* eslint-disable-next-line no-console */
78
+ if (__DEV__) {
79
+ console.log("[LoginForm] Validation errors, returning early");
80
+ }
81
+ return;
82
+ }
73
83
 
74
84
  try {
85
+ /* eslint-disable-next-line no-console */
86
+ if (__DEV__) {
87
+ console.log("[LoginForm] Calling signIn with email:", email.trim());
88
+ }
75
89
  await signIn(email.trim(), password);
90
+ /* eslint-disable-next-line no-console */
91
+ if (__DEV__) {
92
+ console.log("[LoginForm] signIn completed successfully");
93
+ }
76
94
  } catch (err: any) {
95
+ /* eslint-disable-next-line no-console */
96
+ if (__DEV__) {
97
+ console.error("[LoginForm] signIn error:", err);
98
+ }
77
99
  const localizationKey = getAuthErrorLocalizationKey(err);
78
100
  const errorMessage = t(localizationKey);
79
101
  setLocalError(errorMessage);
@@ -112,7 +112,7 @@ export function useAuth(): UseAuthResult {
112
112
 
113
113
  // Listen for guest-mode-enabled event to update state
114
114
  useEffect(() => {
115
- const subscription = DeviceEventEmitter.addListener(
115
+ const guestSubscription = DeviceEventEmitter.addListener(
116
116
  "guest-mode-enabled",
117
117
  () => {
118
118
  /* eslint-disable-next-line no-console */
@@ -123,10 +123,26 @@ export function useAuth(): UseAuthResult {
123
123
  }
124
124
  );
125
125
 
126
+ // Listen for user-authenticated event to ensure state updates
127
+ const authSubscription = DeviceEventEmitter.addListener(
128
+ "user-authenticated",
129
+ () => {
130
+ /* eslint-disable-next-line no-console */
131
+ if (__DEV__) {
132
+ console.log("[useAuth] User authenticated event received");
133
+ }
134
+ // Clear guest mode if set
135
+ if (isGuest) {
136
+ setIsGuest(false);
137
+ }
138
+ }
139
+ );
140
+
126
141
  return () => {
127
- subscription.remove();
142
+ guestSubscription.remove();
143
+ authSubscription.remove();
128
144
  };
129
- }, []);
145
+ }, [isGuest]);
130
146
 
131
147
  const signUp = useCallback(async (
132
148
  email: string,
@@ -158,6 +174,10 @@ export function useAuth(): UseAuthResult {
158
174
  }, [isGuest]);
159
175
 
160
176
  const signIn = useCallback(async (email: string, password: string) => {
177
+ /* eslint-disable-next-line no-console */
178
+ if (__DEV__) {
179
+ console.log("[useAuth] signIn called with email:", email);
180
+ }
161
181
  const service = getAuthService();
162
182
  if (!service) {
163
183
  const err = "Auth service is not initialized";
@@ -167,13 +187,29 @@ export function useAuth(): UseAuthResult {
167
187
  try {
168
188
  setLoading(true);
169
189
  setError(null);
190
+ /* eslint-disable-next-line no-console */
191
+ if (__DEV__) {
192
+ console.log("[useAuth] Calling service.signIn()");
193
+ }
170
194
  await service.signIn({ email, password });
195
+ /* eslint-disable-next-line no-console */
196
+ if (__DEV__) {
197
+ console.log("[useAuth] Service.signIn() completed successfully");
198
+ }
171
199
  // Clear guest mode when user signs in
172
200
  if (isGuest) {
201
+ /* eslint-disable-next-line no-console */
202
+ if (__DEV__) {
203
+ console.log("[useAuth] Clearing guest mode after sign in");
204
+ }
173
205
  setIsGuest(false);
174
206
  }
175
207
  // User state is updated by Firebase Auth's onAuthStateChanged
176
208
  } catch (err: any) {
209
+ /* eslint-disable-next-line no-console */
210
+ if (__DEV__) {
211
+ console.error("[useAuth] Error in signIn:", err);
212
+ }
177
213
  const errorMessage = err.message || "Failed to sign in";
178
214
  setError(errorMessage);
179
215
  throw err;