@capgo/capacitor-social-login 8.3.17 → 8.3.18

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
@@ -854,13 +854,21 @@ var capacitorCapacitorUpdater = (function (exports, core) {
854
854
  reject(new Error('Failed to open popup'));
855
855
  return;
856
856
  }
857
- const cleanup = () => {
857
+ const cleanup = (shouldClose = false) => {
858
858
  window.removeEventListener('message', handleMessage);
859
859
  clearInterval(popupClosedInterval);
860
860
  clearTimeout(timeoutHandle);
861
861
  if (broadcastChannel) {
862
862
  broadcastChannel.close();
863
863
  }
864
+ if (shouldClose) {
865
+ try {
866
+ popup.close();
867
+ }
868
+ catch (_a) {
869
+ // Ignore cross-origin errors when closing the popup
870
+ }
871
+ }
864
872
  };
865
873
  const processOAuthResponse = (data) => {
866
874
  if (this.loginType === 'online') {
@@ -911,11 +919,11 @@ var capacitorCapacitorUpdater = (function (exports, core) {
911
919
  if (event.origin !== window.location.origin || ((_b = (_a = event.data) === null || _a === void 0 ? void 0 : _a.source) === null || _b === void 0 ? void 0 : _b.startsWith('angular')))
912
920
  return;
913
921
  if (((_c = event.data) === null || _c === void 0 ? void 0 : _c.type) === 'oauth-response') {
914
- cleanup();
922
+ cleanup(true);
915
923
  processOAuthResponse(event.data);
916
924
  }
917
925
  else if (((_d = event.data) === null || _d === void 0 ? void 0 : _d.type) === 'oauth-error') {
918
- cleanup();
926
+ cleanup(true);
919
927
  const errorMessage = event.data.error || 'User cancelled the OAuth flow';
920
928
  reject(new Error(errorMessage));
921
929
  }
@@ -929,11 +937,11 @@ var capacitorCapacitorUpdater = (function (exports, core) {
929
937
  if ((_a = data === null || data === void 0 ? void 0 : data.source) === null || _a === void 0 ? void 0 : _a.toString().startsWith('angular'))
930
938
  return;
931
939
  if ((data === null || data === void 0 ? void 0 : data.type) === 'oauth-response') {
932
- cleanup();
940
+ cleanup(true);
933
941
  processOAuthResponse(data);
934
942
  }
935
943
  else if ((data === null || data === void 0 ? void 0 : data.type) === 'oauth-error') {
936
- cleanup();
944
+ cleanup(true);
937
945
  const errorMessage = data.error || 'User cancelled the OAuth flow';
938
946
  reject(new Error(errorMessage));
939
947
  }
@@ -942,13 +950,7 @@ var capacitorCapacitorUpdater = (function (exports, core) {
942
950
  window.addEventListener('message', handleMessage);
943
951
  // Timeout after 5 minutes
944
952
  timeoutHandle = setTimeout(() => {
945
- cleanup();
946
- try {
947
- popup.close();
948
- }
949
- catch (_a) {
950
- // Ignore cross-origin errors when closing
951
- }
953
+ cleanup(true);
952
954
  reject(new Error('OAuth timeout'));
953
955
  }, 300000);
954
956
  popupClosedInterval = setInterval(() => {
@@ -1008,6 +1010,7 @@ var capacitorCapacitorUpdater = (function (exports, core) {
1008
1010
  }
1009
1011
  return {
1010
1012
  appId,
1013
+ clientSecret: config.clientSecret,
1011
1014
  issuerUrl: config.issuerUrl,
1012
1015
  authorizationBaseUrl,
1013
1016
  accessTokenEndpoint,
@@ -1470,6 +1473,9 @@ var capacitorCapacitorUpdater = (function (exports, core) {
1470
1473
  if (config.pkceEnabled) {
1471
1474
  params.set('code_verifier', pending.codeVerifier);
1472
1475
  }
1476
+ if (config.clientSecret) {
1477
+ params.set('client_secret', config.clientSecret);
1478
+ }
1473
1479
  if (config.additionalTokenParameters) {
1474
1480
  for (const [k, v] of Object.entries(config.additionalTokenParameters)) {
1475
1481
  params.set(k, v);
@@ -1501,6 +1507,9 @@ var capacitorCapacitorUpdater = (function (exports, core) {
1501
1507
  refresh_token: refreshToken,
1502
1508
  client_id: config.appId,
1503
1509
  });
1510
+ if (config.clientSecret) {
1511
+ params.set('client_secret', config.clientSecret);
1512
+ }
1504
1513
  if (config.additionalTokenParameters) {
1505
1514
  for (const [k, v] of Object.entries(config.additionalTokenParameters)) {
1506
1515
  params.set(k, v);