@umituz/react-native-firebase 1.13.23 → 1.13.24

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.23",
3
+ "version": "1.13.24",
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",
@@ -42,9 +42,16 @@ export interface AccountDeletionOptions {
42
42
  export async function deleteCurrentUser(
43
43
  options: AccountDeletionOptions = { autoReauthenticate: true }
44
44
  ): Promise<AccountDeletionResult> {
45
+ if (__DEV__) {
46
+ console.log("[deleteCurrentUser] Starting with options:", options);
47
+ }
48
+
45
49
  const auth = getFirebaseAuth();
46
50
 
47
51
  if (!auth) {
52
+ if (__DEV__) {
53
+ console.log("[deleteCurrentUser] ❌ Firebase Auth not initialized");
54
+ }
48
55
  return {
49
56
  success: false,
50
57
  error: {
@@ -58,6 +65,9 @@ export async function deleteCurrentUser(
58
65
  const user = auth.currentUser;
59
66
 
60
67
  if (!user) {
68
+ if (__DEV__) {
69
+ console.log("[deleteCurrentUser] ❌ No user signed in");
70
+ }
61
71
  return {
62
72
  success: false,
63
73
  error: {
@@ -69,6 +79,9 @@ export async function deleteCurrentUser(
69
79
  }
70
80
 
71
81
  if (user.isAnonymous) {
82
+ if (__DEV__) {
83
+ console.log("[deleteCurrentUser] ❌ Cannot delete anonymous user");
84
+ }
72
85
  return {
73
86
  success: false,
74
87
  error: {
@@ -79,18 +92,47 @@ export async function deleteCurrentUser(
79
92
  };
80
93
  }
81
94
 
95
+ if (__DEV__) {
96
+ const provider = getUserAuthProvider(user);
97
+ console.log("[deleteCurrentUser] User info:", {
98
+ uid: user.uid,
99
+ provider,
100
+ providerData: user.providerData?.map(p => p.providerId),
101
+ });
102
+ }
103
+
82
104
  // First attempt to delete
83
105
  try {
106
+ if (__DEV__) {
107
+ console.log("[deleteCurrentUser] Attempting to delete user...");
108
+ }
84
109
  await deleteUser(user);
110
+ if (__DEV__) {
111
+ console.log("[deleteCurrentUser] ✅ User deleted successfully");
112
+ }
85
113
  return { success: true };
86
114
  } catch (error) {
87
115
  const firebaseError = error as { code?: string; message?: string };
88
116
  const requiresReauth = firebaseError.code === "auth/requires-recent-login";
89
117
 
118
+ if (__DEV__) {
119
+ console.log("[deleteCurrentUser] First delete attempt failed:", {
120
+ code: firebaseError.code,
121
+ message: firebaseError.message,
122
+ requiresReauth,
123
+ });
124
+ }
125
+
90
126
  // If reauthentication is required and autoReauthenticate is enabled
91
127
  if (requiresReauth && options.autoReauthenticate) {
128
+ if (__DEV__) {
129
+ console.log("[deleteCurrentUser] Attempting auto-reauthentication...");
130
+ }
92
131
  const reauthResult = await attemptReauthenticationAndDelete(user, options);
93
132
  if (reauthResult) {
133
+ if (__DEV__) {
134
+ console.log("[deleteCurrentUser] Auto-reauth result:", reauthResult);
135
+ }
94
136
  return reauthResult;
95
137
  }
96
138
  }
@@ -117,17 +159,38 @@ async function attemptReauthenticationAndDelete(
117
159
  ): Promise<AccountDeletionResult | null> {
118
160
  const provider = getUserAuthProvider(user);
119
161
 
162
+ if (__DEV__) {
163
+ console.log("[attemptReauthenticationAndDelete] Provider:", provider);
164
+ }
165
+
120
166
  // Handle Apple reauthentication
121
167
  if (provider === "apple.com") {
168
+ if (__DEV__) {
169
+ console.log("[attemptReauthenticationAndDelete] Attempting Apple reauthentication...");
170
+ }
171
+
122
172
  const reauthResult = await reauthenticateWithApple(user);
123
173
 
174
+ if (__DEV__) {
175
+ console.log("[attemptReauthenticationAndDelete] Apple reauth result:", reauthResult);
176
+ }
177
+
124
178
  if (reauthResult.success) {
125
179
  // Retry deletion after successful reauthentication
126
180
  try {
181
+ if (__DEV__) {
182
+ console.log("[attemptReauthenticationAndDelete] Deleting user after Apple reauth...");
183
+ }
127
184
  await deleteUser(user);
185
+ if (__DEV__) {
186
+ console.log("[attemptReauthenticationAndDelete] ✅ User deleted after Apple reauth");
187
+ }
128
188
  return { success: true };
129
189
  } catch (deleteError) {
130
190
  const firebaseError = deleteError as { code?: string; message?: string };
191
+ if (__DEV__) {
192
+ console.log("[attemptReauthenticationAndDelete] ❌ Delete failed after Apple reauth:", firebaseError);
193
+ }
131
194
  return {
132
195
  success: false,
133
196
  error: {
@@ -139,6 +202,9 @@ async function attemptReauthenticationAndDelete(
139
202
  }
140
203
  } else {
141
204
  // Reauthentication failed
205
+ if (__DEV__) {
206
+ console.log("[attemptReauthenticationAndDelete] ❌ Apple reauth failed");
207
+ }
142
208
  return {
143
209
  success: false,
144
210
  error: {