react-native-oauth-essentials 1.0.2 → 1.0.4
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 +511 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -8,7 +8,517 @@ API. It's a must-have for every React Native app.
|
|
|
8
8
|
|
|
9
9
|
[Installation](./installation.md)
|
|
10
10
|
|
|
11
|
-
[Usage](./usage)
|
|
11
|
+
[Usage](./usage)no
|
|
12
|
+
## Usage
|
|
13
|
+
|
|
14
|
+
### Platform Support Details
|
|
15
|
+
|
|
16
|
+
This library provides native OAuth implementations with platform-specific behaviors and requirements:
|
|
17
|
+
|
|
18
|
+
#### Google Sign-In
|
|
19
|
+
|
|
20
|
+
**iOS:**
|
|
21
|
+
- **Minimum:** iOS 13+
|
|
22
|
+
- Uses native iOS Google Sign-In SDK
|
|
23
|
+
- Presents native iOS authentication UI
|
|
24
|
+
- No Google Play Services dependency
|
|
25
|
+
- Requires Google OAuth 2.0 Web Client ID from Google Cloud Console
|
|
26
|
+
- Supports One Tap sign-in experience
|
|
27
|
+
- Available: `GOOGLE_ID_SUPPORTED` constant
|
|
28
|
+
|
|
29
|
+
**Android:**
|
|
30
|
+
- **Minimum:** Android 8.0+ (API 26+)
|
|
31
|
+
- Uses Credential Manager API with Google ID provider
|
|
32
|
+
- Requires Google Play Services to be installed and up-to-date
|
|
33
|
+
- Check `GOOGLE_PLAY_SERVICES_SUPPORTED` before using
|
|
34
|
+
- Supports additional options: `authorizedAccounts` and `autoSelectEnabled`
|
|
35
|
+
- Presents native Android credential picker UI
|
|
36
|
+
- Requires Google OAuth 2.0 Web Client ID from Google Cloud Console
|
|
37
|
+
- Available: `GOOGLE_ID_SUPPORTED` constant
|
|
38
|
+
|
|
39
|
+
**Common Features:**
|
|
40
|
+
- Returns standardized `GoogleIdCredentialResult` with user profile data
|
|
41
|
+
- Includes ID token for backend verification
|
|
42
|
+
- User can cancel, returning `CancelledCredentialResult`
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
#### Apple Sign-In
|
|
47
|
+
|
|
48
|
+
**iOS:**
|
|
49
|
+
- **Minimum:** iOS 13+
|
|
50
|
+
- Uses native `AuthenticationServices` framework
|
|
51
|
+
- Presents native Apple Sign-In UI sheet
|
|
52
|
+
- Full integration with iOS Keychain
|
|
53
|
+
- Returns `AppleIdCredentialResult` with:
|
|
54
|
+
- ID token and authorization code
|
|
55
|
+
- User identifier (stable across app reinstalls)
|
|
56
|
+
- Email and full name (only on first sign-in)
|
|
57
|
+
- Real user indicator (`likelyReal`)
|
|
58
|
+
- Caches email and fullName for subsequent sign-ins
|
|
59
|
+
- No additional configuration needed
|
|
60
|
+
- Available: `APPLE_ID_SUPPORTED` constant
|
|
61
|
+
|
|
62
|
+
**Android:**
|
|
63
|
+
- **Minimum:** Android 8.0+ (API 26+)
|
|
64
|
+
- Uses browser-based OAuth flow via Chrome Custom Tabs (no native Apple Sign-In on Android)
|
|
65
|
+
- Opens device's default browser with your provided `androidWebUrl`
|
|
66
|
+
- Returns `WebAppleIdCredentialResult` with redirect URL components
|
|
67
|
+
- **Requires backend implementation** to handle OAuth flow
|
|
68
|
+
- You must implement Apple Sign-In REST API on your server
|
|
69
|
+
- See [Apple Sign-In REST API Documentation](https://developer.apple.com/documentation/signinwithapplerestapi)
|
|
70
|
+
- Available: `APPLE_ID_SUPPORTED` constant
|
|
71
|
+
|
|
72
|
+
**Implementation Note:** iOS provides a complete native experience, while Android uses Chrome Custom Tabs to open your OAuth endpoint in the browser, then captures the redirect URL.
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
#### Password Sign-In
|
|
77
|
+
|
|
78
|
+
**iOS:**
|
|
79
|
+
- **Minimum:** iOS 12+
|
|
80
|
+
- Uses iOS Keychain Services
|
|
81
|
+
- Integrates with iCloud Keychain for sync across devices
|
|
82
|
+
- Presents native password autofill UI
|
|
83
|
+
- Supports AutoFill in WebViews
|
|
84
|
+
- Available: `PASSWORD_SUPPORTED` constant
|
|
85
|
+
|
|
86
|
+
**Android:**
|
|
87
|
+
- **Minimum:** Android 7.0+ (API 24+)
|
|
88
|
+
- Uses Credential Manager API
|
|
89
|
+
- Integrates with Google Smart Lock for Passwords
|
|
90
|
+
- Can sync credentials across devices via Google account
|
|
91
|
+
- Presents native credential picker UI
|
|
92
|
+
- Supports autofill in WebViews and native forms
|
|
93
|
+
- Available: `PASSWORD_SUPPORTED` constant
|
|
94
|
+
|
|
95
|
+
**Common Features:**
|
|
96
|
+
- `passwordSignIn()` - Saves credentials securely
|
|
97
|
+
- `getPassword()` - Retrieves stored credentials
|
|
98
|
+
- Returns `PasswordCredentialResult` with username and password
|
|
99
|
+
- Can be used alongside biometric authentication
|
|
100
|
+
- Returns `false` if no credentials stored
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
#### Hybrid Sign-In
|
|
105
|
+
|
|
106
|
+
**Purpose:** Attempts all available sign-in methods simultaneously to find existing credentials.
|
|
107
|
+
|
|
108
|
+
**iOS:**
|
|
109
|
+
- Checks for: Apple ID, Google ID, and saved passwords
|
|
110
|
+
- Presents unified credential picker if multiple options available
|
|
111
|
+
- Returns first available credential
|
|
112
|
+
- Ideal for app launch to restore previous session
|
|
113
|
+
- Available: `HYBRID_SUPPORTED` constant
|
|
114
|
+
|
|
115
|
+
**Android:**
|
|
116
|
+
- Checks for: Google ID and saved passwords (Apple requires web flow)
|
|
117
|
+
- Uses Credential Manager to aggregate all options
|
|
118
|
+
- Presents native Android credential picker
|
|
119
|
+
- Returns first selected credential
|
|
120
|
+
- Available: `HYBRID_SUPPORTED` constant
|
|
121
|
+
|
|
122
|
+
**Use Case:** Perfect for "Continue with..." screens or automatic sign-in on app start.
|
|
123
|
+
|
|
124
|
+
**Returns:**
|
|
125
|
+
- `GoogleIdCredentialResult`
|
|
126
|
+
- `AppleIdCredentialResult` (iOS only)
|
|
127
|
+
- `PasswordCredentialResult`
|
|
128
|
+
- `CancelledCredentialResult`
|
|
129
|
+
|
|
130
|
+
---
|
|
131
|
+
|
|
132
|
+
#### Passkeys
|
|
133
|
+
|
|
134
|
+
**iOS:**
|
|
135
|
+
- Uses `AuthenticationServices` framework (iOS 16+)
|
|
136
|
+
- Supports WebAuthn/FIDO2 standard
|
|
137
|
+
- Syncs via iCloud Keychain
|
|
138
|
+
- Presents native passkey creation/selection UI
|
|
139
|
+
- Available: `PASSKEYS_SUPPORTED` constant (iOS 16+)
|
|
140
|
+
|
|
141
|
+
**Android:**
|
|
142
|
+
- Uses Credential Manager API with passkey support (Android 9+ / API 28+)
|
|
143
|
+
- Supports WebAuthn/FIDO2 standard
|
|
144
|
+
- Syncs via Google Password Manager
|
|
145
|
+
- Additional options: `preferImmediatelyAvailableCredentials`, `isConditional`
|
|
146
|
+
- Available: `PASSKEYS_SUPPORTED` constant
|
|
147
|
+
|
|
148
|
+
**Common Features:**
|
|
149
|
+
- Standards-based implementation (WebAuthn)
|
|
150
|
+
- Requires `requestJson` string with `PublicKeyCredentialCreationOptions`
|
|
151
|
+
- Returns `PassKeyCredentialResult` with platform public key credential
|
|
152
|
+
- More secure than passwords (phishing-resistant)
|
|
153
|
+
- Biometric authentication integration
|
|
154
|
+
|
|
155
|
+
---
|
|
156
|
+
|
|
157
|
+
### Import
|
|
158
|
+
|
|
159
|
+
```typescript
|
|
160
|
+
import {
|
|
161
|
+
googleSignIn,
|
|
162
|
+
appleSignIn,
|
|
163
|
+
passwordSignIn,
|
|
164
|
+
getPassword,
|
|
165
|
+
hybridSignIn,
|
|
166
|
+
createPassKey,
|
|
167
|
+
// Constants
|
|
168
|
+
GOOGLE_PLAY_SERVICES_SUPPORTED,
|
|
169
|
+
PASSWORD_SUPPORTED,
|
|
170
|
+
GOOGLE_ID_SUPPORTED,
|
|
171
|
+
APPLE_ID_SUPPORTED,
|
|
172
|
+
HYBRID_SUPPORTED,
|
|
173
|
+
PASSKEYS_SUPPORTED,
|
|
174
|
+
// Types
|
|
175
|
+
type GoogleSignInOptions,
|
|
176
|
+
type PasskeyOptions,
|
|
177
|
+
type GoogleIdCredentialResult,
|
|
178
|
+
type AppleIdCredentialResult,
|
|
179
|
+
type WebAppleIdCredentialResult,
|
|
180
|
+
type PasswordCredentialResult,
|
|
181
|
+
type PassKeyCredentialResult,
|
|
182
|
+
type CancelledCredentialResult,
|
|
183
|
+
CredentialsType,
|
|
184
|
+
CredentialError,
|
|
185
|
+
} from 'react-native-oauth-essentials';
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### Constants
|
|
189
|
+
|
|
190
|
+
Check platform support before using OAuth methods:
|
|
191
|
+
|
|
192
|
+
| Constant | Type | Description |
|
|
193
|
+
|----------|------|-------------|
|
|
194
|
+
| `GOOGLE_PLAY_SERVICES_SUPPORTED` | `boolean` | Google Play Services are available. Always `false` on iOS. |
|
|
195
|
+
| `PASSWORD_SUPPORTED` | `boolean` | Password credential manager is supported on this device. |
|
|
196
|
+
| `GOOGLE_ID_SUPPORTED` | `boolean` | Google Sign-In is supported. **Use this to check if you can use `googleSignIn()`**. |
|
|
197
|
+
| `APPLE_ID_SUPPORTED` | `boolean` | Apple Sign-In is supported on this device. |
|
|
198
|
+
| `HYBRID_SUPPORTED` | `boolean` | Hybrid sign-in is supported (multiple methods at once). |
|
|
199
|
+
| `PASSKEYS_SUPPORTED` | `boolean` | Passkeys are supported on this device. |
|
|
200
|
+
|
|
201
|
+
**Example:**
|
|
202
|
+
|
|
203
|
+
```typescript
|
|
204
|
+
if (GOOGLE_ID_SUPPORTED) {
|
|
205
|
+
await googleSignIn('YOUR_WEB_CLIENT_ID');
|
|
206
|
+
}
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
### Methods
|
|
210
|
+
|
|
211
|
+
#### `googleSignIn(webClientId, options?)`
|
|
212
|
+
|
|
213
|
+
Performs Google Sign-In with native UI.
|
|
214
|
+
|
|
215
|
+
**Parameters:**
|
|
216
|
+
- `webClientId` (string): Your Google OAuth 2.0 web client ID
|
|
217
|
+
- `options` (GoogleSignInOptions, optional): Sign-in configuration
|
|
218
|
+
|
|
219
|
+
**Returns:** `Promise<GoogleIdCredentialResult | CancelledCredentialResult>`
|
|
220
|
+
|
|
221
|
+
**Platform:** Android, iOS (check `GOOGLE_ID_SUPPORTED`)
|
|
222
|
+
|
|
223
|
+
**Example:**
|
|
224
|
+
|
|
225
|
+
```typescript
|
|
226
|
+
const result = await googleSignIn('YOUR_WEB_CLIENT_ID', {
|
|
227
|
+
authorizedAccounts: true, // Android only
|
|
228
|
+
autoSelectEnabled: false, // Android only
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
if (result.type === CredentialsType.GOOGLE_ID) {
|
|
232
|
+
console.log('User ID:', result.data.id);
|
|
233
|
+
console.log('ID Token:', result.data.idToken);
|
|
234
|
+
console.log('Name:', result.data.displayName);
|
|
235
|
+
}
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
---
|
|
239
|
+
|
|
240
|
+
#### `appleSignIn(androidWebUrl?)`
|
|
241
|
+
|
|
242
|
+
Initiates Apple Sign-In process.
|
|
243
|
+
|
|
244
|
+
**Parameters:**
|
|
245
|
+
- `androidWebUrl` (string, optional): Web URL for Android OAuth flow. **Required on Android.**
|
|
246
|
+
|
|
247
|
+
**Returns:** `Promise<AppleIdCredentialResult | WebAppleIdCredentialResult>`
|
|
248
|
+
|
|
249
|
+
**Platform:**
|
|
250
|
+
- iOS: Native Apple Sign-In UI
|
|
251
|
+
- Android: Opens browser with your web URL for OAuth flow
|
|
252
|
+
|
|
253
|
+
**Platform:** Check `APPLE_ID_SUPPORTED`
|
|
254
|
+
|
|
255
|
+
**Example:**
|
|
256
|
+
|
|
257
|
+
```typescript
|
|
258
|
+
const result = await appleSignIn('https://yourserver.com/apple-signin');
|
|
259
|
+
|
|
260
|
+
if (result.type === CredentialsType.APPLE_ID) {
|
|
261
|
+
// iOS result
|
|
262
|
+
console.log('User:', result.data.user);
|
|
263
|
+
console.log('ID Token:', result.data.idToken);
|
|
264
|
+
console.log('Email:', result.data.email);
|
|
265
|
+
} else if (result.type === CredentialsType.WEB_APPLE_ID) {
|
|
266
|
+
// Android result
|
|
267
|
+
console.log('Redirect URL:', result.data.url);
|
|
268
|
+
}
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
---
|
|
272
|
+
|
|
273
|
+
#### `passwordSignIn(username, password)`
|
|
274
|
+
|
|
275
|
+
Saves username/password credentials to the platform's credential manager.
|
|
276
|
+
|
|
277
|
+
**Parameters:**
|
|
278
|
+
- `username` (string): Username to save
|
|
279
|
+
- `password` (string): Password to save
|
|
280
|
+
|
|
281
|
+
**Returns:** `Promise<boolean>`
|
|
282
|
+
|
|
283
|
+
**Platform:** Android, iOS (check `PASSWORD_SUPPORTED`)
|
|
284
|
+
|
|
285
|
+
**Example:**
|
|
286
|
+
|
|
287
|
+
```typescript
|
|
288
|
+
const saved = await passwordSignIn('user@example.com', 'password123');
|
|
289
|
+
console.log('Credentials saved:', saved);
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
---
|
|
293
|
+
|
|
294
|
+
#### `getPassword()`
|
|
295
|
+
|
|
296
|
+
Retrieves stored password credentials.
|
|
297
|
+
|
|
298
|
+
**Returns:** `Promise<false | PasswordCredentialResult>`
|
|
299
|
+
|
|
300
|
+
**Platform:** Android, iOS (check `PASSWORD_SUPPORTED`)
|
|
301
|
+
|
|
302
|
+
**Example:**
|
|
303
|
+
|
|
304
|
+
```typescript
|
|
305
|
+
const result = await getPassword();
|
|
306
|
+
|
|
307
|
+
if (result && result.type === CredentialsType.PASSWORD) {
|
|
308
|
+
console.log('Username:', result.data.username);
|
|
309
|
+
console.log('Password:', result.data.password);
|
|
310
|
+
} else {
|
|
311
|
+
console.log('No stored password found');
|
|
312
|
+
}
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
---
|
|
316
|
+
|
|
317
|
+
#### `hybridSignIn(googleClientId, options?)`
|
|
318
|
+
|
|
319
|
+
Attempts all available sign-in methods at once. Useful on app start to check for existing credentials.
|
|
320
|
+
|
|
321
|
+
**Parameters:**
|
|
322
|
+
- `googleClientId` (string): Your Google OAuth 2.0 web client ID
|
|
323
|
+
- `options` (GoogleSignInOptions, optional): Google sign-in configuration
|
|
324
|
+
|
|
325
|
+
**Returns:** `Promise<AppleIdCredentialResult | GoogleIdCredentialResult | PasswordCredentialResult | CancelledCredentialResult>`
|
|
326
|
+
|
|
327
|
+
**Platform:** Android, iOS (check `HYBRID_SUPPORTED`)
|
|
328
|
+
|
|
329
|
+
**Example:**
|
|
330
|
+
|
|
331
|
+
```typescript
|
|
332
|
+
const result = await hybridSignIn('YOUR_WEB_CLIENT_ID');
|
|
333
|
+
|
|
334
|
+
switch (result.type) {
|
|
335
|
+
case CredentialsType.GOOGLE_ID:
|
|
336
|
+
console.log('Google user:', result.data.displayName);
|
|
337
|
+
break;
|
|
338
|
+
case CredentialsType.APPLE_ID:
|
|
339
|
+
console.log('Apple user:', result.data.user);
|
|
340
|
+
break;
|
|
341
|
+
case CredentialsType.PASSWORD:
|
|
342
|
+
console.log('Username:', result.data.username);
|
|
343
|
+
break;
|
|
344
|
+
case CredentialsType.CANCELLED:
|
|
345
|
+
console.log('User cancelled');
|
|
346
|
+
break;
|
|
347
|
+
}
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
---
|
|
351
|
+
|
|
352
|
+
#### `createPassKey(options)`
|
|
353
|
+
|
|
354
|
+
Creates a new passkey credential.
|
|
355
|
+
|
|
356
|
+
**Parameters:**
|
|
357
|
+
- `options` (PasskeyOptions): Passkey creation configuration
|
|
358
|
+
|
|
359
|
+
**Returns:** `Promise<PassKeyCredentialResult>`
|
|
360
|
+
|
|
361
|
+
**Platform:** Check `PASSKEYS_SUPPORTED`
|
|
362
|
+
|
|
363
|
+
**Example:**
|
|
364
|
+
|
|
365
|
+
```typescript
|
|
366
|
+
const result = await createPassKey({
|
|
367
|
+
requestJson: JSON.stringify({ /* PublicKeyCredentialCreationOptions */ }),
|
|
368
|
+
preferImmediatelyAvailableCredentials: true, // Android only
|
|
369
|
+
isConditional: false, // Android only
|
|
370
|
+
});
|
|
371
|
+
|
|
372
|
+
if (result.type === CredentialsType.PASSKEY) {
|
|
373
|
+
console.log('Passkey created:', result.data);
|
|
374
|
+
}
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
---
|
|
378
|
+
|
|
379
|
+
### Type Definitions
|
|
380
|
+
|
|
381
|
+
#### `GoogleSignInOptions`
|
|
382
|
+
|
|
383
|
+
```typescript
|
|
384
|
+
type GoogleSignInOptions = {
|
|
385
|
+
authorizedAccounts?: boolean; // Android only: Filter to authorized accounts
|
|
386
|
+
autoSelectEnabled?: boolean; // Android only: Enable auto-selection
|
|
387
|
+
};
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
#### `PasskeyOptions`
|
|
391
|
+
|
|
392
|
+
```typescript
|
|
393
|
+
type PasskeyOptions = {
|
|
394
|
+
requestJson: string; // JSON string of PublicKeyCredentialCreationOptions
|
|
395
|
+
preferImmediatelyAvailableCredentials?: boolean; // Android only
|
|
396
|
+
isConditional?: boolean; // Android only
|
|
397
|
+
};
|
|
398
|
+
```
|
|
399
|
+
|
|
400
|
+
---
|
|
401
|
+
|
|
402
|
+
### Result Types
|
|
403
|
+
|
|
404
|
+
#### `GoogleIdCredentialResult`
|
|
405
|
+
|
|
406
|
+
```typescript
|
|
407
|
+
type GoogleIdCredentialResult = {
|
|
408
|
+
type: CredentialsType.GOOGLE_ID;
|
|
409
|
+
data: {
|
|
410
|
+
id: string; // User's Google ID
|
|
411
|
+
idToken: string; // JWT ID token
|
|
412
|
+
displayName: string; // Full name
|
|
413
|
+
givenName: string; // First name
|
|
414
|
+
familyName: string; // Last name
|
|
415
|
+
profilePictureUri?: string | null; // Profile picture URL
|
|
416
|
+
phoneNumber?: string | null; // Phone number (if available)
|
|
417
|
+
};
|
|
418
|
+
};
|
|
419
|
+
```
|
|
420
|
+
|
|
421
|
+
#### `AppleIdCredentialResult`
|
|
422
|
+
|
|
423
|
+
```typescript
|
|
424
|
+
type AppleIdCredentialResult = {
|
|
425
|
+
type: CredentialsType.APPLE_ID;
|
|
426
|
+
data: {
|
|
427
|
+
idToken: string; // JWT ID token
|
|
428
|
+
authorizationCode: string; // Authorization code
|
|
429
|
+
user: string; // Unique user identifier
|
|
430
|
+
email: string; // User's email
|
|
431
|
+
fullName: string; // Full name
|
|
432
|
+
likelyReal: boolean; // Indicates if user is likely real
|
|
433
|
+
};
|
|
434
|
+
};
|
|
435
|
+
```
|
|
436
|
+
|
|
437
|
+
#### `WebAppleIdCredentialResult`
|
|
438
|
+
|
|
439
|
+
Android-specific result when using web-based Apple Sign-In:
|
|
440
|
+
|
|
441
|
+
```typescript
|
|
442
|
+
type WebAppleIdCredentialResult = {
|
|
443
|
+
type: CredentialsType.WEB_APPLE_ID;
|
|
444
|
+
data: {
|
|
445
|
+
url: string; // Full redirect URL
|
|
446
|
+
scheme: string | null; // URL scheme
|
|
447
|
+
host: string | null; // URL host
|
|
448
|
+
path: string | null; // URL path
|
|
449
|
+
query: string | null; // URL query parameters
|
|
450
|
+
};
|
|
451
|
+
};
|
|
452
|
+
```
|
|
453
|
+
|
|
454
|
+
#### `PasswordCredentialResult`
|
|
455
|
+
|
|
456
|
+
```typescript
|
|
457
|
+
type PasswordCredentialResult = {
|
|
458
|
+
type: CredentialsType.PASSWORD;
|
|
459
|
+
data: {
|
|
460
|
+
username: string; // Stored username
|
|
461
|
+
password: string; // Stored password
|
|
462
|
+
};
|
|
463
|
+
};
|
|
464
|
+
```
|
|
465
|
+
|
|
466
|
+
#### `PassKeyCredentialResult`
|
|
467
|
+
|
|
468
|
+
```typescript
|
|
469
|
+
type PassKeyCredentialResult = {
|
|
470
|
+
type: CredentialsType.PASSKEY;
|
|
471
|
+
data: string; // JSON string of platform public key credential
|
|
472
|
+
};
|
|
473
|
+
```
|
|
474
|
+
|
|
475
|
+
#### `CancelledCredentialResult`
|
|
476
|
+
|
|
477
|
+
```typescript
|
|
478
|
+
type CancelledCredentialResult = {
|
|
479
|
+
type: CredentialsType.CANCELLED;
|
|
480
|
+
data: null; // User cancelled the operation
|
|
481
|
+
};
|
|
482
|
+
```
|
|
483
|
+
|
|
484
|
+
---
|
|
485
|
+
|
|
486
|
+
### Credential Types Enum
|
|
487
|
+
|
|
488
|
+
```typescript
|
|
489
|
+
enum CredentialsType {
|
|
490
|
+
GOOGLE_ID = 'GOOGLE_ID', // Google Sign-In credential
|
|
491
|
+
PASSWORD = 'PASSWORD', // Username/password credential
|
|
492
|
+
APPLE_ID = 'APPLE_ID', // iOS native Apple Sign-In credential
|
|
493
|
+
WEB_APPLE_ID = 'WEB_APPLE_ID', // Android web-based Apple Sign-In credential
|
|
494
|
+
CANCELLED = 'CANCELLED', // User cancelled the sign-in flow
|
|
495
|
+
PASSKEY = 'PASSKEY', // Passkey credential
|
|
496
|
+
}
|
|
497
|
+
```
|
|
498
|
+
|
|
499
|
+
---
|
|
500
|
+
|
|
501
|
+
### Error Codes
|
|
502
|
+
|
|
503
|
+
```typescript
|
|
504
|
+
enum CredentialError {
|
|
505
|
+
NO_PLAY_SERVICES_ERROR = 'NO_PLAY_SERVICES_ERROR', // Google Play Services unavailable
|
|
506
|
+
NO_ACTIVITY_ERROR = 'NO_ACTIVITY_ERROR', // No Android activity available
|
|
507
|
+
INVALID_RESULT_ERROR = 'INVALID_RESULT_ERROR', // Invalid result from native module
|
|
508
|
+
}
|
|
509
|
+
```
|
|
510
|
+
|
|
511
|
+
**Error Handling:**
|
|
512
|
+
|
|
513
|
+
```typescript
|
|
514
|
+
try {
|
|
515
|
+
const result = await googleSignIn('YOUR_WEB_CLIENT_ID');
|
|
516
|
+
} catch (error) {
|
|
517
|
+
if (error.code === CredentialError.NO_PLAY_SERVICES_ERROR) {
|
|
518
|
+
console.error('Google Play Services not available');
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
```
|
|
12
522
|
|
|
13
523
|
## Short history
|
|
14
524
|
|
|
@@ -27,4 +537,3 @@ make me want to throw my laptop out the window?
|
|
|
27
537
|
## Philosophy
|
|
28
538
|
|
|
29
539
|
Free forever, up-to-date features, and focused only on the essentials your mobile app really needs.
|
|
30
|
-
|