@capgo/capacitor-social-login 8.5.3 → 8.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"auth-connect.js","sourceRoot":"","sources":["../../src/auth-connect.ts"],"names":[],"mappings":";AAaA,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AA0EjD,MAAM,sBAAsB,GAAqC,CAAC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC;AAEnH,MAAM,cAAc,GAA0C;IAC5D,KAAK,EAAE,qCAAqC;IAC5C,KAAK,EAAE,sBAAsB;IAC7B,OAAO,EAAE,sBAAsB;IAC/B,IAAI,EAAE,qCAAqC;IAC3C,QAAQ,EAAE,sBAAsB;CACjC,CAAC;AAEF,MAAM,qBAAqB,GAAmD;IAC5E,KAAK,EAAE,qCAAqC;CAC7C,CAAC;AAEF,MAAM,sBAAsB,GAAG,mCAAmC,CAAC;AAEnE,MAAM,cAAc,GAAG,CAAC,KAAa,EAAU,EAAE;IAC/C,IAAI,KAAK,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,KAAK,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QAChE,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,WAAW,KAAK,EAAE,CAAC;AAC5B,CAAC,CAAC;AAEF,MAAM,iBAAiB,GAAG,CAAC,KAAa,EAAU,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AAE/E,MAAM,OAAO,GAAG,CAAC,IAAY,EAAE,IAAY,EAAU,EAAE;IACrD,MAAM,aAAa,GAAG,iBAAiB,CAAC,IAAI,CAAC,CAAC;IAC9C,MAAM,aAAa,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IAC/C,OAAO,GAAG,aAAa,IAAI,aAAa,EA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AC;IAC9G,oBAAoB,EAAE,KAAK,EAAkC,OAG5D,EAA+C,EAAE,CAAC,MAAM,CAAC,oBAAoB,CAAC,OAAO,CAAC;IACvF,gBAAgB,EAAE,KAAK,IAAkC,EAAE,CAAC,MAAM,CAAC,gBAAgB,EAAE;CACtF,CAAC,CAAC;AAEH,MAAM,sBAAsB,GAAG,uBAAuB,CAAC,eAAe,CAAC,CAAC;AAUxE,OAAO,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,CAAC","sourcesContent":["import type {\n AuthorizationCode,\n AuthorizationCodeOptions,\n InitializeOptions,\n LoginOptions,\n OAuth2LoginOptions,\n OAuth2ProviderConfig,\n ProviderSpecificCall,\n ProviderSpecificCallOptionsMap,\n ProviderSpecificCallResponseMap,\n ProviderResponseMap,\n SocialLoginPlugin,\n} from './definitions';\nimport { SocialLoginBase } from './social-login';\n\ntype AuthConnectProviderId = 'auth0' | 'azure' | 'cognito' | 'okta' | 'onelogin';\n\ntype AuthConnectLoginOptions =\n | LoginOptions\n | {\n provider: AuthConnectProviderId;\n options?: Omit<OAuth2LoginOptions, 'providerId'>;\n };\n\ntype AuthConnectProviderOptions =\n | AuthorizationCodeOptions\n | {\n provider: AuthConnectProviderId;\n };\n\ntype AuthConnectInitializeOptions = InitializeOptions & {\n authConnect?: AuthConnectPresets;\n};\n\ntype AuthConnectPresetBase = {\n clientId: string;\n redirectUrl: string;\n scope?: string;\n responseType?: 'code' | 'token';\n pkceEnabled?: boolean;\n additionalParameters?: Record<string, string>;\n additionalResourceHeaders?: Record<string, string>;\n resourceUrl?: string;\n authorizationBaseUrl?: string;\n accessTokenEndpoint?: string;\n logoutUrl?: string;\n logsEnabled?: boolean;\n};\n\ntype Auth0Preset = AuthConnectPresetBase & {\n domain: string;\n audience?: string;\n};\n\ntype AzurePreset = AuthConnectPresetBase & {\n tenantId?: string;\n authorityHost?: string;\n};\n\ntype CognitoPreset = AuthConnectPresetBase & {\n domain: string;\n};\n\ntype OktaPreset = AuthConnectPresetBase & {\n issuer: string;\n};\n\ntype OneLoginPreset = AuthConnectPresetBase & {\n issuer: string;\n};\n\ntype AuthConnectPresets = {\n auth0?: Auth0Preset;\n azure?: AzurePreset;\n cognito?: CognitoPreset;\n okta?: OktaPreset;\n onelogin?: OneLoginPreset;\n};\n\ntype AuthConnectProviderResponseMap = ProviderResponseMap & {\n auth0: ProviderResponseMap['oauth2'];\n azure: ProviderResponseMap['oauth2'];\n cognito: ProviderResponseMap['oauth2'];\n okta: ProviderResponseMap['oauth2'];\n onelogin: ProviderResponseMap['oauth2'];\n};\n\nconst AUTH_CONNECT_PROVIDERS: readonly AuthConnectProviderId[] = ['auth0', 'azure', 'cognito', 'okta', 'onelogin'];\n\nconst DEFAULT_SCOPES: Record<AuthConnectProviderId, string> = {\n auth0: 'openid profile email offline_access',\n azure: 'openid profile email',\n cognito: 'openid profile email',\n okta: 'openid profile email offline_access',\n onelogin: 'openid profile email',\n};\n\nconst DEFAULT_RESOURCE_URLS: Partial<Record<AuthConnectProviderId, string>> = {\n azure: 'https://graph.microsoft.com/v1.0/me',\n};\n\nconst DEFAULT_AUTHORITY_HOST = 'https://login.microsoftonline.com';\n\nconst ensureProtocol = (value: string): string => {\n if (value.startsWith('http://') || value.startsWith('https://')) {\n return value;\n }\n return `https://${value}`;\n};\n\nconst trimTrailingSlash = (value: string): string => value.replace(/\\/+$/, '');\n\nconst joinUrl = (base: string, path: string): string => {\n const sanitizedBase = trimTrailingSlash(base);\n const sanitizedPath = path.replace(/^\\/+/, '');\n return `${sanitizedBase}/${sanitizedPath}`;\n};\n\nconst mergeRecords = (\n base?: Record<string, string>,\n overrides?: Record<string, string>,\n): Record<string, string> | undefined => {\n if (!base && !overrides) {\n return undefined;\n }\n return { ...(base ?? {}), ...(overrides ?? {}) };\n};\n\nconst validatePreset = (providerId: AuthConnectProviderId, preset: AuthConnectPresetBase): void => {\n if (!preset.clientId) {\n throw new Error(`[authConnect] ${providerId} requires clientId.`);\n }\n if (!preset.redirectUrl) {\n throw new Error(`[authConnect] ${providerId} requires redirectUrl.`);\n }\n};\n\nconst buildAuth0Config = (preset: Auth0Preset): OAuth2ProviderConfig => {\n validatePreset('auth0', preset);\n if (!preset.domain) {\n throw new Error('[authConnect] auth0 requires domain.');\n }\n const base = trimTrailingSlash(ensureProtocol(preset.domain));\n return buildConfigFromPreset('auth0', preset, {\n authorizationBaseUrl: joinUrl(base, 'authorize'),\n accessTokenEndpoint: joinUrl(base, 'oauth/token'),\n resourceUrl: joinUrl(base, 'userinfo'),\n logoutUrl: joinUrl(base, 'v2/logout'),\n additionalParameters: preset.audience ? { audience: preset.audience } : undefined,\n });\n};\n\nconst buildAzureConfig = (preset: AzurePreset): OAuth2ProviderConfig => {\n validatePreset('azure', preset);\n const tenantId = preset.tenantId ?? 'common';\n const authorityHost = trimTrailingSlash(ensureProtocol(preset.authorityHost ?? DEFAULT_AUTHORITY_HOST));\n const base = joinUrl(authorityHost, `${tenantId}/oauth2/v2.0`);\n return buildConfigFromPreset('azure', preset, {\n authorizationBaseUrl: joinUrl(base, 'authorize'),\n accessTokenEndpoint: joinUrl(base, 'token'),\n resourceUrl: DEFAULT_RESOURCE_URLS.azure,\n });\n};\n\nconst buildCognitoConfig = (preset: CognitoPreset): OAuth2ProviderConfig => {\n validatePreset('cognito', preset);\n if (!preset.domain) {\n throw new Error('[authConnect] cognito requires domain.');\n }\n const base = trimTrailingSlash(ensureProtocol(preset.domain));\n return buildConfigFromPreset('cognito', preset, {\n authorizationBaseUrl: joinUrl(base, 'oauth2/authorize'),\n accessTokenEndpoint: joinUrl(base, 'oauth2/token'),\n resourceUrl: joinUrl(base, 'oauth2/userInfo'),\n logoutUrl: joinUrl(base, 'logout'),\n });\n};\n\nconst buildOktaConfig = (preset: OktaPreset): OAuth2ProviderConfig => {\n validatePreset('okta', preset);\n if (!preset.issuer) {\n throw new Error('[authConnect] okta requires issuer.');\n }\n const base = trimTrailingSlash(ensureProtocol(preset.issuer));\n return buildConfigFromPreset('okta', preset, {\n authorizationBaseUrl: joinUrl(base, 'v1/authorize'),\n accessTokenEndpoint: joinUrl(base, 'v1/token'),\n resourceUrl: joinUrl(base, 'v1/userinfo'),\n logoutUrl: joinUrl(base, 'v1/logout'),\n });\n};\n\nconst buildOneLoginConfig = (preset: OneLoginPreset): OAuth2ProviderConfig => {\n validatePreset('onelogin', preset);\n if (!preset.issuer) {\n throw new Error('[authConnect] onelogin requires issuer.');\n }\n const base = trimTrailingSlash(ensureProtocol(preset.issuer));\n return buildConfigFromPreset('onelogin', preset, {\n authorizationBaseUrl: joinUrl(base, 'auth'),\n accessTokenEndpoint: joinUrl(base, 'token'),\n resourceUrl: joinUrl(base, 'me'),\n logoutUrl: joinUrl(base, 'logout'),\n });\n};\n\nconst buildConfigFromPreset = (\n providerId: AuthConnectProviderId,\n preset: AuthConnectPresetBase,\n defaults: Partial<OAuth2ProviderConfig>,\n): OAuth2ProviderConfig => {\n const additionalParameters = mergeRecords(defaults.additionalParameters, preset.additionalParameters);\n const additionalResourceHeaders = mergeRecords(defaults.additionalResourceHeaders, preset.additionalResourceHeaders);\n\n const config: OAuth2ProviderConfig = {\n appId: preset.clientId,\n authorizationBaseUrl: preset.authorizationBaseUrl ?? defaults.authorizationBaseUrl ?? '',\n accessTokenEndpoint: preset.accessTokenEndpoint ?? defaults.accessTokenEndpoint,\n redirectUrl: preset.redirectUrl,\n resourceUrl: preset.resourceUrl ?? defaults.resourceUrl,\n responseType: preset.responseType ?? defaults.responseType ?? 'code',\n pkceEnabled: preset.pkceEnabled ?? defaults.pkceEnabled ?? true,\n scope: preset.scope ?? defaults.scope ?? DEFAULT_SCOPES[providerId],\n additionalParameters,\n additionalResourceHeaders,\n logoutUrl: preset.logoutUrl ?? defaults.logoutUrl,\n logsEnabled: preset.logsEnabled ?? defaults.logsEnabled,\n };\n\n if (!config.authorizationBaseUrl) {\n throw new Error(`[authConnect] ${providerId} authorizationBaseUrl is required.`);\n }\n\n return config;\n};\n\nconst buildAuthConnectProviders = (presets?: AuthConnectPresets): Record<string, OAuth2ProviderConfig> => {\n if (!presets) {\n return {};\n }\n const providers: Record<string, OAuth2ProviderConfig> = {};\n\n if (presets.auth0) {\n providers.auth0 = buildAuth0Config(presets.auth0);\n }\n if (presets.azure) {\n providers.azure = buildAzureConfig(presets.azure);\n }\n if (presets.cognito) {\n providers.cognito = buildCognitoConfig(presets.cognito);\n }\n if (presets.okta) {\n providers.okta = buildOktaConfig(presets.okta);\n }\n if (presets.onelogin) {\n providers.onelogin = buildOneLoginConfig(presets.onelogin);\n }\n\n return providers;\n};\n\nconst isAuthConnectProvider = (provider: string): provider is AuthConnectProviderId =>\n AUTH_CONNECT_PROVIDERS.includes(provider as AuthConnectProviderId);\n\nconst isAuthConnectProviderOptions = (\n options: AuthConnectProviderOptions,\n): options is Extract<AuthConnectProviderOptions, { provider: AuthConnectProviderId }> =>\n isAuthConnectProvider(options.provider);\n\nconst isAuthConnectLoginOptions = (\n options: AuthConnectLoginOptions,\n): options is Extract<AuthConnectLoginOptions, { provider: AuthConnectProviderId }> =>\n isAuthConnectProvider(options.provider);\n\nconst mapLoginOptions = (options: AuthConnectLoginOptions): LoginOptions => {\n if (isAuthConnectLoginOptions(options)) {\n return {\n provider: 'oauth2',\n options: {\n providerId: options.provider,\n ...(options.options ?? {}),\n },\n };\n }\n\n return options;\n};\n\nconst mapProviderOptions = (options: AuthConnectProviderOptions): AuthorizationCodeOptions => {\n if (isAuthConnectProviderOptions(options)) {\n return {\n provider: 'oauth2',\n providerId: options.provider,\n };\n }\n\n return options;\n};\n\nconst mapRefreshOptions = (options: AuthConnectLoginOptions): LoginOptions => mapLoginOptions(options);\n\nconst mergeOAuth2Configs = (\n presets: Record<string, OAuth2ProviderConfig>,\n oauth2?: Record<string, OAuth2ProviderConfig>,\n): Record<string, OAuth2ProviderConfig> | undefined => {\n if (!Object.keys(presets).length && !oauth2) {\n return oauth2;\n }\n return {\n ...presets,\n ...(oauth2 ?? {}),\n };\n};\n\ntype AuthConnectClient = {\n initialize: (options: AuthConnectInitializeOptions) => Promise<void>;\n login: <T extends AuthConnectLoginOptions['provider']>(\n options: Extract<AuthConnectLoginOptions, { provider: T }>,\n ) => Promise<{ provider: T; result: AuthConnectProviderResponseMap[T] }>;\n logout: (options: AuthConnectProviderOptions) => Promise<void>;\n isLoggedIn: (options: AuthConnectProviderOptions) => Promise<{ isLoggedIn: boolean }>;\n getAuthorizationCode: (options: AuthConnectProviderOptions) => Promise<AuthorizationCode>;\n refresh: (options: AuthConnectLoginOptions) => Promise<void>;\n providerSpecificCall: <T extends ProviderSpecificCall>(options: {\n call: T;\n options: ProviderSpecificCallOptionsMap[T];\n }) => Promise<ProviderSpecificCallResponseMap[T]>;\n getPluginVersion: () => Promise<{ version: string }>;\n};\n\nconst createAuthConnectClient = (client: SocialLoginPlugin): AuthConnectClient => ({\n initialize: async (options: AuthConnectInitializeOptions): Promise<void> => {\n const { authConnect, oauth2, ...rest } = options;\n const presetProviders = buildAuthConnectProviders(authConnect);\n const mergedOauth2 = mergeOAuth2Configs(presetProviders, oauth2);\n const payload: InitializeOptions = {\n ...rest,\n ...(mergedOauth2 ? { oauth2: mergedOauth2 } : {}),\n };\n return client.initialize(payload);\n },\n login: async <T extends AuthConnectLoginOptions['provider']>(\n options: Extract<AuthConnectLoginOptions, { provider: T }>,\n ): Promise<{ provider: T; result: AuthConnectProviderResponseMap[T] }> => {\n if (isAuthConnectProvider(options.provider)) {\n const mapped = mapLoginOptions(options as AuthConnectLoginOptions);\n const response = await client.login(mapped as LoginOptions);\n return {\n provider: options.provider,\n result: response.result as AuthConnectProviderResponseMap[T],\n };\n }\n\n return client.login(options as LoginOptions) as Promise<{ provider: T; result: AuthConnectProviderResponseMap[T] }>;\n },\n logout: async (options: AuthConnectProviderOptions): Promise<void> => client.logout(mapProviderOptions(options)),\n isLoggedIn: async (options: AuthConnectProviderOptions): Promise<{ isLoggedIn: boolean }> =>\n client.isLoggedIn(mapProviderOptions(options)),\n getAuthorizationCode: async (options: AuthConnectProviderOptions): Promise<AuthorizationCode> =>\n client.getAuthorizationCode(mapProviderOptions(options)),\n refresh: async (options: AuthConnectLoginOptions): Promise<void> => client.refresh(mapRefreshOptions(options)),\n providerSpecificCall: async <T extends ProviderSpecificCall>(options: {\n call: T;\n options: ProviderSpecificCallOptionsMap[T];\n }): Promise<ProviderSpecificCallResponseMap[T]> => client.providerSpecificCall(options),\n getPluginVersion: async (): Promise<{ version: string }> => client.getPluginVersion(),\n});\n\nconst SocialLoginAuthConnect = createAuthConnectClient(SocialLoginBase);\n\nexport type {\n AuthConnectInitializeOptions,\n AuthConnectLoginOptions,\n AuthConnectProviderId,\n AuthConnectProviderOptions,\n AuthConnectPresets,\n};\n\nexport { createAuthConnectClient, SocialLoginAuthConnect };\n"]}
1
+ {"version":3,"file":"auth-connect.js","sourceRoot":"","sources":["../../src/auth-connect.ts"],"names":[],"mappings":";AAaA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AA0E7C,MAAM,sBAAsB,GAAqC,CAAC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC;AAEnH,MAAM,cAAc,GAA0C;IAC5D,KAAK,EAAE,qCAAqC;IAC5C,KAAK,EAAE,sBAAsB;IAC7B,OAAO,EAAE,sBAAsB;IAC/B,IAAI,EAAE,qCAAqC;IAC3C,QAAQ,EAAE,sBAAsB;CACjC,CAAC;AAEF,MAAM,qBAAqB,GAAmD;IAC5E,KAAK,EAAE,qCAAqC;CAC7C,CAAC;AAEF,MAAM,sBAAsB,GAAG,mCAAmC,CAAC;AAEnE,MAAM,cAAc,GAAG,CAAC,KAAa,EAAU,EAAE;IAC/C,IAAI,KAAK,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,KAAK,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QAChE,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,WAAW,KAAK,EAAE,CAAC;AAC5B,CAAC,CAAC;AAEF,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ChH,UAAU,EAAE,KAAK,EAAE,OAAmC,EAAoC,EAAE,CAC1F,MAAM,CAAC,UAAU,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC;IAChD,oBAAoB,EAAE,KAAK,EAAE,OAAmC,EAA8B,EAAE,CAC9F,MAAM,CAAC,oBAAoB,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC;IAC1D,OAAO,EAAE,KAAK,EAAE,OAAgC,EAAiB,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;IAC9G,oBAAoB,EAAE,KAAK,EAAkC,OAG5D,EAA+C,EAAE,CAAC,MAAM,CAAC,oBAAoB,CAAC,OAAO,CAAC;IACvF,gBAAgB,EAAE,KAAK,IAAkC,EAAE,CAAC,MAAM,CAAC,gBAAgB,EAAE;CACtF,CAAC,CAAC;AAEH,MAAM,sBAAsB,GAAG,uBAAuB,CAAC,WAAW,CAAC,CAAC;AAUpE,OAAO,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,CAAC","sourcesContent":["import type {\n AuthorizationCode,\n AuthorizationCodeOptions,\n InitializeOptions,\n LoginOptions,\n OAuth2LoginOptions,\n OAuth2ProviderConfig,\n ProviderSpecificCall,\n ProviderSpecificCallOptionsMap,\n ProviderSpecificCallResponseMap,\n ProviderResponseMap,\n SocialLoginPlugin,\n} from './definitions';\nimport { SocialLogin } from './social-login';\n\ntype AuthConnectProviderId = 'auth0' | 'azure' | 'cognito' | 'okta' | 'onelogin';\n\ntype AuthConnectLoginOptions =\n | LoginOptions\n | {\n provider: AuthConnectProviderId;\n options?: Omit<OAuth2LoginOptions, 'providerId'>;\n };\n\ntype AuthConnectProviderOptions =\n | AuthorizationCodeOptions\n | {\n provider: AuthConnectProviderId;\n };\n\ntype AuthConnectInitializeOptions = InitializeOptions & {\n authConnect?: AuthConnectPresets;\n};\n\ntype AuthConnectPresetBase = {\n clientId: string;\n redirectUrl: string;\n scope?: string;\n responseType?: 'code' | 'token';\n pkceEnabled?: boolean;\n additionalParameters?: Record<string, string>;\n additionalResourceHeaders?: Record<string, string>;\n resourceUrl?: string;\n authorizationBaseUrl?: string;\n accessTokenEndpoint?: string;\n logoutUrl?: string;\n logsEnabled?: boolean;\n};\n\ntype Auth0Preset = AuthConnectPresetBase & {\n domain: string;\n audience?: string;\n};\n\ntype AzurePreset = AuthConnectPresetBase & {\n tenantId?: string;\n authorityHost?: string;\n};\n\ntype CognitoPreset = AuthConnectPresetBase & {\n domain: string;\n};\n\ntype OktaPreset = AuthConnectPresetBase & {\n issuer: string;\n};\n\ntype OneLoginPreset = AuthConnectPresetBase & {\n issuer: string;\n};\n\ntype AuthConnectPresets = {\n auth0?: Auth0Preset;\n azure?: AzurePreset;\n cognito?: CognitoPreset;\n okta?: OktaPreset;\n onelogin?: OneLoginPreset;\n};\n\ntype AuthConnectProviderResponseMap = ProviderResponseMap & {\n auth0: ProviderResponseMap['oauth2'];\n azure: ProviderResponseMap['oauth2'];\n cognito: ProviderResponseMap['oauth2'];\n okta: ProviderResponseMap['oauth2'];\n onelogin: ProviderResponseMap['oauth2'];\n};\n\nconst AUTH_CONNECT_PROVIDERS: readonly AuthConnectProviderId[] = ['auth0', 'azure', 'cognito', 'okta', 'onelogin'];\n\nconst DEFAULT_SCOPES: Record<AuthConnectProviderId, string> = {\n auth0: 'openid profile email offline_access',\n azure: 'openid profile email',\n cognito: 'openid profile email',\n okta: 'openid profile email offline_access',\n onelogin: 'openid profile email',\n};\n\nconst DEFAULT_RESOURCE_URLS: Partial<Record<AuthConnectProviderId, string>> = {\n azure: 'https://graph.microsoft.com/v1.0/me',\n};\n\nconst DEFAULT_AUTHORITY_HOST = 'https://login.microsoftonline.com';\n\nconst ensureProtocol = (value: string): string => {\n if (value.startsWith('http://') || value.startsWith('https://')) {\n return value;\n }\n return `https://${value}`;\n};\n\nconst trimTrailingSlash = (value: string): string => value.replace(/\\/+$/, '');\n\nconst joinUrl = (base: string, path: string): string => {\n const sanitizedBase = trimTrailingSlash(base);\n const sanitizedPath = path.replace(/^\\/+/, '');\n return `${sanitizedBase}/${sanitizedPath}`;\n};\n\nconst mergeRecords = (\n base?: Record<string, string>,\n overrides?: Record<string, string>,\n): Record<string, string> | undefined => {\n if (!base && !overrides) {\n return undefined;\n }\n return { ...(base ?? {}), ...(overrides ?? {}) };\n};\n\nconst validatePreset = (providerId: AuthConnectProviderId, preset: AuthConnectPresetBase): void => {\n if (!preset.clientId) {\n throw new Error(`[authConnect] ${providerId} requires clientId.`);\n }\n if (!preset.redirectUrl) {\n throw new Error(`[authConnect] ${providerId} requires redirectUrl.`);\n }\n};\n\nconst buildAuth0Config = (preset: Auth0Preset): OAuth2ProviderConfig => {\n validatePreset('auth0', preset);\n if (!preset.domain) {\n throw new Error('[authConnect] auth0 requires domain.');\n }\n const base = trimTrailingSlash(ensureProtocol(preset.domain));\n return buildConfigFromPreset('auth0', preset, {\n authorizationBaseUrl: joinUrl(base, 'authorize'),\n accessTokenEndpoint: joinUrl(base, 'oauth/token'),\n resourceUrl: joinUrl(base, 'userinfo'),\n logoutUrl: joinUrl(base, 'v2/logout'),\n additionalParameters: preset.audience ? { audience: preset.audience } : undefined,\n });\n};\n\nconst buildAzureConfig = (preset: AzurePreset): OAuth2ProviderConfig => {\n validatePreset('azure', preset);\n const tenantId = preset.tenantId ?? 'common';\n const authorityHost = trimTrailingSlash(ensureProtocol(preset.authorityHost ?? DEFAULT_AUTHORITY_HOST));\n const base = joinUrl(authorityHost, `${tenantId}/oauth2/v2.0`);\n return buildConfigFromPreset('azure', preset, {\n authorizationBaseUrl: joinUrl(base, 'authorize'),\n accessTokenEndpoint: joinUrl(base, 'token'),\n resourceUrl: DEFAULT_RESOURCE_URLS.azure,\n });\n};\n\nconst buildCognitoConfig = (preset: CognitoPreset): OAuth2ProviderConfig => {\n validatePreset('cognito', preset);\n if (!preset.domain) {\n throw new Error('[authConnect] cognito requires domain.');\n }\n const base = trimTrailingSlash(ensureProtocol(preset.domain));\n return buildConfigFromPreset('cognito', preset, {\n authorizationBaseUrl: joinUrl(base, 'oauth2/authorize'),\n accessTokenEndpoint: joinUrl(base, 'oauth2/token'),\n resourceUrl: joinUrl(base, 'oauth2/userInfo'),\n logoutUrl: joinUrl(base, 'logout'),\n });\n};\n\nconst buildOktaConfig = (preset: OktaPreset): OAuth2ProviderConfig => {\n validatePreset('okta', preset);\n if (!preset.issuer) {\n throw new Error('[authConnect] okta requires issuer.');\n }\n const base = trimTrailingSlash(ensureProtocol(preset.issuer));\n return buildConfigFromPreset('okta', preset, {\n authorizationBaseUrl: joinUrl(base, 'v1/authorize'),\n accessTokenEndpoint: joinUrl(base, 'v1/token'),\n resourceUrl: joinUrl(base, 'v1/userinfo'),\n logoutUrl: joinUrl(base, 'v1/logout'),\n });\n};\n\nconst buildOneLoginConfig = (preset: OneLoginPreset): OAuth2ProviderConfig => {\n validatePreset('onelogin', preset);\n if (!preset.issuer) {\n throw new Error('[authConnect] onelogin requires issuer.');\n }\n const base = trimTrailingSlash(ensureProtocol(preset.issuer));\n return buildConfigFromPreset('onelogin', preset, {\n authorizationBaseUrl: joinUrl(base, 'auth'),\n accessTokenEndpoint: joinUrl(base, 'token'),\n resourceUrl: joinUrl(base, 'me'),\n logoutUrl: joinUrl(base, 'logout'),\n });\n};\n\nconst buildConfigFromPreset = (\n providerId: AuthConnectProviderId,\n preset: AuthConnectPresetBase,\n defaults: Partial<OAuth2ProviderConfig>,\n): OAuth2ProviderConfig => {\n const additionalParameters = mergeRecords(defaults.additionalParameters, preset.additionalParameters);\n const additionalResourceHeaders = mergeRecords(defaults.additionalResourceHeaders, preset.additionalResourceHeaders);\n\n const config: OAuth2ProviderConfig = {\n appId: preset.clientId,\n authorizationBaseUrl: preset.authorizationBaseUrl ?? defaults.authorizationBaseUrl ?? '',\n accessTokenEndpoint: preset.accessTokenEndpoint ?? defaults.accessTokenEndpoint,\n redirectUrl: preset.redirectUrl,\n resourceUrl: preset.resourceUrl ?? defaults.resourceUrl,\n responseType: preset.responseType ?? defaults.responseType ?? 'code',\n pkceEnabled: preset.pkceEnabled ?? defaults.pkceEnabled ?? true,\n scope: preset.scope ?? defaults.scope ?? DEFAULT_SCOPES[providerId],\n additionalParameters,\n additionalResourceHeaders,\n logoutUrl: preset.logoutUrl ?? defaults.logoutUrl,\n logsEnabled: preset.logsEnabled ?? defaults.logsEnabled,\n };\n\n if (!config.authorizationBaseUrl) {\n throw new Error(`[authConnect] ${providerId} authorizationBaseUrl is required.`);\n }\n\n return config;\n};\n\nconst buildAuthConnectProviders = (presets?: AuthConnectPresets): Record<string, OAuth2ProviderConfig> => {\n if (!presets) {\n return {};\n }\n const providers: Record<string, OAuth2ProviderConfig> = {};\n\n if (presets.auth0) {\n providers.auth0 = buildAuth0Config(presets.auth0);\n }\n if (presets.azure) {\n providers.azure = buildAzureConfig(presets.azure);\n }\n if (presets.cognito) {\n providers.cognito = buildCognitoConfig(presets.cognito);\n }\n if (presets.okta) {\n providers.okta = buildOktaConfig(presets.okta);\n }\n if (presets.onelogin) {\n providers.onelogin = buildOneLoginConfig(presets.onelogin);\n }\n\n return providers;\n};\n\nconst isAuthConnectProvider = (provider: string): provider is AuthConnectProviderId =>\n AUTH_CONNECT_PROVIDERS.includes(provider as AuthConnectProviderId);\n\nconst isAuthConnectProviderOptions = (\n options: AuthConnectProviderOptions,\n): options is Extract<AuthConnectProviderOptions, { provider: AuthConnectProviderId }> =>\n isAuthConnectProvider(options.provider);\n\nconst isAuthConnectLoginOptions = (\n options: AuthConnectLoginOptions,\n): options is Extract<AuthConnectLoginOptions, { provider: AuthConnectProviderId }> =>\n isAuthConnectProvider(options.provider);\n\nconst mapLoginOptions = (options: AuthConnectLoginOptions): LoginOptions => {\n if (isAuthConnectLoginOptions(options)) {\n return {\n provider: 'oauth2',\n options: {\n providerId: options.provider,\n ...(options.options ?? {}),\n },\n };\n }\n\n return options;\n};\n\nconst mapProviderOptions = (options: AuthConnectProviderOptions): AuthorizationCodeOptions => {\n if (isAuthConnectProviderOptions(options)) {\n return {\n provider: 'oauth2',\n providerId: options.provider,\n };\n }\n\n return options;\n};\n\nconst mapRefreshOptions = (options: AuthConnectLoginOptions): LoginOptions => mapLoginOptions(options);\n\nconst mergeOAuth2Configs = (\n presets: Record<string, OAuth2ProviderConfig>,\n oauth2?: Record<string, OAuth2ProviderConfig>,\n): Record<string, OAuth2ProviderConfig> | undefined => {\n if (!Object.keys(presets).length && !oauth2) {\n return oauth2;\n }\n return {\n ...presets,\n ...(oauth2 ?? {}),\n };\n};\n\ntype AuthConnectClient = {\n initialize: (options: AuthConnectInitializeOptions) => Promise<void>;\n login: <T extends AuthConnectLoginOptions['provider']>(\n options: Extract<AuthConnectLoginOptions, { provider: T }>,\n ) => Promise<{ provider: T; result: AuthConnectProviderResponseMap[T] }>;\n logout: (options: AuthConnectProviderOptions) => Promise<void>;\n isLoggedIn: (options: AuthConnectProviderOptions) => Promise<{ isLoggedIn: boolean }>;\n getAuthorizationCode: (options: AuthConnectProviderOptions) => Promise<AuthorizationCode>;\n refresh: (options: AuthConnectLoginOptions) => Promise<void>;\n providerSpecificCall: <T extends ProviderSpecificCall>(options: {\n call: T;\n options: ProviderSpecificCallOptionsMap[T];\n }) => Promise<ProviderSpecificCallResponseMap[T]>;\n getPluginVersion: () => Promise<{ version: string }>;\n};\n\nconst createAuthConnectClient = (client: SocialLoginPlugin): AuthConnectClient => ({\n initialize: async (options: AuthConnectInitializeOptions): Promise<void> => {\n const { authConnect, oauth2, ...rest } = options;\n const presetProviders = buildAuthConnectProviders(authConnect);\n const mergedOauth2 = mergeOAuth2Configs(presetProviders, oauth2);\n const payload: InitializeOptions = {\n ...rest,\n ...(mergedOauth2 ? { oauth2: mergedOauth2 } : {}),\n };\n return client.initialize(payload);\n },\n login: async <T extends AuthConnectLoginOptions['provider']>(\n options: Extract<AuthConnectLoginOptions, { provider: T }>,\n ): Promise<{ provider: T; result: AuthConnectProviderResponseMap[T] }> => {\n if (isAuthConnectProvider(options.provider)) {\n const mapped = mapLoginOptions(options as AuthConnectLoginOptions);\n const response = await client.login(mapped as LoginOptions);\n return {\n provider: options.provider,\n result: response.result as AuthConnectProviderResponseMap[T],\n };\n }\n\n return client.login(options as LoginOptions) as Promise<{ provider: T; result: AuthConnectProviderResponseMap[T] }>;\n },\n logout: async (options: AuthConnectProviderOptions): Promise<void> => client.logout(mapProviderOptions(options)),\n isLoggedIn: async (options: AuthConnectProviderOptions): Promise<{ isLoggedIn: boolean }> =>\n client.isLoggedIn(mapProviderOptions(options)),\n getAuthorizationCode: async (options: AuthConnectProviderOptions): Promise<AuthorizationCode> =>\n client.getAuthorizationCode(mapProviderOptions(options)),\n refresh: async (options: AuthConnectLoginOptions): Promise<void> => client.refresh(mapRefreshOptions(options)),\n providerSpecificCall: async <T extends ProviderSpecificCall>(options: {\n call: T;\n options: ProviderSpecificCallOptionsMap[T];\n }): Promise<ProviderSpecificCallResponseMap[T]> => client.providerSpecificCall(options),\n getPluginVersion: async (): Promise<{ version: string }> => client.getPluginVersion(),\n});\n\nconst SocialLoginAuthConnect = createAuthConnectClient(SocialLogin);\n\nexport type {\n AuthConnectInitializeOptions,\n AuthConnectLoginOptions,\n AuthConnectProviderId,\n AuthConnectProviderOptions,\n AuthConnectPresets,\n};\n\nexport { createAuthConnectClient, SocialLoginAuthConnect };\n"]}
@@ -164,6 +164,49 @@ export interface OAuth2ProviderConfig {
164
164
  */
165
165
  logsEnabled?: boolean;
166
166
  }
167
+ /**
168
+ * LinkedIn provider configuration (convenience wrapper around the generic OAuth2 provider).
169
+ *
170
+ * Uses the OAuth2 engine with LinkedIn defaults:
171
+ * - Authorization URL: https://www.linkedin.com/oauth/v2/authorization
172
+ * - Token URL: https://www.linkedin.com/oauth/v2/accessToken
173
+ * - Resource URL: https://api.linkedin.com/v2/userinfo
174
+ * - Default scopes: `openid profile email`
175
+ */
176
+ export interface LinkedInProviderConfig extends OAuth2ProviderConfig {
177
+ /**
178
+ * LinkedIn Client ID from the LinkedIn Developer Portal.
179
+ */
180
+ clientId: string;
181
+ /**
182
+ * Redirect URL that receives the OAuth callback.
183
+ * Must match a redirect URL configured in the LinkedIn Developer Portal.
184
+ * @example 'https://your-app.example/auth/linkedin'
185
+ */
186
+ redirectUrl: string;
187
+ /**
188
+ * LinkedIn Client Secret.
189
+ *
190
+ * Prefer exchanging the authorization code on a backend when possible.
191
+ * Needed for confidential clients that do not use PKCE-only token exchange.
192
+ */
193
+ clientSecret?: string;
194
+ }
195
+ /**
196
+ * Options for `refreshToken()`.
197
+ * `providerId` is required for generic `oauth2` and ignored for LinkedIn.
198
+ */
199
+ export type RefreshTokenOptions = {
200
+ provider: 'oauth2';
201
+ providerId: string;
202
+ refreshToken?: string;
203
+ additionalParameters?: Record<string, string>;
204
+ } | {
205
+ provider: 'linkedin';
206
+ providerId?: string;
207
+ refreshToken?: string;
208
+ additionalParameters?: Record<string, string>;
209
+ };
167
210
  export interface InitializeOptions {
168
211
  /**
169
212
  * OAuth2 provider configurations.
@@ -208,6 +251,11 @@ export interface InitializeOptions {
208
251
  */
209
252
  languageCode?: string;
210
253
  };
254
+ /**
255
+ * LinkedIn configuration.
256
+ * Convenience wrapper that maps to the OAuth2 provider using LinkedIn defaults.
257
+ */
258
+ linkedin?: LinkedInProviderConfig;
211
259
  twitter?: {
212
260
  /**
213
261
  * The OAuth 2.0 client identifier issued by X (Twitter) Developer Portal
@@ -533,6 +581,11 @@ export interface OAuth2LoginOptions {
533
581
  */
534
582
  flow?: 'popup' | 'redirect';
535
583
  }
584
+ /**
585
+ * LinkedIn login options (maps to the OAuth2 provider internally).
586
+ * `providerId` is set to `linkedin` automatically.
587
+ */
588
+ export type LinkedInLoginOptions = Omit<OAuth2LoginOptions, 'providerId'>;
536
589
  export interface OAuth2LoginResponse {
537
590
  /**
538
591
  * The provider ID that was used for this login
@@ -568,6 +621,10 @@ export interface OAuth2LoginResponse {
568
621
  */
569
622
  expiresIn: number | null;
570
623
  }
624
+ /**
625
+ * LinkedIn login response (returned when using the LinkedIn convenience API).
626
+ */
627
+ export type LinkedInLoginResponse = OAuth2LoginResponse;
571
628
  export interface GoogleLoginOptions {
572
629
  /**
573
630
  * Specifies the scopes required for accessing Google APIs
@@ -767,6 +824,9 @@ export type LoginOptions = {
767
824
  } | {
768
825
  provider: 'telegram';
769
826
  options: TelegramLoginOptions;
827
+ } | {
828
+ provider: 'linkedin';
829
+ options: LinkedInLoginOptions;
770
830
  } | {
771
831
  provider: 'oauth2';
772
832
  options: OAuth2LoginOptions;
@@ -786,6 +846,9 @@ export type LoginResult = {
786
846
  } | {
787
847
  provider: 'telegram';
788
848
  result: TelegramLoginResponse;
849
+ } | {
850
+ provider: 'linkedin';
851
+ result: LinkedInLoginResponse;
789
852
  } | {
790
853
  provider: 'oauth2';
791
854
  result: OAuth2LoginResponse;
@@ -914,7 +977,7 @@ export interface AuthorizationCodeOptions {
914
977
  * Provider
915
978
  * @description Provider for the authorization code
916
979
  */
917
- provider: 'apple' | 'google' | 'facebook' | 'twitter' | 'oauth2';
980
+ provider: 'apple' | 'google' | 'facebook' | 'twitter' | 'linkedin' | 'oauth2';
918
981
  /**
919
982
  * Provider ID for OAuth2 providers (required when provider is 'oauth2')
920
983
  * @description The ID used when configuring the OAuth2 provider in initialize()
@@ -926,7 +989,7 @@ export interface isLoggedInOptions {
926
989
  * Provider
927
990
  * @description Provider for the isLoggedIn
928
991
  */
929
- provider: 'apple' | 'google' | 'facebook' | 'twitter' | 'telegram' | 'oauth2';
992
+ provider: 'apple' | 'google' | 'facebook' | 'twitter' | 'telegram' | 'linkedin' | 'oauth2';
930
993
  /**
931
994
  * Provider ID for OAuth2 providers (required when provider is 'oauth2')
932
995
  * @description The ID used when configuring the OAuth2 provider in initialize()
@@ -1071,6 +1134,7 @@ export type ProviderResponseMap = {
1071
1134
  apple: AppleProviderResponse;
1072
1135
  twitter: TwitterLoginResponse;
1073
1136
  telegram: TelegramLoginResponse;
1137
+ linkedin: LinkedInLoginResponse;
1074
1138
  oauth2: OAuth2LoginResponse;
1075
1139
  };
1076
1140
  /**
@@ -1121,7 +1185,7 @@ export interface SocialLoginPlugin {
1121
1185
  * @throws Error if Google provider is in offline mode
1122
1186
  */
1123
1187
  logout(options: {
1124
- provider: 'apple' | 'google' | 'facebook' | 'twitter' | 'telegram' | 'oauth2';
1188
+ provider: 'apple' | 'google' | 'facebook' | 'twitter' | 'telegram' | 'linkedin' | 'oauth2';
1125
1189
  providerId?: string;
1126
1190
  }): Promise<void>;
1127
1191
  /**
@@ -1173,7 +1237,7 @@ export interface SocialLoginPlugin {
1173
1237
  * OAuth2 refresh-token helper (feature parity with Capawesome OAuth).
1174
1238
  *
1175
1239
  * Scope:
1176
- * - Only applies to the built-in `oauth2` provider (not Google/Apple/Facebook/Twitter).
1240
+ * - Applies to the built-in `oauth2` provider and the LinkedIn convenience wrapper.
1177
1241
  * - Requires a token endpoint (either `accessTokenEndpoint`/`tokenEndpoint` or `issuerUrl` discovery).
1178
1242
  *
1179
1243
  * Security note:
@@ -1181,18 +1245,15 @@ export interface SocialLoginPlugin {
1181
1245
  *
1182
1246
  * If `refreshToken` is omitted, the plugin will attempt to use the stored refresh token (if available).
1183
1247
  */
1184
- refreshToken(options: {
1185
- provider: 'oauth2';
1186
- providerId: string;
1187
- refreshToken?: string;
1188
- additionalParameters?: Record<string, string>;
1189
- }): Promise<OAuth2LoginResponse>;
1248
+ refreshToken(options: RefreshTokenOptions): Promise<OAuth2LoginResponse>;
1190
1249
  /**
1191
1250
  * Web-only: handle the OAuth redirect callback and return the parsed result.
1192
1251
  *
1193
1252
  * Notes:
1194
1253
  * - This is only meaningful on Web. iOS/Android implementations will reject.
1195
1254
  * - Intended for redirect-based flows (e.g. `oauth2` with `flow: 'redirect'`) where the page navigates away.
1255
+ * - LinkedIn convenience logins (`provider: 'linkedin'`, `flow: 'redirect'`) return `provider: 'linkedin'`.
1256
+ * The same app used as `oauth2` with `providerId: 'linkedin'` keeps `provider: 'oauth2'`.
1196
1257
  */
1197
1258
  handleRedirectCallback(): Promise<LoginResult | null>;
1198
1259
  /**
@@ -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 * This value is sent as `client_secret` in token/refresh requests when provided.\n */\n clientSecret?: 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\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 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\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\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: '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: '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' | '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' | '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 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 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' | '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 * - Only applies to the built-in `oauth2` provider (not Google/Apple/Facebook/Twitter).\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: {\n provider: 'oauth2';\n providerId: string;\n refreshToken?: string;\n additionalParameters?: Record<string, string>;\n }): 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 */\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"]}
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 * This value is sent as `client_secret` in token/refresh requests when provided.\n */\n clientSecret?: 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 * Options for `refreshToken()`.\n * `providerId` is required for generic `oauth2` and ignored for LinkedIn.\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\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 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 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\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: '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: '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' | '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' | '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 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 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' | '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 convenience wrapper.\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"]}
@@ -0,0 +1,17 @@
1
+ import type { LinkedInLoginOptions, LinkedInLoginResponse, LinkedInProviderConfig, LoginResult, OAuth2LoginOptions, OAuth2LoginResponse, OAuth2ProviderConfig } from './definitions';
2
+ export declare const LINKEDIN_PROVIDER_ID = "linkedin";
3
+ export declare const buildLinkedInOAuthConfig: (config: LinkedInProviderConfig) => OAuth2ProviderConfig;
4
+ export declare const buildLinkedInLoginOptions: (options?: LinkedInLoginOptions) => OAuth2LoginOptions;
5
+ export declare const isLinkedInOAuthResult: (result: LoginResult) => result is {
6
+ provider: "oauth2";
7
+ result: OAuth2LoginResponse;
8
+ };
9
+ export declare const asLinkedInLoginResult: (result: {
10
+ provider: "oauth2";
11
+ result: OAuth2LoginResponse;
12
+ }) => {
13
+ provider: "linkedin";
14
+ result: LinkedInLoginResponse;
15
+ };
16
+ export declare const markLinkedInRedirectPending: (state: string) => void;
17
+ export declare const consumeLinkedInRedirectPending: (state?: string | null) => boolean;
@@ -0,0 +1,54 @@
1
+ export const LINKEDIN_PROVIDER_ID = 'linkedin';
2
+ const LINKEDIN_REDIRECT_PENDING_KEY = 'capgo_social_login_linkedin_redirect';
3
+ const LINKEDIN_AUTH_URL = 'https://www.linkedin.com/oauth/v2/authorization';
4
+ const LINKEDIN_TOKEN_URL = 'https://www.linkedin.com/oauth/v2/accessToken';
5
+ const LINKEDIN_RESOURCE_URL = 'https://api.linkedin.com/v2/userinfo';
6
+ const LINKEDIN_DEFAULT_SCOPE = 'openid profile email';
7
+ const normalizeScope = (scope) => {
8
+ if (!scope)
9
+ return LINKEDIN_DEFAULT_SCOPE;
10
+ if (Array.isArray(scope)) {
11
+ return scope.filter(Boolean).join(' ');
12
+ }
13
+ return scope;
14
+ };
15
+ export const buildLinkedInOAuthConfig = (config) => {
16
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
17
+ const scope = normalizeScope((_a = config.scope) !== null && _a !== void 0 ? _a : config.scopes);
18
+ return Object.assign(Object.assign({}, config), { appId: (_b = config.appId) !== null && _b !== void 0 ? _b : config.clientId, clientSecret: config.clientSecret, authorizationBaseUrl: (_d = (_c = config.authorizationBaseUrl) !== null && _c !== void 0 ? _c : config.authorizationEndpoint) !== null && _d !== void 0 ? _d : LINKEDIN_AUTH_URL, accessTokenEndpoint: (_f = (_e = config.accessTokenEndpoint) !== null && _e !== void 0 ? _e : config.tokenEndpoint) !== null && _f !== void 0 ? _f : LINKEDIN_TOKEN_URL, resourceUrl: (_g = config.resourceUrl) !== null && _g !== void 0 ? _g : LINKEDIN_RESOURCE_URL, responseType: (_h = config.responseType) !== null && _h !== void 0 ? _h : 'code', pkceEnabled: (_j = config.pkceEnabled) !== null && _j !== void 0 ? _j : true, scope });
19
+ };
20
+ const createOAuthState = () => [...crypto.getRandomValues(new Uint8Array(16))].map((b) => b.toString(16).padStart(2, '0')).join('');
21
+ export const buildLinkedInLoginOptions = (options = {}) => {
22
+ var _a;
23
+ const scope = (_a = options.scope) !== null && _a !== void 0 ? _a : options.scopes;
24
+ const loginOptions = Object.assign(Object.assign(Object.assign({}, options), { providerId: LINKEDIN_PROVIDER_ID }), (scope === undefined ? {} : { scope }));
25
+ // Bind convenience-redirect remapping to this OAuth state, not a generic sentinel.
26
+ if (loginOptions.flow === 'redirect' && !loginOptions.state) {
27
+ loginOptions.state = createOAuthState();
28
+ }
29
+ return loginOptions;
30
+ };
31
+ export const isLinkedInOAuthResult = (result) => result.provider === 'oauth2' && result.result.providerId === LINKEDIN_PROVIDER_ID;
32
+ export const asLinkedInLoginResult = (result) => ({
33
+ provider: 'linkedin',
34
+ result: result.result,
35
+ });
36
+ export const markLinkedInRedirectPending = (state) => {
37
+ try {
38
+ sessionStorage.setItem(LINKEDIN_REDIRECT_PENDING_KEY, state);
39
+ }
40
+ catch (_a) {
41
+ // sessionStorage may be unavailable
42
+ }
43
+ };
44
+ export const consumeLinkedInRedirectPending = (state) => {
45
+ try {
46
+ const pending = sessionStorage.getItem(LINKEDIN_REDIRECT_PENDING_KEY);
47
+ sessionStorage.removeItem(LINKEDIN_REDIRECT_PENDING_KEY);
48
+ return Boolean(pending && state && pending === state);
49
+ }
50
+ catch (_a) {
51
+ return false;
52
+ }
53
+ };
54
+ //# sourceMappingURL=linkedin-provider.js.map