@umituz/react-native-firebase 1.13.58 → 1.13.60

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.
Files changed (43) hide show
  1. package/README.md +277 -0
  2. package/package.json +10 -5
  3. package/scripts/README.md +513 -0
  4. package/src/auth/README.md +339 -0
  5. package/src/auth/domain/README.md +264 -0
  6. package/src/auth/domain/errors/README.md +291 -0
  7. package/src/auth/infrastructure/config/README.md +239 -0
  8. package/src/auth/infrastructure/config/initializers/FirebaseAuthInitializer.ts +1 -1
  9. package/src/auth/infrastructure/services/README.md +346 -0
  10. package/src/auth/infrastructure/stores/README.md +407 -0
  11. package/src/auth/infrastructure/stores/auth.store.ts +1 -1
  12. package/src/auth/presentation/hooks/README.md +442 -0
  13. package/src/auth/presentation/hooks/useAnonymousAuth.ts +4 -4
  14. package/src/auth/presentation/hooks/utils/auth-state-change.handler.ts +1 -1
  15. package/src/domain/README.md +628 -0
  16. package/src/firestore/README.md +566 -0
  17. package/src/firestore/domain/README.md +325 -0
  18. package/src/firestore/domain/constants/README.md +332 -0
  19. package/src/firestore/domain/entities/README.md +286 -0
  20. package/src/firestore/domain/errors/README.md +389 -0
  21. package/src/firestore/infrastructure/config/FirestoreClient.ts +1 -1
  22. package/src/firestore/infrastructure/config/README.md +239 -0
  23. package/src/firestore/infrastructure/middleware/README.md +316 -0
  24. package/src/firestore/infrastructure/repositories/BaseRepository.ts +1 -1
  25. package/src/firestore/infrastructure/repositories/README.md +425 -0
  26. package/src/firestore/infrastructure/services/README.md +332 -0
  27. package/src/firestore/infrastructure/services/RequestLoggerService.ts +4 -4
  28. package/src/firestore/types/pagination/README.md +332 -0
  29. package/src/firestore/utils/README.md +574 -0
  30. package/src/firestore/utils/dateUtils/README.md +171 -0
  31. package/src/firestore/utils/document-mapper.helper/README.md +309 -0
  32. package/src/firestore/utils/pagination.helper/README.md +298 -0
  33. package/src/firestore/utils/path-resolver/README.md +277 -0
  34. package/src/firestore/utils/query-builder/README.md +291 -0
  35. package/src/firestore/utils/quota-error-detector/README.md +355 -0
  36. package/src/infrastructure/README.md +408 -0
  37. package/src/infrastructure/config/FirebaseClient.ts +1 -1
  38. package/src/infrastructure/config/README.md +262 -0
  39. package/src/presentation/README.md +556 -0
  40. package/src/storage/README.md +493 -0
  41. package/src/storage/deleter/README.md +370 -0
  42. package/src/storage/types/README.md +313 -0
  43. package/src/storage/uploader/README.md +409 -0
@@ -0,0 +1,291 @@
1
+ # Auth Errors
2
+
3
+ Firebase Authentication error types and error handling utilities.
4
+
5
+ ## Purpose
6
+
7
+ Provides custom error classes for Firebase Authentication operations with structured error handling, type safety, and user-friendly error messages.
8
+
9
+ ## For AI Agents
10
+
11
+ ### Before Using Auth Errors
12
+
13
+ 1. **USE** custom error classes (not raw Firebase errors)
14
+ 2. **CHECK** error types with instanceof
15
+ 3. **PROVIDE** user-friendly error messages
16
+ 4. **HANDLE** retryable errors appropriately
17
+ 5. **LOG** errors for debugging
18
+
19
+ ### Required Practices
20
+
21
+ 1. **Use custom error classes** - Import from auth module
22
+ 2. **Check error types** - Use instanceof for type checking
23
+ 3. **Map error codes** - Convert to user-friendly messages
24
+ 4. **Handle retryable errors** - Implement retry logic
25
+ 5. **Log errors** - Include context for debugging
26
+
27
+ ### Forbidden Practices
28
+
29
+ ## ❌ NEVER
30
+
31
+ - Throw primitive values (always Error instances)
32
+ - Show technical error messages to users
33
+ - Ignore error codes
34
+ - Assume all errors are fatal
35
+ - Catch and suppress errors silently
36
+
37
+ ## ⚠️ Avoid
38
+
39
+ - Generic error handling
40
+ - Not checking error types
41
+ - Not providing user feedback
42
+ - Missing error context
43
+ - Not logging auth errors
44
+
45
+ ## Error Classes
46
+
47
+ ### FirebaseAuthError
48
+
49
+ **Import From:** `@umituz/react-native-firebase/auth` or `src/auth/domain/errors`
50
+
51
+ **Purpose:** Base error class for all Firebase Auth errors
52
+
53
+ **Properties:**
54
+ - `code: string` - Error code for programmatic handling
55
+ - `message: string` - Human-readable error message
56
+
57
+ **Usage:**
58
+ - Base class for all auth errors
59
+ - Type checking with instanceof
60
+ - Error code for conditional logic
61
+
62
+ **When to Use:**
63
+ - Throwing custom auth errors
64
+ - Catching and handling auth errors
65
+ - Type-safe error handling
66
+
67
+ ### FirebaseAuthInitializationError
68
+
69
+ **Import From:** `@umituz/react-native-firebase/auth` or `src/auth/domain/errors`
70
+
71
+ **Purpose:** Error thrown when Firebase Auth fails to initialize
72
+
73
+ **Extends:** FirebaseAuthError
74
+
75
+ **Usage:**
76
+ - Initialization failures
77
+ - Configuration errors
78
+ - Firebase setup issues
79
+
80
+ **When to Use:**
81
+ - Auth not initialized
82
+ - Invalid Firebase config
83
+ - Initialization timeout
84
+
85
+ ## Error Handling Strategies
86
+
87
+ ### For Auth Operation Errors
88
+
89
+ **Strategy:** Catch and handle auth errors with user-friendly messages.
90
+
91
+ **Import From:** `@umituz/react-native-firebase/auth` or `src/auth/domain/errors`
92
+
93
+ **When to Use:**
94
+ - Sign-in failures
95
+ - Sign-up failures
96
+ - Password reset failures
97
+ - Email verification failures
98
+
99
+ **Handling Strategy:**
100
+ 1. Wrap auth operation in try-catch
101
+ 2. Check error type with instanceof
102
+ 3. Map error code to user message
103
+ 4. Display error to user
104
+ 5. Provide retry option if appropriate
105
+ 6. Log technical error for debugging
106
+
107
+ ### For Initialization Errors
108
+
109
+ **Strategy:** Handle Firebase Auth initialization failures.
110
+
111
+ **Import From:** `@umituz/react-native-firebase/auth` or `src/auth/domain/errors`
112
+
113
+ **When to Use:**
114
+ - App startup
115
+ - Auth service initialization
116
+ - Configuration loading
117
+
118
+ **Handling Strategy:**
119
+ 1. Catch initialization error
120
+ 2. Check if FirebaseAuthInitializationError
121
+ 3. Show setup error message
122
+ 4. Provide setup instructions
123
+ 5. Offer retry option
124
+
125
+ ### For Network Errors
126
+
127
+ **Strategy:** Retry transient network failures.
128
+
129
+ **Import From:** `@umituz/react-native-firebase/auth` or `src/auth/domain/errors`
130
+
131
+ **When to Use:**
132
+ - Network connection failed
133
+ - Request timeout
134
+ - Service unavailable
135
+
136
+ **Handling Strategy:**
137
+ 1. Check error code for network issues
138
+ 2. Show network error message
139
+ 3. Provide retry button
140
+ 4. Implement retry with delay
141
+ 5. Limit retry attempts
142
+
143
+ ### For User-Facing Messages
144
+
145
+ **Strategy:** Map error codes to user-friendly messages.
146
+
147
+ **Import From:** Use error.code to map messages
148
+
149
+ **Common Error Messages:**
150
+ - `INVALID_CREDENTIALS` → "Invalid email or password"
151
+ - `USER_NOT_FOUND` → "Account not found"
152
+ - `WEAK_PASSWORD` → "Password is too weak"
153
+ - `EMAIL_ALREADY_IN_USE` → "Email already registered"
154
+ - `NETWORK_ERROR` → "Network error. Please check your connection"
155
+ - `TOO_MANY_REQUESTS` → "Too many attempts. Please try again later"
156
+
157
+ **Implementation:**
158
+ 1. Create error message mapper
159
+ 2. Map error codes to messages
160
+ 3. Display message to user
161
+ 4. Provide action buttons
162
+ 5. Handle retry scenarios
163
+
164
+ ## Error Codes Reference
165
+
166
+ ### Common Error Codes
167
+
168
+ **Import From:** Error.code property
169
+
170
+ | Error Code | Description | Retryable | User Message |
171
+ |------------|-------------|-----------|--------------|
172
+ | `INVALID_CREDENTIALS` | Invalid email or password | No | Invalid email or password |
173
+ | `USER_NOT_FOUND` | User account not found | No | Account not found |
174
+ | `WEAK_PASSWORD` | Password too weak | No | Password is too weak |
175
+ | `EMAIL_ALREADY_IN_USE` | Email already registered | No | Email already registered |
176
+ | `NETWORK_ERROR` | Network connection failed | Yes | Network error. Check connection |
177
+ | `TIMEOUT` | Request timeout | Yes | Request timeout. Try again |
178
+ | `TOO_MANY_REQUESTS` | Rate limit exceeded | Yes | Too many attempts. Wait |
179
+ | `USER_DISABLED` | User account disabled | No | Account disabled |
180
+ | `INVALID_EMAIL` | Invalid email format | No | Invalid email format |
181
+ | `EMAIL_NOT_VERIFIED` | Email not verified | No | Please verify your email |
182
+
183
+ ## Common Mistakes to Avoid
184
+
185
+ 1. ❌ Not checking error types
186
+ - ✅ Use instanceof for type checking
187
+
188
+ 2. ❌ Showing technical messages to users
189
+ - ✅ Map error codes to user-friendly messages
190
+
191
+ 3. ❌ Not providing retry options
192
+ - ✅ Offer retry for retryable errors
193
+
194
+ 4. ❌ Not logging errors
195
+ - ✅ Log errors with context
196
+
197
+ 5. ❌ Generic error handling
198
+ - ✅ Handle specific error types
199
+
200
+ ## AI Agent Instructions
201
+
202
+ ### When Handling Auth Errors
203
+
204
+ 1. Wrap auth operations in try-catch
205
+ 2. Check error type with instanceof
206
+ 3. Map error code to user message
207
+ 4. Display user-friendly message
208
+ 5. Provide retry option if appropriate
209
+ 6. Log technical error for debugging
210
+
211
+ ### When Creating Error Messages
212
+
213
+ 1. Map error codes to messages
214
+ 2. Use clear, non-technical language
215
+ 3. Provide actionable next steps
216
+ 4. Keep messages concise
217
+ 5. Localize if needed
218
+
219
+ ### When Implementing Retry Logic
220
+
221
+ 1. Check if error is retryable
222
+ 2. Show retry button to user
223
+ 3. Implement retry with delay
224
+ 4. Limit retry attempts
225
+ 5. Show countdown if rate limited
226
+
227
+ ## Code Quality Standards
228
+
229
+ ### Error Handling
230
+
231
+ - Always use custom error classes
232
+ - Check error types before handling
233
+ - Provide user-friendly messages
234
+ - Log errors with context
235
+ - Handle specific error types
236
+
237
+ ### Type Safety
238
+
239
+ - Use instanceof for type checking
240
+ - Never use `any` for errors
241
+ - Type all error parameters
242
+ - Export error classes
243
+ - Use discriminated unions
244
+
245
+ ### User Experience
246
+
247
+ - Show clear error messages
248
+ - Provide actionable next steps
249
+ - Offer retry when appropriate
250
+ - Don't show technical details
251
+ - Test error flows
252
+
253
+ ## Performance Considerations
254
+
255
+ ### Error Logging
256
+
257
+ - Log errors asynchronously
258
+ - Don't block on logging
259
+ - Include context (operation, userId)
260
+ - Sanitize sensitive data
261
+ - Use error tracking service
262
+
263
+ ### Retry Logic
264
+
265
+ - Limit retry attempts
266
+ - Use exponential backoff
267
+ - Show retry progress
268
+ - Don't retry non-retryable errors
269
+ - Consider rate limiting
270
+
271
+ ## Related Documentation
272
+
273
+ - [Auth Module README](../../README.md)
274
+ - [Auth Services README](../infrastructure/services/README.md)
275
+ - [Auth Stores README](../infrastructure/stores/README.md)
276
+
277
+ ## API Reference
278
+
279
+ ### Error Classes
280
+
281
+ **Import Path:** `@umituz/react-native-firebase/auth` or `src/auth/domain/errors`
282
+
283
+ | Class | Constructor Parameters | Description |
284
+ |-------|----------------------|-------------|
285
+ | `FirebaseAuthError` | `(message: string, code: string)` | Base auth error |
286
+ | `FirebaseAuthInitializationError` | `(message: string)` | Init error |
287
+
288
+ ---
289
+
290
+ **Last Updated:** 2025-01-08
291
+ **Maintainer:** Auth Module Team
@@ -0,0 +1,239 @@
1
+ # Auth Configuration
2
+
3
+ Firebase Authentication client initialization, configuration management, and service access.
4
+
5
+ ## Purpose
6
+
7
+ Provides core Firebase Auth client functionality including initialization, state management, service access, error handling, and client reset.
8
+
9
+ ## For AI Agents
10
+
11
+ ### Before Using Auth Config
12
+
13
+ 1. **INITIALIZE** Auth once at app startup
14
+ 2. **CHECK** initialization status before use
15
+ 3. **USE** getFirebaseAuth() to get Auth instance
16
+ 4. **HANDLE** initialization errors appropriately
17
+ 5. **NEVER** initialize Auth multiple times
18
+
19
+ ### Required Practices
20
+
21
+ 1. **Initialize once** - Call initializeFirebaseAuth() at app startup
22
+ 2. **Check status** - Verify initialization before using Auth
23
+ 3. **Get Auth instance** - Use getFirebaseAuth() after initialization
24
+ 4. **Handle errors** - Check for initialization errors
25
+ 5. **Use services** - Use auth services instead of direct Auth SDK
26
+
27
+ ### Forbidden Practices
28
+
29
+ ## ❌ NEVER
30
+
31
+ - Initialize Firebase Auth multiple times
32
+ - Use Auth SDK before initialization
33
+ - Use getAuth() from firebase/auth directly
34
+ - Ignore initialization errors
35
+ - Skip initialization status check
36
+
37
+ ## ⚠️ Avoid
38
+
39
+ - Initializing Auth in components
40
+ - Not checking initialization status
41
+ - Direct Firebase Auth SDK usage
42
+ - Initializing without Firebase app
43
+ - Not handling initialization failures
44
+
45
+ ## Initialization Strategy
46
+
47
+ ### Basic Initialization
48
+
49
+ **Import From:** `@umituz/react-native-firebase/auth` or `src/auth/infrastructure/config`
50
+
51
+ **Function:** `initializeFirebaseAuth()`
52
+
53
+ **Returns:** `Promise<void>`
54
+
55
+ **When to Use:**
56
+ - App startup (after Firebase initialized)
57
+ - Before any auth operations
58
+ - Root component initialization
59
+
60
+ **Initialization Flow:**
61
+ 1. Verify Firebase app initialized
62
+ 2. Get Firebase app instance
63
+ 3. Initialize Auth with app
64
+ 4. Set initialization state
65
+ 5. Handle errors appropriately
66
+
67
+ ### Check Initialization Status
68
+
69
+ **Import From:** `@umituz/react-native-firebase/auth` or `src/auth/infrastructure/config`
70
+
71
+ **Functions:**
72
+ - `isFirebaseAuthInitialized()` - Check if Auth initialized
73
+ - `isFirebaseAuthInitializing()` - Check if initializing
74
+ - `getFirebaseAuthInitializationError()` - Get error if failed
75
+
76
+ **Returns:**
77
+ - `boolean` for status checks
78
+ - `Error | null` for error check
79
+
80
+ **When to Use:**
81
+ - Before auth operations
82
+ - Before using auth services
83
+ - Error recovery
84
+ - Status display
85
+
86
+ **Usage Strategy:**
87
+ 1. Check isFirebaseAuthInitialized()
88
+ 2. If false, show loading or initialize
89
+ 3. If error, show error message
90
+ 4. Proceed with auth operations
91
+
92
+ ## Service Access
93
+
94
+ ### Get Auth Instance
95
+
96
+ **Import From:** `@umituz/react-native-firebase/auth` or `src/auth/infrastructure/config`
97
+
98
+ **Function:** `getFirebaseAuth()`
99
+
100
+ **Returns:** `Auth` instance from Firebase Auth SDK
101
+
102
+ **Usage Strategy:**
103
+ 1. Check initialization status first
104
+ 2. Call getFirebaseAuth()
105
+ 3. Use Auth instance for operations
106
+ 4. Handle errors appropriately
107
+
108
+ **When to Use:**
109
+ - Custom auth operations
110
+ - Direct Auth SDK usage (rare)
111
+ - Advanced auth features
112
+ - Auth service implementations
113
+
114
+ **Important:** Prefer using auth services over direct Auth SDK usage
115
+
116
+ ### Reset Client
117
+
118
+ **Import From:** `@umituz/react-native-firebase/auth` or `src/auth/infrastructure/config`
119
+
120
+ **Function:** `resetFirebaseAuthClient()`
121
+
122
+ **Purpose:** Reset Auth client state (useful for testing)
123
+
124
+ **When to Use:**
125
+ - Testing scenarios
126
+ - Error recovery
127
+ - Reinitialization
128
+ - Development
129
+
130
+ **Usage Strategy:**
131
+ 1. Call resetFirebaseAuthClient()
132
+ 2. Reinitialize if needed
133
+ 3. Use only in development/testing
134
+ 4. Never use in production
135
+
136
+ ## Common Mistakes to Avoid
137
+
138
+ 1. ❌ Initializing Auth multiple times
139
+ - ✅ Initialize once at app startup
140
+
141
+ 2. ❌ Not checking initialization status
142
+ - ✅ Always check isFirebaseAuthInitialized()
143
+
144
+ 3. ❌ Using getAuth() from firebase/auth
145
+ - ✅ Use getFirebaseAuth() from auth config
146
+
147
+ 4. ❌ Initializing before Firebase app
148
+ - ✅ Initialize Firebase first, then Auth
149
+
150
+ 5. ❌ Ignoring initialization errors
151
+ - ✅ Handle and display errors
152
+
153
+ ## AI Agent Instructions
154
+
155
+ ### When Initializing Auth
156
+
157
+ 1. Initialize Firebase first
158
+ 2. Call initializeFirebaseAuth()
159
+ 3. Await initialization completion
160
+ 4. Check for errors
161
+ 5. Show error message if failed
162
+
163
+ ### When Using Auth Services
164
+
165
+ 1. Check Auth initialization status
166
+ 2. If not initialized, initialize first
167
+ 3. Use auth services (not direct SDK)
168
+ 4. Handle errors appropriately
169
+ 5. Show user feedback
170
+
171
+ ### When Getting Auth Instance
172
+
173
+ 1. Check isFirebaseAuthInitialized()
174
+ 2. Call getFirebaseAuth()
175
+ 3. Use Auth instance
176
+ 4. Handle uninitialized state
177
+ 5. Prefer auth services over direct usage
178
+
179
+ ## Code Quality Standards
180
+
181
+ ### Initialization
182
+
183
+ - Initialize once at startup
184
+ - Check status before use
185
+ - Handle errors gracefully
186
+ - Show loading states
187
+ - Provide error feedback
188
+
189
+ ### Error Handling
190
+
191
+ - Catch initialization errors
192
+ - Store error in state
193
+ - Provide error context
194
+ - Allow retry/recovery
195
+ - Log for debugging
196
+
197
+ ## Performance Considerations
198
+
199
+ ### Initialization Overhead
200
+
201
+ - One-time cost at app startup
202
+ - Async initialization (non-blocking)
203
+ - ~50-200ms typical
204
+ - Initialize once, reuse Auth instance
205
+ - Don't reinitialize unnecessarily
206
+
207
+ ### State Checking
208
+
209
+ - Fast boolean checks
210
+ - No performance overhead
211
+ - Safe to call frequently
212
+ - Use before auth operations
213
+ - Prevents errors
214
+
215
+ ## Related Documentation
216
+
217
+ - [Auth Module README](../../README.md)
218
+ - [Auth Services README](../services/README.md)
219
+ - [Firebase Infrastructure Config README](../../../infrastructure/config/README.md)
220
+
221
+ ## API Reference
222
+
223
+ ### Main Functions
224
+
225
+ **Import Path:** `@umituz/react-native-firebase/auth` or `src/auth/infrastructure/config`
226
+
227
+ | Function | Returns | Description |
228
+ |----------|---------|-------------|
229
+ | `initializeFirebaseAuth` | `Promise<void>` | Initialize Firebase Auth |
230
+ | `getFirebaseAuth` | `Auth` | Get Auth instance |
231
+ | `isFirebaseAuthInitialized` | `boolean` | Check if initialized |
232
+ | `isFirebaseAuthInitializing` | `boolean` | Check if initializing |
233
+ | `getFirebaseAuthInitializationError` | `Error \| null` | Get initialization error |
234
+ | `resetFirebaseAuthClient` | `void` | Reset client state (testing) |
235
+
236
+ ---
237
+
238
+ **Last Updated:** 2025-01-08
239
+ **Maintainer:** Auth Module Team
@@ -8,7 +8,7 @@
8
8
  import {
9
9
  initializeAuth,
10
10
  getAuth,
11
- // @ts-ignore: getReactNativePersistence exists in the React Native bundle but missing from type definitions
11
+ // @ts-expect-error: getReactNativePersistence exists in the React Native bundle but missing from type definitions
12
12
  // See: https://github.com/firebase/firebase-js-sdk/issues/9316
13
13
  getReactNativePersistence,
14
14
  } from 'firebase/auth';