@capgo/capacitor-social-login 8.5.1 → 8.5.3
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 +78 -18
- package/android/src/main/java/ee/forgr/capacitor/social/login/OAuth2LoginActivity.java +7 -0
- package/android/src/main/java/ee/forgr/capacitor/social/login/SocialLoginPlugin.java +31 -1
- package/android/src/main/java/ee/forgr/capacitor/social/login/TelegramProvider.java +352 -0
- package/android/src/main/java/ee/forgr/capacitor/social/login/helpers/DependencyAvailabilityChecker.java +21 -1
- package/dist/docs.json +150 -8
- package/dist/esm/definitions.d.ts +87 -3
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/facebook-provider.d.ts +3 -1
- package/dist/esm/facebook-provider.js +33 -0
- package/dist/esm/facebook-provider.js.map +1 -1
- package/dist/esm/oauth-popup-bridge.js +17 -7
- package/dist/esm/oauth-popup-bridge.js.map +1 -1
- package/dist/esm/oauth-popup-redirect.js +5 -0
- package/dist/esm/oauth-popup-redirect.js.map +1 -1
- package/dist/esm/social-login.d.ts +1 -1
- package/dist/esm/social-login.js.map +1 -1
- package/dist/esm/telegram-provider.d.ts +37 -0
- package/dist/esm/telegram-provider.js +292 -0
- package/dist/esm/telegram-provider.js.map +1 -0
- package/dist/esm/web.d.ts +2 -1
- package/dist/esm/web.js +23 -3
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +364 -10
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +364 -10
- package/dist/plugin.js.map +1 -1
- package/ios/Sources/SocialLoginPlugin/SocialLoginPlugin.swift +67 -1
- package/ios/Sources/SocialLoginPlugin/TelegramProvider.swift +260 -0
- package/package.json +1 -1
package/dist/plugin.js
CHANGED
|
@@ -72,7 +72,13 @@ var capacitorCapacitorUpdater = (function (exports, core) {
|
|
|
72
72
|
const OAUTH_POPUP_SESSION_KEY = 'social_login_oauth_popup';
|
|
73
73
|
const OAUTH_RESULT_KEY_PREFIX = 'social_login_oauth_result_';
|
|
74
74
|
const OAUTH_DELIVERED_KEY = 'social_login_oauth_delivered';
|
|
75
|
-
const POPUP_WINDOW_NAMES = new Set([
|
|
75
|
+
const POPUP_WINDOW_NAMES = new Set([
|
|
76
|
+
'OAuth2Login',
|
|
77
|
+
'XLogin',
|
|
78
|
+
'Google Sign In',
|
|
79
|
+
'Authorization',
|
|
80
|
+
'TelegramLogin',
|
|
81
|
+
]);
|
|
76
82
|
function getOAuthResultKey(nonce) {
|
|
77
83
|
return `${OAUTH_RESULT_KEY_PREFIX}${nonce}`;
|
|
78
84
|
}
|
|
@@ -81,6 +87,8 @@ var capacitorCapacitorUpdater = (function (exports, core) {
|
|
|
81
87
|
return `oauth2_${nonceOrState}`;
|
|
82
88
|
if (provider === 'twitter')
|
|
83
89
|
return `twitter_oauth_${nonceOrState}`;
|
|
90
|
+
if (provider === 'telegram')
|
|
91
|
+
return `telegram_oauth_${nonceOrState}`;
|
|
84
92
|
return `google_oauth_${nonceOrState}`;
|
|
85
93
|
}
|
|
86
94
|
function markOAuthPopup(nonce) {
|
|
@@ -101,12 +109,14 @@ var capacitorCapacitorUpdater = (function (exports, core) {
|
|
|
101
109
|
}
|
|
102
110
|
}
|
|
103
111
|
function hasOAuthRedirectParams() {
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
hash.
|
|
109
|
-
hash.
|
|
112
|
+
const search = new URLSearchParams(window.location.search);
|
|
113
|
+
const hash = new URLSearchParams(window.location.hash.replace(/^#/, ''));
|
|
114
|
+
return (search.has('code') ||
|
|
115
|
+
search.has('error') ||
|
|
116
|
+
(search.has('hash') && search.has('auth_date')) ||
|
|
117
|
+
hash.has('access_token') ||
|
|
118
|
+
hash.has('id_token') ||
|
|
119
|
+
hash.has('error'));
|
|
110
120
|
}
|
|
111
121
|
function isOAuthPopupContext() {
|
|
112
122
|
if (typeof window === 'undefined')
|
|
@@ -1410,6 +1420,294 @@ var capacitorCapacitorUpdater = (function (exports, core) {
|
|
|
1410
1420
|
}
|
|
1411
1421
|
}
|
|
1412
1422
|
|
|
1423
|
+
class TelegramSocialLogin extends BaseSocialLogin {
|
|
1424
|
+
constructor() {
|
|
1425
|
+
super(...arguments);
|
|
1426
|
+
this.botId = null;
|
|
1427
|
+
this.redirectUrl = null;
|
|
1428
|
+
this.origin = null;
|
|
1429
|
+
this.requestAccess = 'write';
|
|
1430
|
+
this.languageCode = null;
|
|
1431
|
+
this.TOKENS_KEY = 'capgo_social_login_telegram_session_v1';
|
|
1432
|
+
this.STATE_PREFIX = 'capgo_social_login_telegram_state_';
|
|
1433
|
+
this.SESSION_TTL_MS = 24 * 60 * 60 * 1000; // 24h session window based on Telegram auth_date
|
|
1434
|
+
}
|
|
1435
|
+
initialize(botId, requestAccess, redirectUrl, origin, languageCode) {
|
|
1436
|
+
this.botId = botId;
|
|
1437
|
+
this.requestAccess = requestAccess !== null && requestAccess !== void 0 ? requestAccess : 'write';
|
|
1438
|
+
this.redirectUrl = redirectUrl !== null && redirectUrl !== void 0 ? redirectUrl : null;
|
|
1439
|
+
this.origin = origin !== null && origin !== void 0 ? origin : null;
|
|
1440
|
+
this.languageCode = languageCode !== null && languageCode !== void 0 ? languageCode : null;
|
|
1441
|
+
}
|
|
1442
|
+
async login(options) {
|
|
1443
|
+
var _a, _b, _c, _d, _e;
|
|
1444
|
+
if (!this.botId) {
|
|
1445
|
+
throw new Error('Telegram botId is not configured. Call initialize() first.');
|
|
1446
|
+
}
|
|
1447
|
+
const redirectUri = (_b = (_a = options.redirectUrl) !== null && _a !== void 0 ? _a : this.redirectUrl) !== null && _b !== void 0 ? _b : window.location.origin + window.location.pathname;
|
|
1448
|
+
const state = (_c = options.state) !== null && _c !== void 0 ? _c : this.generateState();
|
|
1449
|
+
const requestAccess = (_d = options.requestAccess) !== null && _d !== void 0 ? _d : this.requestAccess;
|
|
1450
|
+
const origin = (_e = this.origin) !== null && _e !== void 0 ? _e : this.getOriginFromRedirect(redirectUri);
|
|
1451
|
+
if (!this.isHttpOrigin(origin)) {
|
|
1452
|
+
throw new Error('Telegram origin must be a valid http(s) URL registered with BotFather. Pass origin when redirectUrl is not http(s).');
|
|
1453
|
+
}
|
|
1454
|
+
const returnTo = this.appendStateToRedirect(redirectUri, state);
|
|
1455
|
+
this.persistPendingLogin(state, {
|
|
1456
|
+
redirectUri,
|
|
1457
|
+
requestAccess,
|
|
1458
|
+
});
|
|
1459
|
+
localStorage.setItem(BaseSocialLogin.OAUTH_STATE_KEY, JSON.stringify({ provider: 'telegram', state }));
|
|
1460
|
+
const authUrl = this.buildAuthUrl(origin, requestAccess, returnTo);
|
|
1461
|
+
const popup = this.openPopup(authUrl);
|
|
1462
|
+
return new Promise((resolve, reject) => {
|
|
1463
|
+
if (!popup) {
|
|
1464
|
+
this.clearPendingTelegramState(state);
|
|
1465
|
+
reject(new Error('Unable to open login window. Please allow popups.'));
|
|
1466
|
+
return;
|
|
1467
|
+
}
|
|
1468
|
+
let settled = false;
|
|
1469
|
+
let timeoutHandle = 0;
|
|
1470
|
+
let popupClosedInterval = 0;
|
|
1471
|
+
let removeOAuthListener = null;
|
|
1472
|
+
const cleanup = (shouldClose = false) => {
|
|
1473
|
+
clearTimeout(timeoutHandle);
|
|
1474
|
+
clearInterval(popupClosedInterval);
|
|
1475
|
+
if (removeOAuthListener) {
|
|
1476
|
+
removeOAuthListener();
|
|
1477
|
+
removeOAuthListener = null;
|
|
1478
|
+
}
|
|
1479
|
+
this.clearPendingTelegramState(state);
|
|
1480
|
+
if (shouldClose) {
|
|
1481
|
+
try {
|
|
1482
|
+
popup.close();
|
|
1483
|
+
}
|
|
1484
|
+
catch (_a) {
|
|
1485
|
+
// ignore if already closed
|
|
1486
|
+
}
|
|
1487
|
+
}
|
|
1488
|
+
};
|
|
1489
|
+
const settle = (shouldClose, action) => {
|
|
1490
|
+
if (settled)
|
|
1491
|
+
return;
|
|
1492
|
+
settled = true;
|
|
1493
|
+
cleanup(shouldClose);
|
|
1494
|
+
action();
|
|
1495
|
+
};
|
|
1496
|
+
removeOAuthListener = listenForOAuthResult('telegram', state, {
|
|
1497
|
+
onResponse: (data) => {
|
|
1498
|
+
if ((data === null || data === void 0 ? void 0 : data.provider) && data.provider !== 'telegram') {
|
|
1499
|
+
return;
|
|
1500
|
+
}
|
|
1501
|
+
const _a = data, { provider: _ignoredProvider, type: _ignoredType, _ts: _ignoredTs } = _a, payload = __rest(_a, ["provider", "type", "_ts"]);
|
|
1502
|
+
settle(true, () => {
|
|
1503
|
+
resolve({
|
|
1504
|
+
provider: 'telegram',
|
|
1505
|
+
result: payload,
|
|
1506
|
+
});
|
|
1507
|
+
});
|
|
1508
|
+
},
|
|
1509
|
+
onError: (error, code) => {
|
|
1510
|
+
const message = error || 'Telegram login was cancelled.';
|
|
1511
|
+
settle(true, () => {
|
|
1512
|
+
reject(code === 'USER_CANCELLED' ? createUserCancelledError(message) : inferUserCancelledError(message));
|
|
1513
|
+
});
|
|
1514
|
+
},
|
|
1515
|
+
});
|
|
1516
|
+
timeoutHandle = window.setTimeout(() => {
|
|
1517
|
+
settle(true, () => {
|
|
1518
|
+
reject(new Error('Telegram login timed out.'));
|
|
1519
|
+
});
|
|
1520
|
+
}, 300000);
|
|
1521
|
+
popupClosedInterval = window.setInterval(() => {
|
|
1522
|
+
try {
|
|
1523
|
+
if (popup.closed) {
|
|
1524
|
+
settle(false, () => {
|
|
1525
|
+
reject(createUserCancelledError('Telegram login window was closed.'));
|
|
1526
|
+
});
|
|
1527
|
+
}
|
|
1528
|
+
}
|
|
1529
|
+
catch (_a) {
|
|
1530
|
+
clearInterval(popupClosedInterval);
|
|
1531
|
+
}
|
|
1532
|
+
}, 1000);
|
|
1533
|
+
});
|
|
1534
|
+
}
|
|
1535
|
+
async logout() {
|
|
1536
|
+
localStorage.removeItem(this.TOKENS_KEY);
|
|
1537
|
+
}
|
|
1538
|
+
async isLoggedIn() {
|
|
1539
|
+
const session = this.getStoredSession();
|
|
1540
|
+
if (!session) {
|
|
1541
|
+
return { isLoggedIn: false };
|
|
1542
|
+
}
|
|
1543
|
+
const isValid = session.expiresAt > Date.now();
|
|
1544
|
+
if (!isValid) {
|
|
1545
|
+
localStorage.removeItem(this.TOKENS_KEY);
|
|
1546
|
+
}
|
|
1547
|
+
return { isLoggedIn: isValid };
|
|
1548
|
+
}
|
|
1549
|
+
async getAuthorizationCode() {
|
|
1550
|
+
throw new Error('getAuthorizationCode is not available for Telegram.');
|
|
1551
|
+
}
|
|
1552
|
+
async refresh() {
|
|
1553
|
+
throw new Error('Telegram refresh is not supported. Call login() again.');
|
|
1554
|
+
}
|
|
1555
|
+
async handleOAuthRedirect(url, expectedState) {
|
|
1556
|
+
var _a;
|
|
1557
|
+
const params = url.searchParams;
|
|
1558
|
+
const stateFromUrl = params.get('state');
|
|
1559
|
+
if (!stateFromUrl) {
|
|
1560
|
+
return null;
|
|
1561
|
+
}
|
|
1562
|
+
if (expectedState && expectedState !== stateFromUrl) {
|
|
1563
|
+
return { error: 'Telegram login session expired or state mismatch.' };
|
|
1564
|
+
}
|
|
1565
|
+
const pending = this.consumePendingLogin(stateFromUrl);
|
|
1566
|
+
if (!pending) {
|
|
1567
|
+
localStorage.removeItem(BaseSocialLogin.OAUTH_STATE_KEY);
|
|
1568
|
+
return { error: 'Telegram login session expired or state mismatch.' };
|
|
1569
|
+
}
|
|
1570
|
+
const error = params.get('error');
|
|
1571
|
+
if (error) {
|
|
1572
|
+
localStorage.removeItem(BaseSocialLogin.OAUTH_STATE_KEY);
|
|
1573
|
+
return { error: params.get('error_description') || error };
|
|
1574
|
+
}
|
|
1575
|
+
const id = params.get('id');
|
|
1576
|
+
const authDateRaw = params.get('auth_date');
|
|
1577
|
+
const hash = params.get('hash');
|
|
1578
|
+
if (!id || !authDateRaw || !hash) {
|
|
1579
|
+
localStorage.removeItem(BaseSocialLogin.OAUTH_STATE_KEY);
|
|
1580
|
+
return { error: 'Telegram login payload is incomplete.' };
|
|
1581
|
+
}
|
|
1582
|
+
const profile = {
|
|
1583
|
+
id,
|
|
1584
|
+
firstName: (_a = params.get('first_name')) !== null && _a !== void 0 ? _a : '',
|
|
1585
|
+
lastName: params.get('last_name'),
|
|
1586
|
+
username: params.get('username'),
|
|
1587
|
+
photoUrl: params.get('photo_url'),
|
|
1588
|
+
};
|
|
1589
|
+
const authDate = Number(authDateRaw);
|
|
1590
|
+
if (!Number.isInteger(authDate)) {
|
|
1591
|
+
localStorage.removeItem(BaseSocialLogin.OAUTH_STATE_KEY);
|
|
1592
|
+
return { error: 'Telegram auth_date is invalid.' };
|
|
1593
|
+
}
|
|
1594
|
+
const result = {
|
|
1595
|
+
profile,
|
|
1596
|
+
authDate,
|
|
1597
|
+
hash,
|
|
1598
|
+
requestAccess: pending.requestAccess,
|
|
1599
|
+
};
|
|
1600
|
+
this.persistSession({
|
|
1601
|
+
expiresAt: authDate * 1000 + this.SESSION_TTL_MS,
|
|
1602
|
+
});
|
|
1603
|
+
localStorage.removeItem(BaseSocialLogin.OAUTH_STATE_KEY);
|
|
1604
|
+
return {
|
|
1605
|
+
provider: 'telegram',
|
|
1606
|
+
result,
|
|
1607
|
+
};
|
|
1608
|
+
}
|
|
1609
|
+
buildAuthUrl(origin, requestAccess, returnTo) {
|
|
1610
|
+
var _a;
|
|
1611
|
+
const params = new URLSearchParams({
|
|
1612
|
+
bot_id: (_a = this.botId) !== null && _a !== void 0 ? _a : '',
|
|
1613
|
+
origin,
|
|
1614
|
+
request_access: requestAccess,
|
|
1615
|
+
return_to: returnTo,
|
|
1616
|
+
embed: '1',
|
|
1617
|
+
mobile: '1',
|
|
1618
|
+
});
|
|
1619
|
+
if (this.languageCode) {
|
|
1620
|
+
params.set('lang', this.languageCode);
|
|
1621
|
+
}
|
|
1622
|
+
return `https://oauth.telegram.org/auth?${params.toString()}`;
|
|
1623
|
+
}
|
|
1624
|
+
openPopup(authUrl) {
|
|
1625
|
+
const width = 500;
|
|
1626
|
+
const height = 650;
|
|
1627
|
+
const left = window.screenX + (window.outerWidth - width) / 2;
|
|
1628
|
+
const top = window.screenY + (window.outerHeight - height) / 2;
|
|
1629
|
+
return window.open(authUrl, 'TelegramLogin', `width=${width},height=${height},left=${left},top=${top},popup=1`);
|
|
1630
|
+
}
|
|
1631
|
+
appendStateToRedirect(redirectUri, state) {
|
|
1632
|
+
try {
|
|
1633
|
+
const redirect = new URL(redirectUri);
|
|
1634
|
+
redirect.searchParams.set('state', state);
|
|
1635
|
+
return redirect.toString();
|
|
1636
|
+
}
|
|
1637
|
+
catch (_a) {
|
|
1638
|
+
return redirectUri;
|
|
1639
|
+
}
|
|
1640
|
+
}
|
|
1641
|
+
isHttpOrigin(value) {
|
|
1642
|
+
if (!value) {
|
|
1643
|
+
return false;
|
|
1644
|
+
}
|
|
1645
|
+
try {
|
|
1646
|
+
const url = new URL(value);
|
|
1647
|
+
return url.protocol === 'http:' || url.protocol === 'https:';
|
|
1648
|
+
}
|
|
1649
|
+
catch (_a) {
|
|
1650
|
+
return false;
|
|
1651
|
+
}
|
|
1652
|
+
}
|
|
1653
|
+
getOriginFromRedirect(redirectUri) {
|
|
1654
|
+
return this.isHttpOrigin(redirectUri) ? new URL(redirectUri).origin : undefined;
|
|
1655
|
+
}
|
|
1656
|
+
persistSession(session) {
|
|
1657
|
+
localStorage.setItem(this.TOKENS_KEY, JSON.stringify(session));
|
|
1658
|
+
}
|
|
1659
|
+
getStoredSession() {
|
|
1660
|
+
const raw = localStorage.getItem(this.TOKENS_KEY);
|
|
1661
|
+
if (!raw) {
|
|
1662
|
+
return null;
|
|
1663
|
+
}
|
|
1664
|
+
try {
|
|
1665
|
+
return JSON.parse(raw);
|
|
1666
|
+
}
|
|
1667
|
+
catch (err) {
|
|
1668
|
+
console.warn('Failed to parse stored Telegram session', err);
|
|
1669
|
+
return null;
|
|
1670
|
+
}
|
|
1671
|
+
}
|
|
1672
|
+
persistPendingLogin(state, payload) {
|
|
1673
|
+
localStorage.setItem(`${this.STATE_PREFIX}${state}`, JSON.stringify(payload));
|
|
1674
|
+
}
|
|
1675
|
+
consumePendingLogin(state) {
|
|
1676
|
+
const key = `${this.STATE_PREFIX}${state}`;
|
|
1677
|
+
const raw = localStorage.getItem(key);
|
|
1678
|
+
localStorage.removeItem(key);
|
|
1679
|
+
if (!raw) {
|
|
1680
|
+
return null;
|
|
1681
|
+
}
|
|
1682
|
+
try {
|
|
1683
|
+
return JSON.parse(raw);
|
|
1684
|
+
}
|
|
1685
|
+
catch (err) {
|
|
1686
|
+
console.warn('Failed to parse pending Telegram login payload', err);
|
|
1687
|
+
return null;
|
|
1688
|
+
}
|
|
1689
|
+
}
|
|
1690
|
+
clearPendingTelegramState(state) {
|
|
1691
|
+
try {
|
|
1692
|
+
localStorage.removeItem(`${this.STATE_PREFIX}${state}`);
|
|
1693
|
+
const raw = localStorage.getItem(BaseSocialLogin.OAUTH_STATE_KEY);
|
|
1694
|
+
if (!raw) {
|
|
1695
|
+
return;
|
|
1696
|
+
}
|
|
1697
|
+
const parsed = JSON.parse(raw);
|
|
1698
|
+
if (parsed.provider === 'telegram' && parsed.state === state) {
|
|
1699
|
+
localStorage.removeItem(BaseSocialLogin.OAUTH_STATE_KEY);
|
|
1700
|
+
}
|
|
1701
|
+
}
|
|
1702
|
+
catch (_a) {
|
|
1703
|
+
// ignore storage errors
|
|
1704
|
+
}
|
|
1705
|
+
}
|
|
1706
|
+
generateState() {
|
|
1707
|
+
return [...crypto.getRandomValues(new Uint8Array(16))].map((b) => b.toString(16).padStart(2, '0')).join('');
|
|
1708
|
+
}
|
|
1709
|
+
}
|
|
1710
|
+
|
|
1413
1711
|
class TwitterSocialLogin extends BaseSocialLogin {
|
|
1414
1712
|
constructor() {
|
|
1415
1713
|
super(...arguments);
|
|
@@ -1801,11 +2099,15 @@ var capacitorCapacitorUpdater = (function (exports, core) {
|
|
|
1801
2099
|
const googleProvider = new GoogleSocialLogin();
|
|
1802
2100
|
const oauth2Provider = new OAuth2SocialLogin();
|
|
1803
2101
|
const twitterProvider = new TwitterSocialLogin();
|
|
2102
|
+
const telegramProvider = new TelegramSocialLogin();
|
|
1804
2103
|
let result = null;
|
|
1805
2104
|
switch (provider) {
|
|
1806
2105
|
case 'twitter':
|
|
1807
2106
|
result = await twitterProvider.handleOAuthRedirect(url, state);
|
|
1808
2107
|
break;
|
|
2108
|
+
case 'telegram':
|
|
2109
|
+
result = await telegramProvider.handleOAuthRedirect(url, state);
|
|
2110
|
+
break;
|
|
1809
2111
|
case 'oauth2':
|
|
1810
2112
|
result = await oauth2Provider.handleOAuthRedirect(url, state);
|
|
1811
2113
|
break;
|
|
@@ -2362,6 +2664,39 @@ var capacitorCapacitorUpdater = (function (exports, core) {
|
|
|
2362
2664
|
async refresh(options) {
|
|
2363
2665
|
await this.login(options);
|
|
2364
2666
|
}
|
|
2667
|
+
async getProfile(fields) {
|
|
2668
|
+
if (!this.appId) {
|
|
2669
|
+
throw new Error('Facebook App ID not set. Call initialize() first.');
|
|
2670
|
+
}
|
|
2671
|
+
const requestedFields = Array.isArray(fields) && fields.length > 0 ? fields : ['id', 'name', 'email', 'picture'];
|
|
2672
|
+
return new Promise((resolve, reject) => {
|
|
2673
|
+
FB.getLoginStatus((statusResponse) => {
|
|
2674
|
+
if (statusResponse.status !== 'connected') {
|
|
2675
|
+
reject(new Error('User is not logged in. Call login() before fetching profile.'));
|
|
2676
|
+
return;
|
|
2677
|
+
}
|
|
2678
|
+
FB.api('/me', { fields: requestedFields.join(',') }, (profile) => {
|
|
2679
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
2680
|
+
if (profile && !profile.error) {
|
|
2681
|
+
resolve({
|
|
2682
|
+
profile: Object.assign(Object.assign({}, profile), { id: (_a = profile.id) !== null && _a !== void 0 ? _a : null, name: (_b = profile.name) !== null && _b !== void 0 ? _b : null, email: (_c = profile.email) !== null && _c !== void 0 ? _c : null, first_name: (_d = profile.first_name) !== null && _d !== void 0 ? _d : null, last_name: (_e = profile.last_name) !== null && _e !== void 0 ? _e : null }),
|
|
2683
|
+
});
|
|
2684
|
+
}
|
|
2685
|
+
else {
|
|
2686
|
+
const errorMessage = (_g = (_f = profile === null || profile === void 0 ? void 0 : profile.error) === null || _f === void 0 ? void 0 : _f.message) !== null && _g !== void 0 ? _g : 'Failed to fetch Facebook profile';
|
|
2687
|
+
reject(new Error(errorMessage));
|
|
2688
|
+
}
|
|
2689
|
+
});
|
|
2690
|
+
});
|
|
2691
|
+
});
|
|
2692
|
+
}
|
|
2693
|
+
async requestTracking() {
|
|
2694
|
+
if (!this.appId) {
|
|
2695
|
+
throw new Error('Facebook App ID not set. Call initialize() first.');
|
|
2696
|
+
}
|
|
2697
|
+
// App Tracking Transparency is not applicable on web.
|
|
2698
|
+
return { status: 'authorized' };
|
|
2699
|
+
}
|
|
2365
2700
|
waitForConnection(timeoutMs = 120000, pollIntervalMs = 500) {
|
|
2366
2701
|
const start = Date.now();
|
|
2367
2702
|
return new Promise((resolve, reject) => {
|
|
@@ -2415,6 +2750,7 @@ var capacitorCapacitorUpdater = (function (exports, core) {
|
|
|
2415
2750
|
this.appleProvider = new AppleSocialLogin();
|
|
2416
2751
|
this.facebookProvider = new FacebookSocialLogin();
|
|
2417
2752
|
this.twitterProvider = new TwitterSocialLogin();
|
|
2753
|
+
this.telegramProvider = new TelegramSocialLogin();
|
|
2418
2754
|
this.oauth2Provider = new OAuth2SocialLogin();
|
|
2419
2755
|
// Auto-finish OAuth redirects only when running inside a popup window.
|
|
2420
2756
|
// For redirect-based flows (full page navigation), the app should call `handleRedirectCallback()` explicitly.
|
|
@@ -2454,6 +2790,9 @@ var capacitorCapacitorUpdater = (function (exports, core) {
|
|
|
2454
2790
|
case 'twitter':
|
|
2455
2791
|
result = await this.twitterProvider.handleOAuthRedirect(url, state);
|
|
2456
2792
|
break;
|
|
2793
|
+
case 'telegram':
|
|
2794
|
+
result = await this.telegramProvider.handleOAuthRedirect(url, state);
|
|
2795
|
+
break;
|
|
2457
2796
|
case 'oauth2':
|
|
2458
2797
|
result = await this.oauth2Provider.handleOAuthRedirect(url, state);
|
|
2459
2798
|
break;
|
|
@@ -2494,7 +2833,7 @@ var capacitorCapacitorUpdater = (function (exports, core) {
|
|
|
2494
2833
|
}
|
|
2495
2834
|
}
|
|
2496
2835
|
async initialize(options) {
|
|
2497
|
-
var _a, _b, _c, _d;
|
|
2836
|
+
var _a, _b, _c, _d, _e;
|
|
2498
2837
|
const initPromises = [];
|
|
2499
2838
|
if ((_a = options.google) === null || _a === void 0 ? void 0 : _a.webClientId) {
|
|
2500
2839
|
initPromises.push(this.googleProvider.initialize(options.google.webClientId, options.google.mode, options.google.hostedDomain, options.google.redirectUrl));
|
|
@@ -2508,6 +2847,9 @@ var capacitorCapacitorUpdater = (function (exports, core) {
|
|
|
2508
2847
|
if ((_d = options.twitter) === null || _d === void 0 ? void 0 : _d.clientId) {
|
|
2509
2848
|
initPromises.push(this.twitterProvider.initialize(options.twitter.clientId, options.twitter.redirectUrl, options.twitter.defaultScopes, options.twitter.forceLogin, options.twitter.audience));
|
|
2510
2849
|
}
|
|
2850
|
+
if ((_e = options.telegram) === null || _e === void 0 ? void 0 : _e.botId) {
|
|
2851
|
+
this.telegramProvider.initialize(options.telegram.botId, options.telegram.requestAccess, options.telegram.redirectUrl, options.telegram.origin, options.telegram.languageCode);
|
|
2852
|
+
}
|
|
2511
2853
|
if (options.oauth2 && Object.keys(options.oauth2).length > 0) {
|
|
2512
2854
|
initPromises.push(this.oauth2Provider.initializeProviders(options.oauth2));
|
|
2513
2855
|
}
|
|
@@ -2523,6 +2865,8 @@ var capacitorCapacitorUpdater = (function (exports, core) {
|
|
|
2523
2865
|
return this.facebookProvider.login(options.options);
|
|
2524
2866
|
case 'twitter':
|
|
2525
2867
|
return this.twitterProvider.login(options.options);
|
|
2868
|
+
case 'telegram':
|
|
2869
|
+
return this.telegramProvider.login(options.options);
|
|
2526
2870
|
case 'oauth2':
|
|
2527
2871
|
return this.oauth2Provider.login(options.options);
|
|
2528
2872
|
default:
|
|
@@ -2539,6 +2883,8 @@ var capacitorCapacitorUpdater = (function (exports, core) {
|
|
|
2539
2883
|
return this.facebookProvider.logout();
|
|
2540
2884
|
case 'twitter':
|
|
2541
2885
|
return this.twitterProvider.logout();
|
|
2886
|
+
case 'telegram':
|
|
2887
|
+
return this.telegramProvider.logout();
|
|
2542
2888
|
case 'oauth2':
|
|
2543
2889
|
if (!options.providerId) {
|
|
2544
2890
|
throw new Error('providerId is required for oauth2 logout');
|
|
@@ -2558,6 +2904,8 @@ var capacitorCapacitorUpdater = (function (exports, core) {
|
|
|
2558
2904
|
return this.facebookProvider.isLoggedIn();
|
|
2559
2905
|
case 'twitter':
|
|
2560
2906
|
return this.twitterProvider.isLoggedIn();
|
|
2907
|
+
case 'telegram':
|
|
2908
|
+
return this.telegramProvider.isLoggedIn();
|
|
2561
2909
|
case 'oauth2':
|
|
2562
2910
|
if (!options.providerId) {
|
|
2563
2911
|
throw new Error('providerId is required for oauth2 isLoggedIn');
|
|
@@ -2596,6 +2944,8 @@ var capacitorCapacitorUpdater = (function (exports, core) {
|
|
|
2596
2944
|
return this.facebookProvider.refresh(options.options);
|
|
2597
2945
|
case 'twitter':
|
|
2598
2946
|
return this.twitterProvider.refresh();
|
|
2947
|
+
case 'telegram':
|
|
2948
|
+
return this.telegramProvider.refresh();
|
|
2599
2949
|
case 'oauth2': {
|
|
2600
2950
|
const oauth2Options = options.options;
|
|
2601
2951
|
if (!(oauth2Options === null || oauth2Options === void 0 ? void 0 : oauth2Options.providerId)) {
|
|
@@ -2608,10 +2958,14 @@ var capacitorCapacitorUpdater = (function (exports, core) {
|
|
|
2608
2958
|
}
|
|
2609
2959
|
}
|
|
2610
2960
|
async providerSpecificCall(options) {
|
|
2961
|
+
var _a;
|
|
2611
2962
|
switch (options.call) {
|
|
2612
|
-
case 'facebook#getProfile':
|
|
2963
|
+
case 'facebook#getProfile': {
|
|
2964
|
+
const fields = (_a = options.options) === null || _a === void 0 ? void 0 : _a.fields;
|
|
2965
|
+
return this.facebookProvider.getProfile(fields);
|
|
2966
|
+
}
|
|
2613
2967
|
case 'facebook#requestTracking':
|
|
2614
|
-
|
|
2968
|
+
return this.facebookProvider.requestTracking();
|
|
2615
2969
|
case 'google#createRestoreCredential':
|
|
2616
2970
|
case 'google#getRestoreCredential':
|
|
2617
2971
|
case 'google#clearRestoreCredential':
|