@umituz/react-native-auth 3.4.31 → 3.4.32

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,303 +1,340 @@
1
1
  # SocialLoginButtons
2
2
 
3
- Google ve Apple ile social login button'larını gösteren component.
3
+ Component that displays Google and Apple social authentication buttons.
4
4
 
5
- ## Özellikler
5
+ ---
6
6
 
7
- - Google ve Apple login button'ları
8
- - ✅ Loading states
9
- - ✅ Disabled states
10
- - ✅ Platform check (Apple sadece iOS)
11
- - ✅ Localisation desteği
12
- - ✅ Design system uyumlu
7
+ ## Component Overview
13
8
 
14
- ## Kullanım
9
+ ### Strategy
15
10
 
11
+ **Purpose**: Provides pre-built social authentication buttons for Google and Apple with consistent styling, loading states, and platform-specific behavior.
12
+
13
+ **When to Use**:
14
+ - Adding social login options to authentication screens
15
+ - Need quick integration with OAuth providers
16
+ - Want consistent social login UI across app
17
+ - Supporting multiple social providers
18
+
19
+ **Import Path**:
16
20
  ```typescript
17
21
  import { SocialLoginButtons } from '@umituz/react-native-auth';
18
-
19
- function LoginScreen() {
20
- const { signInWithGoogle, googleLoading } = useGoogleAuth({
21
- webClientId: 'your-client-id',
22
- });
23
-
24
- const { signInWithApple, appleLoading } = useAppleAuth();
25
-
26
- return (
27
- <View>
28
- <LoginForm />
29
-
30
- <SocialLoginButtons
31
- enabledProviders={['google', 'apple']}
32
- onGooglePress={signInWithGoogle}
33
- onApplePress={signInWithApple}
34
- googleLoading={googleLoading}
35
- appleLoading={appleLoading}
36
- />
37
- </View>
38
- );
39
- }
40
22
  ```
41
23
 
42
- ## Props
24
+ **Component Location**: `src/presentation/components/SocialLoginButtons.tsx`
43
25
 
44
- | Prop | Tip | Required | Default | Açıklama |
45
- |------|-----|----------|---------|----------|
46
- | `enabledProviders` | `SocialAuthProvider[]` | Yes | - | Aktif provider'lar |
47
- | `onGooglePress` | `() => void` | No | - | Google butonu handler |
48
- | `onApplePress` | `() => void` | No | - | Apple butonu handler |
49
- | `googleLoading` | `boolean` | No | `false` | Google loading durumu |
50
- | `appleLoading` | `boolean` | No | `false` | Apple loading durumu |
51
- | `disabled` | `boolean` | No | `false` | Tüm butonları disable et |
26
+ ---
52
27
 
53
- ### SocialAuthProvider
28
+ ## Provider Configuration
54
29
 
55
- ```typescript
56
- type SocialAuthProvider = 'google' | 'apple';
57
- ```
30
+ ### Strategy
58
31
 
59
- ## Örnekler
32
+ **Purpose**: Configure which social providers to display based on platform and availability.
60
33
 
61
- ### Sadece Google
34
+ **Supported Providers**:
35
+ - `google` - Google OAuth (all platforms)
36
+ - `apple` - Apple Sign In (iOS only)
62
37
 
63
- ```typescript
64
- function LoginScreen() {
65
- const { signInWithGoogle, googleLoading } = useGoogleAuth({
66
- webClientId: Config.GOOGLE_WEB_CLIENT_ID,
67
- });
68
-
69
- return (
70
- <View>
71
- <LoginForm />
72
-
73
- <SocialLoginButtons
74
- enabledProviders={['google']}
75
- onGooglePress={signInWithGoogle}
76
- googleLoading={googleLoading}
77
- />
78
- </View>
79
- );
80
- }
81
- ```
38
+ ### Rules
82
39
 
83
- ### Google ve Apple (iOS)
40
+ **MUST**:
41
+ - Pass `enabledProviders` array with provider names
42
+ - Check provider availability before enabling
43
+ - Provide press handlers for enabled providers
44
+ - Respect platform restrictions (Apple = iOS only)
84
45
 
85
- ```typescript
86
- function LoginScreen() {
87
- const { signInWithGoogle, googleLoading } = useGoogleAuth({
88
- iosClientId: Config.GOOGLE_IOS_CLIENT_ID,
89
- });
90
-
91
- const { signInWithApple, appleLoading } = useAppleAuth();
92
-
93
- return (
94
- <View>
95
- <LoginForm />
96
-
97
- <SocialLoginButtons
98
- enabledProviders={['google', 'apple']}
99
- onGooglePress={signInWithGoogle}
100
- onApplePress={signInWithApple}
101
- googleLoading={googleLoading}
102
- appleLoading={appleLoading}
103
- />
104
- </View>
105
- );
106
- }
107
- ```
46
+ **MUST NOT**:
47
+ - Enable Apple on Android or Web
48
+ - Show provider buttons without press handlers
49
+ - Assume provider is available without checking
108
50
 
109
- ### Platform-Specific Providers
51
+ ### Constraints
110
52
 
111
- ```typescript
112
- function LoginScreen() {
113
- const { signInWithGoogle, googleLoading } = useGoogleAuth({
114
- webClientId: Config.GOOGLE_WEB_CLIENT_ID,
115
- });
116
-
117
- const { signInWithApple, appleLoading, appleAvailable } = useAppleAuth();
118
-
119
- // Sadece mevcut provider'ları göster
120
- const enabledProviders = ['google'];
121
- if (appleAvailable) {
122
- enabledProviders.push('apple');
123
- }
124
-
125
- return (
126
- <View>
127
- <SocialLoginButtons
128
- enabledProviders={enabledProviders}
129
- onGooglePress={signInWithGoogle}
130
- onApplePress={signInWithApple}
131
- googleLoading={googleLoading}
132
- appleLoading={appleLoading}
133
- />
134
- </View>
135
- );
136
- }
137
- ```
53
+ **PLATFORM AVAILABILITY**:
54
+ | Provider | iOS | Android | Web |
55
+ |----------|-----|---------|-----|
56
+ | Google | ✅ | ✅ | ✅ |
57
+ | Apple | ✅ | ❌ | ❌ |
138
58
 
139
- ### Custom Handlers
59
+ **PROVIDER DETECTION**:
60
+ - Use `useGoogleAuth` hook to check Google availability
61
+ - Use `useAppleAuth` hook to check Apple availability
62
+ - Filter enabled providers array based on availability
140
63
 
141
- ```typescript
142
- function LoginScreen() {
143
- const navigation = useNavigation();
144
-
145
- const handleGoogleSignIn = async () => {
146
- try {
147
- const result = await customGoogleSignIn();
148
-
149
- if (result.success) {
150
- navigation.navigate('Home');
151
- } else {
152
- Alert.alert('Hata', result.error);
153
- }
154
- } catch (error) {
155
- Alert.alert('Hata', 'Bir sorun oluştu');
156
- }
157
- };
158
-
159
- const handleAppleSignIn = async () => {
160
- try {
161
- const result = await customAppleSignIn();
162
-
163
- if (result.success) {
164
- navigation.navigate('Home');
165
- } else {
166
- Alert.alert('Hata', result.error);
167
- }
168
- } catch (error) {
169
- Alert.alert('Hata', 'Bir sorun oluştu');
170
- }
171
- };
172
-
173
- return (
174
- <View>
175
- <SocialLoginButtons
176
- enabledProviders={['google', 'apple']}
177
- onGooglePress={handleGoogleSignIn}
178
- onApplePress={handleAppleSignIn}
179
- />
180
- </View>
181
- );
182
- }
183
- ```
64
+ **CONFIGURATION REQUIREMENTS**:
65
+ - Google: Requires client ID configuration
66
+ - Apple: Requires Apple Developer account
67
+ - Both: Requires Firebase project setup
184
68
 
185
- ### Disabled State
69
+ ---
186
70
 
187
- ```typescript
188
- function LoginScreen() {
189
- const [isSubmitting, setIsSubmitting] = useState(false);
190
- const { signInWithGoogle, googleLoading } = useGoogleAuth();
191
-
192
- return (
193
- <View>
194
- <Button onPress={handleSubmit} loading={isSubmitting}>
195
- Giriş Yap
196
- </Button>
197
-
198
- <SocialLoginButtons
199
- enabledProviders={['google']}
200
- onGooglePress={signInWithGoogle}
201
- googleLoading={googleLoading}
202
- disabled={isSubmitting} // Form submit sırasında disable et
203
- />
204
- </View>
205
- );
206
- }
207
- ```
71
+ ## Button State Management
208
72
 
209
- ### Error Handling
73
+ ### Strategy
210
74
 
211
- ```typescript
212
- function LoginScreen() {
213
- const { signInWithGoogle, googleLoading } = useGoogleAuth();
214
- const [error, setError] = useState<string | null>(null);
215
-
216
- const handleGoogleSignIn = async () => {
217
- setError(null);
218
- try {
219
- const result = await signInWithGoogle();
220
-
221
- if (!result.success) {
222
- setError(result.error || 'Google ile giriş başarısız');
223
- }
224
- } catch (err) {
225
- setError(err instanceof Error ? err.message : 'Bir hata oluştu');
226
- }
227
- };
228
-
229
- return (
230
- <View>
231
- {error && <Text style={styles.error}>{error}</Text>}
232
-
233
- <SocialLoginButtons
234
- enabledProviders={['google']}
235
- onGooglePress={handleGoogleSignIn}
236
- googleLoading={googleLoading}
237
- />
238
- </View>
239
- );
240
- }
241
- ```
75
+ **Purpose**: Provide visual feedback for loading, disabled, and error states.
242
76
 
243
- ## Görünüm
77
+ ### Rules
244
78
 
245
- ### Divider
246
- ```
247
- ─────────────────── veya şununla devam et ───────────────────
248
- ```
79
+ **MUST**:
80
+ - Show loading indicator during OAuth flow
81
+ - Disable buttons during authentication
82
+ - Re-enable buttons after completion (success or error)
83
+ - Handle user cancellation gracefully
249
84
 
250
- ### Buttons
251
- ```
252
- ┌─────────────────┐ ┌─────────────────┐
253
- │ G Google │ │ A Apple │
254
- └─────────────────┘ └─────────────────┘
255
- ```
85
+ **MUST NOT**:
86
+ - Leave buttons in loading state indefinitely
87
+ - Allow multiple simultaneous OAuth requests
88
+ - Show loading without active OAuth flow
89
+
90
+ ### Constraints
91
+
92
+ **LOADING STATES**:
93
+ - `googleLoading` - Show Google button in loading state
94
+ - `appleLoading` - Show Apple button in loading state
95
+ - Loading overrides disabled state visually
96
+
97
+ **DISABLED STATES**:
98
+ - Global disabled: All buttons disabled
99
+ - Per-button loading: Only that button disabled
100
+ - Parent form disabled: All social buttons disabled
101
+
102
+ **ERROR RECOVERY**:
103
+ - Auto-recover after cancellation
104
+ - Manual retry required after errors
105
+ - No retry limit (user can try indefinitely)
106
+
107
+ ---
108
+
109
+ ## Platform-Specific Behavior
110
+
111
+ ### Strategy
112
+
113
+ **Purpose**: Optimize social login experience for each platform's conventions.
114
+
115
+ ### Rules
116
+
117
+ **MUST**:
118
+ - Hide Apple button on non-iOS platforms
119
+ - Use platform-appropriate button styles
120
+ - Follow platform OAuth flow conventions
121
+ - Respect platform-specific limitations
122
+
123
+ **MUST NOT**:
124
+ - Show Apple button on Android
125
+ - Force web OAuth flow on native platforms
126
+ - Bypass platform security features
127
+
128
+ ### Constraints
129
+
130
+ **iOS BEHAVIOR**:
131
+ - Apple Sign-In uses native credential UI
132
+ - Google uses app-based OAuth when available
133
+ - Falls back to web OAuth if needed
134
+ - Requires Info.plist configuration
135
+
136
+ **ANDROID BEHAVIOR**:
137
+ - Google uses app-based OAuth
138
+ - Apple button hidden
139
+ - Requires Firebase configuration
140
+ - Requires Google Services JSON
141
+
142
+ **WEB BEHAVIOR**:
143
+ - Both providers use popup/redirect OAuth
144
+ - Requires proper callback handling
145
+ - Requires auth session setup
146
+ - Browser popup blockers may interfere
147
+
148
+ ---
149
+
150
+ ## Error Handling
151
+
152
+ ### Strategy
153
+
154
+ **Purpose**: Gracefully handle OAuth errors without breaking user experience.
256
155
 
257
- ### Loading
156
+ ### Rules
157
+
158
+ **MUST**:
159
+ - Distinguish between user cancellation and errors
160
+ - Show user-friendly error messages
161
+ - Allow retry after errors
162
+ - Log errors for debugging (not to user)
163
+
164
+ **MUST NOT**:
165
+ - Show raw OAuth errors to users
166
+ - Block retry after errors
167
+ - Crash or hang on OAuth failure
168
+ - Expose sensitive tokens in errors
169
+
170
+ ### Constraints
171
+
172
+ **ERROR TYPES**:
173
+ - User cancellation: Silent or gentle notification
174
+ - Network error: Retry prompt
175
+ - Configuration error: Developer-focused message
176
+ - Provider error: Generic "try again" message
177
+
178
+ **ERROR DISPLAY**:
179
+ - Alert/Modal for critical errors
180
+ - Inline text for non-critical errors
181
+ - Toast for success/cancellation
182
+ - Console logging for debugging
183
+
184
+ ---
185
+
186
+ ## Security Requirements
187
+
188
+ ### Strategy
189
+
190
+ **Purpose**: Ensure OAuth authentication follows security best practices.
191
+
192
+ ### Rules
193
+
194
+ **MUST**:
195
+ - Use HTTPS for all OAuth endpoints
196
+ - Store tokens securely (Keychain/Keystore)
197
+ - Never log tokens or credentials
198
+ - Validate tokens server-side
199
+ - Implement token refresh logic
200
+
201
+ **MUST NOT**:
202
+ - Store tokens in AsyncStorage/localStorage
203
+ - Log OAuth responses with tokens
204
+ - Skip server-side token validation
205
+ - Use HTTP for OAuth flows
206
+ - Expose client secrets in app code
207
+
208
+ ### Constraints
209
+
210
+ **TOKEN HANDLING**:
211
+ - Tokens managed by Firebase SDK
212
+ - App never directly accesses refresh tokens
213
+ - ID tokens accessible for API calls
214
+ - Secure storage handled automatically
215
+
216
+ **CLIENT SECRETS**:
217
+ - Never include client secrets in app
218
+ - Use public client flows
219
+ - Server-side validation required
220
+ - Firebase manages OAuth credentials
221
+
222
+ ---
223
+
224
+ ## Localization
225
+
226
+ ### Strategy
227
+
228
+ **Purpose**: Support international users with localized button text and messages.
229
+
230
+ ### Rules
231
+
232
+ **MUST**:
233
+ - Use localization keys for all text
234
+ - Provide translations for supported languages
235
+ - Respect user's language preference
236
+ - Format error messages appropriately
237
+
238
+ **MUST NOT**:
239
+ - Hardcode English text
240
+ - Assume user speaks English
241
+ - Mix languages in UI
242
+
243
+ ### Constraints
244
+
245
+ **LOCALIZATION KEYS**:
258
246
  ```
259
- ┌─────────────────┐
260
- │ ⏳ Yükleniyor... │
261
- └─────────────────┘
247
+ auth.orContinueWith
248
+ auth.google
249
+ auth.apple
250
+ auth.signingIn
262
251
  ```
263
252
 
264
- ## Platform Davranışı
253
+ **SUPPORTED LANGUAGES**:
254
+ - English (default)
255
+ - Turkish
256
+ - Add more via i18n configuration
265
257
 
266
- | Platform | Google | Apple |
267
- |----------|--------|-------|
268
- | iOS | ✅ | ✅ |
269
- | Android | ✅ | ❌ |
270
- | Web | ✅ | ❌ |
258
+ ---
271
259
 
272
- Apple butonu otomatik olarak sadece iOS'ta gösterilir.
260
+ ## Design System Integration
273
261
 
274
- ## Localisation
262
+ ### Strategy
275
263
 
276
- Component localisation kullanır:
264
+ **Purpose**: Consistent styling with application design system.
277
265
 
278
- ```typescript
279
- // Türkçe
280
- "auth.orContinueWith": "veya şununla devam et"
281
- "auth.google": "Google"
282
- "auth.apple": "Apple"
283
- ```
266
+ ### Rules
267
+
268
+ **MUST**:
269
+ - Use design system color tokens
270
+ - Follow design system spacing
271
+ - Match design system button styles
272
+ - Use design system icons/logos
273
+
274
+ **MUST NOT**:
275
+ - Hardcode colors or sizes
276
+ - Use unofficial provider logos
277
+ - Override design system styles
278
+
279
+ ### Constraints
280
+
281
+ **STYLE TOKENS**:
282
+ - Button colors: Design system primary
283
+ - Text colors: Design system text tokens
284
+ - Spacing: Design system spacing scale
285
+ - Border radius: Design system radius tokens
286
+
287
+ **PROVIDER BRANDING**:
288
+ - Use official Google/Apple logos
289
+ - Follow provider brand guidelines
290
+ - Maintain minimum logo sizes
291
+ - Don't modify logo colors
292
+
293
+ ---
294
+
295
+ ## Analytics Integration
296
+
297
+ ### Strategy
298
+
299
+ **Purpose**: Track social login usage for analytics and optimization.
300
+
301
+ ### Rules
302
+
303
+ **MUST**:
304
+ - Track login attempts per provider
305
+ - Track successful logins
306
+ - Track failures (without sensitive data)
307
+ - Track cancellation rates
308
+
309
+ **MUST NOT**:
310
+ - Log personally identifiable information
311
+ - Log OAuth tokens or credentials
312
+ - Track before user consents
313
+ - Expose raw analytics data to users
314
+
315
+ ### Constraints
284
316
 
285
- ## Design System
317
+ **EVENTS TO TRACK**:
318
+ - `social_login_attempt` (provider, platform)
319
+ - `social_login_success` (provider, platform)
320
+ - `social_login_failed` (provider, error_category)
321
+ - `social_login_cancelled` (provider, platform)
286
322
 
287
- Component design system tokens kullanır:
323
+ **PRIVACY**:
324
+ - No user data in events
325
+ - No session identifiers in events
326
+ - Aggregate data only
327
+ - GDPR/CCPA compliant
288
328
 
289
- - `tokens.colors.border` - Border rengi
290
- - `tokens.colors.textPrimary` - Metin rengi
291
- - `tokens.spacing` - Spacing değerleri
329
+ ---
292
330
 
293
- ## İlgili Component'ler
331
+ ## Related Components
294
332
 
295
- - [`LoginForm`](./LoginForm.md) - Login formu
296
- - [`RegisterForm`](./LoginForm.md#registerform) - Kayıt formu
297
- - [`AuthDivider`](./AuthDivider.md) - Divider component'i
333
+ - **`LoginForm`** (`src/presentation/components/LoginForm.tsx`) - Email/password form
334
+ - **`RegisterForm`** (`src/presentation/components/RegisterForm.tsx`) - Registration form
298
335
 
299
- ## İlgili Hook'lar
336
+ ## Related Hooks
300
337
 
301
- - [`useGoogleAuth`](../hooks/useSocialLogin.md#usegoogleauth) - Google auth hook'u
302
- - [`useAppleAuth`](../hooks/useSocialLogin.md#useappleauth) - Apple auth hook'u
303
- - [`useSocialLogin`](../hooks/useSocialLogin.md#usesociallogin) - Genel social login hook'u
338
+ - **`useGoogleAuth`** (`src/presentation/hooks/useSocialLogin.ts`) - Google authentication
339
+ - **`useAppleAuth`** (`src/presentation/hooks/useSocialLogin.ts`) - Apple authentication
340
+ - **`useSocialLogin`** (`src/presentation/hooks/useSocialLogin.ts`) - Combined social auth