@umituz/react-native-firebase 1.13.30 → 1.13.32

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.30",
3
+ "version": "1.13.32",
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,13 @@
5
5
  * Platform-agnostic: Works on all platforms (Web, iOS, Android)
6
6
  */
7
7
 
8
- import { initializeAuth, getAuth } from 'firebase/auth';
8
+ import {
9
+ initializeAuth,
10
+ getAuth,
11
+ // @ts-ignore: getReactNativePersistence exists in the React Native bundle but missing from type definitions
12
+ // See: https://github.com/firebase/firebase-js-sdk/issues/9316
13
+ getReactNativePersistence,
14
+ } from 'firebase/auth';
9
15
  import type { Auth } from 'firebase/auth';
10
16
  import AsyncStorage from '@react-native-async-storage/async-storage';
11
17
  import type { FirebaseApp } from 'firebase/app';
@@ -30,7 +36,6 @@ export class FirebaseAuthInitializer {
30
36
  addPackageBreadcrumb('firebase-auth', 'Initializing Firebase Auth');
31
37
 
32
38
  try {
33
- // Try React Native persistence first (works on all platforms)
34
39
  const auth = this.initializeWithPersistence(app, config);
35
40
 
36
41
  if (auth) {
@@ -38,57 +43,54 @@ export class FirebaseAuthInitializer {
38
43
  }
39
44
 
40
45
  return auth;
41
- } catch (error: any) {
42
- // If already initialized or persistence fails, get existing instance
43
- if (error.code === 'auth/already-initialized') {
44
- trackPackageWarning(
45
- 'firebase-auth',
46
- 'Auth already initialized, returning existing instance',
47
- { errorCode: error.code }
48
- );
49
-
50
- try {
51
- return getAuth(app);
52
- } catch (getAuthError) {
53
- const errorObj = getAuthError instanceof Error ? getAuthError : new Error(String(getAuthError));
54
- trackPackageError(errorObj, {
55
- packageName: 'firebase-auth',
56
- operation: 'getAuth-after-already-initialized',
57
- });
58
-
59
- if (__DEV__) {
60
- console.warn('Firebase Auth: Failed to get existing auth instance:', getAuthError);
61
- }
62
- return null;
63
- }
64
- }
46
+ } catch (error: unknown) {
47
+ return this.handleInitializationError(error, app);
48
+ }
49
+ }
50
+
51
+ private static handleInitializationError(error: unknown, app: FirebaseApp): Auth | null {
52
+ const errorObj = error instanceof Error ? error : new Error(String(error));
53
+ const errorCode = (error as { code?: string })?.code;
54
+
55
+ if (errorCode === 'auth/already-initialized') {
56
+ trackPackageWarning(
57
+ 'firebase-auth',
58
+ 'Auth already initialized, returning existing instance',
59
+ { errorCode }
60
+ );
61
+ return this.getExistingAuth(app);
62
+ }
63
+
64
+ trackPackageError(errorObj, {
65
+ packageName: 'firebase-auth',
66
+ operation: 'initialize',
67
+ errorCode,
68
+ });
69
+
70
+ if (__DEV__) {
71
+ console.warn('Firebase Auth initialization error:', error);
72
+ }
73
+
74
+ return this.getExistingAuth(app);
75
+ }
76
+
77
+ private static getExistingAuth(app: FirebaseApp): Auth | null {
78
+ try {
79
+ return getAuth(app);
80
+ } catch (getAuthError) {
81
+ const errorObj = getAuthError instanceof Error
82
+ ? getAuthError
83
+ : new Error(String(getAuthError));
65
84
 
66
- const errorObj = error instanceof Error ? error : new Error(String(error));
67
85
  trackPackageError(errorObj, {
68
86
  packageName: 'firebase-auth',
69
- operation: 'initialize',
70
- errorCode: error.code,
87
+ operation: 'getAuth-fallback',
71
88
  });
72
89
 
73
90
  if (__DEV__) {
74
- console.warn('Firebase Auth initialization error:', error);
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;
91
+ console.warn('Firebase Auth: Failed to get auth instance:', getAuthError);
91
92
  }
93
+ return null;
92
94
  }
93
95
  }
94
96
 
@@ -97,25 +99,6 @@ export class FirebaseAuthInitializer {
97
99
  config?: FirebaseAuthConfig
98
100
  ): Auth | null {
99
101
  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
102
  const storage = config?.authStorage || {
120
103
  getItem: (key: string) => AsyncStorage.getItem(key),
121
104
  setItem: (key: string, value: string) => AsyncStorage.setItem(key, value),
@@ -137,12 +120,8 @@ export class FirebaseAuthInitializer {
137
120
  if (__DEV__) {
138
121
  console.warn('Firebase Auth: Persistence initialization failed:', error);
139
122
  }
140
- try {
141
- return getAuth(app);
142
- } catch {
143
- return null;
144
- }
123
+
124
+ return this.getExistingAuth(app);
145
125
  }
146
126
  }
147
127
  }
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';