@capgo/capacitor-social-login 8.3.18 → 8.3.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -0
- package/android/src/main/java/ee/forgr/capacitor/social/login/FacebookProvider.java +2 -1
- package/android/src/main/java/ee/forgr/capacitor/social/login/GoogleProvider.java +6 -0
- package/android/src/main/java/ee/forgr/capacitor/social/login/OAuth2LoginActivity.java +5 -3
- package/android/src/main/java/ee/forgr/capacitor/social/login/OAuth2Provider.java +25 -2
- package/android/src/main/java/ee/forgr/capacitor/social/login/SocialLoginPlugin.java +1 -1
- package/android/src/main/java/ee/forgr/capacitor/social/login/TwitterLoginActivity.java +5 -3
- package/android/src/main/java/ee/forgr/capacitor/social/login/TwitterProvider.java +25 -2
- package/dist/docs.json +1 -1
- package/dist/esm/apple-provider.js +4 -1
- package/dist/esm/apple-provider.js.map +1 -1
- package/dist/esm/definitions.d.ts +17 -0
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/errors.d.ts +8 -0
- package/dist/esm/errors.js +30 -0
- package/dist/esm/errors.js.map +1 -0
- package/dist/esm/facebook-provider.d.ts +2 -1
- package/dist/esm/facebook-provider.js +91 -26
- package/dist/esm/facebook-provider.js.map +1 -1
- package/dist/esm/google-provider.d.ts +1 -1
- package/dist/esm/google-provider.js +4 -3
- package/dist/esm/google-provider.js.map +1 -1
- package/dist/esm/oauth2-provider.d.ts +5 -0
- package/dist/esm/oauth2-provider.js +42 -3
- package/dist/esm/oauth2-provider.js.map +1 -1
- package/dist/esm/twitter-provider.js +5 -4
- package/dist/esm/twitter-provider.js.map +1 -1
- package/dist/esm/web.js +4 -6
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +174 -43
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +174 -43
- package/dist/plugin.js.map +1 -1
- package/ios/Sources/SocialLoginPlugin/SocialLoginPlugin.swift +46 -2
- package/package.json +1 -1
package/dist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gB,EAAE,eAAe,CAAC,CAAC,CAAC","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport { AppleSocialLogin } from './apple-provider';\nimport type {\n SocialLoginPlugin,\n InitializeOptions,\n LoginOptions,\n AuthorizationCode,\n AuthorizationCodeOptions,\n isLoggedInOptions,\n ProviderResponseMap,\n FacebookLoginOptions,\n ProviderSpecificCall,\n ProviderSpecificCallOptionsMap,\n ProviderSpecificCallResponseMap,\n LoginResult,\n OAuth2LoginOptions,\n OAuth2LoginResponse,\n OpenSecureWindowOptions,\n OpenSecureWindowResponse,\n} from './definitions';\nimport { FacebookSocialLogin } from './facebook-provider';\nimport { GoogleSocialLogin } from './google-provider';\nimport { OAuth2SocialLogin } from './oauth2-provider';\nimport { TwitterSocialLogin } from './twitter-provider';\n\nexport class SocialLoginWeb extends WebPlugin implements SocialLoginPlugin {\n private static readonly OAUTH_STATE_KEY = 'social_login_oauth_pending';\n private static readonly POPUP_WINDOW_NAMES = new Set(['OAuth2Login', 'XLogin', 'Google Sign In', 'Authorization']);\n\n private googleProvider: GoogleSocialLogin;\n private appleProvider: AppleSocialLogin;\n private facebookProvider: FacebookSocialLogin;\n private twitterProvider: TwitterSocialLogin;\n private oauth2Provider: OAuth2SocialLogin;\n\n constructor() {\n super();\n\n this.googleProvider = new GoogleSocialLogin();\n this.appleProvider = new AppleSocialLogin();\n this.facebookProvider = new FacebookSocialLogin();\n this.twitterProvider = new TwitterSocialLogin();\n this.oauth2Provider = new OAuth2SocialLogin();\n\n // Auto-finish OAuth redirects only when running inside a popup window.\n // For redirect-based flows (full page navigation), the app should call `handleRedirectCallback()` explicitly.\n const hasPending = !!localStorage.getItem(SocialLoginWeb.OAUTH_STATE_KEY);\n const isPopup = !!window.opener || SocialLoginWeb.POPUP_WINDOW_NAMES.has(window.name);\n if (hasPending && isPopup) {\n this.finishOAuthRedirectInPopup().catch((error) => {\n console.error('Failed to finish OAuth redirect', error);\n try {\n window.close();\n } catch {\n // ignore\n }\n });\n }\n }\n\n private async parseRedirectResult(): Promise<{\n provider: string | null;\n state?: string;\n nonce?: string;\n result: LoginResult | { error: string } | null;\n }> {\n const url = new URL(window.location.href);\n const stateRaw = localStorage.getItem(SocialLoginWeb.OAUTH_STATE_KEY);\n let provider: string | null = null;\n let state: string | undefined;\n let nonce: string | undefined;\n\n if (stateRaw) {\n try {\n const parsed = JSON.parse(stateRaw);\n provider = parsed.provider ?? null;\n state = parsed.state;\n nonce = parsed.nonce;\n } catch {\n provider = stateRaw === 'true' ? 'google' : null;\n }\n }\n\n let result: LoginResult | { error: string } | null = null;\n\n switch (provider) {\n case 'twitter':\n result = await this.twitterProvider.handleOAuthRedirect(url, state);\n break;\n case 'oauth2':\n result = await this.oauth2Provider.handleOAuthRedirect(url, state);\n break;\n case 'google':\n default:\n result = this.googleProvider.handleOAuthRedirect(url);\n break;\n }\n\n return { provider, state, nonce, result };\n }\n\n private async finishOAuthRedirectInPopup(): Promise<void> {\n const parsed = await this.parseRedirectResult();\n const result = parsed.result;\n if (!result) return;\n\n // Build the message to send\n let message: Record<string, unknown>;\n if ('error' in result) {\n const resolvedProvider = parsed.provider ?? null;\n message = {\n type: 'oauth-error',\n provider: resolvedProvider,\n error: result.error,\n };\n } else {\n message = {\n type: 'oauth-response',\n provider: result.provider,\n ...result.result,\n };\n }\n\n // Try postMessage first (works when window.opener is accessible)\n try {\n if (window.opener) {\n window.opener.postMessage(message, window.location.origin);\n }\n } catch {\n // Cross-origin error - window.opener may not be accessible\n console.log('postMessage to opener failed, using BroadcastChannel');\n }\n\n // Also use BroadcastChannel as a fallback (works across same-origin windows\n // even when window.opener is not accessible due to cross-origin navigation)\n try {\n // Determine the channel name based on provider and state/nonce\n let channelName: string | null = null;\n if (parsed.provider === 'oauth2' && parsed.state) {\n channelName = `oauth2_${parsed.state}`;\n } else if (parsed.provider === 'twitter' && parsed.state) {\n channelName = `twitter_oauth_${parsed.state}`;\n } else if (parsed.provider === 'google' && parsed.nonce) {\n channelName = `google_oauth_${parsed.nonce}`;\n }\n\n if (channelName) {\n const channel = new BroadcastChannel(channelName);\n channel.postMessage(message);\n channel.close();\n }\n } catch {\n // BroadcastChannel not supported or other error\n console.log('BroadcastChannel not available');\n }\n\n window.close();\n }\n\n async initialize(options: InitializeOptions): Promise<void> {\n const initPromises: Promise<void>[] = [];\n\n if (options.google?.webClientId) {\n initPromises.push(\n this.googleProvider.initialize(\n options.google.webClientId,\n options.google.mode,\n options.google.hostedDomain,\n options.google.redirectUrl,\n ),\n );\n }\n\n if (options.apple?.clientId) {\n initPromises.push(\n this.appleProvider.initialize(\n options.apple.clientId,\n options.apple.redirectUrl,\n options.apple.useProperTokenExchange,\n ),\n );\n }\n\n if (options.facebook?.appId) {\n initPromises.push(this.facebookProvider.initialize(options.facebook.appId, options.facebook.locale));\n }\n\n if (options.twitter?.clientId) {\n initPromises.push(\n this.twitterProvider.initialize(\n options.twitter.clientId,\n options.twitter.redirectUrl,\n options.twitter.defaultScopes,\n options.twitter.forceLogin,\n options.twitter.audience,\n ),\n );\n }\n\n if (options.oauth2 && Object.keys(options.oauth2).length > 0) {\n initPromises.push(this.oauth2Provider.initializeProviders(options.oauth2));\n }\n\n await Promise.all(initPromises);\n }\n\n async login<T extends LoginOptions['provider']>(\n options: Extract<LoginOptions, { provider: T }>,\n ): Promise<{ provider: T; result: ProviderResponseMap[T] }> {\n switch (options.provider) {\n case 'google':\n return this.googleProvider.login(options.options as any) as Promise<{\n provider: T;\n result: ProviderResponseMap[T];\n }>;\n case 'apple':\n return this.appleProvider.login(options.options as any) as Promise<{\n provider: T;\n result: ProviderResponseMap[T];\n }>;\n case 'facebook':\n return this.facebookProvider.login(options.options as FacebookLoginOptions) as Promise<{\n provider: T;\n result: ProviderResponseMap[T];\n }>;\n case 'twitter':\n return this.twitterProvider.login(options.options as any) as Promise<{\n provider: T;\n result: ProviderResponseMap[T];\n }>;\n case 'oauth2':\n return this.oauth2Provider.login(options.options as OAuth2LoginOptions) as Promise<{\n provider: T;\n result: ProviderResponseMap[T];\n }>;\n default:\n throw new Error(`Login for ${options.provider} is not implemented on web`);\n }\n }\n\n async logout(options: {\n provider: 'apple' | 'google' | 'facebook' | 'twitter' | 'oauth2';\n providerId?: string;\n }): Promise<void> {\n switch (options.provider) {\n case 'google':\n return this.googleProvider.logout();\n case 'apple':\n return this.appleProvider.logout();\n case 'facebook':\n return this.facebookProvider.logout();\n case 'twitter':\n return this.twitterProvider.logout();\n case 'oauth2':\n if (!options.providerId) {\n throw new Error('providerId is required for oauth2 logout');\n }\n return this.oauth2Provider.logout(options.providerId);\n default:\n throw new Error(`Logout for ${options.provider} is not implemented`);\n }\n }\n\n async isLoggedIn(options: isLoggedInOptions): Promise<{ isLoggedIn: boolean }> {\n switch (options.provider) {\n case 'google':\n return this.googleProvider.isLoggedIn();\n case 'apple':\n return this.appleProvider.isLoggedIn();\n case 'facebook':\n return this.facebookProvider.isLoggedIn();\n case 'twitter':\n return this.twitterProvider.isLoggedIn();\n case 'oauth2':\n if (!options.providerId) {\n throw new Error('providerId is required for oauth2 isLoggedIn');\n }\n return this.oauth2Provider.isLoggedIn(options.providerId);\n default:\n throw new Error(`isLoggedIn for ${options.provider} is not implemented`);\n }\n }\n\n async getAuthorizationCode(options: AuthorizationCodeOptions): Promise<AuthorizationCode> {\n switch (options.provider) {\n case 'google':\n return this.googleProvider.getAuthorizationCode();\n case 'apple':\n return this.appleProvider.getAuthorizationCode();\n case 'facebook':\n return this.facebookProvider.getAuthorizationCode();\n case 'twitter':\n return this.twitterProvider.getAuthorizationCode();\n case 'oauth2':\n if (!options.providerId) {\n throw new Error('providerId is required for oauth2 getAuthorizationCode');\n }\n return this.oauth2Provider.getAuthorizationCode(options.providerId);\n default:\n throw new Error(`getAuthorizationCode for ${options.provider} is not implemented`);\n }\n }\n\n async refresh(options: LoginOptions): Promise<void> {\n switch (options.provider) {\n case 'google':\n return this.googleProvider.refresh();\n case 'apple':\n return this.appleProvider.refresh();\n case 'facebook':\n return this.facebookProvider.refresh(options.options as FacebookLoginOptions);\n case 'twitter':\n return this.twitterProvider.refresh();\n case 'oauth2': {\n const oauth2Options = options.options as OAuth2LoginOptions;\n if (!oauth2Options?.providerId) {\n throw new Error('providerId is required for oauth2 refresh');\n }\n return this.oauth2Provider.refresh(oauth2Options.providerId);\n }\n default:\n throw new Error(`Refresh for ${(options as any).provider} is not implemented`);\n }\n }\n\n async providerSpecificCall<T extends ProviderSpecificCall>(options: {\n call: T;\n options: ProviderSpecificCallOptionsMap[T];\n }): Promise<ProviderSpecificCallResponseMap[T]> {\n throw new Error(`Provider specific call for ${options.call} is not implemented`);\n }\n\n async refreshToken(options: {\n provider: 'oauth2';\n providerId: string;\n refreshToken?: string;\n additionalParameters?: Record<string, string>;\n }): Promise<OAuth2LoginResponse> {\n if (options.provider !== 'oauth2') {\n throw new Error('refreshToken is only implemented for oauth2 on web');\n }\n return this.oauth2Provider.refreshToken(options.providerId, options.refreshToken, options.additionalParameters);\n }\n\n async handleRedirectCallback(): Promise<LoginResult | null> {\n const parsed = await this.parseRedirectResult();\n const result = parsed.result;\n if (!result) return null;\n if ('error' in result) {\n throw new Error(result.error);\n }\n return result;\n }\n\n async decodeIdToken(options: { idToken?: string; token?: string }): Promise<{ claims: Record<string, any> }> {\n const token = options?.idToken ?? options?.token;\n if (!token) {\n throw new Error('idToken (or token) is required');\n }\n const claims = this.oauth2Provider.decodeIdToken(token);\n return { claims };\n }\n\n async getAccessTokenExpirationDate(options: { accessTokenExpirationDate: number }): Promise<{ date: string }> {\n if (typeof options?.accessTokenExpirationDate !== 'number') {\n throw new Error('accessTokenExpirationDate is required');\n }\n return { date: new Date(options.accessTokenExpirationDate).toISOString() };\n }\n\n async isAccessTokenAvailable(options: { accessToken: string | null }): Promise<{ isAvailable: boolean }> {\n const token = options?.accessToken ?? null;\n return { isAvailable: typeof token === 'string' && token.length > 0 };\n }\n\n async isAccessTokenExpired(options: { accessTokenExpirationDate: number }): Promise<{ isExpired: boolean }> {\n if (typeof options?.accessTokenExpirationDate !== 'number') {\n throw new Error('accessTokenExpirationDate is required');\n }\n return { isExpired: options.accessTokenExpirationDate <= Date.now() };\n }\n\n async isRefreshTokenAvailable(options: { refreshToken: string | null }): Promise<{ isAvailable: boolean }> {\n const token = options?.refreshToken ?? null;\n return { isAvailable: typeof token === 'string' && token.length > 0 };\n }\n\n async getPluginVersion(): Promise<{ version: string }> {\n return { version: 'web' };\n }\n\n async openSecureWindow(options: OpenSecureWindowOptions): Promise<OpenSecureWindowResponse> {\n const w = 600;\n const h = 550;\n const settings = [\n ['width', w],\n ['height', h],\n ['left', screen.width / 2 - w / 2],\n ['top', screen.height / 2 - h / 2],\n ]\n .map((x) => x.join('='))\n .join(',');\n\n const popup = window.open(options.authEndpoint, 'Authorization', settings)!;\n if (typeof popup.focus === 'function') {\n popup.focus();\n }\n return new Promise((resolve, reject) => {\n const bc = new BroadcastChannel(options.broadcastChannelName || 'oauth-channel');\n bc.addEventListener('message', (event) => {\n if (event.data.startsWith(options.redirectUri)) {\n bc.close();\n resolve({ redirectedUri: event.data });\n } else {\n bc.close();\n reject(new Error('Redirect URI does not match, expected ' + options.redirectUri + ' but got ' + event.data));\n }\n });\n setTimeout(() => {\n bc.close();\n reject(new Error('The sign-in flow timed out'));\n }, 5 * 60000);\n });\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAmBpD,OAAO,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB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,EAAE,CAAC;QAChB,CAAC;QACD,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACrC,MAAM,EAAE,GAAG,IAAI,gBAAgB,CAAC,OAAO,CAAC,oBAAoB,IAAI,eAAe,CAAC,CAAC;YACjF,EAAE,CAAC,gBAAgB,CAAC,SAAS,EAAE,CAAC,KAAK,EAAE,EAAE;gBACvC,IAAI,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC;oBAC/C,EAAE,CAAC,KAAK,EAAE,CAAC;oBACX,OAAO,CAAC,EAAE,aAAa,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;gBACzC,CAAC;qBAAM,CAAC;oBACN,EAAE,CAAC,KAAK,EAAE,CAAC;oBACX,MAAM,CAAC,IAAI,KAAK,CAAC,wCAAwC,GAAG,OAAO,CAAC,WAAW,GAAG,WAAW,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;gBAC/G,CAAC;YACH,CAAC,CAAC,CAAC;YACH,UAAU,CAAC,GAAG,EAAE;gBACd,EAAE,CAAC,KAAK,EAAE,CAAC;gBACX,MAAM,CAAC,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC,CAAC;YAClD,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,CAAC;QAChB,CAAC,CAAC,CAAC;IACL,CAAC;;AA/YuB,8BAAe,GAAG,4BAA4B,CAAC;AAC/C,iCAAkB,GAAG,IAAI,GAAG,CAAC,CAAC,aAAa,EAAE,QAAQ,EAAE,gBAAgB,EAAE,eAAe,CAAC,CAAC,CAAC","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport { AppleSocialLogin } from './apple-provider';\nimport type {\n SocialLoginPlugin,\n InitializeOptions,\n LoginOptions,\n AuthorizationCode,\n AuthorizationCodeOptions,\n isLoggedInOptions,\n ProviderResponseMap,\n FacebookLoginOptions,\n ProviderSpecificCall,\n ProviderSpecificCallOptionsMap,\n ProviderSpecificCallResponseMap,\n LoginResult,\n OAuth2LoginOptions,\n OAuth2LoginResponse,\n OpenSecureWindowOptions,\n OpenSecureWindowResponse,\n} from './definitions';\nimport { inferUserCancelledError } from './errors';\nimport { FacebookSocialLogin } from './facebook-provider';\nimport { GoogleSocialLogin } from './google-provider';\nimport { OAuth2SocialLogin } from './oauth2-provider';\nimport { TwitterSocialLogin } from './twitter-provider';\n\nexport class SocialLoginWeb extends WebPlugin implements SocialLoginPlugin {\n private static readonly OAUTH_STATE_KEY = 'social_login_oauth_pending';\n private static readonly POPUP_WINDOW_NAMES = new Set(['OAuth2Login', 'XLogin', 'Google Sign In', 'Authorization']);\n\n private googleProvider: GoogleSocialLogin;\n private appleProvider: AppleSocialLogin;\n private facebookProvider: FacebookSocialLogin;\n private twitterProvider: TwitterSocialLogin;\n private oauth2Provider: OAuth2SocialLogin;\n\n constructor() {\n super();\n\n this.googleProvider = new GoogleSocialLogin();\n this.appleProvider = new AppleSocialLogin();\n this.facebookProvider = new FacebookSocialLogin();\n this.twitterProvider = new TwitterSocialLogin();\n this.oauth2Provider = new OAuth2SocialLogin();\n\n // Auto-finish OAuth redirects only when running inside a popup window.\n // For redirect-based flows (full page navigation), the app should call `handleRedirectCallback()` explicitly.\n const hasPending = !!localStorage.getItem(SocialLoginWeb.OAUTH_STATE_KEY);\n const isPopup = !!window.opener || SocialLoginWeb.POPUP_WINDOW_NAMES.has(window.name);\n if (hasPending && isPopup) {\n this.finishOAuthRedirectInPopup().catch((error) => {\n console.error('Failed to finish OAuth redirect', error);\n try {\n window.close();\n } catch {\n // ignore\n }\n });\n }\n }\n\n private async parseRedirectResult(): Promise<{\n provider: string | null;\n state?: string;\n nonce?: string;\n result: LoginResult | { error: string } | null;\n }> {\n const url = new URL(window.location.href);\n const stateRaw = localStorage.getItem(SocialLoginWeb.OAUTH_STATE_KEY);\n let provider: string | null = null;\n let state: string | undefined;\n let nonce: string | undefined;\n\n if (stateRaw) {\n try {\n const parsed = JSON.parse(stateRaw);\n provider = parsed.provider ?? null;\n state = parsed.state;\n nonce = parsed.nonce;\n } catch {\n provider = stateRaw === 'true' ? 'google' : null;\n }\n }\n\n let result: LoginResult | { error: string } | null = null;\n\n switch (provider) {\n case 'twitter':\n result = await this.twitterProvider.handleOAuthRedirect(url, state);\n break;\n case 'oauth2':\n result = await this.oauth2Provider.handleOAuthRedirect(url, state);\n break;\n case 'google':\n default:\n result = this.googleProvider.handleOAuthRedirect(url);\n break;\n }\n\n return { provider, state, nonce, result };\n }\n\n private async finishOAuthRedirectInPopup(): Promise<void> {\n const parsed = await this.parseRedirectResult();\n const result = parsed.result;\n if (!result) return;\n\n // Build the message to send\n let message: Record<string, unknown>;\n if ('error' in result) {\n const resolvedProvider = parsed.provider ?? null;\n const error = inferUserCancelledError(result.error);\n message = {\n type: 'oauth-error',\n provider: resolvedProvider,\n error: error.message,\n ...(error.code ? { code: error.code } : null),\n };\n } else {\n message = {\n type: 'oauth-response',\n provider: result.provider,\n ...result.result,\n };\n }\n\n // Try postMessage first (works when window.opener is accessible)\n try {\n if (window.opener) {\n window.opener.postMessage(message, window.location.origin);\n }\n } catch {\n // Cross-origin error - window.opener may not be accessible\n console.log('postMessage to opener failed, using BroadcastChannel');\n }\n\n // Also use BroadcastChannel as a fallback (works across same-origin windows\n // even when window.opener is not accessible due to cross-origin navigation)\n try {\n // Determine the channel name based on provider and state/nonce\n let channelName: string | null = null;\n if (parsed.provider === 'oauth2' && parsed.state) {\n channelName = `oauth2_${parsed.state}`;\n } else if (parsed.provider === 'twitter' && parsed.state) {\n channelName = `twitter_oauth_${parsed.state}`;\n } else if (parsed.provider === 'google' && parsed.nonce) {\n channelName = `google_oauth_${parsed.nonce}`;\n }\n\n if (channelName) {\n const channel = new BroadcastChannel(channelName);\n channel.postMessage(message);\n channel.close();\n }\n } catch {\n // BroadcastChannel not supported or other error\n console.log('BroadcastChannel not available');\n }\n\n window.close();\n }\n\n async initialize(options: InitializeOptions): Promise<void> {\n const initPromises: Promise<void>[] = [];\n\n if (options.google?.webClientId) {\n initPromises.push(\n this.googleProvider.initialize(\n options.google.webClientId,\n options.google.mode,\n options.google.hostedDomain,\n options.google.redirectUrl,\n ),\n );\n }\n\n if (options.apple?.clientId) {\n initPromises.push(\n this.appleProvider.initialize(\n options.apple.clientId,\n options.apple.redirectUrl,\n options.apple.useProperTokenExchange,\n ),\n );\n }\n\n if (options.facebook?.appId) {\n initPromises.push(this.facebookProvider.initialize(options.facebook.appId, options.facebook.locale));\n }\n\n if (options.twitter?.clientId) {\n initPromises.push(\n this.twitterProvider.initialize(\n options.twitter.clientId,\n options.twitter.redirectUrl,\n options.twitter.defaultScopes,\n options.twitter.forceLogin,\n options.twitter.audience,\n ),\n );\n }\n\n if (options.oauth2 && Object.keys(options.oauth2).length > 0) {\n initPromises.push(this.oauth2Provider.initializeProviders(options.oauth2));\n }\n\n await Promise.all(initPromises);\n }\n\n async login<T extends LoginOptions['provider']>(\n options: Extract<LoginOptions, { provider: T }>,\n ): Promise<{ provider: T; result: ProviderResponseMap[T] }> {\n switch (options.provider) {\n case 'google':\n return this.googleProvider.login(options.options as any) as Promise<{\n provider: T;\n result: ProviderResponseMap[T];\n }>;\n case 'apple':\n return this.appleProvider.login(options.options as any) as Promise<{\n provider: T;\n result: ProviderResponseMap[T];\n }>;\n case 'facebook':\n return this.facebookProvider.login(options.options as FacebookLoginOptions) as Promise<{\n provider: T;\n result: ProviderResponseMap[T];\n }>;\n case 'twitter':\n return this.twitterProvider.login(options.options as any) as Promise<{\n provider: T;\n result: ProviderResponseMap[T];\n }>;\n case 'oauth2':\n return this.oauth2Provider.login(options.options as OAuth2LoginOptions) as Promise<{\n provider: T;\n result: ProviderResponseMap[T];\n }>;\n default:\n throw new Error(`Login for ${options.provider} is not implemented on web`);\n }\n }\n\n async logout(options: {\n provider: 'apple' | 'google' | 'facebook' | 'twitter' | 'oauth2';\n providerId?: string;\n }): Promise<void> {\n switch (options.provider) {\n case 'google':\n return this.googleProvider.logout();\n case 'apple':\n return this.appleProvider.logout();\n case 'facebook':\n return this.facebookProvider.logout();\n case 'twitter':\n return this.twitterProvider.logout();\n case 'oauth2':\n if (!options.providerId) {\n throw new Error('providerId is required for oauth2 logout');\n }\n return this.oauth2Provider.logout(options.providerId);\n default:\n throw new Error(`Logout for ${options.provider} is not implemented`);\n }\n }\n\n async isLoggedIn(options: isLoggedInOptions): Promise<{ isLoggedIn: boolean }> {\n switch (options.provider) {\n case 'google':\n return this.googleProvider.isLoggedIn();\n case 'apple':\n return this.appleProvider.isLoggedIn();\n case 'facebook':\n return this.facebookProvider.isLoggedIn();\n case 'twitter':\n return this.twitterProvider.isLoggedIn();\n case 'oauth2':\n if (!options.providerId) {\n throw new Error('providerId is required for oauth2 isLoggedIn');\n }\n return this.oauth2Provider.isLoggedIn(options.providerId);\n default:\n throw new Error(`isLoggedIn for ${options.provider} is not implemented`);\n }\n }\n\n async getAuthorizationCode(options: AuthorizationCodeOptions): Promise<AuthorizationCode> {\n switch (options.provider) {\n case 'google':\n return this.googleProvider.getAuthorizationCode();\n case 'apple':\n return this.appleProvider.getAuthorizationCode();\n case 'facebook':\n return this.facebookProvider.getAuthorizationCode();\n case 'twitter':\n return this.twitterProvider.getAuthorizationCode();\n case 'oauth2':\n if (!options.providerId) {\n throw new Error('providerId is required for oauth2 getAuthorizationCode');\n }\n return this.oauth2Provider.getAuthorizationCode(options.providerId);\n default:\n throw new Error(`getAuthorizationCode for ${options.provider} is not implemented`);\n }\n }\n\n async refresh(options: LoginOptions): Promise<void> {\n switch (options.provider) {\n case 'google':\n return this.googleProvider.refresh();\n case 'apple':\n return this.appleProvider.refresh();\n case 'facebook':\n return this.facebookProvider.refresh(options.options as FacebookLoginOptions);\n case 'twitter':\n return this.twitterProvider.refresh();\n case 'oauth2': {\n const oauth2Options = options.options as OAuth2LoginOptions;\n if (!oauth2Options?.providerId) {\n throw new Error('providerId is required for oauth2 refresh');\n }\n return this.oauth2Provider.refresh(oauth2Options.providerId);\n }\n default:\n throw new Error(`Refresh for ${(options as any).provider} is not implemented`);\n }\n }\n\n async providerSpecificCall<T extends ProviderSpecificCall>(options: {\n call: T;\n options: ProviderSpecificCallOptionsMap[T];\n }): Promise<ProviderSpecificCallResponseMap[T]> {\n throw new Error(`Provider specific call for ${options.call} is not implemented`);\n }\n\n async refreshToken(options: {\n provider: 'oauth2';\n providerId: string;\n refreshToken?: string;\n additionalParameters?: Record<string, string>;\n }): Promise<OAuth2LoginResponse> {\n if (options.provider !== 'oauth2') {\n throw new Error('refreshToken is only implemented for oauth2 on web');\n }\n return this.oauth2Provider.refreshToken(options.providerId, options.refreshToken, options.additionalParameters);\n }\n\n async handleRedirectCallback(): Promise<LoginResult | null> {\n const parsed = await this.parseRedirectResult();\n const result = parsed.result;\n if (!result) return null;\n if ('error' in result) {\n throw inferUserCancelledError(result.error);\n }\n return result;\n }\n\n async decodeIdToken(options: { idToken?: string; token?: string }): Promise<{ claims: Record<string, any> }> {\n const token = options?.idToken ?? options?.token;\n if (!token) {\n throw new Error('idToken (or token) is required');\n }\n const claims = this.oauth2Provider.decodeIdToken(token);\n return { claims };\n }\n\n async getAccessTokenExpirationDate(options: { accessTokenExpirationDate: number }): Promise<{ date: string }> {\n if (typeof options?.accessTokenExpirationDate !== 'number') {\n throw new Error('accessTokenExpirationDate is required');\n }\n return { date: new Date(options.accessTokenExpirationDate).toISOString() };\n }\n\n async isAccessTokenAvailable(options: { accessToken: string | null }): Promise<{ isAvailable: boolean }> {\n const token = options?.accessToken ?? null;\n return { isAvailable: typeof token === 'string' && token.length > 0 };\n }\n\n async isAccessTokenExpired(options: { accessTokenExpirationDate: number }): Promise<{ isExpired: boolean }> {\n if (typeof options?.accessTokenExpirationDate !== 'number') {\n throw new Error('accessTokenExpirationDate is required');\n }\n return { isExpired: options.accessTokenExpirationDate <= Date.now() };\n }\n\n async isRefreshTokenAvailable(options: { refreshToken: string | null }): Promise<{ isAvailable: boolean }> {\n const token = options?.refreshToken ?? null;\n return { isAvailable: typeof token === 'string' && token.length > 0 };\n }\n\n async getPluginVersion(): Promise<{ version: string }> {\n return { version: 'web' };\n }\n\n async openSecureWindow(options: OpenSecureWindowOptions): Promise<OpenSecureWindowResponse> {\n const w = 600;\n const h = 550;\n const settings = [\n ['width', w],\n ['height', h],\n ['left', screen.width / 2 - w / 2],\n ['top', screen.height / 2 - h / 2],\n ]\n .map((x) => x.join('='))\n .join(',');\n\n const popup = window.open(options.authEndpoint, 'Authorization', settings)!;\n if (typeof popup.focus === 'function') {\n popup.focus();\n }\n return new Promise((resolve, reject) => {\n const bc = new BroadcastChannel(options.broadcastChannelName || 'oauth-channel');\n bc.addEventListener('message', (event) => {\n if (event.data.startsWith(options.redirectUri)) {\n bc.close();\n resolve({ redirectedUri: event.data });\n } else {\n bc.close();\n reject(new Error('Redirect URI does not match, expected ' + options.redirectUri + ' but got ' + event.data));\n }\n });\n setTimeout(() => {\n bc.close();\n reject(new Error('The sign-in flow timed out'));\n }, 5 * 60000);\n });\n }\n}\n"]}
|
package/dist/plugin.cjs.js
CHANGED
|
@@ -337,6 +337,36 @@ class BaseSocialLogin extends core.WebPlugin {
|
|
|
337
337
|
}
|
|
338
338
|
BaseSocialLogin.OAUTH_STATE_KEY = 'social_login_oauth_pending';
|
|
339
339
|
|
|
340
|
+
const USER_CANCELLED_CODE = 'USER_CANCELLED';
|
|
341
|
+
const CANCELLED_PATTERNS = [
|
|
342
|
+
'access_denied',
|
|
343
|
+
'access denied',
|
|
344
|
+
'user_cancelled_authorize',
|
|
345
|
+
'user_cancelled',
|
|
346
|
+
'user cancelled',
|
|
347
|
+
'user canceled',
|
|
348
|
+
'login cancelled',
|
|
349
|
+
'login canceled',
|
|
350
|
+
'popup closed',
|
|
351
|
+
'window was closed',
|
|
352
|
+
];
|
|
353
|
+
function createUserCancelledError(message) {
|
|
354
|
+
const error = new Error(message);
|
|
355
|
+
error.code = USER_CANCELLED_CODE;
|
|
356
|
+
return error;
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* Detects cancellation-like messages and marks them with USER_CANCELLED.
|
|
360
|
+
* Falls back to a regular Error when the message doesn't look like a user cancellation.
|
|
361
|
+
*/
|
|
362
|
+
function inferUserCancelledError(message) {
|
|
363
|
+
const normalized = message.toLowerCase();
|
|
364
|
+
if (CANCELLED_PATTERNS.some((pattern) => normalized.includes(pattern))) {
|
|
365
|
+
return createUserCancelledError(message);
|
|
366
|
+
}
|
|
367
|
+
return new Error(message);
|
|
368
|
+
}
|
|
369
|
+
|
|
340
370
|
class AppleSocialLogin extends BaseSocialLogin {
|
|
341
371
|
constructor() {
|
|
342
372
|
super(...arguments);
|
|
@@ -397,7 +427,9 @@ class AppleSocialLogin extends BaseSocialLogin {
|
|
|
397
427
|
resolve({ provider: 'apple', result });
|
|
398
428
|
})
|
|
399
429
|
.catch((error) => {
|
|
400
|
-
|
|
430
|
+
var _a, _b, _c;
|
|
431
|
+
const message = (_c = (_b = (_a = error === null || error === void 0 ? void 0 : error.message) !== null && _a !== void 0 ? _a : error === null || error === void 0 ? void 0 : error.localizedDescription) !== null && _b !== void 0 ? _b : error === null || error === void 0 ? void 0 : error.error) !== null && _c !== void 0 ? _c : 'Apple login failed';
|
|
432
|
+
reject(inferUserCancelledError(message));
|
|
401
433
|
});
|
|
402
434
|
});
|
|
403
435
|
}
|
|
@@ -456,37 +488,69 @@ class FacebookSocialLogin extends BaseSocialLogin {
|
|
|
456
488
|
throw new Error('Facebook App ID not set. Call initialize() first.');
|
|
457
489
|
}
|
|
458
490
|
return new Promise((resolve, reject) => {
|
|
491
|
+
var _a;
|
|
492
|
+
let settled = false;
|
|
493
|
+
let waitingForStatus = false;
|
|
494
|
+
const resolveWithProfile = (authResponse) => {
|
|
495
|
+
if (settled)
|
|
496
|
+
return;
|
|
497
|
+
if (!(authResponse === null || authResponse === void 0 ? void 0 : authResponse.accessToken) || !authResponse.userID) {
|
|
498
|
+
settled = true;
|
|
499
|
+
reject(new Error('Facebook login failed'));
|
|
500
|
+
return;
|
|
501
|
+
}
|
|
502
|
+
const accessToken = authResponse.accessToken;
|
|
503
|
+
const userId = authResponse.userID;
|
|
504
|
+
FB.api('/me', { fields: 'id,name,email,picture' }, (userInfo) => {
|
|
505
|
+
var _a, _b;
|
|
506
|
+
settled = true;
|
|
507
|
+
const result = {
|
|
508
|
+
accessToken: {
|
|
509
|
+
token: accessToken,
|
|
510
|
+
userId,
|
|
511
|
+
},
|
|
512
|
+
profile: {
|
|
513
|
+
userID: userInfo.id,
|
|
514
|
+
name: userInfo.name,
|
|
515
|
+
email: userInfo.email || null,
|
|
516
|
+
imageURL: ((_b = (_a = userInfo.picture) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.url) || null,
|
|
517
|
+
friendIDs: [],
|
|
518
|
+
birthday: null,
|
|
519
|
+
ageRange: null,
|
|
520
|
+
gender: null,
|
|
521
|
+
location: null,
|
|
522
|
+
hometown: null,
|
|
523
|
+
profileURL: null,
|
|
524
|
+
},
|
|
525
|
+
idToken: null,
|
|
526
|
+
};
|
|
527
|
+
resolve({ provider: 'facebook', result });
|
|
528
|
+
});
|
|
529
|
+
};
|
|
530
|
+
const waitForConnected = () => {
|
|
531
|
+
if (settled || waitingForStatus)
|
|
532
|
+
return;
|
|
533
|
+
waitingForStatus = true;
|
|
534
|
+
this.waitForConnection()
|
|
535
|
+
.then((statusResponse) => resolveWithProfile(statusResponse.authResponse))
|
|
536
|
+
.catch((error) => {
|
|
537
|
+
if (settled)
|
|
538
|
+
return;
|
|
539
|
+
settled = true;
|
|
540
|
+
reject(error);
|
|
541
|
+
});
|
|
542
|
+
};
|
|
459
543
|
FB.login((response) => {
|
|
460
544
|
if (response.status === 'connected') {
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
token: response.authResponse.accessToken,
|
|
466
|
-
userId: response.authResponse.userID,
|
|
467
|
-
},
|
|
468
|
-
profile: {
|
|
469
|
-
userID: userInfo.id,
|
|
470
|
-
name: userInfo.name,
|
|
471
|
-
email: userInfo.email || null,
|
|
472
|
-
imageURL: ((_b = (_a = userInfo.picture) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.url) || null,
|
|
473
|
-
friendIDs: [],
|
|
474
|
-
birthday: null,
|
|
475
|
-
ageRange: null,
|
|
476
|
-
gender: null,
|
|
477
|
-
location: null,
|
|
478
|
-
hometown: null,
|
|
479
|
-
profileURL: null,
|
|
480
|
-
},
|
|
481
|
-
idToken: null,
|
|
482
|
-
};
|
|
483
|
-
resolve({ provider: 'facebook', result });
|
|
484
|
-
});
|
|
545
|
+
resolveWithProfile(response.authResponse);
|
|
546
|
+
}
|
|
547
|
+
else if (response.status === 'not_authorized' || response.status === 'unknown') {
|
|
548
|
+
reject(createUserCancelledError('Facebook login was cancelled.'));
|
|
485
549
|
}
|
|
486
550
|
else {
|
|
487
|
-
|
|
551
|
+
waitForConnected();
|
|
488
552
|
}
|
|
489
|
-
}, { scope: options.permissions.join(',') });
|
|
553
|
+
}, ((_a = options.permissions) === null || _a === void 0 ? void 0 : _a.length) ? { scope: options.permissions.join(',') } : undefined);
|
|
490
554
|
});
|
|
491
555
|
}
|
|
492
556
|
async logout() {
|
|
@@ -517,6 +581,38 @@ class FacebookSocialLogin extends BaseSocialLogin {
|
|
|
517
581
|
async refresh(options) {
|
|
518
582
|
await this.login(options);
|
|
519
583
|
}
|
|
584
|
+
waitForConnection(timeoutMs = 120000, pollIntervalMs = 500) {
|
|
585
|
+
const start = Date.now();
|
|
586
|
+
return new Promise((resolve, reject) => {
|
|
587
|
+
let finished = false;
|
|
588
|
+
const pollStatus = () => {
|
|
589
|
+
if (finished)
|
|
590
|
+
return;
|
|
591
|
+
FB.getLoginStatus((response) => {
|
|
592
|
+
var _a;
|
|
593
|
+
if (finished)
|
|
594
|
+
return;
|
|
595
|
+
if (response.status === 'connected' && ((_a = response.authResponse) === null || _a === void 0 ? void 0 : _a.accessToken)) {
|
|
596
|
+
finished = true;
|
|
597
|
+
resolve(response);
|
|
598
|
+
return;
|
|
599
|
+
}
|
|
600
|
+
if (response.status === 'not_authorized' || response.status === 'unknown') {
|
|
601
|
+
finished = true;
|
|
602
|
+
reject(createUserCancelledError('Facebook login was cancelled.'));
|
|
603
|
+
return;
|
|
604
|
+
}
|
|
605
|
+
if (Date.now() - start >= timeoutMs) {
|
|
606
|
+
finished = true;
|
|
607
|
+
reject(new Error('Facebook login failed or timed out'));
|
|
608
|
+
return;
|
|
609
|
+
}
|
|
610
|
+
setTimeout(pollStatus, pollIntervalMs);
|
|
611
|
+
});
|
|
612
|
+
};
|
|
613
|
+
pollStatus();
|
|
614
|
+
});
|
|
615
|
+
}
|
|
520
616
|
async loadFacebookScript(locale) {
|
|
521
617
|
if (this.scriptLoaded)
|
|
522
618
|
return;
|
|
@@ -926,7 +1022,7 @@ class GoogleSocialLogin extends BaseSocialLogin {
|
|
|
926
1022
|
else if (((_d = event.data) === null || _d === void 0 ? void 0 : _d.type) === 'oauth-error') {
|
|
927
1023
|
cleanup(true);
|
|
928
1024
|
const errorMessage = event.data.error || 'User cancelled the OAuth flow';
|
|
929
|
-
reject(
|
|
1025
|
+
reject(inferUserCancelledError(errorMessage));
|
|
930
1026
|
}
|
|
931
1027
|
// Don't reject for non-OAuth messages, just ignore them
|
|
932
1028
|
};
|
|
@@ -944,7 +1040,7 @@ class GoogleSocialLogin extends BaseSocialLogin {
|
|
|
944
1040
|
else if ((data === null || data === void 0 ? void 0 : data.type) === 'oauth-error') {
|
|
945
1041
|
cleanup(true);
|
|
946
1042
|
const errorMessage = data.error || 'User cancelled the OAuth flow';
|
|
947
|
-
reject(
|
|
1043
|
+
reject(inferUserCancelledError(errorMessage));
|
|
948
1044
|
}
|
|
949
1045
|
};
|
|
950
1046
|
}
|
|
@@ -959,7 +1055,7 @@ class GoogleSocialLogin extends BaseSocialLogin {
|
|
|
959
1055
|
// Check if popup is closed - this may throw cross-origin errors for some providers
|
|
960
1056
|
if (popup.closed) {
|
|
961
1057
|
cleanup();
|
|
962
|
-
reject(
|
|
1058
|
+
reject(createUserCancelledError('Popup closed'));
|
|
963
1059
|
}
|
|
964
1060
|
}
|
|
965
1061
|
catch (_a) {
|
|
@@ -979,10 +1075,13 @@ class GoogleSocialLogin extends BaseSocialLogin {
|
|
|
979
1075
|
*/
|
|
980
1076
|
class OAuth2SocialLogin extends BaseSocialLogin {
|
|
981
1077
|
constructor() {
|
|
982
|
-
super(
|
|
1078
|
+
super();
|
|
983
1079
|
this.providers = new Map();
|
|
984
1080
|
this.TOKENS_KEY_PREFIX = 'capgo_social_login_oauth2_tokens_';
|
|
985
1081
|
this.STATE_PREFIX = 'capgo_social_login_oauth2_state_';
|
|
1082
|
+
this.CONFIG_KEY_PREFIX = 'capgo_social_login_oauth2_config_';
|
|
1083
|
+
// Restore configurations from localStorage for popup window context
|
|
1084
|
+
this.restoreConfigurationsFromStorage();
|
|
986
1085
|
}
|
|
987
1086
|
normalizeScopeValue(scope) {
|
|
988
1087
|
if (!scope)
|
|
@@ -1065,6 +1164,8 @@ class OAuth2SocialLogin extends BaseSocialLogin {
|
|
|
1065
1164
|
logoutUrl: config.logoutUrl,
|
|
1066
1165
|
});
|
|
1067
1166
|
}
|
|
1167
|
+
// Persist updated configuration after discovery
|
|
1168
|
+
this.persistConfiguration(providerId, config);
|
|
1068
1169
|
}
|
|
1069
1170
|
/**
|
|
1070
1171
|
* Initialize multiple OAuth2 providers
|
|
@@ -1085,6 +1186,8 @@ class OAuth2SocialLogin extends BaseSocialLogin {
|
|
|
1085
1186
|
}
|
|
1086
1187
|
// Pre-resolve discovery on web if issuerUrl is provided.
|
|
1087
1188
|
await this.ensureDiscovered(providerId);
|
|
1189
|
+
// Persist configuration to localStorage so it's available in popup window context
|
|
1190
|
+
this.persistConfiguration(providerId, internalConfig);
|
|
1088
1191
|
}
|
|
1089
1192
|
}
|
|
1090
1193
|
getProvider(providerId) {
|
|
@@ -1097,6 +1200,37 @@ class OAuth2SocialLogin extends BaseSocialLogin {
|
|
|
1097
1200
|
getTokensKey(providerId) {
|
|
1098
1201
|
return `${this.TOKENS_KEY_PREFIX}${providerId}`;
|
|
1099
1202
|
}
|
|
1203
|
+
getConfigKey(providerId) {
|
|
1204
|
+
return `${this.CONFIG_KEY_PREFIX}${providerId}`;
|
|
1205
|
+
}
|
|
1206
|
+
persistConfiguration(providerId, config) {
|
|
1207
|
+
try {
|
|
1208
|
+
localStorage.setItem(this.getConfigKey(providerId), JSON.stringify(config));
|
|
1209
|
+
}
|
|
1210
|
+
catch (err) {
|
|
1211
|
+
console.warn(`Failed to persist OAuth2 configuration for provider '${providerId}'`, err);
|
|
1212
|
+
}
|
|
1213
|
+
}
|
|
1214
|
+
restoreConfigurationsFromStorage() {
|
|
1215
|
+
// Restore all provider configurations from localStorage
|
|
1216
|
+
// This is needed for popup window context where the parent's in-memory state is not available
|
|
1217
|
+
const keys = Object.keys(localStorage);
|
|
1218
|
+
for (const key of keys) {
|
|
1219
|
+
if (key.startsWith(this.CONFIG_KEY_PREFIX)) {
|
|
1220
|
+
const providerId = key.substring(this.CONFIG_KEY_PREFIX.length);
|
|
1221
|
+
try {
|
|
1222
|
+
const raw = localStorage.getItem(key);
|
|
1223
|
+
if (raw) {
|
|
1224
|
+
const config = JSON.parse(raw);
|
|
1225
|
+
this.providers.set(providerId, config);
|
|
1226
|
+
}
|
|
1227
|
+
}
|
|
1228
|
+
catch (err) {
|
|
1229
|
+
console.warn(`Failed to restore OAuth2 configuration for provider '${providerId}'`, err);
|
|
1230
|
+
}
|
|
1231
|
+
}
|
|
1232
|
+
}
|
|
1233
|
+
}
|
|
1100
1234
|
async login(options) {
|
|
1101
1235
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
1102
1236
|
const { providerId } = options;
|
|
@@ -1213,7 +1347,7 @@ class OAuth2SocialLogin extends BaseSocialLogin {
|
|
|
1213
1347
|
return false;
|
|
1214
1348
|
}
|
|
1215
1349
|
cleanup(messageHandler, timeoutHandle, popupClosedInterval);
|
|
1216
|
-
reject(
|
|
1350
|
+
reject(inferUserCancelledError(data.error || 'OAuth2 login was cancelled.'));
|
|
1217
1351
|
return true;
|
|
1218
1352
|
}
|
|
1219
1353
|
return false;
|
|
@@ -1246,7 +1380,7 @@ class OAuth2SocialLogin extends BaseSocialLogin {
|
|
|
1246
1380
|
// Check if popup is closed - this may throw cross-origin errors for some providers
|
|
1247
1381
|
if (popup.closed) {
|
|
1248
1382
|
cleanup(messageHandler, timeoutHandle, popupClosedInterval);
|
|
1249
|
-
reject(
|
|
1383
|
+
reject(createUserCancelledError('OAuth2 login window was closed.'));
|
|
1250
1384
|
}
|
|
1251
1385
|
}
|
|
1252
1386
|
catch (_a) {
|
|
@@ -1672,6 +1806,7 @@ class TwitterSocialLogin extends BaseSocialLogin {
|
|
|
1672
1806
|
const codeVerifier = (_e = options.codeVerifier) !== null && _e !== void 0 ? _e : this.generateCodeVerifier();
|
|
1673
1807
|
const codeChallenge = await this.generateCodeChallenge(codeVerifier);
|
|
1674
1808
|
this.persistPendingLogin(state, {
|
|
1809
|
+
clientId: this.clientId,
|
|
1675
1810
|
codeVerifier,
|
|
1676
1811
|
redirectUri,
|
|
1677
1812
|
scopes,
|
|
@@ -1739,7 +1874,7 @@ class TwitterSocialLogin extends BaseSocialLogin {
|
|
|
1739
1874
|
return false;
|
|
1740
1875
|
}
|
|
1741
1876
|
cleanup(messageHandler, timeoutHandle, popupClosedInterval);
|
|
1742
|
-
reject(
|
|
1877
|
+
reject(inferUserCancelledError(data.error || 'Twitter login was cancelled.'));
|
|
1743
1878
|
return true;
|
|
1744
1879
|
}
|
|
1745
1880
|
return false;
|
|
@@ -1772,7 +1907,7 @@ class TwitterSocialLogin extends BaseSocialLogin {
|
|
|
1772
1907
|
// Check if popup is closed - this may throw cross-origin errors for some providers
|
|
1773
1908
|
if (popup.closed) {
|
|
1774
1909
|
cleanup(messageHandler, timeoutHandle, popupClosedInterval);
|
|
1775
|
-
reject(
|
|
1910
|
+
reject(createUserCancelledError('Twitter login window was closed.'));
|
|
1776
1911
|
}
|
|
1777
1912
|
}
|
|
1778
1913
|
catch (_a) {
|
|
@@ -1877,10 +2012,9 @@ class TwitterSocialLogin extends BaseSocialLogin {
|
|
|
1877
2012
|
}
|
|
1878
2013
|
}
|
|
1879
2014
|
async exchangeAuthorizationCode(code, pending) {
|
|
1880
|
-
var _a;
|
|
1881
2015
|
const params = new URLSearchParams({
|
|
1882
2016
|
grant_type: 'authorization_code',
|
|
1883
|
-
client_id:
|
|
2017
|
+
client_id: pending.clientId,
|
|
1884
2018
|
code,
|
|
1885
2019
|
redirect_uri: pending.redirectUri,
|
|
1886
2020
|
code_verifier: pending.codeVerifier,
|
|
@@ -2079,11 +2213,8 @@ class SocialLoginWeb extends core.WebPlugin {
|
|
|
2079
2213
|
let message;
|
|
2080
2214
|
if ('error' in result) {
|
|
2081
2215
|
const resolvedProvider = (_a = parsed.provider) !== null && _a !== void 0 ? _a : null;
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
provider: resolvedProvider,
|
|
2085
|
-
error: result.error,
|
|
2086
|
-
};
|
|
2216
|
+
const error = inferUserCancelledError(result.error);
|
|
2217
|
+
message = Object.assign({ type: 'oauth-error', provider: resolvedProvider, error: error.message }, (error.code ? { code: error.code } : null));
|
|
2087
2218
|
}
|
|
2088
2219
|
else {
|
|
2089
2220
|
message = Object.assign({ type: 'oauth-response', provider: result.provider }, result.result);
|
|
@@ -2253,7 +2384,7 @@ class SocialLoginWeb extends core.WebPlugin {
|
|
|
2253
2384
|
if (!result)
|
|
2254
2385
|
return null;
|
|
2255
2386
|
if ('error' in result) {
|
|
2256
|
-
throw
|
|
2387
|
+
throw inferUserCancelledError(result.error);
|
|
2257
2388
|
}
|
|
2258
2389
|
return result;
|
|
2259
2390
|
}
|