@capgo/capacitor-social-login 8.3.19 → 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/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 +1 -1
- package/dist/esm/facebook-provider.js +3 -2
- 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.js +3 -2
- package/dist/esm/oauth2-provider.js.map +1 -1
- package/dist/esm/twitter-provider.js +3 -2
- 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 +45 -16
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +45 -16
- package/dist/plugin.js.map +1 -1
- package/ios/Sources/SocialLoginPlugin/SocialLoginPlugin.swift +46 -2
- package/package.json +1 -1
package/dist/plugin.js
CHANGED
|
@@ -336,6 +336,36 @@ var capacitorCapacitorUpdater = (function (exports, core) {
|
|
|
336
336
|
}
|
|
337
337
|
BaseSocialLogin.OAUTH_STATE_KEY = 'social_login_oauth_pending';
|
|
338
338
|
|
|
339
|
+
const USER_CANCELLED_CODE = 'USER_CANCELLED';
|
|
340
|
+
const CANCELLED_PATTERNS = [
|
|
341
|
+
'access_denied',
|
|
342
|
+
'access denied',
|
|
343
|
+
'user_cancelled_authorize',
|
|
344
|
+
'user_cancelled',
|
|
345
|
+
'user cancelled',
|
|
346
|
+
'user canceled',
|
|
347
|
+
'login cancelled',
|
|
348
|
+
'login canceled',
|
|
349
|
+
'popup closed',
|
|
350
|
+
'window was closed',
|
|
351
|
+
];
|
|
352
|
+
function createUserCancelledError(message) {
|
|
353
|
+
const error = new Error(message);
|
|
354
|
+
error.code = USER_CANCELLED_CODE;
|
|
355
|
+
return error;
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* Detects cancellation-like messages and marks them with USER_CANCELLED.
|
|
359
|
+
* Falls back to a regular Error when the message doesn't look like a user cancellation.
|
|
360
|
+
*/
|
|
361
|
+
function inferUserCancelledError(message) {
|
|
362
|
+
const normalized = message.toLowerCase();
|
|
363
|
+
if (CANCELLED_PATTERNS.some((pattern) => normalized.includes(pattern))) {
|
|
364
|
+
return createUserCancelledError(message);
|
|
365
|
+
}
|
|
366
|
+
return new Error(message);
|
|
367
|
+
}
|
|
368
|
+
|
|
339
369
|
class AppleSocialLogin extends BaseSocialLogin {
|
|
340
370
|
constructor() {
|
|
341
371
|
super(...arguments);
|
|
@@ -396,7 +426,9 @@ var capacitorCapacitorUpdater = (function (exports, core) {
|
|
|
396
426
|
resolve({ provider: 'apple', result });
|
|
397
427
|
})
|
|
398
428
|
.catch((error) => {
|
|
399
|
-
|
|
429
|
+
var _a, _b, _c;
|
|
430
|
+
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';
|
|
431
|
+
reject(inferUserCancelledError(message));
|
|
400
432
|
});
|
|
401
433
|
});
|
|
402
434
|
}
|
|
@@ -512,7 +544,7 @@ var capacitorCapacitorUpdater = (function (exports, core) {
|
|
|
512
544
|
resolveWithProfile(response.authResponse);
|
|
513
545
|
}
|
|
514
546
|
else if (response.status === 'not_authorized' || response.status === 'unknown') {
|
|
515
|
-
reject(
|
|
547
|
+
reject(createUserCancelledError('Facebook login was cancelled.'));
|
|
516
548
|
}
|
|
517
549
|
else {
|
|
518
550
|
waitForConnected();
|
|
@@ -566,7 +598,7 @@ var capacitorCapacitorUpdater = (function (exports, core) {
|
|
|
566
598
|
}
|
|
567
599
|
if (response.status === 'not_authorized' || response.status === 'unknown') {
|
|
568
600
|
finished = true;
|
|
569
|
-
reject(
|
|
601
|
+
reject(createUserCancelledError('Facebook login was cancelled.'));
|
|
570
602
|
return;
|
|
571
603
|
}
|
|
572
604
|
if (Date.now() - start >= timeoutMs) {
|
|
@@ -989,7 +1021,7 @@ var capacitorCapacitorUpdater = (function (exports, core) {
|
|
|
989
1021
|
else if (((_d = event.data) === null || _d === void 0 ? void 0 : _d.type) === 'oauth-error') {
|
|
990
1022
|
cleanup(true);
|
|
991
1023
|
const errorMessage = event.data.error || 'User cancelled the OAuth flow';
|
|
992
|
-
reject(
|
|
1024
|
+
reject(inferUserCancelledError(errorMessage));
|
|
993
1025
|
}
|
|
994
1026
|
// Don't reject for non-OAuth messages, just ignore them
|
|
995
1027
|
};
|
|
@@ -1007,7 +1039,7 @@ var capacitorCapacitorUpdater = (function (exports, core) {
|
|
|
1007
1039
|
else if ((data === null || data === void 0 ? void 0 : data.type) === 'oauth-error') {
|
|
1008
1040
|
cleanup(true);
|
|
1009
1041
|
const errorMessage = data.error || 'User cancelled the OAuth flow';
|
|
1010
|
-
reject(
|
|
1042
|
+
reject(inferUserCancelledError(errorMessage));
|
|
1011
1043
|
}
|
|
1012
1044
|
};
|
|
1013
1045
|
}
|
|
@@ -1022,7 +1054,7 @@ var capacitorCapacitorUpdater = (function (exports, core) {
|
|
|
1022
1054
|
// Check if popup is closed - this may throw cross-origin errors for some providers
|
|
1023
1055
|
if (popup.closed) {
|
|
1024
1056
|
cleanup();
|
|
1025
|
-
reject(
|
|
1057
|
+
reject(createUserCancelledError('Popup closed'));
|
|
1026
1058
|
}
|
|
1027
1059
|
}
|
|
1028
1060
|
catch (_a) {
|
|
@@ -1314,7 +1346,7 @@ var capacitorCapacitorUpdater = (function (exports, core) {
|
|
|
1314
1346
|
return false;
|
|
1315
1347
|
}
|
|
1316
1348
|
cleanup(messageHandler, timeoutHandle, popupClosedInterval);
|
|
1317
|
-
reject(
|
|
1349
|
+
reject(inferUserCancelledError(data.error || 'OAuth2 login was cancelled.'));
|
|
1318
1350
|
return true;
|
|
1319
1351
|
}
|
|
1320
1352
|
return false;
|
|
@@ -1347,7 +1379,7 @@ var capacitorCapacitorUpdater = (function (exports, core) {
|
|
|
1347
1379
|
// Check if popup is closed - this may throw cross-origin errors for some providers
|
|
1348
1380
|
if (popup.closed) {
|
|
1349
1381
|
cleanup(messageHandler, timeoutHandle, popupClosedInterval);
|
|
1350
|
-
reject(
|
|
1382
|
+
reject(createUserCancelledError('OAuth2 login window was closed.'));
|
|
1351
1383
|
}
|
|
1352
1384
|
}
|
|
1353
1385
|
catch (_a) {
|
|
@@ -1841,7 +1873,7 @@ var capacitorCapacitorUpdater = (function (exports, core) {
|
|
|
1841
1873
|
return false;
|
|
1842
1874
|
}
|
|
1843
1875
|
cleanup(messageHandler, timeoutHandle, popupClosedInterval);
|
|
1844
|
-
reject(
|
|
1876
|
+
reject(inferUserCancelledError(data.error || 'Twitter login was cancelled.'));
|
|
1845
1877
|
return true;
|
|
1846
1878
|
}
|
|
1847
1879
|
return false;
|
|
@@ -1874,7 +1906,7 @@ var capacitorCapacitorUpdater = (function (exports, core) {
|
|
|
1874
1906
|
// Check if popup is closed - this may throw cross-origin errors for some providers
|
|
1875
1907
|
if (popup.closed) {
|
|
1876
1908
|
cleanup(messageHandler, timeoutHandle, popupClosedInterval);
|
|
1877
|
-
reject(
|
|
1909
|
+
reject(createUserCancelledError('Twitter login window was closed.'));
|
|
1878
1910
|
}
|
|
1879
1911
|
}
|
|
1880
1912
|
catch (_a) {
|
|
@@ -2180,11 +2212,8 @@ var capacitorCapacitorUpdater = (function (exports, core) {
|
|
|
2180
2212
|
let message;
|
|
2181
2213
|
if ('error' in result) {
|
|
2182
2214
|
const resolvedProvider = (_a = parsed.provider) !== null && _a !== void 0 ? _a : null;
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
provider: resolvedProvider,
|
|
2186
|
-
error: result.error,
|
|
2187
|
-
};
|
|
2215
|
+
const error = inferUserCancelledError(result.error);
|
|
2216
|
+
message = Object.assign({ type: 'oauth-error', provider: resolvedProvider, error: error.message }, (error.code ? { code: error.code } : null));
|
|
2188
2217
|
}
|
|
2189
2218
|
else {
|
|
2190
2219
|
message = Object.assign({ type: 'oauth-response', provider: result.provider }, result.result);
|
|
@@ -2354,7 +2383,7 @@ var capacitorCapacitorUpdater = (function (exports, core) {
|
|
|
2354
2383
|
if (!result)
|
|
2355
2384
|
return null;
|
|
2356
2385
|
if ('error' in result) {
|
|
2357
|
-
throw
|
|
2386
|
+
throw inferUserCancelledError(result.error);
|
|
2358
2387
|
}
|
|
2359
2388
|
return result;
|
|
2360
2389
|
}
|