@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
|
@@ -6,351 +6,376 @@ Hooks for Google and Apple social authentication.
|
|
|
6
6
|
|
|
7
7
|
## useSocialLogin
|
|
8
8
|
|
|
9
|
-
General social login functionality.
|
|
9
|
+
General social login functionality wrapper.
|
|
10
10
|
|
|
11
|
-
###
|
|
11
|
+
### Strategy
|
|
12
12
|
|
|
13
|
+
**Purpose**: Provides unified interface for Google and Apple social authentication by wrapping `@umituz/react-native-firebase`'s `useSocialAuth`.
|
|
14
|
+
|
|
15
|
+
**When to Use**:
|
|
16
|
+
- Need both Google and Apple auth
|
|
17
|
+
- Want unified social auth interface
|
|
18
|
+
- Prefer single hook for multiple providers
|
|
19
|
+
- Don't need provider-specific features
|
|
20
|
+
|
|
21
|
+
**Import Path**:
|
|
13
22
|
```typescript
|
|
14
23
|
import { useSocialLogin } from '@umituz/react-native-auth';
|
|
15
|
-
|
|
16
|
-
function LoginScreen() {
|
|
17
|
-
const {
|
|
18
|
-
signInWithGoogle,
|
|
19
|
-
signInWithApple,
|
|
20
|
-
googleLoading,
|
|
21
|
-
appleLoading,
|
|
22
|
-
googleConfigured,
|
|
23
|
-
appleAvailable,
|
|
24
|
-
} = useSocialLogin({
|
|
25
|
-
google: {
|
|
26
|
-
webClientId: 'your-web-client-id',
|
|
27
|
-
iosClientId: 'your-ios-client-id',
|
|
28
|
-
},
|
|
29
|
-
apple: { enabled: true },
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
return (
|
|
33
|
-
<View>
|
|
34
|
-
<Button onPress={signInWithGoogle} disabled={googleLoading || !googleConfigured}>
|
|
35
|
-
{googleLoading ? 'Signing in...' : 'Sign in with Google'}
|
|
36
|
-
</Button>
|
|
37
|
-
|
|
38
|
-
<Button onPress={signInWithApple} disabled={appleLoading || !appleAvailable}>
|
|
39
|
-
{appleLoading ? 'Signing in...' : 'Sign in with Apple'}
|
|
40
|
-
</Button>
|
|
41
|
-
</View>
|
|
42
|
-
);
|
|
43
|
-
}
|
|
44
24
|
```
|
|
45
25
|
|
|
46
|
-
|
|
26
|
+
**Hook Location**: `src/presentation/hooks/useSocialLogin.ts`
|
|
27
|
+
|
|
28
|
+
**Dependency**: `@umituz/react-native-firebase`
|
|
29
|
+
|
|
30
|
+
### Rules
|
|
31
|
+
|
|
32
|
+
**MUST**:
|
|
33
|
+
- Configure provider settings before use
|
|
34
|
+
- Check provider availability before showing buttons
|
|
35
|
+
- Handle loading states appropriately
|
|
36
|
+
- Display errors to users
|
|
37
|
+
- Check `googleConfigured` before using Google
|
|
38
|
+
- Check `appleAvailable` before using Apple
|
|
39
|
+
|
|
40
|
+
**MUST NOT**:
|
|
41
|
+
- Show unavailable provider buttons
|
|
42
|
+
- Assume provider is configured
|
|
43
|
+
- Ignore loading states
|
|
44
|
+
- Bypass error handling
|
|
45
|
+
|
|
46
|
+
### Constraints
|
|
47
|
+
|
|
48
|
+
**CONFIGURATION PARAMETERS**:
|
|
49
|
+
- `google?: GoogleAuthConfig` - Google client IDs
|
|
50
|
+
- `apple?: { enabled: boolean }` - Apple enable flag
|
|
47
51
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
52
|
+
**RETURN VALUES**:
|
|
53
|
+
- `signInWithGoogle: () => Promise<SocialAuthResult>` - Google sign-in
|
|
54
|
+
- `signInWithApple: () => Promise<SocialAuthResult>` - Apple sign-in
|
|
55
|
+
- `googleLoading: boolean` - Google loading state
|
|
56
|
+
- `appleLoading: boolean` - Apple loading state
|
|
57
|
+
- `googleConfigured: boolean` - Google configuration status
|
|
58
|
+
- `appleAvailable: boolean` - Apple availability status
|
|
59
|
+
|
|
60
|
+
**PLATFORM LIMITATIONS**:
|
|
61
|
+
- Google: All platforms
|
|
62
|
+
- Apple: iOS only (returns `appleAvailable: false` on other platforms)
|
|
56
63
|
|
|
57
64
|
---
|
|
58
65
|
|
|
59
66
|
## useGoogleAuth
|
|
60
67
|
|
|
61
|
-
|
|
68
|
+
Google OAuth authentication with expo-auth-session.
|
|
69
|
+
|
|
70
|
+
### Strategy
|
|
71
|
+
|
|
72
|
+
**Purpose**: Complete Google OAuth flow using expo-auth-session for cross-platform support.
|
|
62
73
|
|
|
63
|
-
|
|
74
|
+
**When to Use**:
|
|
75
|
+
- Need Google OAuth specifically
|
|
76
|
+
- Want full OAuth flow (not just Firebase)
|
|
77
|
+
- Need web/expo support
|
|
78
|
+
- Require custom Google configuration
|
|
64
79
|
|
|
80
|
+
**Import Path**:
|
|
65
81
|
```typescript
|
|
66
82
|
import { useGoogleAuth } from '@umituz/react-native-auth';
|
|
67
|
-
|
|
68
|
-
function LoginScreen() {
|
|
69
|
-
const { signInWithGoogle, googleLoading, googleConfigured } = useGoogleAuth({
|
|
70
|
-
iosClientId: 'your-ios-client-id.apps.googleusercontent.com',
|
|
71
|
-
webClientId: 'your-web-client-id.apps.googleusercontent.com',
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
const handleGoogleSignIn = async () => {
|
|
75
|
-
const result = await signInWithGoogle();
|
|
76
|
-
|
|
77
|
-
if (result.success) {
|
|
78
|
-
console.log('Google sign-in successful');
|
|
79
|
-
} else {
|
|
80
|
-
Alert.alert('Error', result.error || 'Sign-in failed');
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
return (
|
|
85
|
-
<Button onPress={handleGoogleSignIn} disabled={googleLoading || !googleConfigured}>
|
|
86
|
-
Sign in with Google
|
|
87
|
-
</Button>
|
|
88
|
-
);
|
|
89
|
-
}
|
|
90
83
|
```
|
|
91
84
|
|
|
92
|
-
|
|
85
|
+
**Hook Location**: `src/presentation/hooks/useSocialLogin.ts`
|
|
93
86
|
|
|
94
|
-
|
|
87
|
+
**Dependencies**:
|
|
88
|
+
- `expo-auth-session`
|
|
89
|
+
- `expo-web-browser`
|
|
90
|
+
- `@react-native-firebase/auth`
|
|
95
91
|
|
|
96
|
-
|
|
97
|
-
|-------|------|----------|-------------|
|
|
98
|
-
| `iosClientId` | `string` | No* | iOS Google Client ID |
|
|
99
|
-
| `webClientId` | `string` | No* | Web Google Client ID |
|
|
100
|
-
| `androidClientId` | `string` | No* | Android Google Client ID |
|
|
92
|
+
### Rules
|
|
101
93
|
|
|
102
|
-
|
|
94
|
+
**MUST**:
|
|
95
|
+
- Provide at least one client ID
|
|
96
|
+
- Call `WebBrowser.maybeCompleteAuthSession()` in app root
|
|
97
|
+
- Check `googleConfigured` before showing button
|
|
98
|
+
- Handle loading and error states
|
|
99
|
+
- Support platform-specific client IDs
|
|
103
100
|
|
|
104
|
-
|
|
101
|
+
**MUST NOT**:
|
|
102
|
+
- Call without client ID configuration
|
|
103
|
+
- Skip web browser setup
|
|
104
|
+
- Ignore platform differences
|
|
105
|
+
- Show button if not configured
|
|
105
106
|
|
|
106
|
-
|
|
107
|
-
|------|------|-------------|
|
|
108
|
-
| `signInWithGoogle` | `() => Promise<SocialAuthResult>` | Google sign-in function |
|
|
109
|
-
| `googleLoading` | `boolean` | Loading state |
|
|
110
|
-
| `googleConfigured` | `boolean` | Is configured |
|
|
107
|
+
### Constraints
|
|
111
108
|
|
|
112
|
-
|
|
109
|
+
**CLIENT IDs REQUIRED**:
|
|
110
|
+
- `iosClientId?: string` - iOS client ID (optional)
|
|
111
|
+
- `webClientId?: string` - Web client ID (optional)
|
|
112
|
+
- `androidClientId?: string` - Android client ID (optional)
|
|
113
|
+
- At least one MUST be provided
|
|
113
114
|
|
|
114
|
-
|
|
115
|
+
**RETURN VALUES**:
|
|
116
|
+
- `signInWithGoogle: () => Promise<SocialAuthResult>` - Sign-in function
|
|
117
|
+
- `googleLoading: boolean` - Loading state
|
|
118
|
+
- `googleConfigured: boolean` - Configuration status
|
|
115
119
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
const { signInWithApple, appleLoading, appleAvailable } = useAppleAuth();
|
|
124
|
-
|
|
125
|
-
return (
|
|
126
|
-
<View style={styles.container}>
|
|
127
|
-
<Text style={styles.title}>Sign In</Text>
|
|
128
|
-
|
|
129
|
-
<TouchableOpacity
|
|
130
|
-
style={styles.googleButton}
|
|
131
|
-
onPress={signInWithGoogle}
|
|
132
|
-
disabled={googleLoading}
|
|
133
|
-
>
|
|
134
|
-
{googleLoading ? (
|
|
135
|
-
<ActivityIndicator />
|
|
136
|
-
) : (
|
|
137
|
-
<>
|
|
138
|
-
<GoogleIcon />
|
|
139
|
-
<Text>Continue with Google</Text>
|
|
140
|
-
</>
|
|
141
|
-
)}
|
|
142
|
-
</TouchableOpacity>
|
|
143
|
-
|
|
144
|
-
{Platform.OS === 'ios' && appleAvailable && (
|
|
145
|
-
<TouchableOpacity
|
|
146
|
-
style={styles.appleButton}
|
|
147
|
-
onPress={signInWithApple}
|
|
148
|
-
disabled={appleLoading}
|
|
149
|
-
>
|
|
150
|
-
{appleLoading ? (
|
|
151
|
-
<ActivityIndicator />
|
|
152
|
-
) : (
|
|
153
|
-
<>
|
|
154
|
-
<AppleIcon />
|
|
155
|
-
<Text>Continue with Apple</Text>
|
|
156
|
-
</>
|
|
157
|
-
)}
|
|
158
|
-
</TouchableOpacity>
|
|
159
|
-
)}
|
|
160
|
-
</View>
|
|
161
|
-
);
|
|
162
|
-
}
|
|
163
|
-
```
|
|
164
|
-
|
|
165
|
-
#### Error Handling
|
|
120
|
+
**PLATFORM BEHAVIOR**:
|
|
121
|
+
- iOS: Uses `iosClientId` or falls back to `webClientId`
|
|
122
|
+
- Android: Uses `androidClientId` or falls back to `webClientId`
|
|
123
|
+
- Web: Uses `webClientId`
|
|
124
|
+
- Requires OAuth 2.0 client ID from Google Cloud Console
|
|
166
125
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
});
|
|
172
|
-
|
|
173
|
-
const handleGoogleSignIn = async () => {
|
|
174
|
-
try {
|
|
175
|
-
const result = await signInWithGoogle();
|
|
176
|
-
|
|
177
|
-
if (result.success) {
|
|
178
|
-
navigation.navigate('Home');
|
|
179
|
-
} else {
|
|
180
|
-
// User cancelled or error
|
|
181
|
-
if (result.error?.includes('cancelled')) {
|
|
182
|
-
return; // Silent cancel
|
|
183
|
-
}
|
|
184
|
-
Alert.alert('Error', result.error || 'Google sign-in failed');
|
|
185
|
-
}
|
|
186
|
-
} catch (error) {
|
|
187
|
-
Alert.alert('Error', 'An unexpected error occurred');
|
|
188
|
-
}
|
|
189
|
-
};
|
|
190
|
-
|
|
191
|
-
return <Button onPress={handleGoogleSignIn} />;
|
|
192
|
-
}
|
|
193
|
-
```
|
|
126
|
+
**SETUP REQUIREMENTS**:
|
|
127
|
+
- OAuth 2.0 Client ID from Google Cloud Console
|
|
128
|
+
- Authorized redirect URI (auto-configured by expo)
|
|
129
|
+
- Web browser warm-up (maybeCompleteAuthSession)
|
|
194
130
|
|
|
195
131
|
---
|
|
196
132
|
|
|
197
133
|
## useAppleAuth
|
|
198
134
|
|
|
199
|
-
|
|
135
|
+
Apple Sign-In authentication wrapper.
|
|
200
136
|
|
|
201
|
-
###
|
|
137
|
+
### Strategy
|
|
202
138
|
|
|
139
|
+
**Purpose**: Convenience wrapper for Apple Sign-In functionality on iOS.
|
|
140
|
+
|
|
141
|
+
**When to Use**:
|
|
142
|
+
- Need Apple Sign-In specifically
|
|
143
|
+
- Targeting iOS users
|
|
144
|
+
- Want simple Apple auth integration
|
|
145
|
+
- Don't need custom Apple configuration
|
|
146
|
+
|
|
147
|
+
**Import Path**:
|
|
203
148
|
```typescript
|
|
204
149
|
import { useAppleAuth } from '@umituz/react-native-auth';
|
|
205
|
-
import { Platform } from 'react-native';
|
|
206
|
-
|
|
207
|
-
function LoginScreen() {
|
|
208
|
-
const { signInWithApple, appleLoading, appleAvailable } = useAppleAuth();
|
|
209
|
-
|
|
210
|
-
if (Platform.OS !== 'ios' || !appleAvailable) {
|
|
211
|
-
return null;
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
return (
|
|
215
|
-
<TouchableOpacity
|
|
216
|
-
onPress={signInWithApple}
|
|
217
|
-
disabled={appleLoading}
|
|
218
|
-
style={styles.appleButton}
|
|
219
|
-
>
|
|
220
|
-
{appleLoading ? (
|
|
221
|
-
<ActivityIndicator />
|
|
222
|
-
) : (
|
|
223
|
-
<>
|
|
224
|
-
<AppleIcon />
|
|
225
|
-
<Text>Sign in with Apple</Text>
|
|
226
|
-
</>
|
|
227
|
-
)}
|
|
228
|
-
</TouchableOpacity>
|
|
229
|
-
);
|
|
230
|
-
}
|
|
231
150
|
```
|
|
232
151
|
|
|
233
|
-
|
|
152
|
+
**Hook Location**: `src/presentation/hooks/useSocialLogin.ts`
|
|
234
153
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
| `appleLoading` | `boolean` | Loading state |
|
|
239
|
-
| `appleAvailable` | `boolean` | Apple Sign-In is available (iOS only) |
|
|
154
|
+
**Dependencies**:
|
|
155
|
+
- `expo-apple-authentication`
|
|
156
|
+
- `@react-native-firebase/auth`
|
|
240
157
|
|
|
241
|
-
###
|
|
158
|
+
### Rules
|
|
242
159
|
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
});
|
|
249
|
-
|
|
250
|
-
return (
|
|
251
|
-
<View>
|
|
252
|
-
{/* Google - all platforms */}
|
|
253
|
-
<SocialButton
|
|
254
|
-
provider="google"
|
|
255
|
-
onPress={signInWithGoogle}
|
|
256
|
-
loading={googleLoading}
|
|
257
|
-
/>
|
|
258
|
-
|
|
259
|
-
{/* Apple - iOS only */}
|
|
260
|
-
{Platform.OS === 'ios' && appleAvailable && (
|
|
261
|
-
<SocialButton
|
|
262
|
-
provider="apple"
|
|
263
|
-
onPress={signInWithApple}
|
|
264
|
-
loading={appleLoading}
|
|
265
|
-
/>
|
|
266
|
-
)}
|
|
267
|
-
</View>
|
|
268
|
-
);
|
|
269
|
-
}
|
|
270
|
-
```
|
|
160
|
+
**MUST**:
|
|
161
|
+
- Check `appleAvailable` before showing button
|
|
162
|
+
- Handle loading and error states
|
|
163
|
+
- Only show on iOS platform
|
|
164
|
+
- Support Apple Sign-In requirements
|
|
271
165
|
|
|
272
|
-
|
|
166
|
+
**MUST NOT**:
|
|
167
|
+
- Show Apple button on Android/Web
|
|
168
|
+
- Call without availability check
|
|
169
|
+
- Ignore Apple's guidelines
|
|
170
|
+
- Require Apple auth for all users
|
|
273
171
|
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
<Text>Sign in with Apple</Text>
|
|
300
|
-
</TouchableOpacity>
|
|
301
|
-
);
|
|
302
|
-
}
|
|
303
|
-
```
|
|
172
|
+
### Constraints
|
|
173
|
+
|
|
174
|
+
**RETURN VALUES**:
|
|
175
|
+
- `signInWithApple: () => Promise<SocialAuthResult>` - Sign-in function
|
|
176
|
+
- `appleLoading: boolean` - Loading state
|
|
177
|
+
- `appleAvailable: boolean` - iOS availability status
|
|
178
|
+
|
|
179
|
+
**PLATFORM SUPPORT**:
|
|
180
|
+
- iOS: ✅ Fully supported (if configured)
|
|
181
|
+
- Android: ❌ Not supported (appleAvailable = false)
|
|
182
|
+
- Web: ❌ Not supported (appleAvailable = false)
|
|
183
|
+
|
|
184
|
+
**SETUP REQUIREMENTS**:
|
|
185
|
+
- Apple Developer account
|
|
186
|
+
- App ID with Sign In with Apple enabled
|
|
187
|
+
- Firebase Auth with Apple enabled
|
|
188
|
+
- Physical device (may not work in simulator)
|
|
189
|
+
|
|
190
|
+
**APPLE GUIDELINES**:
|
|
191
|
+
- Must offer alternative auth methods
|
|
192
|
+
- Cannot require Apple as only option
|
|
193
|
+
- Must follow Apple's UI guidelines
|
|
194
|
+
- Button design per Apple specifications
|
|
195
|
+
|
|
196
|
+
---
|
|
304
197
|
|
|
305
198
|
## SocialAuthResult
|
|
306
199
|
|
|
307
|
-
|
|
200
|
+
Common return type for all social auth functions.
|
|
308
201
|
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
202
|
+
### Structure
|
|
203
|
+
|
|
204
|
+
**PROPERTIES**:
|
|
205
|
+
- `success: boolean` - Operation success status
|
|
206
|
+
- `error?: string` - Error message if failed
|
|
207
|
+
- `user?: AuthUser` - User object if successful
|
|
208
|
+
|
|
209
|
+
**Rules**:
|
|
210
|
+
- MUST check `success` before using `user`
|
|
211
|
+
- MUST handle `error` if `success = false`
|
|
212
|
+
- MUST NOT assume `user` exists without checking
|
|
213
|
+
|
|
214
|
+
**Constraints**:
|
|
215
|
+
- Always returns success boolean
|
|
216
|
+
- User object only present on success
|
|
217
|
+
- Error string only present on failure
|
|
218
|
+
- Used by all social auth functions
|
|
219
|
+
|
|
220
|
+
---
|
|
221
|
+
|
|
222
|
+
## Configuration Strategy
|
|
223
|
+
|
|
224
|
+
### Strategy
|
|
225
|
+
|
|
226
|
+
**Purpose**: Proper setup and configuration for social authentication.
|
|
227
|
+
|
|
228
|
+
**Rules**:
|
|
229
|
+
- MUST configure OAuth providers in Firebase Console
|
|
230
|
+
- MUST set up projects in provider consoles
|
|
231
|
+
- MUST provide correct client IDs
|
|
232
|
+
- MUST test on physical devices
|
|
233
|
+
|
|
234
|
+
**MUST NOT**:
|
|
235
|
+
- Use development client IDs in production
|
|
236
|
+
- Skip provider console setup
|
|
237
|
+
- Assume configuration is correct
|
|
238
|
+
- Test only on simulator
|
|
239
|
+
|
|
240
|
+
### Constraints
|
|
241
|
+
|
|
242
|
+
**FIREBASE SETUP**:
|
|
243
|
+
- Enable Google Sign-In in Firebase Auth
|
|
244
|
+
- Enable Apple Sign-In in Firebase Auth
|
|
245
|
+
- Configure OAuth consent screen
|
|
246
|
+
- Set up authorized domains
|
|
247
|
+
|
|
248
|
+
**GOOGLE CONSOLE SETUP**:
|
|
249
|
+
1. Go to Google Cloud Console
|
|
250
|
+
2. Create OAuth 2.0 Client IDs
|
|
251
|
+
3. Add authorized redirect URIs
|
|
252
|
+
4. Copy client IDs to app config
|
|
253
|
+
|
|
254
|
+
**APPLE SETUP**:
|
|
255
|
+
1. Apple Developer account
|
|
256
|
+
2. Enable Sign In with Apple for App ID
|
|
257
|
+
3. Create provider ID in Firebase
|
|
258
|
+
4. Configure certificates
|
|
259
|
+
|
|
260
|
+
---
|
|
261
|
+
|
|
262
|
+
## Error Handling
|
|
263
|
+
|
|
264
|
+
### Strategy
|
|
265
|
+
|
|
266
|
+
**Purpose**: Graceful handling of social authentication failures.
|
|
267
|
+
|
|
268
|
+
**Rules**:
|
|
269
|
+
- MUST distinguish cancellation from errors
|
|
270
|
+
- MUST show user-friendly error messages
|
|
271
|
+
- MUST allow retry after failures
|
|
272
|
+
- MUST not crash on auth failures
|
|
273
|
+
|
|
274
|
+
**MUST NOT**:
|
|
275
|
+
- Show raw OAuth errors
|
|
276
|
+
- Block retry indefinitely
|
|
277
|
+
- Crash on provider errors
|
|
278
|
+
- Expose sensitive tokens in errors
|
|
279
|
+
|
|
280
|
+
### Constraints
|
|
316
281
|
|
|
317
|
-
|
|
282
|
+
**ERROR TYPES**:
|
|
283
|
+
- User cancellation: Silent handling
|
|
284
|
+
- Network errors: Retry prompt
|
|
285
|
+
- Configuration errors: Developer message
|
|
286
|
+
- Provider errors: Generic "try again"
|
|
318
287
|
|
|
319
|
-
|
|
288
|
+
**CANCELLATION HANDLING**:
|
|
289
|
+
- Check error message for "cancelled"
|
|
290
|
+
- Don't show error for cancellation
|
|
291
|
+
- Allow retry without blocking
|
|
292
|
+
- Silent return preferred
|
|
320
293
|
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
294
|
+
---
|
|
295
|
+
|
|
296
|
+
## Security Requirements
|
|
297
|
+
|
|
298
|
+
### Strategy
|
|
299
|
+
|
|
300
|
+
**Purpose**: Secure social authentication implementation.
|
|
301
|
+
|
|
302
|
+
**Rules**:
|
|
303
|
+
- MUST use HTTPS for all OAuth endpoints
|
|
304
|
+
- MUST store tokens securely
|
|
305
|
+
- MUST validate tokens server-side
|
|
306
|
+
- MUST never log OAuth credentials
|
|
307
|
+
- MUST implement token refresh
|
|
308
|
+
|
|
309
|
+
**MUST NOT**:
|
|
310
|
+
- Store tokens in AsyncStorage
|
|
311
|
+
- Log OAuth responses
|
|
312
|
+
- Skip server-side validation
|
|
313
|
+
- Expose client secrets
|
|
314
|
+
- Use HTTP for OAuth flows
|
|
315
|
+
|
|
316
|
+
### Constraints
|
|
317
|
+
|
|
318
|
+
**TOKEN HANDLING**:
|
|
319
|
+
- Tokens managed by Firebase SDK
|
|
320
|
+
- Secure storage automatic
|
|
321
|
+
- App never accesses refresh tokens
|
|
322
|
+
- ID tokens available for API calls
|
|
323
|
+
- Token refresh handled by Firebase
|
|
324
|
+
|
|
325
|
+
**CLIENT SECRETS**:
|
|
326
|
+
- Never included in app code
|
|
327
|
+
- Public client flows only
|
|
328
|
+
- Server-side validation required
|
|
329
|
+
- Firebase manages credentials
|
|
328
330
|
|
|
329
|
-
|
|
331
|
+
---
|
|
332
|
+
|
|
333
|
+
## Platform-Specific Behavior
|
|
334
|
+
|
|
335
|
+
### Strategy
|
|
336
|
+
|
|
337
|
+
**Purpose**: Optimize social auth experience for each platform.
|
|
338
|
+
|
|
339
|
+
**Rules**:
|
|
340
|
+
- MUST respect platform limitations
|
|
341
|
+
- MUST use appropriate client IDs
|
|
342
|
+
- MUST handle platform-specific errors
|
|
343
|
+
- MUST test on target platforms
|
|
330
344
|
|
|
331
|
-
|
|
332
|
-
2. Navigate to "Certificates, Identifiers & Profiles" > "Identifiers"
|
|
333
|
-
3. Select your App ID and enable "Sign In with Apple"
|
|
334
|
-
4. Enable Apple Sign-In in Firebase Console
|
|
345
|
+
**Constraints**:
|
|
335
346
|
|
|
336
|
-
|
|
347
|
+
**iOS**:
|
|
348
|
+
- Apple Sign-In available
|
|
349
|
+
- Google uses app-based OAuth
|
|
350
|
+
- Requires Info.plist configuration
|
|
351
|
+
- Best on physical devices
|
|
337
352
|
|
|
338
|
-
|
|
339
|
-
-
|
|
340
|
-
-
|
|
341
|
-
-
|
|
353
|
+
**Android**:
|
|
354
|
+
- Apple Sign-In NOT available
|
|
355
|
+
- Google uses app-based OAuth
|
|
356
|
+
- Requires google-services.json
|
|
357
|
+
- Works on emulator
|
|
342
358
|
|
|
343
|
-
|
|
344
|
-
-
|
|
345
|
-
-
|
|
346
|
-
- Requires
|
|
347
|
-
-
|
|
359
|
+
**Web**:
|
|
360
|
+
- Apple Sign-In NOT available
|
|
361
|
+
- Google uses popup OAuth
|
|
362
|
+
- Requires proper callback handling
|
|
363
|
+
- Browser popup blockers
|
|
364
|
+
|
|
365
|
+
---
|
|
348
366
|
|
|
349
367
|
## Related Hooks
|
|
350
368
|
|
|
351
|
-
-
|
|
352
|
-
-
|
|
369
|
+
- **`useAuth`** (`src/presentation/hooks/useAuth.ts`) - Core authentication state
|
|
370
|
+
- **`useAuthBottomSheet`** (`src/presentation/hooks/useAuthBottomSheet.md`) - Auth modal integration
|
|
353
371
|
|
|
354
372
|
## Related Components
|
|
355
373
|
|
|
356
|
-
-
|
|
374
|
+
- **`SocialLoginButtons`** (`src/presentation/components/SocialLoginButtons.md`) - Social auth UI
|
|
375
|
+
|
|
376
|
+
## External Dependencies
|
|
377
|
+
|
|
378
|
+
- **`@umituz/react-native-firebase`** - Firebase social auth wrapper
|
|
379
|
+
- **`expo-auth-session`** - OAuth session management
|
|
380
|
+
- **`expo-web-browser`** - Web browser for OAuth
|
|
381
|
+
- **`expo-apple-authentication`** - Apple Sign-In
|