@umituz/react-native-firebase 1.13.30 → 1.13.31
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 +1 -1
- package/src/auth/infrastructure/config/initializers/FirebaseAuthInitializer.ts +48 -71
- package/src/firestore/infrastructure/config/FirestoreClient.ts +3 -0
- package/src/firestore/infrastructure/repositories/BaseRepository.ts +3 -0
- package/src/infrastructure/config/FirebaseClient.ts +3 -0
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.31",
|
|
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",
|
|
@@ -5,7 +5,11 @@
|
|
|
5
5
|
* Platform-agnostic: Works on all platforms (Web, iOS, Android)
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
initializeAuth,
|
|
10
|
+
getAuth,
|
|
11
|
+
getReactNativePersistence,
|
|
12
|
+
} from 'firebase/auth';
|
|
9
13
|
import type { Auth } from 'firebase/auth';
|
|
10
14
|
import AsyncStorage from '@react-native-async-storage/async-storage';
|
|
11
15
|
import type { FirebaseApp } from 'firebase/app';
|
|
@@ -30,7 +34,6 @@ export class FirebaseAuthInitializer {
|
|
|
30
34
|
addPackageBreadcrumb('firebase-auth', 'Initializing Firebase Auth');
|
|
31
35
|
|
|
32
36
|
try {
|
|
33
|
-
// Try React Native persistence first (works on all platforms)
|
|
34
37
|
const auth = this.initializeWithPersistence(app, config);
|
|
35
38
|
|
|
36
39
|
if (auth) {
|
|
@@ -38,57 +41,54 @@ export class FirebaseAuthInitializer {
|
|
|
38
41
|
}
|
|
39
42
|
|
|
40
43
|
return auth;
|
|
41
|
-
} catch (error:
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
44
|
+
} catch (error: unknown) {
|
|
45
|
+
return this.handleInitializationError(error, app);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
private static handleInitializationError(error: unknown, app: FirebaseApp): Auth | null {
|
|
50
|
+
const errorObj = error instanceof Error ? error : new Error(String(error));
|
|
51
|
+
const errorCode = (error as { code?: string })?.code;
|
|
52
|
+
|
|
53
|
+
if (errorCode === 'auth/already-initialized') {
|
|
54
|
+
trackPackageWarning(
|
|
55
|
+
'firebase-auth',
|
|
56
|
+
'Auth already initialized, returning existing instance',
|
|
57
|
+
{ errorCode }
|
|
58
|
+
);
|
|
59
|
+
return this.getExistingAuth(app);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
trackPackageError(errorObj, {
|
|
63
|
+
packageName: 'firebase-auth',
|
|
64
|
+
operation: 'initialize',
|
|
65
|
+
errorCode,
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
if (__DEV__) {
|
|
69
|
+
console.warn('Firebase Auth initialization error:', error);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return this.getExistingAuth(app);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
private static getExistingAuth(app: FirebaseApp): Auth | null {
|
|
76
|
+
try {
|
|
77
|
+
return getAuth(app);
|
|
78
|
+
} catch (getAuthError) {
|
|
79
|
+
const errorObj = getAuthError instanceof Error
|
|
80
|
+
? getAuthError
|
|
81
|
+
: new Error(String(getAuthError));
|
|
65
82
|
|
|
66
|
-
const errorObj = error instanceof Error ? error : new Error(String(error));
|
|
67
83
|
trackPackageError(errorObj, {
|
|
68
84
|
packageName: 'firebase-auth',
|
|
69
|
-
operation: '
|
|
70
|
-
errorCode: error.code,
|
|
85
|
+
operation: 'getAuth-fallback',
|
|
71
86
|
});
|
|
72
87
|
|
|
73
88
|
if (__DEV__) {
|
|
74
|
-
console.warn('Firebase Auth
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
// Try to get auth instance as fallback
|
|
78
|
-
try {
|
|
79
|
-
return getAuth(app);
|
|
80
|
-
} catch (getAuthError) {
|
|
81
|
-
const fallbackError = getAuthError instanceof Error ? getAuthError : new Error(String(getAuthError));
|
|
82
|
-
trackPackageError(fallbackError, {
|
|
83
|
-
packageName: 'firebase-auth',
|
|
84
|
-
operation: 'getAuth-fallback',
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
if (__DEV__) {
|
|
88
|
-
console.warn('Firebase Auth: Failed to get auth instance after initialization error:', getAuthError);
|
|
89
|
-
}
|
|
90
|
-
return null;
|
|
89
|
+
console.warn('Firebase Auth: Failed to get auth instance:', getAuthError);
|
|
91
90
|
}
|
|
91
|
+
return null;
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
|
|
@@ -97,25 +97,6 @@ export class FirebaseAuthInitializer {
|
|
|
97
97
|
config?: FirebaseAuthConfig
|
|
98
98
|
): Auth | null {
|
|
99
99
|
try {
|
|
100
|
-
const authModule = require('firebase/auth');
|
|
101
|
-
const getReactNativePersistence = authModule.getReactNativePersistence;
|
|
102
|
-
|
|
103
|
-
if (!getReactNativePersistence) {
|
|
104
|
-
trackPackageWarning(
|
|
105
|
-
'firebase-auth',
|
|
106
|
-
'getReactNativePersistence not available, using default persistence'
|
|
107
|
-
);
|
|
108
|
-
|
|
109
|
-
if (__DEV__) {
|
|
110
|
-
console.log('Firebase Auth: getReactNativePersistence not available, using default persistence');
|
|
111
|
-
}
|
|
112
|
-
try {
|
|
113
|
-
return getAuth(app);
|
|
114
|
-
} catch {
|
|
115
|
-
return null;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
100
|
const storage = config?.authStorage || {
|
|
120
101
|
getItem: (key: string) => AsyncStorage.getItem(key),
|
|
121
102
|
setItem: (key: string, value: string) => AsyncStorage.setItem(key, value),
|
|
@@ -137,12 +118,8 @@ export class FirebaseAuthInitializer {
|
|
|
137
118
|
if (__DEV__) {
|
|
138
119
|
console.warn('Firebase Auth: Persistence initialization failed:', error);
|
|
139
120
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
} catch {
|
|
143
|
-
return null;
|
|
144
|
-
}
|
|
121
|
+
|
|
122
|
+
return this.getExistingAuth(app);
|
|
145
123
|
}
|
|
146
124
|
}
|
|
147
125
|
}
|
|
148
|
-
|
|
@@ -13,6 +13,9 @@
|
|
|
13
13
|
* - Dependency Inversion: Depends on Firebase App from @umituz/react-native-firebase
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
|
+
// eslint-disable-next-line no-console
|
|
17
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) console.log("📍 [LIFECYCLE] FirestoreClient.ts - Module loading");
|
|
18
|
+
|
|
16
19
|
import type { Firestore } from 'firebase/firestore';
|
|
17
20
|
import { getFirebaseApp } from '../../../infrastructure/config/FirebaseClient';
|
|
18
21
|
import { FirebaseFirestoreInitializer } from './initializers/FirebaseFirestoreInitializer';
|
|
@@ -14,6 +14,9 @@
|
|
|
14
14
|
* It provides a consistent interface for Firestore operations.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
+
// eslint-disable-next-line no-console
|
|
18
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) console.log("📍 [LIFECYCLE] BaseRepository.ts - Module loading");
|
|
19
|
+
|
|
17
20
|
import type { Firestore } from "firebase/firestore";
|
|
18
21
|
import { getFirestore } from "../config/FirestoreClient";
|
|
19
22
|
import {
|
|
@@ -16,6 +16,9 @@
|
|
|
16
16
|
* - Dependency Inversion: Depends on abstractions (interfaces), not concrete implementations
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
+
// eslint-disable-next-line no-console
|
|
20
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) console.log("📍 [LIFECYCLE] FirebaseClient.ts - Module loading");
|
|
21
|
+
|
|
19
22
|
import type { FirebaseConfig } from '../../domain/value-objects/FirebaseConfig';
|
|
20
23
|
import type { IFirebaseClient } from '../../application/ports/IFirebaseClient';
|
|
21
24
|
import type { FirebaseApp } from './initializers/FirebaseAppInitializer';
|