@capgo/capacitor-social-login 8.5.2 → 8.5.4
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 +176 -24
- 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 +299 -13
- package/dist/esm/auth-connect.js +2 -2
- package/dist/esm/auth-connect.js.map +1 -1
- package/dist/esm/definitions.d.ts +154 -10
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/linkedin-provider.d.ts +17 -0
- package/dist/esm/linkedin-provider.js +54 -0
- package/dist/esm/linkedin-provider.js.map +1 -0
- 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 +4 -8
- package/dist/esm/social-login.js +50 -3
- 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 +4 -8
- package/dist/esm/web.js +52 -4
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +498 -51
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +3181 -2734
- 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/README.md
CHANGED
|
@@ -19,6 +19,8 @@ This plugin implements social auth for:
|
|
|
19
19
|
- Apple (with OAuth on android)
|
|
20
20
|
- Facebook (with latest SDK)
|
|
21
21
|
- Twitter/X (OAuth 2.0)
|
|
22
|
+
- Telegram (Login Widget)
|
|
23
|
+
- LinkedIn (OAuth 2.0 / OpenID Connect)
|
|
22
24
|
- Generic OAuth2 (supports multiple providers: GitHub, Azure AD, Auth0, Okta, and any OAuth2-compliant server)
|
|
23
25
|
|
|
24
26
|
This plugin is the all-in-one solution for social authentication on Web, iOS, and Android.
|
|
@@ -558,6 +560,61 @@ Initialize method to create a script tag with Google lib. We cannot know when it
|
|
|
558
560
|
|
|
559
561
|
On Web, Google `refresh()` is not implemented, even when using `mode: 'online'`. Call `SocialLogin.login({ provider: 'google', ... })` again to obtain a fresh token.
|
|
560
562
|
|
|
563
|
+
## Telegram
|
|
564
|
+
|
|
565
|
+
Telegram uses the [Login Widget](https://core.telegram.org/widgets/login) (`oauth.telegram.org`), not standard OAuth2. Create a bot with [@BotFather](https://t.me/BotFather), set the domain for the widget, and pass the **bot id** (not the bot token):
|
|
566
|
+
|
|
567
|
+
```typescript
|
|
568
|
+
await SocialLogin.initialize({
|
|
569
|
+
telegram: {
|
|
570
|
+
botId: '123456789',
|
|
571
|
+
redirectUrl: 'https://your-app.example/auth/telegram', // or myapp://telegram-auth on native
|
|
572
|
+
// Required on native when redirectUrl is a custom scheme
|
|
573
|
+
origin: 'https://your-app.example',
|
|
574
|
+
requestAccess: 'write',
|
|
575
|
+
},
|
|
576
|
+
});
|
|
577
|
+
|
|
578
|
+
const res = await SocialLogin.login({
|
|
579
|
+
provider: 'telegram',
|
|
580
|
+
options: {},
|
|
581
|
+
});
|
|
582
|
+
|
|
583
|
+
// Verify `res.result.hash` on your backend with the bot token.
|
|
584
|
+
// Reject stale or future `res.result.authDate` values before creating a session.
|
|
585
|
+
// Never ship the bot token in the app.
|
|
586
|
+
console.log(res.result.profile.id, res.result.hash);
|
|
587
|
+
```
|
|
588
|
+
|
|
589
|
+
## LinkedIn
|
|
590
|
+
|
|
591
|
+
LinkedIn is a convenience wrapper around the generic OAuth2 engine (OpenID Connect `userinfo`).
|
|
592
|
+
|
|
593
|
+
Register a web app in the [LinkedIn Developer Portal](https://www.linkedin.com/developers/apps) with the **Sign In with LinkedIn using OpenID Connect** product, then:
|
|
594
|
+
|
|
595
|
+
```typescript
|
|
596
|
+
await SocialLogin.initialize({
|
|
597
|
+
linkedin: {
|
|
598
|
+
clientId: 'your-linkedin-client-id',
|
|
599
|
+
redirectUrl: 'https://your-app.example/auth/linkedin',
|
|
600
|
+
// Optional: only if your LinkedIn app is a confidential client
|
|
601
|
+
// clientSecret: 'your-linkedin-client-secret',
|
|
602
|
+
},
|
|
603
|
+
});
|
|
604
|
+
|
|
605
|
+
const res = await SocialLogin.login({
|
|
606
|
+
provider: 'linkedin',
|
|
607
|
+
options: {
|
|
608
|
+
// defaults to 'openid profile email'
|
|
609
|
+
},
|
|
610
|
+
});
|
|
611
|
+
|
|
612
|
+
console.log(res.result.accessToken?.token);
|
|
613
|
+
console.log(res.result.resourceData); // LinkedIn userinfo payload
|
|
614
|
+
```
|
|
615
|
+
|
|
616
|
+
You can still configure LinkedIn yourself via `oauth2.linkedin` if you need custom endpoints.
|
|
617
|
+
|
|
561
618
|
## OAuth2 (Generic)
|
|
562
619
|
|
|
563
620
|
The plugin supports generic OAuth2 authentication, allowing you to integrate with any OAuth2-compliant provider (GitHub, Azure AD, Auth0, Okta, Keycloak, custom servers, etc.). You can configure multiple OAuth2 providers simultaneously.
|
|
@@ -878,14 +935,14 @@ Initialize the plugin
|
|
|
878
935
|
### login(...)
|
|
879
936
|
|
|
880
937
|
```typescript
|
|
881
|
-
login<T extends "apple" | "google" | "facebook" | "twitter" | "oauth2">(options: Extract<LoginOptions, { provider: T; }>) => Promise<{ provider: T; result: ProviderResponseMap[T]; }>
|
|
938
|
+
login<T extends "apple" | "google" | "facebook" | "twitter" | "linkedin" | "oauth2" | "telegram">(options: Extract<LoginOptions, { provider: T; }>) => Promise<{ provider: T; result: ProviderResponseMap[T]; }>
|
|
882
939
|
```
|
|
883
940
|
|
|
884
941
|
Login with the selected provider
|
|
885
942
|
|
|
886
|
-
| Param | Type
|
|
887
|
-
| ------------- |
|
|
888
|
-
| **`options`** | <code><a href="#extract">Extract</a><{ provider: 'facebook'; options: <a href="#facebookloginoptions">FacebookLoginOptions</a>; }, { provider: T; }> \| <a href="#extract">Extract</a><{ provider: 'google'; options: <a href="#googleloginoptions">GoogleLoginOptions</a>; }, { provider: T; }> \| <a href="#extract">Extract</a><{ provider: 'apple'; options: <a href="#appleprovideroptions">AppleProviderOptions</a>; }, { provider: T; }> \| <a href="#extract">Extract</a><{ provider: 'twitter'; options: <a href="#twitterloginoptions">TwitterLoginOptions</a>; }, { provider: T; }> \| <a href="#extract">Extract</a><{ provider: 'oauth2'; options: <a href="#oauth2loginoptions">OAuth2LoginOptions</a>; }, { provider: T; }></code> |
|
|
943
|
+
| Param | Type |
|
|
944
|
+
| ------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
945
|
+
| **`options`** | <code><a href="#extract">Extract</a><{ provider: 'facebook'; options: <a href="#facebookloginoptions">FacebookLoginOptions</a>; }, { provider: T; }> \| <a href="#extract">Extract</a><{ provider: 'google'; options: <a href="#googleloginoptions">GoogleLoginOptions</a>; }, { provider: T; }> \| <a href="#extract">Extract</a><{ provider: 'apple'; options: <a href="#appleprovideroptions">AppleProviderOptions</a>; }, { provider: T; }> \| <a href="#extract">Extract</a><{ provider: 'twitter'; options: <a href="#twitterloginoptions">TwitterLoginOptions</a>; }, { provider: T; }> \| <a href="#extract">Extract</a><{ provider: 'telegram'; options: <a href="#telegramloginoptions">TelegramLoginOptions</a>; }, { provider: T; }> \| <a href="#extract">Extract</a><{ provider: 'linkedin'; options: <a href="#linkedinloginoptions">LinkedInLoginOptions</a>; }, { provider: T; }> \| <a href="#extract">Extract</a><{ provider: 'oauth2'; options: <a href="#oauth2loginoptions">OAuth2LoginOptions</a>; }, { provider: T; }></code> |
|
|
889
946
|
|
|
890
947
|
**Returns:** <code>Promise<{ provider: T; result: ProviderResponseMap[T]; }></code>
|
|
891
948
|
|
|
@@ -895,14 +952,14 @@ Login with the selected provider
|
|
|
895
952
|
### logout(...)
|
|
896
953
|
|
|
897
954
|
```typescript
|
|
898
|
-
logout(options: { provider: 'apple' | 'google' | 'facebook' | 'twitter' | 'oauth2'; providerId?: string; }) => Promise<void>
|
|
955
|
+
logout(options: { provider: 'apple' | 'google' | 'facebook' | 'twitter' | 'telegram' | 'linkedin' | 'oauth2'; providerId?: string; }) => Promise<void>
|
|
899
956
|
```
|
|
900
957
|
|
|
901
958
|
Logout
|
|
902
959
|
|
|
903
|
-
| Param | Type
|
|
904
|
-
| ------------- |
|
|
905
|
-
| **`options`** | <code>{ provider: 'apple' \| 'google' \| 'facebook' \| 'twitter' \| 'oauth2'; providerId?: string; }</code> |
|
|
960
|
+
| Param | Type |
|
|
961
|
+
| ------------- | --------------------------------------------------------------------------------------------------------------------------------------- |
|
|
962
|
+
| **`options`** | <code>{ provider: 'apple' \| 'google' \| 'facebook' \| 'twitter' \| 'linkedin' \| 'oauth2' \| 'telegram'; providerId?: string; }</code> |
|
|
906
963
|
|
|
907
964
|
--------------------
|
|
908
965
|
|
|
@@ -959,13 +1016,13 @@ Refresh the access token
|
|
|
959
1016
|
### refreshToken(...)
|
|
960
1017
|
|
|
961
1018
|
```typescript
|
|
962
|
-
refreshToken(options:
|
|
1019
|
+
refreshToken(options: RefreshTokenOptions) => Promise<OAuth2LoginResponse>
|
|
963
1020
|
```
|
|
964
1021
|
|
|
965
1022
|
OAuth2 refresh-token helper (feature parity with Capawesome OAuth).
|
|
966
1023
|
|
|
967
1024
|
Scope:
|
|
968
|
-
-
|
|
1025
|
+
- Applies to the built-in `oauth2` provider and the LinkedIn convenience wrapper.
|
|
969
1026
|
- Requires a token endpoint (either `accessTokenEndpoint`/`tokenEndpoint` or `issuerUrl` discovery).
|
|
970
1027
|
|
|
971
1028
|
Security note:
|
|
@@ -973,9 +1030,9 @@ Security note:
|
|
|
973
1030
|
|
|
974
1031
|
If `refreshToken` is omitted, the plugin will attempt to use the stored refresh token (if available).
|
|
975
1032
|
|
|
976
|
-
| Param | Type
|
|
977
|
-
| ------------- |
|
|
978
|
-
| **`options`** | <code
|
|
1033
|
+
| Param | Type |
|
|
1034
|
+
| ------------- | ------------------------------------------------------------------- |
|
|
1035
|
+
| **`options`** | <code><a href="#refreshtokenoptions">RefreshTokenOptions</a></code> |
|
|
979
1036
|
|
|
980
1037
|
**Returns:** <code>Promise<<a href="#oauth2loginresponse">OAuth2LoginResponse</a>></code>
|
|
981
1038
|
|
|
@@ -993,6 +1050,8 @@ Web-only: handle the OAuth redirect callback and return the parsed result.
|
|
|
993
1050
|
Notes:
|
|
994
1051
|
- This is only meaningful on Web. iOS/Android implementations will reject.
|
|
995
1052
|
- Intended for redirect-based flows (e.g. `oauth2` with `flow: 'redirect'`) where the page navigates away.
|
|
1053
|
+
- LinkedIn convenience logins (`provider: 'linkedin'`, `flow: 'redirect'`) return `provider: 'linkedin'`.
|
|
1054
|
+
The same app used as `oauth2` with `providerId: 'linkedin'` keeps `provider: 'oauth2'`.
|
|
996
1055
|
|
|
997
1056
|
**Returns:** <code>Promise<<a href="#loginresult">LoginResult</a> | null></code>
|
|
998
1057
|
|
|
@@ -1201,6 +1260,8 @@ And in the AndroidManifest.xml file:
|
|
|
1201
1260
|
| Prop | Type | Description |
|
|
1202
1261
|
| -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ |
|
|
1203
1262
|
| **`oauth2`** | <code><a href="#record">Record</a><string, <a href="#oauth2providerconfig">OAuth2ProviderConfig</a>></code> | OAuth2 provider configurations. Supports multiple providers by using a <a href="#record">Record</a> with provider IDs as keys. |
|
|
1263
|
+
| **`telegram`** | <code>{ botId: string; redirectUrl?: string; origin?: string; requestAccess?: 'read' \| 'write'; languageCode?: string; }</code> | Telegram Login Widget configuration. Uses Telegram's OAuth widget (`oauth.telegram.org`), not standard OAuth2. |
|
|
1264
|
+
| **`linkedin`** | <code><a href="#linkedinproviderconfig">LinkedInProviderConfig</a></code> | LinkedIn configuration. Convenience wrapper that maps to the OAuth2 provider using LinkedIn defaults. |
|
|
1204
1265
|
| **`twitter`** | <code>{ clientId: string; redirectUrl: string; defaultScopes?: string[]; forceLogin?: boolean; audience?: string; }</code> | |
|
|
1205
1266
|
| **`facebook`** | <code>{ appId: string; clientToken?: string; locale?: string; }</code> | |
|
|
1206
1267
|
| **`google`** | <code>{ iOSClientId?: string; iOSServerClientId?: string; webClientId?: string; mode?: 'online' \| 'offline'; hostedDomain?: string; redirectUrl?: string; }</code> | |
|
|
@@ -1242,6 +1303,23 @@ Configuration for a single OAuth2 provider instance
|
|
|
1242
1303
|
| **`logsEnabled`** | <code>boolean</code> | Enable debug logging | <code>false</code> |
|
|
1243
1304
|
|
|
1244
1305
|
|
|
1306
|
+
#### LinkedInProviderConfig
|
|
1307
|
+
|
|
1308
|
+
LinkedIn provider configuration (convenience wrapper around the generic OAuth2 provider).
|
|
1309
|
+
|
|
1310
|
+
Uses the OAuth2 engine with LinkedIn defaults:
|
|
1311
|
+
- Authorization URL: https://www.linkedin.com/oauth/v2/authorization
|
|
1312
|
+
- Token URL: https://www.linkedin.com/oauth/v2/accessToken
|
|
1313
|
+
- Resource URL: https://api.linkedin.com/v2/userinfo
|
|
1314
|
+
- Default scopes: `openid profile email`
|
|
1315
|
+
|
|
1316
|
+
| Prop | Type | Description |
|
|
1317
|
+
| ------------------ | ------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
1318
|
+
| **`clientId`** | <code>string</code> | LinkedIn Client ID from the LinkedIn Developer Portal. |
|
|
1319
|
+
| **`redirectUrl`** | <code>string</code> | Redirect URL that receives the OAuth callback. Must match a redirect URL configured in the LinkedIn Developer Portal. |
|
|
1320
|
+
| **`clientSecret`** | <code>string</code> | LinkedIn Client Secret. Prefer exchanging the authorization code on a backend when possible. Needed for confidential clients that do not use PKCE-only token exchange. |
|
|
1321
|
+
|
|
1322
|
+
|
|
1245
1323
|
#### FacebookLoginResponse
|
|
1246
1324
|
|
|
1247
1325
|
| Prop | Type | Description | Since |
|
|
@@ -1320,6 +1398,27 @@ Configuration for a single OAuth2 provider instance
|
|
|
1320
1398
|
| **`email`** | <code>string \| null</code> |
|
|
1321
1399
|
|
|
1322
1400
|
|
|
1401
|
+
#### TelegramLoginResponse
|
|
1402
|
+
|
|
1403
|
+
| Prop | Type | Description |
|
|
1404
|
+
| ------------------- | ----------------------------------------------------------- | ------------------------------------------------------------ |
|
|
1405
|
+
| **`profile`** | <code><a href="#telegramprofile">TelegramProfile</a></code> | |
|
|
1406
|
+
| **`authDate`** | <code>number</code> | Unix timestamp (seconds) when the user authorized the login. |
|
|
1407
|
+
| **`hash`** | <code>string</code> | Telegram-provided hash for server-side verification. |
|
|
1408
|
+
| **`requestAccess`** | <code>'read' \| 'write'</code> | Requested access level that was used for this login. |
|
|
1409
|
+
|
|
1410
|
+
|
|
1411
|
+
#### TelegramProfile
|
|
1412
|
+
|
|
1413
|
+
| Prop | Type |
|
|
1414
|
+
| --------------- | --------------------------- |
|
|
1415
|
+
| **`id`** | <code>string</code> |
|
|
1416
|
+
| **`firstName`** | <code>string</code> |
|
|
1417
|
+
| **`lastName`** | <code>string \| null</code> |
|
|
1418
|
+
| **`username`** | <code>string \| null</code> |
|
|
1419
|
+
| **`photoUrl`** | <code>string \| null</code> |
|
|
1420
|
+
|
|
1421
|
+
|
|
1323
1422
|
#### OAuth2LoginResponse
|
|
1324
1423
|
|
|
1325
1424
|
| Prop | Type | Description |
|
|
@@ -1378,6 +1477,15 @@ Configuration for a single OAuth2 provider instance
|
|
|
1378
1477
|
| **`forceLogin`** | <code>boolean</code> | Force the consent screen on every attempt, maps to `force_login=true`. |
|
|
1379
1478
|
|
|
1380
1479
|
|
|
1480
|
+
#### TelegramLoginOptions
|
|
1481
|
+
|
|
1482
|
+
| Prop | Type | Description | Default |
|
|
1483
|
+
| ------------------- | ------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------- |
|
|
1484
|
+
| **`redirectUrl`** | <code>string</code> | Override the redirect URL for this login attempt. Defaults to the redirect configured during initialize(). Required on iOS/Android when initialize() did not set `redirectUrl`. | |
|
|
1485
|
+
| **`state`** | <code>string</code> | Optional state parameter for CSRF protection. If omitted, a secure random value is generated automatically. | |
|
|
1486
|
+
| **`requestAccess`** | <code>'read' \| 'write'</code> | Override requested access level for this login. Defaults to the value configured during initialize(). | <code>'write'</code> |
|
|
1487
|
+
|
|
1488
|
+
|
|
1381
1489
|
#### OAuth2LoginOptions
|
|
1382
1490
|
|
|
1383
1491
|
| Prop | Type | Description | Default |
|
|
@@ -1396,10 +1504,10 @@ Configuration for a single OAuth2 provider instance
|
|
|
1396
1504
|
|
|
1397
1505
|
#### isLoggedInOptions
|
|
1398
1506
|
|
|
1399
|
-
| Prop | Type
|
|
1400
|
-
| ---------------- |
|
|
1401
|
-
| **`provider`** | <code>'apple' \| 'google' \| 'facebook' \| 'twitter' \| 'oauth2'</code> | Provider |
|
|
1402
|
-
| **`providerId`** | <code>string</code>
|
|
1507
|
+
| Prop | Type | Description |
|
|
1508
|
+
| ---------------- | --------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------- |
|
|
1509
|
+
| **`provider`** | <code>'apple' \| 'google' \| 'facebook' \| 'twitter' \| 'linkedin' \| 'oauth2' \| 'telegram'</code> | Provider |
|
|
1510
|
+
| **`providerId`** | <code>string</code> | Provider ID for OAuth2 providers (required when provider is 'oauth2') |
|
|
1403
1511
|
|
|
1404
1512
|
|
|
1405
1513
|
#### AuthorizationCode
|
|
@@ -1412,10 +1520,10 @@ Configuration for a single OAuth2 provider instance
|
|
|
1412
1520
|
|
|
1413
1521
|
#### AuthorizationCodeOptions
|
|
1414
1522
|
|
|
1415
|
-
| Prop | Type
|
|
1416
|
-
| ---------------- |
|
|
1417
|
-
| **`provider`** | <code>'apple' \| 'google' \| 'facebook' \| 'twitter' \| 'oauth2'</code> | Provider |
|
|
1418
|
-
| **`providerId`** | <code>string</code>
|
|
1523
|
+
| Prop | Type | Description |
|
|
1524
|
+
| ---------------- | ------------------------------------------------------------------------------------- | --------------------------------------------------------------------- |
|
|
1525
|
+
| **`provider`** | <code>'apple' \| 'google' \| 'facebook' \| 'twitter' \| 'linkedin' \| 'oauth2'</code> | Provider |
|
|
1526
|
+
| **`providerId`** | <code>string</code> | Provider ID for OAuth2 providers (required when provider is 'oauth2') |
|
|
1419
1527
|
|
|
1420
1528
|
|
|
1421
1529
|
#### FacebookGetProfileResponse
|
|
@@ -1524,7 +1632,7 @@ Construct a type with a set of properties K of type T
|
|
|
1524
1632
|
|
|
1525
1633
|
#### ProviderResponseMap
|
|
1526
1634
|
|
|
1527
|
-
<code>{ facebook: <a href="#facebookloginresponse">FacebookLoginResponse</a>; google: <a href="#googleloginresponse">GoogleLoginResponse</a>; apple: <a href="#appleproviderresponse">AppleProviderResponse</a>; twitter: <a href="#twitterloginresponse">TwitterLoginResponse</a>; oauth2: <a href="#oauth2loginresponse">OAuth2LoginResponse</a>; }</code>
|
|
1635
|
+
<code>{ facebook: <a href="#facebookloginresponse">FacebookLoginResponse</a>; google: <a href="#googleloginresponse">GoogleLoginResponse</a>; apple: <a href="#appleproviderresponse">AppleProviderResponse</a>; twitter: <a href="#twitterloginresponse">TwitterLoginResponse</a>; telegram: <a href="#telegramloginresponse">TelegramLoginResponse</a>; linkedin: <a href="#linkedinloginresponse">LinkedInLoginResponse</a>; oauth2: <a href="#oauth2loginresponse">OAuth2LoginResponse</a>; }</code>
|
|
1528
1636
|
|
|
1529
1637
|
|
|
1530
1638
|
#### GoogleLoginResponse
|
|
@@ -1532,9 +1640,45 @@ Construct a type with a set of properties K of type T
|
|
|
1532
1640
|
<code><a href="#googleloginresponseonline">GoogleLoginResponseOnline</a> | <a href="#googleloginresponseoffline">GoogleLoginResponseOffline</a></code>
|
|
1533
1641
|
|
|
1534
1642
|
|
|
1643
|
+
#### LinkedInLoginResponse
|
|
1644
|
+
|
|
1645
|
+
LinkedIn login response (returned when using the LinkedIn convenience API).
|
|
1646
|
+
|
|
1647
|
+
<code><a href="#oauth2loginresponse">OAuth2LoginResponse</a></code>
|
|
1648
|
+
|
|
1649
|
+
|
|
1535
1650
|
#### LoginOptions
|
|
1536
1651
|
|
|
1537
|
-
<code>{ provider: 'facebook'; options: <a href="#facebookloginoptions">FacebookLoginOptions</a>; } | { provider: 'google'; options: <a href="#googleloginoptions">GoogleLoginOptions</a>; } | { provider: 'apple'; options: <a href="#appleprovideroptions">AppleProviderOptions</a>; } | { provider: 'twitter'; options: <a href="#twitterloginoptions">TwitterLoginOptions</a>; } | { provider: 'oauth2'; options: <a href="#oauth2loginoptions">OAuth2LoginOptions</a>; }</code>
|
|
1652
|
+
<code>{ provider: 'facebook'; options: <a href="#facebookloginoptions">FacebookLoginOptions</a>; } | { provider: 'google'; options: <a href="#googleloginoptions">GoogleLoginOptions</a>; } | { provider: 'apple'; options: <a href="#appleprovideroptions">AppleProviderOptions</a>; } | { provider: 'twitter'; options: <a href="#twitterloginoptions">TwitterLoginOptions</a>; } | { provider: 'telegram'; options: <a href="#telegramloginoptions">TelegramLoginOptions</a>; } | { provider: 'linkedin'; options: <a href="#linkedinloginoptions">LinkedInLoginOptions</a>; } | { provider: 'oauth2'; options: <a href="#oauth2loginoptions">OAuth2LoginOptions</a>; }</code>
|
|
1653
|
+
|
|
1654
|
+
|
|
1655
|
+
#### LinkedInLoginOptions
|
|
1656
|
+
|
|
1657
|
+
LinkedIn login options (maps to the OAuth2 provider internally).
|
|
1658
|
+
`providerId` is set to `linkedin` automatically.
|
|
1659
|
+
|
|
1660
|
+
<code><a href="#omit">Omit</a><<a href="#oauth2loginoptions">OAuth2LoginOptions</a>, 'providerId'></code>
|
|
1661
|
+
|
|
1662
|
+
|
|
1663
|
+
#### Omit
|
|
1664
|
+
|
|
1665
|
+
Construct a type with the properties of T except for those in type K.
|
|
1666
|
+
|
|
1667
|
+
<code><a href="#pick">Pick</a><T, <a href="#exclude">Exclude</a><keyof T, K>></code>
|
|
1668
|
+
|
|
1669
|
+
|
|
1670
|
+
#### Pick
|
|
1671
|
+
|
|
1672
|
+
From T, pick a set of properties whose keys are in the union K
|
|
1673
|
+
|
|
1674
|
+
<code>{
|
|
1538
1675
|
[P in K]: T[P];
|
|
1539
1676
|
}</code>
|
|
1677
|
+
|
|
1678
|
+
|
|
1679
|
+
#### Exclude
|
|
1680
|
+
|
|
1681
|
+
<a href="#exclude">Exclude</a> from T those types that are assignable to U
|
|
1682
|
+
|
|
1683
|
+
<code>T extends U ? never : T</code>
|
|
1540
1684
|
|
|
1541
1685
|
|
|
1542
1686
|
#### Extract
|
|
@@ -1544,9 +1688,17 @@ Construct a type with a set of properties K of type T
|
|
|
1544
1688
|
<code>T extends U ? T : never</code>
|
|
1545
1689
|
|
|
1546
1690
|
|
|
1691
|
+
#### RefreshTokenOptions
|
|
1692
|
+
|
|
1693
|
+
Options for `refreshToken()`.
|
|
1694
|
+
`providerId` is required for generic `oauth2` and ignored for LinkedIn.
|
|
1695
|
+
|
|
1696
|
+
<code>{ provider: 'oauth2'; providerId: string; refreshToken?: string; additionalParameters?: <a href="#record">Record</a><string, string>; } | { provider: 'linkedin'; providerId?: string; refreshToken?: string; additionalParameters?: <a href="#record">Record</a><string, string>; }</code>
|
|
1697
|
+
|
|
1698
|
+
|
|
1547
1699
|
#### LoginResult
|
|
1548
1700
|
|
|
1549
|
-
<code>{ provider: 'facebook'; result: <a href="#facebookloginresponse">FacebookLoginResponse</a>; } | { provider: 'google'; result: <a href="#googleloginresponse">GoogleLoginResponse</a>; } | { provider: 'apple'; result: <a href="#appleproviderresponse">AppleProviderResponse</a>; } | { provider: 'twitter'; result: <a href="#twitterloginresponse">TwitterLoginResponse</a>; } | { provider: 'oauth2'; result: <a href="#oauth2loginresponse">OAuth2LoginResponse</a>; }</code>
|
|
1701
|
+
<code>{ provider: 'facebook'; result: <a href="#facebookloginresponse">FacebookLoginResponse</a>; } | { provider: 'google'; result: <a href="#googleloginresponse">GoogleLoginResponse</a>; } | { provider: 'apple'; result: <a href="#appleproviderresponse">AppleProviderResponse</a>; } | { provider: 'twitter'; result: <a href="#twitterloginresponse">TwitterLoginResponse</a>; } | { provider: 'telegram'; result: <a href="#telegramloginresponse">TelegramLoginResponse</a>; } | { provider: 'linkedin'; result: <a href="#linkedinloginresponse">LinkedInLoginResponse</a>; } | { provider: 'oauth2'; result: <a href="#oauth2loginresponse">OAuth2LoginResponse</a>; }</code>
|
|
1550
1702
|
|
|
1551
1703
|
|
|
1552
1704
|
#### ProviderSpecificCallResponseMap
|
|
@@ -76,6 +76,13 @@ public class OAuth2LoginActivity extends Activity {
|
|
|
76
76
|
data.putExtra("error", uri.getQueryParameter("error"));
|
|
77
77
|
data.putExtra("error_description", uri.getQueryParameter("error_description"));
|
|
78
78
|
|
|
79
|
+
for (String name : uri.getQueryParameterNames()) {
|
|
80
|
+
if (data.hasExtra(name)) {
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
data.putExtra(name, uri.getQueryParameter(name));
|
|
84
|
+
}
|
|
85
|
+
|
|
79
86
|
// Handle implicit flow (fragment parameters)
|
|
80
87
|
String fragment = uri.getFragment();
|
|
81
88
|
if (fragment != null && !fragment.isEmpty()) {
|
|
@@ -24,7 +24,7 @@ import org.json.JSONObject;
|
|
|
24
24
|
@CapacitorPlugin(name = "SocialLogin")
|
|
25
25
|
public class SocialLoginPlugin extends Plugin {
|
|
26
26
|
|
|
27
|
-
private final String pluginVersion = "8.5.
|
|
27
|
+
private final String pluginVersion = "8.5.4";
|
|
28
28
|
|
|
29
29
|
public static String LOG_TAG = "CapgoSocialLogin";
|
|
30
30
|
public HashMap<String, SocialProvider> socialProviderHashMap = new HashMap<>();
|
|
@@ -164,6 +164,27 @@ public class SocialLoginPlugin extends Plugin {
|
|
|
164
164
|
}
|
|
165
165
|
}
|
|
166
166
|
|
|
167
|
+
JSObject telegram = call.getObject("telegram");
|
|
168
|
+
if (telegram != null) {
|
|
169
|
+
if (!DependencyAvailabilityChecker.isProviderAvailable("telegram")) {
|
|
170
|
+
call.reject("Telegram provider is disabled in capacitor.config");
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
String botId = telegram.getString("botId");
|
|
174
|
+
if (botId == null || botId.isEmpty()) {
|
|
175
|
+
call.reject("telegram.botId is null or empty");
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
TelegramProvider telegramProvider = new TelegramProvider(this.getActivity(), this.getContext());
|
|
179
|
+
try {
|
|
180
|
+
telegramProvider.initialize(telegram);
|
|
181
|
+
this.socialProviderHashMap.put("telegram", telegramProvider);
|
|
182
|
+
} catch (JSONException e) {
|
|
183
|
+
call.reject("Failed to initialize Telegram provider: " + e.getMessage());
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
167
188
|
JSObject oauth2 = call.getObject("oauth2");
|
|
168
189
|
if (oauth2 != null && oauth2.length() > 0) {
|
|
169
190
|
// oauth2 is now a map of providerId -> config: { "github": {...}, "azure": {...} }
|
|
@@ -483,6 +504,15 @@ public class SocialLoginPlugin extends Plugin {
|
|
|
483
504
|
}
|
|
484
505
|
}
|
|
485
506
|
|
|
507
|
+
SocialProvider telegramProvider = socialProviderHashMap.get("telegram");
|
|
508
|
+
if (telegramProvider instanceof TelegramProvider) {
|
|
509
|
+
boolean handled = ((TelegramProvider) telegramProvider).handleActivityResult(requestCode, resultCode, data);
|
|
510
|
+
if (handled) {
|
|
511
|
+
Log.d(LOG_TAG, "Telegram activity result handled");
|
|
512
|
+
return;
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
|
|
486
516
|
SocialProvider oauth2Provider = socialProviderHashMap.get("oauth2");
|
|
487
517
|
if (oauth2Provider instanceof OAuth2Provider) {
|
|
488
518
|
boolean handled = ((OAuth2Provider) oauth2Provider).handleActivityResult(requestCode, resultCode, data);
|