@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,20 +1,14 @@
1
1
  # Social Login Hooks
2
2
 
3
- Google ve Apple ile social authentication işlemleri için hooks.
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
- Genel social login işlevselliği sağlar. `@umituz/react-native-firebase` paketinin `useSocialAuth` hook'unu wrap'ler.
9
+ General social login functionality. Wraps `@umituz/react-native-firebase`'s `useSocialAuth`.
16
10
 
17
- ### Kullanım
11
+ ### Usage
18
12
 
19
13
  ```typescript
20
14
  import { useSocialLogin } from '@umituz/react-native-auth';
@@ -29,26 +23,20 @@ function LoginScreen() {
29
23
  appleAvailable,
30
24
  } = useSocialLogin({
31
25
  google: {
32
- webClientId: 'your-web-client-id.apps.googleusercontent.com',
33
- iosClientId: 'your-ios-client-id.apps.googleusercontent.com',
26
+ webClientId: 'your-web-client-id',
27
+ iosClientId: 'your-ios-client-id',
34
28
  },
35
29
  apple: { enabled: true },
36
30
  });
37
31
 
38
32
  return (
39
33
  <View>
40
- <Button
41
- onPress={signInWithGoogle}
42
- disabled={googleLoading || !googleConfigured}
43
- >
44
- {googleLoading ? 'Giriş yapılıyor...' : 'Google ile Giriş'}
34
+ <Button onPress={signInWithGoogle} disabled={googleLoading || !googleConfigured}>
35
+ {googleLoading ? 'Signing in...' : 'Sign in with Google'}
45
36
  </Button>
46
37
 
47
- <Button
48
- onPress={signInWithApple}
49
- disabled={appleLoading || !appleAvailable}
50
- >
51
- {appleLoading ? 'Giriş yapılıyor...' : 'Apple ile Giriş'}
38
+ <Button onPress={signInWithApple} disabled={appleLoading || !appleAvailable}>
39
+ {appleLoading ? 'Signing in...' : 'Sign in with Apple'}
52
40
  </Button>
53
41
  </View>
54
42
  );
@@ -57,47 +45,22 @@ function LoginScreen() {
57
45
 
58
46
  ### API
59
47
 
60
- #### Parameters
61
-
62
- | Param | Tip | Açıklama |
63
- |-------|------|----------|
64
- | `config` | `UseSocialLoginConfig` | Social auth konfigürasyonu |
65
-
66
- #### UseSocialLoginConfig
67
-
68
- ```typescript
69
- interface UseSocialLoginConfig {
70
- google?: {
71
- iosClientId?: string;
72
- webClientId?: string;
73
- androidClientId?: string;
74
- };
75
- apple?: {
76
- enabled: boolean;
77
- };
78
- }
79
- ```
80
-
81
- #### Return Value
82
-
83
- | Prop | Tip | Açıklama |
84
- |------|-----|----------|
85
- | `signInWithGoogle` | `() => Promise<SocialAuthResult>` | Google ile giriş (Not: `useGoogleAuth` kullanın) |
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) |
91
-
92
- **Not:** `signInWithGoogle` için tam OAuth flow'u `useGoogleAuth` hook'unu kullanın.
48
+ | Prop | Type | Description |
49
+ |------|------|-------------|
50
+ | `signInWithGoogle` | `() => Promise<SocialAuthResult>` | Google sign-in (use `useGoogleAuth` for OAuth) |
51
+ | `signInWithApple` | `() => Promise<SocialAuthResult>` | Apple sign-in |
52
+ | `googleLoading` | `boolean` | Google loading state |
53
+ | `appleLoading` | `boolean` | Apple loading state |
54
+ | `googleConfigured` | `boolean` | Google is configured |
55
+ | `appleAvailable` | `boolean` | Apple is available (iOS only) |
93
56
 
94
57
  ---
95
58
 
96
59
  ## useGoogleAuth
97
60
 
98
- Google OAuth flow'unu `expo-auth-session` kullanarak yönetir ve Firebase authentication ile entegre eder.
61
+ Handles complete Google OAuth flow with `expo-auth-session`.
99
62
 
100
- ### Kullanım
63
+ ### Usage
101
64
 
102
65
  ```typescript
103
66
  import { useGoogleAuth } from '@umituz/react-native-auth';
@@ -106,25 +69,21 @@ function LoginScreen() {
106
69
  const { signInWithGoogle, googleLoading, googleConfigured } = useGoogleAuth({
107
70
  iosClientId: 'your-ios-client-id.apps.googleusercontent.com',
108
71
  webClientId: 'your-web-client-id.apps.googleusercontent.com',
109
- androidClientId: 'your-android-client-id.apps.googleusercontent.com',
110
72
  });
111
73
 
112
74
  const handleGoogleSignIn = async () => {
113
75
  const result = await signInWithGoogle();
114
76
 
115
77
  if (result.success) {
116
- console.log('Google ile giriş başarılı');
78
+ console.log('Google sign-in successful');
117
79
  } else {
118
- Alert.alert('Hata', result.error || 'Giriş başarısız');
80
+ Alert.alert('Error', result.error || 'Sign-in failed');
119
81
  }
120
82
  };
121
83
 
122
84
  return (
123
- <Button
124
- onPress={handleGoogleSignIn}
125
- disabled={googleLoading || !googleConfigured}
126
- >
127
- {googleLoading ? 'Giriş yapılıyor...' : 'Google ile Giriş'}
85
+ <Button onPress={handleGoogleSignIn} disabled={googleLoading || !googleConfigured}>
86
+ Sign in with Google
128
87
  </Button>
129
88
  );
130
89
  }
@@ -134,25 +93,25 @@ function LoginScreen() {
134
93
 
135
94
  #### Parameters
136
95
 
137
- | Param | Tip | Required | Açıklama |
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 |
96
+ | Param | Type | Required | Description |
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 |
142
101
 
143
- *En az biri sağlanmalıdır.
102
+ *At least one must be provided
144
103
 
145
104
  #### Return Value
146
105
 
147
- | Prop | Tip | Açıklama |
148
- |------|-----|----------|
149
- | `signInWithGoogle` | `() => Promise<SocialAuthResult>` | Google ile giriş fonksiyonu |
150
- | `googleLoading` | `boolean` | Loading durumu |
151
- | `googleConfigured` | `boolean` | Yapılandırılmış |
106
+ | Prop | Type | Description |
107
+ |------|------|-------------|
108
+ | `signInWithGoogle` | `() => Promise<SocialAuthResult>` | Google sign-in function |
109
+ | `googleLoading` | `boolean` | Loading state |
110
+ | `googleConfigured` | `boolean` | Is configured |
152
111
 
153
- ### Örnekler
112
+ ### Examples
154
113
 
155
- #### Google ile Giriş Ekranı
114
+ #### Google Sign-In Screen
156
115
 
157
116
  ```typescript
158
117
  function SocialLoginScreen() {
@@ -165,7 +124,7 @@ function SocialLoginScreen() {
165
124
 
166
125
  return (
167
126
  <View style={styles.container}>
168
- <Text style={styles.title}>Giriş Yap</Text>
127
+ <Text style={styles.title}>Sign In</Text>
169
128
 
170
129
  <TouchableOpacity
171
130
  style={styles.googleButton}
@@ -177,7 +136,7 @@ function SocialLoginScreen() {
177
136
  ) : (
178
137
  <>
179
138
  <GoogleIcon />
180
- <Text>Google ile devam et</Text>
139
+ <Text>Continue with Google</Text>
181
140
  </>
182
141
  )}
183
142
  </TouchableOpacity>
@@ -193,7 +152,7 @@ function SocialLoginScreen() {
193
152
  ) : (
194
153
  <>
195
154
  <AppleIcon />
196
- <Text>Apple ile devam et</Text>
155
+ <Text>Continue with Apple</Text>
197
156
  </>
198
157
  )}
199
158
  </TouchableOpacity>
@@ -203,7 +162,7 @@ function SocialLoginScreen() {
203
162
  }
204
163
  ```
205
164
 
206
- #### Hata Yönetimi
165
+ #### Error Handling
207
166
 
208
167
  ```typescript
209
168
  function LoginWithErrorHandling() {
@@ -216,25 +175,16 @@ function LoginWithErrorHandling() {
216
175
  const result = await signInWithGoogle();
217
176
 
218
177
  if (result.success) {
219
- // Başarılı giriş
220
178
  navigation.navigate('Home');
221
179
  } else {
222
- // Hata durumunda
180
+ // User cancelled or error
223
181
  if (result.error?.includes('cancelled')) {
224
- // Kullanıcı iptal etti
225
- return;
182
+ return; // Silent cancel
226
183
  }
227
-
228
- Alert.alert(
229
- 'Giriş Hatası',
230
- result.error || 'Google ile giriş yapılamadı'
231
- );
184
+ Alert.alert('Error', result.error || 'Google sign-in failed');
232
185
  }
233
186
  } catch (error) {
234
- Alert.alert(
235
- 'Beklenmeyen Hata',
236
- 'Bir hata oluştu. Lütfen daha sonra tekrar deneyin.'
237
- );
187
+ Alert.alert('Error', 'An unexpected error occurred');
238
188
  }
239
189
  };
240
190
 
@@ -246,9 +196,9 @@ function LoginWithErrorHandling() {
246
196
 
247
197
  ## useAppleAuth
248
198
 
249
- Apple Sign-In işlevselliği sağlar. Sadece iOS'ta mevcuttur.
199
+ Convenience wrapper for Apple Sign-In.
250
200
 
251
- ### Kullanım
201
+ ### Usage
252
202
 
253
203
  ```typescript
254
204
  import { useAppleAuth } from '@umituz/react-native-auth';
@@ -258,7 +208,7 @@ function LoginScreen() {
258
208
  const { signInWithApple, appleLoading, appleAvailable } = useAppleAuth();
259
209
 
260
210
  if (Platform.OS !== 'ios' || !appleAvailable) {
261
- return null; // Apple sadece iOS'ta çalışır
211
+ return null;
262
212
  }
263
213
 
264
214
  return (
@@ -272,7 +222,7 @@ function LoginScreen() {
272
222
  ) : (
273
223
  <>
274
224
  <AppleIcon />
275
- <Text>Apple ile Giriş</Text>
225
+ <Text>Sign in with Apple</Text>
276
226
  </>
277
227
  )}
278
228
  </TouchableOpacity>
@@ -282,17 +232,13 @@ function LoginScreen() {
282
232
 
283
233
  ### API
284
234
 
285
- #### Return Value
286
-
287
- | Prop | Tip | Açıklama |
288
- |------|-----|----------|
289
- | `signInWithApple` | `() => Promise<SocialAuthResult>` | Apple ile giriş fonksiyonu |
290
- | `appleLoading` | `boolean` | Loading durumu |
291
- | `appleAvailable` | `boolean` | Apple Sign-In mevcut mu (iOS only) |
292
-
293
- ### Örnekler
235
+ | Prop | Type | Description |
236
+ |------|------|-------------|
237
+ | `signInWithApple` | `() => Promise<SocialAuthResult>` | Apple sign-in function |
238
+ | `appleLoading` | `boolean` | Loading state |
239
+ | `appleAvailable` | `boolean` | Apple Sign-In is available (iOS only) |
294
240
 
295
- #### Platform-Specific Apple Button
241
+ ### Platform-Specific Button
296
242
 
297
243
  ```typescript
298
244
  function SocialLoginButtons() {
@@ -303,14 +249,14 @@ function SocialLoginButtons() {
303
249
 
304
250
  return (
305
251
  <View>
306
- {/* Google - tüm platformlar */}
252
+ {/* Google - all platforms */}
307
253
  <SocialButton
308
254
  provider="google"
309
255
  onPress={signInWithGoogle}
310
256
  loading={googleLoading}
311
257
  />
312
258
 
313
- {/* Apple - sadece iOS */}
259
+ {/* Apple - iOS only */}
314
260
  {Platform.OS === 'ios' && appleAvailable && (
315
261
  <SocialButton
316
262
  provider="apple"
@@ -323,7 +269,7 @@ function SocialLoginButtons() {
323
269
  }
324
270
  ```
325
271
 
326
- #### Apple ile Giriş ve Hata Yönetimi
272
+ ### Apple Sign-In with Error Handling
327
273
 
328
274
  ```typescript
329
275
  function AppleLoginButton() {
@@ -333,14 +279,13 @@ function AppleLoginButton() {
333
279
  const result = await signInWithApple();
334
280
 
335
281
  if (result.success) {
336
- console.log('Apple ile giriş başarılı');
337
- // Kullanıcıyı ana ekrana yönlendir
282
+ console.log('Apple sign-in successful');
338
283
  } else {
339
- // Hata yönetimi
284
+ // Handle error
340
285
  if (result.error?.includes('cancelled')) {
341
- console.log('Kullanıcı iptal etti');
286
+ console.log('User cancelled');
342
287
  } else {
343
- Alert.alert('Hata', result.error || 'Apple ile giriş yapılamadı');
288
+ Alert.alert('Error', result.error || 'Apple sign-in failed');
344
289
  }
345
290
  }
346
291
  };
@@ -351,7 +296,7 @@ function AppleLoginButton() {
351
296
 
352
297
  return (
353
298
  <TouchableOpacity onPress={handleAppleSignIn} disabled={appleLoading}>
354
- <Text>Apple ile Giriş</Text>
299
+ <Text>Sign in with Apple</Text>
355
300
  </TouchableOpacity>
356
301
  );
357
302
  }
@@ -359,7 +304,7 @@ function AppleLoginButton() {
359
304
 
360
305
  ## SocialAuthResult
361
306
 
362
- Tüm social login fonksiyonları aynı result tipini döner:
307
+ All social login functions return the same type:
363
308
 
364
309
  ```typescript
365
310
  interface SocialAuthResult {
@@ -369,43 +314,43 @@ interface SocialAuthResult {
369
314
  }
370
315
  ```
371
316
 
372
- ## Konfigürasyon
317
+ ## Configuration
373
318
 
374
- ### Google Client ID Almak
319
+ ### Get Google Client ID
375
320
 
376
- 1. [Google Cloud Console](https://console.cloud.google.com/)'a gidin
377
- 2. Yeni bir proje oluşturun veya mevcut projeyi seçin
378
- 3. "APIs & Services" > "Credentials" sayfasına gidin
379
- 4. "OAuth 2.0 Client IDs" oluşturun:
380
- - **iOS**: iOS uygulamanız için
381
- - **Android**: Android uygulamanız için
382
- - **Web**: Expo/web için
321
+ 1. Go to [Google Cloud Console](https://console.cloud.google.com/)
322
+ 2. Create a new project or select existing
323
+ 3. Navigate to "APIs & Services" > "Credentials"
324
+ 4. Create "OAuth 2.0 Client IDs":
325
+ - **iOS**: For your iOS app
326
+ - **Android**: For your Android app
327
+ - **Web**: For Expo/web
383
328
 
384
- ### Apple Sign-In Konfigürasyonu
329
+ ### Configure Apple Sign-In
385
330
 
386
- 1. [Apple Developer](https://developer.apple.com/)'da gidin
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
331
+ 1. Go to [Apple Developer](https://developer.apple.com/)
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
390
335
 
391
- ## Önemli Notlar
336
+ ## Important Notes
392
337
 
393
338
  ### Google
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
339
+ - Requires `expo-web-browser` setup
340
+ - `WebBrowser.maybeCompleteAuthSession()` must be called in app root
341
+ - At least one client ID must be provided
397
342
 
398
343
  ### Apple
399
- - Sadece iOS'ta mevcuttur
400
- - `expo-apple-authentication` kurulumu gerekir
401
- - Apple Developer hesabı gerekir
402
- - Test için cihaz gereklidir (simulator'de çalışmayabilir)
344
+ - Only available on iOS
345
+ - Requires `expo-apple-authentication` setup
346
+ - Requires Apple Developer account
347
+ - Testing requires a physical device (may not work in simulator)
403
348
 
404
- ## İlgili Hook'lar
349
+ ## Related Hooks
405
350
 
406
- - [`useAuth`](./useAuth.md) - Ana auth state yönetimi
407
- - [`useSocialLogin`](#usesociallogin) - Genel social login yönetimi
351
+ - [`useAuth`](./useAuth.md) - Main auth state management
352
+ - [`useSocialLogin`](#usesociallogin) - General social login
408
353
 
409
- ## İlgili Component'ler
354
+ ## Related Components
410
355
 
411
- - [`SocialLoginButtons`](../components/SocialLoginButtons.md) - Social login button component'i
356
+ - [`SocialLoginButtons`](../components/SocialLoginButtons.md) - Social login button component