@umituz/react-native-auth 3.4.33 → 3.4.34

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.
@@ -1,417 +1,491 @@
1
- # Auth Services
1
+ # Infrastructure Services
2
2
 
3
- React Native Auth paketi için core servisler ve authentication işlevselliği.
3
+ Core authentication services and infrastructure implementations.
4
4
 
5
- ## Servisler
5
+ ---
6
+
7
+ ## Strategy
8
+
9
+ **Purpose**: Provides concrete implementations for authentication operations, user document management, event handling, and validation.
6
10
 
7
- - **[`AuthService`](./AuthService.ts)** - Ana authentication servisi
8
- - **[`initializeAuth`](./initializeAuth.ts)** - Auth başlatma servisi
9
- - **[`UserDocumentService`](./UserDocumentService.ts)** - Kullanıcı dokümanı servisi
10
- - **[`AnonymousModeService`](./AnonymousModeService.ts)** - Anonymous mod servisi
11
- - **[`AuthEventService`](./AuthEventService.ts)** - Auth event servisi
11
+ **When to Use**:
12
+ - Understanding service architecture
13
+ - Implementing custom services
14
+ - Debugging service issues
15
+ - Learning about Firebase integration
16
+
17
+ **Location**: `src/infrastructure/services/`
12
18
 
13
19
  ---
14
20
 
15
- ## AuthService
21
+ ## Available Services
16
22
 
17
- Ana authentication servisi. Firebase Authentication ile tüm auth işlemlerini yönetir.
23
+ ### AuthService
18
24
 
19
- ### Kullanım
25
+ **PURPOSE**: Main authentication service orchestrating all auth operations
20
26
 
27
+ **IMPORT PATH**:
21
28
  ```typescript
22
29
  import {
23
30
  AuthService,
24
31
  initializeAuthService,
25
- getAuthService
32
+ getAuthService,
33
+ resetAuthService
26
34
  } from '@umituz/react-native-auth';
35
+ ```
27
36
 
28
- // Service başlatma
29
- initializeAuthService({
30
- firebaseAuth: getAuth(),
31
- });
37
+ **File**: `AuthService.ts`
38
+
39
+ **METHODS**:
40
+ - `signIn(params)` - Sign in with email/password
41
+ - `signUp(params)` - Create new account
42
+ - `signOut()` - Sign out current user
43
+ - `getCurrentUser()` - Get current user
44
+ - `sendPasswordResetEmail(email)` - Reset password
45
+
46
+ **FUNCTIONS**:
47
+ - `initializeAuthService(config)` - Initialize service
48
+ - `getAuthService()` - Get service instance
49
+ - `resetAuthService()` - Reset service (testing only)
50
+
51
+ **Rules**:
52
+ - MUST initialize before use
53
+ - MUST implement IAuthService interface
54
+ - MUST handle Firebase errors
55
+ - MUST create user documents on registration
56
+ - MUST not create multiple instances
57
+
58
+ **MUST NOT**:
59
+ - Skip initialization
60
+ - Use before initialization
61
+ - Expose Firebase types
62
+ - Create multiple service instances
63
+ - Skip error handling
32
64
 
33
- // Service alma
34
- const authService = getAuthService();
65
+ ---
35
66
 
36
- // Giriş yapma
37
- await authService.signIn({ email, password });
67
+ ### initializeAuth
38
68
 
39
- // Kayıt olma
40
- await authService.signUp({ email, password, displayName });
69
+ **PURPOSE**: Initialize authentication system and Firebase Auth state listener
41
70
 
42
- // Çıkış yapma
43
- await authService.signOut();
71
+ **IMPORT PATH**:
72
+ ```typescript
73
+ import {
74
+ initializeAuth,
75
+ isAuthInitialized,
76
+ resetAuthInitialization
77
+ } from '@umituz/react-native-auth';
44
78
  ```
45
79
 
46
- ### API
47
-
48
- #### Methods
49
-
50
- | Method | Parametreler | Açıklama |
51
- |--------|--------------|----------|
52
- | `signIn` | `{ email, password }` | Email/password ile giriş |
53
- | `signUp` | `{ email, password, displayName? }` | Yeni kullanıcı kaydı |
54
- | `signOut` | - | Çıkış yapma |
55
- | `sendPasswordResetEmail` | `email` | Şifre sıfırlama email'i gönderme |
80
+ **File**: `initializeAuth.ts`
56
81
 
57
- ### Örnekler
82
+ **PARAMETERS**:
83
+ - `onAuthStateChanged` - Auth state callback (optional)
84
+ - `onAuthError` - Error callback (optional)
58
85
 
59
- #### Service Başlatma
86
+ **FUNCTIONS**:
87
+ - `initializeAuth(options)` - Initialize auth system
88
+ - `isAuthInitialized()` - Check initialization status
89
+ - `resetAuthInitialization()` - Reset (testing only)
60
90
 
61
- ```typescript
62
- import { initializeAuthService } from '@umituz/react-native-auth';
63
- import { getAuth } from 'firebase/auth';
64
-
65
- function App() {
66
- useEffect(() => {
67
- const firebaseAuth = getAuth();
68
-
69
- initializeAuthService({
70
- firebaseAuth,
71
- onAuthStateChanged: (user) => {
72
- console.log('Auth state changed:', user);
73
- },
74
- });
75
- }, []);
76
-
77
- return <AppNavigator />;
78
- }
79
- ```
91
+ **Rules**:
92
+ - MUST call once at app startup
93
+ - MUST wait for initialization completion
94
+ - MUST handle initialization errors
95
+ - MUST not call multiple times
96
+ - MUST check status before operations
80
97
 
81
- #### Custom AuthService
98
+ **MUST NOT**:
99
+ - Skip initialization
100
+ - Call in components (use app root)
101
+ - Initialize multiple times
102
+ - Skip status check
103
+ - Ignore initialization errors
82
104
 
83
- ```typescript
84
- import { AuthService } from '@umituz/react-native-auth';
85
-
86
- class CustomAuthService extends AuthService {
87
- async signInWithCustomToken(token: string) {
88
- // Custom implementation
89
- const userCredential = await signInWithCustomToken(
90
- this.firebaseAuth,
91
- token
92
- );
93
-
94
- await this.ensureUserDocument(userCredential.user);
95
- return userCredential.user;
96
- }
97
- }
98
-
99
- // Custom service kullanımı
100
- const customService = new CustomAuthService({
101
- firebaseAuth: getAuth(),
102
- });
103
- ```
105
+ **CALLBACKS**:
106
+ - `onAuthStateChanged(user)` - Called when auth state changes
107
+ - `onAuthError(error)` - Called on auth errors
104
108
 
105
109
  ---
106
110
 
107
- ## initializeAuth
108
-
109
- Authentication sistemini başlatır. Firebase Auth listener'ını kurar ve user state'ini yönetir.
111
+ ### UserDocumentService
110
112
 
111
- ### Kullanım
113
+ **PURPOSE**: Manage Firestore user documents
112
114
 
115
+ **IMPORT PATH**:
113
116
  ```typescript
114
- import { initializeAuth } from '@umituz/react-native-auth';
115
-
116
- function App() {
117
- useEffect(() => {
118
- const init = async () => {
119
- await initializeAuth({
120
- onAuthStateChanged: (user) => {
121
- console.log('User:', user);
122
- },
123
- });
124
- };
125
-
126
- init();
127
- }, []);
128
-
129
- return <AppNavigator />;
130
- }
117
+ import {
118
+ ensureUserDocument,
119
+ markUserDeleted,
120
+ configureUserDocumentService
121
+ } from '@umituz/react-native-auth';
131
122
  ```
132
123
 
133
- ### Options
124
+ **File**: `UserDocumentService.ts`
125
+
126
+ **FUNCTIONS**:
127
+ - `ensureUserDocument(user, data?)` - Create/retrieve user document
128
+ - `markUserDeleted(userId)` - Mark user as deleted
129
+ - `configureUserDocumentService(config)` - Configure service
130
+
131
+ **Rules**:
132
+ - MUST create document on registration
133
+ - MUST check document existence
134
+ - MUST use server timestamps
135
+ - MUST support custom configuration
136
+ - MUST not delete documents permanently
137
+
138
+ **MUST NOT**:
139
+ - Skip document creation
140
+ - Overwrite existing data
141
+ - Use client timestamps
142
+ - Hardcode collection name
143
+ - Delete documents permanently
144
+
145
+ **CONFIGURATION**:
146
+ - `collection` - Firestore collection name (default: 'users')
147
+ - `timestamps` - Add createdAt/updatedAt fields
148
+ - `userData` - Custom fields to add to documents
149
+
150
+ **CUSTOM DATA**:
151
+ - Can add custom fields on document creation
152
+ - Merges with existing data
153
+ - Supports nested objects
154
+ - Preserves user-provided data
134
155
 
135
- ```typescript
136
- interface InitializeAuthOptions {
137
- onAuthStateChanged?: (user: AuthUser | null) => void;
138
- onAuthError?: (error: Error) => void;
139
- }
140
- ```
156
+ ---
141
157
 
142
- ### Örnekler
158
+ ### AnonymousModeService
143
159
 
144
- #### Basit Başlatma
160
+ **PURPOSE**: Handle anonymous user authentication and upgrade
145
161
 
162
+ **IMPORT PATH**:
146
163
  ```typescript
147
- import { initializeAuth } from '@umituz/react-native-auth';
148
-
149
- function App() {
150
- useEffect(() => {
151
- initializeAuth();
152
- }, []);
153
-
154
- return <Navigator />;
155
- }
164
+ import { AnonymousModeService } from '@umituz/react-native-auth';
156
165
  ```
157
166
 
158
- #### Callback ile Başlatma
167
+ **File**: `AnonymousModeService.ts`
159
168
 
160
- ```typescript
161
- import { initializeAuth } from '@umituz/react-native-auth';
162
-
163
- function App() {
164
- const navigation = useNavigation();
165
-
166
- useEffect(() => {
167
- initializeAuth({
168
- onAuthStateChanged: (user) => {
169
- if (user) {
170
- navigation.reset({
171
- index: 0,
172
- routes: [{ name: 'Home' }],
173
- });
174
- } else {
175
- navigation.reset({
176
- index: 0,
177
- routes: [{ name: 'Login' }],
178
- });
179
- }
180
- },
181
- onAuthError: (error) => {
182
- console.error('Auth error:', error);
183
- Alert.alert('Auth Hatası', error.message);
184
- },
185
- });
186
- }, []);
187
-
188
- return <Navigator />;
189
- }
190
- ```
169
+ **METHODS**:
170
+ - `signInAnonymously()` - Create anonymous user
191
171
 
192
- ---
172
+ **UPGRADE**:
173
+ - Handled via Firebase credential linking
174
+ - Converts anonymous to permanent account
175
+ - Preserves anonymous user data
193
176
 
194
- ## UserDocumentService
177
+ **Rules**:
178
+ - MUST create temporary accounts
179
+ - MUST support upgrade to permanent account
180
+ - MUST warn about data loss
181
+ - MUST handle upgrade failures
182
+ - MUST not delete anonymous data on sign out
195
183
 
196
- Firestore'da kullanıcı dokümanlarını yönetir.
184
+ **MUST NOT**:
185
+ - Skip upgrade warnings
186
+ - Lose user data during upgrade
187
+ - Allow restricted operations without warning
188
+ - Make anonymous accounts permanent
197
189
 
198
- ### Kullanım
190
+ **CONSTRAINTS**:
191
+ - Anonymous users have limited functionality
192
+ - Data lost if signed out without upgrade
193
+ - Upgrade requires valid credentials
194
+ - Cannot revert to anonymous after upgrade
199
195
 
200
- ```typescript
201
- import {
202
- ensureUserDocument,
203
- markUserDeleted,
204
- configureUserDocumentService
205
- } from '@umituz/react-native-auth';
196
+ ---
206
197
 
207
- // Kullanıcı dokümanını garanti altına al
208
- await ensureUserDocument(user);
198
+ ### AuthEventService
209
199
 
210
- // Kullanıcıyı silinmiş olarak işaretle
211
- await markUserDeleted(user.uid);
200
+ **PURPOSE**: Pub/sub system for authentication events
212
201
 
213
- // Service konfigürasyonu
214
- configureUserDocumentService({
215
- collection: 'users',
216
- timestamps: true,
217
- });
202
+ **IMPORT PATH**:
203
+ ```typescript
204
+ import { AuthEventService } from '@umituz/react-native-auth';
218
205
  ```
219
206
 
220
- ### API
207
+ **File**: `AuthEventService.ts`
208
+
209
+ **METHODS**:
210
+ - `on(event, callback)` - Subscribe to event
211
+ - `emit(event, data)` - Emit event
212
+ - Returns unsubscribe function
213
+
214
+ **EVENTS**:
215
+ - `signIn` - User signed in (payload: AuthUser)
216
+ - `signUp` - New user registered (payload: AuthUser)
217
+ - `signOut` - User signed out (payload: undefined)
218
+ - `authStateChanged` - Auth state changed (payload: AuthUser | null)
219
+
220
+ **Rules**:
221
+ - MUST emit events on state changes
222
+ - MUST support multiple subscribers
223
+ - MUST provide unsubscribe function
224
+ - MUST not throw in event handlers
225
+ - MUST handle subscriber errors gracefully
226
+
227
+ **MUST NOT**:
228
+ - Skip critical events
229
+ - Block event emission on handler errors
230
+ - Throw unhandled errors
231
+ - Memory leak subscribers
232
+ - Modify event payload
233
+
234
+ **USAGE**:
235
+ - Subscribe returns unsubscribe function
236
+ - Multiple subscribers per event allowed
237
+ - Subscriber errors should not affect other subscribers
238
+ - Unsubscribe when done to prevent memory leaks
221
239
 
222
- | Method | Parametreler | Açıklama |
223
- |--------|--------------|----------|
224
- | `ensureUserDocument` | `user` | Kullanıcı dokümanını oluştur |
225
- | `markUserDeleted` | `userId` | Kullanıcıyı silinmiş olarak işaretle |
226
- | `configureUserDocumentService` | `config` | Service konfigürasyonu |
240
+ ---
227
241
 
228
- ### Örnekler
242
+ ## Storage Adapter
229
243
 
230
- #### Custom Konfigürasyon
244
+ ### StorageProviderAdapter
231
245
 
232
- ```typescript
233
- import { configureUserDocumentService } from '@umituz/react-native-auth';
234
-
235
- configureUserDocumentService({
236
- collection: 'customers', // Varsayılan: 'users'
237
- timestamps: true, // createdAt, updatedAt alanları ekle
238
- userData: {
239
- source: 'app',
240
- version: '1.0.0',
241
- },
242
- });
243
- ```
244
-
245
- #### Custom User Data
246
+ **PURPOSE**: Interface for storage providers (AsyncStorage, MMKV, etc.)
246
247
 
248
+ **IMPORT PATH**:
247
249
  ```typescript
248
- import { ensureUserDocument } from '@umituz/react-native-auth';
249
-
250
- const user = await signInWithGoogle();
251
-
252
- await ensureUserDocument(user, {
253
- role: 'user',
254
- subscription: 'free',
255
- preferences: {
256
- newsletter: true,
257
- notifications: true,
258
- },
259
- });
250
+ import {
251
+ createStorageProvider,
252
+ StorageProviderAdapter
253
+ } from '@umituz/react-native-auth';
260
254
  ```
261
255
 
256
+ **INTERFACE METHODS**:
257
+ - `getItem(key)` - Retrieve value (returns string | null)
258
+ - `setItem(key, value)` - Store value
259
+ - `removeItem(key)` - Delete value
260
+
261
+ **Rules**:
262
+ - MUST implement all three methods
263
+ - MUST handle async operations
264
+ - MUST return null for missing keys
265
+ - MUST handle storage errors
266
+ - MUST only store string values
267
+
268
+ **MUST NOT**:
269
+ - Throw for missing keys
270
+ - Skip error handling
271
+ - Assume synchronous operations
272
+ - Store non-string values
273
+ - Return undefined for missing keys
274
+
275
+ **IMPLEMENTATIONS**:
276
+ - AsyncStorage (React Native default)
277
+ - MMKV (faster alternative)
278
+ - SecureStorage (for sensitive data)
279
+ - Custom implementations allowed
280
+
262
281
  ---
263
282
 
264
- ## AnonymousModeService
283
+ ## Validation
265
284
 
266
- Anonymous kullanıcı modunu yönetir.
285
+ ### AuthValidation Utilities
267
286
 
268
- ### Kullanım
287
+ **PURPOSE**: Input validation for authentication forms
269
288
 
289
+ **IMPORT PATH**:
270
290
  ```typescript
271
- import { AnonymousModeService } from '@umituz/react-native-auth';
272
-
273
- const anonymousService = new AnonymousModeService();
274
-
275
- // Anonymous kullanıcı oluştur
276
- const user = await anonymousService.signInAnonymously();
277
-
278
- // Anonymous kullanıcıyı authenticated kullanıcısına yükselt
279
- const credential = EmailAuthProvider.credential(email, password);
280
- await user.linkWithCredential(credential);
291
+ import {
292
+ validateEmail,
293
+ validatePasswordForLogin,
294
+ validatePasswordForRegister,
295
+ validatePasswordConfirmation,
296
+ validateDisplayName,
297
+ DEFAULT_VAL_CONFIG
298
+ } from '@umituz/react-native-auth';
281
299
  ```
282
300
 
301
+ **VALIDATORS**:
302
+
303
+ **validateEmail(email)**
304
+ - Validates email format
305
+ - Returns: `{ isValid: boolean, error?: string }`
306
+
307
+ **validatePasswordForLogin(password)**
308
+ - Checks password not empty
309
+ - Returns: `{ isValid: boolean, error?: string }`
310
+
311
+ **validatePasswordForRegister(password)**
312
+ - Checks password complexity
313
+ - Returns: `{ isValid: boolean, error?: string, requirements: PasswordRequirements }`
314
+
315
+ **validatePasswordConfirmation(password, confirmation)**
316
+ - Checks passwords match
317
+ - Returns: `{ isValid: boolean, matches: boolean, error?: string }`
318
+
319
+ **validateDisplayName(name)**
320
+ - Validates display name
321
+ - Returns: `{ isValid: boolean, error?: string }`
322
+
323
+ **Rules**:
324
+ - MUST return validation result object
325
+ - MUST provide error messages
326
+ - MUST use configurable rules
327
+ - MUST not throw for invalid input
328
+ - MUST support internationalization
329
+
330
+ **MUST NOT**:
331
+ - Return boolean only
332
+ - Skip error messages
333
+ - Hardcode validation rules
334
+ - Throw on validation failure
335
+ - Assume required fields present
336
+
337
+ **DEFAULT CONFIG**:
338
+ - `password.minLength` - 8 characters
339
+ - `password.requireUppercase` - true
340
+ - `password.requireLowercase` - true
341
+ - `password.requireNumber` - true
342
+ - `password.requireSpecialChar` - true
343
+
283
344
  ---
284
345
 
285
- ## AuthEventService
346
+ ## Migration Utilities
286
347
 
287
- Authentication event'lerini yönetir ve yayınlar.
348
+ ### User Data Migration
288
349
 
289
- ### Kullanım
350
+ **PURPOSE**: Migrate user data between collections
290
351
 
352
+ **IMPORT PATH**:
291
353
  ```typescript
292
- import { AuthEventService } from '@umituz/react-native-auth';
354
+ import {
355
+ migrateUserData,
356
+ configureMigration
357
+ } from '@umituz/react-native-auth';
358
+ ```
293
359
 
294
- const eventService = new AuthEventService();
360
+ **FUNCTIONS**:
361
+ - `configureMigration(config)` - Configure migration
362
+ - `migrateUserData(userId)` - Run migration
363
+
364
+ **Rules**:
365
+ - MUST configure before migrating
366
+ - MUST transform data correctly
367
+ - MUST handle migration errors
368
+ - MUST verify migration success
369
+ - MUST not delete source data automatically
370
+
371
+ **MUST NOT**:
372
+ - Skip configuration
373
+ - Lose data during migration
374
+ - Assume identical schemas
375
+ - Delete source without verification
376
+ - Migrate without backup
377
+
378
+ **CONFIGURATION**:
379
+ - `from` - Source collection name
380
+ - `to` - Target collection name
381
+ - `transform` - Data transformation function
382
+ - `verify` - Verification function (optional)
295
383
 
296
- // Event dinle
297
- const unsubscribe = eventService.on('signIn', (user) => {
298
- console.log('User signed in:', user);
299
- });
384
+ ---
300
385
 
301
- // Event tetikle
302
- eventService.emit('signIn', user);
386
+ ## Best Practices
303
387
 
304
- // Dinlemeyi bırak
305
- unsubscribe();
306
- ```
388
+ ### Service Initialization
307
389
 
308
- ### Event Türleri
390
+ **MUST**:
391
+ - Initialize services at app root
392
+ - Wait for initialization completion
393
+ - Handle initialization errors
394
+ - Check initialization status
395
+ - Configure before initialization
309
396
 
310
- | Event | Açıklama |
311
- |-------|----------|
312
- | `signIn` | Kullanıcı giriş yaptı |
313
- | `signUp` | Yeni kullanıcı kayıt oldu |
314
- | `signOut` | Kullanıcı çıkış yaptı |
315
- | `authStateChanged` | Auth state değişti |
397
+ **MUST NOT**:
398
+ - Initialize in components
399
+ - Use before initialization
400
+ - Skip error handling
401
+ - Initialize multiple times
402
+ - Ignore status checks
316
403
 
317
404
  ---
318
405
 
319
- ## Migration
406
+ ### User Document Management
320
407
 
321
- Kullanıcı verilerini taşımak için utility:
408
+ **MUST**:
409
+ - Create documents on registration
410
+ - Use server timestamps
411
+ - Handle existing documents
412
+ - Configure collection name
413
+ - Add custom fields appropriately
322
414
 
323
- ```typescript
324
- import { migrateUserData, configureMigration } from '@umituz/react-native-auth';
325
-
326
- // Migration konfigürasyonu
327
- configureMigration({
328
- from: 'legacy_users',
329
- to: 'users',
330
- transform: (legacyData) => ({
331
- displayName: legacyData.name,
332
- email: legacyData.email_address,
333
- createdAt: legacyData.joined_at,
334
- }),
335
- });
336
-
337
- // Migration çalıştırma
338
- await migrateUserData(userId);
339
- ```
415
+ **MUST NOT**:
416
+ - Skip document creation
417
+ - Overwrite existing data unnecessarily
418
+ - Use client timestamps
419
+ - Hardcode collection names
420
+ - Delete documents permanently
340
421
 
341
422
  ---
342
423
 
343
- ## Storage Provider
424
+ ### Event Handling
344
425
 
345
- Custom storage provider tanımlama:
426
+ **MUST**:
427
+ - Emit events on all state changes
428
+ - Support multiple subscribers
429
+ - Provide unsubscribe function
430
+ - Handle subscriber errors gracefully
431
+ - Unsubscribe when done
346
432
 
347
- ```typescript
348
- import {
349
- createStorageProvider,
350
- StorageProviderAdapter
351
- } from '@umituz/react-native-auth';
433
+ **MUST NOT**:
434
+ - Skip critical events
435
+ - Block on subscriber errors
436
+ - Throw unhandled errors
437
+ - Memory leak subscribers
438
+ - Emit duplicate events
352
439
 
353
- // Custom storage provider
354
- class CustomStorageAdapter implements StorageProviderAdapter {
355
- async getItem(key: string): Promise<string | null> {
356
- return await AsyncStorage.getItem(key);
357
- }
440
+ ---
358
441
 
359
- async setItem(key: string, value: string): Promise<void> {
360
- await AsyncStorage.setItem(key, value);
361
- }
442
+ ### Validation
362
443
 
363
- async removeItem(key: string): Promise<void> {
364
- await AsyncStorage.removeItem(key);
365
- }
366
- }
444
+ **MUST**:
445
+ - Validate all user inputs
446
+ - Provide clear error messages
447
+ - Use consistent return types
448
+ - Support internationalization
449
+ - Configure rules appropriately
367
450
 
368
- // Kullanımı
369
- const storageProvider = createStorageProvider(new CustomStorageAdapter());
370
- ```
451
+ **MUST NOT**:
452
+ - Skip validation
453
+ - Return ambiguous results
454
+ - Hardcode rules
455
+ - Throw on invalid input
456
+ - Assume required fields present
371
457
 
372
458
  ---
373
459
 
374
- ## Validation
460
+ ## Error Handling
375
461
 
376
- Auth validasyon utility'leri:
462
+ ### Service Errors
377
463
 
378
- ```typescript
379
- import {
380
- validateEmail,
381
- validatePasswordForLogin,
382
- validatePasswordForRegister,
383
- validatePasswordConfirmation,
384
- validateDisplayName
385
- } from '@umituz/react-native-auth';
386
-
387
- // Email validasyonu
388
- const emailResult = validateEmail('test@example.com');
389
- // { isValid: true }
390
-
391
- // Şifre validasyonu (kayıt için)
392
- const passwordResult = validatePasswordForRegister('MyPass123!');
393
- // {
394
- // isValid: true,
395
- // requirements: { hasMinLength: true, hasUppercase: true, ... }
396
- // }
464
+ **STRATEGY**:
465
+ - Map Firebase errors to domain errors
466
+ - Provide error context
467
+ - Log appropriately
468
+ - Show user-friendly messages
469
+ - Allow retry where appropriate
397
470
 
398
- // Şifre validasyonu (giriş için)
399
- const loginPasswordResult = validatePasswordForLogin('password');
400
- // { isValid: true }
471
+ **Rules**:
472
+ - MUST map all Firebase errors
473
+ - MUST preserve error context
474
+ - MUST use domain error types
475
+ - MUST handle network failures
476
+ - MUST not expose implementation details
401
477
 
402
- // Şifre eşleşme validasyonu
403
- const matchResult = validatePasswordConfirmation('password', 'password');
404
- // { isValid: true, matches: true }
405
-
406
- // DisplayName validasyonu
407
- const nameResult = validateDisplayName('John Doe');
408
- // { isValid: true }
409
- ```
478
+ **MUST NOT**:
479
+ - Throw raw Firebase errors
480
+ - Lose error context
481
+ - Expose technical details
482
+ - Skip error logging
483
+ - Suppress errors silently
410
484
 
411
485
  ---
412
486
 
413
- ## İlgili Modüller
487
+ ## Related Modules
414
488
 
415
- - **[Domain](../../domain/README.md)** - Domain entities ve value objects
416
- - **[Application](../../application/README.md)** - Application ports ve interfaces
417
- - **[Hooks](../../presentation/hooks/README.md)** - React hooks
489
+ - **Domain** (`../../domain/README.md`) - AuthUser entity, AuthError, AuthConfig
490
+ - **Application** (`../../application/README.md`) - IAuthService, IAuthProvider interfaces
491
+ - **Presentation** (`../../presentation/README.md`) - UI components and hooks