@umituz/react-native-firebase 1.13.58 → 1.13.59
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/README.md +277 -0
- package/package.json +1 -1
- package/scripts/README.md +513 -0
- package/src/auth/README.md +339 -0
- package/src/auth/domain/README.md +264 -0
- package/src/auth/domain/errors/README.md +291 -0
- package/src/auth/infrastructure/config/README.md +239 -0
- package/src/auth/infrastructure/services/README.md +346 -0
- package/src/auth/infrastructure/stores/README.md +407 -0
- package/src/auth/presentation/hooks/README.md +442 -0
- package/src/domain/README.md +628 -0
- package/src/firestore/README.md +566 -0
- package/src/firestore/domain/README.md +325 -0
- package/src/firestore/domain/constants/README.md +332 -0
- package/src/firestore/domain/entities/README.md +286 -0
- package/src/firestore/domain/errors/README.md +389 -0
- package/src/firestore/infrastructure/config/README.md +239 -0
- package/src/firestore/infrastructure/middleware/README.md +316 -0
- package/src/firestore/infrastructure/repositories/README.md +425 -0
- package/src/firestore/infrastructure/services/README.md +332 -0
- package/src/firestore/types/pagination/README.md +332 -0
- package/src/firestore/utils/README.md +574 -0
- package/src/firestore/utils/dateUtils/README.md +171 -0
- package/src/firestore/utils/document-mapper.helper/README.md +309 -0
- package/src/firestore/utils/pagination.helper/README.md +298 -0
- package/src/firestore/utils/path-resolver/README.md +277 -0
- package/src/firestore/utils/query-builder/README.md +291 -0
- package/src/firestore/utils/quota-error-detector/README.md +355 -0
- package/src/infrastructure/README.md +408 -0
- package/src/infrastructure/config/README.md +262 -0
- package/src/presentation/README.md +556 -0
- package/src/storage/README.md +493 -0
- package/src/storage/deleter/README.md +370 -0
- package/src/storage/types/README.md +313 -0
- package/src/storage/uploader/README.md +409 -0
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
# Auth Services
|
|
2
|
+
|
|
3
|
+
Firebase Authentication service layer providing authentication operations, utilities, and guards.
|
|
4
|
+
|
|
5
|
+
## Purpose
|
|
6
|
+
|
|
7
|
+
Provides service layer for Firebase Authentication including anonymous auth, Google OAuth, Apple Auth, reauthentication, account deletion, auth guards, and auth-related Firestore utilities.
|
|
8
|
+
|
|
9
|
+
## For AI Agents
|
|
10
|
+
|
|
11
|
+
### Before Using Auth Services
|
|
12
|
+
|
|
13
|
+
1. **USE** services (never Firebase Auth SDK directly in UI)
|
|
14
|
+
2. **HANDLE** service results properly
|
|
15
|
+
3. **CHECK** success property before using data
|
|
16
|
+
4. **HANDLE** errors appropriately
|
|
17
|
+
5. **USE** auth guards for protected routes
|
|
18
|
+
|
|
19
|
+
### Required Practices
|
|
20
|
+
|
|
21
|
+
1. **Use services** - Import from auth infrastructure/services
|
|
22
|
+
2. **Check results** - Always check success property
|
|
23
|
+
3. **Handle errors** - Display user-friendly messages
|
|
24
|
+
4. **Use guards** - Protect routes with authGuardService
|
|
25
|
+
5. **Clean up** - Delete Firestore data on account deletion
|
|
26
|
+
|
|
27
|
+
### Forbidden Practices
|
|
28
|
+
|
|
29
|
+
## ❌ NEVER
|
|
30
|
+
|
|
31
|
+
- Use Firebase Auth SDK directly in UI components
|
|
32
|
+
- Ignore success property in results
|
|
33
|
+
- Skip error handling
|
|
34
|
+
- Mix service concerns
|
|
35
|
+
- Delete Auth without Firestore cleanup
|
|
36
|
+
|
|
37
|
+
## ⚠️ Avoid
|
|
38
|
+
|
|
39
|
+
- Not checking success before using user data
|
|
40
|
+
- Showing technical error messages
|
|
41
|
+
- Not using auth guards for protected routes
|
|
42
|
+
- Forgetting to delete Firestore data
|
|
43
|
+
- Hardcoding auth configuration
|
|
44
|
+
|
|
45
|
+
## Service Overview
|
|
46
|
+
|
|
47
|
+
### AnonymousAuthService
|
|
48
|
+
|
|
49
|
+
**Import From:** `@umituz/react-native-firebase/auth` or `src/auth/infrastructure/services`
|
|
50
|
+
|
|
51
|
+
**Purpose:** Handle anonymous (guest) user authentication
|
|
52
|
+
|
|
53
|
+
**Methods:**
|
|
54
|
+
- `signIn()` - Sign in as anonymous user
|
|
55
|
+
|
|
56
|
+
**Returns:** `Promise<AnonymousAuthResult>`
|
|
57
|
+
- `success: boolean` - Operation succeeded
|
|
58
|
+
- `user?: User` - Authenticated user
|
|
59
|
+
- `error?: Error` - Error if failed
|
|
60
|
+
|
|
61
|
+
**Usage Strategy:**
|
|
62
|
+
1. Call signIn() for guest access
|
|
63
|
+
2. Check success property
|
|
64
|
+
3. Access user data if successful
|
|
65
|
+
4. Handle errors appropriately
|
|
66
|
+
5. Prompt to upgrade to permanent account
|
|
67
|
+
|
|
68
|
+
**When to Use:**
|
|
69
|
+
- Quick app tryout without registration
|
|
70
|
+
- Temporary user sessions
|
|
71
|
+
- Testing without credentials
|
|
72
|
+
- Guest access with limited functionality
|
|
73
|
+
|
|
74
|
+
### GoogleAuthService
|
|
75
|
+
|
|
76
|
+
**Import From:** `@umituz/react-native-firebase/auth` or `src/auth/infrastructure/services`
|
|
77
|
+
|
|
78
|
+
**Purpose:** Handle Google OAuth authentication
|
|
79
|
+
|
|
80
|
+
**Methods:**
|
|
81
|
+
- `signIn(config)` - Sign in with Google
|
|
82
|
+
|
|
83
|
+
**Parameters:**
|
|
84
|
+
- `config: GoogleAuthConfig`
|
|
85
|
+
- `clientId: string` - Google OAuth Client ID
|
|
86
|
+
|
|
87
|
+
**Returns:** `Promise<GoogleAuthResult>`
|
|
88
|
+
- `success: boolean` - Operation succeeded
|
|
89
|
+
- `user?: User` - Authenticated user
|
|
90
|
+
- `idToken?: string` - Google ID token
|
|
91
|
+
- `error?: Error` - Error if failed
|
|
92
|
+
|
|
93
|
+
**Usage Strategy:**
|
|
94
|
+
1. Configure with Google Client ID
|
|
95
|
+
2. Call signIn() on user action
|
|
96
|
+
3. Check success property
|
|
97
|
+
4. Access user and idToken if successful
|
|
98
|
+
5. Handle errors gracefully
|
|
99
|
+
|
|
100
|
+
**When to Use:**
|
|
101
|
+
- Primary authentication method
|
|
102
|
+
- Google account sign-in
|
|
103
|
+
- Account linking
|
|
104
|
+
- Reauthentication
|
|
105
|
+
|
|
106
|
+
### AppleAuthService
|
|
107
|
+
|
|
108
|
+
**Import From:** `@umituz/react-native-firebase/auth` or `src/auth/infrastructure/services`
|
|
109
|
+
|
|
110
|
+
**Purpose:** Handle Apple ID authentication (iOS only)
|
|
111
|
+
|
|
112
|
+
**Methods:**
|
|
113
|
+
- `signIn()` - Sign in with Apple ID
|
|
114
|
+
|
|
115
|
+
**Returns:** `Promise<AppleAuthResult>`
|
|
116
|
+
- `success: boolean` - Operation succeeded
|
|
117
|
+
- `user?: User` - Authenticated user
|
|
118
|
+
- `authorizationCode?: string` - Apple authorization code
|
|
119
|
+
- `error?: Error` - Error if failed
|
|
120
|
+
|
|
121
|
+
**Usage Strategy:**
|
|
122
|
+
1. Call signIn() on user action (iOS only)
|
|
123
|
+
2. Automatically skipped on Android
|
|
124
|
+
3. Check success property
|
|
125
|
+
4. Access user data if successful
|
|
126
|
+
5. Handle errors appropriately
|
|
127
|
+
|
|
128
|
+
**When to Use:**
|
|
129
|
+
- iOS applications
|
|
130
|
+
- Alternative to Google sign-in
|
|
131
|
+
- Privacy-focused authentication
|
|
132
|
+
- Account linking
|
|
133
|
+
|
|
134
|
+
## Account Operations
|
|
135
|
+
|
|
136
|
+
### ReauthenticationService
|
|
137
|
+
|
|
138
|
+
**Import From:** `@umituz/react-native-firebase/auth` or `src/auth/infrastructure/services`
|
|
139
|
+
|
|
140
|
+
**Purpose:** Handle user reauthentication for sensitive operations
|
|
141
|
+
|
|
142
|
+
**Methods:**
|
|
143
|
+
- `reauthenticate(user)` - Reauthenticate current user
|
|
144
|
+
|
|
145
|
+
**When to Use:**
|
|
146
|
+
- Before account deletion
|
|
147
|
+
- Before password change
|
|
148
|
+
- Before sensitive operations
|
|
149
|
+
- Email verification
|
|
150
|
+
|
|
151
|
+
**Strategy:**
|
|
152
|
+
1. Verify user identity
|
|
153
|
+
2. Call reauthenticate method
|
|
154
|
+
3. Handle reauthentication
|
|
155
|
+
4. Proceed with sensitive operation
|
|
156
|
+
5. Handle errors appropriately
|
|
157
|
+
|
|
158
|
+
### Account Deletion Service
|
|
159
|
+
|
|
160
|
+
**Import From:** `@umituz/react-native-firebase/auth` or `src/auth/infrastructure/services`
|
|
161
|
+
|
|
162
|
+
**Purpose:** Handle complete account deletion including Auth and Firestore data
|
|
163
|
+
|
|
164
|
+
**Methods:**
|
|
165
|
+
- `deleteCurrentUser()` - Delete current user account
|
|
166
|
+
|
|
167
|
+
**Cleanup Process:**
|
|
168
|
+
1. Delete Firebase Auth account
|
|
169
|
+
2. Automatically delete Firestore user data
|
|
170
|
+
3. Clean up Storage files (manual if needed)
|
|
171
|
+
4. Sign out user
|
|
172
|
+
5. Navigate to login screen
|
|
173
|
+
|
|
174
|
+
**When to Use:**
|
|
175
|
+
- User requests account deletion
|
|
176
|
+
- GDPR compliance
|
|
177
|
+
- User data cleanup
|
|
178
|
+
- Account testing
|
|
179
|
+
|
|
180
|
+
**Strategy:**
|
|
181
|
+
1. Confirm deletion with user
|
|
182
|
+
2. Call deleteCurrentUser()
|
|
183
|
+
3. Auth deletion automatic
|
|
184
|
+
4. Firestore cleanup automatic
|
|
185
|
+
5. Manual Storage cleanup if needed
|
|
186
|
+
|
|
187
|
+
## Route Protection
|
|
188
|
+
|
|
189
|
+
### AuthGuardService
|
|
190
|
+
|
|
191
|
+
**Import From:** `@umituz/react-native-firebase/auth` or `src/auth/infrastructure/services`
|
|
192
|
+
|
|
193
|
+
**Purpose:** Protect routes that require authentication
|
|
194
|
+
|
|
195
|
+
**Methods:**
|
|
196
|
+
- `canActivate()` - Check if route can be activated
|
|
197
|
+
- `canActivateAnonymous()` - Check if anonymous users allowed
|
|
198
|
+
|
|
199
|
+
**Returns:** `boolean` - Whether route can be accessed
|
|
200
|
+
|
|
201
|
+
**Usage Strategy:**
|
|
202
|
+
1. Use in protected route components
|
|
203
|
+
2. Check canActivate() before rendering
|
|
204
|
+
3. Redirect to login if not authenticated
|
|
205
|
+
4. Handle anonymous users appropriately
|
|
206
|
+
5. Show loading state during check
|
|
207
|
+
|
|
208
|
+
**When to Use:**
|
|
209
|
+
- Pages requiring authentication
|
|
210
|
+
- User profile pages
|
|
211
|
+
- Dashboard and settings
|
|
212
|
+
- Protected features
|
|
213
|
+
|
|
214
|
+
## Firestore Utilities
|
|
215
|
+
|
|
216
|
+
### AuthFirestoreUtils
|
|
217
|
+
|
|
218
|
+
**Import From:** `@umituz/react-native-firebase/auth` or `src/auth/infrastructure/services`
|
|
219
|
+
|
|
220
|
+
**Purpose:** Helper functions for auth-related Firestore operations
|
|
221
|
+
|
|
222
|
+
**Utilities:**
|
|
223
|
+
- User document path resolution
|
|
224
|
+
- User data creation/update
|
|
225
|
+
- User data cleanup on deletion
|
|
226
|
+
- Auth state synchronization
|
|
227
|
+
|
|
228
|
+
**When to Use:**
|
|
229
|
+
- Creating user documents in Firestore
|
|
230
|
+
- Updating user profile data
|
|
231
|
+
- Cleaning up user data
|
|
232
|
+
- Syncing auth state with database
|
|
233
|
+
|
|
234
|
+
## Service Result Types
|
|
235
|
+
|
|
236
|
+
### AuthResult Pattern
|
|
237
|
+
|
|
238
|
+
**Import From:** All auth services return similar result types
|
|
239
|
+
|
|
240
|
+
**Common Properties:**
|
|
241
|
+
- `success: boolean` - Operation succeeded
|
|
242
|
+
- `user?: User` - Authenticated user (when applicable)
|
|
243
|
+
- `error?: Error` - Error if operation failed
|
|
244
|
+
|
|
245
|
+
**Usage:**
|
|
246
|
+
1. Call service method
|
|
247
|
+
2. Check result.success
|
|
248
|
+
3. Use result.user if success
|
|
249
|
+
4. Handle result.error if failed
|
|
250
|
+
5. Never assume success
|
|
251
|
+
|
|
252
|
+
## Common Mistakes to Avoid
|
|
253
|
+
|
|
254
|
+
1. ❌ Not checking success property
|
|
255
|
+
- ✅ Always check result.success first
|
|
256
|
+
|
|
257
|
+
2. ❌ Using Firebase Auth SDK directly
|
|
258
|
+
- ✅ Use auth services
|
|
259
|
+
|
|
260
|
+
3. ❌ Not handling errors
|
|
261
|
+
- ✅ Check result.error and display message
|
|
262
|
+
|
|
263
|
+
4. ❌ Deleting Auth without Firestore cleanup
|
|
264
|
+
- ✅ Use deleteCurrentUser() for complete cleanup
|
|
265
|
+
|
|
266
|
+
5. ❌ Not protecting routes
|
|
267
|
+
- ✅ Use authGuardService
|
|
268
|
+
|
|
269
|
+
## AI Agent Instructions
|
|
270
|
+
|
|
271
|
+
### When Using Auth Services
|
|
272
|
+
|
|
273
|
+
1. Import service from auth infrastructure/services
|
|
274
|
+
2. Call service method with appropriate parameters
|
|
275
|
+
3. Check result.success property
|
|
276
|
+
4. Use result.user data if successful
|
|
277
|
+
5. Handle result.error appropriately
|
|
278
|
+
|
|
279
|
+
### When Protecting Route
|
|
280
|
+
|
|
281
|
+
1. Use authGuardService.canActivate()
|
|
282
|
+
2. Check result before showing protected content
|
|
283
|
+
3. Redirect to login if not authenticated
|
|
284
|
+
4. Handle anonymous users appropriately
|
|
285
|
+
5. Show loading state during check
|
|
286
|
+
|
|
287
|
+
### When Deleting Account
|
|
288
|
+
|
|
289
|
+
1. Confirm deletion with user
|
|
290
|
+
2. Call deleteCurrentUser() service
|
|
291
|
+
3. Firestore cleanup automatic
|
|
292
|
+
4. Clean up Storage files if needed
|
|
293
|
+
5. Sign out and navigate to login
|
|
294
|
+
|
|
295
|
+
## Code Quality Standards
|
|
296
|
+
|
|
297
|
+
### TypeScript
|
|
298
|
+
|
|
299
|
+
- Type all service methods
|
|
300
|
+
- Use proper result types
|
|
301
|
+
- Handle errors with types
|
|
302
|
+
- Export service instances
|
|
303
|
+
- Document service behavior
|
|
304
|
+
|
|
305
|
+
### Error Handling
|
|
306
|
+
|
|
307
|
+
- Always return success property
|
|
308
|
+
- Include error details
|
|
309
|
+
- Provide context in errors
|
|
310
|
+
- Handle edge cases
|
|
311
|
+
- Test error flows
|
|
312
|
+
|
|
313
|
+
## Related Documentation
|
|
314
|
+
|
|
315
|
+
- [Auth Module README](../../README.md)
|
|
316
|
+
- [Auth Stores README](../stores/README.md)
|
|
317
|
+
- [Auth Hooks README](../../presentation/hooks/README.md)
|
|
318
|
+
- [Auth Errors README](../../domain/errors/README.md)
|
|
319
|
+
|
|
320
|
+
## API Reference
|
|
321
|
+
|
|
322
|
+
### Main Services
|
|
323
|
+
|
|
324
|
+
**Import Path:** `@umituz/react-native-firebase/auth` or `src/auth/infrastructure/services`
|
|
325
|
+
|
|
326
|
+
| Service | Purpose | Methods |
|
|
327
|
+
|---------|---------|---------|
|
|
328
|
+
| `anonymousAuthService` | Anonymous authentication | `signIn()` |
|
|
329
|
+
| `googleAuthService` | Google OAuth | `signIn(config)` |
|
|
330
|
+
| `appleAuthService` | Apple ID authentication | `signIn()` |
|
|
331
|
+
| `authGuardService` | Route protection | `canActivate()`, `canActivateAnonymous()` |
|
|
332
|
+
| `reauthenticationService` | User reauthentication | `reauthenticate(user)` |
|
|
333
|
+
| `accountDeletionService` | Account deletion | `deleteCurrentUser()` |
|
|
334
|
+
|
|
335
|
+
### Result Types
|
|
336
|
+
|
|
337
|
+
| Type | Properties |
|
|
338
|
+
|------|------------|
|
|
339
|
+
| `AnonymousAuthResult` | success, user?, error? |
|
|
340
|
+
| `GoogleAuthResult` | success, user?, idToken?, error? |
|
|
341
|
+
| `AppleAuthResult` | success, user?, authorizationCode?, error? |
|
|
342
|
+
|
|
343
|
+
---
|
|
344
|
+
|
|
345
|
+
**Last Updated:** 2025-01-08
|
|
346
|
+
**Maintainer:** Auth Module Team
|