@umituz/react-native-firebase 2.4.3 → 2.4.4
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": "2.4.
|
|
3
|
+
"version": "2.4.4",
|
|
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",
|
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { deleteUser, type User } from "firebase/auth";
|
|
7
|
+
|
|
8
|
+
declare const __DEV__: boolean;
|
|
7
9
|
import { getFirebaseAuth } from "../../../auth/infrastructure/config/FirebaseAuthClient";
|
|
8
10
|
import {
|
|
9
11
|
getUserAuthProvider,
|
|
@@ -23,10 +25,17 @@ export type { AccountDeletionOptions } from "../../application/ports/reauthentic
|
|
|
23
25
|
export async function deleteCurrentUser(
|
|
24
26
|
options: AccountDeletionOptions = { autoReauthenticate: true }
|
|
25
27
|
): Promise<AccountDeletionResult> {
|
|
28
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
29
|
+
console.log("[deleteCurrentUser] Called with options:", options);
|
|
30
|
+
}
|
|
31
|
+
|
|
26
32
|
const auth = getFirebaseAuth();
|
|
27
33
|
const user = auth?.currentUser;
|
|
28
34
|
|
|
29
35
|
if (!auth || !user) {
|
|
36
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
37
|
+
console.log("[deleteCurrentUser] Auth not ready");
|
|
38
|
+
}
|
|
30
39
|
return {
|
|
31
40
|
success: false,
|
|
32
41
|
error: { code: "auth/not-ready", message: "Auth not ready" },
|
|
@@ -35,6 +44,9 @@ export async function deleteCurrentUser(
|
|
|
35
44
|
}
|
|
36
45
|
|
|
37
46
|
if (user.isAnonymous) {
|
|
47
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
48
|
+
console.log("[deleteCurrentUser] Cannot delete anonymous user");
|
|
49
|
+
}
|
|
38
50
|
return {
|
|
39
51
|
success: false,
|
|
40
52
|
error: { code: "auth/anonymous", message: "Cannot delete anonymous" },
|
|
@@ -43,9 +55,18 @@ export async function deleteCurrentUser(
|
|
|
43
55
|
}
|
|
44
56
|
|
|
45
57
|
const provider = getUserAuthProvider(user);
|
|
58
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
59
|
+
console.log("[deleteCurrentUser] User provider:", provider);
|
|
60
|
+
}
|
|
46
61
|
|
|
47
62
|
if (provider === "password" && options.autoReauthenticate && options.onPasswordRequired) {
|
|
63
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
64
|
+
console.log("[deleteCurrentUser] Password provider, calling attemptReauth");
|
|
65
|
+
}
|
|
48
66
|
const reauth = await attemptReauth(user, options);
|
|
67
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
68
|
+
console.log("[deleteCurrentUser] attemptReauth result:", reauth);
|
|
69
|
+
}
|
|
49
70
|
if (reauth) return reauth;
|
|
50
71
|
}
|
|
51
72
|
|
|
@@ -74,12 +95,26 @@ export async function deleteCurrentUser(
|
|
|
74
95
|
}
|
|
75
96
|
|
|
76
97
|
async function attemptReauth(user: User, options: AccountDeletionOptions): Promise<AccountDeletionResult | null> {
|
|
98
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
99
|
+
console.log("[attemptReauth] Called");
|
|
100
|
+
}
|
|
101
|
+
|
|
77
102
|
const provider = getUserAuthProvider(user);
|
|
103
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
104
|
+
console.log("[attemptReauth] Provider:", provider);
|
|
105
|
+
}
|
|
106
|
+
|
|
78
107
|
let res: { success: boolean; error?: { code?: string; message?: string } };
|
|
79
108
|
|
|
80
109
|
if (provider === "apple.com") {
|
|
110
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
111
|
+
console.log("[attemptReauth] Apple provider");
|
|
112
|
+
}
|
|
81
113
|
res = await reauthenticateWithApple(user);
|
|
82
114
|
} else if (provider === "google.com") {
|
|
115
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
116
|
+
console.log("[attemptReauth] Google provider");
|
|
117
|
+
}
|
|
83
118
|
let googleToken = options.googleIdToken;
|
|
84
119
|
if (!googleToken && options.onGoogleReauthRequired) {
|
|
85
120
|
const token = await options.onGoogleReauthRequired();
|
|
@@ -101,9 +136,18 @@ async function attemptReauth(user: User, options: AccountDeletionOptions): Promi
|
|
|
101
136
|
}
|
|
102
137
|
res = await reauthenticateWithGoogle(user, googleToken);
|
|
103
138
|
} else if (provider === "password") {
|
|
139
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
140
|
+
console.log("[attemptReauth] Password provider, calling onPasswordRequired...");
|
|
141
|
+
}
|
|
104
142
|
let password = options.password;
|
|
105
143
|
if (!password && options.onPasswordRequired) {
|
|
144
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
145
|
+
console.log("[attemptReauth] Calling onPasswordRequired callback");
|
|
146
|
+
}
|
|
106
147
|
const pwd = await options.onPasswordRequired();
|
|
148
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
149
|
+
console.log("[attemptReauth] onPasswordRequired returned:", pwd ? "password received" : "null/cancelled");
|
|
150
|
+
}
|
|
107
151
|
if (!pwd) {
|
|
108
152
|
return {
|
|
109
153
|
success: false,
|