@capgo/capacitor-social-login 8.2.8 → 8.2.9

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/dist/plugin.js CHANGED
@@ -530,7 +530,7 @@ var capacitorCapacitorUpdater = (function (exports, core) {
530
530
  const height = 600;
531
531
  const left = window.screenX + (window.outerWidth - width) / 2;
532
532
  const top = window.screenY + (window.outerHeight - height) / 2;
533
- localStorage.setItem(BaseSocialLogin.OAUTH_STATE_KEY, JSON.stringify({ provider: 'google', loginType: this.loginType }));
533
+ localStorage.setItem(BaseSocialLogin.OAUTH_STATE_KEY, JSON.stringify({ provider: 'google', loginType: this.loginType, nonce }));
534
534
  const popup = window.open(url, 'Google Sign In', `width=${width},height=${height},left=${left},top=${top},popup=1`);
535
535
  let popupClosedInterval;
536
536
  let timeoutHandle;
@@ -582,9 +582,16 @@ var capacitorCapacitorUpdater = (function (exports, core) {
582
582
  },
583
583
  });
584
584
  }
585
+ else {
586
+ reject(new Error('Invalid OAuth response: missing accessToken or idToken'));
587
+ }
585
588
  }
586
589
  else {
587
590
  const { serverAuthCode } = data;
591
+ if (!serverAuthCode) {
592
+ reject(new Error('Invalid OAuth response: missing serverAuthCode'));
593
+ return;
594
+ }
588
595
  resolve({
589
596
  provider: 'google',
590
597
  result: {
@@ -1240,7 +1247,7 @@ var capacitorCapacitorUpdater = (function (exports, core) {
1240
1247
  }
1241
1248
  cleanup(messageHandler, timeoutHandle, popupClosedInterval);
1242
1249
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
1243
- const _a = data, { provider: _ignoredProvider } = _a, payload = __rest(_a, ["provider"]);
1250
+ const _a = data, { provider: _ignoredProvider, type: _ignoredType } = _a, payload = __rest(_a, ["provider", "type"]);
1244
1251
  resolve({
1245
1252
  provider: 'twitter',
1246
1253
  result: payload,
@@ -1548,11 +1555,13 @@ var capacitorCapacitorUpdater = (function (exports, core) {
1548
1555
  const stateRaw = localStorage.getItem(SocialLoginWeb.OAUTH_STATE_KEY);
1549
1556
  let provider = null;
1550
1557
  let state;
1558
+ let nonce;
1551
1559
  if (stateRaw) {
1552
1560
  try {
1553
1561
  const parsed = JSON.parse(stateRaw);
1554
1562
  provider = (_a = parsed.provider) !== null && _a !== void 0 ? _a : null;
1555
1563
  state = parsed.state;
1564
+ nonce = parsed.nonce;
1556
1565
  }
1557
1566
  catch (_b) {
1558
1567
  provider = stateRaw === 'true' ? 'google' : null;
@@ -1600,7 +1609,7 @@ var capacitorCapacitorUpdater = (function (exports, core) {
1600
1609
  // Also use BroadcastChannel as a fallback (works across same-origin windows
1601
1610
  // even when window.opener is not accessible due to cross-origin navigation)
1602
1611
  try {
1603
- // Determine the channel name based on provider and state
1612
+ // Determine the channel name based on provider and state/nonce
1604
1613
  let channelName = null;
1605
1614
  if (provider === 'oauth2' && state) {
1606
1615
  channelName = `oauth2_${state}`;
@@ -1608,9 +1617,8 @@ var capacitorCapacitorUpdater = (function (exports, core) {
1608
1617
  else if (provider === 'twitter' && state) {
1609
1618
  channelName = `twitter_oauth_${state}`;
1610
1619
  }
1611
- else if (provider === 'google') {
1612
- // Google uses nonce which we can't easily recover here, but try anyway
1613
- // The parent window will have created a channel with a nonce-based name
1620
+ else if (provider === 'google' && nonce) {
1621
+ channelName = `google_oauth_${nonce}`;
1614
1622
  }
1615
1623
  if (channelName) {
1616
1624
  const channel = new BroadcastChannel(channelName);