@capgo/capacitor-social-login 1.2.6 → 7.1.6

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.
@@ -24,7 +24,7 @@ class SocialLoginWeb extends core.WebPlugin {
24
24
  console.log('OAUTH_STATE_KEY found');
25
25
  const result = this.handleOAuthRedirect();
26
26
  if (result) {
27
- (_a = window.opener) === null || _a === undefined ? undefined : _a.postMessage(Object.assign({ type: 'oauth-response' }, result.result), window.location.origin);
27
+ (_a = window.opener) === null || _a === void 0 ? void 0 : _a.postMessage(Object.assign({ type: 'oauth-response' }, result.result), window.location.origin);
28
28
  window.close();
29
29
  }
30
30
  }
@@ -76,18 +76,19 @@ class SocialLoginWeb extends core.WebPlugin {
76
76
  }
77
77
  async initialize(options) {
78
78
  var _a, _b, _c;
79
- if ((_a = options.google) === null || _a === undefined ? undefined : _a.webClientId) {
79
+ if ((_a = options.google) === null || _a === void 0 ? void 0 : _a.webClientId) {
80
80
  this.googleClientId = options.google.webClientId;
81
81
  if (options.google.mode) {
82
82
  this.googleLoginType = options.google.mode;
83
83
  }
84
+ this.googleHostedDomain = options.google.hostedDomain;
84
85
  await this.loadGoogleScript();
85
86
  }
86
- if ((_b = options.apple) === null || _b === undefined ? undefined : _b.clientId) {
87
+ if ((_b = options.apple) === null || _b === void 0 ? void 0 : _b.clientId) {
87
88
  this.appleClientId = options.apple.clientId;
88
89
  await this.loadAppleScript();
89
90
  }
90
- if ((_c = options.facebook) === null || _c === undefined ? undefined : _c.appId) {
91
+ if ((_c = options.facebook) === null || _c === void 0 ? void 0 : _c.appId) {
91
92
  this.facebookAppId = options.facebook.appId;
92
93
  await this.loadFacebookScript();
93
94
  FB.init({
@@ -306,7 +307,7 @@ class SocialLoginWeb extends core.WebPlugin {
306
307
  FB.getLoginStatus((response) => {
307
308
  var _a;
308
309
  if (response.status === 'connected') {
309
- resolve({ jwt: ((_a = response.authResponse) === null || _a === undefined ? undefined : _a.accessToken) || '' });
310
+ resolve({ jwt: ((_a = response.authResponse) === null || _a === void 0 ? void 0 : _a.accessToken) || '' });
310
311
  }
311
312
  else {
312
313
  reject(new Error('No Facebook authorization code available'));
@@ -359,11 +360,12 @@ class SocialLoginWeb extends core.WebPlugin {
359
360
  }
360
361
  if (scopes.length > 3 || this.googleLoginType === 'offline' || options.disableOneTap) {
361
362
  // If scopes are provided, directly use the traditional OAuth flow
362
- return this.fallbackToTraditionalOAuth(scopes);
363
+ return this.fallbackToTraditionalOAuth(scopes, this.googleHostedDomain);
363
364
  }
364
365
  return new Promise((resolve, reject) => {
365
366
  google.accounts.id.initialize({
366
367
  client_id: this.googleClientId,
368
+ hd: this.googleHostedDomain,
367
369
  callback: (response) => {
368
370
  console.log('google.accounts.id.initialize callback', response);
369
371
  if (response.error) {
@@ -394,7 +396,7 @@ class SocialLoginWeb extends core.WebPlugin {
394
396
  if (notification.isNotDisplayed() || notification.isSkippedMoment()) {
395
397
  console.log('OneTap is not displayed or skipped');
396
398
  // Fallback to traditional OAuth if One Tap is not available
397
- this.fallbackToTraditionalOAuth(scopes)
399
+ this.fallbackToTraditionalOAuth(scopes, this.googleHostedDomain)
398
400
  .then((r) => resolve({ provider: 'google', result: r.result }))
399
401
  .catch(reject);
400
402
  }
@@ -441,7 +443,7 @@ class SocialLoginWeb extends core.WebPlugin {
441
443
  var _a;
442
444
  AppleID.auth.init({
443
445
  clientId: this.appleClientId,
444
- scope: ((_a = options.scopes) === null || _a === undefined ? undefined : _a.join(' ')) || 'name email',
446
+ scope: ((_a = options.scopes) === null || _a === void 0 ? void 0 : _a.join(' ')) || 'name email',
445
447
  redirectURI: options.redirectUrl || window.location.href,
446
448
  state: options.state,
447
449
  nonce: options.nonce,
@@ -453,10 +455,10 @@ class SocialLoginWeb extends core.WebPlugin {
453
455
  var _a, _b, _c, _d, _e, _f, _g;
454
456
  const result = {
455
457
  profile: {
456
- user: ((_b = (_a = res.user) === null || _a === undefined ? undefined : _a.name) === null || _b === undefined ? undefined : _b.firstName) ? `${res.user.name.firstName} ${res.user.name.lastName}` : '',
457
- email: ((_c = res.user) === null || _c === undefined ? undefined : _c.email) || null,
458
- givenName: ((_e = (_d = res.user) === null || _d === undefined ? undefined : _d.name) === null || _e === undefined ? undefined : _e.firstName) || null,
459
- familyName: ((_g = (_f = res.user) === null || _f === undefined ? undefined : _f.name) === null || _g === undefined ? undefined : _g.lastName) || null,
458
+ user: ((_b = (_a = res.user) === null || _a === void 0 ? void 0 : _a.name) === null || _b === void 0 ? void 0 : _b.firstName) ? `${res.user.name.firstName} ${res.user.name.lastName}` : '',
459
+ email: ((_c = res.user) === null || _c === void 0 ? void 0 : _c.email) || null,
460
+ givenName: ((_e = (_d = res.user) === null || _d === void 0 ? void 0 : _d.name) === null || _e === void 0 ? void 0 : _e.firstName) || null,
461
+ familyName: ((_g = (_f = res.user) === null || _f === void 0 ? void 0 : _f.name) === null || _g === void 0 ? void 0 : _g.lastName) || null,
460
462
  },
461
463
  accessToken: {
462
464
  token: res.authorization.code, // TODO: to fix and find the correct token
@@ -548,7 +550,7 @@ class SocialLoginWeb extends core.WebPlugin {
548
550
  userID: userInfo.id,
549
551
  name: userInfo.name,
550
552
  email: userInfo.email || null,
551
- imageURL: ((_b = (_a = userInfo.picture) === null || _a === undefined ? undefined : _a.data) === null || _b === undefined ? undefined : _b.url) || null,
553
+ imageURL: ((_b = (_a = userInfo.picture) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.url) || null,
552
554
  friendIDs: [],
553
555
  birthday: null,
554
556
  ageRange: null,
@@ -568,7 +570,7 @@ class SocialLoginWeb extends core.WebPlugin {
568
570
  }, { scope: options.permissions.join(',') });
569
571
  });
570
572
  }
571
- async fallbackToTraditionalOAuth(scopes) {
573
+ async fallbackToTraditionalOAuth(scopes, hostedDomain) {
572
574
  const uniqueScopes = [...new Set([...scopes, 'openid'])];
573
575
  const params = new URLSearchParams({
574
576
  client_id: this.googleClientId,
@@ -579,6 +581,9 @@ class SocialLoginWeb extends core.WebPlugin {
579
581
  include_granted_scopes: 'true',
580
582
  state: 'popup',
581
583
  });
584
+ if (hostedDomain !== undefined) {
585
+ params.append('hd', hostedDomain);
586
+ }
582
587
  const url = `https://accounts.google.com/o/oauth2/v2/auth?${params.toString()}`;
583
588
  const width = 500;
584
589
  const height = 600;
@@ -596,7 +601,7 @@ class SocialLoginWeb extends core.WebPlugin {
596
601
  var _a;
597
602
  if (event.origin !== window.location.origin)
598
603
  return;
599
- if (((_a = event.data) === null || _a === undefined ? undefined : _a.type) === 'oauth-response') {
604
+ if (((_a = event.data) === null || _a === void 0 ? void 0 : _a.type) === 'oauth-response') {
600
605
  window.removeEventListener('message', handleMessage);
601
606
  if (this.googleLoginType === 'online') {
602
607
  const { accessToken, idToken } = event.data;
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst SocialLogin = registerPlugin('SocialLogin', {\n web: () => import('./web').then((m) => new m.SocialLoginWeb()),\n});\nexport * from './definitions';\nexport { SocialLogin };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class SocialLoginWeb extends WebPlugin {\n constructor() {\n var _a;\n super();\n this.googleClientId = null;\n this.appleClientId = null;\n this.googleScriptLoaded = false;\n this.googleLoginType = 'online';\n this.appleScriptLoaded = false;\n this.appleScriptUrl = 'https://appleid.cdn-apple.com/appleauth/static/jsapi/appleid/1/en_US/appleid.auth.js';\n this.GOOGLE_TOKEN_REQUEST_URL = 'https://www.googleapis.com/oauth2/v3/tokeninfo';\n this.facebookAppId = null;\n this.facebookScriptLoaded = false;\n // Set up listener for OAuth redirects if we have a pending OAuth flow\n if (localStorage.getItem(SocialLoginWeb.OAUTH_STATE_KEY)) {\n console.log('OAUTH_STATE_KEY found');\n const result = this.handleOAuthRedirect();\n if (result) {\n (_a = window.opener) === null || _a === void 0 ? void 0 : _a.postMessage(Object.assign({ type: 'oauth-response' }, result.result), window.location.origin);\n window.close();\n }\n }\n }\n handleOAuthRedirect() {\n const paramsRaw = new URL(window.location.href).searchParams;\n const code = paramsRaw.get('code');\n if (code && paramsRaw.has('scope')) {\n return {\n provider: 'google',\n result: {\n provider: 'google',\n result: {\n serverAuthCode: code,\n },\n },\n };\n }\n const hash = window.location.hash.substring(1);\n console.log('handleOAuthRedirect', window.location.hash);\n if (!hash)\n return;\n console.log('handleOAuthRedirect ok');\n const params = new URLSearchParams(hash);\n const accessToken = params.get('access_token');\n const idToken = params.get('id_token');\n if (accessToken && idToken) {\n localStorage.removeItem(SocialLoginWeb.OAUTH_STATE_KEY);\n const profile = this.parseJwt(idToken);\n return {\n provider: 'google',\n result: {\n accessToken: {\n token: accessToken,\n },\n idToken,\n profile: {\n email: profile.email || null,\n familyName: profile.family_name || null,\n givenName: profile.given_name || null,\n id: profile.sub || null,\n name: profile.name || null,\n imageUrl: profile.picture || null,\n },\n },\n };\n }\n return null;\n }\n async initialize(options) {\n var _a, _b, _c;\n if ((_a = options.google) === null || _a === void 0 ? void 0 : _a.webClientId) {\n this.googleClientId = options.google.webClientId;\n if (options.google.mode) {\n this.googleLoginType = options.google.mode;\n }\n await this.loadGoogleScript();\n }\n if ((_b = options.apple) === null || _b === void 0 ? void 0 : _b.clientId) {\n this.appleClientId = options.apple.clientId;\n await this.loadAppleScript();\n }\n if ((_c = options.facebook) === null || _c === void 0 ? void 0 : _c.appId) {\n this.facebookAppId = options.facebook.appId;\n await this.loadFacebookScript();\n FB.init({\n appId: this.facebookAppId,\n version: 'v17.0',\n xfbml: true,\n cookie: true,\n });\n }\n // Implement initialization for other providers if needed\n }\n async login(options) {\n switch (options.provider) {\n case 'google':\n return this.loginWithGoogle(options.options);\n case 'apple':\n return this.loginWithApple(options.options);\n case 'facebook':\n return this.loginWithFacebook(options.options);\n default:\n throw new Error(`Login for ${options.provider} is not implemented on web`);\n }\n }\n async logout(options) {\n switch (options.provider) {\n case 'google':\n if (this.googleLoginType === 'offline') {\n return Promise.reject(\"Offline login doesn't store tokens. logout is not available\");\n }\n // Google doesn't have a specific logout method for web\n // We can revoke the token if we have it stored\n console.log('Google logout: Id token should be revoked on the client side if stored');\n // eslint-disable-next-line\n const state = this.getGoogleState();\n if (!state)\n return;\n await this.rawLogoutGoogle(state.accessToken);\n break;\n case 'apple':\n // Apple doesn't provide a logout method for web\n console.log('Apple logout: Session should be managed on the client side');\n break;\n case 'facebook':\n return new Promise((resolve) => {\n FB.logout(() => resolve());\n });\n default:\n throw new Error(`Logout for ${options.provider} is not implemented`);\n }\n }\n async accessTokenIsValid(accessToken) {\n const url = `${this.GOOGLE_TOKEN_REQUEST_URL}?access_token=${encodeURIComponent(accessToken)}`;\n try {\n // Make the GET request using fetch\n const response = await fetch(url);\n // Check if the response is successful\n if (!response.ok) {\n console.log(`Invalid response from ${this.GOOGLE_TOKEN_REQUEST_URL}. Response not successful. Status code: ${response.status}. Assuming that the token is not valid`);\n return false;\n }\n // Get the response body as text\n const responseBody = await response.text();\n if (!responseBody) {\n console.error(`Invalid response from ${this.GOOGLE_TOKEN_REQUEST_URL}. Response body is null`);\n throw new Error(`Invalid response from ${this.GOOGLE_TOKEN_REQUEST_URL}. Response body is null`);\n }\n // Parse the response body as JSON\n let jsonObject;\n try {\n jsonObject = JSON.parse(responseBody);\n }\n catch (e) {\n console.error(`Invalid response from ${this.GOOGLE_TOKEN_REQUEST_URL}. Response body is not valid JSON. Error: ${e}`);\n throw new Error(`Invalid response from ${this.GOOGLE_TOKEN_REQUEST_URL}. Response body is not valid JSON. Error: ${e}`);\n }\n // Extract the 'expires_in' field\n const expiresInStr = jsonObject['expires_in'];\n if (expiresInStr === undefined || expiresInStr === null) {\n console.error(`Invalid response from ${this.GOOGLE_TOKEN_REQUEST_URL}. Response JSON does not include 'expires_in'.`);\n throw new Error(`Invalid response from ${this.GOOGLE_TOKEN_REQUEST_URL}. Response JSON does not include 'expires_in'.`);\n }\n // Parse 'expires_in' as an integer\n let expiresInInt;\n try {\n expiresInInt = parseInt(expiresInStr, 10);\n if (isNaN(expiresInInt)) {\n throw new Error(`'expires_in' is not a valid integer`);\n }\n }\n catch (e) {\n console.error(`Invalid response from ${this.GOOGLE_TOKEN_REQUEST_URL}. 'expires_in': ${expiresInStr} is not a valid integer. Error: ${e}`);\n throw new Error(`Invalid response from ${this.GOOGLE_TOKEN_REQUEST_URL}. 'expires_in': ${expiresInStr} is not a valid integer. Error: ${e}`);\n }\n // Determine if the access token is valid based on 'expires_in'\n return expiresInInt > 5;\n }\n catch (error) {\n console.error(error);\n throw error;\n }\n }\n idTokenValid(idToken) {\n try {\n const parsed = this.parseJwt(idToken);\n const currentTime = Math.ceil(Date.now() / 1000) + 5; // Convert current time to seconds since epoch\n return parsed.exp && currentTime < parsed.exp;\n }\n catch (e) {\n return false;\n }\n }\n async rawLogoutGoogle(accessToken, tokenValid = null) {\n if (tokenValid === null) {\n tokenValid = await this.accessTokenIsValid(accessToken);\n }\n if (tokenValid === true) {\n return new Promise((resolve, reject) => {\n try {\n google.accounts.oauth2.revoke(accessToken, async () => {\n this.clearStateGoogle();\n resolve();\n });\n }\n catch (e) {\n reject(e);\n }\n });\n }\n else {\n this.clearStateGoogle();\n return;\n }\n }\n async isLoggedIn(options) {\n switch (options.provider) {\n case 'google':\n if (this.googleLoginType === 'offline') {\n return Promise.reject(\"Offline login doesn't store tokens. isLoggedIn is not available\");\n }\n // For Google, we can check if there's a valid token\n // eslint-disable-next-line\n const state = this.getGoogleState();\n if (!state)\n return { isLoggedIn: false };\n try {\n // todo: cache accessTokenIsValid calls\n const isValidAccessToken = await this.accessTokenIsValid(state.accessToken);\n const isValidIdToken = this.idTokenValid(state.idToken);\n if (isValidAccessToken && isValidIdToken) {\n return { isLoggedIn: true };\n }\n else {\n try {\n await this.rawLogoutGoogle(state.accessToken, false);\n }\n catch (e) {\n console.error('Access token is not valid, but cannot logout', e);\n }\n return { isLoggedIn: false };\n }\n }\n catch (e) {\n return Promise.reject(e);\n }\n case 'apple':\n // Apple doesn't provide a method to check login status on web\n console.log('Apple login status should be managed on the client side');\n return { isLoggedIn: false };\n case 'facebook':\n return new Promise((resolve) => {\n FB.getLoginStatus((response) => {\n resolve({ isLoggedIn: response.status === 'connected' });\n });\n });\n default:\n throw new Error(`isLoggedIn for ${options.provider} is not implemented`);\n }\n }\n async getAuthorizationCode(options) {\n switch (options.provider) {\n case 'google':\n if (this.googleLoginType === 'offline') {\n return Promise.reject(\"Offline login doesn't store tokens. getAuthorizationCode is not available\");\n }\n // For Google, we can use the id_token as the authorization code\n // eslint-disable-next-line\n const state = this.getGoogleState();\n if (!state)\n throw new Error('No Google authorization code available');\n try {\n // todo: cache accessTokenIsValid calls\n const isValidAccessToken = await this.accessTokenIsValid(state.accessToken);\n const isValidIdToken = this.idTokenValid(state.idToken);\n if (isValidAccessToken && isValidIdToken) {\n return { accessToken: state.accessToken, jwt: state.idToken };\n }\n else {\n try {\n await this.rawLogoutGoogle(state.accessToken, false);\n }\n catch (e) {\n console.error('Access token is not valid, but cannot logout', e);\n }\n throw new Error('No Google authorization code available');\n }\n }\n catch (e) {\n return Promise.reject(e);\n }\n case 'apple':\n // Apple authorization code should be obtained during login\n console.log('Apple authorization code should be stored during login');\n throw new Error('Apple authorization code not available');\n case 'facebook':\n return new Promise((resolve, reject) => {\n FB.getLoginStatus((response) => {\n var _a;\n if (response.status === 'connected') {\n resolve({ jwt: ((_a = response.authResponse) === null || _a === void 0 ? void 0 : _a.accessToken) || '' });\n }\n else {\n reject(new Error('No Facebook authorization code available'));\n }\n });\n });\n default:\n throw new Error(`getAuthorizationCode for ${options.provider} is not implemented`);\n }\n }\n async refresh(options) {\n switch (options.provider) {\n case 'google':\n // For Google, we can prompt for re-authentication\n return Promise.reject('Not implemented');\n case 'apple':\n // Apple doesn't provide a refresh method for web\n console.log('Apple refresh not available on web');\n break;\n case 'facebook':\n await this.loginWithFacebook(options.options);\n break;\n default:\n throw new Error(`Refresh for ${options.provider} is not implemented`);\n }\n }\n loginWithGoogle(options) {\n if (!this.googleClientId) {\n throw new Error('Google Client ID not set. Call initialize() first.');\n }\n let scopes = options.scopes || [];\n if (scopes.length > 0) {\n // If scopes are provided, directly use the traditional OAuth flow\n if (!scopes.includes('https://www.googleapis.com/auth/userinfo.email')) {\n scopes.push('https://www.googleapis.com/auth/userinfo.email');\n }\n if (!scopes.includes('https://www.googleapis.com/auth/userinfo.profile')) {\n scopes.push('https://www.googleapis.com/auth/userinfo.profile');\n }\n if (!scopes.includes('openid')) {\n scopes.push('openid');\n }\n }\n else {\n scopes = [\n 'https://www.googleapis.com/auth/userinfo.email',\n 'https://www.googleapis.com/auth/userinfo.profile',\n 'openid',\n ];\n }\n if (scopes.length > 3 || this.googleLoginType === 'offline' || options.disableOneTap) {\n // If scopes are provided, directly use the traditional OAuth flow\n return this.fallbackToTraditionalOAuth(scopes);\n }\n return new Promise((resolve, reject) => {\n google.accounts.id.initialize({\n client_id: this.googleClientId,\n callback: (response) => {\n console.log('google.accounts.id.initialize callback', response);\n if (response.error) {\n // we use any because type fail but we need to double check if that works\n reject(response.error);\n }\n else {\n const payload = this.parseJwt(response.credential);\n const result = {\n accessToken: null,\n responseType: 'online',\n idToken: response.credential,\n profile: {\n email: payload.email || null,\n familyName: payload.family_name || null,\n givenName: payload.given_name || null,\n id: payload.sub || null,\n name: payload.name || null,\n imageUrl: payload.picture || null,\n },\n };\n resolve({ provider: 'google', result });\n }\n },\n auto_select: true,\n });\n google.accounts.id.prompt((notification) => {\n if (notification.isNotDisplayed() || notification.isSkippedMoment()) {\n console.log('OneTap is not displayed or skipped');\n // Fallback to traditional OAuth if One Tap is not available\n this.fallbackToTraditionalOAuth(scopes)\n .then((r) => resolve({ provider: 'google', result: r.result }))\n .catch(reject);\n }\n else {\n console.log('OneTap is displayed');\n }\n });\n });\n }\n parseJwt(token) {\n const base64Url = token.split('.')[1];\n const base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/');\n const jsonPayload = decodeURIComponent(atob(base64)\n .split('')\n .map((c) => {\n return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);\n })\n .join(''));\n return JSON.parse(jsonPayload);\n }\n async loadGoogleScript() {\n if (this.googleScriptLoaded)\n return;\n return new Promise((resolve, reject) => {\n const script = document.createElement('script');\n script.src = 'https://accounts.google.com/gsi/client';\n script.async = true;\n script.onload = () => {\n this.googleScriptLoaded = true;\n resolve();\n };\n script.onerror = reject;\n document.body.appendChild(script);\n });\n }\n async loginWithApple(options) {\n if (!this.appleClientId) {\n throw new Error('Apple Client ID not set. Call initialize() first.');\n }\n if (!this.appleScriptLoaded) {\n throw new Error('Apple Sign-In script not loaded.');\n }\n return new Promise((resolve, reject) => {\n var _a;\n AppleID.auth.init({\n clientId: this.appleClientId,\n scope: ((_a = options.scopes) === null || _a === void 0 ? void 0 : _a.join(' ')) || 'name email',\n redirectURI: options.redirectUrl || window.location.href,\n state: options.state,\n nonce: options.nonce,\n usePopup: true,\n });\n AppleID.auth\n .signIn()\n .then((res) => {\n var _a, _b, _c, _d, _e, _f, _g;\n const result = {\n profile: {\n user: ((_b = (_a = res.user) === null || _a === void 0 ? void 0 : _a.name) === null || _b === void 0 ? void 0 : _b.firstName) ? `${res.user.name.firstName} ${res.user.name.lastName}` : '',\n email: ((_c = res.user) === null || _c === void 0 ? void 0 : _c.email) || null,\n givenName: ((_e = (_d = res.user) === null || _d === void 0 ? void 0 : _d.name) === null || _e === void 0 ? void 0 : _e.firstName) || null,\n familyName: ((_g = (_f = res.user) === null || _f === void 0 ? void 0 : _f.name) === null || _g === void 0 ? void 0 : _g.lastName) || null,\n },\n accessToken: {\n token: res.authorization.code, // TODO: to fix and find the correct token\n },\n idToken: res.authorization.id_token || null,\n };\n resolve({ provider: 'apple', result });\n })\n .catch((error) => {\n reject(error);\n });\n });\n }\n async loadAppleScript() {\n if (this.appleScriptLoaded)\n return;\n return new Promise((resolve, reject) => {\n const script = document.createElement('script');\n script.src = this.appleScriptUrl;\n script.async = true;\n script.onload = () => {\n this.appleScriptLoaded = true;\n resolve();\n };\n script.onerror = reject;\n document.body.appendChild(script);\n });\n }\n persistStateGoogle(accessToken, idToken) {\n try {\n window.localStorage.setItem('capgo_social_login_google_state', JSON.stringify({ accessToken, idToken }));\n }\n catch (e) {\n console.error('Cannot persist state google', e);\n }\n }\n clearStateGoogle() {\n try {\n window.localStorage.removeItem('capgo_social_login_google_state');\n }\n catch (e) {\n console.error('Cannot clear state google', e);\n }\n }\n getGoogleState() {\n try {\n const state = window.localStorage.getItem('capgo_social_login_google_state');\n if (!state)\n return null;\n const { accessToken, idToken } = JSON.parse(state);\n return { accessToken, idToken };\n }\n catch (e) {\n console.error('Cannot get state google', e);\n return null;\n }\n }\n async loadFacebookScript() {\n if (this.facebookScriptLoaded)\n return;\n return new Promise((resolve, reject) => {\n const script = document.createElement('script');\n script.src = 'https://connect.facebook.net/en_US/sdk.js';\n script.async = true;\n script.defer = true;\n script.onload = () => {\n this.facebookScriptLoaded = true;\n resolve();\n };\n script.onerror = reject;\n document.body.appendChild(script);\n });\n }\n async loginWithFacebook(options) {\n if (!this.facebookAppId) {\n throw new Error('Facebook App ID not set. Call initialize() first.');\n }\n return new Promise((resolve, reject) => {\n FB.login((response) => {\n if (response.status === 'connected') {\n FB.api('/me', { fields: 'id,name,email,picture' }, (userInfo) => {\n var _a, _b;\n const result = {\n accessToken: {\n token: response.authResponse.accessToken,\n userId: response.authResponse.userID,\n },\n profile: {\n userID: userInfo.id,\n name: userInfo.name,\n email: userInfo.email || null,\n imageURL: ((_b = (_a = userInfo.picture) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.url) || null,\n friendIDs: [],\n birthday: null,\n ageRange: null,\n gender: null,\n location: null,\n hometown: null,\n profileURL: null,\n },\n idToken: null,\n };\n resolve({ provider: 'facebook', result });\n });\n }\n else {\n reject(new Error('Facebook login failed'));\n }\n }, { scope: options.permissions.join(',') });\n });\n }\n async fallbackToTraditionalOAuth(scopes) {\n const uniqueScopes = [...new Set([...scopes, 'openid'])];\n const params = new URLSearchParams({\n client_id: this.googleClientId,\n redirect_uri: window.location.href,\n response_type: this.googleLoginType === 'offline' ? 'code' : 'token id_token',\n scope: uniqueScopes.join(' '),\n nonce: Math.random().toString(36).substring(2),\n include_granted_scopes: 'true',\n state: 'popup',\n });\n const url = `https://accounts.google.com/o/oauth2/v2/auth?${params.toString()}`;\n const width = 500;\n const height = 600;\n const left = window.screenX + (window.outerWidth - width) / 2;\n const top = window.screenY + (window.outerHeight - height) / 2;\n localStorage.setItem(SocialLoginWeb.OAUTH_STATE_KEY, 'true');\n const popup = window.open(url, 'Google Sign In', `width=${width},height=${height},left=${left},top=${top},popup=1`);\n // This may never return...\n return new Promise((resolve, reject) => {\n if (!popup) {\n reject(new Error('Failed to open popup'));\n return;\n }\n const handleMessage = (event) => {\n var _a;\n if (event.origin !== window.location.origin)\n return;\n if (((_a = event.data) === null || _a === void 0 ? void 0 : _a.type) === 'oauth-response') {\n window.removeEventListener('message', handleMessage);\n if (this.googleLoginType === 'online') {\n const { accessToken, idToken } = event.data;\n if (accessToken && idToken) {\n const profile = this.parseJwt(idToken);\n this.persistStateGoogle(accessToken.token, idToken);\n resolve({\n provider: 'google',\n result: {\n accessToken: {\n token: accessToken.token,\n },\n idToken,\n profile: {\n email: profile.email || null,\n familyName: profile.family_name || null,\n givenName: profile.given_name || null,\n id: profile.sub || null,\n name: profile.name || null,\n imageUrl: profile.picture || null,\n },\n responseType: 'online',\n },\n });\n }\n }\n else {\n const { serverAuthCode } = event.data.result;\n resolve({\n provider: 'google',\n result: {\n responseType: 'offline',\n serverAuthCode,\n },\n });\n }\n }\n else {\n reject(new Error('Login failed'));\n }\n };\n window.addEventListener('message', handleMessage);\n // Timeout after 5 minutes\n setTimeout(() => {\n window.removeEventListener('message', handleMessage);\n popup.close();\n reject(new Error('OAuth timeout'));\n }, 300000);\n });\n }\n}\nSocialLoginWeb.OAUTH_STATE_KEY = 'social_login_oauth_pending';\n//# sourceMappingURL=web.js.map"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I,IAAI;AAClE,wCAAwC,QAAQ,EAAE,OAAO,CAAC,OAAO,IAAI,IAAI;AACzE,qCAAqC;AACrC,oCAAoC,YAAY,EAAE,QAAQ;AAC1D,iCAAiC;AACjC,6BAA6B,CAAC;AAC9B;AACA;AACA,yBAAyB;AACzB,wBAAwB,MAAM,EAAE,cAAc,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM;AACpE,wBAAwB,OAAO,CAAC;AAChC,4BAA4B,QAAQ,EAAE,QAAQ;AAC9C,4BAA4B,MAAM,EAAE;AACpC,gCAAgC,YAAY,EAAE,SAAS;AACvD,gCAAgC,cAAc;AAC9C,6BAA6B;AAC7B,yBAAyB,CAAC;AAC1B;AACA;AACA,qBAAqB;AACrB,oBAAoB,MAAM,CAAC,IAAI,KAAK,CAAC,cAAc,CAAC,CAAC;AACrD;AACA,aAAa;AACb,YAAY,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,aAAa,CAAC;AAC7D;AACA,YAAY,UAAU,CAAC,MAAM;AAC7B,gBAAgB,MAAM,CAAC,mBAAmB,CAAC,SAAS,EAAE,aAAa,CAAC;AACpE,gBAAgB,KAAK,CAAC,KAAK,EAAE;AAC7B,gBAAgB,MAAM,CAAC,IAAI,KAAK,CAAC,eAAe,CAAC,CAAC;AAClD,aAAa,EAAE,MAAM,CAAC;AACtB,SAAS,CAAC;AACV;AACA;AACA,cAAc,CAAC,eAAe,GAAG,4BAA4B;;;;;;;;;"}
1
+ {"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst SocialLogin = registerPlugin('SocialLogin', {\n web: () => import('./web').then((m) => new m.SocialLoginWeb()),\n});\nexport * from './definitions';\nexport { SocialLogin };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class SocialLoginWeb extends WebPlugin {\n constructor() {\n var _a;\n super();\n this.googleClientId = null;\n this.appleClientId = null;\n this.googleScriptLoaded = false;\n this.googleLoginType = 'online';\n this.appleScriptLoaded = false;\n this.appleScriptUrl = 'https://appleid.cdn-apple.com/appleauth/static/jsapi/appleid/1/en_US/appleid.auth.js';\n this.GOOGLE_TOKEN_REQUEST_URL = 'https://www.googleapis.com/oauth2/v3/tokeninfo';\n this.facebookAppId = null;\n this.facebookScriptLoaded = false;\n // Set up listener for OAuth redirects if we have a pending OAuth flow\n if (localStorage.getItem(SocialLoginWeb.OAUTH_STATE_KEY)) {\n console.log('OAUTH_STATE_KEY found');\n const result = this.handleOAuthRedirect();\n if (result) {\n (_a = window.opener) === null || _a === void 0 ? void 0 : _a.postMessage(Object.assign({ type: 'oauth-response' }, result.result), window.location.origin);\n window.close();\n }\n }\n }\n handleOAuthRedirect() {\n const paramsRaw = new URL(window.location.href).searchParams;\n const code = paramsRaw.get('code');\n if (code && paramsRaw.has('scope')) {\n return {\n provider: 'google',\n result: {\n provider: 'google',\n result: {\n serverAuthCode: code,\n },\n },\n };\n }\n const hash = window.location.hash.substring(1);\n console.log('handleOAuthRedirect', window.location.hash);\n if (!hash)\n return;\n console.log('handleOAuthRedirect ok');\n const params = new URLSearchParams(hash);\n const accessToken = params.get('access_token');\n const idToken = params.get('id_token');\n if (accessToken && idToken) {\n localStorage.removeItem(SocialLoginWeb.OAUTH_STATE_KEY);\n const profile = this.parseJwt(idToken);\n return {\n provider: 'google',\n result: {\n accessToken: {\n token: accessToken,\n },\n idToken,\n profile: {\n email: profile.email || null,\n familyName: profile.family_name || null,\n givenName: profile.given_name || null,\n id: profile.sub || null,\n name: profile.name || null,\n imageUrl: profile.picture || null,\n },\n },\n };\n }\n return null;\n }\n async initialize(options) {\n var _a, _b, _c;\n if ((_a = options.google) === null || _a === void 0 ? void 0 : _a.webClientId) {\n this.googleClientId = options.google.webClientId;\n if (options.google.mode) {\n this.googleLoginType = options.google.mode;\n }\n this.googleHostedDomain = options.google.hostedDomain;\n await this.loadGoogleScript();\n }\n if ((_b = options.apple) === null || _b === void 0 ? void 0 : _b.clientId) {\n this.appleClientId = options.apple.clientId;\n await this.loadAppleScript();\n }\n if ((_c = options.facebook) === null || _c === void 0 ? void 0 : _c.appId) {\n this.facebookAppId = options.facebook.appId;\n await this.loadFacebookScript();\n FB.init({\n appId: this.facebookAppId,\n version: 'v17.0',\n xfbml: true,\n cookie: true,\n });\n }\n // Implement initialization for other providers if needed\n }\n async login(options) {\n switch (options.provider) {\n case 'google':\n return this.loginWithGoogle(options.options);\n case 'apple':\n return this.loginWithApple(options.options);\n case 'facebook':\n return this.loginWithFacebook(options.options);\n default:\n throw new Error(`Login for ${options.provider} is not implemented on web`);\n }\n }\n async logout(options) {\n switch (options.provider) {\n case 'google':\n if (this.googleLoginType === 'offline') {\n return Promise.reject(\"Offline login doesn't store tokens. logout is not available\");\n }\n // Google doesn't have a specific logout method for web\n // We can revoke the token if we have it stored\n console.log('Google logout: Id token should be revoked on the client side if stored');\n // eslint-disable-next-line\n const state = this.getGoogleState();\n if (!state)\n return;\n await this.rawLogoutGoogle(state.accessToken);\n break;\n case 'apple':\n // Apple doesn't provide a logout method for web\n console.log('Apple logout: Session should be managed on the client side');\n break;\n case 'facebook':\n return new Promise((resolve) => {\n FB.logout(() => resolve());\n });\n default:\n throw new Error(`Logout for ${options.provider} is not implemented`);\n }\n }\n async accessTokenIsValid(accessToken) {\n const url = `${this.GOOGLE_TOKEN_REQUEST_URL}?access_token=${encodeURIComponent(accessToken)}`;\n try {\n // Make the GET request using fetch\n const response = await fetch(url);\n // Check if the response is successful\n if (!response.ok) {\n console.log(`Invalid response from ${this.GOOGLE_TOKEN_REQUEST_URL}. Response not successful. Status code: ${response.status}. Assuming that the token is not valid`);\n return false;\n }\n // Get the response body as text\n const responseBody = await response.text();\n if (!responseBody) {\n console.error(`Invalid response from ${this.GOOGLE_TOKEN_REQUEST_URL}. Response body is null`);\n throw new Error(`Invalid response from ${this.GOOGLE_TOKEN_REQUEST_URL}. Response body is null`);\n }\n // Parse the response body as JSON\n let jsonObject;\n try {\n jsonObject = JSON.parse(responseBody);\n }\n catch (e) {\n console.error(`Invalid response from ${this.GOOGLE_TOKEN_REQUEST_URL}. Response body is not valid JSON. Error: ${e}`);\n throw new Error(`Invalid response from ${this.GOOGLE_TOKEN_REQUEST_URL}. Response body is not valid JSON. Error: ${e}`);\n }\n // Extract the 'expires_in' field\n const expiresInStr = jsonObject['expires_in'];\n if (expiresInStr === undefined || expiresInStr === null) {\n console.error(`Invalid response from ${this.GOOGLE_TOKEN_REQUEST_URL}. Response JSON does not include 'expires_in'.`);\n throw new Error(`Invalid response from ${this.GOOGLE_TOKEN_REQUEST_URL}. Response JSON does not include 'expires_in'.`);\n }\n // Parse 'expires_in' as an integer\n let expiresInInt;\n try {\n expiresInInt = parseInt(expiresInStr, 10);\n if (isNaN(expiresInInt)) {\n throw new Error(`'expires_in' is not a valid integer`);\n }\n }\n catch (e) {\n console.error(`Invalid response from ${this.GOOGLE_TOKEN_REQUEST_URL}. 'expires_in': ${expiresInStr} is not a valid integer. Error: ${e}`);\n throw new Error(`Invalid response from ${this.GOOGLE_TOKEN_REQUEST_URL}. 'expires_in': ${expiresInStr} is not a valid integer. Error: ${e}`);\n }\n // Determine if the access token is valid based on 'expires_in'\n return expiresInInt > 5;\n }\n catch (error) {\n console.error(error);\n throw error;\n }\n }\n idTokenValid(idToken) {\n try {\n const parsed = this.parseJwt(idToken);\n const currentTime = Math.ceil(Date.now() / 1000) + 5; // Convert current time to seconds since epoch\n return parsed.exp && currentTime < parsed.exp;\n }\n catch (e) {\n return false;\n }\n }\n async rawLogoutGoogle(accessToken, tokenValid = null) {\n if (tokenValid === null) {\n tokenValid = await this.accessTokenIsValid(accessToken);\n }\n if (tokenValid === true) {\n return new Promise((resolve, reject) => {\n try {\n google.accounts.oauth2.revoke(accessToken, async () => {\n this.clearStateGoogle();\n resolve();\n });\n }\n catch (e) {\n reject(e);\n }\n });\n }\n else {\n this.clearStateGoogle();\n return;\n }\n }\n async isLoggedIn(options) {\n switch (options.provider) {\n case 'google':\n if (this.googleLoginType === 'offline') {\n return Promise.reject(\"Offline login doesn't store tokens. isLoggedIn is not available\");\n }\n // For Google, we can check if there's a valid token\n // eslint-disable-next-line\n const state = this.getGoogleState();\n if (!state)\n return { isLoggedIn: false };\n try {\n // todo: cache accessTokenIsValid calls\n const isValidAccessToken = await this.accessTokenIsValid(state.accessToken);\n const isValidIdToken = this.idTokenValid(state.idToken);\n if (isValidAccessToken && isValidIdToken) {\n return { isLoggedIn: true };\n }\n else {\n try {\n await this.rawLogoutGoogle(state.accessToken, false);\n }\n catch (e) {\n console.error('Access token is not valid, but cannot logout', e);\n }\n return { isLoggedIn: false };\n }\n }\n catch (e) {\n return Promise.reject(e);\n }\n case 'apple':\n // Apple doesn't provide a method to check login status on web\n console.log('Apple login status should be managed on the client side');\n return { isLoggedIn: false };\n case 'facebook':\n return new Promise((resolve) => {\n FB.getLoginStatus((response) => {\n resolve({ isLoggedIn: response.status === 'connected' });\n });\n });\n default:\n throw new Error(`isLoggedIn for ${options.provider} is not implemented`);\n }\n }\n async getAuthorizationCode(options) {\n switch (options.provider) {\n case 'google':\n if (this.googleLoginType === 'offline') {\n return Promise.reject(\"Offline login doesn't store tokens. getAuthorizationCode is not available\");\n }\n // For Google, we can use the id_token as the authorization code\n // eslint-disable-next-line\n const state = this.getGoogleState();\n if (!state)\n throw new Error('No Google authorization code available');\n try {\n // todo: cache accessTokenIsValid calls\n const isValidAccessToken = await this.accessTokenIsValid(state.accessToken);\n const isValidIdToken = this.idTokenValid(state.idToken);\n if (isValidAccessToken && isValidIdToken) {\n return { accessToken: state.accessToken, jwt: state.idToken };\n }\n else {\n try {\n await this.rawLogoutGoogle(state.accessToken, false);\n }\n catch (e) {\n console.error('Access token is not valid, but cannot logout', e);\n }\n throw new Error('No Google authorization code available');\n }\n }\n catch (e) {\n return Promise.reject(e);\n }\n case 'apple':\n // Apple authorization code should be obtained during login\n console.log('Apple authorization code should be stored during login');\n throw new Error('Apple authorization code not available');\n case 'facebook':\n return new Promise((resolve, reject) => {\n FB.getLoginStatus((response) => {\n var _a;\n if (response.status === 'connected') {\n resolve({ jwt: ((_a = response.authResponse) === null || _a === void 0 ? void 0 : _a.accessToken) || '' });\n }\n else {\n reject(new Error('No Facebook authorization code available'));\n }\n });\n });\n default:\n throw new Error(`getAuthorizationCode for ${options.provider} is not implemented`);\n }\n }\n async refresh(options) {\n switch (options.provider) {\n case 'google':\n // For Google, we can prompt for re-authentication\n return Promise.reject('Not implemented');\n case 'apple':\n // Apple doesn't provide a refresh method for web\n console.log('Apple refresh not available on web');\n break;\n case 'facebook':\n await this.loginWithFacebook(options.options);\n break;\n default:\n throw new Error(`Refresh for ${options.provider} is not implemented`);\n }\n }\n loginWithGoogle(options) {\n if (!this.googleClientId) {\n throw new Error('Google Client ID not set. Call initialize() first.');\n }\n let scopes = options.scopes || [];\n if (scopes.length > 0) {\n // If scopes are provided, directly use the traditional OAuth flow\n if (!scopes.includes('https://www.googleapis.com/auth/userinfo.email')) {\n scopes.push('https://www.googleapis.com/auth/userinfo.email');\n }\n if (!scopes.includes('https://www.googleapis.com/auth/userinfo.profile')) {\n scopes.push('https://www.googleapis.com/auth/userinfo.profile');\n }\n if (!scopes.includes('openid')) {\n scopes.push('openid');\n }\n }\n else {\n scopes = [\n 'https://www.googleapis.com/auth/userinfo.email',\n 'https://www.googleapis.com/auth/userinfo.profile',\n 'openid',\n ];\n }\n if (scopes.length > 3 || this.googleLoginType === 'offline' || options.disableOneTap) {\n // If scopes are provided, directly use the traditional OAuth flow\n return this.fallbackToTraditionalOAuth(scopes, this.googleHostedDomain);\n }\n return new Promise((resolve, reject) => {\n google.accounts.id.initialize({\n client_id: this.googleClientId,\n hd: this.googleHostedDomain,\n callback: (response) => {\n console.log('google.accounts.id.initialize callback', response);\n if (response.error) {\n // we use any because type fail but we need to double check if that works\n reject(response.error);\n }\n else {\n const payload = this.parseJwt(response.credential);\n const result = {\n accessToken: null,\n responseType: 'online',\n idToken: response.credential,\n profile: {\n email: payload.email || null,\n familyName: payload.family_name || null,\n givenName: payload.given_name || null,\n id: payload.sub || null,\n name: payload.name || null,\n imageUrl: payload.picture || null,\n },\n };\n resolve({ provider: 'google', result });\n }\n },\n auto_select: true,\n });\n google.accounts.id.prompt((notification) => {\n if (notification.isNotDisplayed() || notification.isSkippedMoment()) {\n console.log('OneTap is not displayed or skipped');\n // Fallback to traditional OAuth if One Tap is not available\n this.fallbackToTraditionalOAuth(scopes, this.googleHostedDomain)\n .then((r) => resolve({ provider: 'google', result: r.result }))\n .catch(reject);\n }\n else {\n console.log('OneTap is displayed');\n }\n });\n });\n }\n parseJwt(token) {\n const base64Url = token.split('.')[1];\n const base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/');\n const jsonPayload = decodeURIComponent(atob(base64)\n .split('')\n .map((c) => {\n return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);\n })\n .join(''));\n return JSON.parse(jsonPayload);\n }\n async loadGoogleScript() {\n if (this.googleScriptLoaded)\n return;\n return new Promise((resolve, reject) => {\n const script = document.createElement('script');\n script.src = 'https://accounts.google.com/gsi/client';\n script.async = true;\n script.onload = () => {\n this.googleScriptLoaded = true;\n resolve();\n };\n script.onerror = reject;\n document.body.appendChild(script);\n });\n }\n async loginWithApple(options) {\n if (!this.appleClientId) {\n throw new Error('Apple Client ID not set. Call initialize() first.');\n }\n if (!this.appleScriptLoaded) {\n throw new Error('Apple Sign-In script not loaded.');\n }\n return new Promise((resolve, reject) => {\n var _a;\n AppleID.auth.init({\n clientId: this.appleClientId,\n scope: ((_a = options.scopes) === null || _a === void 0 ? void 0 : _a.join(' ')) || 'name email',\n redirectURI: options.redirectUrl || window.location.href,\n state: options.state,\n nonce: options.nonce,\n usePopup: true,\n });\n AppleID.auth\n .signIn()\n .then((res) => {\n var _a, _b, _c, _d, _e, _f, _g;\n const result = {\n profile: {\n user: ((_b = (_a = res.user) === null || _a === void 0 ? void 0 : _a.name) === null || _b === void 0 ? void 0 : _b.firstName) ? `${res.user.name.firstName} ${res.user.name.lastName}` : '',\n email: ((_c = res.user) === null || _c === void 0 ? void 0 : _c.email) || null,\n givenName: ((_e = (_d = res.user) === null || _d === void 0 ? void 0 : _d.name) === null || _e === void 0 ? void 0 : _e.firstName) || null,\n familyName: ((_g = (_f = res.user) === null || _f === void 0 ? void 0 : _f.name) === null || _g === void 0 ? void 0 : _g.lastName) || null,\n },\n accessToken: {\n token: res.authorization.code, // TODO: to fix and find the correct token\n },\n idToken: res.authorization.id_token || null,\n };\n resolve({ provider: 'apple', result });\n })\n .catch((error) => {\n reject(error);\n });\n });\n }\n async loadAppleScript() {\n if (this.appleScriptLoaded)\n return;\n return new Promise((resolve, reject) => {\n const script = document.createElement('script');\n script.src = this.appleScriptUrl;\n script.async = true;\n script.onload = () => {\n this.appleScriptLoaded = true;\n resolve();\n };\n script.onerror = reject;\n document.body.appendChild(script);\n });\n }\n persistStateGoogle(accessToken, idToken) {\n try {\n window.localStorage.setItem('capgo_social_login_google_state', JSON.stringify({ accessToken, idToken }));\n }\n catch (e) {\n console.error('Cannot persist state google', e);\n }\n }\n clearStateGoogle() {\n try {\n window.localStorage.removeItem('capgo_social_login_google_state');\n }\n catch (e) {\n console.error('Cannot clear state google', e);\n }\n }\n getGoogleState() {\n try {\n const state = window.localStorage.getItem('capgo_social_login_google_state');\n if (!state)\n return null;\n const { accessToken, idToken } = JSON.parse(state);\n return { accessToken, idToken };\n }\n catch (e) {\n console.error('Cannot get state google', e);\n return null;\n }\n }\n async loadFacebookScript() {\n if (this.facebookScriptLoaded)\n return;\n return new Promise((resolve, reject) => {\n const script = document.createElement('script');\n script.src = 'https://connect.facebook.net/en_US/sdk.js';\n script.async = true;\n script.defer = true;\n script.onload = () => {\n this.facebookScriptLoaded = true;\n resolve();\n };\n script.onerror = reject;\n document.body.appendChild(script);\n });\n }\n async loginWithFacebook(options) {\n if (!this.facebookAppId) {\n throw new Error('Facebook App ID not set. Call initialize() first.');\n }\n return new Promise((resolve, reject) => {\n FB.login((response) => {\n if (response.status === 'connected') {\n FB.api('/me', { fields: 'id,name,email,picture' }, (userInfo) => {\n var _a, _b;\n const result = {\n accessToken: {\n token: response.authResponse.accessToken,\n userId: response.authResponse.userID,\n },\n profile: {\n userID: userInfo.id,\n name: userInfo.name,\n email: userInfo.email || null,\n imageURL: ((_b = (_a = userInfo.picture) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.url) || null,\n friendIDs: [],\n birthday: null,\n ageRange: null,\n gender: null,\n location: null,\n hometown: null,\n profileURL: null,\n },\n idToken: null,\n };\n resolve({ provider: 'facebook', result });\n });\n }\n else {\n reject(new Error('Facebook login failed'));\n }\n }, { scope: options.permissions.join(',') });\n });\n }\n async fallbackToTraditionalOAuth(scopes, hostedDomain) {\n const uniqueScopes = [...new Set([...scopes, 'openid'])];\n const params = new URLSearchParams({\n client_id: this.googleClientId,\n redirect_uri: window.location.href,\n response_type: this.googleLoginType === 'offline' ? 'code' : 'token id_token',\n scope: uniqueScopes.join(' '),\n nonce: Math.random().toString(36).substring(2),\n include_granted_scopes: 'true',\n state: 'popup',\n });\n if (hostedDomain !== undefined) {\n params.append('hd', hostedDomain);\n }\n const url = `https://accounts.google.com/o/oauth2/v2/auth?${params.toString()}`;\n const width = 500;\n const height = 600;\n const left = window.screenX + (window.outerWidth - width) / 2;\n const top = window.screenY + (window.outerHeight - height) / 2;\n localStorage.setItem(SocialLoginWeb.OAUTH_STATE_KEY, 'true');\n const popup = window.open(url, 'Google Sign In', `width=${width},height=${height},left=${left},top=${top},popup=1`);\n // This may never return...\n return new Promise((resolve, reject) => {\n if (!popup) {\n reject(new Error('Failed to open popup'));\n return;\n }\n const handleMessage = (event) => {\n var _a;\n if (event.origin !== window.location.origin)\n return;\n if (((_a = event.data) === null || _a === void 0 ? void 0 : _a.type) === 'oauth-response') {\n window.removeEventListener('message', handleMessage);\n if (this.googleLoginType === 'online') {\n const { accessToken, idToken } = event.data;\n if (accessToken && idToken) {\n const profile = this.parseJwt(idToken);\n this.persistStateGoogle(accessToken.token, idToken);\n resolve({\n provider: 'google',\n result: {\n accessToken: {\n token: accessToken.token,\n },\n idToken,\n profile: {\n email: profile.email || null,\n familyName: profile.family_name || null,\n givenName: profile.given_name || null,\n id: profile.sub || null,\n name: profile.name || null,\n imageUrl: profile.picture || null,\n },\n responseType: 'online',\n },\n });\n }\n }\n else {\n const { serverAuthCode } = event.data.result;\n resolve({\n provider: 'google',\n result: {\n responseType: 'offline',\n serverAuthCode,\n },\n });\n }\n }\n else {\n reject(new Error('Login failed'));\n }\n };\n window.addEventListener('message', handleMessage);\n // Timeout after 5 minutes\n setTimeout(() => {\n window.removeEventListener('message', handleMessage);\n popup.close();\n reject(new Error('OAuth timeout'));\n }, 300000);\n });\n }\n}\nSocialLoginWeb.OAUTH_STATE_KEY = 'social_login_oauth_pending';\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;AACK,MAAC,WAAW,GAAGA,mBAAc,CAAC,aAAa,EAAE;AAClD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,cAAc,EAAE,CAAC;AAClE,CAAC;;ACFM,MAAM,cAAc,SAASC,cAAS,CAAC;AAC9C,IAAI,WAAW,GAAG;AAClB,QAAQ,IAAI,EAAE;AACd,QAAQ,KAAK,EAAE;AACf,QAAQ,IAAI,CAAC,cAAc,GAAG,IAAI;AAClC,QAAQ,IAAI,CAAC,aAAa,GAAG,IAAI;AACjC,QAAQ,IAAI,CAAC,kBAAkB,GAAG,KAAK;AACvC,QAAQ,IAAI,CAAC,eAAe,GAAG,QAAQ;AACvC,QAAQ,IAAI,CAAC,iBAAiB,GAAG,KAAK;AACtC,QAAQ,IAAI,CAAC,cAAc,GAAG,sFAAsF;AACpH,QAAQ,IAAI,CAAC,wBAAwB,GAAG,gDAAgD;AACxF,QAAQ,IAAI,CAAC,aAAa,GAAG,IAAI;AACjC,QAAQ,IAAI,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;AAC7B,yBAAyB,CAAC;AAC1B;AACA;AACA,qBAAqB;AACrB,oBAAoB,MAAM,CAAC,IAAI,KAAK,CAAC,cAAc,CAAC,CAAC;AACrD;AACA,aAAa;AACb,YAAY,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,aAAa,CAAC;AAC7D;AACA,YAAY,UAAU,CAAC,MAAM;AAC7B,gBAAgB,MAAM,CAAC,mBAAmB,CAAC,SAAS,EAAE,aAAa,CAAC;AACpE,gBAAgB,KAAK,CAAC,KAAK,EAAE;AAC7B,gBAAgB,MAAM,CAAC,IAAI,KAAK,CAAC,eAAe,CAAC,CAAC;AAClD,aAAa,EAAE,MAAM,CAAC;AACtB,SAAS,CAAC;AACV;AACA;AACA,cAAc,CAAC,eAAe,GAAG,4BAA4B;;;;;;;;;"}
package/dist/plugin.js CHANGED
@@ -23,7 +23,7 @@ var capacitorCapacitorUpdater = (function (exports, core) {
23
23
  console.log('OAUTH_STATE_KEY found');
24
24
  const result = this.handleOAuthRedirect();
25
25
  if (result) {
26
- (_a = window.opener) === null || _a === undefined ? undefined : _a.postMessage(Object.assign({ type: 'oauth-response' }, result.result), window.location.origin);
26
+ (_a = window.opener) === null || _a === void 0 ? void 0 : _a.postMessage(Object.assign({ type: 'oauth-response' }, result.result), window.location.origin);
27
27
  window.close();
28
28
  }
29
29
  }
@@ -75,18 +75,19 @@ var capacitorCapacitorUpdater = (function (exports, core) {
75
75
  }
76
76
  async initialize(options) {
77
77
  var _a, _b, _c;
78
- if ((_a = options.google) === null || _a === undefined ? undefined : _a.webClientId) {
78
+ if ((_a = options.google) === null || _a === void 0 ? void 0 : _a.webClientId) {
79
79
  this.googleClientId = options.google.webClientId;
80
80
  if (options.google.mode) {
81
81
  this.googleLoginType = options.google.mode;
82
82
  }
83
+ this.googleHostedDomain = options.google.hostedDomain;
83
84
  await this.loadGoogleScript();
84
85
  }
85
- if ((_b = options.apple) === null || _b === undefined ? undefined : _b.clientId) {
86
+ if ((_b = options.apple) === null || _b === void 0 ? void 0 : _b.clientId) {
86
87
  this.appleClientId = options.apple.clientId;
87
88
  await this.loadAppleScript();
88
89
  }
89
- if ((_c = options.facebook) === null || _c === undefined ? undefined : _c.appId) {
90
+ if ((_c = options.facebook) === null || _c === void 0 ? void 0 : _c.appId) {
90
91
  this.facebookAppId = options.facebook.appId;
91
92
  await this.loadFacebookScript();
92
93
  FB.init({
@@ -305,7 +306,7 @@ var capacitorCapacitorUpdater = (function (exports, core) {
305
306
  FB.getLoginStatus((response) => {
306
307
  var _a;
307
308
  if (response.status === 'connected') {
308
- resolve({ jwt: ((_a = response.authResponse) === null || _a === undefined ? undefined : _a.accessToken) || '' });
309
+ resolve({ jwt: ((_a = response.authResponse) === null || _a === void 0 ? void 0 : _a.accessToken) || '' });
309
310
  }
310
311
  else {
311
312
  reject(new Error('No Facebook authorization code available'));
@@ -358,11 +359,12 @@ var capacitorCapacitorUpdater = (function (exports, core) {
358
359
  }
359
360
  if (scopes.length > 3 || this.googleLoginType === 'offline' || options.disableOneTap) {
360
361
  // If scopes are provided, directly use the traditional OAuth flow
361
- return this.fallbackToTraditionalOAuth(scopes);
362
+ return this.fallbackToTraditionalOAuth(scopes, this.googleHostedDomain);
362
363
  }
363
364
  return new Promise((resolve, reject) => {
364
365
  google.accounts.id.initialize({
365
366
  client_id: this.googleClientId,
367
+ hd: this.googleHostedDomain,
366
368
  callback: (response) => {
367
369
  console.log('google.accounts.id.initialize callback', response);
368
370
  if (response.error) {
@@ -393,7 +395,7 @@ var capacitorCapacitorUpdater = (function (exports, core) {
393
395
  if (notification.isNotDisplayed() || notification.isSkippedMoment()) {
394
396
  console.log('OneTap is not displayed or skipped');
395
397
  // Fallback to traditional OAuth if One Tap is not available
396
- this.fallbackToTraditionalOAuth(scopes)
398
+ this.fallbackToTraditionalOAuth(scopes, this.googleHostedDomain)
397
399
  .then((r) => resolve({ provider: 'google', result: r.result }))
398
400
  .catch(reject);
399
401
  }
@@ -440,7 +442,7 @@ var capacitorCapacitorUpdater = (function (exports, core) {
440
442
  var _a;
441
443
  AppleID.auth.init({
442
444
  clientId: this.appleClientId,
443
- scope: ((_a = options.scopes) === null || _a === undefined ? undefined : _a.join(' ')) || 'name email',
445
+ scope: ((_a = options.scopes) === null || _a === void 0 ? void 0 : _a.join(' ')) || 'name email',
444
446
  redirectURI: options.redirectUrl || window.location.href,
445
447
  state: options.state,
446
448
  nonce: options.nonce,
@@ -452,10 +454,10 @@ var capacitorCapacitorUpdater = (function (exports, core) {
452
454
  var _a, _b, _c, _d, _e, _f, _g;
453
455
  const result = {
454
456
  profile: {
455
- user: ((_b = (_a = res.user) === null || _a === undefined ? undefined : _a.name) === null || _b === undefined ? undefined : _b.firstName) ? `${res.user.name.firstName} ${res.user.name.lastName}` : '',
456
- email: ((_c = res.user) === null || _c === undefined ? undefined : _c.email) || null,
457
- givenName: ((_e = (_d = res.user) === null || _d === undefined ? undefined : _d.name) === null || _e === undefined ? undefined : _e.firstName) || null,
458
- familyName: ((_g = (_f = res.user) === null || _f === undefined ? undefined : _f.name) === null || _g === undefined ? undefined : _g.lastName) || null,
457
+ user: ((_b = (_a = res.user) === null || _a === void 0 ? void 0 : _a.name) === null || _b === void 0 ? void 0 : _b.firstName) ? `${res.user.name.firstName} ${res.user.name.lastName}` : '',
458
+ email: ((_c = res.user) === null || _c === void 0 ? void 0 : _c.email) || null,
459
+ givenName: ((_e = (_d = res.user) === null || _d === void 0 ? void 0 : _d.name) === null || _e === void 0 ? void 0 : _e.firstName) || null,
460
+ familyName: ((_g = (_f = res.user) === null || _f === void 0 ? void 0 : _f.name) === null || _g === void 0 ? void 0 : _g.lastName) || null,
459
461
  },
460
462
  accessToken: {
461
463
  token: res.authorization.code, // TODO: to fix and find the correct token
@@ -547,7 +549,7 @@ var capacitorCapacitorUpdater = (function (exports, core) {
547
549
  userID: userInfo.id,
548
550
  name: userInfo.name,
549
551
  email: userInfo.email || null,
550
- imageURL: ((_b = (_a = userInfo.picture) === null || _a === undefined ? undefined : _a.data) === null || _b === undefined ? undefined : _b.url) || null,
552
+ imageURL: ((_b = (_a = userInfo.picture) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.url) || null,
551
553
  friendIDs: [],
552
554
  birthday: null,
553
555
  ageRange: null,
@@ -567,7 +569,7 @@ var capacitorCapacitorUpdater = (function (exports, core) {
567
569
  }, { scope: options.permissions.join(',') });
568
570
  });
569
571
  }
570
- async fallbackToTraditionalOAuth(scopes) {
572
+ async fallbackToTraditionalOAuth(scopes, hostedDomain) {
571
573
  const uniqueScopes = [...new Set([...scopes, 'openid'])];
572
574
  const params = new URLSearchParams({
573
575
  client_id: this.googleClientId,
@@ -578,6 +580,9 @@ var capacitorCapacitorUpdater = (function (exports, core) {
578
580
  include_granted_scopes: 'true',
579
581
  state: 'popup',
580
582
  });
583
+ if (hostedDomain !== undefined) {
584
+ params.append('hd', hostedDomain);
585
+ }
581
586
  const url = `https://accounts.google.com/o/oauth2/v2/auth?${params.toString()}`;
582
587
  const width = 500;
583
588
  const height = 600;
@@ -595,7 +600,7 @@ var capacitorCapacitorUpdater = (function (exports, core) {
595
600
  var _a;
596
601
  if (event.origin !== window.location.origin)
597
602
  return;
598
- if (((_a = event.data) === null || _a === undefined ? undefined : _a.type) === 'oauth-response') {
603
+ if (((_a = event.data) === null || _a === void 0 ? void 0 : _a.type) === 'oauth-response') {
599
604
  window.removeEventListener('message', handleMessage);
600
605
  if (this.googleLoginType === 'online') {
601
606
  const { accessToken, idToken } = event.data;