@umituz/react-native-auth 3.4.32 β 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.
- package/README.md +347 -348
- package/package.json +2 -3
- package/src/application/README.md +323 -442
- package/src/domain/ConfigAndErrors.md +296 -431
- package/src/domain/README.md +361 -210
- package/src/domain/entities/AuthUser.md +231 -372
- package/src/domain/entities/UserProfile.md +271 -441
- package/src/index.ts +35 -0
- package/src/infrastructure/README.md +388 -444
- package/src/infrastructure/services/README.md +386 -312
- package/src/infrastructure/utils/validation/BaseValidators.ts +35 -0
- package/src/infrastructure/utils/validation/CollectionValidators.ts +56 -0
- package/src/infrastructure/utils/validation/DateValidators.ts +63 -0
- package/src/infrastructure/utils/validation/FormValidators.ts +22 -0
- package/src/infrastructure/utils/validation/NumberValidators.ts +55 -0
- package/src/infrastructure/utils/validation/StringValidators.ts +55 -0
- package/src/infrastructure/utils/validation/sanitization.ts +98 -0
- package/src/infrastructure/utils/validation/types.ts +15 -0
- package/src/presentation/README.md +631 -563
- package/src/presentation/components/ProfileComponents.md +307 -504
- package/src/presentation/components/README.md +254 -92
- package/src/presentation/hooks/README.md +247 -83
- package/src/presentation/hooks/useAccountManagement.md +295 -344
- package/src/presentation/hooks/useAuth.md +271 -227
- package/src/presentation/hooks/useAuthBottomSheet.md +417 -367
- package/src/presentation/hooks/useAuthRequired.md +308 -194
- package/src/presentation/hooks/useProfileUpdate.md +251 -279
- package/src/presentation/hooks/useSocialLogin.md +312 -287
- package/src/presentation/hooks/useUserProfile.md +259 -192
- package/src/presentation/screens/README.md +151 -153
package/README.md
CHANGED
|
@@ -1,426 +1,425 @@
|
|
|
1
1
|
# @umituz/react-native-auth
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Authentication service for React Native applications with secure, type-safe, and production-ready implementation.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Strategy
|
|
8
|
+
|
|
9
|
+
**Purpose**: Provides comprehensive authentication solution for React Native apps with Domain-Driven Design architecture, supporting multiple authentication methods and providers.
|
|
10
|
+
|
|
11
|
+
**When to Use**:
|
|
12
|
+
- Building React Native apps requiring authentication
|
|
13
|
+
- Need multiple auth methods (email, social, anonymous)
|
|
14
|
+
- Want type-safe auth implementation
|
|
15
|
+
- Prefer DDD architecture
|
|
16
|
+
- Need production-ready auth solution
|
|
17
|
+
|
|
18
|
+
**Package Location**: `/src`
|
|
19
|
+
|
|
20
|
+
**Documentation**: See `/src/[layer]/README.md` for detailed documentation
|
|
21
|
+
|
|
22
|
+
---
|
|
7
23
|
|
|
8
|
-
## Features
|
|
24
|
+
## Core Features
|
|
9
25
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
-
|
|
26
|
+
### Authentication Methods
|
|
27
|
+
|
|
28
|
+
**SUPPORTED METHODS**:
|
|
29
|
+
- Email/Password authentication
|
|
30
|
+
- Google OAuth integration
|
|
31
|
+
- Apple Sign-In (iOS)
|
|
32
|
+
- Anonymous user sessions
|
|
33
|
+
- Account upgrade (anonymous β registered)
|
|
34
|
+
|
|
35
|
+
### Architecture
|
|
36
|
+
|
|
37
|
+
**DOMAIN-DRIVEN DESIGN LAYERS**:
|
|
38
|
+
- **Domain**: Core business logic and entities
|
|
39
|
+
- **Application**: Use cases and interfaces
|
|
40
|
+
- **Infrastructure**: External integrations
|
|
41
|
+
- **Presentation**: UI components and hooks
|
|
42
|
+
|
|
43
|
+
---
|
|
18
44
|
|
|
19
45
|
## Installation
|
|
20
46
|
|
|
47
|
+
### Package Installation
|
|
48
|
+
|
|
49
|
+
**NPM**:
|
|
21
50
|
```bash
|
|
22
51
|
npm install @umituz/react-native-auth
|
|
23
|
-
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
**Yarn**:
|
|
55
|
+
```bash
|
|
24
56
|
yarn add @umituz/react-native-auth
|
|
25
57
|
```
|
|
26
58
|
|
|
27
|
-
|
|
59
|
+
### Peer Dependencies
|
|
28
60
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
"zustand": ">=4.0.0"
|
|
36
|
-
}
|
|
37
|
-
```
|
|
61
|
+
**REQUIRED PACKAGES**:
|
|
62
|
+
- `firebase`: >= 11.0.0
|
|
63
|
+
- `react`: >= 18.2.0
|
|
64
|
+
- `react-native`: >= 0.74.0
|
|
65
|
+
- `@tanstack/react-query`: >= 5.0.0
|
|
66
|
+
- `zustand`: >= 4.0.0
|
|
38
67
|
|
|
39
|
-
|
|
68
|
+
**EXTERNAL DEPENDENCIES**:
|
|
69
|
+
- `@umituz/react-native-firebase` - Firebase integration
|
|
70
|
+
- `@umituz/react-native-design-system` - UI components
|
|
40
71
|
|
|
41
|
-
|
|
72
|
+
---
|
|
42
73
|
|
|
43
|
-
|
|
74
|
+
## Configuration
|
|
44
75
|
|
|
45
|
-
|
|
46
|
-
import React, { useEffect } from 'react';
|
|
47
|
-
import { AuthProvider, initializeAuth } from '@umituz/react-native-auth';
|
|
48
|
-
import { getAuth } from 'firebase/auth';
|
|
49
|
-
import { NavigationContainer } from '@react-navigation/native';
|
|
50
|
-
import { createNativeStackNavigator } from '@react-navigation/native-stack';
|
|
51
|
-
|
|
52
|
-
// Initialize auth (call once in app root)
|
|
53
|
-
initializeAuth({
|
|
54
|
-
onAuthStateChanged: (user) => {
|
|
55
|
-
console.log('Auth state changed:', user);
|
|
56
|
-
},
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
function App() {
|
|
60
|
-
return (
|
|
61
|
-
<AuthProvider>
|
|
62
|
-
<NavigationContainer>
|
|
63
|
-
<Stack.Navigator>
|
|
64
|
-
<Stack.Screen name="Login" component={LoginScreen} />
|
|
65
|
-
<Stack.Screen name="Home" component={HomeScreen} />
|
|
66
|
-
</Stack.Navigator>
|
|
67
|
-
</NavigationContainer>
|
|
68
|
-
</AuthProvider>
|
|
69
|
-
);
|
|
70
|
-
}
|
|
71
|
-
```
|
|
76
|
+
### Firebase Setup
|
|
72
77
|
|
|
73
|
-
|
|
78
|
+
**Rules**:
|
|
79
|
+
- MUST create Firebase project
|
|
80
|
+
- MUST enable Authentication
|
|
81
|
+
- MUST enable Firestore (for user documents)
|
|
82
|
+
- MUST configure OAuth providers
|
|
74
83
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
function LoginScreen() {
|
|
80
|
-
const { signIn, loading, error } = useAuth();
|
|
81
|
-
|
|
82
|
-
const handleLogin = async () => {
|
|
83
|
-
try {
|
|
84
|
-
await signIn('user@example.com', 'password123');
|
|
85
|
-
// Navigate to home
|
|
86
|
-
} catch (err) {
|
|
87
|
-
// Error is automatically set in error state
|
|
88
|
-
}
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
return (
|
|
92
|
-
<View>
|
|
93
|
-
<Button onPress={handleLogin} disabled={loading}>
|
|
94
|
-
{loading ? 'Signing in...' : 'Sign In'}
|
|
95
|
-
</Button>
|
|
96
|
-
{error && <Text>{error}</Text>}
|
|
97
|
-
</View>
|
|
98
|
-
);
|
|
99
|
-
}
|
|
100
|
-
```
|
|
84
|
+
**MUST NOT**:
|
|
85
|
+
- Skip Firebase console setup
|
|
86
|
+
- Use production keys in development
|
|
87
|
+
- Forget to enable required providers
|
|
101
88
|
|
|
102
|
-
|
|
89
|
+
**Steps**:
|
|
90
|
+
1. Create Firebase project at console.firebase.google.com
|
|
91
|
+
2. Enable Authentication
|
|
92
|
+
3. Enable Google Sign-In
|
|
93
|
+
4. Enable Apple Sign-In (for iOS)
|
|
94
|
+
5. Enable Firestore
|
|
95
|
+
6. Download config files
|
|
103
96
|
|
|
104
|
-
|
|
105
|
-
import { useAuthRequired } from '@umituz/react-native-auth';
|
|
106
|
-
|
|
107
|
-
function ProtectedComponent() {
|
|
108
|
-
const { isAllowed, checkAndRequireAuth } = useAuthRequired();
|
|
109
|
-
|
|
110
|
-
const handleAction = () => {
|
|
111
|
-
if (checkAndRequireAuth()) {
|
|
112
|
-
// User is authenticated, proceed with action
|
|
113
|
-
console.log('Action performed');
|
|
114
|
-
}
|
|
115
|
-
// If not authenticated, auth modal is shown automatically
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
return (
|
|
119
|
-
<Button onPress={handleAction}>
|
|
120
|
-
{isAllowed ? 'Perform Action' : 'Sign In to Continue'}
|
|
121
|
-
</Button>
|
|
122
|
-
);
|
|
123
|
-
}
|
|
124
|
-
```
|
|
97
|
+
---
|
|
125
98
|
|
|
126
|
-
##
|
|
99
|
+
## Layer Overview
|
|
127
100
|
|
|
128
|
-
###
|
|
101
|
+
### Domain Layer
|
|
129
102
|
|
|
130
|
-
|
|
131
|
-
import { useGoogleAuth } from '@umituz/react-native-auth';
|
|
132
|
-
|
|
133
|
-
function GoogleLoginButton() {
|
|
134
|
-
const { signInWithGoogle, googleLoading } = useGoogleAuth({
|
|
135
|
-
iosClientId: 'your-ios-client-id.apps.googleusercontent.com',
|
|
136
|
-
webClientId: 'your-web-client-id.apps.googleusercontent.com',
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
return (
|
|
140
|
-
<Button onPress={signInWithGoogle} disabled={googleLoading}>
|
|
141
|
-
Sign in with Google
|
|
142
|
-
</Button>
|
|
143
|
-
);
|
|
144
|
-
}
|
|
145
|
-
```
|
|
103
|
+
**Location**: `src/domain/`
|
|
146
104
|
|
|
147
|
-
|
|
105
|
+
**Purpose**: Core business logic and entities
|
|
148
106
|
|
|
149
|
-
|
|
150
|
-
|
|
107
|
+
**CONTAINS**:
|
|
108
|
+
- `AuthUser` entity
|
|
109
|
+
- `UserProfile` entity
|
|
110
|
+
- `AuthConfig` value object
|
|
111
|
+
- `AuthError` hierarchy
|
|
151
112
|
|
|
152
|
-
|
|
153
|
-
const { signInWithApple, appleLoading, appleAvailable } = useAppleAuth();
|
|
113
|
+
**Documentation**: `src/domain/README.md`
|
|
154
114
|
|
|
155
|
-
|
|
115
|
+
---
|
|
156
116
|
|
|
157
|
-
|
|
158
|
-
<Button onPress={signInWithApple} disabled={appleLoading}>
|
|
159
|
-
Sign in with Apple
|
|
160
|
-
</Button>
|
|
161
|
-
);
|
|
162
|
-
}
|
|
163
|
-
```
|
|
117
|
+
### Application Layer
|
|
164
118
|
|
|
165
|
-
|
|
119
|
+
**Location**: `src/application/`
|
|
166
120
|
|
|
167
|
-
Use
|
|
121
|
+
**Purpose**: Use cases and interfaces
|
|
168
122
|
|
|
169
|
-
|
|
170
|
-
|
|
123
|
+
**CONTAINS**:
|
|
124
|
+
- Authentication ports
|
|
125
|
+
- User profile ports
|
|
126
|
+
- Account management ports
|
|
171
127
|
|
|
172
|
-
|
|
173
|
-
name="Login"
|
|
174
|
-
component={LoginScreen}
|
|
175
|
-
options={{ headerShown: false }}
|
|
176
|
-
/>
|
|
177
|
-
```
|
|
128
|
+
**Documentation**: `src/application/README.md`
|
|
178
129
|
|
|
179
|
-
|
|
130
|
+
---
|
|
180
131
|
|
|
181
|
-
###
|
|
132
|
+
### Infrastructure Layer
|
|
182
133
|
|
|
183
|
-
|
|
184
|
-
import { useUserProfile } from '@umituz/react-native-auth';
|
|
185
|
-
|
|
186
|
-
function ProfileHeader() {
|
|
187
|
-
const profile = useUserProfile({
|
|
188
|
-
accountRoute: '/account',
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
if (!profile) return <LoadingSpinner />;
|
|
192
|
-
|
|
193
|
-
return (
|
|
194
|
-
<View>
|
|
195
|
-
<Avatar source={{ uri: profile.avatarUrl }} />
|
|
196
|
-
<Text>{profile.displayName}</Text>
|
|
197
|
-
{profile.isAnonymous && <Badge>Guest</Badge>}
|
|
198
|
-
</View>
|
|
199
|
-
);
|
|
200
|
-
}
|
|
201
|
-
```
|
|
134
|
+
**Location**: `src/infrastructure/`
|
|
202
135
|
|
|
203
|
-
|
|
136
|
+
**Purpose**: External integrations and implementations
|
|
204
137
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
Alert.alert('Error', 'Failed to update profile');
|
|
219
|
-
}
|
|
220
|
-
};
|
|
221
|
-
|
|
222
|
-
return <ProfileForm onSave={handleSave} loading={isUpdating} />;
|
|
223
|
-
}
|
|
224
|
-
```
|
|
138
|
+
**CONTAINS**:
|
|
139
|
+
- Firebase Auth service
|
|
140
|
+
- Firestore repositories
|
|
141
|
+
- Validation utilities
|
|
142
|
+
- Provider implementations
|
|
143
|
+
|
|
144
|
+
**Documentation**:
|
|
145
|
+
- `src/infrastructure/README.md`
|
|
146
|
+
- `src/infrastructure/services/README.md`
|
|
147
|
+
|
|
148
|
+
---
|
|
149
|
+
|
|
150
|
+
### Presentation Layer
|
|
225
151
|
|
|
226
|
-
|
|
152
|
+
**Location**: `src/presentation/`
|
|
227
153
|
|
|
228
|
-
|
|
154
|
+
**Purpose**: UI components and hooks
|
|
229
155
|
|
|
156
|
+
**CONTAINS**:
|
|
157
|
+
- React hooks for auth
|
|
158
|
+
- Pre-built components
|
|
159
|
+
- Screen components
|
|
160
|
+
- State management (Zustand)
|
|
161
|
+
|
|
162
|
+
**Documentation**:
|
|
163
|
+
- `src/presentation/README.md`
|
|
164
|
+
- `src/presentation/hooks/README.md`
|
|
165
|
+
- `src/presentation/components/README.md`
|
|
166
|
+
- `src/presentation/screens/README.md`
|
|
167
|
+
|
|
168
|
+
---
|
|
169
|
+
|
|
170
|
+
## Usage Guidelines
|
|
171
|
+
|
|
172
|
+
### Authentication Hooks
|
|
173
|
+
|
|
174
|
+
**PRIMARY HOOK**: `useAuth`
|
|
175
|
+
**Location**: `src/presentation/hooks/useAuth.ts`
|
|
176
|
+
|
|
177
|
+
**When to Use**:
|
|
178
|
+
- Need authentication state
|
|
179
|
+
- Require user information
|
|
180
|
+
- Performing auth operations
|
|
181
|
+
- Checking auth status
|
|
182
|
+
|
|
183
|
+
**Import Path**:
|
|
230
184
|
```typescript
|
|
231
|
-
import {
|
|
232
|
-
|
|
233
|
-
function AccountSettings() {
|
|
234
|
-
const { deleteAccount, logout } = useAccountManagement({
|
|
235
|
-
onReauthRequired: async () => {
|
|
236
|
-
// Show re-authentication UI
|
|
237
|
-
const result = await showReauthDialog();
|
|
238
|
-
return result.success;
|
|
239
|
-
},
|
|
240
|
-
});
|
|
241
|
-
|
|
242
|
-
return (
|
|
243
|
-
<View>
|
|
244
|
-
<Button onPress={logout}>Sign Out</Button>
|
|
245
|
-
<Button onPress={deleteAccount}>Delete Account</Button>
|
|
246
|
-
</View>
|
|
247
|
-
);
|
|
248
|
-
}
|
|
185
|
+
import { useAuth } from '@umituz/react-native-auth';
|
|
249
186
|
```
|
|
250
187
|
|
|
251
|
-
|
|
188
|
+
**Rules**:
|
|
189
|
+
- MUST initialize AuthProvider before use
|
|
190
|
+
- MUST handle loading state
|
|
191
|
+
- MUST check auth readiness
|
|
192
|
+
- MUST handle errors appropriately
|
|
252
193
|
|
|
253
|
-
|
|
194
|
+
---
|
|
254
195
|
|
|
196
|
+
### Components
|
|
197
|
+
|
|
198
|
+
**AVAILABLE COMPONENTS**:
|
|
199
|
+
- `LoginForm` - Email/password login
|
|
200
|
+
- `RegisterForm` - User registration
|
|
201
|
+
- `SocialLoginButtons` - Google/Apple buttons
|
|
202
|
+
- `ProfileSection` - Profile display
|
|
203
|
+
- `AccountActions` - Account management
|
|
204
|
+
|
|
205
|
+
**Import Path**:
|
|
255
206
|
```typescript
|
|
256
207
|
import {
|
|
257
|
-
|
|
258
|
-
|
|
208
|
+
LoginForm,
|
|
209
|
+
RegisterForm,
|
|
210
|
+
SocialLoginButtons
|
|
259
211
|
} from '@umituz/react-native-auth';
|
|
260
|
-
|
|
261
|
-
// Validate password
|
|
262
|
-
const result = validatePasswordForRegister('MyPass123!');
|
|
263
|
-
|
|
264
|
-
if (result.isValid) {
|
|
265
|
-
console.log('Password is strong');
|
|
266
|
-
} else {
|
|
267
|
-
console.log('Requirements:', result.requirements);
|
|
268
|
-
// {
|
|
269
|
-
// hasMinLength: true,
|
|
270
|
-
// hasUppercase: true,
|
|
271
|
-
// hasLowercase: true,
|
|
272
|
-
// hasNumber: true,
|
|
273
|
-
// hasSpecialChar: true
|
|
274
|
-
// }
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
// Validate password confirmation
|
|
278
|
-
const matchResult = validatePasswordConfirmation('pass123', 'pass123');
|
|
279
|
-
// { isValid: true, matches: true }
|
|
280
212
|
```
|
|
281
213
|
|
|
282
|
-
|
|
214
|
+
**Rules**:
|
|
215
|
+
- MUST follow component documentation
|
|
216
|
+
- MUST provide required props
|
|
217
|
+
- MUST handle events appropriately
|
|
218
|
+
- MUST NOT override internal logic
|
|
283
219
|
|
|
284
|
-
|
|
285
|
-
import { validateEmail } from '@umituz/react-native-auth';
|
|
220
|
+
---
|
|
286
221
|
|
|
287
|
-
|
|
288
|
-
// { isValid: true }
|
|
289
|
-
```
|
|
222
|
+
## Platform Support
|
|
290
223
|
|
|
291
|
-
|
|
224
|
+
### Supported Platforms
|
|
292
225
|
|
|
293
|
-
|
|
226
|
+
**iOS**: β
Full support
|
|
227
|
+
- All authentication methods
|
|
228
|
+
- Apple Sign-In available
|
|
229
|
+
- Google Sign-In available
|
|
294
230
|
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
const customConfig: AuthConfig = {
|
|
299
|
-
password: {
|
|
300
|
-
minLength: 12,
|
|
301
|
-
requireUppercase: true,
|
|
302
|
-
requireLowercase: true,
|
|
303
|
-
requireNumber: true,
|
|
304
|
-
requireSpecialChar: true,
|
|
305
|
-
},
|
|
306
|
-
social: {
|
|
307
|
-
google: {
|
|
308
|
-
enabled: true,
|
|
309
|
-
webClientId: Config.GOOGLE_WEB_CLIENT_ID,
|
|
310
|
-
iosClientId: Config.GOOGLE_IOS_CLIENT_ID,
|
|
311
|
-
},
|
|
312
|
-
apple: {
|
|
313
|
-
enabled: Platform.OS === 'ios',
|
|
314
|
-
},
|
|
315
|
-
},
|
|
316
|
-
};
|
|
317
|
-
```
|
|
231
|
+
**Android**: β
Full support
|
|
232
|
+
- All authentication methods (except Apple)
|
|
233
|
+
- Google Sign-In available
|
|
318
234
|
|
|
319
|
-
|
|
235
|
+
**Web**: β
Full support
|
|
236
|
+
- All authentication methods (except Apple)
|
|
237
|
+
- Google Sign-In available
|
|
320
238
|
|
|
321
|
-
|
|
239
|
+
---
|
|
322
240
|
|
|
323
|
-
|
|
324
|
-
src/
|
|
325
|
-
βββ domain/ # Business logic and entities
|
|
326
|
-
β βββ entities/ # AuthUser, UserProfile
|
|
327
|
-
β βββ value-objects/# AuthConfig, PasswordConfig
|
|
328
|
-
β βββ errors/ # AuthError classes
|
|
329
|
-
β βββ utils/ # Domain utilities
|
|
330
|
-
βββ application/ # Interfaces and ports
|
|
331
|
-
β βββ ports/ # IAuthService, IAuthProvider
|
|
332
|
-
βββ infrastructure/ # External integrations
|
|
333
|
-
β βββ providers/ # Firebase implementation
|
|
334
|
-
β βββ services/ # AuthService, UserDocumentService
|
|
335
|
-
β βββ utils/ # Validation, storage adapters
|
|
336
|
-
βββ presentation/ # UI layer
|
|
337
|
-
βββ hooks/ # React hooks
|
|
338
|
-
βββ components/ # React components
|
|
339
|
-
βββ screens/ # Full screens
|
|
340
|
-
βββ stores/ # State management (Zustand)
|
|
341
|
-
βββ navigation/ # Navigation setup
|
|
342
|
-
```
|
|
241
|
+
## Security Requirements
|
|
343
242
|
|
|
344
|
-
|
|
243
|
+
### Rules
|
|
345
244
|
|
|
346
|
-
|
|
245
|
+
**MUST**:
|
|
246
|
+
- Validate all inputs
|
|
247
|
+
- Use HTTPS for all operations
|
|
248
|
+
- Implement proper error handling
|
|
249
|
+
- Follow Firebase security best practices
|
|
250
|
+
- Use secure token storage
|
|
251
|
+
- Validate tokens server-side
|
|
347
252
|
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
| `useProfileUpdate` | Update profile |
|
|
355
|
-
| `useProfileEdit` | Profile editing form state |
|
|
356
|
-
| `useAccountManagement` | Account operations |
|
|
357
|
-
| `useSocialLogin` | Social login management |
|
|
358
|
-
| `useGoogleAuth` | Google authentication |
|
|
359
|
-
| `useAppleAuth` | Apple authentication |
|
|
360
|
-
| `useAuthBottomSheet` | Auth bottom sheet management |
|
|
253
|
+
**MUST NOT**:
|
|
254
|
+
- Store tokens in AsyncStorage
|
|
255
|
+
- Log passwords or tokens
|
|
256
|
+
- Expose sensitive data in errors
|
|
257
|
+
- Skip validation
|
|
258
|
+
- Use HTTP for auth operations
|
|
361
259
|
|
|
362
|
-
|
|
260
|
+
---
|
|
261
|
+
|
|
262
|
+
## Architecture Principles
|
|
263
|
+
|
|
264
|
+
### Domain-Driven Design
|
|
265
|
+
|
|
266
|
+
**PRINCIPLES**:
|
|
267
|
+
- Business logic in domain layer
|
|
268
|
+
- Infrastructure concerns isolated
|
|
269
|
+
- Presentation layer UI-focused
|
|
270
|
+
- Application layer orchestrates
|
|
271
|
+
|
|
272
|
+
**BENEFITS**:
|
|
273
|
+
- Testable business logic
|
|
274
|
+
- Swappable providers
|
|
275
|
+
- Clear separation of concerns
|
|
276
|
+
- Maintainable codebase
|
|
277
|
+
|
|
278
|
+
---
|
|
279
|
+
|
|
280
|
+
## Error Handling
|
|
281
|
+
|
|
282
|
+
### Strategy
|
|
283
|
+
|
|
284
|
+
**Purpose**: Comprehensive error handling throughout application.
|
|
285
|
+
|
|
286
|
+
**Rules**:
|
|
287
|
+
- MUST handle auth errors gracefully
|
|
288
|
+
- MUST show user-friendly messages
|
|
289
|
+
- MUST allow retry after failures
|
|
290
|
+
- MUST log errors for debugging
|
|
291
|
+
- MUST not expose sensitive data
|
|
292
|
+
|
|
293
|
+
**Error Hierarchy**:
|
|
294
|
+
- `AuthError` - Base error class
|
|
295
|
+
- `ValidationError` - Input validation errors
|
|
296
|
+
- `AuthenticationError` - Auth operation errors
|
|
297
|
+
- `NetworkError` - Network issues
|
|
298
|
+
|
|
299
|
+
---
|
|
300
|
+
|
|
301
|
+
## Validation Strategy
|
|
302
|
+
|
|
303
|
+
### Purpose
|
|
304
|
+
|
|
305
|
+
**Purpose**: Ensure data integrity and security.
|
|
306
|
+
|
|
307
|
+
**Rules**:
|
|
308
|
+
- MUST validate email format
|
|
309
|
+
- MUST validate password complexity
|
|
310
|
+
- MUST validate required fields
|
|
311
|
+
- MUST provide clear error messages
|
|
312
|
+
- MUST prevent invalid submissions
|
|
313
|
+
|
|
314
|
+
**Validation Location**: `src/infrastructure/utils/AuthValidation.ts`
|
|
363
315
|
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
-
|
|
390
|
-
-
|
|
391
|
-
-
|
|
392
|
-
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
316
|
+
---
|
|
317
|
+
|
|
318
|
+
## Migration Guide
|
|
319
|
+
|
|
320
|
+
### From Previous Versions
|
|
321
|
+
|
|
322
|
+
**Breaking Changes**:
|
|
323
|
+
- See changelog for details
|
|
324
|
+
- Follow migration steps
|
|
325
|
+
- Update component props
|
|
326
|
+
- Update hook usage
|
|
327
|
+
|
|
328
|
+
**Rules**:
|
|
329
|
+
- MUST read migration guide
|
|
330
|
+
- MUST test thoroughly after upgrade
|
|
331
|
+
- MUST update dependencies
|
|
332
|
+
- MUST check deprecated features
|
|
333
|
+
|
|
334
|
+
---
|
|
335
|
+
|
|
336
|
+
## Performance Considerations
|
|
337
|
+
|
|
338
|
+
### Optimization
|
|
339
|
+
|
|
340
|
+
**Rules**:
|
|
341
|
+
- MUST memoize expensive computations
|
|
342
|
+
- MUST minimize re-renders
|
|
343
|
+
- MUST optimize state updates
|
|
344
|
+
- MUST use efficient selectors
|
|
345
|
+
|
|
346
|
+
**Constraints**:
|
|
347
|
+
- Auth state single source of truth
|
|
348
|
+
- Minimal network requests
|
|
349
|
+
- Efficient validation checks
|
|
350
|
+
- Optimized component rendering
|
|
351
|
+
|
|
352
|
+
---
|
|
353
|
+
|
|
354
|
+
## Testing Strategy
|
|
355
|
+
|
|
356
|
+
### Unit Testing
|
|
357
|
+
|
|
358
|
+
**WHAT TO TEST**:
|
|
359
|
+
- Domain logic and entities
|
|
360
|
+
- Validation utilities
|
|
361
|
+
- Hook behavior
|
|
362
|
+
- Component rendering
|
|
363
|
+
|
|
364
|
+
**RULES**:
|
|
365
|
+
- MUST test auth operations
|
|
366
|
+
- MUST test validation
|
|
367
|
+
- MUST test error handling
|
|
368
|
+
- MUST mock Firebase dependencies
|
|
369
|
+
|
|
370
|
+
---
|
|
402
371
|
|
|
403
372
|
## Contributing
|
|
404
373
|
|
|
405
|
-
|
|
374
|
+
### Development Setup
|
|
375
|
+
|
|
376
|
+
**RULES**:
|
|
377
|
+
- MUST follow DDD principles
|
|
378
|
+
- MUST maintain type safety
|
|
379
|
+
- MUST update documentation
|
|
380
|
+
- MUST add tests for new features
|
|
381
|
+
- MUST follow existing patterns
|
|
382
|
+
|
|
383
|
+
**MUST NOT**:
|
|
384
|
+
- Break DDD layer boundaries
|
|
385
|
+
- Skip documentation
|
|
386
|
+
- Add code without tests
|
|
387
|
+
- Introduce breaking changes without major version bump
|
|
388
|
+
|
|
389
|
+
---
|
|
406
390
|
|
|
407
391
|
## License
|
|
408
392
|
|
|
409
|
-
MIT
|
|
393
|
+
MIT License - See LICENSE file for details
|
|
394
|
+
|
|
395
|
+
---
|
|
396
|
+
|
|
397
|
+
## Support and Documentation
|
|
410
398
|
|
|
411
|
-
|
|
399
|
+
### Documentation Structure
|
|
412
400
|
|
|
413
|
-
|
|
414
|
-
- π¦ Twitter: [@umituz](https://twitter.com/umituz)
|
|
415
|
-
- π» GitHub: [umituz/react-native-auth](https://github.com/umituz/react-native-auth)
|
|
401
|
+
**MAIN README**: This file
|
|
416
402
|
|
|
417
|
-
|
|
403
|
+
**LAYER DOCUMENTATION**:
|
|
404
|
+
- `src/domain/README.md` - Domain layer details
|
|
405
|
+
- `src/application/README.md` - Application layer details
|
|
406
|
+
- `src/infrastructure/README.md` - Infrastructure details
|
|
407
|
+
- `src/presentation/README.md` - Presentation layer details
|
|
418
408
|
|
|
419
|
-
|
|
420
|
-
-
|
|
421
|
-
-
|
|
422
|
-
-
|
|
409
|
+
**COMPONENT/HOOK DOCUMENTATION**:
|
|
410
|
+
- Each component has dedicated .md file
|
|
411
|
+
- Each hook has dedicated .md file
|
|
412
|
+
- Follows Strategy/Rules/Constraints format
|
|
413
|
+
|
|
414
|
+
### Getting Help
|
|
415
|
+
|
|
416
|
+
- Read documentation first
|
|
417
|
+
- Check existing issues
|
|
418
|
+
- Review examples in docs
|
|
419
|
+
- Follow AI agent guidelines
|
|
423
420
|
|
|
424
421
|
---
|
|
425
422
|
|
|
426
|
-
|
|
423
|
+
## Changelog
|
|
424
|
+
|
|
425
|
+
See CHANGELOG.md for version history and changes.
|