@capgo/capacitor-social-login 8.6.0 → 8.7.0

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 CHANGED
@@ -1062,14 +1062,14 @@ Login with the selected provider
1062
1062
  ### logout(...)
1063
1063
 
1064
1064
  ```typescript
1065
- logout(options: { provider: 'apple' | 'google' | 'facebook' | 'twitter' | 'telegram' | 'linkedin' | 'tiktok' | 'oauth2'; providerId?: string; }) => Promise<void>
1065
+ logout(options: { provider: 'apple' | 'google' | 'facebook' | 'twitter' | 'telegram' | 'linkedin' | 'tiktok' | 'oauth2'; providerId?: string; clearCachedUserInfo?: boolean; }) => Promise<void>
1066
1066
  ```
1067
1067
 
1068
1068
  Logout
1069
1069
 
1070
- | Param | Type |
1071
- | ------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
1072
- | **`options`** | <code>{ provider: 'apple' \| 'google' \| 'facebook' \| 'twitter' \| 'linkedin' \| 'tiktok' \| 'oauth2' \| 'telegram'; providerId?: string; }</code> |
1070
+ | Param | Type |
1071
+ | ------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
1072
+ | **`options`** | <code>{ provider: 'apple' \| 'google' \| 'facebook' \| 'twitter' \| 'linkedin' \| 'tiktok' \| 'oauth2' \| 'telegram'; providerId?: string; clearCachedUserInfo?: boolean; }</code> |
1073
1073
 
1074
1074
  --------------------
1075
1075
 
@@ -118,7 +118,8 @@ public class AppleProvider implements SocialProvider {
118
118
  AppleProvider.this.idToken = idToken;
119
119
  AppleProvider.this.refreshToken = refreshToken;
120
120
  AppleProvider.this.accessToken = accessToken;
121
- Log.i(SocialLoginPlugin.LOG_TAG, String.format("Apple restoreState: %s", object));
121
+ // The restored state holds the tokens, so it is not logged.
122
+ Log.i(SocialLoginPlugin.LOG_TAG, "Apple restoreState: restored");
122
123
  } catch (JSONException e) {
123
124
  Log.e(SocialLoginPlugin.LOG_TAG, "Apple restoreState: Failed to parse JSON", e);
124
125
  }
@@ -134,9 +135,9 @@ public class AppleProvider implements SocialProvider {
134
135
  String scheme = data.getScheme(); // "capgo-demo-app"
135
136
  String host = data.getHost(); // "path"
136
137
  String path = data.getPath(); // Additional path segments
137
- String query = data.getQuery(); // Query parameters
138
138
 
139
- Log.i(SocialLoginPlugin.LOG_TAG, String.format("Received apple login intent: %s, %s, %s, %s", scheme, host, path, query));
139
+ // The query carries the authorization code or the tokens, so it is not logged.
140
+ Log.i(SocialLoginPlugin.LOG_TAG, String.format("Received apple login intent: %s, %s, %s", scheme, host, path));
140
141
 
141
142
  handleUrl(data.toString());
142
143
  // if (data.toString().contains("success=")) {
@@ -424,10 +425,7 @@ public class AppleProvider implements SocialProvider {
424
425
  AppleProvider.this.lastcall.resolve(appleResponse);
425
426
  AppleProvider.this.lastcall = null;
426
427
  } else {
427
- Log.e(
428
- SocialLoginPlugin.LOG_TAG,
429
- "Cannot resolve access_token response: lastcall is null. Response: " + appleResponse.toString()
430
- );
428
+ Log.e(SocialLoginPlugin.LOG_TAG, "Cannot resolve access_token response: lastcall is null");
431
429
  }
432
430
  } catch (Exception e) {
433
431
  if (AppleProvider.this.lastcall != null) {
@@ -661,7 +659,7 @@ public class AppleProvider implements SocialProvider {
661
659
  JSONObject messageData = data.getJSONObject("data");
662
660
 
663
661
  Log.d("BroadcastChannel", "Received message from channel: " + channel);
664
- Log.d("BroadcastChannel", "Message data: " + messageData.toString());
662
+ // The message data carries the tokens, so it is not logged.
665
663
 
666
664
  // Handle authentication messages
667
665
  if ("auth".equals(channel)) {
@@ -27,7 +27,7 @@ import org.json.JSONObject;
27
27
  @CapacitorPlugin(name = "SocialLogin")
28
28
  public class SocialLoginPlugin extends Plugin {
29
29
 
30
- private final String pluginVersion = "8.6.0";
30
+ private final String pluginVersion = "8.7.0";
31
31
 
32
32
  public static String LOG_TAG = "CapgoSocialLogin";
33
33
  private static final String USER_CANCELLED_CODE = "USER_CANCELLED";
package/dist/docs.json CHANGED
@@ -56,19 +56,19 @@
56
56
  },
57
57
  {
58
58
  "name": "logout",
59
- "signature": "(options: { provider: 'apple' | 'google' | 'facebook' | 'twitter' | 'telegram' | 'linkedin' | 'tiktok' | 'oauth2'; providerId?: string; }) => Promise<void>",
59
+ "signature": "(options: { provider: 'apple' | 'google' | 'facebook' | 'twitter' | 'telegram' | 'linkedin' | 'tiktok' | 'oauth2'; providerId?: string; clearCachedUserInfo?: boolean; }) => Promise<void>",
60
60
  "parameters": [
61
61
  {
62
62
  "name": "options",
63
63
  "docs": "",
64
- "type": "{ provider: 'apple' | 'google' | 'facebook' | 'twitter' | 'linkedin' | 'tiktok' | 'oauth2' | 'telegram'; providerId?: string | undefined; }"
64
+ "type": "{ provider: 'apple' | 'google' | 'facebook' | 'twitter' | 'linkedin' | 'tiktok' | 'oauth2' | 'telegram'; providerId?: string | undefined; clearCachedUserInfo?: boolean | undefined; }"
65
65
  }
66
66
  ],
67
67
  "returns": "Promise<void>",
68
68
  "tags": [
69
69
  {
70
70
  "name": "description",
71
- "text": "Logout the user from the specified provider\n\n**Google Offline Mode Limitation:**\nThis method is NOT supported when Google is initialized with `mode: 'offline'`.\nIt will reject with error: \"logout is not implemented when using offline mode\"\n\n**Google Restore Credentials (Android):**\nWhen logging out from Google, the plugin also clears any stored Restore Credential\n(`google#clearRestoreCredential`) in addition to Credential Manager sign-in state."
71
+ "text": "Logout the user from the specified provider\n\n**Google Offline Mode Limitation:**\nThis method is NOT supported when Google is initialized with `mode: 'offline'`.\nIt will reject with error: \"logout is not implemented when using offline mode\"\n\n**Google Restore Credentials (Android):**\nWhen logging out from Google, the plugin also clears any stored Restore Credential\n(`google#clearRestoreCredential`) in addition to Credential Manager sign-in state.\n\n**Apple cached name (iOS):**\nThe plugin keeps the name Apple returns only on the first authorization, and logging out\nkeeps it. Pass `clearCachedUserInfo: true` to remove it too, for example on account deletion."
72
72
  },
73
73
  {
74
74
  "name": "throws",
@@ -1313,11 +1313,24 @@ export interface SocialLoginPlugin {
1313
1313
  * When logging out from Google, the plugin also clears any stored Restore Credential
1314
1314
  * (`google#clearRestoreCredential`) in addition to Credential Manager sign-in state.
1315
1315
  *
1316
+ * **Apple cached name (iOS):**
1317
+ * The plugin keeps the name Apple returns only on the first authorization, and logging out
1318
+ * keeps it. Pass `clearCachedUserInfo: true` to remove it too, for example on account deletion.
1319
+ *
1316
1320
  * @throws Error if Google provider is in offline mode
1317
1321
  */
1318
1322
  logout(options: {
1319
1323
  provider: 'apple' | 'google' | 'facebook' | 'twitter' | 'telegram' | 'linkedin' | 'tiktok' | 'oauth2';
1320
1324
  providerId?: string;
1325
+ /**
1326
+ * Apple on iOS: also remove the first and family name the plugin keeps on the device. Apple
1327
+ * returns the name only on the first authorization, so the plugin caches it to fill `givenName`
1328
+ * and `familyName` on later logins. Pass `true` when the user deletes their account, or should
1329
+ * otherwise leave no trace on the device. The name is removed even if no Apple session is held.
1330
+ * Ignored by other providers and platforms.
1331
+ * @default false
1332
+ */
1333
+ clearCachedUserInfo?: boolean;
1321
1334
  }): Promise<void>;
1322
1335
  /**
1323
1336
  * IsLoggedIn
@@ -1 +1 @@
1
- {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Configuration for a single OAuth2 provider instance\n */\nexport interface OAuth2ProviderConfig {\n /**\n * The OAuth 2.0 client identifier (App ID / Client ID).\n *\n * Note: this configuration object is only used by the plugin's built-in `oauth2` provider\n * (i.e. `SocialLogin.initialize({ oauth2: { ... } })`). It does not affect Google/Apple/Facebook/Twitter.\n * @example 'your-client-id'\n */\n appId?: string;\n /**\n * Alias for `appId` to match common OAuth/OIDC naming (`clientId`).\n * If both are provided, `appId` takes precedence.\n * @example 'your-client-id'\n */\n clientId?: string;\n /**\n * OpenID Connect issuer URL (enables discovery via `/.well-known/openid-configuration`).\n * When set, you may omit explicit endpoints like `authorizationBaseUrl` and `accessTokenEndpoint`.\n *\n * Notes:\n * - Explicit endpoints (authorization/token/logout) take precedence over discovered values.\n * - Discovery is supported for `oauth2` on Web, iOS, and Android.\n *\n * @example 'https://accounts.example.com'\n */\n issuerUrl?: string;\n /**\n * The base URL of the authorization endpoint\n * @example 'https://accounts.example.com/oauth2/authorize'\n */\n authorizationBaseUrl?: string;\n /**\n * Alias for `authorizationBaseUrl` (to match common OAuth/OIDC naming).\n * @example 'https://accounts.example.com/oauth2/authorize'\n */\n authorizationEndpoint?: string;\n /**\n * OAuth 2.0 client secret for token requests (e.g., when exchanging the code).\n * When provided, this value is sent using `clientSecretParamName` (default `client_secret`).\n */\n clientSecret?: string;\n /**\n * Override the client identifier parameter name used for authorization and token requests.\n * Some providers (e.g. TikTok) expect `client_key` instead of the default `client_id`.\n * @default 'client_id'\n */\n clientIdParamName?: string;\n /**\n * Override the client secret parameter name used for token requests.\n * Useful for providers that expect a different parameter name.\n * @default 'client_secret'\n */\n clientSecretParamName?: string;\n /**\n * The URL to exchange the authorization code for tokens\n * Required for authorization code flow\n * @example 'https://accounts.example.com/oauth2/token'\n */\n accessTokenEndpoint?: string;\n /**\n * Alias for `accessTokenEndpoint` (to match common OAuth/OIDC naming).\n * @example 'https://accounts.example.com/oauth2/token'\n */\n tokenEndpoint?: string;\n /**\n * Redirect URL that receives the OAuth callback\n * @example 'myapp://oauth/callback'\n */\n redirectUrl: string;\n /**\n * Optional URL to fetch user profile/resource data after authentication\n * The access token will be sent as Bearer token in the Authorization header\n * @example 'https://api.example.com/userinfo'\n */\n resourceUrl?: string;\n /**\n * The OAuth response type\n * - 'code': Authorization Code flow (recommended, requires accessTokenEndpoint)\n * - 'token': Implicit flow (less secure, tokens returned directly)\n * @default 'code'\n */\n responseType?: 'code' | 'token';\n /**\n * Enable PKCE (Proof Key for Code Exchange)\n * Strongly recommended for public clients (mobile/web apps)\n * @default true\n */\n pkceEnabled?: boolean;\n /**\n * Default scopes to request during authorization\n * @example 'openid profile email'\n * @example ['openid','profile','email']\n */\n scope?: string | string[];\n /**\n * Alias for `scope` using common naming (`scopes`).\n * If both are provided, `scope` takes precedence.\n */\n scopes?: string[];\n /**\n * Additional parameters to include in the authorization request\n * @example { prompt: 'consent', login_hint: 'user@example.com' }\n */\n additionalParameters?: Record<string, string>;\n /**\n * Convenience option for OIDC `login_hint`.\n * Equivalent to passing `additionalParameters.login_hint`.\n */\n loginHint?: string;\n /**\n * Convenience option for OAuth/OIDC `prompt`.\n * Equivalent to passing `additionalParameters.prompt`.\n */\n prompt?: string;\n /**\n * Additional parameters to include in token requests (code exchange / refresh).\n * Useful for providers that require non-standard parameters.\n */\n additionalTokenParameters?: Record<string, string>;\n /**\n * Additional headers to include when fetching the resource URL\n * @example { 'X-Custom-Header': 'value' }\n */\n additionalResourceHeaders?: Record<string, string>;\n /**\n * Custom logout URL for ending the session\n * @example 'https://accounts.example.com/logout'\n */\n logoutUrl?: string;\n /**\n * Alias for `logoutUrl` to match OIDC naming (`endSessionEndpoint`).\n * @example 'https://accounts.example.com/logout'\n */\n endSessionEndpoint?: string;\n /**\n * OIDC post logout redirect URL (sent as `post_logout_redirect_uri` when building the end-session URL).\n * @example 'myapp://logout/callback'\n */\n postLogoutRedirectUrl?: string;\n /**\n * Additional parameters to include in logout / end-session URL.\n */\n additionalLogoutParameters?: Record<string, string>;\n /**\n * iOS-only: Whether to prefer an ephemeral browser session for ASWebAuthenticationSession.\n * Defaults to true to match existing behavior in this plugin.\n */\n iosPrefersEphemeralWebBrowserSession?: boolean;\n /**\n * Alias for `iosPrefersEphemeralWebBrowserSession` (to match Capawesome OAuth naming).\n */\n iosPrefersEphemeralSession?: boolean;\n /**\n * Android-only: Use Chrome Custom Tabs (system browser) instead of an embedded WebView\n * for the authorization request.\n *\n * Custom Tabs follow RFC 8252 (OAuth 2.0 for Native Apps) and fix issues with brokered\n * IdPs (Microsoft Entra Conditional Access / Authenticator, passkeys/WebAuthn, Google\n * `disallowed_useragent`, SSO cookie sharing, password managers).\n *\n * Requires a custom-scheme or App Link `redirectUrl` with a matching intent filter in\n * your app's `AndroidManifest.xml` (same setup as `openSecureWindow()` / Apple on Android).\n *\n * Defaults to `false` to preserve the historical WebView flow.\n *\n * @default false\n * @example true\n */\n androidUseCustomTabs?: boolean;\n /**\n * Enable debug logging\n * @default false\n */\n logsEnabled?: boolean;\n}\n\n/**\n * LinkedIn provider configuration (convenience wrapper around the generic OAuth2 provider).\n *\n * Uses the OAuth2 engine with LinkedIn defaults:\n * - Authorization URL: https://www.linkedin.com/oauth/v2/authorization\n * - Token URL: https://www.linkedin.com/oauth/v2/accessToken\n * - Resource URL: https://api.linkedin.com/v2/userinfo\n * - Default scopes: `openid profile email`\n */\nexport interface LinkedInProviderConfig extends OAuth2ProviderConfig {\n /**\n * LinkedIn Client ID from the LinkedIn Developer Portal.\n */\n clientId: string;\n /**\n * Redirect URL that receives the OAuth callback.\n * Must match a redirect URL configured in the LinkedIn Developer Portal.\n * @example 'https://your-app.example/auth/linkedin'\n */\n redirectUrl: string;\n /**\n * LinkedIn Client Secret.\n *\n * Prefer exchanging the authorization code on a backend when possible.\n * Needed for confidential clients that do not use PKCE-only token exchange.\n */\n clientSecret?: string;\n}\n\n/**\n * TikTok Login Kit configuration (convenience wrapper around the generic OAuth2 provider).\n *\n * Uses TikTok OAuth 2.0 endpoints and `client_key` instead of `client_id`.\n * @see https://developers.tiktok.com/doc/login-kit-web\n */\nexport interface TikTokProviderConfig {\n /**\n * TikTok client key (also known as app key).\n * @example 'aw3y*****'\n */\n clientKey: string;\n /**\n * Redirect URL registered in your TikTok developer app.\n * @example 'myapp://auth/tiktok'\n */\n redirectUrl: string;\n /**\n * TikTok client secret. Optional.\n * When set, the plugin includes it on token and refresh requests.\n * On web this value is stored with the OAuth2 config.\n * Login always exchanges the authorization code in the plugin; the raw code is not returned to the app.\n */\n clientSecret?: string;\n /**\n * Scopes to request during login. Arrays are sent as a comma-separated string (TikTok Login Kit).\n * @default ['user.info.basic']\n * @example ['user.info.basic','video.list']\n */\n scopes?: string[];\n /**\n * Alias for `scopes`.\n */\n scope?: string | string[];\n /**\n * Toggle PKCE usage during the authorization code flow.\n * @default true\n */\n pkceEnabled?: boolean;\n /**\n * Enable verbose debug logging for the TikTok OAuth2 flow.\n * @default false\n */\n logsEnabled?: boolean;\n}\n\n/**\n * Options for `refreshToken()`.\n * `providerId` is required for generic `oauth2` and ignored for LinkedIn and TikTok.\n */\nexport type RefreshTokenOptions =\n | {\n provider: 'oauth2';\n providerId: string;\n refreshToken?: string;\n additionalParameters?: Record<string, string>;\n }\n | {\n provider: 'linkedin';\n providerId?: string;\n refreshToken?: string;\n additionalParameters?: Record<string, string>;\n }\n | {\n provider: 'tiktok';\n providerId?: string;\n refreshToken?: string;\n additionalParameters?: Record<string, string>;\n };\n\nexport interface InitializeOptions {\n /**\n * OAuth2 provider configurations.\n * Supports multiple providers by using a Record with provider IDs as keys.\n * @example\n * {\n * github: { appId: '...', authorizationBaseUrl: 'https://github.com/login/oauth/authorize', ... },\n * azure: { appId: '...', authorizationBaseUrl: 'https://login.microsoftonline.com/.../oauth2/v2.0/authorize', ... }\n * }\n */\n oauth2?: Record<string, OAuth2ProviderConfig>;\n /**\n * Telegram Login Widget configuration.\n * Uses Telegram's OAuth widget (`oauth.telegram.org`), not standard OAuth2.\n */\n telegram?: {\n /**\n * Telegram bot ID (numeric, not the bot token).\n * @example '123456789'\n */\n botId: string;\n /**\n * Default redirect URL that will receive Telegram auth data.\n * For mobile apps, prefer a custom scheme (e.g. `myapp://telegram-auth`).\n * On iOS/Android this must be set here or per login; native login rejects if it is missing.\n */\n redirectUrl?: string;\n /**\n * Origin/domain registered for the Telegram login widget.\n * Required when `redirectUrl` is not `http`/`https` (for example a custom scheme like `myapp://telegram-auth`).\n * Defaults to the origin of `redirectUrl` only when that URL is already http(s).\n * @example 'https://example.com'\n */\n origin?: string;\n /**\n * Requested access level.\n * @default 'write'\n */\n requestAccess?: 'read' | 'write';\n /**\n * Optional language code passed to Telegram (e.g. 'en', 'fr').\n */\n languageCode?: string;\n };\n /**\n * LinkedIn configuration.\n * Convenience wrapper that maps to the OAuth2 provider using LinkedIn defaults.\n */\n linkedin?: LinkedInProviderConfig;\n /**\n * TikTok Login Kit configuration.\n * Convenience wrapper that maps to the OAuth2 provider using TikTok defaults (`client_key`).\n */\n tiktok?: TikTokProviderConfig;\n twitter?: {\n /**\n * The OAuth 2.0 client identifier issued by X (Twitter) Developer Portal\n * @example 'Y2xpZW50SWQ'\n */\n clientId: string;\n /**\n * Redirect URL that is registered inside the X Developer Portal.\n * The plugin uses this URL on every platform to receive the authorization code.\n * @example 'myapp://auth/x'\n */\n redirectUrl: string;\n /**\n * Default scopes appended to every login request when no custom scopes are provided.\n * @description Defaults to the minimum required scopes for Log in with X.\n * @default ['tweet.read','users.read']\n */\n defaultScopes?: string[];\n /**\n * Force the consent screen to show on every login attempt.\n * Mirrors X's `force_login=true` flag.\n * @default false\n */\n forceLogin?: boolean;\n /**\n * Optional audience value when your application has been approved for multi-tenant access.\n */\n audience?: string;\n };\n facebook?: {\n /**\n * Facebook App ID, provided by Facebook for web, in mobile it's set in the native files\n * @description For business integrations, use your Business App ID from Facebook Developer Console.\n * Business apps can access additional permissions like Instagram API, Pages API, and business management features.\n * @see docs/facebook_business_login.md for business app setup guide\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 * Locale\n * @description The locale to use for the Facebook SDK (e.g., 'en_US', 'fr_FR', 'es_ES')\n * @default 'en_US'\n * @example 'fr_FR'\n */\n locale?: 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 *\n * **Online mode (default):**\n * - Returns user profile data and access tokens\n * - Supports all methods: login, logout, isLoggedIn, getAuthorizationCode\n *\n * **Offline mode:**\n * - Returns only serverAuthCode for backend authentication\n * - No user profile data available\n * - **Limitations:** The following methods are NOT supported in offline mode:\n * - `logout()` - Will reject with \"not implemented when using offline mode\"\n * - `isLoggedIn()` - Will reject with \"not implemented when using offline mode\"\n * - `getAuthorizationCode()` - Will reject with \"not implemented when using offline mode\"\n * - `refresh()` - Will reject because offline mode only returns `serverAuthCode`; token refresh must happen on your backend\n * - Only `login()` method works in offline mode, returning serverAuthCode only\n * - `serverAuthCode` must be exchanged on your backend for access/refresh tokens\n * - Requires `iOSServerClientId` to be set on iOS\n *\n * @example 'offline'\n * @default 'online'\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 * **Note**: Not required when using Broadcast Channel mode on Android.\n */\n redirectUrl?: string;\n /**\n * Use proper token exchange for Apple Sign-In\n * @description Controls how Apple Sign-In tokens are handled and what gets returned:\n *\n * **When `true` (Recommended for new implementations):**\n * - Exchanges authorization code for proper access tokens via Apple's token endpoint\n * - `idToken`: JWT containing user identity information (email, name, user ID)\n * - `accessToken.token`: Proper access token from Apple (short-lived, ~1 hour)\n * - `authorizationCode`: Raw authorization code for backend token exchange\n *\n * **When `false` (Default - Legacy mode):**\n * - Uses authorization code directly as access token for backward compatibility\n * - `idToken`: JWT containing user identity information (email, name, user ID)\n * - `accessToken.token`: The authorization code itself (not a real access token)\n * - `authorizationCode`: undefined\n *\n * @default false\n * @example\n * // Enable proper token exchange (recommended)\n * useProperTokenExchange: true\n * // Result: idToken=JWT, accessToken=real_token, authorizationCode=present\n *\n * // Legacy mode (backward compatibility)\n * useProperTokenExchange: false\n * // Result: idToken=JWT, accessToken=auth_code, authorizationCode=undefined\n */\n useProperTokenExchange?: boolean;\n /**\n * Use Broadcast Channel for Android Apple Sign-In (Recommended)\n * @description When enabled, Android uses Broadcast Channel API instead of URL redirects.\n * This eliminates the need for redirect URL configuration and server-side setup.\n *\n * **Benefits:**\n * - No redirect URL configuration required\n * - No backend server needed for Android\n * - Simpler setup and more reliable communication\n * - Direct client-server communication via Broadcast Channel\n *\n * **When `true`:**\n * - Uses Broadcast Channel for authentication flow\n * - `redirectUrl` is ignored\n * - Requires Broadcast Channel compatible backend or direct token handling\n *\n * **When `false` (Default - Legacy mode):**\n * - Uses traditional URL redirect flow\n * - Requires `redirectUrl` configuration\n * - Requires backend server for token exchange\n *\n * @default false\n * @since 7.10.0\n * @example\n * // Enable Broadcast Channel mode (recommended for new Android implementations)\n * useBroadcastChannel: true\n * // Result: Simplified setup, no redirect URL needed\n *\n * // Legacy mode (backward compatibility)\n * useBroadcastChannel: false\n * // Result: Traditional URL redirect flow with server-side setup\n */\n useBroadcastChannel?: boolean;\n };\n}\n\nexport interface FacebookLoginOptions {\n /**\n * Permissions\n * @description Select permissions to login with. Supports both consumer and business permissions.\n *\n * **Consumer Permissions:**\n * - `email` - User's email address\n * - `public_profile` - User's public profile info\n * - `user_friends` - List of friends who also use your app\n *\n * **Business Permissions** (require business app configuration and may need App Review):\n * - `instagram_basic` - Instagram Basic Display API access\n * - `instagram_manage_insights` - Instagram Insights data\n * - `instagram_manage_comments` - Manage Instagram comments\n * - `instagram_content_publish` - Publish to Instagram\n * - `pages_show_list` - List of Pages managed by user\n * - `pages_read_engagement` - Read Page engagement metrics\n * - `pages_manage_posts` - Manage Page posts\n * - `pages_messaging` - Page messaging features\n * - `business_management` - Manage business assets\n * - `catalog_management` - Manage product catalogs\n * - `ads_management` - Manage advertising accounts\n *\n * @example ['email', 'public_profile'] // Consumer permissions\n * @example ['email', 'instagram_basic', 'pages_show_list'] // Business permissions\n * @see https://developers.facebook.com/docs/permissions/reference\n * @see docs/facebook_business_login.md for complete business integration guide\n */\n permissions: string[];\n /**\n * Is Limited Login\n * @description use limited login for Facebook iOS only. Important: This is iOS-only and doesn't affect Android.\n * Even if set to false, Facebook will automatically force it to true if App Tracking Transparency (ATT) permission is not granted.\n * Developers should always be prepared to handle both limited and full login scenarios.\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 TwitterLoginOptions {\n /**\n * Additional scopes to request during login.\n * If omitted the plugin falls back to the default scopes configured during initialization.\n * @example ['tweet.read','users.read','offline.access']\n */\n scopes?: string[];\n /**\n * Provide a custom OAuth state value.\n * When not provided the plugin generates a cryptographically random value.\n */\n state?: string;\n /**\n * Provide a pre-computed PKCE code verifier (mostly used for testing).\n * When omitted the plugin generates a secure verifier automatically.\n */\n codeVerifier?: string;\n /**\n * Override the redirect URI for a single login call.\n * Useful when the same app supports multiple callback URLs per platform.\n */\n redirectUrl?: string;\n /**\n * Force the consent screen on every attempt, maps to `force_login=true`.\n */\n forceLogin?: boolean;\n}\n\nexport interface TelegramLoginOptions {\n /**\n * Override the redirect URL for this login attempt.\n * Defaults to the redirect configured during initialize().\n * Required on iOS/Android when initialize() did not set `redirectUrl`.\n */\n redirectUrl?: string;\n /**\n * Optional state parameter for CSRF protection.\n * If omitted, a secure random value is generated automatically.\n */\n state?: string;\n /**\n * Override requested access level for this login.\n * Defaults to the value configured during initialize().\n * @default 'write'\n */\n requestAccess?: 'read' | 'write';\n}\n\nexport interface OAuth2LoginOptions {\n /**\n * The provider ID as configured in initialize()\n * This is required to identify which OAuth2 provider to use\n * @example 'github', 'azure', 'keycloak'\n */\n providerId: string;\n /**\n * Override the scopes for this login request\n * If not provided, uses the scopes from initialization\n */\n scope?: string | string[];\n /**\n * Alias for `scope` using common naming (`scopes`).\n * If both are provided, `scope` takes precedence.\n */\n scopes?: string[];\n /**\n * Custom state parameter for CSRF protection\n * If not provided, a random value is generated\n */\n state?: string;\n /**\n * Override PKCE code verifier (for testing purposes)\n * If not provided, a secure random verifier is generated\n */\n codeVerifier?: string;\n /**\n * Override redirect URL for this login request\n */\n redirectUrl?: string;\n /**\n * Additional parameters to add to the authorization URL\n */\n additionalParameters?: Record<string, string>;\n /**\n * Convenience option for OIDC `login_hint`.\n * Equivalent to passing `additionalParameters.login_hint`.\n */\n loginHint?: string;\n /**\n * Convenience option for OAuth/OIDC `prompt`.\n * Equivalent to passing `additionalParameters.prompt`.\n */\n prompt?: string;\n /**\n * Web-only (`oauth2` provider only): Use a full-page redirect instead of a popup window.\n *\n * When using `redirect`, the promise returned by `login()` will not resolve because the page navigates away.\n * After the redirect lands back in your app, call `SocialLogin.handleRedirectCallback()` on that page to\n * parse the result.\n *\n * @default 'popup'\n */\n flow?: 'popup' | 'redirect';\n}\n\n/**\n * LinkedIn login options (maps to the OAuth2 provider internally).\n * `providerId` is set to `linkedin` automatically.\n */\nexport type LinkedInLoginOptions = Omit<OAuth2LoginOptions, 'providerId'>;\n\nexport interface TikTokLoginOptions {\n /**\n * Optional scopes to override the initialization scopes.\n * @example ['user.info.basic']\n */\n scopes?: string[];\n /**\n * Alias for `scopes`.\n */\n scope?: string | string[];\n /**\n * Custom state parameter for CSRF protection.\n */\n state?: string;\n /**\n * Custom PKCE code verifier (mostly for testing).\n */\n codeVerifier?: string;\n /**\n * Override redirect URL for this login request.\n */\n redirectUrl?: string;\n}\n\nexport interface OAuth2LoginResponse {\n /**\n * The provider ID that was used for this login\n */\n providerId: string;\n /**\n * The access token received from the OAuth provider\n */\n accessToken: AccessToken | null;\n /**\n * The ID token (JWT) if provided by the OAuth server (e.g., OpenID Connect)\n */\n idToken: string | null;\n /**\n * The refresh token if provided (requires appropriate scope like offline_access)\n */\n refreshToken: string | null;\n /**\n * Resource data fetched from resourceUrl if configured\n * Contains the raw JSON response from the resource endpoint\n */\n resourceData: Record<string, unknown> | null;\n /**\n * The scopes that were granted\n */\n scope: string[];\n /**\n * Token type (usually 'bearer')\n */\n tokenType: string;\n /**\n * Token expiration time in seconds\n */\n expiresIn: number | null;\n}\n\n/**\n * LinkedIn login response (returned when using the LinkedIn convenience API).\n */\nexport type LinkedInLoginResponse = OAuth2LoginResponse;\n\n/**\n * TikTok login response (same shape as generic OAuth2).\n */\nexport type TikTokLoginResponse = OAuth2LoginResponse;\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 * @note On Android, the OS caches access tokens, and if a token is invalid (e.g., user revoked app access), the plugin might return an invalid accessToken. Using getAuthorizationCode() is recommended to ensure the token is valid.\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 false\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 * Prompt parameter for Google OAuth (Web only)\n * @description A space-delimited, case-sensitive list of prompts to present the user.\n * If you don't specify this parameter, the user will be prompted only the first time your project requests access.\n *\n * **Possible values:**\n * - `none`: Don't display any authentication or consent screens. Must not be specified with other values.\n * - `consent`: Prompt the user for consent.\n * - `select_account`: Prompt the user to select an account.\n *\n * **Examples:**\n * - `prompt: 'consent'` - Always show consent screen\n * - `prompt: 'select_account'` - Always show account selection\n * - `prompt: 'consent select_account'` - Show both consent and account selection\n *\n * **Note:** This parameter only affects web platform behavior. Mobile platforms use their own native prompts.\n *\n * @example 'consent'\n * @example 'select_account'\n * @example 'consent select_account'\n * @see [Google OAuth2 Prompt Parameter](https://developers.google.com/identity/protocols/oauth2/openid-connect#prompt)\n * @since 7.12.0\n */\n prompt?: 'none' | 'consent' | 'select_account' | 'consent select_account' | 'select_account consent';\n}\n\nexport interface GoogleLoginResponseOnline {\n /**\n * OAuth access token for Google APIs.\n *\n * May be `null` on Android when Credential Manager authentication succeeds but\n * AuthorizationClient does not return an access token (authentication-only /\n * ID-token login with default OIDC scopes). Use `idToken` for user authentication;\n * request additional Google API scopes when an access token is required.\n */\n accessToken: AccessToken | null;\n /**\n * OpenID Connect ID token (JWT).\n *\n * Includes an `email_verified` claim when the `email` scope is granted. Use\n * `SocialLogin.decodeIdToken({ idToken })` to read claims on the client, but\n * always verify the token signature, `iss`, `aud`, and `exp` on your backend\n * before trusting `email_verified` for account linking.\n *\n * @see https://developers.google.com/identity/gsi/web/guides/verify-google-id-token\n */\n idToken: string | null;\n profile: {\n /**\n * Email from the ID token payload. Does not include a separate verification flag;\n * check `idToken` claims (`email_verified`) for whether Google attests the address.\n */\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 * Use Broadcast Channel for authentication flow\n * @description When enabled, uses Broadcast Channel API for communication instead of URL redirects.\n * Only applicable on platforms that support Broadcast Channel (Android).\n * @default false\n */\n useBroadcastChannel?: boolean;\n}\n\nexport interface AppleProviderResponse {\n /**\n * Access token from Apple\n * @description Content depends on `useProperTokenExchange` setting:\n * - When `useProperTokenExchange: true`: Real access token from Apple (~1 hour validity)\n * - When `useProperTokenExchange: false`: Contains authorization code as token (legacy mode)\n * Use `idToken` for user authentication, `accessToken` for API calls when properly exchanged.\n */\n accessToken: AccessToken | null;\n\n /**\n * Identity token (JWT) from Apple.\n *\n * Includes standard OIDC claims such as `sub`, `email` (when granted), and\n * `email_verified` (boolean). Apple sets `email_verified` to `true` when it\n * attests the user controls the email (including Hide My Email relay addresses).\n *\n * Use `SocialLogin.decodeIdToken({ idToken })` to read claims on the client, but\n * verify the token signature, `iss`, `aud`, and `exp` on your backend before\n * trusting `email_verified` for account linking.\n *\n * @see https://developer.apple.com/documentation/signinwithapple/authenticating-users-with-sign-in-with-apple\n */\n idToken: string | null;\n\n /**\n * User profile information\n * @description Basic user profile data extracted from the identity token and Apple response:\n * - `user`: Apple's user identifier (sub claim from idToken)\n * - `email`: User's email address (if permission granted)\n * - `givenName`: User's first name (if permission granted)\n * - `familyName`: User's last name (if permission granted)\n */\n profile: {\n user: string;\n email: string | null;\n givenName: string | null;\n familyName: string | null;\n };\n\n /**\n * Authorization code for proper token exchange (when useProperTokenExchange is enabled)\n * @description Only present when `useProperTokenExchange` is `true`. This code should be exchanged\n * for proper access tokens on your backend using Apple's token endpoint. Use this for secure\n * server-side token validation and to obtain refresh tokens.\n * @see https://developer.apple.com/documentation/sign_in_with_apple/tokenresponse\n */\n authorizationCode?: string;\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 | {\n provider: 'twitter';\n options: TwitterLoginOptions;\n }\n | {\n provider: 'telegram';\n options: TelegramLoginOptions;\n }\n | {\n provider: 'linkedin';\n options: LinkedInLoginOptions;\n }\n | {\n provider: 'tiktok';\n options: TikTokLoginOptions;\n }\n | {\n provider: 'oauth2';\n options: OAuth2LoginOptions;\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 | {\n provider: 'twitter';\n result: TwitterLoginResponse;\n }\n | {\n provider: 'telegram';\n result: TelegramLoginResponse;\n }\n | {\n provider: 'linkedin';\n result: LinkedInLoginResponse;\n }\n | {\n provider: 'tiktok';\n result: TikTokLoginResponse;\n }\n | {\n provider: 'oauth2';\n result: OAuth2LoginResponse;\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 tokenType?: string;\n refreshToken?: string;\n userId?: string;\n}\n\nexport interface FacebookLoginResponse {\n accessToken: AccessToken | null;\n /**\n * Whether Facebook Limited Login was used for this session.\n * When `true`, `accessToken` is not valid for Graph API calls (Facebook error 190).\n * Validate `idToken` on your backend instead, or call `facebook#requestTracking` and log in again after ATT is granted.\n * @since 8.4.0\n */\n isLimitedLogin?: boolean;\n /**\n * OpenID Connect ID token (JWT) from Meta Limited Login (iOS native, when available).\n *\n * **Not equivalent to Google/Apple `email_verified`:** Meta's OIDC token may include\n * an `email` claim (when the `email` permission is granted) but does **not** publish an\n * `email_verified` claim like Google or Apple. Meta documents the value as the user's\n * primary account email, not as an OIDC-verified email assertion.\n *\n * On Android and Web this is usually `null` (Graph API access token flow instead).\n * Validate signature, `iss` (`https://www.facebook.com` or `https://limited.facebook.com`),\n * `aud`, `exp`, and nonce on your backend. Do not infer `email_verified: true` from the\n * presence of `email` alone when linking accounts across providers.\n *\n * @see https://developers.facebook.com/docs/facebook-login/limited-login/token/validating/\n */\n idToken: string | null;\n profile: {\n userID: string;\n /**\n * Primary email from the Meta profile / Graph API (`/me?fields=email`).\n *\n * **Not equivalent to Google/Apple `email_verified`:** this field has no verification\n * flag. Meta returns the account's primary email when the `email` permission is\n * granted; it does not expose an `email_verified` boolean comparable to Google or\n * Apple ID tokens. Treat this as an identifier hint only—verify ownership yourself\n * (e.g. magic link) before linking Meta sign-in to Google/Apple accounts by email.\n */\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 TwitterProfile {\n id: string;\n username: string;\n name: string | null;\n profileImageUrl: string | null;\n verified: boolean;\n email?: string | null;\n}\n\nexport interface TwitterLoginResponse {\n accessToken: AccessToken | null;\n refreshToken?: string | null;\n scope: string[];\n tokenType: 'bearer';\n expiresIn?: number | null;\n profile: TwitterProfile;\n}\n\nexport interface TelegramProfile {\n id: string;\n firstName: string;\n lastName?: string | null;\n username?: string | null;\n photoUrl?: string | null;\n}\n\nexport interface TelegramLoginResponse {\n profile: TelegramProfile;\n /**\n * Unix timestamp (seconds) when the user authorized the login.\n */\n authDate: number;\n /**\n * Telegram-provided hash for server-side verification.\n */\n hash: string;\n /**\n * Requested access level that was used for this login.\n */\n requestAccess: 'read' | 'write';\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' | 'twitter' | 'linkedin' | 'tiktok' | 'oauth2';\n /**\n * Provider ID for OAuth2 providers (required when provider is 'oauth2')\n * @description The ID used when configuring the OAuth2 provider in initialize()\n */\n providerId?: string;\n}\n\nexport interface isLoggedInOptions {\n /**\n * Provider\n * @description Provider for the isLoggedIn\n */\n provider: 'apple' | 'google' | 'facebook' | 'twitter' | 'telegram' | 'linkedin' | 'tiktok' | 'oauth2';\n /**\n * Provider ID for OAuth2 providers (required when provider is 'oauth2')\n * @description The ID used when configuring the OAuth2 provider in initialize()\n */\n providerId?: string;\n}\n\n// Define the provider-specific call types\n/**\n * Options for `providerSpecificCall` with `google#createRestoreCredential`.\n *\n * Android-only. Creates a Restore Credential (restore key) via Credential Manager after the user\n * signs in. Your backend must supply WebAuthn PublicKeyCredentialCreationOptionsJSON (the same\n * FIDO2/passkey registration flow used for passkeys).\n *\n * @see https://developer.android.com/identity/sign-in/restore-credentials\n * @since 8.5.0\n */\nexport interface GoogleCreateRestoreCredentialOptions {\n /**\n * Credential creation options from your server in WebAuthn PublicKeyCredentialCreationOptionsJSON format.\n */\n requestJson: string;\n /**\n * When `true` (default), the restore key is backed up to the cloud when the user has backup and\n * end-to-end encryption (e.g. screen lock) enabled. If cloud backup creation fails with\n * `E2eeUnavailableException` on Android, the plugin automatically retries with local-only storage.\n * @default true\n */\n isCloudBackupEnabled?: boolean;\n}\n\n/**\n * Response from `google#createRestoreCredential`.\n *\n * Send `responseJson` to your server to complete restore key registration (same as passkey creation).\n */\nexport interface GoogleCreateRestoreCredentialResponse {\n /** Public key credential registration response JSON from Credential Manager. */\n responseJson: string;\n}\n\n/**\n * Options for `providerSpecificCall` with `google#getRestoreCredential`.\n *\n * Android-only. Retrieves a Restore Credential silently (e.g. on first launch on a new device or from\n * BackupAgent `onRestoreFinished`). Your backend must supply WebAuthn authentication request JSON.\n */\nexport interface GoogleGetRestoreCredentialOptions {\n /**\n * Credential request options from your server (WebAuthn authentication request JSON).\n */\n requestJson: string;\n}\n\n/**\n * Response from `google#getRestoreCredential`.\n *\n * Send `responseJson` to your server to sign the user in (same server path as passkey authentication).\n */\nexport interface GoogleGetRestoreCredentialResponse {\n /** Restore credential authentication response JSON from Credential Manager. */\n responseJson: string;\n}\n\n/** Options for `google#clearRestoreCredential` (no fields). */\nexport type GoogleClearRestoreCredentialOptions = Record<string, never>;\n\n/** Response from `google#clearRestoreCredential`. */\nexport interface GoogleClearRestoreCredentialResponse {\n /** Whether the restore credential clear request completed successfully. */\n cleared: boolean;\n}\n\nexport type ProviderSpecificCall =\n | 'facebook#getProfile'\n | 'facebook#requestTracking'\n | 'google#createRestoreCredential'\n | 'google#getRestoreCredential'\n | 'google#clearRestoreCredential';\n\n// Define the options and response types for each specific call\nexport interface FacebookGetProfileOptions {\n /**\n * Fields to retrieve from Facebook profile.\n * @default ['id', 'name', 'email', 'picture']\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 interface OpenSecureWindowOptions {\n /**\n * The endpoint to open\n */\n authEndpoint: string;\n /**\n * The redirect URI to use for the openSecureWindow call.\n * This will be checked to make sure it matches the redirect URI after the window finishes the redirection.\n */\n redirectUri: string;\n /**\n * The name of the broadcast channel to listen to, relevant only for web\n */\n broadcastChannelName?: string;\n}\n\nexport interface OpenSecureWindowResponse {\n /**\n * The result of the openSecureWindow call\n */\n redirectedUri: string;\n}\n\nexport interface OpenAuthSessionOptions {\n /**\n * Authorization or login URL to open in the system browser session (OAuth/OIDC authorize endpoint, SSO login page, etc.).\n * @example 'https://login.example.com/oauth2/authorize?client_id=...&redirect_uri=...&state=...'\n */\n url: string;\n /**\n * Custom URL scheme that receives the redirect (without `://`).\n * Must match the scheme in your registered redirect URI and native URL handler (iOS/Android).\n * On Web, the plugin also accepts HTTPS redirect URLs when `redirect_uri` is present in `url`, or messages prefixed with `${callbackURLScheme}://` on the BroadcastChannel.\n * @example 'myapp'\n */\n callbackURLScheme: string;\n /**\n * iOS-only: prefer an ephemeral `ASWebAuthenticationSession` (no shared cookies with Safari).\n * Defaults to `false` so SSO cookies in the system browser can be reused.\n */\n prefersEphemeralSession?: boolean;\n /**\n * Web-only: `BroadcastChannel` name used by the redirect page to post the callback URL back to the app.\n * @default 'capgo-auth-session'\n */\n broadcastChannelName?: string;\n}\n\nexport interface OpenAuthSessionResult {\n /**\n * Full redirect URI returned by the identity provider, including query or fragment (e.g. `myapp://auth/callback?code=...&state=...`).\n */\n callbackURL: string;\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 'google#createRestoreCredential': GoogleCreateRestoreCredentialOptions;\n 'google#getRestoreCredential': GoogleGetRestoreCredentialOptions;\n 'google#clearRestoreCredential': GoogleClearRestoreCredentialOptions;\n};\n\nexport type ProviderSpecificCallResponseMap = {\n 'facebook#getProfile': FacebookGetProfileResponse;\n 'facebook#requestTracking': FacebookRequestTrackingResponse;\n 'google#createRestoreCredential': GoogleCreateRestoreCredentialResponse;\n 'google#getRestoreCredential': GoogleGetRestoreCredentialResponse;\n 'google#clearRestoreCredential': GoogleClearRestoreCredentialResponse;\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 twitter: TwitterLoginResponse;\n telegram: TelegramLoginResponse;\n linkedin: LinkedInLoginResponse;\n tiktok: TikTokLoginResponse;\n oauth2: OAuth2LoginResponse;\n};\n\n/**\n * Error codes returned by the plugin.\n * @since 8.3.x\n */\nexport type SocialLoginErrorCode = 'USER_CANCELLED';\n\n/**\n * Errors thrown by SocialLogin methods.\n *\n * When a user dismisses or cancels the provider UI (popup closed, system dialog cancelled, access denied, etc.),\n * the plugin rejects with `code === 'USER_CANCELLED'` so the caller can distinguish user intent from real failures.\n * Other errors may omit the code or use provider-specific values.\n */\nexport interface SocialLoginError extends Error {\n code?: SocialLoginErrorCode | string;\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 * On user dismissal/cancellation, the Promise is rejected with `code === 'USER_CANCELLED'` (see `SocialLoginError`).\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 from the specified provider\n *\n * **Google Offline Mode Limitation:**\n * This method is NOT supported when Google is initialized with `mode: 'offline'`.\n * It will reject with error: \"logout is not implemented when using offline mode\"\n *\n * **Google Restore Credentials (Android):**\n * When logging out from Google, the plugin also clears any stored Restore Credential\n * (`google#clearRestoreCredential`) in addition to Credential Manager sign-in state.\n *\n * @throws Error if Google provider is in offline mode\n */\n logout(options: {\n provider: 'apple' | 'google' | 'facebook' | 'twitter' | 'telegram' | 'linkedin' | 'tiktok' | 'oauth2';\n providerId?: string;\n }): Promise<void>;\n /**\n * IsLoggedIn\n * @description Check if the user is currently logged in with the specified provider\n *\n * **Google Offline Mode Limitation:**\n * This method is NOT supported when Google is initialized with `mode: 'offline'`.\n * It will reject with error: \"isLoggedIn is not implemented when using offline mode\"\n *\n * @throws Error if Google provider is in offline mode\n */\n isLoggedIn(options: isLoggedInOptions): Promise<{ isLoggedIn: boolean }>;\n\n /**\n * Get the current authorization code\n * @description Get the authorization code for server-side authentication\n *\n * **Google Offline Mode Limitation:**\n * This method is NOT supported when Google is initialized with `mode: 'offline'`.\n * It will reject with error: \"getAuthorizationCode is not implemented when using offline mode\"\n *\n * In offline mode, the authorization code (serverAuthCode) is already returned by the `login()` method.\n *\n * Telegram login does not produce an authorization code; use the `hash` from `login()` and verify it on your backend.\n *\n * @throws Error if Google provider is in offline mode\n */\n getAuthorizationCode(options: AuthorizationCodeOptions): Promise<AuthorizationCode>;\n /**\n * Refresh the access token\n * @description refresh the access token\n *\n * **Google Offline Mode Limitation:**\n * This method is NOT supported when Google is initialized with `mode: 'offline'`.\n * Offline mode only returns `serverAuthCode` for backend token exchange, so token refresh must happen on your backend.\n * The plugin logs and rejects with a message explaining that you should send `serverAuthCode` to your backend,\n * refresh the Google tokens there, or switch to `mode: 'online'` for client-side refresh.\n *\n * **Google Web Limitation:**\n * On Web, Google `refresh()` is not implemented, even when using `mode: 'online'`.\n * Call `login()` again on Web to obtain a fresh token instead.\n *\n * @throws Error if Google provider is in offline mode, or on Web where Google `refresh()` is not implemented\n */\n refresh(options: LoginOptions): Promise<void>;\n\n /**\n * OAuth2 refresh-token helper (feature parity with Capawesome OAuth).\n *\n * Scope:\n * - Applies to the built-in `oauth2` provider and the LinkedIn and TikTok convenience wrappers.\n * - Requires a token endpoint (either `accessTokenEndpoint`/`tokenEndpoint` or `issuerUrl` discovery).\n *\n * Security note:\n * - This does not validate JWT signatures. It only exchanges/refreshes tokens.\n *\n * If `refreshToken` is omitted, the plugin will attempt to use the stored refresh token (if available).\n */\n refreshToken(options: RefreshTokenOptions): Promise<OAuth2LoginResponse>;\n\n /**\n * Web-only: handle the OAuth redirect callback and return the parsed result.\n *\n * Notes:\n * - This is only meaningful on Web. iOS/Android implementations will reject.\n * - Intended for redirect-based flows (e.g. `oauth2` with `flow: 'redirect'`) where the page navigates away.\n * - LinkedIn convenience logins (`provider: 'linkedin'`, `flow: 'redirect'`) return `provider: 'linkedin'`.\n * The same app used as `oauth2` with `providerId: 'linkedin'` keeps `provider: 'oauth2'`.\n */\n handleRedirectCallback(): Promise<LoginResult | null>;\n\n /**\n * Decode a JWT (typically an OIDC ID token) into its claims.\n *\n * Notes:\n * - Accepts both `idToken` and `token` to match common naming (Capawesome uses `token`).\n * - This does not validate the signature or issuer/audience. It only base64url-decodes the payload.\n *\n * **`email_verified` semantics by provider (for account linking):**\n * - **Google** — ID token includes `email_verified` (boolean). When `true`, Google attests\n * the user controls that email. Verify the JWT on your backend before trusting it.\n * - **Apple** — ID token includes `email_verified` (boolean). When `true`, Apple attests\n * the user controls that email (including private relay). Verify the JWT on your backend.\n * - **Meta (Facebook)** — Limited Login OIDC tokens may include `email` but **do not**\n * include `email_verified`. The presence of `email` is not the same guarantee as\n * `email_verified: true` from Google or Apple. Do not link accounts by email across\n * providers using Meta claims alone; perform your own email verification if needed.\n */\n decodeIdToken(options: { idToken?: string; token?: string }): Promise<{ claims: Record<string, any> }>;\n\n /**\n * Convert an access token expiration timestamp (milliseconds since epoch) to an ISO date string.\n *\n * This is a pure helper (feature parity with Capawesome OAuth) and does not depend on provider state.\n */\n getAccessTokenExpirationDate(options: {\n /**\n * Access token expiration date in milliseconds since epoch.\n * Typically: `Date.now() + expiresInSeconds * 1000`.\n */\n accessTokenExpirationDate: number;\n }): Promise<{ date: string }>;\n\n /**\n * Check if an access token is available (non-empty).\n *\n * This is a pure helper (feature parity with Capawesome OAuth) and does not depend on provider state.\n */\n isAccessTokenAvailable(options: { accessToken: string | null }): Promise<{ isAvailable: boolean }>;\n\n /**\n * Check if an access token is expired.\n *\n * This is a pure helper (feature parity with Capawesome OAuth) and does not depend on provider state.\n */\n isAccessTokenExpired(options: { accessTokenExpirationDate: number }): Promise<{ isExpired: boolean }>;\n\n /**\n * Check if a refresh token is available (non-empty).\n *\n * This is a pure helper (feature parity with Capawesome OAuth) and does not depend on provider state.\n */\n isRefreshTokenAvailable(options: { refreshToken: string | null }): Promise<{ isAvailable: boolean }>;\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 /**\n * Get the native Capacitor plugin version\n *\n * @returns {Promise<{ id: string }>} an Promise with version for this device\n * @throws An error if the something went wrong\n */\n getPluginVersion(): Promise<{ version: string }>;\n\n /**\n * Opens a secured window for OAuth2 authentication.\n * For web, you should have the code in the redirected page to use a broadcast channel to send the redirected url to the app\n * Something like:\n * ```html\n * <html>\n * <head></head>\n * <body>\n * <script>\n * const searchParams = new URLSearchParams(location.search)\n * if (searchParams.has(\"code\")) {\n * new BroadcastChannel(\"my-channel-name\").postMessage(location.href);\n * window.close();\n * }\n * </script>\n * </body>\n * </html>\n * ```\n * For mobile, you should have a redirect uri that opens the app, something like: `myapp://oauth_callback/`\n * And make sure to register it in the app's info.plist:\n * ```xml\n * <key>CFBundleURLTypes</key>\n * <array>\n * <dict>\n * <key>CFBundleURLSchemes</key>\n * <array>\n * <string>myapp</string>\n * </array>\n * </dict>\n * </array>\n * ```\n * And in the AndroidManifest.xml file:\n * ```xml\n * <activity>\n * <intent-filter>\n * <action android:name=\"android.intent.action.VIEW\" />\n * <category android:name=\"android.intent.category.DEFAULT\" />\n * <category android:name=\"android.intent.category.BROWSABLE\" />\n * <data android:host=\"oauth_callback\" android:scheme=\"myapp\" />\n * </intent-filter>\n * </activity>\n * ```\n * @param options - the options for the openSecureWindow call\n */\n openSecureWindow(options: OpenSecureWindowOptions): Promise<OpenSecureWindowResponse>;\n\n /**\n * Opens a system auth session for generic OAuth/OIDC or enterprise SSO.\n *\n * Use this when you build the authorize URL yourself (or your IdP SDK returns one) and only need\n * the plugin to run the secure browser flow and return the redirect callback URL. Exchange the\n * authorization code or tokens on your backend or with your own client logic.\n *\n * **iOS/Android:** system browser session (`ASWebAuthenticationSession` / Chrome Custom Tabs).\n * **Web:** popup window plus `BroadcastChannel` (not a native browser session).\n *\n * On user cancel or dismiss, the Promise rejects with `code === 'USER_CANCELLED'`.\n *\n * @param options - auth session options\n */\n openAuthSession(options: OpenAuthSessionOptions): Promise<OpenAuthSessionResult>;\n}\n"]}
1
+ {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Configuration for a single OAuth2 provider instance\n */\nexport interface OAuth2ProviderConfig {\n /**\n * The OAuth 2.0 client identifier (App ID / Client ID).\n *\n * Note: this configuration object is only used by the plugin's built-in `oauth2` provider\n * (i.e. `SocialLogin.initialize({ oauth2: { ... } })`). It does not affect Google/Apple/Facebook/Twitter.\n * @example 'your-client-id'\n */\n appId?: string;\n /**\n * Alias for `appId` to match common OAuth/OIDC naming (`clientId`).\n * If both are provided, `appId` takes precedence.\n * @example 'your-client-id'\n */\n clientId?: string;\n /**\n * OpenID Connect issuer URL (enables discovery via `/.well-known/openid-configuration`).\n * When set, you may omit explicit endpoints like `authorizationBaseUrl` and `accessTokenEndpoint`.\n *\n * Notes:\n * - Explicit endpoints (authorization/token/logout) take precedence over discovered values.\n * - Discovery is supported for `oauth2` on Web, iOS, and Android.\n *\n * @example 'https://accounts.example.com'\n */\n issuerUrl?: string;\n /**\n * The base URL of the authorization endpoint\n * @example 'https://accounts.example.com/oauth2/authorize'\n */\n authorizationBaseUrl?: string;\n /**\n * Alias for `authorizationBaseUrl` (to match common OAuth/OIDC naming).\n * @example 'https://accounts.example.com/oauth2/authorize'\n */\n authorizationEndpoint?: string;\n /**\n * OAuth 2.0 client secret for token requests (e.g., when exchanging the code).\n * When provided, this value is sent using `clientSecretParamName` (default `client_secret`).\n */\n clientSecret?: string;\n /**\n * Override the client identifier parameter name used for authorization and token requests.\n * Some providers (e.g. TikTok) expect `client_key` instead of the default `client_id`.\n * @default 'client_id'\n */\n clientIdParamName?: string;\n /**\n * Override the client secret parameter name used for token requests.\n * Useful for providers that expect a different parameter name.\n * @default 'client_secret'\n */\n clientSecretParamName?: string;\n /**\n * The URL to exchange the authorization code for tokens\n * Required for authorization code flow\n * @example 'https://accounts.example.com/oauth2/token'\n */\n accessTokenEndpoint?: string;\n /**\n * Alias for `accessTokenEndpoint` (to match common OAuth/OIDC naming).\n * @example 'https://accounts.example.com/oauth2/token'\n */\n tokenEndpoint?: string;\n /**\n * Redirect URL that receives the OAuth callback\n * @example 'myapp://oauth/callback'\n */\n redirectUrl: string;\n /**\n * Optional URL to fetch user profile/resource data after authentication\n * The access token will be sent as Bearer token in the Authorization header\n * @example 'https://api.example.com/userinfo'\n */\n resourceUrl?: string;\n /**\n * The OAuth response type\n * - 'code': Authorization Code flow (recommended, requires accessTokenEndpoint)\n * - 'token': Implicit flow (less secure, tokens returned directly)\n * @default 'code'\n */\n responseType?: 'code' | 'token';\n /**\n * Enable PKCE (Proof Key for Code Exchange)\n * Strongly recommended for public clients (mobile/web apps)\n * @default true\n */\n pkceEnabled?: boolean;\n /**\n * Default scopes to request during authorization\n * @example 'openid profile email'\n * @example ['openid','profile','email']\n */\n scope?: string | string[];\n /**\n * Alias for `scope` using common naming (`scopes`).\n * If both are provided, `scope` takes precedence.\n */\n scopes?: string[];\n /**\n * Additional parameters to include in the authorization request\n * @example { prompt: 'consent', login_hint: 'user@example.com' }\n */\n additionalParameters?: Record<string, string>;\n /**\n * Convenience option for OIDC `login_hint`.\n * Equivalent to passing `additionalParameters.login_hint`.\n */\n loginHint?: string;\n /**\n * Convenience option for OAuth/OIDC `prompt`.\n * Equivalent to passing `additionalParameters.prompt`.\n */\n prompt?: string;\n /**\n * Additional parameters to include in token requests (code exchange / refresh).\n * Useful for providers that require non-standard parameters.\n */\n additionalTokenParameters?: Record<string, string>;\n /**\n * Additional headers to include when fetching the resource URL\n * @example { 'X-Custom-Header': 'value' }\n */\n additionalResourceHeaders?: Record<string, string>;\n /**\n * Custom logout URL for ending the session\n * @example 'https://accounts.example.com/logout'\n */\n logoutUrl?: string;\n /**\n * Alias for `logoutUrl` to match OIDC naming (`endSessionEndpoint`).\n * @example 'https://accounts.example.com/logout'\n */\n endSessionEndpoint?: string;\n /**\n * OIDC post logout redirect URL (sent as `post_logout_redirect_uri` when building the end-session URL).\n * @example 'myapp://logout/callback'\n */\n postLogoutRedirectUrl?: string;\n /**\n * Additional parameters to include in logout / end-session URL.\n */\n additionalLogoutParameters?: Record<string, string>;\n /**\n * iOS-only: Whether to prefer an ephemeral browser session for ASWebAuthenticationSession.\n * Defaults to true to match existing behavior in this plugin.\n */\n iosPrefersEphemeralWebBrowserSession?: boolean;\n /**\n * Alias for `iosPrefersEphemeralWebBrowserSession` (to match Capawesome OAuth naming).\n */\n iosPrefersEphemeralSession?: boolean;\n /**\n * Android-only: Use Chrome Custom Tabs (system browser) instead of an embedded WebView\n * for the authorization request.\n *\n * Custom Tabs follow RFC 8252 (OAuth 2.0 for Native Apps) and fix issues with brokered\n * IdPs (Microsoft Entra Conditional Access / Authenticator, passkeys/WebAuthn, Google\n * `disallowed_useragent`, SSO cookie sharing, password managers).\n *\n * Requires a custom-scheme or App Link `redirectUrl` with a matching intent filter in\n * your app's `AndroidManifest.xml` (same setup as `openSecureWindow()` / Apple on Android).\n *\n * Defaults to `false` to preserve the historical WebView flow.\n *\n * @default false\n * @example true\n */\n androidUseCustomTabs?: boolean;\n /**\n * Enable debug logging\n * @default false\n */\n logsEnabled?: boolean;\n}\n\n/**\n * LinkedIn provider configuration (convenience wrapper around the generic OAuth2 provider).\n *\n * Uses the OAuth2 engine with LinkedIn defaults:\n * - Authorization URL: https://www.linkedin.com/oauth/v2/authorization\n * - Token URL: https://www.linkedin.com/oauth/v2/accessToken\n * - Resource URL: https://api.linkedin.com/v2/userinfo\n * - Default scopes: `openid profile email`\n */\nexport interface LinkedInProviderConfig extends OAuth2ProviderConfig {\n /**\n * LinkedIn Client ID from the LinkedIn Developer Portal.\n */\n clientId: string;\n /**\n * Redirect URL that receives the OAuth callback.\n * Must match a redirect URL configured in the LinkedIn Developer Portal.\n * @example 'https://your-app.example/auth/linkedin'\n */\n redirectUrl: string;\n /**\n * LinkedIn Client Secret.\n *\n * Prefer exchanging the authorization code on a backend when possible.\n * Needed for confidential clients that do not use PKCE-only token exchange.\n */\n clientSecret?: string;\n}\n\n/**\n * TikTok Login Kit configuration (convenience wrapper around the generic OAuth2 provider).\n *\n * Uses TikTok OAuth 2.0 endpoints and `client_key` instead of `client_id`.\n * @see https://developers.tiktok.com/doc/login-kit-web\n */\nexport interface TikTokProviderConfig {\n /**\n * TikTok client key (also known as app key).\n * @example 'aw3y*****'\n */\n clientKey: string;\n /**\n * Redirect URL registered in your TikTok developer app.\n * @example 'myapp://auth/tiktok'\n */\n redirectUrl: string;\n /**\n * TikTok client secret. Optional.\n * When set, the plugin includes it on token and refresh requests.\n * On web this value is stored with the OAuth2 config.\n * Login always exchanges the authorization code in the plugin; the raw code is not returned to the app.\n */\n clientSecret?: string;\n /**\n * Scopes to request during login. Arrays are sent as a comma-separated string (TikTok Login Kit).\n * @default ['user.info.basic']\n * @example ['user.info.basic','video.list']\n */\n scopes?: string[];\n /**\n * Alias for `scopes`.\n */\n scope?: string | string[];\n /**\n * Toggle PKCE usage during the authorization code flow.\n * @default true\n */\n pkceEnabled?: boolean;\n /**\n * Enable verbose debug logging for the TikTok OAuth2 flow.\n * @default false\n */\n logsEnabled?: boolean;\n}\n\n/**\n * Options for `refreshToken()`.\n * `providerId` is required for generic `oauth2` and ignored for LinkedIn and TikTok.\n */\nexport type RefreshTokenOptions =\n | {\n provider: 'oauth2';\n providerId: string;\n refreshToken?: string;\n additionalParameters?: Record<string, string>;\n }\n | {\n provider: 'linkedin';\n providerId?: string;\n refreshToken?: string;\n additionalParameters?: Record<string, string>;\n }\n | {\n provider: 'tiktok';\n providerId?: string;\n refreshToken?: string;\n additionalParameters?: Record<string, string>;\n };\n\nexport interface InitializeOptions {\n /**\n * OAuth2 provider configurations.\n * Supports multiple providers by using a Record with provider IDs as keys.\n * @example\n * {\n * github: { appId: '...', authorizationBaseUrl: 'https://github.com/login/oauth/authorize', ... },\n * azure: { appId: '...', authorizationBaseUrl: 'https://login.microsoftonline.com/.../oauth2/v2.0/authorize', ... }\n * }\n */\n oauth2?: Record<string, OAuth2ProviderConfig>;\n /**\n * Telegram Login Widget configuration.\n * Uses Telegram's OAuth widget (`oauth.telegram.org`), not standard OAuth2.\n */\n telegram?: {\n /**\n * Telegram bot ID (numeric, not the bot token).\n * @example '123456789'\n */\n botId: string;\n /**\n * Default redirect URL that will receive Telegram auth data.\n * For mobile apps, prefer a custom scheme (e.g. `myapp://telegram-auth`).\n * On iOS/Android this must be set here or per login; native login rejects if it is missing.\n */\n redirectUrl?: string;\n /**\n * Origin/domain registered for the Telegram login widget.\n * Required when `redirectUrl` is not `http`/`https` (for example a custom scheme like `myapp://telegram-auth`).\n * Defaults to the origin of `redirectUrl` only when that URL is already http(s).\n * @example 'https://example.com'\n */\n origin?: string;\n /**\n * Requested access level.\n * @default 'write'\n */\n requestAccess?: 'read' | 'write';\n /**\n * Optional language code passed to Telegram (e.g. 'en', 'fr').\n */\n languageCode?: string;\n };\n /**\n * LinkedIn configuration.\n * Convenience wrapper that maps to the OAuth2 provider using LinkedIn defaults.\n */\n linkedin?: LinkedInProviderConfig;\n /**\n * TikTok Login Kit configuration.\n * Convenience wrapper that maps to the OAuth2 provider using TikTok defaults (`client_key`).\n */\n tiktok?: TikTokProviderConfig;\n twitter?: {\n /**\n * The OAuth 2.0 client identifier issued by X (Twitter) Developer Portal\n * @example 'Y2xpZW50SWQ'\n */\n clientId: string;\n /**\n * Redirect URL that is registered inside the X Developer Portal.\n * The plugin uses this URL on every platform to receive the authorization code.\n * @example 'myapp://auth/x'\n */\n redirectUrl: string;\n /**\n * Default scopes appended to every login request when no custom scopes are provided.\n * @description Defaults to the minimum required scopes for Log in with X.\n * @default ['tweet.read','users.read']\n */\n defaultScopes?: string[];\n /**\n * Force the consent screen to show on every login attempt.\n * Mirrors X's `force_login=true` flag.\n * @default false\n */\n forceLogin?: boolean;\n /**\n * Optional audience value when your application has been approved for multi-tenant access.\n */\n audience?: string;\n };\n facebook?: {\n /**\n * Facebook App ID, provided by Facebook for web, in mobile it's set in the native files\n * @description For business integrations, use your Business App ID from Facebook Developer Console.\n * Business apps can access additional permissions like Instagram API, Pages API, and business management features.\n * @see docs/facebook_business_login.md for business app setup guide\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 * Locale\n * @description The locale to use for the Facebook SDK (e.g., 'en_US', 'fr_FR', 'es_ES')\n * @default 'en_US'\n * @example 'fr_FR'\n */\n locale?: 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 *\n * **Online mode (default):**\n * - Returns user profile data and access tokens\n * - Supports all methods: login, logout, isLoggedIn, getAuthorizationCode\n *\n * **Offline mode:**\n * - Returns only serverAuthCode for backend authentication\n * - No user profile data available\n * - **Limitations:** The following methods are NOT supported in offline mode:\n * - `logout()` - Will reject with \"not implemented when using offline mode\"\n * - `isLoggedIn()` - Will reject with \"not implemented when using offline mode\"\n * - `getAuthorizationCode()` - Will reject with \"not implemented when using offline mode\"\n * - `refresh()` - Will reject because offline mode only returns `serverAuthCode`; token refresh must happen on your backend\n * - Only `login()` method works in offline mode, returning serverAuthCode only\n * - `serverAuthCode` must be exchanged on your backend for access/refresh tokens\n * - Requires `iOSServerClientId` to be set on iOS\n *\n * @example 'offline'\n * @default 'online'\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 * **Note**: Not required when using Broadcast Channel mode on Android.\n */\n redirectUrl?: string;\n /**\n * Use proper token exchange for Apple Sign-In\n * @description Controls how Apple Sign-In tokens are handled and what gets returned:\n *\n * **When `true` (Recommended for new implementations):**\n * - Exchanges authorization code for proper access tokens via Apple's token endpoint\n * - `idToken`: JWT containing user identity information (email, name, user ID)\n * - `accessToken.token`: Proper access token from Apple (short-lived, ~1 hour)\n * - `authorizationCode`: Raw authorization code for backend token exchange\n *\n * **When `false` (Default - Legacy mode):**\n * - Uses authorization code directly as access token for backward compatibility\n * - `idToken`: JWT containing user identity information (email, name, user ID)\n * - `accessToken.token`: The authorization code itself (not a real access token)\n * - `authorizationCode`: undefined\n *\n * @default false\n * @example\n * // Enable proper token exchange (recommended)\n * useProperTokenExchange: true\n * // Result: idToken=JWT, accessToken=real_token, authorizationCode=present\n *\n * // Legacy mode (backward compatibility)\n * useProperTokenExchange: false\n * // Result: idToken=JWT, accessToken=auth_code, authorizationCode=undefined\n */\n useProperTokenExchange?: boolean;\n /**\n * Use Broadcast Channel for Android Apple Sign-In (Recommended)\n * @description When enabled, Android uses Broadcast Channel API instead of URL redirects.\n * This eliminates the need for redirect URL configuration and server-side setup.\n *\n * **Benefits:**\n * - No redirect URL configuration required\n * - No backend server needed for Android\n * - Simpler setup and more reliable communication\n * - Direct client-server communication via Broadcast Channel\n *\n * **When `true`:**\n * - Uses Broadcast Channel for authentication flow\n * - `redirectUrl` is ignored\n * - Requires Broadcast Channel compatible backend or direct token handling\n *\n * **When `false` (Default - Legacy mode):**\n * - Uses traditional URL redirect flow\n * - Requires `redirectUrl` configuration\n * - Requires backend server for token exchange\n *\n * @default false\n * @since 7.10.0\n * @example\n * // Enable Broadcast Channel mode (recommended for new Android implementations)\n * useBroadcastChannel: true\n * // Result: Simplified setup, no redirect URL needed\n *\n * // Legacy mode (backward compatibility)\n * useBroadcastChannel: false\n * // Result: Traditional URL redirect flow with server-side setup\n */\n useBroadcastChannel?: boolean;\n };\n}\n\nexport interface FacebookLoginOptions {\n /**\n * Permissions\n * @description Select permissions to login with. Supports both consumer and business permissions.\n *\n * **Consumer Permissions:**\n * - `email` - User's email address\n * - `public_profile` - User's public profile info\n * - `user_friends` - List of friends who also use your app\n *\n * **Business Permissions** (require business app configuration and may need App Review):\n * - `instagram_basic` - Instagram Basic Display API access\n * - `instagram_manage_insights` - Instagram Insights data\n * - `instagram_manage_comments` - Manage Instagram comments\n * - `instagram_content_publish` - Publish to Instagram\n * - `pages_show_list` - List of Pages managed by user\n * - `pages_read_engagement` - Read Page engagement metrics\n * - `pages_manage_posts` - Manage Page posts\n * - `pages_messaging` - Page messaging features\n * - `business_management` - Manage business assets\n * - `catalog_management` - Manage product catalogs\n * - `ads_management` - Manage advertising accounts\n *\n * @example ['email', 'public_profile'] // Consumer permissions\n * @example ['email', 'instagram_basic', 'pages_show_list'] // Business permissions\n * @see https://developers.facebook.com/docs/permissions/reference\n * @see docs/facebook_business_login.md for complete business integration guide\n */\n permissions: string[];\n /**\n * Is Limited Login\n * @description use limited login for Facebook iOS only. Important: This is iOS-only and doesn't affect Android.\n * Even if set to false, Facebook will automatically force it to true if App Tracking Transparency (ATT) permission is not granted.\n * Developers should always be prepared to handle both limited and full login scenarios.\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 TwitterLoginOptions {\n /**\n * Additional scopes to request during login.\n * If omitted the plugin falls back to the default scopes configured during initialization.\n * @example ['tweet.read','users.read','offline.access']\n */\n scopes?: string[];\n /**\n * Provide a custom OAuth state value.\n * When not provided the plugin generates a cryptographically random value.\n */\n state?: string;\n /**\n * Provide a pre-computed PKCE code verifier (mostly used for testing).\n * When omitted the plugin generates a secure verifier automatically.\n */\n codeVerifier?: string;\n /**\n * Override the redirect URI for a single login call.\n * Useful when the same app supports multiple callback URLs per platform.\n */\n redirectUrl?: string;\n /**\n * Force the consent screen on every attempt, maps to `force_login=true`.\n */\n forceLogin?: boolean;\n}\n\nexport interface TelegramLoginOptions {\n /**\n * Override the redirect URL for this login attempt.\n * Defaults to the redirect configured during initialize().\n * Required on iOS/Android when initialize() did not set `redirectUrl`.\n */\n redirectUrl?: string;\n /**\n * Optional state parameter for CSRF protection.\n * If omitted, a secure random value is generated automatically.\n */\n state?: string;\n /**\n * Override requested access level for this login.\n * Defaults to the value configured during initialize().\n * @default 'write'\n */\n requestAccess?: 'read' | 'write';\n}\n\nexport interface OAuth2LoginOptions {\n /**\n * The provider ID as configured in initialize()\n * This is required to identify which OAuth2 provider to use\n * @example 'github', 'azure', 'keycloak'\n */\n providerId: string;\n /**\n * Override the scopes for this login request\n * If not provided, uses the scopes from initialization\n */\n scope?: string | string[];\n /**\n * Alias for `scope` using common naming (`scopes`).\n * If both are provided, `scope` takes precedence.\n */\n scopes?: string[];\n /**\n * Custom state parameter for CSRF protection\n * If not provided, a random value is generated\n */\n state?: string;\n /**\n * Override PKCE code verifier (for testing purposes)\n * If not provided, a secure random verifier is generated\n */\n codeVerifier?: string;\n /**\n * Override redirect URL for this login request\n */\n redirectUrl?: string;\n /**\n * Additional parameters to add to the authorization URL\n */\n additionalParameters?: Record<string, string>;\n /**\n * Convenience option for OIDC `login_hint`.\n * Equivalent to passing `additionalParameters.login_hint`.\n */\n loginHint?: string;\n /**\n * Convenience option for OAuth/OIDC `prompt`.\n * Equivalent to passing `additionalParameters.prompt`.\n */\n prompt?: string;\n /**\n * Web-only (`oauth2` provider only): Use a full-page redirect instead of a popup window.\n *\n * When using `redirect`, the promise returned by `login()` will not resolve because the page navigates away.\n * After the redirect lands back in your app, call `SocialLogin.handleRedirectCallback()` on that page to\n * parse the result.\n *\n * @default 'popup'\n */\n flow?: 'popup' | 'redirect';\n}\n\n/**\n * LinkedIn login options (maps to the OAuth2 provider internally).\n * `providerId` is set to `linkedin` automatically.\n */\nexport type LinkedInLoginOptions = Omit<OAuth2LoginOptions, 'providerId'>;\n\nexport interface TikTokLoginOptions {\n /**\n * Optional scopes to override the initialization scopes.\n * @example ['user.info.basic']\n */\n scopes?: string[];\n /**\n * Alias for `scopes`.\n */\n scope?: string | string[];\n /**\n * Custom state parameter for CSRF protection.\n */\n state?: string;\n /**\n * Custom PKCE code verifier (mostly for testing).\n */\n codeVerifier?: string;\n /**\n * Override redirect URL for this login request.\n */\n redirectUrl?: string;\n}\n\nexport interface OAuth2LoginResponse {\n /**\n * The provider ID that was used for this login\n */\n providerId: string;\n /**\n * The access token received from the OAuth provider\n */\n accessToken: AccessToken | null;\n /**\n * The ID token (JWT) if provided by the OAuth server (e.g., OpenID Connect)\n */\n idToken: string | null;\n /**\n * The refresh token if provided (requires appropriate scope like offline_access)\n */\n refreshToken: string | null;\n /**\n * Resource data fetched from resourceUrl if configured\n * Contains the raw JSON response from the resource endpoint\n */\n resourceData: Record<string, unknown> | null;\n /**\n * The scopes that were granted\n */\n scope: string[];\n /**\n * Token type (usually 'bearer')\n */\n tokenType: string;\n /**\n * Token expiration time in seconds\n */\n expiresIn: number | null;\n}\n\n/**\n * LinkedIn login response (returned when using the LinkedIn convenience API).\n */\nexport type LinkedInLoginResponse = OAuth2LoginResponse;\n\n/**\n * TikTok login response (same shape as generic OAuth2).\n */\nexport type TikTokLoginResponse = OAuth2LoginResponse;\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 * @note On Android, the OS caches access tokens, and if a token is invalid (e.g., user revoked app access), the plugin might return an invalid accessToken. Using getAuthorizationCode() is recommended to ensure the token is valid.\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 false\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 * Prompt parameter for Google OAuth (Web only)\n * @description A space-delimited, case-sensitive list of prompts to present the user.\n * If you don't specify this parameter, the user will be prompted only the first time your project requests access.\n *\n * **Possible values:**\n * - `none`: Don't display any authentication or consent screens. Must not be specified with other values.\n * - `consent`: Prompt the user for consent.\n * - `select_account`: Prompt the user to select an account.\n *\n * **Examples:**\n * - `prompt: 'consent'` - Always show consent screen\n * - `prompt: 'select_account'` - Always show account selection\n * - `prompt: 'consent select_account'` - Show both consent and account selection\n *\n * **Note:** This parameter only affects web platform behavior. Mobile platforms use their own native prompts.\n *\n * @example 'consent'\n * @example 'select_account'\n * @example 'consent select_account'\n * @see [Google OAuth2 Prompt Parameter](https://developers.google.com/identity/protocols/oauth2/openid-connect#prompt)\n * @since 7.12.0\n */\n prompt?: 'none' | 'consent' | 'select_account' | 'consent select_account' | 'select_account consent';\n}\n\nexport interface GoogleLoginResponseOnline {\n /**\n * OAuth access token for Google APIs.\n *\n * May be `null` on Android when Credential Manager authentication succeeds but\n * AuthorizationClient does not return an access token (authentication-only /\n * ID-token login with default OIDC scopes). Use `idToken` for user authentication;\n * request additional Google API scopes when an access token is required.\n */\n accessToken: AccessToken | null;\n /**\n * OpenID Connect ID token (JWT).\n *\n * Includes an `email_verified` claim when the `email` scope is granted. Use\n * `SocialLogin.decodeIdToken({ idToken })` to read claims on the client, but\n * always verify the token signature, `iss`, `aud`, and `exp` on your backend\n * before trusting `email_verified` for account linking.\n *\n * @see https://developers.google.com/identity/gsi/web/guides/verify-google-id-token\n */\n idToken: string | null;\n profile: {\n /**\n * Email from the ID token payload. Does not include a separate verification flag;\n * check `idToken` claims (`email_verified`) for whether Google attests the address.\n */\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 * Use Broadcast Channel for authentication flow\n * @description When enabled, uses Broadcast Channel API for communication instead of URL redirects.\n * Only applicable on platforms that support Broadcast Channel (Android).\n * @default false\n */\n useBroadcastChannel?: boolean;\n}\n\nexport interface AppleProviderResponse {\n /**\n * Access token from Apple\n * @description Content depends on `useProperTokenExchange` setting:\n * - When `useProperTokenExchange: true`: Real access token from Apple (~1 hour validity)\n * - When `useProperTokenExchange: false`: Contains authorization code as token (legacy mode)\n * Use `idToken` for user authentication, `accessToken` for API calls when properly exchanged.\n */\n accessToken: AccessToken | null;\n\n /**\n * Identity token (JWT) from Apple.\n *\n * Includes standard OIDC claims such as `sub`, `email` (when granted), and\n * `email_verified` (boolean). Apple sets `email_verified` to `true` when it\n * attests the user controls the email (including Hide My Email relay addresses).\n *\n * Use `SocialLogin.decodeIdToken({ idToken })` to read claims on the client, but\n * verify the token signature, `iss`, `aud`, and `exp` on your backend before\n * trusting `email_verified` for account linking.\n *\n * @see https://developer.apple.com/documentation/signinwithapple/authenticating-users-with-sign-in-with-apple\n */\n idToken: string | null;\n\n /**\n * User profile information\n * @description Basic user profile data extracted from the identity token and Apple response:\n * - `user`: Apple's user identifier (sub claim from idToken)\n * - `email`: User's email address (if permission granted)\n * - `givenName`: User's first name (if permission granted)\n * - `familyName`: User's last name (if permission granted)\n */\n profile: {\n user: string;\n email: string | null;\n givenName: string | null;\n familyName: string | null;\n };\n\n /**\n * Authorization code for proper token exchange (when useProperTokenExchange is enabled)\n * @description Only present when `useProperTokenExchange` is `true`. This code should be exchanged\n * for proper access tokens on your backend using Apple's token endpoint. Use this for secure\n * server-side token validation and to obtain refresh tokens.\n * @see https://developer.apple.com/documentation/sign_in_with_apple/tokenresponse\n */\n authorizationCode?: string;\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 | {\n provider: 'twitter';\n options: TwitterLoginOptions;\n }\n | {\n provider: 'telegram';\n options: TelegramLoginOptions;\n }\n | {\n provider: 'linkedin';\n options: LinkedInLoginOptions;\n }\n | {\n provider: 'tiktok';\n options: TikTokLoginOptions;\n }\n | {\n provider: 'oauth2';\n options: OAuth2LoginOptions;\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 | {\n provider: 'twitter';\n result: TwitterLoginResponse;\n }\n | {\n provider: 'telegram';\n result: TelegramLoginResponse;\n }\n | {\n provider: 'linkedin';\n result: LinkedInLoginResponse;\n }\n | {\n provider: 'tiktok';\n result: TikTokLoginResponse;\n }\n | {\n provider: 'oauth2';\n result: OAuth2LoginResponse;\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 tokenType?: string;\n refreshToken?: string;\n userId?: string;\n}\n\nexport interface FacebookLoginResponse {\n accessToken: AccessToken | null;\n /**\n * Whether Facebook Limited Login was used for this session.\n * When `true`, `accessToken` is not valid for Graph API calls (Facebook error 190).\n * Validate `idToken` on your backend instead, or call `facebook#requestTracking` and log in again after ATT is granted.\n * @since 8.4.0\n */\n isLimitedLogin?: boolean;\n /**\n * OpenID Connect ID token (JWT) from Meta Limited Login (iOS native, when available).\n *\n * **Not equivalent to Google/Apple `email_verified`:** Meta's OIDC token may include\n * an `email` claim (when the `email` permission is granted) but does **not** publish an\n * `email_verified` claim like Google or Apple. Meta documents the value as the user's\n * primary account email, not as an OIDC-verified email assertion.\n *\n * On Android and Web this is usually `null` (Graph API access token flow instead).\n * Validate signature, `iss` (`https://www.facebook.com` or `https://limited.facebook.com`),\n * `aud`, `exp`, and nonce on your backend. Do not infer `email_verified: true` from the\n * presence of `email` alone when linking accounts across providers.\n *\n * @see https://developers.facebook.com/docs/facebook-login/limited-login/token/validating/\n */\n idToken: string | null;\n profile: {\n userID: string;\n /**\n * Primary email from the Meta profile / Graph API (`/me?fields=email`).\n *\n * **Not equivalent to Google/Apple `email_verified`:** this field has no verification\n * flag. Meta returns the account's primary email when the `email` permission is\n * granted; it does not expose an `email_verified` boolean comparable to Google or\n * Apple ID tokens. Treat this as an identifier hint only—verify ownership yourself\n * (e.g. magic link) before linking Meta sign-in to Google/Apple accounts by email.\n */\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 TwitterProfile {\n id: string;\n username: string;\n name: string | null;\n profileImageUrl: string | null;\n verified: boolean;\n email?: string | null;\n}\n\nexport interface TwitterLoginResponse {\n accessToken: AccessToken | null;\n refreshToken?: string | null;\n scope: string[];\n tokenType: 'bearer';\n expiresIn?: number | null;\n profile: TwitterProfile;\n}\n\nexport interface TelegramProfile {\n id: string;\n firstName: string;\n lastName?: string | null;\n username?: string | null;\n photoUrl?: string | null;\n}\n\nexport interface TelegramLoginResponse {\n profile: TelegramProfile;\n /**\n * Unix timestamp (seconds) when the user authorized the login.\n */\n authDate: number;\n /**\n * Telegram-provided hash for server-side verification.\n */\n hash: string;\n /**\n * Requested access level that was used for this login.\n */\n requestAccess: 'read' | 'write';\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' | 'twitter' | 'linkedin' | 'tiktok' | 'oauth2';\n /**\n * Provider ID for OAuth2 providers (required when provider is 'oauth2')\n * @description The ID used when configuring the OAuth2 provider in initialize()\n */\n providerId?: string;\n}\n\nexport interface isLoggedInOptions {\n /**\n * Provider\n * @description Provider for the isLoggedIn\n */\n provider: 'apple' | 'google' | 'facebook' | 'twitter' | 'telegram' | 'linkedin' | 'tiktok' | 'oauth2';\n /**\n * Provider ID for OAuth2 providers (required when provider is 'oauth2')\n * @description The ID used when configuring the OAuth2 provider in initialize()\n */\n providerId?: string;\n}\n\n// Define the provider-specific call types\n/**\n * Options for `providerSpecificCall` with `google#createRestoreCredential`.\n *\n * Android-only. Creates a Restore Credential (restore key) via Credential Manager after the user\n * signs in. Your backend must supply WebAuthn PublicKeyCredentialCreationOptionsJSON (the same\n * FIDO2/passkey registration flow used for passkeys).\n *\n * @see https://developer.android.com/identity/sign-in/restore-credentials\n * @since 8.5.0\n */\nexport interface GoogleCreateRestoreCredentialOptions {\n /**\n * Credential creation options from your server in WebAuthn PublicKeyCredentialCreationOptionsJSON format.\n */\n requestJson: string;\n /**\n * When `true` (default), the restore key is backed up to the cloud when the user has backup and\n * end-to-end encryption (e.g. screen lock) enabled. If cloud backup creation fails with\n * `E2eeUnavailableException` on Android, the plugin automatically retries with local-only storage.\n * @default true\n */\n isCloudBackupEnabled?: boolean;\n}\n\n/**\n * Response from `google#createRestoreCredential`.\n *\n * Send `responseJson` to your server to complete restore key registration (same as passkey creation).\n */\nexport interface GoogleCreateRestoreCredentialResponse {\n /** Public key credential registration response JSON from Credential Manager. */\n responseJson: string;\n}\n\n/**\n * Options for `providerSpecificCall` with `google#getRestoreCredential`.\n *\n * Android-only. Retrieves a Restore Credential silently (e.g. on first launch on a new device or from\n * BackupAgent `onRestoreFinished`). Your backend must supply WebAuthn authentication request JSON.\n */\nexport interface GoogleGetRestoreCredentialOptions {\n /**\n * Credential request options from your server (WebAuthn authentication request JSON).\n */\n requestJson: string;\n}\n\n/**\n * Response from `google#getRestoreCredential`.\n *\n * Send `responseJson` to your server to sign the user in (same server path as passkey authentication).\n */\nexport interface GoogleGetRestoreCredentialResponse {\n /** Restore credential authentication response JSON from Credential Manager. */\n responseJson: string;\n}\n\n/** Options for `google#clearRestoreCredential` (no fields). */\nexport type GoogleClearRestoreCredentialOptions = Record<string, never>;\n\n/** Response from `google#clearRestoreCredential`. */\nexport interface GoogleClearRestoreCredentialResponse {\n /** Whether the restore credential clear request completed successfully. */\n cleared: boolean;\n}\n\nexport type ProviderSpecificCall =\n | 'facebook#getProfile'\n | 'facebook#requestTracking'\n | 'google#createRestoreCredential'\n | 'google#getRestoreCredential'\n | 'google#clearRestoreCredential';\n\n// Define the options and response types for each specific call\nexport interface FacebookGetProfileOptions {\n /**\n * Fields to retrieve from Facebook profile.\n * @default ['id', 'name', 'email', 'picture']\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 interface OpenSecureWindowOptions {\n /**\n * The endpoint to open\n */\n authEndpoint: string;\n /**\n * The redirect URI to use for the openSecureWindow call.\n * This will be checked to make sure it matches the redirect URI after the window finishes the redirection.\n */\n redirectUri: string;\n /**\n * The name of the broadcast channel to listen to, relevant only for web\n */\n broadcastChannelName?: string;\n}\n\nexport interface OpenSecureWindowResponse {\n /**\n * The result of the openSecureWindow call\n */\n redirectedUri: string;\n}\n\nexport interface OpenAuthSessionOptions {\n /**\n * Authorization or login URL to open in the system browser session (OAuth/OIDC authorize endpoint, SSO login page, etc.).\n * @example 'https://login.example.com/oauth2/authorize?client_id=...&redirect_uri=...&state=...'\n */\n url: string;\n /**\n * Custom URL scheme that receives the redirect (without `://`).\n * Must match the scheme in your registered redirect URI and native URL handler (iOS/Android).\n * On Web, the plugin also accepts HTTPS redirect URLs when `redirect_uri` is present in `url`, or messages prefixed with `${callbackURLScheme}://` on the BroadcastChannel.\n * @example 'myapp'\n */\n callbackURLScheme: string;\n /**\n * iOS-only: prefer an ephemeral `ASWebAuthenticationSession` (no shared cookies with Safari).\n * Defaults to `false` so SSO cookies in the system browser can be reused.\n */\n prefersEphemeralSession?: boolean;\n /**\n * Web-only: `BroadcastChannel` name used by the redirect page to post the callback URL back to the app.\n * @default 'capgo-auth-session'\n */\n broadcastChannelName?: string;\n}\n\nexport interface OpenAuthSessionResult {\n /**\n * Full redirect URI returned by the identity provider, including query or fragment (e.g. `myapp://auth/callback?code=...&state=...`).\n */\n callbackURL: string;\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 'google#createRestoreCredential': GoogleCreateRestoreCredentialOptions;\n 'google#getRestoreCredential': GoogleGetRestoreCredentialOptions;\n 'google#clearRestoreCredential': GoogleClearRestoreCredentialOptions;\n};\n\nexport type ProviderSpecificCallResponseMap = {\n 'facebook#getProfile': FacebookGetProfileResponse;\n 'facebook#requestTracking': FacebookRequestTrackingResponse;\n 'google#createRestoreCredential': GoogleCreateRestoreCredentialResponse;\n 'google#getRestoreCredential': GoogleGetRestoreCredentialResponse;\n 'google#clearRestoreCredential': GoogleClearRestoreCredentialResponse;\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 twitter: TwitterLoginResponse;\n telegram: TelegramLoginResponse;\n linkedin: LinkedInLoginResponse;\n tiktok: TikTokLoginResponse;\n oauth2: OAuth2LoginResponse;\n};\n\n/**\n * Error codes returned by the plugin.\n * @since 8.3.x\n */\nexport type SocialLoginErrorCode = 'USER_CANCELLED';\n\n/**\n * Errors thrown by SocialLogin methods.\n *\n * When a user dismisses or cancels the provider UI (popup closed, system dialog cancelled, access denied, etc.),\n * the plugin rejects with `code === 'USER_CANCELLED'` so the caller can distinguish user intent from real failures.\n * Other errors may omit the code or use provider-specific values.\n */\nexport interface SocialLoginError extends Error {\n code?: SocialLoginErrorCode | string;\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 * On user dismissal/cancellation, the Promise is rejected with `code === 'USER_CANCELLED'` (see `SocialLoginError`).\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 from the specified provider\n *\n * **Google Offline Mode Limitation:**\n * This method is NOT supported when Google is initialized with `mode: 'offline'`.\n * It will reject with error: \"logout is not implemented when using offline mode\"\n *\n * **Google Restore Credentials (Android):**\n * When logging out from Google, the plugin also clears any stored Restore Credential\n * (`google#clearRestoreCredential`) in addition to Credential Manager sign-in state.\n *\n * **Apple cached name (iOS):**\n * The plugin keeps the name Apple returns only on the first authorization, and logging out\n * keeps it. Pass `clearCachedUserInfo: true` to remove it too, for example on account deletion.\n *\n * @throws Error if Google provider is in offline mode\n */\n logout(options: {\n provider: 'apple' | 'google' | 'facebook' | 'twitter' | 'telegram' | 'linkedin' | 'tiktok' | 'oauth2';\n providerId?: string;\n /**\n * Apple on iOS: also remove the first and family name the plugin keeps on the device. Apple\n * returns the name only on the first authorization, so the plugin caches it to fill `givenName`\n * and `familyName` on later logins. Pass `true` when the user deletes their account, or should\n * otherwise leave no trace on the device. The name is removed even if no Apple session is held.\n * Ignored by other providers and platforms.\n * @default false\n */\n clearCachedUserInfo?: boolean;\n }): Promise<void>;\n /**\n * IsLoggedIn\n * @description Check if the user is currently logged in with the specified provider\n *\n * **Google Offline Mode Limitation:**\n * This method is NOT supported when Google is initialized with `mode: 'offline'`.\n * It will reject with error: \"isLoggedIn is not implemented when using offline mode\"\n *\n * @throws Error if Google provider is in offline mode\n */\n isLoggedIn(options: isLoggedInOptions): Promise<{ isLoggedIn: boolean }>;\n\n /**\n * Get the current authorization code\n * @description Get the authorization code for server-side authentication\n *\n * **Google Offline Mode Limitation:**\n * This method is NOT supported when Google is initialized with `mode: 'offline'`.\n * It will reject with error: \"getAuthorizationCode is not implemented when using offline mode\"\n *\n * In offline mode, the authorization code (serverAuthCode) is already returned by the `login()` method.\n *\n * Telegram login does not produce an authorization code; use the `hash` from `login()` and verify it on your backend.\n *\n * @throws Error if Google provider is in offline mode\n */\n getAuthorizationCode(options: AuthorizationCodeOptions): Promise<AuthorizationCode>;\n /**\n * Refresh the access token\n * @description refresh the access token\n *\n * **Google Offline Mode Limitation:**\n * This method is NOT supported when Google is initialized with `mode: 'offline'`.\n * Offline mode only returns `serverAuthCode` for backend token exchange, so token refresh must happen on your backend.\n * The plugin logs and rejects with a message explaining that you should send `serverAuthCode` to your backend,\n * refresh the Google tokens there, or switch to `mode: 'online'` for client-side refresh.\n *\n * **Google Web Limitation:**\n * On Web, Google `refresh()` is not implemented, even when using `mode: 'online'`.\n * Call `login()` again on Web to obtain a fresh token instead.\n *\n * @throws Error if Google provider is in offline mode, or on Web where Google `refresh()` is not implemented\n */\n refresh(options: LoginOptions): Promise<void>;\n\n /**\n * OAuth2 refresh-token helper (feature parity with Capawesome OAuth).\n *\n * Scope:\n * - Applies to the built-in `oauth2` provider and the LinkedIn and TikTok convenience wrappers.\n * - Requires a token endpoint (either `accessTokenEndpoint`/`tokenEndpoint` or `issuerUrl` discovery).\n *\n * Security note:\n * - This does not validate JWT signatures. It only exchanges/refreshes tokens.\n *\n * If `refreshToken` is omitted, the plugin will attempt to use the stored refresh token (if available).\n */\n refreshToken(options: RefreshTokenOptions): Promise<OAuth2LoginResponse>;\n\n /**\n * Web-only: handle the OAuth redirect callback and return the parsed result.\n *\n * Notes:\n * - This is only meaningful on Web. iOS/Android implementations will reject.\n * - Intended for redirect-based flows (e.g. `oauth2` with `flow: 'redirect'`) where the page navigates away.\n * - LinkedIn convenience logins (`provider: 'linkedin'`, `flow: 'redirect'`) return `provider: 'linkedin'`.\n * The same app used as `oauth2` with `providerId: 'linkedin'` keeps `provider: 'oauth2'`.\n */\n handleRedirectCallback(): Promise<LoginResult | null>;\n\n /**\n * Decode a JWT (typically an OIDC ID token) into its claims.\n *\n * Notes:\n * - Accepts both `idToken` and `token` to match common naming (Capawesome uses `token`).\n * - This does not validate the signature or issuer/audience. It only base64url-decodes the payload.\n *\n * **`email_verified` semantics by provider (for account linking):**\n * - **Google** — ID token includes `email_verified` (boolean). When `true`, Google attests\n * the user controls that email. Verify the JWT on your backend before trusting it.\n * - **Apple** — ID token includes `email_verified` (boolean). When `true`, Apple attests\n * the user controls that email (including private relay). Verify the JWT on your backend.\n * - **Meta (Facebook)** — Limited Login OIDC tokens may include `email` but **do not**\n * include `email_verified`. The presence of `email` is not the same guarantee as\n * `email_verified: true` from Google or Apple. Do not link accounts by email across\n * providers using Meta claims alone; perform your own email verification if needed.\n */\n decodeIdToken(options: { idToken?: string; token?: string }): Promise<{ claims: Record<string, any> }>;\n\n /**\n * Convert an access token expiration timestamp (milliseconds since epoch) to an ISO date string.\n *\n * This is a pure helper (feature parity with Capawesome OAuth) and does not depend on provider state.\n */\n getAccessTokenExpirationDate(options: {\n /**\n * Access token expiration date in milliseconds since epoch.\n * Typically: `Date.now() + expiresInSeconds * 1000`.\n */\n accessTokenExpirationDate: number;\n }): Promise<{ date: string }>;\n\n /**\n * Check if an access token is available (non-empty).\n *\n * This is a pure helper (feature parity with Capawesome OAuth) and does not depend on provider state.\n */\n isAccessTokenAvailable(options: { accessToken: string | null }): Promise<{ isAvailable: boolean }>;\n\n /**\n * Check if an access token is expired.\n *\n * This is a pure helper (feature parity with Capawesome OAuth) and does not depend on provider state.\n */\n isAccessTokenExpired(options: { accessTokenExpirationDate: number }): Promise<{ isExpired: boolean }>;\n\n /**\n * Check if a refresh token is available (non-empty).\n *\n * This is a pure helper (feature parity with Capawesome OAuth) and does not depend on provider state.\n */\n isRefreshTokenAvailable(options: { refreshToken: string | null }): Promise<{ isAvailable: boolean }>;\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 /**\n * Get the native Capacitor plugin version\n *\n * @returns {Promise<{ id: string }>} an Promise with version for this device\n * @throws An error if the something went wrong\n */\n getPluginVersion(): Promise<{ version: string }>;\n\n /**\n * Opens a secured window for OAuth2 authentication.\n * For web, you should have the code in the redirected page to use a broadcast channel to send the redirected url to the app\n * Something like:\n * ```html\n * <html>\n * <head></head>\n * <body>\n * <script>\n * const searchParams = new URLSearchParams(location.search)\n * if (searchParams.has(\"code\")) {\n * new BroadcastChannel(\"my-channel-name\").postMessage(location.href);\n * window.close();\n * }\n * </script>\n * </body>\n * </html>\n * ```\n * For mobile, you should have a redirect uri that opens the app, something like: `myapp://oauth_callback/`\n * And make sure to register it in the app's info.plist:\n * ```xml\n * <key>CFBundleURLTypes</key>\n * <array>\n * <dict>\n * <key>CFBundleURLSchemes</key>\n * <array>\n * <string>myapp</string>\n * </array>\n * </dict>\n * </array>\n * ```\n * And in the AndroidManifest.xml file:\n * ```xml\n * <activity>\n * <intent-filter>\n * <action android:name=\"android.intent.action.VIEW\" />\n * <category android:name=\"android.intent.category.DEFAULT\" />\n * <category android:name=\"android.intent.category.BROWSABLE\" />\n * <data android:host=\"oauth_callback\" android:scheme=\"myapp\" />\n * </intent-filter>\n * </activity>\n * ```\n * @param options - the options for the openSecureWindow call\n */\n openSecureWindow(options: OpenSecureWindowOptions): Promise<OpenSecureWindowResponse>;\n\n /**\n * Opens a system auth session for generic OAuth/OIDC or enterprise SSO.\n *\n * Use this when you build the authorize URL yourself (or your IdP SDK returns one) and only need\n * the plugin to run the secure browser flow and return the redirect callback URL. Exchange the\n * authorization code or tokens on your backend or with your own client logic.\n *\n * **iOS/Android:** system browser session (`ASWebAuthenticationSession` / Chrome Custom Tabs).\n * **Web:** popup window plus `BroadcastChannel` (not a native browser session).\n *\n * On user cancel or dismiss, the Promise rejects with `code === 'USER_CANCELLED'`.\n *\n * @param options - auth session options\n */\n openAuthSession(options: OpenAuthSessionOptions): Promise<OpenAuthSessionResult>;\n}\n"]}
@@ -14,6 +14,7 @@ declare class SocialLoginClient implements SocialLoginPlugin {
14
14
  logout(options: {
15
15
  provider: 'apple' | 'google' | 'facebook' | 'twitter' | 'telegram' | 'linkedin' | 'tiktok' | 'oauth2';
16
16
  providerId?: string;
17
+ clearCachedUserInfo?: boolean;
17
18
  }): Promise<void>;
18
19
  isLoggedIn(options: isLoggedInOptions): Promise<{
19
20
  isLoggedIn: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"social-login.js","sourceRoot":"","sources":["../../src/social-login.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEjD,2EAA2E;AAC3E,OAAO,wBAAwB,CAAC;AAsBhC,OAAO,EACL,qBAAqB,EACrB,yBAAyB,EACzB,wBAAwB,EACxB,oBAAoB,EACpB,2BAA2B,GAC5B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,mBAAmB,EACnB,uBAAuB,EACvB,sBAAsB,EACtB,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,mBAAmB,CAAC;AAE3B,MAAM,8BAA8B,GAClC,0PAA0P,CAAC;AAE7P,MAAM,cAAc,GAAG,cAAc,CAAoB,aAAa,EAAE;IACtE,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,cAAc,EAAE,CAAC;CAC/D,CAAC,CAAC;AAEH,MAAM,iBAAiB;IAGb,0BAA0B,CAAC,OAA0B;;QAC3D,IAAI,IAAI,GAAG,OAAO,CAAC;QAEnB,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAClB,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAc,IAAI,EAAb,IAAI,UAAK,IAAI,EAApC,sBAA6B,CAAO,CAAC;YAC3C,IAAI,mCACC,IAAI,KACP,QAAQ,EACR,MAAM,kCACD,CAAC,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,EAAE,CAAC,KACjB,CAAC,oBAAoB,CAAC,EAAE,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAG,oBAAoB,CAAC,mCAAI,wBAAwB,CAAC,QAAQ,CAAC,MAE/F,CAAC;QACJ,CAAC;QA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AAC,OAAO,CAAC,CAAC;IAC/C,CAAC;IAED,KAAK,CAAC,4BAA4B,CAAC,OAA8C;QAC/E,OAAO,cAAc,CAAC,4BAA4B,CAAC,OAAO,CAAC,CAAC;IAC9D,CAAC;IAED,KAAK,CAAC,sBAAsB,CAAC,OAAuC;QAClE,OAAO,cAAc,CAAC,sBAAsB,CAAC,OAAO,CAAC,CAAC;IACxD,CAAC;IAED,KAAK,CAAC,oBAAoB,CAAC,OAA8C;QACvE,OAAO,cAAc,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC;IACtD,CAAC;IAED,KAAK,CAAC,uBAAuB,CAAC,OAAwC;QACpE,OAAO,cAAc,CAAC,uBAAuB,CAAC,OAAO,CAAC,CAAC;IACzD,CAAC;IAED,KAAK,CAAC,oBAAoB,CAAiC,OAG1D;QACC,OAAO,cAAc,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC;IACtD,CAAC;IAED,KAAK,CAAC,gBAAgB;QACpB,OAAO,cAAc,CAAC,gBAAgB,EAAE,CAAC;IAC3C,CAAC;IAED,KAAK,CAAC,gBAAgB,CAAC,OAAgC;QACrD,OAAO,cAAc,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;IAClD,CAAC;IAED,KAAK,CAAC,eAAe,CAAC,OAA+B;QACnD,OAAO,cAAc,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;IACjD,CAAC;CACF;AAED,MAAM,CAAC,MAAM,eAAe,GAAG,cAAc,CAAC;AAC9C,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,iBAAiB,EAAE,CAAC","sourcesContent":["import { registerPlugin } from '@capacitor/core';\n\n// Eagerly finish OAuth popup redirects before plugin lazy-load (COOP-safe)\nimport './oauth-popup-redirect';\n\nimport type {\n AuthorizationCode,\n AuthorizationCodeOptions,\n InitializeOptions,\n LinkedInLoginOptions,\n LoginOptions,\n OpenAuthSessionOptions,\n OpenAuthSessionResult,\n OpenSecureWindowOptions,\n OpenSecureWindowResponse,\n OAuth2LoginResponse,\n ProviderResponseMap,\n RefreshTokenOptions,\n ProviderSpecificCall,\n ProviderSpecificCallOptionsMap,\n ProviderSpecificCallResponseMap,\n SocialLoginPlugin,\n TikTokLoginOptions,\n isLoggedInOptions,\n} from './definitions';\nimport {\n asLinkedInLoginResult,\n buildLinkedInLoginOptions,\n buildLinkedInOAuthConfig,\n LINKEDIN_PROVIDER_ID,\n markLinkedInRedirectPending,\n} from './linkedin-provider';\nimport {\n asTikTokLoginResult,\n buildTikTokLoginOptions,\n buildTikTokOAuthConfig,\n isTikTokOAuthResult,\n TIKTOK_PROVIDER_ID,\n} from './tiktok-provider';\n\nconst GOOGLE_OFFLINE_REFRESH_MESSAGE =\n \"Google refresh() is not available when using offline mode. Offline mode only returns serverAuthCode for backend token exchange. Send serverAuthCode to your backend and refresh tokens there, or switch google.mode to 'online' for client-side refresh.\";\n\nconst rawSocialLogin = registerPlugin<SocialLoginPlugin>('SocialLogin', {\n web: () => import('./web').then((m) => new m.SocialLoginWeb()),\n});\n\nclass SocialLoginClient implements SocialLoginPlugin {\n private initializeOptions?: InitializeOptions;\n\n private normalizeInitializeOptions(options: InitializeOptions): InitializeOptions {\n let next = options;\n\n if (next.linkedin) {\n const { linkedin, oauth2, ...rest } = next;\n next = {\n ...rest,\n linkedin,\n oauth2: {\n ...(oauth2 ?? {}),\n [LINKEDIN_PROVIDER_ID]: oauth2?.[LINKEDIN_PROVIDER_ID] ?? buildLinkedInOAuthConfig(linkedin),\n },\n };\n }\n\n if (next.tiktok) {\n if (!next.tiktok.clientKey || !next.tiktok.redirectUrl) {\n throw new Error('tiktok.clientKey and tiktok.redirectUrl are required');\n }\n const { tiktok, oauth2, ...rest } = next;\n next = {\n ...rest,\n tiktok,\n oauth2: {\n ...(oauth2 ?? {}),\n [TIKTOK_PROVIDER_ID]: oauth2?.[TIKTOK_PROVIDER_ID] ?? buildTikTokOAuthConfig(tiktok),\n },\n };\n }\n\n return next;\n }\n\n constructor() {\n this.initialize = this.initialize.bind(this);\n this.refresh = this.refresh.bind(this);\n }\n\n async initialize(options: InitializeOptions): Promise<void> {\n const normalized = this.normalizeInitializeOptions(options);\n await rawSocialLogin.initialize(normalized);\n this.initializeOptions = normalized;\n }\n\n async login<T extends LoginOptions['provider']>(\n options: Extract<LoginOptions, { provider: T }>,\n ): Promise<{ provider: T; result: ProviderResponseMap[T] }> {\n if (options.provider === 'linkedin') {\n const linkedInOptions = (options.options as LinkedInLoginOptions | undefined) ?? {};\n const oauthOptions = buildLinkedInLoginOptions(linkedInOptions);\n if (oauthOptions.flow === 'redirect' && oauthOptions.state) {\n markLinkedInRedirectPending(oauthOptions.state);\n }\n const response = await rawSocialLogin.login({\n provider: 'oauth2',\n options: oauthOptions,\n });\n return asLinkedInLoginResult(response) as { provider: T; result: ProviderResponseMap[T] };\n }\n if (options.provider === 'tiktok') {\n const response = await rawSocialLogin.login({\n provider: 'oauth2',\n options: buildTikTokLoginOptions(options.options as TikTokLoginOptions),\n });\n return asTikTokLoginResult(response) as { provider: T; result: ProviderResponseMap[T] };\n }\n return rawSocialLogin.login(options);\n }\n\n async logout(options: {\n provider: 'apple' | 'google' | 'facebook' | 'twitter' | 'telegram' | 'linkedin' | 'tiktok' | 'oauth2';\n providerId?: string;\n }): Promise<void> {\n if (options.provider === 'linkedin') {\n return rawSocialLogin.logout({ provider: 'oauth2', providerId: LINKEDIN_PROVIDER_ID });\n }\n if (options.provider === 'tiktok') {\n return rawSocialLogin.logout({ provider: 'oauth2', providerId: TIKTOK_PROVIDER_ID });\n }\n return rawSocialLogin.logout(options);\n }\n\n async isLoggedIn(options: isLoggedInOptions): Promise<{ isLoggedIn: boolean }> {\n if (options.provider === 'linkedin') {\n return rawSocialLogin.isLoggedIn({ provider: 'oauth2', providerId: LINKEDIN_PROVIDER_ID });\n }\n if (options.provider === 'tiktok') {\n return rawSocialLogin.isLoggedIn({ provider: 'oauth2', providerId: TIKTOK_PROVIDER_ID });\n }\n return rawSocialLogin.isLoggedIn(options);\n }\n\n async getAuthorizationCode(options: AuthorizationCodeOptions): Promise<AuthorizationCode> {\n if (options.provider === 'linkedin') {\n return rawSocialLogin.getAuthorizationCode({ provider: 'oauth2', providerId: LINKEDIN_PROVIDER_ID });\n }\n if (options.provider === 'tiktok') {\n return rawSocialLogin.getAuthorizationCode({ provider: 'oauth2', providerId: TIKTOK_PROVIDER_ID });\n }\n return rawSocialLogin.getAuthorizationCode(options);\n }\n\n async refresh(options: LoginOptions): Promise<void> {\n if (options.provider === 'google' && this.initializeOptions?.google?.mode === 'offline') {\n console.warn(`[SocialLogin] ${GOOGLE_OFFLINE_REFRESH_MESSAGE}`);\n }\n if (options.provider === 'linkedin') {\n return rawSocialLogin.refresh({\n provider: 'oauth2',\n options: buildLinkedInLoginOptions((options.options as LinkedInLoginOptions | undefined) ?? {}),\n });\n }\n if (options.provider === 'tiktok') {\n return rawSocialLogin.refresh({\n provider: 'oauth2',\n options: buildTikTokLoginOptions(options.options as TikTokLoginOptions),\n });\n }\n return rawSocialLogin.refresh(options);\n }\n\n async refreshToken(options: RefreshTokenOptions): Promise<OAuth2LoginResponse> {\n if (options.provider === 'linkedin') {\n return rawSocialLogin.refreshToken({\n provider: 'oauth2',\n providerId: LINKEDIN_PROVIDER_ID,\n refreshToken: options.refreshToken,\n additionalParameters: options.additionalParameters,\n });\n }\n if (options.provider === 'tiktok') {\n return rawSocialLogin.refreshToken({\n provider: 'oauth2',\n providerId: TIKTOK_PROVIDER_ID,\n refreshToken: options.refreshToken,\n additionalParameters: options.additionalParameters,\n });\n }\n return rawSocialLogin.refreshToken(options);\n }\n\n async handleRedirectCallback() {\n const result = await rawSocialLogin.handleRedirectCallback();\n if (result && isTikTokOAuthResult(result)) {\n return asTikTokLoginResult(result);\n }\n return result;\n }\n\n async decodeIdToken(options: { idToken?: string; token?: string }): Promise<{ claims: Record<string, any> }> {\n return rawSocialLogin.decodeIdToken(options);\n }\n\n async getAccessTokenExpirationDate(options: { accessTokenExpirationDate: number }): Promise<{ date: string }> {\n return rawSocialLogin.getAccessTokenExpirationDate(options);\n }\n\n async isAccessTokenAvailable(options: { accessToken: string | null }): Promise<{ isAvailable: boolean }> {\n return rawSocialLogin.isAccessTokenAvailable(options);\n }\n\n async isAccessTokenExpired(options: { accessTokenExpirationDate: number }): Promise<{ isExpired: boolean }> {\n return rawSocialLogin.isAccessTokenExpired(options);\n }\n\n async isRefreshTokenAvailable(options: { refreshToken: string | null }): Promise<{ isAvailable: boolean }> {\n return rawSocialLogin.isRefreshTokenAvailable(options);\n }\n\n async providerSpecificCall<T extends ProviderSpecificCall>(options: {\n call: T;\n options: ProviderSpecificCallOptionsMap[T];\n }): Promise<ProviderSpecificCallResponseMap[T]> {\n return rawSocialLogin.providerSpecificCall(options);\n }\n\n async getPluginVersion(): Promise<{ version: string }> {\n return rawSocialLogin.getPluginVersion();\n }\n\n async openSecureWindow(options: OpenSecureWindowOptions): Promise<OpenSecureWindowResponse> {\n return rawSocialLogin.openSecureWindow(options);\n }\n\n async openAuthSession(options: OpenAuthSessionOptions): Promise<OpenAuthSessionResult> {\n return rawSocialLogin.openAuthSession(options);\n }\n}\n\nexport const SocialLoginBase = rawSocialLogin;\nexport const SocialLogin = new SocialLoginClient();\n"]}
1
+ {"version":3,"file":"social-login.js","sourceRoot":"","sources":["../../src/social-login.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEjD,2EAA2E;AAC3E,OAAO,wBAAwB,CAAC;AAsBhC,OAAO,EACL,qBAAqB,EACrB,yBAAyB,EACzB,wBAAwB,EACxB,oBAAoB,EACpB,2BAA2B,GAC5B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,mBAAmB,EACnB,uBAAuB,EACvB,sBAAsB,EACtB,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,mBAAmB,CAAC;AAE3B,MAAM,8BAA8B,GAClC,0PAA0P,CAAC;AAE7P,MAAM,cAAc,GAAG,cAAc,CAAoB,aAAa,EA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;IAED,KAAK,CAAC,gBAAgB;QACpB,OAAO,cAAc,CAAC,gBAAgB,EAAE,CAAC;IAC3C,CAAC;IAED,KAAK,CAAC,gBAAgB,CAAC,OAAgC;QACrD,OAAO,cAAc,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;IAClD,CAAC;IAED,KAAK,CAAC,eAAe,CAAC,OAA+B;QACnD,OAAO,cAAc,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;IACjD,CAAC;CACF;AAED,MAAM,CAAC,MAAM,eAAe,GAAG,cAAc,CAAC;AAC9C,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,iBAAiB,EAAE,CAAC","sourcesContent":["import { registerPlugin } from '@capacitor/core';\n\n// Eagerly finish OAuth popup redirects before plugin lazy-load (COOP-safe)\nimport './oauth-popup-redirect';\n\nimport type {\n AuthorizationCode,\n AuthorizationCodeOptions,\n InitializeOptions,\n LinkedInLoginOptions,\n LoginOptions,\n OpenAuthSessionOptions,\n OpenAuthSessionResult,\n OpenSecureWindowOptions,\n OpenSecureWindowResponse,\n OAuth2LoginResponse,\n ProviderResponseMap,\n RefreshTokenOptions,\n ProviderSpecificCall,\n ProviderSpecificCallOptionsMap,\n ProviderSpecificCallResponseMap,\n SocialLoginPlugin,\n TikTokLoginOptions,\n isLoggedInOptions,\n} from './definitions';\nimport {\n asLinkedInLoginResult,\n buildLinkedInLoginOptions,\n buildLinkedInOAuthConfig,\n LINKEDIN_PROVIDER_ID,\n markLinkedInRedirectPending,\n} from './linkedin-provider';\nimport {\n asTikTokLoginResult,\n buildTikTokLoginOptions,\n buildTikTokOAuthConfig,\n isTikTokOAuthResult,\n TIKTOK_PROVIDER_ID,\n} from './tiktok-provider';\n\nconst GOOGLE_OFFLINE_REFRESH_MESSAGE =\n \"Google refresh() is not available when using offline mode. Offline mode only returns serverAuthCode for backend token exchange. Send serverAuthCode to your backend and refresh tokens there, or switch google.mode to 'online' for client-side refresh.\";\n\nconst rawSocialLogin = registerPlugin<SocialLoginPlugin>('SocialLogin', {\n web: () => import('./web').then((m) => new m.SocialLoginWeb()),\n});\n\nclass SocialLoginClient implements SocialLoginPlugin {\n private initializeOptions?: InitializeOptions;\n\n private normalizeInitializeOptions(options: InitializeOptions): InitializeOptions {\n let next = options;\n\n if (next.linkedin) {\n const { linkedin, oauth2, ...rest } = next;\n next = {\n ...rest,\n linkedin,\n oauth2: {\n ...(oauth2 ?? {}),\n [LINKEDIN_PROVIDER_ID]: oauth2?.[LINKEDIN_PROVIDER_ID] ?? buildLinkedInOAuthConfig(linkedin),\n },\n };\n }\n\n if (next.tiktok) {\n if (!next.tiktok.clientKey || !next.tiktok.redirectUrl) {\n throw new Error('tiktok.clientKey and tiktok.redirectUrl are required');\n }\n const { tiktok, oauth2, ...rest } = next;\n next = {\n ...rest,\n tiktok,\n oauth2: {\n ...(oauth2 ?? {}),\n [TIKTOK_PROVIDER_ID]: oauth2?.[TIKTOK_PROVIDER_ID] ?? buildTikTokOAuthConfig(tiktok),\n },\n };\n }\n\n return next;\n }\n\n constructor() {\n this.initialize = this.initialize.bind(this);\n this.refresh = this.refresh.bind(this);\n }\n\n async initialize(options: InitializeOptions): Promise<void> {\n const normalized = this.normalizeInitializeOptions(options);\n await rawSocialLogin.initialize(normalized);\n this.initializeOptions = normalized;\n }\n\n async login<T extends LoginOptions['provider']>(\n options: Extract<LoginOptions, { provider: T }>,\n ): Promise<{ provider: T; result: ProviderResponseMap[T] }> {\n if (options.provider === 'linkedin') {\n const linkedInOptions = (options.options as LinkedInLoginOptions | undefined) ?? {};\n const oauthOptions = buildLinkedInLoginOptions(linkedInOptions);\n if (oauthOptions.flow === 'redirect' && oauthOptions.state) {\n markLinkedInRedirectPending(oauthOptions.state);\n }\n const response = await rawSocialLogin.login({\n provider: 'oauth2',\n options: oauthOptions,\n });\n return asLinkedInLoginResult(response) as { provider: T; result: ProviderResponseMap[T] };\n }\n if (options.provider === 'tiktok') {\n const response = await rawSocialLogin.login({\n provider: 'oauth2',\n options: buildTikTokLoginOptions(options.options as TikTokLoginOptions),\n });\n return asTikTokLoginResult(response) as { provider: T; result: ProviderResponseMap[T] };\n }\n return rawSocialLogin.login(options);\n }\n\n async logout(options: {\n provider: 'apple' | 'google' | 'facebook' | 'twitter' | 'telegram' | 'linkedin' | 'tiktok' | 'oauth2';\n providerId?: string;\n clearCachedUserInfo?: boolean;\n }): Promise<void> {\n if (options.provider === 'linkedin') {\n return rawSocialLogin.logout({ provider: 'oauth2', providerId: LINKEDIN_PROVIDER_ID });\n }\n if (options.provider === 'tiktok') {\n return rawSocialLogin.logout({ provider: 'oauth2', providerId: TIKTOK_PROVIDER_ID });\n }\n return rawSocialLogin.logout(options);\n }\n\n async isLoggedIn(options: isLoggedInOptions): Promise<{ isLoggedIn: boolean }> {\n if (options.provider === 'linkedin') {\n return rawSocialLogin.isLoggedIn({ provider: 'oauth2', providerId: LINKEDIN_PROVIDER_ID });\n }\n if (options.provider === 'tiktok') {\n return rawSocialLogin.isLoggedIn({ provider: 'oauth2', providerId: TIKTOK_PROVIDER_ID });\n }\n return rawSocialLogin.isLoggedIn(options);\n }\n\n async getAuthorizationCode(options: AuthorizationCodeOptions): Promise<AuthorizationCode> {\n if (options.provider === 'linkedin') {\n return rawSocialLogin.getAuthorizationCode({ provider: 'oauth2', providerId: LINKEDIN_PROVIDER_ID });\n }\n if (options.provider === 'tiktok') {\n return rawSocialLogin.getAuthorizationCode({ provider: 'oauth2', providerId: TIKTOK_PROVIDER_ID });\n }\n return rawSocialLogin.getAuthorizationCode(options);\n }\n\n async refresh(options: LoginOptions): Promise<void> {\n if (options.provider === 'google' && this.initializeOptions?.google?.mode === 'offline') {\n console.warn(`[SocialLogin] ${GOOGLE_OFFLINE_REFRESH_MESSAGE}`);\n }\n if (options.provider === 'linkedin') {\n return rawSocialLogin.refresh({\n provider: 'oauth2',\n options: buildLinkedInLoginOptions((options.options as LinkedInLoginOptions | undefined) ?? {}),\n });\n }\n if (options.provider === 'tiktok') {\n return rawSocialLogin.refresh({\n provider: 'oauth2',\n options: buildTikTokLoginOptions(options.options as TikTokLoginOptions),\n });\n }\n return rawSocialLogin.refresh(options);\n }\n\n async refreshToken(options: RefreshTokenOptions): Promise<OAuth2LoginResponse> {\n if (options.provider === 'linkedin') {\n return rawSocialLogin.refreshToken({\n provider: 'oauth2',\n providerId: LINKEDIN_PROVIDER_ID,\n refreshToken: options.refreshToken,\n additionalParameters: options.additionalParameters,\n });\n }\n if (options.provider === 'tiktok') {\n return rawSocialLogin.refreshToken({\n provider: 'oauth2',\n providerId: TIKTOK_PROVIDER_ID,\n refreshToken: options.refreshToken,\n additionalParameters: options.additionalParameters,\n });\n }\n return rawSocialLogin.refreshToken(options);\n }\n\n async handleRedirectCallback() {\n const result = await rawSocialLogin.handleRedirectCallback();\n if (result && isTikTokOAuthResult(result)) {\n return asTikTokLoginResult(result);\n }\n return result;\n }\n\n async decodeIdToken(options: { idToken?: string; token?: string }): Promise<{ claims: Record<string, any> }> {\n return rawSocialLogin.decodeIdToken(options);\n }\n\n async getAccessTokenExpirationDate(options: { accessTokenExpirationDate: number }): Promise<{ date: string }> {\n return rawSocialLogin.getAccessTokenExpirationDate(options);\n }\n\n async isAccessTokenAvailable(options: { accessToken: string | null }): Promise<{ isAvailable: boolean }> {\n return rawSocialLogin.isAccessTokenAvailable(options);\n }\n\n async isAccessTokenExpired(options: { accessTokenExpirationDate: number }): Promise<{ isExpired: boolean }> {\n return rawSocialLogin.isAccessTokenExpired(options);\n }\n\n async isRefreshTokenAvailable(options: { refreshToken: string | null }): Promise<{ isAvailable: boolean }> {\n return rawSocialLogin.isRefreshTokenAvailable(options);\n }\n\n async providerSpecificCall<T extends ProviderSpecificCall>(options: {\n call: T;\n options: ProviderSpecificCallOptionsMap[T];\n }): Promise<ProviderSpecificCallResponseMap[T]> {\n return rawSocialLogin.providerSpecificCall(options);\n }\n\n async getPluginVersion(): Promise<{ version: string }> {\n return rawSocialLogin.getPluginVersion();\n }\n\n async openSecureWindow(options: OpenSecureWindowOptions): Promise<OpenSecureWindowResponse> {\n return rawSocialLogin.openSecureWindow(options);\n }\n\n async openAuthSession(options: OpenAuthSessionOptions): Promise<OpenAuthSessionResult> {\n return rawSocialLogin.openAuthSession(options);\n }\n}\n\nexport const SocialLoginBase = rawSocialLogin;\nexport const SocialLogin = new SocialLoginClient();\n"]}
package/dist/esm/web.d.ts CHANGED
@@ -22,6 +22,7 @@ export declare class SocialLoginWeb extends WebPlugin implements SocialLoginPlug
22
22
  logout(options: {
23
23
  provider: 'apple' | 'google' | 'facebook' | 'twitter' | 'telegram' | 'linkedin' | 'tiktok' | 'oauth2';
24
24
  providerId?: string;
25
+ clearCachedUserInfo?: boolean;
25
26
  }): Promise<void>;
26
27
  isLoggedIn(options: isLoggedInOptions): Promise<{
27
28
  isLoggedIn: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AA2BpD,OAAO,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAC7E,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EACL,qBAAqB,EACrB,yBAAyB,EACzB,wBAAwB,EACxB,8BAA8B,EAC9B,qBAAqB,EACrB,oBAAoB,EACpB,2BAA2B,GAC5B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,qBAAqB,EACrB,kBAAkB,EAClB,eAAe,EACf,6BAA6B,GAE9B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EACL,mBAAmB,EACnB,uB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CAAC,CAAC,CAAC;YAEH,IAAI,mBAAmB,GAAwB,EAAE,gBAAgB,EAAE,IAAI,EAAE,CAAC;YAE1E,SAAS,GAAG,MAAM,CAAC,WAAW,CAAC,GAAG,EAAE;gBAClC,IAAI,CAAC;oBACH,MAAM,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC;oBAClC,MAAM,UAAU,GAAG,uBAAuB,CAAC,MAAM,EAAE,mBAAmB,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;oBACpF,mBAAmB,GAAG,UAAU,CAAC,KAAK,CAAC;oBACvC,IAAI,UAAU,CAAC,YAAY,EAAE,CAAC;wBAC5B,MAAM,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,wBAAwB,CAAC,8BAA8B,CAAC,CAAC,CAAC,CAAC;oBACjF,CAAC;gBACH,CAAC;gBAAC,WAAM,CAAC;oBACP,MAAM,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;oBAChC,SAAS,GAAG,CAAC,CAAC;gBAChB,CAAC;YACH,CAAC,EAAE,GAAG,CAAC,CAAC;YAER,YAAY,GAAG,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE;gBACpC,MAAM,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC,CAAC,CAAC;YAChE,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,CAAC;QAChB,CAAC,CAAC,CAAC;IACL,CAAC;;AAplBuB,8BAAe,GAAG,eAAe,AAAlB,CAAmB","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport { AppleSocialLogin } from './apple-provider';\nimport type {\n SocialLoginPlugin,\n InitializeOptions,\n LoginOptions,\n AuthorizationCode,\n AuthorizationCodeOptions,\n isLoggedInOptions,\n ProviderResponseMap,\n FacebookLoginOptions,\n ProviderSpecificCall,\n ProviderSpecificCallOptionsMap,\n ProviderSpecificCallResponseMap,\n LoginResult,\n OAuth2LoginOptions,\n OAuth2LoginResponse,\n OAuth2ProviderConfig,\n OpenAuthSessionOptions,\n OpenAuthSessionResult,\n OpenSecureWindowOptions,\n OpenSecureWindowResponse,\n FacebookGetProfileOptions,\n TelegramLoginOptions,\n LinkedInLoginOptions,\n TikTokLoginOptions,\n RefreshTokenOptions,\n} from './definitions';\nimport { createUserCancelledError, inferUserCancelledError } from './errors';\nimport { FacebookSocialLogin } from './facebook-provider';\nimport { GoogleSocialLogin } from './google-provider';\nimport {\n asLinkedInLoginResult,\n buildLinkedInLoginOptions,\n buildLinkedInOAuthConfig,\n consumeLinkedInRedirectPending,\n isLinkedInOAuthResult,\n LINKEDIN_PROVIDER_ID,\n markLinkedInRedirectPending,\n} from './linkedin-provider';\nimport {\n clearOAuthPopupMarker,\n deliverOAuthResult,\n OAUTH_STATE_KEY,\n shouldAutoFinishOAuthRedirect,\n type OAuthBridgeMessage,\n} from './oauth-popup-bridge';\nimport { OAuth2SocialLogin } from './oauth2-provider';\nimport { TelegramSocialLogin } from './telegram-provider';\nimport {\n asTikTokLoginResult,\n buildTikTokLoginOptions,\n buildTikTokOAuthConfig,\n isTikTokOAuthResult,\n TIKTOK_PROVIDER_ID,\n} from './tiktok-provider';\nimport { TwitterSocialLogin } from './twitter-provider';\nimport { nextPopupClosePollState, type PopupClosePollState } from './web-auth-popup-close';\n\nexport class SocialLoginWeb extends WebPlugin implements SocialLoginPlugin {\n private static readonly OAUTH_STATE_KEY = OAUTH_STATE_KEY;\n\n private googleProvider: GoogleSocialLogin;\n private appleProvider: AppleSocialLogin;\n private facebookProvider: FacebookSocialLogin;\n private twitterProvider: TwitterSocialLogin;\n private telegramProvider: TelegramSocialLogin;\n private oauth2Provider: OAuth2SocialLogin;\n private webAuthPopupInProgress = false;\n\n constructor() {\n super();\n\n this.googleProvider = new GoogleSocialLogin();\n this.appleProvider = new AppleSocialLogin();\n this.facebookProvider = new FacebookSocialLogin();\n this.twitterProvider = new TwitterSocialLogin();\n this.telegramProvider = new TelegramSocialLogin();\n this.oauth2Provider = new OAuth2SocialLogin();\n\n // Auto-finish OAuth redirects only when running inside a popup window.\n // For redirect-based flows (full page navigation), the app should call `handleRedirectCallback()` explicitly.\n // Note: oauth-popup-redirect.ts also handles this eagerly on package import for COOP-safe popup completion.\n if (shouldAutoFinishOAuthRedirect()) {\n this.finishOAuthRedirectInPopup().catch((error) => {\n console.error('Failed to finish OAuth redirect', error);\n try {\n window.close();\n } catch {\n // ignore\n }\n });\n }\n }\n\n private async parseRedirectResult(): Promise<{\n provider: string | null;\n state?: string;\n nonce?: string;\n result: LoginResult | { error: string } | null;\n }> {\n const url = new URL(window.location.href);\n const stateRaw = localStorage.getItem(SocialLoginWeb.OAUTH_STATE_KEY);\n let provider: string | null = null;\n let state: string | undefined;\n let nonce: string | undefined;\n\n if (stateRaw) {\n try {\n const parsed = JSON.parse(stateRaw);\n provider = parsed.provider ?? null;\n state = parsed.state;\n nonce = parsed.nonce;\n } catch {\n provider = stateRaw === 'true' ? 'google' : null;\n }\n }\n\n let result: LoginResult | { error: string } | null;\n\n switch (provider) {\n case 'twitter':\n result = await this.twitterProvider.handleOAuthRedirect(url, state);\n break;\n case 'telegram':\n result = await this.telegramProvider.handleOAuthRedirect(url, state);\n break;\n case 'oauth2':\n result = await this.oauth2Provider.handleOAuthRedirect(url, state);\n break;\n case 'google':\n default:\n result = this.googleProvider.handleOAuthRedirect(url);\n break;\n }\n\n return { provider, state, nonce, result };\n }\n\n private async finishOAuthRedirectInPopup(): Promise<void> {\n const parsed = await this.parseRedirectResult();\n const nonceOrState = parsed.nonce ?? parsed.state;\n let message: OAuthBridgeMessage;\n\n if (!parsed.result) {\n message = {\n type: 'oauth-error',\n provider: parsed.provider,\n error: 'OAuth redirect did not contain expected parameters.',\n };\n } else if ('error' in parsed.result) {\n const resolvedProvider = parsed.provider ?? null;\n const error = inferUserCancelledError(parsed.result.error);\n message = {\n type: 'oauth-error',\n provider: resolvedProvider,\n error: error.message,\n ...(error.code ? { code: error.code } : null),\n };\n } else {\n message = {\n type: 'oauth-response',\n provider: parsed.result.provider,\n ...parsed.result.result,\n };\n }\n\n deliverOAuthResult(parsed.provider ?? 'google', nonceOrState, message);\n clearOAuthPopupMarker();\n\n try {\n window.close();\n } catch {\n // Popup may not be allowed to close itself in some contexts\n }\n }\n\n async initialize(options: InitializeOptions): Promise<void> {\n const initPromises: Promise<void>[] = [];\n\n if (options.google?.webClientId) {\n initPromises.push(\n this.googleProvider.initialize(\n options.google.webClientId,\n options.google.mode,\n options.google.hostedDomain,\n options.google.redirectUrl,\n ),\n );\n }\n\n if (options.apple?.clientId) {\n initPromises.push(\n this.appleProvider.initialize(\n options.apple.clientId,\n options.apple.redirectUrl,\n options.apple.useProperTokenExchange,\n ),\n );\n }\n\n if (options.facebook?.appId) {\n initPromises.push(this.facebookProvider.initialize(options.facebook.appId, options.facebook.locale));\n }\n\n if (options.twitter?.clientId) {\n initPromises.push(\n this.twitterProvider.initialize(\n options.twitter.clientId,\n options.twitter.redirectUrl,\n options.twitter.defaultScopes,\n options.twitter.forceLogin,\n options.twitter.audience,\n ),\n );\n }\n\n if (options.telegram?.botId) {\n this.telegramProvider.initialize(\n options.telegram.botId,\n options.telegram.requestAccess,\n options.telegram.redirectUrl,\n options.telegram.origin,\n options.telegram.languageCode,\n );\n }\n\n const oauth2Configs: Record<string, OAuth2ProviderConfig> = { ...(options.oauth2 ?? {}) };\n if (options.linkedin && !oauth2Configs[LINKEDIN_PROVIDER_ID]) {\n oauth2Configs[LINKEDIN_PROVIDER_ID] = buildLinkedInOAuthConfig(options.linkedin);\n }\n if (options.tiktok) {\n if (!options.tiktok.clientKey || !options.tiktok.redirectUrl) {\n throw new Error('tiktok.clientKey and tiktok.redirectUrl are required');\n }\n if (!oauth2Configs[TIKTOK_PROVIDER_ID]) {\n oauth2Configs[TIKTOK_PROVIDER_ID] = buildTikTokOAuthConfig(options.tiktok);\n }\n }\n if (Object.keys(oauth2Configs).length > 0) {\n initPromises.push(this.oauth2Provider.initializeProviders(oauth2Configs));\n }\n\n await Promise.all(initPromises);\n }\n\n async login<T extends LoginOptions['provider']>(\n options: Extract<LoginOptions, { provider: T }>,\n ): Promise<{ provider: T; result: ProviderResponseMap[T] }> {\n switch (options.provider) {\n case 'google':\n return this.googleProvider.login(options.options as any) as Promise<{\n provider: T;\n result: ProviderResponseMap[T];\n }>;\n case 'apple':\n return this.appleProvider.login(options.options as any) as Promise<{\n provider: T;\n result: ProviderResponseMap[T];\n }>;\n case 'facebook':\n return this.facebookProvider.login(options.options as FacebookLoginOptions) as Promise<{\n provider: T;\n result: ProviderResponseMap[T];\n }>;\n case 'twitter':\n return this.twitterProvider.login(options.options as any) as Promise<{\n provider: T;\n result: ProviderResponseMap[T];\n }>;\n case 'telegram':\n return this.telegramProvider.login(options.options as TelegramLoginOptions) as Promise<{\n provider: T;\n result: ProviderResponseMap[T];\n }>;\n case 'linkedin': {\n const linkedInOptions = (options.options as LinkedInLoginOptions | undefined) ?? {};\n const oauthOptions = buildLinkedInLoginOptions(linkedInOptions);\n if (oauthOptions.flow === 'redirect' && oauthOptions.state) {\n markLinkedInRedirectPending(oauthOptions.state);\n }\n const response = await this.oauth2Provider.login(oauthOptions);\n return asLinkedInLoginResult(response) as { provider: T; result: ProviderResponseMap[T] };\n }\n case 'tiktok': {\n const response = await this.oauth2Provider.login(\n buildTikTokLoginOptions(options.options as TikTokLoginOptions),\n );\n return asTikTokLoginResult(response) as { provider: T; result: ProviderResponseMap[T] };\n }\n case 'oauth2':\n return this.oauth2Provider.login(options.options as OAuth2LoginOptions) as Promise<{\n provider: T;\n result: ProviderResponseMap[T];\n }>;\n default:\n throw new Error(`Login for ${options.provider} is not implemented on web`);\n }\n }\n\n async logout(options: {\n provider: 'apple' | 'google' | 'facebook' | 'twitter' | 'telegram' | 'linkedin' | 'tiktok' | 'oauth2';\n providerId?: string;\n }): Promise<void> {\n switch (options.provider) {\n case 'google':\n return this.googleProvider.logout();\n case 'apple':\n return this.appleProvider.logout();\n case 'facebook':\n return this.facebookProvider.logout();\n case 'twitter':\n return this.twitterProvider.logout();\n case 'telegram':\n return this.telegramProvider.logout();\n case 'linkedin':\n return this.oauth2Provider.logout(LINKEDIN_PROVIDER_ID);\n case 'tiktok':\n return this.oauth2Provider.logout(TIKTOK_PROVIDER_ID);\n case 'oauth2':\n if (!options.providerId) {\n throw new Error('providerId is required for oauth2 logout');\n }\n return this.oauth2Provider.logout(options.providerId);\n default:\n throw new Error(`Logout for ${options.provider} is not implemented`);\n }\n }\n\n async isLoggedIn(options: isLoggedInOptions): Promise<{ isLoggedIn: boolean }> {\n switch (options.provider) {\n case 'google':\n return this.googleProvider.isLoggedIn();\n case 'apple':\n return this.appleProvider.isLoggedIn();\n case 'facebook':\n return this.facebookProvider.isLoggedIn();\n case 'twitter':\n return this.twitterProvider.isLoggedIn();\n case 'telegram':\n return this.telegramProvider.isLoggedIn();\n case 'linkedin':\n return this.oauth2Provider.isLoggedIn(LINKEDIN_PROVIDER_ID);\n case 'tiktok':\n return this.oauth2Provider.isLoggedIn(TIKTOK_PROVIDER_ID);\n case 'oauth2':\n if (!options.providerId) {\n throw new Error('providerId is required for oauth2 isLoggedIn');\n }\n return this.oauth2Provider.isLoggedIn(options.providerId);\n default:\n throw new Error(`isLoggedIn for ${options.provider} is not implemented`);\n }\n }\n\n async getAuthorizationCode(options: AuthorizationCodeOptions): Promise<AuthorizationCode> {\n switch (options.provider) {\n case 'google':\n return this.googleProvider.getAuthorizationCode();\n case 'apple':\n return this.appleProvider.getAuthorizationCode();\n case 'facebook':\n return this.facebookProvider.getAuthorizationCode();\n case 'twitter':\n return this.twitterProvider.getAuthorizationCode();\n case 'linkedin':\n return this.oauth2Provider.getAuthorizationCode(LINKEDIN_PROVIDER_ID);\n case 'tiktok':\n return this.oauth2Provider.getAuthorizationCode(TIKTOK_PROVIDER_ID);\n case 'oauth2':\n if (!options.providerId) {\n throw new Error('providerId is required for oauth2 getAuthorizationCode');\n }\n return this.oauth2Provider.getAuthorizationCode(options.providerId);\n default:\n throw new Error(`getAuthorizationCode for ${options.provider} is not implemented`);\n }\n }\n\n async refresh(options: LoginOptions): Promise<void> {\n switch (options.provider) {\n case 'google':\n return this.googleProvider.refresh();\n case 'apple':\n return this.appleProvider.refresh();\n case 'facebook':\n return this.facebookProvider.refresh(options.options as FacebookLoginOptions);\n case 'twitter':\n return this.twitterProvider.refresh();\n case 'telegram':\n return this.telegramProvider.refresh();\n case 'linkedin':\n return this.oauth2Provider.refresh(LINKEDIN_PROVIDER_ID);\n case 'tiktok':\n return this.oauth2Provider.refresh(TIKTOK_PROVIDER_ID);\n case 'oauth2': {\n const oauth2Options = options.options as OAuth2LoginOptions;\n if (!oauth2Options?.providerId) {\n throw new Error('providerId is required for oauth2 refresh');\n }\n return this.oauth2Provider.refresh(oauth2Options.providerId);\n }\n default:\n throw new Error(`Refresh for ${(options as any).provider} is not implemented`);\n }\n }\n\n async providerSpecificCall<T extends ProviderSpecificCall>(options: {\n call: T;\n options: ProviderSpecificCallOptionsMap[T];\n }): Promise<ProviderSpecificCallResponseMap[T]> {\n switch (options.call) {\n case 'facebook#getProfile': {\n const fields = (options.options as FacebookGetProfileOptions | undefined)?.fields;\n return this.facebookProvider.getProfile(fields) as Promise<ProviderSpecificCallResponseMap[T]>;\n }\n case 'facebook#requestTracking':\n return this.facebookProvider.requestTracking() as Promise<ProviderSpecificCallResponseMap[T]>;\n case 'google#createRestoreCredential':\n case 'google#getRestoreCredential':\n case 'google#clearRestoreCredential':\n throw new Error(`${options.call} is only available on Android`);\n default:\n throw new Error(`Provider specific call for ${options.call} is not implemented`);\n }\n }\n\n async refreshToken(options: RefreshTokenOptions): Promise<OAuth2LoginResponse> {\n if (options.provider === 'linkedin') {\n return this.oauth2Provider.refreshToken(LINKEDIN_PROVIDER_ID, options.refreshToken, options.additionalParameters);\n }\n if (options.provider === 'tiktok') {\n return this.oauth2Provider.refreshToken(TIKTOK_PROVIDER_ID, options.refreshToken, options.additionalParameters);\n }\n if (options.provider !== 'oauth2') {\n throw new Error('refreshToken is only implemented for oauth2, linkedin, and tiktok on web');\n }\n return this.oauth2Provider.refreshToken(options.providerId, options.refreshToken, options.additionalParameters);\n }\n\n async handleRedirectCallback(): Promise<LoginResult | null> {\n const parsed = await this.parseRedirectResult();\n const callbackState = parsed.state ?? new URL(window.location.href).searchParams.get('state');\n const pendingLinkedInRedirect = consumeLinkedInRedirectPending(callbackState);\n const result = parsed.result;\n if (!result) return null;\n if ('error' in result) {\n throw inferUserCancelledError(result.error);\n }\n if (pendingLinkedInRedirect && isLinkedInOAuthResult(result)) {\n return asLinkedInLoginResult(result);\n }\n if (isTikTokOAuthResult(result)) {\n return asTikTokLoginResult(result);\n }\n return result;\n }\n\n async decodeIdToken(options: { idToken?: string; token?: string }): Promise<{ claims: Record<string, any> }> {\n const token = options?.idToken ?? options?.token;\n if (!token) {\n throw new Error('idToken (or token) is required');\n }\n const claims = this.oauth2Provider.decodeIdToken(token);\n return { claims };\n }\n\n async getAccessTokenExpirationDate(options: { accessTokenExpirationDate: number }): Promise<{ date: string }> {\n if (typeof options?.accessTokenExpirationDate !== 'number') {\n throw new Error('accessTokenExpirationDate is required');\n }\n return { date: new Date(options.accessTokenExpirationDate).toISOString() };\n }\n\n async isAccessTokenAvailable(options: { accessToken: string | null }): Promise<{ isAvailable: boolean }> {\n const token = options?.accessToken ?? null;\n return { isAvailable: typeof token === 'string' && token.length > 0 };\n }\n\n async isAccessTokenExpired(options: { accessTokenExpirationDate: number }): Promise<{ isExpired: boolean }> {\n if (typeof options?.accessTokenExpirationDate !== 'number') {\n throw new Error('accessTokenExpirationDate is required');\n }\n return { isExpired: options.accessTokenExpirationDate <= Date.now() };\n }\n\n async isRefreshTokenAvailable(options: { refreshToken: string | null }): Promise<{ isAvailable: boolean }> {\n const token = options?.refreshToken ?? null;\n return { isAvailable: typeof token === 'string' && token.length > 0 };\n }\n\n async getPluginVersion(): Promise<{ version: string }> {\n return { version: 'web' };\n }\n\n async openSecureWindow(options: OpenSecureWindowOptions): Promise<OpenSecureWindowResponse> {\n const callbackURL = await this.runWebAuthPopup({\n url: options.authEndpoint,\n redirectPrefix: options.redirectUri,\n broadcastChannelName: options.broadcastChannelName,\n });\n return { redirectedUri: callbackURL };\n }\n\n async openAuthSession(options: OpenAuthSessionOptions): Promise<OpenAuthSessionResult> {\n const redirectPrefixes = [`${options.callbackURLScheme}://`];\n try {\n const authUrl = new URL(options.url);\n const redirectUri = authUrl.searchParams.get('redirect_uri');\n if (redirectUri && /^https?:\\/\\//i.test(redirectUri) && !redirectPrefixes.includes(redirectUri)) {\n redirectPrefixes.unshift(redirectUri);\n }\n } catch {\n // ignore malformed authorize URLs; scheme prefix remains the fallback\n }\n\n const callbackURL = await this.runWebAuthPopup({\n url: options.url,\n redirectPrefixes,\n broadcastChannelName: options.broadcastChannelName ?? 'capgo-auth-session',\n });\n return { callbackURL };\n }\n\n private runWebAuthPopup(options: {\n url: string;\n redirectPrefix?: string;\n redirectPrefixes?: string[];\n broadcastChannelName?: string;\n }): Promise<string> {\n if (this.webAuthPopupInProgress) {\n return Promise.reject(new Error('Another auth session is already in progress'));\n }\n this.webAuthPopupInProgress = true;\n\n let popup: Window | null = null;\n let bc: BroadcastChannel | null = null;\n let pollTimer = 0;\n let timeoutTimer = 0;\n\n const releasePopupGuard = () => {\n this.webAuthPopupInProgress = false;\n if (pollTimer) {\n window.clearInterval(pollTimer);\n pollTimer = 0;\n }\n if (timeoutTimer) {\n window.clearTimeout(timeoutTimer);\n timeoutTimer = 0;\n }\n if (bc) {\n try {\n bc.close();\n } catch {\n // ignore close errors\n }\n bc = null;\n }\n };\n\n try {\n const w = 600;\n const h = 550;\n const settings = [\n ['width', w],\n ['height', h],\n ['left', screen.width / 2 - w / 2],\n ['top', screen.height / 2 - h / 2],\n ]\n .map((x) => x.join('='))\n .join(',');\n\n popup = window.open(options.url, 'Authorization', settings);\n if (!popup) {\n releasePopupGuard();\n return Promise.reject(new Error('Unable to open authorization popup. Allow popups for this origin.'));\n }\n if (typeof popup.focus === 'function') {\n popup.focus();\n }\n\n const channelName = options.broadcastChannelName ?? 'oauth-channel';\n bc = new BroadcastChannel(channelName);\n } catch (error) {\n releasePopupGuard();\n if (popup && !popup.closed) {\n try {\n popup.close();\n } catch {\n // ignore cross-origin close errors\n }\n }\n throw error;\n }\n\n const activePopup = popup;\n const activeBc = bc;\n if (!activeBc) {\n releasePopupGuard();\n return Promise.reject(new Error('Unable to open authorization channel'));\n }\n\n return new Promise((resolve, reject) => {\n let settled = false;\n const prefixes = options.redirectPrefixes ?? (options.redirectPrefix != null ? [options.redirectPrefix] : []);\n\n const finish = (handler: () => void) => {\n if (settled) {\n return;\n }\n settled = true;\n releasePopupGuard();\n handler();\n };\n\n activeBc.addEventListener('message', (event) => {\n const data = typeof event.data === 'string' ? event.data : String(event.data ?? '');\n if (prefixes.some((prefix) => data.startsWith(prefix))) {\n finish(() => resolve(data));\n return;\n }\n const looksLikeRedirect = /^https?:\\/\\//i.test(data) || /^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(data);\n if (looksLikeRedirect) {\n finish(() =>\n reject(\n new Error(\n 'Redirect URI does not match expected prefix. Received: ' +\n data +\n ' Expected one of: ' +\n prefixes.join(', '),\n ),\n ),\n );\n }\n });\n\n let popupClosePollState: PopupClosePollState = { graceStartedAtMs: null };\n\n pollTimer = window.setInterval(() => {\n try {\n const closed = activePopup.closed;\n const pollResult = nextPopupClosePollState(closed, popupClosePollState, Date.now());\n popupClosePollState = pollResult.state;\n if (pollResult.shouldCancel) {\n finish(() => reject(createUserCancelledError('User cancelled authorization')));\n }\n } catch {\n window.clearInterval(pollTimer);\n pollTimer = 0;\n }\n }, 500);\n\n timeoutTimer = window.setTimeout(() => {\n finish(() => reject(new Error('The sign-in flow timed out')));\n }, 5 * 60000);\n });\n }\n}\n"]}
1
+ {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,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AAC,EAAE,GAAG,CAAC,CAAC;YAER,YAAY,GAAG,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE;gBACpC,MAAM,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC,CAAC,CAAC;YAChE,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,CAAC;QAChB,CAAC,CAAC,CAAC;IACL,CAAC;;AArlBuB,8BAAe,GAAG,eAAe,AAAlB,CAAmB","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport { AppleSocialLogin } from './apple-provider';\nimport type {\n SocialLoginPlugin,\n InitializeOptions,\n LoginOptions,\n AuthorizationCode,\n AuthorizationCodeOptions,\n isLoggedInOptions,\n ProviderResponseMap,\n FacebookLoginOptions,\n ProviderSpecificCall,\n ProviderSpecificCallOptionsMap,\n ProviderSpecificCallResponseMap,\n LoginResult,\n OAuth2LoginOptions,\n OAuth2LoginResponse,\n OAuth2ProviderConfig,\n OpenAuthSessionOptions,\n OpenAuthSessionResult,\n OpenSecureWindowOptions,\n OpenSecureWindowResponse,\n FacebookGetProfileOptions,\n TelegramLoginOptions,\n LinkedInLoginOptions,\n TikTokLoginOptions,\n RefreshTokenOptions,\n} from './definitions';\nimport { createUserCancelledError, inferUserCancelledError } from './errors';\nimport { FacebookSocialLogin } from './facebook-provider';\nimport { GoogleSocialLogin } from './google-provider';\nimport {\n asLinkedInLoginResult,\n buildLinkedInLoginOptions,\n buildLinkedInOAuthConfig,\n consumeLinkedInRedirectPending,\n isLinkedInOAuthResult,\n LINKEDIN_PROVIDER_ID,\n markLinkedInRedirectPending,\n} from './linkedin-provider';\nimport {\n clearOAuthPopupMarker,\n deliverOAuthResult,\n OAUTH_STATE_KEY,\n shouldAutoFinishOAuthRedirect,\n type OAuthBridgeMessage,\n} from './oauth-popup-bridge';\nimport { OAuth2SocialLogin } from './oauth2-provider';\nimport { TelegramSocialLogin } from './telegram-provider';\nimport {\n asTikTokLoginResult,\n buildTikTokLoginOptions,\n buildTikTokOAuthConfig,\n isTikTokOAuthResult,\n TIKTOK_PROVIDER_ID,\n} from './tiktok-provider';\nimport { TwitterSocialLogin } from './twitter-provider';\nimport { nextPopupClosePollState, type PopupClosePollState } from './web-auth-popup-close';\n\nexport class SocialLoginWeb extends WebPlugin implements SocialLoginPlugin {\n private static readonly OAUTH_STATE_KEY = OAUTH_STATE_KEY;\n\n private googleProvider: GoogleSocialLogin;\n private appleProvider: AppleSocialLogin;\n private facebookProvider: FacebookSocialLogin;\n private twitterProvider: TwitterSocialLogin;\n private telegramProvider: TelegramSocialLogin;\n private oauth2Provider: OAuth2SocialLogin;\n private webAuthPopupInProgress = false;\n\n constructor() {\n super();\n\n this.googleProvider = new GoogleSocialLogin();\n this.appleProvider = new AppleSocialLogin();\n this.facebookProvider = new FacebookSocialLogin();\n this.twitterProvider = new TwitterSocialLogin();\n this.telegramProvider = new TelegramSocialLogin();\n this.oauth2Provider = new OAuth2SocialLogin();\n\n // Auto-finish OAuth redirects only when running inside a popup window.\n // For redirect-based flows (full page navigation), the app should call `handleRedirectCallback()` explicitly.\n // Note: oauth-popup-redirect.ts also handles this eagerly on package import for COOP-safe popup completion.\n if (shouldAutoFinishOAuthRedirect()) {\n this.finishOAuthRedirectInPopup().catch((error) => {\n console.error('Failed to finish OAuth redirect', error);\n try {\n window.close();\n } catch {\n // ignore\n }\n });\n }\n }\n\n private async parseRedirectResult(): Promise<{\n provider: string | null;\n state?: string;\n nonce?: string;\n result: LoginResult | { error: string } | null;\n }> {\n const url = new URL(window.location.href);\n const stateRaw = localStorage.getItem(SocialLoginWeb.OAUTH_STATE_KEY);\n let provider: string | null = null;\n let state: string | undefined;\n let nonce: string | undefined;\n\n if (stateRaw) {\n try {\n const parsed = JSON.parse(stateRaw);\n provider = parsed.provider ?? null;\n state = parsed.state;\n nonce = parsed.nonce;\n } catch {\n provider = stateRaw === 'true' ? 'google' : null;\n }\n }\n\n let result: LoginResult | { error: string } | null;\n\n switch (provider) {\n case 'twitter':\n result = await this.twitterProvider.handleOAuthRedirect(url, state);\n break;\n case 'telegram':\n result = await this.telegramProvider.handleOAuthRedirect(url, state);\n break;\n case 'oauth2':\n result = await this.oauth2Provider.handleOAuthRedirect(url, state);\n break;\n case 'google':\n default:\n result = this.googleProvider.handleOAuthRedirect(url);\n break;\n }\n\n return { provider, state, nonce, result };\n }\n\n private async finishOAuthRedirectInPopup(): Promise<void> {\n const parsed = await this.parseRedirectResult();\n const nonceOrState = parsed.nonce ?? parsed.state;\n let message: OAuthBridgeMessage;\n\n if (!parsed.result) {\n message = {\n type: 'oauth-error',\n provider: parsed.provider,\n error: 'OAuth redirect did not contain expected parameters.',\n };\n } else if ('error' in parsed.result) {\n const resolvedProvider = parsed.provider ?? null;\n const error = inferUserCancelledError(parsed.result.error);\n message = {\n type: 'oauth-error',\n provider: resolvedProvider,\n error: error.message,\n ...(error.code ? { code: error.code } : null),\n };\n } else {\n message = {\n type: 'oauth-response',\n provider: parsed.result.provider,\n ...parsed.result.result,\n };\n }\n\n deliverOAuthResult(parsed.provider ?? 'google', nonceOrState, message);\n clearOAuthPopupMarker();\n\n try {\n window.close();\n } catch {\n // Popup may not be allowed to close itself in some contexts\n }\n }\n\n async initialize(options: InitializeOptions): Promise<void> {\n const initPromises: Promise<void>[] = [];\n\n if (options.google?.webClientId) {\n initPromises.push(\n this.googleProvider.initialize(\n options.google.webClientId,\n options.google.mode,\n options.google.hostedDomain,\n options.google.redirectUrl,\n ),\n );\n }\n\n if (options.apple?.clientId) {\n initPromises.push(\n this.appleProvider.initialize(\n options.apple.clientId,\n options.apple.redirectUrl,\n options.apple.useProperTokenExchange,\n ),\n );\n }\n\n if (options.facebook?.appId) {\n initPromises.push(this.facebookProvider.initialize(options.facebook.appId, options.facebook.locale));\n }\n\n if (options.twitter?.clientId) {\n initPromises.push(\n this.twitterProvider.initialize(\n options.twitter.clientId,\n options.twitter.redirectUrl,\n options.twitter.defaultScopes,\n options.twitter.forceLogin,\n options.twitter.audience,\n ),\n );\n }\n\n if (options.telegram?.botId) {\n this.telegramProvider.initialize(\n options.telegram.botId,\n options.telegram.requestAccess,\n options.telegram.redirectUrl,\n options.telegram.origin,\n options.telegram.languageCode,\n );\n }\n\n const oauth2Configs: Record<string, OAuth2ProviderConfig> = { ...(options.oauth2 ?? {}) };\n if (options.linkedin && !oauth2Configs[LINKEDIN_PROVIDER_ID]) {\n oauth2Configs[LINKEDIN_PROVIDER_ID] = buildLinkedInOAuthConfig(options.linkedin);\n }\n if (options.tiktok) {\n if (!options.tiktok.clientKey || !options.tiktok.redirectUrl) {\n throw new Error('tiktok.clientKey and tiktok.redirectUrl are required');\n }\n if (!oauth2Configs[TIKTOK_PROVIDER_ID]) {\n oauth2Configs[TIKTOK_PROVIDER_ID] = buildTikTokOAuthConfig(options.tiktok);\n }\n }\n if (Object.keys(oauth2Configs).length > 0) {\n initPromises.push(this.oauth2Provider.initializeProviders(oauth2Configs));\n }\n\n await Promise.all(initPromises);\n }\n\n async login<T extends LoginOptions['provider']>(\n options: Extract<LoginOptions, { provider: T }>,\n ): Promise<{ provider: T; result: ProviderResponseMap[T] }> {\n switch (options.provider) {\n case 'google':\n return this.googleProvider.login(options.options as any) as Promise<{\n provider: T;\n result: ProviderResponseMap[T];\n }>;\n case 'apple':\n return this.appleProvider.login(options.options as any) as Promise<{\n provider: T;\n result: ProviderResponseMap[T];\n }>;\n case 'facebook':\n return this.facebookProvider.login(options.options as FacebookLoginOptions) as Promise<{\n provider: T;\n result: ProviderResponseMap[T];\n }>;\n case 'twitter':\n return this.twitterProvider.login(options.options as any) as Promise<{\n provider: T;\n result: ProviderResponseMap[T];\n }>;\n case 'telegram':\n return this.telegramProvider.login(options.options as TelegramLoginOptions) as Promise<{\n provider: T;\n result: ProviderResponseMap[T];\n }>;\n case 'linkedin': {\n const linkedInOptions = (options.options as LinkedInLoginOptions | undefined) ?? {};\n const oauthOptions = buildLinkedInLoginOptions(linkedInOptions);\n if (oauthOptions.flow === 'redirect' && oauthOptions.state) {\n markLinkedInRedirectPending(oauthOptions.state);\n }\n const response = await this.oauth2Provider.login(oauthOptions);\n return asLinkedInLoginResult(response) as { provider: T; result: ProviderResponseMap[T] };\n }\n case 'tiktok': {\n const response = await this.oauth2Provider.login(\n buildTikTokLoginOptions(options.options as TikTokLoginOptions),\n );\n return asTikTokLoginResult(response) as { provider: T; result: ProviderResponseMap[T] };\n }\n case 'oauth2':\n return this.oauth2Provider.login(options.options as OAuth2LoginOptions) as Promise<{\n provider: T;\n result: ProviderResponseMap[T];\n }>;\n default:\n throw new Error(`Login for ${options.provider} is not implemented on web`);\n }\n }\n\n async logout(options: {\n provider: 'apple' | 'google' | 'facebook' | 'twitter' | 'telegram' | 'linkedin' | 'tiktok' | 'oauth2';\n providerId?: string;\n clearCachedUserInfo?: boolean;\n }): Promise<void> {\n switch (options.provider) {\n case 'google':\n return this.googleProvider.logout();\n case 'apple':\n return this.appleProvider.logout();\n case 'facebook':\n return this.facebookProvider.logout();\n case 'twitter':\n return this.twitterProvider.logout();\n case 'telegram':\n return this.telegramProvider.logout();\n case 'linkedin':\n return this.oauth2Provider.logout(LINKEDIN_PROVIDER_ID);\n case 'tiktok':\n return this.oauth2Provider.logout(TIKTOK_PROVIDER_ID);\n case 'oauth2':\n if (!options.providerId) {\n throw new Error('providerId is required for oauth2 logout');\n }\n return this.oauth2Provider.logout(options.providerId);\n default:\n throw new Error(`Logout for ${options.provider} is not implemented`);\n }\n }\n\n async isLoggedIn(options: isLoggedInOptions): Promise<{ isLoggedIn: boolean }> {\n switch (options.provider) {\n case 'google':\n return this.googleProvider.isLoggedIn();\n case 'apple':\n return this.appleProvider.isLoggedIn();\n case 'facebook':\n return this.facebookProvider.isLoggedIn();\n case 'twitter':\n return this.twitterProvider.isLoggedIn();\n case 'telegram':\n return this.telegramProvider.isLoggedIn();\n case 'linkedin':\n return this.oauth2Provider.isLoggedIn(LINKEDIN_PROVIDER_ID);\n case 'tiktok':\n return this.oauth2Provider.isLoggedIn(TIKTOK_PROVIDER_ID);\n case 'oauth2':\n if (!options.providerId) {\n throw new Error('providerId is required for oauth2 isLoggedIn');\n }\n return this.oauth2Provider.isLoggedIn(options.providerId);\n default:\n throw new Error(`isLoggedIn for ${options.provider} is not implemented`);\n }\n }\n\n async getAuthorizationCode(options: AuthorizationCodeOptions): Promise<AuthorizationCode> {\n switch (options.provider) {\n case 'google':\n return this.googleProvider.getAuthorizationCode();\n case 'apple':\n return this.appleProvider.getAuthorizationCode();\n case 'facebook':\n return this.facebookProvider.getAuthorizationCode();\n case 'twitter':\n return this.twitterProvider.getAuthorizationCode();\n case 'linkedin':\n return this.oauth2Provider.getAuthorizationCode(LINKEDIN_PROVIDER_ID);\n case 'tiktok':\n return this.oauth2Provider.getAuthorizationCode(TIKTOK_PROVIDER_ID);\n case 'oauth2':\n if (!options.providerId) {\n throw new Error('providerId is required for oauth2 getAuthorizationCode');\n }\n return this.oauth2Provider.getAuthorizationCode(options.providerId);\n default:\n throw new Error(`getAuthorizationCode for ${options.provider} is not implemented`);\n }\n }\n\n async refresh(options: LoginOptions): Promise<void> {\n switch (options.provider) {\n case 'google':\n return this.googleProvider.refresh();\n case 'apple':\n return this.appleProvider.refresh();\n case 'facebook':\n return this.facebookProvider.refresh(options.options as FacebookLoginOptions);\n case 'twitter':\n return this.twitterProvider.refresh();\n case 'telegram':\n return this.telegramProvider.refresh();\n case 'linkedin':\n return this.oauth2Provider.refresh(LINKEDIN_PROVIDER_ID);\n case 'tiktok':\n return this.oauth2Provider.refresh(TIKTOK_PROVIDER_ID);\n case 'oauth2': {\n const oauth2Options = options.options as OAuth2LoginOptions;\n if (!oauth2Options?.providerId) {\n throw new Error('providerId is required for oauth2 refresh');\n }\n return this.oauth2Provider.refresh(oauth2Options.providerId);\n }\n default:\n throw new Error(`Refresh for ${(options as any).provider} is not implemented`);\n }\n }\n\n async providerSpecificCall<T extends ProviderSpecificCall>(options: {\n call: T;\n options: ProviderSpecificCallOptionsMap[T];\n }): Promise<ProviderSpecificCallResponseMap[T]> {\n switch (options.call) {\n case 'facebook#getProfile': {\n const fields = (options.options as FacebookGetProfileOptions | undefined)?.fields;\n return this.facebookProvider.getProfile(fields) as Promise<ProviderSpecificCallResponseMap[T]>;\n }\n case 'facebook#requestTracking':\n return this.facebookProvider.requestTracking() as Promise<ProviderSpecificCallResponseMap[T]>;\n case 'google#createRestoreCredential':\n case 'google#getRestoreCredential':\n case 'google#clearRestoreCredential':\n throw new Error(`${options.call} is only available on Android`);\n default:\n throw new Error(`Provider specific call for ${options.call} is not implemented`);\n }\n }\n\n async refreshToken(options: RefreshTokenOptions): Promise<OAuth2LoginResponse> {\n if (options.provider === 'linkedin') {\n return this.oauth2Provider.refreshToken(LINKEDIN_PROVIDER_ID, options.refreshToken, options.additionalParameters);\n }\n if (options.provider === 'tiktok') {\n return this.oauth2Provider.refreshToken(TIKTOK_PROVIDER_ID, options.refreshToken, options.additionalParameters);\n }\n if (options.provider !== 'oauth2') {\n throw new Error('refreshToken is only implemented for oauth2, linkedin, and tiktok on web');\n }\n return this.oauth2Provider.refreshToken(options.providerId, options.refreshToken, options.additionalParameters);\n }\n\n async handleRedirectCallback(): Promise<LoginResult | null> {\n const parsed = await this.parseRedirectResult();\n const callbackState = parsed.state ?? new URL(window.location.href).searchParams.get('state');\n const pendingLinkedInRedirect = consumeLinkedInRedirectPending(callbackState);\n const result = parsed.result;\n if (!result) return null;\n if ('error' in result) {\n throw inferUserCancelledError(result.error);\n }\n if (pendingLinkedInRedirect && isLinkedInOAuthResult(result)) {\n return asLinkedInLoginResult(result);\n }\n if (isTikTokOAuthResult(result)) {\n return asTikTokLoginResult(result);\n }\n return result;\n }\n\n async decodeIdToken(options: { idToken?: string; token?: string }): Promise<{ claims: Record<string, any> }> {\n const token = options?.idToken ?? options?.token;\n if (!token) {\n throw new Error('idToken (or token) is required');\n }\n const claims = this.oauth2Provider.decodeIdToken(token);\n return { claims };\n }\n\n async getAccessTokenExpirationDate(options: { accessTokenExpirationDate: number }): Promise<{ date: string }> {\n if (typeof options?.accessTokenExpirationDate !== 'number') {\n throw new Error('accessTokenExpirationDate is required');\n }\n return { date: new Date(options.accessTokenExpirationDate).toISOString() };\n }\n\n async isAccessTokenAvailable(options: { accessToken: string | null }): Promise<{ isAvailable: boolean }> {\n const token = options?.accessToken ?? null;\n return { isAvailable: typeof token === 'string' && token.length > 0 };\n }\n\n async isAccessTokenExpired(options: { accessTokenExpirationDate: number }): Promise<{ isExpired: boolean }> {\n if (typeof options?.accessTokenExpirationDate !== 'number') {\n throw new Error('accessTokenExpirationDate is required');\n }\n return { isExpired: options.accessTokenExpirationDate <= Date.now() };\n }\n\n async isRefreshTokenAvailable(options: { refreshToken: string | null }): Promise<{ isAvailable: boolean }> {\n const token = options?.refreshToken ?? null;\n return { isAvailable: typeof token === 'string' && token.length > 0 };\n }\n\n async getPluginVersion(): Promise<{ version: string }> {\n return { version: 'web' };\n }\n\n async openSecureWindow(options: OpenSecureWindowOptions): Promise<OpenSecureWindowResponse> {\n const callbackURL = await this.runWebAuthPopup({\n url: options.authEndpoint,\n redirectPrefix: options.redirectUri,\n broadcastChannelName: options.broadcastChannelName,\n });\n return { redirectedUri: callbackURL };\n }\n\n async openAuthSession(options: OpenAuthSessionOptions): Promise<OpenAuthSessionResult> {\n const redirectPrefixes = [`${options.callbackURLScheme}://`];\n try {\n const authUrl = new URL(options.url);\n const redirectUri = authUrl.searchParams.get('redirect_uri');\n if (redirectUri && /^https?:\\/\\//i.test(redirectUri) && !redirectPrefixes.includes(redirectUri)) {\n redirectPrefixes.unshift(redirectUri);\n }\n } catch {\n // ignore malformed authorize URLs; scheme prefix remains the fallback\n }\n\n const callbackURL = await this.runWebAuthPopup({\n url: options.url,\n redirectPrefixes,\n broadcastChannelName: options.broadcastChannelName ?? 'capgo-auth-session',\n });\n return { callbackURL };\n }\n\n private runWebAuthPopup(options: {\n url: string;\n redirectPrefix?: string;\n redirectPrefixes?: string[];\n broadcastChannelName?: string;\n }): Promise<string> {\n if (this.webAuthPopupInProgress) {\n return Promise.reject(new Error('Another auth session is already in progress'));\n }\n this.webAuthPopupInProgress = true;\n\n let popup: Window | null = null;\n let bc: BroadcastChannel | null = null;\n let pollTimer = 0;\n let timeoutTimer = 0;\n\n const releasePopupGuard = () => {\n this.webAuthPopupInProgress = false;\n if (pollTimer) {\n window.clearInterval(pollTimer);\n pollTimer = 0;\n }\n if (timeoutTimer) {\n window.clearTimeout(timeoutTimer);\n timeoutTimer = 0;\n }\n if (bc) {\n try {\n bc.close();\n } catch {\n // ignore close errors\n }\n bc = null;\n }\n };\n\n try {\n const w = 600;\n const h = 550;\n const settings = [\n ['width', w],\n ['height', h],\n ['left', screen.width / 2 - w / 2],\n ['top', screen.height / 2 - h / 2],\n ]\n .map((x) => x.join('='))\n .join(',');\n\n popup = window.open(options.url, 'Authorization', settings);\n if (!popup) {\n releasePopupGuard();\n return Promise.reject(new Error('Unable to open authorization popup. Allow popups for this origin.'));\n }\n if (typeof popup.focus === 'function') {\n popup.focus();\n }\n\n const channelName = options.broadcastChannelName ?? 'oauth-channel';\n bc = new BroadcastChannel(channelName);\n } catch (error) {\n releasePopupGuard();\n if (popup && !popup.closed) {\n try {\n popup.close();\n } catch {\n // ignore cross-origin close errors\n }\n }\n throw error;\n }\n\n const activePopup = popup;\n const activeBc = bc;\n if (!activeBc) {\n releasePopupGuard();\n return Promise.reject(new Error('Unable to open authorization channel'));\n }\n\n return new Promise((resolve, reject) => {\n let settled = false;\n const prefixes = options.redirectPrefixes ?? (options.redirectPrefix != null ? [options.redirectPrefix] : []);\n\n const finish = (handler: () => void) => {\n if (settled) {\n return;\n }\n settled = true;\n releasePopupGuard();\n handler();\n };\n\n activeBc.addEventListener('message', (event) => {\n const data = typeof event.data === 'string' ? event.data : String(event.data ?? '');\n if (prefixes.some((prefix) => data.startsWith(prefix))) {\n finish(() => resolve(data));\n return;\n }\n const looksLikeRedirect = /^https?:\\/\\//i.test(data) || /^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(data);\n if (looksLikeRedirect) {\n finish(() =>\n reject(\n new Error(\n 'Redirect URI does not match expected prefix. Received: ' +\n data +\n ' Expected one of: ' +\n prefixes.join(', '),\n ),\n ),\n );\n }\n });\n\n let popupClosePollState: PopupClosePollState = { graceStartedAtMs: null };\n\n pollTimer = window.setInterval(() => {\n try {\n const closed = activePopup.closed;\n const pollResult = nextPopupClosePollState(closed, popupClosePollState, Date.now());\n popupClosePollState = pollResult.state;\n if (pollResult.shouldCancel) {\n finish(() => reject(createUserCancelledError('User cancelled authorization')));\n }\n } catch {\n window.clearInterval(pollTimer);\n pollTimer = 0;\n }\n }, 500);\n\n timeoutTimer = window.setTimeout(() => {\n finish(() => reject(new Error('The sign-in flow timed out')));\n }, 5 * 60000);\n });\n }\n}\n"]}
@@ -189,11 +189,8 @@ class AppleProvider: NSObject, ASAuthorizationControllerDelegate, ASAuthorizatio
189
189
  // Convert the object to JSON data
190
190
  let jsonData = try JSONSerialization.data(withJSONObject: object, options: [])
191
191
 
192
- // Convert JSON data to a string for logging
192
+ // Convert JSON data to a string. It holds the tokens, so it is not logged.
193
193
  if let jsonString = String(data: jsonData, encoding: .utf8) {
194
- // Log the object
195
- print("Apple persistState: \(jsonString)")
196
-
197
194
  // Save the JSON string to UserDefaults or use your helper method
198
195
  UserDefaults.standard.set(jsonString, forKey: SHARED_PREFERENCE_NAME)
199
196
  } else {
@@ -232,9 +229,6 @@ class AppleProvider: NSObject, ASAuthorizationControllerDelegate, ASAuthorizatio
232
229
  self.idToken = idToken
233
230
  self.refreshToken = refreshToken
234
231
  self.accessToken = accessToken
235
-
236
- // Log the retrieved object
237
- print("Apple retrieveState: \(object)")
238
232
  }
239
233
 
240
234
  func login(payload: [String: Any], completion: @escaping (Result<AppleProviderResponse, Error>) -> Void) {
@@ -266,7 +260,12 @@ class AppleProvider: NSObject, ASAuthorizationControllerDelegate, ASAuthorizatio
266
260
  }
267
261
  }
268
262
 
269
- func logout(completion: @escaping (Result<Void, Error>) -> Void) {
263
+ func logout(clearCachedUserInfo: Bool = false, completion: @escaping (Result<Void, Error>) -> Void) {
264
+ // First, so it also happens without a session: the cached name outlives the tokens.
265
+ if clearCachedUserInfo {
266
+ UserDefaults.standard.removeObject(forKey: USER_INFO_KEY)
267
+ }
268
+
270
269
  // we check only idtoken, because with apple, refresh token MIGHT not be set
271
270
  if self.idToken == nil || ((self.idToken?.isEmpty) == true) {
272
271
 
@@ -336,7 +335,6 @@ class AppleProvider: NSObject, ASAuthorizationControllerDelegate, ASAuthorizatio
336
335
 
337
336
  if let decodedData = Data(base64Encoded: base64String, options: []),
338
337
  let payload = try? JSONSerialization.jsonObject(with: decodedData, options: []) as? [String: Any] {
339
- print("payload", payload)
340
338
  decodedEmail = payload["email"] as? String ?? email
341
339
  }
342
340
  }
@@ -444,15 +442,14 @@ class AppleProvider: NSObject, ASAuthorizationControllerDelegate, ASAuthorizatio
444
442
  // Check if the response is a redirect
445
443
  if (300...399).contains(httpResponse.statusCode) {
446
444
  if let location = httpResponse.value(forHTTPHeaderField: "Location") {
447
- print("Redirect Location: \(location)")
445
+ // Neither the redirect URL nor its query items are logged: they carry
446
+ // the authorization code or the tokens.
448
447
 
449
448
  // Parse the redirect URL
450
449
  if let redirectURL = URL(string: location),
451
450
  let urlComponents = URLComponents(url: redirectURL, resolvingAgainstBaseURL: false),
452
451
  let pathComponents = urlComponents.queryItems {
453
452
 
454
- print("Query items: \(String(describing: urlComponents.queryItems))")
455
-
456
453
  // there are 4 main ways this can go:
457
454
  // 1. it provides the "code" and we fetch apple servers in order to get the JWT (yuck)
458
455
  // 2. It doesn't provide the code but it provides access_token, refresh_token, id_token
@@ -543,10 +540,9 @@ class AppleProvider: NSObject, ASAuthorizationControllerDelegate, ASAuthorizatio
543
540
  return
544
541
  }
545
542
  } else {
546
- // Handle non-redirect responses
547
- if let data = data,
548
- let responseString = String(data: data, encoding: .utf8) {
549
- print("Response: \(responseString)")
543
+ // Handle non-redirect responses. The body is not logged: it can carry tokens.
544
+ if let data = data, !data.isEmpty {
545
+ print("Received a non-redirect response (\(data.count) bytes)")
550
546
  } else {
551
547
  print("No response data received")
552
548
  }
@@ -659,13 +655,6 @@ class AppleProvider: NSObject, ASAuthorizationControllerDelegate, ASAuthorizatio
659
655
  authorizationCode: nil
660
656
  )
661
657
 
662
- // Log the tokens (replace with your logging mechanism)
663
- print("Apple Access Token is: \(accessToken)")
664
- print("Expires in: \(expiresIn)")
665
- print("Refresh token: \(refreshToken)")
666
- print("ID Token: \(idToken)")
667
- print("Apple User ID: \(userId)")
668
-
669
658
  do {
670
659
  try self.persistState(idToken: idToken, refreshToken: refreshToken, accessToken: accessToken)
671
660
  } catch {
@@ -16,7 +16,7 @@ import GoogleSignIn
16
16
  */
17
17
  @objc(SocialLoginPlugin)
18
18
  public class SocialLoginPlugin: CAPPlugin, CAPBridgedPlugin {
19
- private let pluginVersion: String = "8.6.0"
19
+ private let pluginVersion: String = "8.7.0"
20
20
  public let identifier = "SocialLoginPlugin"
21
21
  public let jsName = "SocialLogin"
22
22
  private static let userCancelledCode = "USER_CANCELLED"
@@ -589,7 +589,7 @@ public class SocialLoginPlugin: CAPPlugin, CAPBridgedPlugin {
589
589
  call.reject("Apple Sign-In provider is disabled in capacitor.config")
590
590
  return
591
591
  }
592
- apple.logout { result in
592
+ apple.logout(clearCachedUserInfo: call.getBool("clearCachedUserInfo") ?? false) { result in
593
593
  self.handleLogoutResult(result, call: call)
594
594
  }
595
595
  case "twitter":
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/capacitor-social-login",
3
- "version": "8.6.0",
3
+ "version": "8.7.0",
4
4
  "description": "All social logins in one plugin",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",