@umituz/react-native-firebase 1.13.24 → 1.13.26

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.24",
3
+ "version": "1.13.26",
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
@@ -101,6 +101,7 @@ export {
101
101
  getUserAuthProvider,
102
102
  reauthenticateWithGoogle,
103
103
  reauthenticateWithApple,
104
+ reauthenticateWithPassword,
104
105
  getAppleReauthCredential,
105
106
  } from './infrastructure/services/reauthentication.service';
106
107
 
@@ -10,6 +10,7 @@ import { getFirebaseAuth } from "../config/FirebaseAuthClient";
10
10
  import {
11
11
  getUserAuthProvider,
12
12
  reauthenticateWithApple,
13
+ reauthenticateWithPassword,
13
14
  } from "./reauthentication.service";
14
15
 
15
16
  export interface AccountDeletionResult {
@@ -27,6 +28,11 @@ export interface AccountDeletionOptions {
27
28
  * This must be provided by the calling code after prompting user for Google sign-in
28
29
  */
29
30
  googleIdToken?: string;
31
+ /**
32
+ * Password for reauthentication (required if user signed in with email/password)
33
+ * This must be provided by the calling code after prompting user for password
34
+ */
35
+ password?: string;
30
36
  /**
31
37
  * If true, will attempt to reauthenticate with Apple automatically
32
38
  * (shows Apple sign-in prompt to user)
@@ -123,8 +129,8 @@ export async function deleteCurrentUser(
123
129
  });
124
130
  }
125
131
 
126
- // If reauthentication is required and autoReauthenticate is enabled
127
- if (requiresReauth && options.autoReauthenticate) {
132
+ // If reauthentication is required and autoReauthenticate is enabled OR password is provided
133
+ if (requiresReauth && (options.autoReauthenticate || options.password)) {
128
134
  if (__DEV__) {
129
135
  console.log("[deleteCurrentUser] Attempting auto-reauthentication...");
130
136
  }
@@ -262,6 +268,76 @@ async function attemptReauthenticationAndDelete(
262
268
  }
263
269
  }
264
270
 
271
+ // Handle Password reauthentication (requires password from caller)
272
+ if (provider === "password") {
273
+ if (__DEV__) {
274
+ console.log("[attemptReauthenticationAndDelete] Password provider detected");
275
+ }
276
+
277
+ // For password, we need the caller to provide the password
278
+ if (!options.password) {
279
+ if (__DEV__) {
280
+ console.log("[attemptReauthenticationAndDelete] No password provided, requesting reauth");
281
+ }
282
+ return {
283
+ success: false,
284
+ error: {
285
+ code: "auth/password-reauth-required",
286
+ message: "Please enter your password to delete your account",
287
+ requiresReauth: true,
288
+ },
289
+ };
290
+ }
291
+
292
+ if (__DEV__) {
293
+ console.log("[attemptReauthenticationAndDelete] Attempting password reauthentication...");
294
+ }
295
+
296
+ const reauthResult = await reauthenticateWithPassword(user, options.password);
297
+
298
+ if (__DEV__) {
299
+ console.log("[attemptReauthenticationAndDelete] Password reauth result:", reauthResult);
300
+ }
301
+
302
+ if (reauthResult.success) {
303
+ try {
304
+ if (__DEV__) {
305
+ console.log("[attemptReauthenticationAndDelete] Deleting user after password reauth...");
306
+ }
307
+ await deleteUser(user);
308
+ if (__DEV__) {
309
+ console.log("[attemptReauthenticationAndDelete] ✅ User deleted after password reauth");
310
+ }
311
+ return { success: true };
312
+ } catch (deleteError) {
313
+ const firebaseError = deleteError as { code?: string; message?: string };
314
+ if (__DEV__) {
315
+ console.log("[attemptReauthenticationAndDelete] ❌ Delete failed after password reauth:", firebaseError);
316
+ }
317
+ return {
318
+ success: false,
319
+ error: {
320
+ code: firebaseError.code || "auth/deletion-failed-after-reauth",
321
+ message: firebaseError.message || "Failed to delete account after reauthentication",
322
+ requiresReauth: false,
323
+ },
324
+ };
325
+ }
326
+ } else {
327
+ if (__DEV__) {
328
+ console.log("[attemptReauthenticationAndDelete] ❌ Password reauth failed");
329
+ }
330
+ return {
331
+ success: false,
332
+ error: {
333
+ code: reauthResult.error?.code || "auth/reauthentication-failed",
334
+ message: reauthResult.error?.message || "Password reauthentication failed",
335
+ requiresReauth: true,
336
+ },
337
+ };
338
+ }
339
+ }
340
+
265
341
  // For other providers, return null to use the default error handling
266
342
  return null;
267
343
  }
@@ -9,6 +9,7 @@ import {
9
9
  reauthenticateWithCredential,
10
10
  GoogleAuthProvider,
11
11
  OAuthProvider,
12
+ EmailAuthProvider,
12
13
  type User,
13
14
  type AuthCredential,
14
15
  } from "firebase/auth";
@@ -83,6 +84,39 @@ export async function reauthenticateWithGoogle(
83
84
  }
84
85
  }
85
86
 
87
+ /**
88
+ * Reauthenticate with Email/Password
89
+ */
90
+ export async function reauthenticateWithPassword(
91
+ user: User,
92
+ password: string
93
+ ): Promise<ReauthenticationResult> {
94
+ try {
95
+ if (!user.email) {
96
+ return {
97
+ success: false,
98
+ error: {
99
+ code: "auth/no-email",
100
+ message: "User has no email address",
101
+ },
102
+ };
103
+ }
104
+
105
+ const credential = EmailAuthProvider.credential(user.email, password);
106
+ await reauthenticateWithCredential(user, credential);
107
+ return { success: true };
108
+ } catch (error) {
109
+ const firebaseError = error as { code?: string; message?: string };
110
+ return {
111
+ success: false,
112
+ error: {
113
+ code: firebaseError.code || "auth/reauthentication-failed",
114
+ message: firebaseError.message || "Password reauthentication failed",
115
+ },
116
+ };
117
+ }
118
+ }
119
+
86
120
  /**
87
121
  * Generate a random nonce for Apple Sign-In security
88
122
  */