@umituz/react-native-auth 3.4.31 → 3.4.33
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/index.ts +35 -0
- 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 +2 -2
- package/src/presentation/components/LoginForm.md +158 -267
- package/src/presentation/components/PasswordIndicators.md +199 -410
- package/src/presentation/components/ProfileComponents.md +322 -376
- package/src/presentation/components/SocialLoginButtons.md +295 -258
- package/src/presentation/hooks/useAccountManagement.md +301 -344
- package/src/presentation/hooks/useAuth.md +271 -227
- package/src/presentation/hooks/useAuthBottomSheet.md +419 -372
- package/src/presentation/hooks/useAuthRequired.md +308 -194
- package/src/presentation/hooks/useProfileUpdate.md +251 -279
- package/src/presentation/hooks/useSocialLogin.md +307 -337
- package/src/presentation/hooks/useUserProfile.md +259 -192
|
@@ -1,411 +1,381 @@
|
|
|
1
1
|
# Social Login Hooks
|
|
2
2
|
|
|
3
|
-
Google
|
|
4
|
-
|
|
5
|
-
## Hooks
|
|
6
|
-
|
|
7
|
-
- **[`useSocialLogin`](#usesociallogin)** - Genel social login yönetimi
|
|
8
|
-
- **[`useGoogleAuth`](#usegoogleauth)** - Google ile giriş (OAuth flow)
|
|
9
|
-
- **[`useAppleAuth`](#useappleauth)** - Apple ile giriş
|
|
3
|
+
Hooks for Google and Apple social authentication.
|
|
10
4
|
|
|
11
5
|
---
|
|
12
6
|
|
|
13
7
|
## useSocialLogin
|
|
14
8
|
|
|
15
|
-
|
|
9
|
+
General social login functionality wrapper.
|
|
10
|
+
|
|
11
|
+
### Strategy
|
|
16
12
|
|
|
17
|
-
|
|
13
|
+
**Purpose**: Provides unified interface for Google and Apple social authentication by wrapping `@umituz/react-native-firebase`'s `useSocialAuth`.
|
|
18
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**:
|
|
19
22
|
```typescript
|
|
20
23
|
import { useSocialLogin } from '@umituz/react-native-auth';
|
|
21
|
-
|
|
22
|
-
function LoginScreen() {
|
|
23
|
-
const {
|
|
24
|
-
signInWithGoogle,
|
|
25
|
-
signInWithApple,
|
|
26
|
-
googleLoading,
|
|
27
|
-
appleLoading,
|
|
28
|
-
googleConfigured,
|
|
29
|
-
appleAvailable,
|
|
30
|
-
} = useSocialLogin({
|
|
31
|
-
google: {
|
|
32
|
-
webClientId: 'your-web-client-id.apps.googleusercontent.com',
|
|
33
|
-
iosClientId: 'your-ios-client-id.apps.googleusercontent.com',
|
|
34
|
-
},
|
|
35
|
-
apple: { enabled: true },
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
return (
|
|
39
|
-
<View>
|
|
40
|
-
<Button
|
|
41
|
-
onPress={signInWithGoogle}
|
|
42
|
-
disabled={googleLoading || !googleConfigured}
|
|
43
|
-
>
|
|
44
|
-
{googleLoading ? 'Giriş yapılıyor...' : 'Google ile Giriş'}
|
|
45
|
-
</Button>
|
|
46
|
-
|
|
47
|
-
<Button
|
|
48
|
-
onPress={signInWithApple}
|
|
49
|
-
disabled={appleLoading || !appleAvailable}
|
|
50
|
-
>
|
|
51
|
-
{appleLoading ? 'Giriş yapılıyor...' : 'Apple ile Giriş'}
|
|
52
|
-
</Button>
|
|
53
|
-
</View>
|
|
54
|
-
);
|
|
55
|
-
}
|
|
56
24
|
```
|
|
57
25
|
|
|
58
|
-
|
|
26
|
+
**Hook Location**: `src/presentation/hooks/useSocialLogin.ts`
|
|
59
27
|
|
|
60
|
-
|
|
28
|
+
**Dependency**: `@umituz/react-native-firebase`
|
|
61
29
|
|
|
62
|
-
|
|
63
|
-
|-------|------|----------|
|
|
64
|
-
| `config` | `UseSocialLoginConfig` | Social auth konfigürasyonu |
|
|
30
|
+
### Rules
|
|
65
31
|
|
|
66
|
-
|
|
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
|
|
67
39
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
androidClientId?: string;
|
|
74
|
-
};
|
|
75
|
-
apple?: {
|
|
76
|
-
enabled: boolean;
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
```
|
|
40
|
+
**MUST NOT**:
|
|
41
|
+
- Show unavailable provider buttons
|
|
42
|
+
- Assume provider is configured
|
|
43
|
+
- Ignore loading states
|
|
44
|
+
- Bypass error handling
|
|
80
45
|
|
|
81
|
-
|
|
46
|
+
### Constraints
|
|
82
47
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
| `signInWithApple` | `() => Promise<SocialAuthResult>` | Apple ile giriş |
|
|
87
|
-
| `googleLoading` | `boolean` | Google giriş loading durumu |
|
|
88
|
-
| `appleLoading` | `boolean` | Apple giriş loading durumu |
|
|
89
|
-
| `googleConfigured` | `boolean` | Google yapılandırılmış mı |
|
|
90
|
-
| `appleAvailable` | `boolean` | Apple mevcut mu (sadece iOS) |
|
|
48
|
+
**CONFIGURATION PARAMETERS**:
|
|
49
|
+
- `google?: GoogleAuthConfig` - Google client IDs
|
|
50
|
+
- `apple?: { enabled: boolean }` - Apple enable flag
|
|
91
51
|
|
|
92
|
-
**
|
|
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)
|
|
93
63
|
|
|
94
64
|
---
|
|
95
65
|
|
|
96
66
|
## useGoogleAuth
|
|
97
67
|
|
|
98
|
-
Google OAuth
|
|
68
|
+
Google OAuth authentication with expo-auth-session.
|
|
69
|
+
|
|
70
|
+
### Strategy
|
|
99
71
|
|
|
100
|
-
|
|
72
|
+
**Purpose**: Complete Google OAuth flow using expo-auth-session for cross-platform support.
|
|
101
73
|
|
|
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
|
|
79
|
+
|
|
80
|
+
**Import Path**:
|
|
102
81
|
```typescript
|
|
103
82
|
import { useGoogleAuth } from '@umituz/react-native-auth';
|
|
104
|
-
|
|
105
|
-
function LoginScreen() {
|
|
106
|
-
const { signInWithGoogle, googleLoading, googleConfigured } = useGoogleAuth({
|
|
107
|
-
iosClientId: 'your-ios-client-id.apps.googleusercontent.com',
|
|
108
|
-
webClientId: 'your-web-client-id.apps.googleusercontent.com',
|
|
109
|
-
androidClientId: 'your-android-client-id.apps.googleusercontent.com',
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
const handleGoogleSignIn = async () => {
|
|
113
|
-
const result = await signInWithGoogle();
|
|
114
|
-
|
|
115
|
-
if (result.success) {
|
|
116
|
-
console.log('Google ile giriş başarılı');
|
|
117
|
-
} else {
|
|
118
|
-
Alert.alert('Hata', result.error || 'Giriş başarısız');
|
|
119
|
-
}
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
return (
|
|
123
|
-
<Button
|
|
124
|
-
onPress={handleGoogleSignIn}
|
|
125
|
-
disabled={googleLoading || !googleConfigured}
|
|
126
|
-
>
|
|
127
|
-
{googleLoading ? 'Giriş yapılıyor...' : 'Google ile Giriş'}
|
|
128
|
-
</Button>
|
|
129
|
-
);
|
|
130
|
-
}
|
|
131
83
|
```
|
|
132
84
|
|
|
133
|
-
|
|
85
|
+
**Hook Location**: `src/presentation/hooks/useSocialLogin.ts`
|
|
134
86
|
|
|
135
|
-
|
|
87
|
+
**Dependencies**:
|
|
88
|
+
- `expo-auth-session`
|
|
89
|
+
- `expo-web-browser`
|
|
90
|
+
- `@react-native-firebase/auth`
|
|
136
91
|
|
|
137
|
-
|
|
138
|
-
|-------|------|----------|----------|
|
|
139
|
-
| `iosClientId` | `string` | No* | iOS için Google Client ID |
|
|
140
|
-
| `webClientId` | `string` | No* | Web için Google Client ID |
|
|
141
|
-
| `androidClientId` | `string` | No* | Android için Google Client ID |
|
|
92
|
+
### Rules
|
|
142
93
|
|
|
143
|
-
|
|
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
|
|
144
100
|
|
|
145
|
-
|
|
101
|
+
**MUST NOT**:
|
|
102
|
+
- Call without client ID configuration
|
|
103
|
+
- Skip web browser setup
|
|
104
|
+
- Ignore platform differences
|
|
105
|
+
- Show button if not configured
|
|
146
106
|
|
|
147
|
-
|
|
148
|
-
|------|-----|----------|
|
|
149
|
-
| `signInWithGoogle` | `() => Promise<SocialAuthResult>` | Google ile giriş fonksiyonu |
|
|
150
|
-
| `googleLoading` | `boolean` | Loading durumu |
|
|
151
|
-
| `googleConfigured` | `boolean` | Yapılandırılmış mı |
|
|
107
|
+
### Constraints
|
|
152
108
|
|
|
153
|
-
|
|
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
|
|
154
114
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
const { signInWithGoogle, googleLoading } = useGoogleAuth({
|
|
160
|
-
iosClientId: Config.GOOGLE_IOS_CLIENT_ID,
|
|
161
|
-
webClientId: Config.GOOGLE_WEB_CLIENT_ID,
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
const { signInWithApple, appleLoading, appleAvailable } = useAppleAuth();
|
|
165
|
-
|
|
166
|
-
return (
|
|
167
|
-
<View style={styles.container}>
|
|
168
|
-
<Text style={styles.title}>Giriş Yap</Text>
|
|
169
|
-
|
|
170
|
-
<TouchableOpacity
|
|
171
|
-
style={styles.googleButton}
|
|
172
|
-
onPress={signInWithGoogle}
|
|
173
|
-
disabled={googleLoading}
|
|
174
|
-
>
|
|
175
|
-
{googleLoading ? (
|
|
176
|
-
<ActivityIndicator />
|
|
177
|
-
) : (
|
|
178
|
-
<>
|
|
179
|
-
<GoogleIcon />
|
|
180
|
-
<Text>Google ile devam et</Text>
|
|
181
|
-
</>
|
|
182
|
-
)}
|
|
183
|
-
</TouchableOpacity>
|
|
184
|
-
|
|
185
|
-
{Platform.OS === 'ios' && appleAvailable && (
|
|
186
|
-
<TouchableOpacity
|
|
187
|
-
style={styles.appleButton}
|
|
188
|
-
onPress={signInWithApple}
|
|
189
|
-
disabled={appleLoading}
|
|
190
|
-
>
|
|
191
|
-
{appleLoading ? (
|
|
192
|
-
<ActivityIndicator />
|
|
193
|
-
) : (
|
|
194
|
-
<>
|
|
195
|
-
<AppleIcon />
|
|
196
|
-
<Text>Apple ile devam et</Text>
|
|
197
|
-
</>
|
|
198
|
-
)}
|
|
199
|
-
</TouchableOpacity>
|
|
200
|
-
)}
|
|
201
|
-
</View>
|
|
202
|
-
);
|
|
203
|
-
}
|
|
204
|
-
```
|
|
115
|
+
**RETURN VALUES**:
|
|
116
|
+
- `signInWithGoogle: () => Promise<SocialAuthResult>` - Sign-in function
|
|
117
|
+
- `googleLoading: boolean` - Loading state
|
|
118
|
+
- `googleConfigured: boolean` - Configuration status
|
|
205
119
|
|
|
206
|
-
|
|
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
|
|
207
125
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
});
|
|
213
|
-
|
|
214
|
-
const handleGoogleSignIn = async () => {
|
|
215
|
-
try {
|
|
216
|
-
const result = await signInWithGoogle();
|
|
217
|
-
|
|
218
|
-
if (result.success) {
|
|
219
|
-
// Başarılı giriş
|
|
220
|
-
navigation.navigate('Home');
|
|
221
|
-
} else {
|
|
222
|
-
// Hata durumunda
|
|
223
|
-
if (result.error?.includes('cancelled')) {
|
|
224
|
-
// Kullanıcı iptal etti
|
|
225
|
-
return;
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
Alert.alert(
|
|
229
|
-
'Giriş Hatası',
|
|
230
|
-
result.error || 'Google ile giriş yapılamadı'
|
|
231
|
-
);
|
|
232
|
-
}
|
|
233
|
-
} catch (error) {
|
|
234
|
-
Alert.alert(
|
|
235
|
-
'Beklenmeyen Hata',
|
|
236
|
-
'Bir hata oluştu. Lütfen daha sonra tekrar deneyin.'
|
|
237
|
-
);
|
|
238
|
-
}
|
|
239
|
-
};
|
|
240
|
-
|
|
241
|
-
return <Button onPress={handleGoogleSignIn} />;
|
|
242
|
-
}
|
|
243
|
-
```
|
|
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)
|
|
244
130
|
|
|
245
131
|
---
|
|
246
132
|
|
|
247
133
|
## useAppleAuth
|
|
248
134
|
|
|
249
|
-
Apple Sign-In
|
|
135
|
+
Apple Sign-In authentication wrapper.
|
|
136
|
+
|
|
137
|
+
### Strategy
|
|
250
138
|
|
|
251
|
-
|
|
139
|
+
**Purpose**: Convenience wrapper for Apple Sign-In functionality on iOS.
|
|
252
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**:
|
|
253
148
|
```typescript
|
|
254
149
|
import { useAppleAuth } from '@umituz/react-native-auth';
|
|
255
|
-
import { Platform } from 'react-native';
|
|
256
|
-
|
|
257
|
-
function LoginScreen() {
|
|
258
|
-
const { signInWithApple, appleLoading, appleAvailable } = useAppleAuth();
|
|
259
|
-
|
|
260
|
-
if (Platform.OS !== 'ios' || !appleAvailable) {
|
|
261
|
-
return null; // Apple sadece iOS'ta çalışır
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
return (
|
|
265
|
-
<TouchableOpacity
|
|
266
|
-
onPress={signInWithApple}
|
|
267
|
-
disabled={appleLoading}
|
|
268
|
-
style={styles.appleButton}
|
|
269
|
-
>
|
|
270
|
-
{appleLoading ? (
|
|
271
|
-
<ActivityIndicator />
|
|
272
|
-
) : (
|
|
273
|
-
<>
|
|
274
|
-
<AppleIcon />
|
|
275
|
-
<Text>Apple ile Giriş</Text>
|
|
276
|
-
</>
|
|
277
|
-
)}
|
|
278
|
-
</TouchableOpacity>
|
|
279
|
-
);
|
|
280
|
-
}
|
|
281
150
|
```
|
|
282
151
|
|
|
283
|
-
|
|
152
|
+
**Hook Location**: `src/presentation/hooks/useSocialLogin.ts`
|
|
284
153
|
|
|
285
|
-
|
|
154
|
+
**Dependencies**:
|
|
155
|
+
- `expo-apple-authentication`
|
|
156
|
+
- `@react-native-firebase/auth`
|
|
286
157
|
|
|
287
|
-
|
|
288
|
-
|------|-----|----------|
|
|
289
|
-
| `signInWithApple` | `() => Promise<SocialAuthResult>` | Apple ile giriş fonksiyonu |
|
|
290
|
-
| `appleLoading` | `boolean` | Loading durumu |
|
|
291
|
-
| `appleAvailable` | `boolean` | Apple Sign-In mevcut mu (iOS only) |
|
|
158
|
+
### Rules
|
|
292
159
|
|
|
293
|
-
|
|
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
|
|
294
165
|
|
|
295
|
-
|
|
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
|
|
296
171
|
|
|
297
|
-
|
|
298
|
-
function SocialLoginButtons() {
|
|
299
|
-
const { signInWithApple, appleLoading, appleAvailable } = useAppleAuth();
|
|
300
|
-
const { signInWithGoogle, googleLoading } = useGoogleAuth({
|
|
301
|
-
webClientId: Config.GOOGLE_WEB_CLIENT_ID,
|
|
302
|
-
});
|
|
303
|
-
|
|
304
|
-
return (
|
|
305
|
-
<View>
|
|
306
|
-
{/* Google - tüm platformlar */}
|
|
307
|
-
<SocialButton
|
|
308
|
-
provider="google"
|
|
309
|
-
onPress={signInWithGoogle}
|
|
310
|
-
loading={googleLoading}
|
|
311
|
-
/>
|
|
312
|
-
|
|
313
|
-
{/* Apple - sadece iOS */}
|
|
314
|
-
{Platform.OS === 'ios' && appleAvailable && (
|
|
315
|
-
<SocialButton
|
|
316
|
-
provider="apple"
|
|
317
|
-
onPress={signInWithApple}
|
|
318
|
-
loading={appleLoading}
|
|
319
|
-
/>
|
|
320
|
-
)}
|
|
321
|
-
</View>
|
|
322
|
-
);
|
|
323
|
-
}
|
|
324
|
-
```
|
|
172
|
+
### Constraints
|
|
325
173
|
|
|
326
|
-
|
|
174
|
+
**RETURN VALUES**:
|
|
175
|
+
- `signInWithApple: () => Promise<SocialAuthResult>` - Sign-in function
|
|
176
|
+
- `appleLoading: boolean` - Loading state
|
|
177
|
+
- `appleAvailable: boolean` - iOS availability status
|
|
327
178
|
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
};
|
|
347
|
-
|
|
348
|
-
if (!appleAvailable) {
|
|
349
|
-
return null;
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
return (
|
|
353
|
-
<TouchableOpacity onPress={handleAppleSignIn} disabled={appleLoading}>
|
|
354
|
-
<Text>Apple ile Giriş</Text>
|
|
355
|
-
</TouchableOpacity>
|
|
356
|
-
);
|
|
357
|
-
}
|
|
358
|
-
```
|
|
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
|
+
---
|
|
359
197
|
|
|
360
198
|
## SocialAuthResult
|
|
361
199
|
|
|
362
|
-
|
|
200
|
+
Common return type for all social auth functions.
|
|
363
201
|
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
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
|
|
371
223
|
|
|
372
|
-
|
|
224
|
+
### Strategy
|
|
373
225
|
|
|
374
|
-
|
|
226
|
+
**Purpose**: Proper setup and configuration for social authentication.
|
|
375
227
|
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
- **Android**: Android uygulamanız için
|
|
382
|
-
- **Web**: Expo/web için
|
|
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
|
|
383
233
|
|
|
384
|
-
|
|
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
|
|
385
239
|
|
|
386
|
-
|
|
387
|
-
2. "Certificates, Identifiers & Profiles" > "Identifiers"
|
|
388
|
-
3. App ID'nizi seçin ve "Sign In with Apple"ı enable edin
|
|
389
|
-
4. Firebase Console'da Apple Sign-In'i enable edin
|
|
240
|
+
### Constraints
|
|
390
241
|
|
|
391
|
-
|
|
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
|
|
281
|
+
|
|
282
|
+
**ERROR TYPES**:
|
|
283
|
+
- User cancellation: Silent handling
|
|
284
|
+
- Network errors: Retry prompt
|
|
285
|
+
- Configuration errors: Developer message
|
|
286
|
+
- Provider errors: Generic "try again"
|
|
287
|
+
|
|
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
|
|
293
|
+
|
|
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
|
|
330
|
+
|
|
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
|
|
344
|
+
|
|
345
|
+
**Constraints**:
|
|
346
|
+
|
|
347
|
+
**iOS**:
|
|
348
|
+
- Apple Sign-In available
|
|
349
|
+
- Google uses app-based OAuth
|
|
350
|
+
- Requires Info.plist configuration
|
|
351
|
+
- Best on physical devices
|
|
352
|
+
|
|
353
|
+
**Android**:
|
|
354
|
+
- Apple Sign-In NOT available
|
|
355
|
+
- Google uses app-based OAuth
|
|
356
|
+
- Requires google-services.json
|
|
357
|
+
- Works on emulator
|
|
358
|
+
|
|
359
|
+
**Web**:
|
|
360
|
+
- Apple Sign-In NOT available
|
|
361
|
+
- Google uses popup OAuth
|
|
362
|
+
- Requires proper callback handling
|
|
363
|
+
- Browser popup blockers
|
|
364
|
+
|
|
365
|
+
---
|
|
392
366
|
|
|
393
|
-
|
|
394
|
-
- `expo-web-browser` kurulumu gerekir
|
|
395
|
-
- `WebBrowser.maybeCompleteAuthSession()` app root'ta çağrılmalı
|
|
396
|
-
- En az bir client ID sağlanmalıdır
|
|
367
|
+
## Related Hooks
|
|
397
368
|
|
|
398
|
-
|
|
399
|
-
-
|
|
400
|
-
- `expo-apple-authentication` kurulumu gerekir
|
|
401
|
-
- Apple Developer hesabı gerekir
|
|
402
|
-
- Test için cihaz gereklidir (simulator'de çalışmayabilir)
|
|
369
|
+
- **`useAuth`** (`src/presentation/hooks/useAuth.ts`) - Core authentication state
|
|
370
|
+
- **`useAuthBottomSheet`** (`src/presentation/hooks/useAuthBottomSheet.md`) - Auth modal integration
|
|
403
371
|
|
|
404
|
-
##
|
|
372
|
+
## Related Components
|
|
405
373
|
|
|
406
|
-
-
|
|
407
|
-
- [`useSocialLogin`](#usesociallogin) - Genel social login yönetimi
|
|
374
|
+
- **`SocialLoginButtons`** (`src/presentation/components/SocialLoginButtons.md`) - Social auth UI
|
|
408
375
|
|
|
409
|
-
##
|
|
376
|
+
## External Dependencies
|
|
410
377
|
|
|
411
|
-
-
|
|
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
|