@capgo/capacitor-social-login 7.8.2 → 7.8.12
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/CapgoCapacitorSocialLogin.podspec +2 -2
- package/Package.swift +2 -2
- package/README.md +45 -9
- package/android/build.gradle +4 -4
- package/android/src/main/java/ee/forgr/capacitor/social/login/GoogleProvider.java +34 -9
- package/dist/docs.json +32 -0
- package/dist/esm/definitions.d.ts +18 -1
- package/dist/esm/definitions.js.map +1 -1
- package/package.json +1 -1
|
@@ -14,8 +14,8 @@ Pod::Spec.new do |s|
|
|
|
14
14
|
s.exclude_files = '**/node_modules/**/*', '**/examples/**/*'
|
|
15
15
|
s.ios.deployment_target = '14.0'
|
|
16
16
|
s.dependency 'Capacitor'
|
|
17
|
-
s.dependency 'FBSDKCoreKit', '
|
|
18
|
-
s.dependency 'FBSDKLoginKit', '
|
|
17
|
+
s.dependency 'FBSDKCoreKit', '18.0.0'
|
|
18
|
+
s.dependency 'FBSDKLoginKit', '18.0.0'
|
|
19
19
|
s.dependency 'GoogleSignIn', '~> 9.0.0'
|
|
20
20
|
s.dependency 'Alamofire', '~> 5.10.2'
|
|
21
21
|
s.swift_version = '5.1'
|
package/Package.swift
CHANGED
|
@@ -10,9 +10,9 @@ let package = Package(
|
|
|
10
10
|
targets: ["SocialLoginPlugin"])
|
|
11
11
|
],
|
|
12
12
|
dependencies: [
|
|
13
|
-
.package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "7.
|
|
13
|
+
.package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "7.4.2"),
|
|
14
14
|
// FBSDKCoreKit and FBSDKLoginKit
|
|
15
|
-
.package(url: "https://github.com/facebook/facebook-ios-sdk.git", .upToNextMajor(from: "
|
|
15
|
+
.package(url: "https://github.com/facebook/facebook-ios-sdk.git", .upToNextMajor(from: "18.0.0")),
|
|
16
16
|
// Add Google Sign-In dependency
|
|
17
17
|
.package(url: "https://github.com/google/GoogleSignIn-iOS.git", .upToNextMajor(from: "9.0.0")),
|
|
18
18
|
// Alamofire
|
package/README.md
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
<a href="https://capgo.app/"><img src='https://raw.githubusercontent.com/Cap-go/capgo/main/assets/capgo_banner.png' alt='Capgo - Instant updates for capacitor'/></a>
|
|
3
3
|
|
|
4
4
|
<div align="center">
|
|
5
|
-
<h2><a href="https://capgo.app/?ref=plugin"> ➡️ Get Instant updates for your App with Capgo
|
|
6
|
-
<h2><a href="https://capgo.app/consulting/?ref=plugin">
|
|
5
|
+
<h2><a href="https://capgo.app/?ref=plugin"> ➡️ Get Instant updates for your App with Capgo</a></h2>
|
|
6
|
+
<h2><a href="https://capgo.app/consulting/?ref=plugin"> Missing a feature? We’ll build the plugin for you 💪</a></h2>
|
|
7
7
|
</div>
|
|
8
8
|
|
|
9
9
|
## Fork Information
|
|
@@ -334,6 +334,40 @@ For advanced users who want to completely exclude Facebook from builds, you can
|
|
|
334
334
|
|
|
335
335
|
The Facebook dependencies should still be present (for compatibility), but the AD_ID permission should be removed from your final APK.
|
|
336
336
|
|
|
337
|
+
### Google Sign-In with Family Link Supervised Accounts
|
|
338
|
+
|
|
339
|
+
**Problem**: When users try to sign in with Google accounts supervised by Family Link, login fails with:
|
|
340
|
+
```
|
|
341
|
+
NoCredentialException: No credentials available
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
**Root Cause**: Family Link supervised accounts have different authentication requirements and may not work properly with certain Google Sign-In configurations.
|
|
345
|
+
|
|
346
|
+
**Solution**:
|
|
347
|
+
When implementing Google Sign-In for apps that need to support Family Link accounts, use the following configuration:
|
|
348
|
+
|
|
349
|
+
```typescript
|
|
350
|
+
import { SocialLogin } from '@capacitor/social-login';
|
|
351
|
+
|
|
352
|
+
// For Family Link accounts, disable filtering by authorized accounts
|
|
353
|
+
await SocialLogin.login({
|
|
354
|
+
provider: 'google',
|
|
355
|
+
options: {
|
|
356
|
+
style: 'bottom', // or 'standard'
|
|
357
|
+
filterByAuthorizedAccounts: false, // Important for Family Link (default is true)
|
|
358
|
+
scopes: ['profile', 'email']
|
|
359
|
+
}
|
|
360
|
+
});
|
|
361
|
+
```
|
|
362
|
+
|
|
363
|
+
**Key Points**:
|
|
364
|
+
- Set `filterByAuthorizedAccounts` to `false` to ensure Family Link accounts are visible (default is `true`)
|
|
365
|
+
- The plugin will automatically retry with 'standard' style if 'bottom' style fails with NoCredentialException
|
|
366
|
+
- These options only affect Android; iOS handles Family Link accounts normally
|
|
367
|
+
- The error message will suggest disabling `filterByAuthorizedAccounts` if login fails
|
|
368
|
+
|
|
369
|
+
**Note**: Other apps like Listonic work with Family Link accounts because they use similar configurations. The default settings may be too restrictive for supervised accounts.
|
|
370
|
+
|
|
337
371
|
## API
|
|
338
372
|
|
|
339
373
|
<docgen-index>
|
|
@@ -540,13 +574,15 @@ Execute provider-specific calls
|
|
|
540
574
|
|
|
541
575
|
#### GoogleLoginOptions
|
|
542
576
|
|
|
543
|
-
| Prop
|
|
544
|
-
|
|
|
545
|
-
| **`scopes`**
|
|
546
|
-
| **`nonce`**
|
|
547
|
-
| **`forceRefreshToken`**
|
|
548
|
-
| **`forcePrompt`**
|
|
549
|
-
| **`style`**
|
|
577
|
+
| Prop | Type | Description | Default |
|
|
578
|
+
| -------------------------------- | ----------------------------------- | ---------------------------------------------------------------------------------------------------- | ----------------------- |
|
|
579
|
+
| **`scopes`** | <code>string[]</code> | Specifies the scopes required for accessing Google APIs The default is defined in the configuration. | |
|
|
580
|
+
| **`nonce`** | <code>string</code> | Nonce | |
|
|
581
|
+
| **`forceRefreshToken`** | <code>boolean</code> | Force refresh token (only for Android) | <code>false</code> |
|
|
582
|
+
| **`forcePrompt`** | <code>boolean</code> | Force account selection prompt (iOS) | <code>false</code> |
|
|
583
|
+
| **`style`** | <code>'bottom' \| 'standard'</code> | Style | <code>'standard'</code> |
|
|
584
|
+
| **`filterByAuthorizedAccounts`** | <code>boolean</code> | Filter by authorized accounts (Android only) | <code>true</code> |
|
|
585
|
+
| **`autoSelectEnabled`** | <code>boolean</code> | Auto select enabled (Android only) | <code>false</code> |
|
|
550
586
|
|
|
551
587
|
|
|
552
588
|
#### AppleProviderOptions
|
package/android/build.gradle
CHANGED
|
@@ -52,14 +52,14 @@ dependencies {
|
|
|
52
52
|
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
|
53
53
|
implementation project(':capacitor-android')
|
|
54
54
|
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
|
|
55
|
-
implementation 'com.facebook.android:facebook-login:18.
|
|
55
|
+
implementation 'com.facebook.android:facebook-login:18.1.3'
|
|
56
56
|
implementation 'com.squareup.okhttp3:okhttp:4.12.0'
|
|
57
57
|
implementation 'com.auth0.android:jwtdecode:2.0.2'
|
|
58
|
-
implementation "androidx.credentials:credentials:1.
|
|
58
|
+
implementation "androidx.credentials:credentials:1.5.0"
|
|
59
59
|
implementation 'com.google.android.gms:play-services-auth:21.3.0'
|
|
60
|
-
implementation "androidx.credentials:credentials-play-services-auth:1.
|
|
60
|
+
implementation "androidx.credentials:credentials-play-services-auth:1.5.0"
|
|
61
61
|
implementation "com.google.android.libraries.identity.googleid:googleid:1.1.1"
|
|
62
|
-
implementation 'com.google.androidbrowserhelper:androidbrowserhelper:2.
|
|
62
|
+
implementation 'com.google.androidbrowserhelper:androidbrowserhelper:2.6.2'
|
|
63
63
|
testImplementation "junit:junit:$junitVersion"
|
|
64
64
|
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
|
|
65
65
|
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
|
|
@@ -614,18 +614,43 @@ public class GoogleProvider implements SocialProvider {
|
|
|
614
614
|
// do nothing
|
|
615
615
|
}
|
|
616
616
|
}
|
|
617
|
-
if (e instanceof NoCredentialException
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
// https://developer.android.com/reference/androidx/credentials/exceptions/NoCredentialException
|
|
617
|
+
if (e instanceof NoCredentialException) {
|
|
618
|
+
// Check if filterByAuthorizedAccounts is set (default is false if not explicitly set to false)
|
|
619
|
+
boolean filterByAuthorizedAccountsValue = false;
|
|
621
620
|
try {
|
|
622
|
-
options.
|
|
623
|
-
|
|
621
|
+
if (options.has("filterByAuthorizedAccounts")) {
|
|
622
|
+
filterByAuthorizedAccountsValue = options.getBoolean("filterByAuthorizedAccounts");
|
|
623
|
+
}
|
|
624
624
|
} catch (JSONException ex) {
|
|
625
|
-
|
|
626
|
-
|
|
625
|
+
// Ignore, use default
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
if (isBottomUi) {
|
|
629
|
+
Log.e(
|
|
630
|
+
LOG_TAG,
|
|
631
|
+
"No Google accounts available with bottomUi. This may be due to Family Link supervised accounts when filterByAuthorizedAccounts is true. Switching to standard UI."
|
|
632
|
+
);
|
|
633
|
+
// During the get credential flow, this is returned when no viable credential is available for the the user. This can be caused by various scenarios such as that the user doesn't have any credential or the user doesn't grant consent to using any available credential. Upon this exception, your app should navigate to use the regular app sign-up or sign-in screen.
|
|
634
|
+
// https://developer.android.com/reference/androidx/credentials/exceptions/NoCredentialException
|
|
635
|
+
// Note: Family Link supervised accounts may cause this error when filterByAuthorizedAccounts is true
|
|
636
|
+
try {
|
|
637
|
+
options.put("style", "standard");
|
|
638
|
+
call.getData().put("options", options);
|
|
639
|
+
} catch (JSONException ex) {
|
|
640
|
+
call.reject("Google Sign-In failed: " + ex.getMessage());
|
|
641
|
+
return;
|
|
642
|
+
}
|
|
643
|
+
login(call, config);
|
|
644
|
+
} else {
|
|
645
|
+
// If it's already standard UI, provide more detailed error message
|
|
646
|
+
if (filterByAuthorizedAccountsValue) {
|
|
647
|
+
call.reject(
|
|
648
|
+
"Google Sign-In failed: No credentials available. If signing in with a Family Link supervised account, try setting filterByAuthorizedAccounts to false."
|
|
649
|
+
);
|
|
650
|
+
} else {
|
|
651
|
+
call.reject("Google Sign-In failed: " + e.getMessage());
|
|
652
|
+
}
|
|
627
653
|
}
|
|
628
|
-
login(call, config);
|
|
629
654
|
} else {
|
|
630
655
|
call.reject("Google Sign-In failed: " + e.getMessage());
|
|
631
656
|
}
|
package/dist/docs.json
CHANGED
|
@@ -534,6 +534,38 @@
|
|
|
534
534
|
"docs": "Style",
|
|
535
535
|
"complexTypes": [],
|
|
536
536
|
"type": "'bottom' | 'standard' | undefined"
|
|
537
|
+
},
|
|
538
|
+
{
|
|
539
|
+
"name": "filterByAuthorizedAccounts",
|
|
540
|
+
"tags": [
|
|
541
|
+
{
|
|
542
|
+
"text": "Only show accounts that have previously been used to sign in to the app.\nThis option is only available for the 'bottom' style.\nNote: For Family Link supervised accounts, this should be set to false.",
|
|
543
|
+
"name": "description"
|
|
544
|
+
},
|
|
545
|
+
{
|
|
546
|
+
"text": "true",
|
|
547
|
+
"name": "default"
|
|
548
|
+
}
|
|
549
|
+
],
|
|
550
|
+
"docs": "Filter by authorized accounts (Android only)",
|
|
551
|
+
"complexTypes": [],
|
|
552
|
+
"type": "boolean | undefined"
|
|
553
|
+
},
|
|
554
|
+
{
|
|
555
|
+
"name": "autoSelectEnabled",
|
|
556
|
+
"tags": [
|
|
557
|
+
{
|
|
558
|
+
"text": "Automatically select the account if only one Google account is available.\nThis option is only available for the 'bottom' style.",
|
|
559
|
+
"name": "description"
|
|
560
|
+
},
|
|
561
|
+
{
|
|
562
|
+
"text": "false",
|
|
563
|
+
"name": "default"
|
|
564
|
+
}
|
|
565
|
+
],
|
|
566
|
+
"docs": "Auto select enabled (Android only)",
|
|
567
|
+
"complexTypes": [],
|
|
568
|
+
"type": "boolean | undefined"
|
|
537
569
|
}
|
|
538
570
|
]
|
|
539
571
|
},
|
|
@@ -57,7 +57,9 @@ export interface InitializeOptions {
|
|
|
57
57
|
*/
|
|
58
58
|
clientId?: string;
|
|
59
59
|
/**
|
|
60
|
-
* Apple Redirect URL, should be your backend url that is configured in your apple app
|
|
60
|
+
* Apple Redirect URL, should be your backend url that is configured in your apple app
|
|
61
|
+
*
|
|
62
|
+
* **Note**: Use empty string `''` for iOS to prevent redirect.
|
|
61
63
|
*/
|
|
62
64
|
redirectUrl?: string;
|
|
63
65
|
};
|
|
@@ -111,6 +113,21 @@ export interface GoogleLoginOptions {
|
|
|
111
113
|
* @default 'standard'
|
|
112
114
|
*/
|
|
113
115
|
style?: 'bottom' | 'standard';
|
|
116
|
+
/**
|
|
117
|
+
* Filter by authorized accounts (Android only)
|
|
118
|
+
* @description Only show accounts that have previously been used to sign in to the app.
|
|
119
|
+
* This option is only available for the 'bottom' style.
|
|
120
|
+
* Note: For Family Link supervised accounts, this should be set to false.
|
|
121
|
+
* @default true
|
|
122
|
+
*/
|
|
123
|
+
filterByAuthorizedAccounts?: boolean;
|
|
124
|
+
/**
|
|
125
|
+
* Auto select enabled (Android only)
|
|
126
|
+
* @description Automatically select the account if only one Google account is available.
|
|
127
|
+
* This option is only available for the 'bottom' style.
|
|
128
|
+
* @default false
|
|
129
|
+
*/
|
|
130
|
+
autoSelectEnabled?: boolean;
|
|
114
131
|
}
|
|
115
132
|
export interface GoogleLoginResponseOnline {
|
|
116
133
|
accessToken: AccessToken | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["export interface InitializeOptions {\n facebook?: {\n /**\n * Facebook App ID, provided by Facebook for web, in mobile it's set in the native files\n */\n appId: string;\n /**\n * Facebook Client Token, provided by Facebook for web, in mobile it's set in the native files\n */\n clientToken?: string;\n };\n\n google?: {\n /**\n * The app's client ID, found and created in the Google Developers Console.\n * Required for iOS platform.\n * @example xxxxxx-xxxxxxxxxxxxxxxxxx.apps.googleusercontent.com\n * @since 3.1.0\n */\n iOSClientId?: string;\n /**\n * The app's server client ID, required for offline mode on iOS.\n * Should be the same value as webClientId.\n * Found and created in the Google Developers Console.\n * @example xxxxxx-xxxxxxxxxxxxxxxxxx.apps.googleusercontent.com\n * @since 3.1.0\n */\n iOSServerClientId?: string;\n /**\n * The app's web client ID, found and created in the Google Developers Console.\n * Required for Android and Web platforms.\n * @example xxxxxx-xxxxxxxxxxxxxxxxxx.apps.googleusercontent.com\n * @since 3.1.0\n */\n webClientId?: string;\n /**\n * The login mode, can be online or offline.\n * - online: Returns user profile data and access tokens (default)\n * - offline: Returns only serverAuthCode for backend authentication, no user profile data\n * Note: offline mode requires iOSServerClientId to be set on iOS\n * @example offline\n * @since 3.1.0\n */\n mode?: 'online' | 'offline';\n /**\n * Filter visible accounts by hosted domain\n * @description filter visible accounts by hosted domain\n */\n hostedDomain?: string;\n /**\n * Google Redirect URL, should be your backend url that is configured in your google app\n */\n redirectUrl?: string;\n };\n apple?: {\n /**\n * Apple Client ID, provided by Apple for web and Android\n */\n clientId?: string;\n /**\n * Apple Redirect URL, should be your backend url that is configured in your apple app, only for android\n */\n redirectUrl?: string;\n };\n}\n\nexport interface FacebookLoginOptions {\n /**\n * Permissions\n * @description select permissions to login with\n */\n permissions: string[];\n /**\n * Is Limited Login\n * @description use limited login for Facebook IOS\n * @default false\n */\n limitedLogin?: boolean;\n /**\n * Nonce\n * @description A custom nonce to use for the login request\n */\n nonce?: string;\n}\n\nexport interface GoogleLoginOptions {\n /**\n * Specifies the scopes required for accessing Google APIs\n * The default is defined in the configuration.\n * @example [\"profile\", \"email\"]\n * @see [Google OAuth2 Scopes](https://developers.google.com/identity/protocols/oauth2/scopes)\n */\n scopes?: string[];\n /**\n * Nonce\n * @description nonce\n */\n nonce?: string;\n /**\n * Force refresh token (only for Android)\n * @description force refresh token\n * @default false\n */\n forceRefreshToken?: boolean;\n /**\n * Force account selection prompt (iOS)\n * @description forces the account selection prompt to appear on iOS\n * @default false\n */\n forcePrompt?: boolean;\n /**\n * Style\n * @description style\n * @default 'standard'\n */\n style?: 'bottom' | 'standard';\n}\n\nexport interface GoogleLoginResponseOnline {\n accessToken: AccessToken | null;\n idToken: string | null;\n profile: {\n email: string | null;\n familyName: string | null;\n givenName: string | null;\n id: string | null;\n name: string | null;\n imageUrl: string | null;\n };\n responseType: 'online';\n}\n\nexport interface GoogleLoginResponseOffline {\n serverAuthCode: string;\n responseType: 'offline';\n}\n\nexport type GoogleLoginResponse = GoogleLoginResponseOnline | GoogleLoginResponseOffline;\n\nexport interface AppleProviderOptions {\n /**\n * Scopes\n * @description An array of scopes to request during login\n * @example [\"name\", \"email\"]\n * default: [\"name\", \"email\"]\n */\n scopes?: string[];\n /**\n * Nonce\n * @description nonce\n */\n nonce?: string;\n /**\n * State\n * @description state\n */\n state?: string;\n}\n\nexport interface AppleProviderResponse {\n accessToken: AccessToken | null;\n idToken: string | null;\n profile: {\n user: string;\n email: string | null;\n givenName: string | null;\n familyName: string | null;\n };\n}\n\nexport type LoginOptions =\n | {\n provider: 'facebook';\n options: FacebookLoginOptions;\n }\n | {\n provider: 'google';\n options: GoogleLoginOptions;\n }\n | {\n provider: 'apple';\n options: AppleProviderOptions;\n };\n\nexport type LoginResult =\n | {\n provider: 'facebook';\n result: FacebookLoginResponse;\n }\n | {\n provider: 'google';\n result: GoogleLoginResponse;\n }\n | {\n provider: 'apple';\n result: AppleProviderResponse;\n };\n\nexport interface AccessToken {\n applicationId?: string;\n declinedPermissions?: string[];\n expires?: string;\n isExpired?: boolean;\n lastRefresh?: string;\n permissions?: string[];\n token: string;\n refreshToken?: string;\n userId?: string;\n}\n\nexport interface FacebookLoginResponse {\n accessToken: AccessToken | null;\n idToken: string | null;\n profile: {\n userID: string;\n email: string | null;\n friendIDs: string[];\n birthday: string | null;\n ageRange: { min?: number; max?: number } | null;\n gender: string | null;\n location: { id: string; name: string } | null;\n hometown: { id: string; name: string } | null;\n profileURL: string | null;\n name: string | null;\n imageURL: string | null;\n };\n}\n\nexport interface AuthorizationCode {\n /**\n * Jwt\n * @description A JSON web token\n */\n jwt?: string;\n /**\n * Access Token\n * @description An access token\n */\n accessToken?: string;\n}\n\nexport interface AuthorizationCodeOptions {\n /**\n * Provider\n * @description Provider for the authorization code\n */\n provider: 'apple' | 'google' | 'facebook';\n}\n\nexport interface isLoggedInOptions {\n /**\n * Provider\n * @description Provider for the isLoggedIn\n */\n provider: 'apple' | 'google' | 'facebook';\n}\n\n// Define the provider-specific call types\nexport type ProviderSpecificCall = 'facebook#getProfile' | 'facebook#requestTracking';\n\n// Define the options and response types for each specific call\nexport interface FacebookGetProfileOptions {\n /**\n * Fields to retrieve from Facebook profile\n * @example [\"id\", \"name\", \"email\", \"picture\"]\n */\n fields?: string[];\n}\n\nexport interface FacebookGetProfileResponse {\n /**\n * Facebook profile data\n */\n profile: {\n id: string | null;\n name: string | null;\n email: string | null;\n first_name: string | null;\n last_name: string | null;\n picture?: {\n data: {\n height: number | null;\n is_silhouette: boolean | null;\n url: string | null;\n width: number | null;\n };\n } | null;\n [key: string]: any; // For additional fields that might be requested\n };\n}\n\nexport type FacebookRequestTrackingOptions = Record<string, never>;\n\nexport interface FacebookRequestTrackingResponse {\n /**\n * App tracking authorization status\n */\n status: 'authorized' | 'denied' | 'notDetermined' | 'restricted';\n}\n\n// Map call strings to their options and response types\nexport type ProviderSpecificCallOptionsMap = {\n 'facebook#getProfile': FacebookGetProfileOptions;\n 'facebook#requestTracking': FacebookRequestTrackingOptions;\n};\n\nexport type ProviderSpecificCallResponseMap = {\n 'facebook#getProfile': FacebookGetProfileResponse;\n 'facebook#requestTracking': FacebookRequestTrackingResponse;\n};\n\n// Add a helper type to map providers to their response types\nexport type ProviderResponseMap = {\n facebook: FacebookLoginResponse;\n google: GoogleLoginResponse;\n apple: AppleProviderResponse;\n};\n\nexport interface SocialLoginPlugin {\n /**\n * Initialize the plugin\n * @description initialize the plugin with the required options\n */\n initialize(options: InitializeOptions): Promise<void>;\n /**\n * Login with the selected provider\n * @description login with the selected provider\n */\n login<T extends LoginOptions['provider']>(\n options: Extract<LoginOptions, { provider: T }>,\n ): Promise<{ provider: T; result: ProviderResponseMap[T] }>;\n /**\n * Logout\n * @description logout the user\n */\n logout(options: { provider: 'apple' | 'google' | 'facebook' }): Promise<void>;\n /**\n * IsLoggedIn\n * @description logout the user\n */\n isLoggedIn(options: isLoggedInOptions): Promise<{ isLoggedIn: boolean }>;\n\n /**\n * Get the current access token\n * @description get the current access token\n */\n getAuthorizationCode(options: AuthorizationCodeOptions): Promise<AuthorizationCode>;\n /**\n * Refresh the access token\n * @description refresh the access token\n */\n refresh(options: LoginOptions): Promise<void>;\n\n /**\n * Execute provider-specific calls\n * @description Execute a provider-specific functionality\n */\n providerSpecificCall<T extends ProviderSpecificCall>(options: {\n call: T;\n options: ProviderSpecificCallOptionsMap[T];\n }): Promise<ProviderSpecificCallResponseMap[T]>;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["export interface InitializeOptions {\n facebook?: {\n /**\n * Facebook App ID, provided by Facebook for web, in mobile it's set in the native files\n */\n appId: string;\n /**\n * Facebook Client Token, provided by Facebook for web, in mobile it's set in the native files\n */\n clientToken?: string;\n };\n\n google?: {\n /**\n * The app's client ID, found and created in the Google Developers Console.\n * Required for iOS platform.\n * @example xxxxxx-xxxxxxxxxxxxxxxxxx.apps.googleusercontent.com\n * @since 3.1.0\n */\n iOSClientId?: string;\n /**\n * The app's server client ID, required for offline mode on iOS.\n * Should be the same value as webClientId.\n * Found and created in the Google Developers Console.\n * @example xxxxxx-xxxxxxxxxxxxxxxxxx.apps.googleusercontent.com\n * @since 3.1.0\n */\n iOSServerClientId?: string;\n /**\n * The app's web client ID, found and created in the Google Developers Console.\n * Required for Android and Web platforms.\n * @example xxxxxx-xxxxxxxxxxxxxxxxxx.apps.googleusercontent.com\n * @since 3.1.0\n */\n webClientId?: string;\n /**\n * The login mode, can be online or offline.\n * - online: Returns user profile data and access tokens (default)\n * - offline: Returns only serverAuthCode for backend authentication, no user profile data\n * Note: offline mode requires iOSServerClientId to be set on iOS\n * @example offline\n * @since 3.1.0\n */\n mode?: 'online' | 'offline';\n /**\n * Filter visible accounts by hosted domain\n * @description filter visible accounts by hosted domain\n */\n hostedDomain?: string;\n /**\n * Google Redirect URL, should be your backend url that is configured in your google app\n */\n redirectUrl?: string;\n };\n apple?: {\n /**\n * Apple Client ID, provided by Apple for web and Android\n */\n clientId?: string;\n /**\n * Apple Redirect URL, should be your backend url that is configured in your apple app\n *\n * **Note**: Use empty string `''` for iOS to prevent redirect.\n */\n redirectUrl?: string;\n };\n}\n\nexport interface FacebookLoginOptions {\n /**\n * Permissions\n * @description select permissions to login with\n */\n permissions: string[];\n /**\n * Is Limited Login\n * @description use limited login for Facebook IOS\n * @default false\n */\n limitedLogin?: boolean;\n /**\n * Nonce\n * @description A custom nonce to use for the login request\n */\n nonce?: string;\n}\n\nexport interface GoogleLoginOptions {\n /**\n * Specifies the scopes required for accessing Google APIs\n * The default is defined in the configuration.\n * @example [\"profile\", \"email\"]\n * @see [Google OAuth2 Scopes](https://developers.google.com/identity/protocols/oauth2/scopes)\n */\n scopes?: string[];\n /**\n * Nonce\n * @description nonce\n */\n nonce?: string;\n /**\n * Force refresh token (only for Android)\n * @description force refresh token\n * @default false\n */\n forceRefreshToken?: boolean;\n /**\n * Force account selection prompt (iOS)\n * @description forces the account selection prompt to appear on iOS\n * @default false\n */\n forcePrompt?: boolean;\n /**\n * Style\n * @description style\n * @default 'standard'\n */\n style?: 'bottom' | 'standard';\n /**\n * Filter by authorized accounts (Android only)\n * @description Only show accounts that have previously been used to sign in to the app.\n * This option is only available for the 'bottom' style.\n * Note: For Family Link supervised accounts, this should be set to false.\n * @default true\n */\n filterByAuthorizedAccounts?: boolean;\n /**\n * Auto select enabled (Android only)\n * @description Automatically select the account if only one Google account is available.\n * This option is only available for the 'bottom' style.\n * @default false\n */\n autoSelectEnabled?: boolean;\n}\n\nexport interface GoogleLoginResponseOnline {\n accessToken: AccessToken | null;\n idToken: string | null;\n profile: {\n email: string | null;\n familyName: string | null;\n givenName: string | null;\n id: string | null;\n name: string | null;\n imageUrl: string | null;\n };\n responseType: 'online';\n}\n\nexport interface GoogleLoginResponseOffline {\n serverAuthCode: string;\n responseType: 'offline';\n}\n\nexport type GoogleLoginResponse = GoogleLoginResponseOnline | GoogleLoginResponseOffline;\n\nexport interface AppleProviderOptions {\n /**\n * Scopes\n * @description An array of scopes to request during login\n * @example [\"name\", \"email\"]\n * default: [\"name\", \"email\"]\n */\n scopes?: string[];\n /**\n * Nonce\n * @description nonce\n */\n nonce?: string;\n /**\n * State\n * @description state\n */\n state?: string;\n}\n\nexport interface AppleProviderResponse {\n accessToken: AccessToken | null;\n idToken: string | null;\n profile: {\n user: string;\n email: string | null;\n givenName: string | null;\n familyName: string | null;\n };\n}\n\nexport type LoginOptions =\n | {\n provider: 'facebook';\n options: FacebookLoginOptions;\n }\n | {\n provider: 'google';\n options: GoogleLoginOptions;\n }\n | {\n provider: 'apple';\n options: AppleProviderOptions;\n };\n\nexport type LoginResult =\n | {\n provider: 'facebook';\n result: FacebookLoginResponse;\n }\n | {\n provider: 'google';\n result: GoogleLoginResponse;\n }\n | {\n provider: 'apple';\n result: AppleProviderResponse;\n };\n\nexport interface AccessToken {\n applicationId?: string;\n declinedPermissions?: string[];\n expires?: string;\n isExpired?: boolean;\n lastRefresh?: string;\n permissions?: string[];\n token: string;\n refreshToken?: string;\n userId?: string;\n}\n\nexport interface FacebookLoginResponse {\n accessToken: AccessToken | null;\n idToken: string | null;\n profile: {\n userID: string;\n email: string | null;\n friendIDs: string[];\n birthday: string | null;\n ageRange: { min?: number; max?: number } | null;\n gender: string | null;\n location: { id: string; name: string } | null;\n hometown: { id: string; name: string } | null;\n profileURL: string | null;\n name: string | null;\n imageURL: string | null;\n };\n}\n\nexport interface AuthorizationCode {\n /**\n * Jwt\n * @description A JSON web token\n */\n jwt?: string;\n /**\n * Access Token\n * @description An access token\n */\n accessToken?: string;\n}\n\nexport interface AuthorizationCodeOptions {\n /**\n * Provider\n * @description Provider for the authorization code\n */\n provider: 'apple' | 'google' | 'facebook';\n}\n\nexport interface isLoggedInOptions {\n /**\n * Provider\n * @description Provider for the isLoggedIn\n */\n provider: 'apple' | 'google' | 'facebook';\n}\n\n// Define the provider-specific call types\nexport type ProviderSpecificCall = 'facebook#getProfile' | 'facebook#requestTracking';\n\n// Define the options and response types for each specific call\nexport interface FacebookGetProfileOptions {\n /**\n * Fields to retrieve from Facebook profile\n * @example [\"id\", \"name\", \"email\", \"picture\"]\n */\n fields?: string[];\n}\n\nexport interface FacebookGetProfileResponse {\n /**\n * Facebook profile data\n */\n profile: {\n id: string | null;\n name: string | null;\n email: string | null;\n first_name: string | null;\n last_name: string | null;\n picture?: {\n data: {\n height: number | null;\n is_silhouette: boolean | null;\n url: string | null;\n width: number | null;\n };\n } | null;\n [key: string]: any; // For additional fields that might be requested\n };\n}\n\nexport type FacebookRequestTrackingOptions = Record<string, never>;\n\nexport interface FacebookRequestTrackingResponse {\n /**\n * App tracking authorization status\n */\n status: 'authorized' | 'denied' | 'notDetermined' | 'restricted';\n}\n\n// Map call strings to their options and response types\nexport type ProviderSpecificCallOptionsMap = {\n 'facebook#getProfile': FacebookGetProfileOptions;\n 'facebook#requestTracking': FacebookRequestTrackingOptions;\n};\n\nexport type ProviderSpecificCallResponseMap = {\n 'facebook#getProfile': FacebookGetProfileResponse;\n 'facebook#requestTracking': FacebookRequestTrackingResponse;\n};\n\n// Add a helper type to map providers to their response types\nexport type ProviderResponseMap = {\n facebook: FacebookLoginResponse;\n google: GoogleLoginResponse;\n apple: AppleProviderResponse;\n};\n\nexport interface SocialLoginPlugin {\n /**\n * Initialize the plugin\n * @description initialize the plugin with the required options\n */\n initialize(options: InitializeOptions): Promise<void>;\n /**\n * Login with the selected provider\n * @description login with the selected provider\n */\n login<T extends LoginOptions['provider']>(\n options: Extract<LoginOptions, { provider: T }>,\n ): Promise<{ provider: T; result: ProviderResponseMap[T] }>;\n /**\n * Logout\n * @description logout the user\n */\n logout(options: { provider: 'apple' | 'google' | 'facebook' }): Promise<void>;\n /**\n * IsLoggedIn\n * @description logout the user\n */\n isLoggedIn(options: isLoggedInOptions): Promise<{ isLoggedIn: boolean }>;\n\n /**\n * Get the current access token\n * @description get the current access token\n */\n getAuthorizationCode(options: AuthorizationCodeOptions): Promise<AuthorizationCode>;\n /**\n * Refresh the access token\n * @description refresh the access token\n */\n refresh(options: LoginOptions): Promise<void>;\n\n /**\n * Execute provider-specific calls\n * @description Execute a provider-specific functionality\n */\n providerSpecificCall<T extends ProviderSpecificCall>(options: {\n call: T;\n options: ProviderSpecificCallOptionsMap[T];\n }): Promise<ProviderSpecificCallResponseMap[T]>;\n}\n"]}
|