@capgo/capacitor-social-login 7.16.0 → 7.17.0
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 +55 -18
- package/android/src/main/AndroidManifest.xml +4 -0
- package/android/src/main/java/ee/forgr/capacitor/social/login/AppleProvider.java +1 -1
- package/android/src/main/java/ee/forgr/capacitor/social/login/SocialLoginPlugin.java +32 -1
- package/android/src/main/java/ee/forgr/capacitor/social/login/TwitterLoginActivity.java +93 -0
- package/android/src/main/java/ee/forgr/capacitor/social/login/TwitterProvider.java +510 -0
- package/dist/docs.json +184 -8
- package/dist/esm/definitions.d.ts +83 -3
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/google-provider.d.ts +3 -1
- package/dist/esm/google-provider.js +25 -3
- package/dist/esm/google-provider.js.map +1 -1
- package/dist/esm/twitter-provider.d.ts +36 -0
- package/dist/esm/twitter-provider.js +346 -0
- package/dist/esm/twitter-provider.js.map +1 -0
- package/dist/esm/web.d.ts +2 -1
- package/dist/esm/web.js +59 -8
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +428 -11
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +428 -11
- package/dist/plugin.js.map +1 -1
- package/ios/Sources/SocialLoginPlugin/SocialLoginPlugin.swift +93 -1
- package/ios/Sources/SocialLoginPlugin/TwitterProvider.swift +381 -0
- package/package.json +1 -1
package/dist/docs.json
CHANGED
|
@@ -30,12 +30,12 @@
|
|
|
30
30
|
},
|
|
31
31
|
{
|
|
32
32
|
"name": "login",
|
|
33
|
-
"signature": "<T extends \"apple\" | \"google\" | \"facebook\">(options: Extract<LoginOptions, { provider: T; }>) => Promise<{ provider: T; result: ProviderResponseMap[T]; }>",
|
|
33
|
+
"signature": "<T extends \"apple\" | \"google\" | \"facebook\" | \"twitter\">(options: Extract<LoginOptions, { provider: T; }>) => Promise<{ provider: T; result: ProviderResponseMap[T]; }>",
|
|
34
34
|
"parameters": [
|
|
35
35
|
{
|
|
36
36
|
"name": "options",
|
|
37
37
|
"docs": "",
|
|
38
|
-
"type": "Extract<{ provider: 'facebook'; options: FacebookLoginOptions; }, { provider: T; }> | Extract<{ provider: 'google'; options: GoogleLoginOptions; }, { provider: T; }> | Extract<{ provider: 'apple'; options: AppleProviderOptions; }, { provider: T; }>"
|
|
38
|
+
"type": "Extract<{ provider: 'facebook'; options: FacebookLoginOptions; }, { provider: T; }> | Extract<{ provider: 'google'; options: GoogleLoginOptions; }, { provider: T; }> | Extract<{ provider: 'apple'; options: AppleProviderOptions; }, { provider: T; }> | Extract<{ provider: 'twitter'; options: TwitterLoginOptions; }, { provider: T; }>"
|
|
39
39
|
}
|
|
40
40
|
],
|
|
41
41
|
"returns": "Promise<{ provider: T; result: ProviderResponseMap[T]; }>",
|
|
@@ -56,12 +56,12 @@
|
|
|
56
56
|
},
|
|
57
57
|
{
|
|
58
58
|
"name": "logout",
|
|
59
|
-
"signature": "(options: { provider: 'apple' | 'google' | 'facebook'; }) => Promise<void>",
|
|
59
|
+
"signature": "(options: { provider: 'apple' | 'google' | 'facebook' | 'twitter'; }) => Promise<void>",
|
|
60
60
|
"parameters": [
|
|
61
61
|
{
|
|
62
62
|
"name": "options",
|
|
63
63
|
"docs": "",
|
|
64
|
-
"type": "{ provider: 'apple' | 'google' | 'facebook'; }"
|
|
64
|
+
"type": "{ provider: 'apple' | 'google' | 'facebook' | 'twitter'; }"
|
|
65
65
|
}
|
|
66
66
|
],
|
|
67
67
|
"returns": "Promise<void>",
|
|
@@ -213,6 +213,13 @@
|
|
|
213
213
|
"tags": [],
|
|
214
214
|
"methods": [],
|
|
215
215
|
"properties": [
|
|
216
|
+
{
|
|
217
|
+
"name": "twitter",
|
|
218
|
+
"tags": [],
|
|
219
|
+
"docs": "",
|
|
220
|
+
"complexTypes": [],
|
|
221
|
+
"type": "{ clientId: string; redirectUrl: string; defaultScopes?: string[] | undefined; forceLogin?: boolean | undefined; audience?: string | undefined; } | undefined"
|
|
222
|
+
},
|
|
216
223
|
{
|
|
217
224
|
"name": "facebook",
|
|
218
225
|
"tags": [],
|
|
@@ -324,6 +331,13 @@
|
|
|
324
331
|
"complexTypes": [],
|
|
325
332
|
"type": "string"
|
|
326
333
|
},
|
|
334
|
+
{
|
|
335
|
+
"name": "tokenType",
|
|
336
|
+
"tags": [],
|
|
337
|
+
"docs": "",
|
|
338
|
+
"complexTypes": [],
|
|
339
|
+
"type": "string | undefined"
|
|
340
|
+
},
|
|
327
341
|
{
|
|
328
342
|
"name": "refreshToken",
|
|
329
343
|
"tags": [],
|
|
@@ -465,6 +479,112 @@
|
|
|
465
479
|
}
|
|
466
480
|
]
|
|
467
481
|
},
|
|
482
|
+
{
|
|
483
|
+
"name": "TwitterLoginResponse",
|
|
484
|
+
"slug": "twitterloginresponse",
|
|
485
|
+
"docs": "",
|
|
486
|
+
"tags": [],
|
|
487
|
+
"methods": [],
|
|
488
|
+
"properties": [
|
|
489
|
+
{
|
|
490
|
+
"name": "accessToken",
|
|
491
|
+
"tags": [],
|
|
492
|
+
"docs": "",
|
|
493
|
+
"complexTypes": [
|
|
494
|
+
"AccessToken"
|
|
495
|
+
],
|
|
496
|
+
"type": "AccessToken | null"
|
|
497
|
+
},
|
|
498
|
+
{
|
|
499
|
+
"name": "refreshToken",
|
|
500
|
+
"tags": [],
|
|
501
|
+
"docs": "",
|
|
502
|
+
"complexTypes": [],
|
|
503
|
+
"type": "string | null | undefined"
|
|
504
|
+
},
|
|
505
|
+
{
|
|
506
|
+
"name": "scope",
|
|
507
|
+
"tags": [],
|
|
508
|
+
"docs": "",
|
|
509
|
+
"complexTypes": [],
|
|
510
|
+
"type": "string[]"
|
|
511
|
+
},
|
|
512
|
+
{
|
|
513
|
+
"name": "tokenType",
|
|
514
|
+
"tags": [],
|
|
515
|
+
"docs": "",
|
|
516
|
+
"complexTypes": [],
|
|
517
|
+
"type": "'bearer'"
|
|
518
|
+
},
|
|
519
|
+
{
|
|
520
|
+
"name": "expiresIn",
|
|
521
|
+
"tags": [],
|
|
522
|
+
"docs": "",
|
|
523
|
+
"complexTypes": [],
|
|
524
|
+
"type": "number | null | undefined"
|
|
525
|
+
},
|
|
526
|
+
{
|
|
527
|
+
"name": "profile",
|
|
528
|
+
"tags": [],
|
|
529
|
+
"docs": "",
|
|
530
|
+
"complexTypes": [
|
|
531
|
+
"TwitterProfile"
|
|
532
|
+
],
|
|
533
|
+
"type": "TwitterProfile"
|
|
534
|
+
}
|
|
535
|
+
]
|
|
536
|
+
},
|
|
537
|
+
{
|
|
538
|
+
"name": "TwitterProfile",
|
|
539
|
+
"slug": "twitterprofile",
|
|
540
|
+
"docs": "",
|
|
541
|
+
"tags": [],
|
|
542
|
+
"methods": [],
|
|
543
|
+
"properties": [
|
|
544
|
+
{
|
|
545
|
+
"name": "id",
|
|
546
|
+
"tags": [],
|
|
547
|
+
"docs": "",
|
|
548
|
+
"complexTypes": [],
|
|
549
|
+
"type": "string"
|
|
550
|
+
},
|
|
551
|
+
{
|
|
552
|
+
"name": "username",
|
|
553
|
+
"tags": [],
|
|
554
|
+
"docs": "",
|
|
555
|
+
"complexTypes": [],
|
|
556
|
+
"type": "string"
|
|
557
|
+
},
|
|
558
|
+
{
|
|
559
|
+
"name": "name",
|
|
560
|
+
"tags": [],
|
|
561
|
+
"docs": "",
|
|
562
|
+
"complexTypes": [],
|
|
563
|
+
"type": "string | null"
|
|
564
|
+
},
|
|
565
|
+
{
|
|
566
|
+
"name": "profileImageUrl",
|
|
567
|
+
"tags": [],
|
|
568
|
+
"docs": "",
|
|
569
|
+
"complexTypes": [],
|
|
570
|
+
"type": "string | null"
|
|
571
|
+
},
|
|
572
|
+
{
|
|
573
|
+
"name": "verified",
|
|
574
|
+
"tags": [],
|
|
575
|
+
"docs": "",
|
|
576
|
+
"complexTypes": [],
|
|
577
|
+
"type": "boolean"
|
|
578
|
+
},
|
|
579
|
+
{
|
|
580
|
+
"name": "email",
|
|
581
|
+
"tags": [],
|
|
582
|
+
"docs": "",
|
|
583
|
+
"complexTypes": [],
|
|
584
|
+
"type": "string | null | undefined"
|
|
585
|
+
}
|
|
586
|
+
]
|
|
587
|
+
},
|
|
468
588
|
{
|
|
469
589
|
"name": "FacebookLoginOptions",
|
|
470
590
|
"slug": "facebookloginoptions",
|
|
@@ -728,6 +848,55 @@
|
|
|
728
848
|
}
|
|
729
849
|
]
|
|
730
850
|
},
|
|
851
|
+
{
|
|
852
|
+
"name": "TwitterLoginOptions",
|
|
853
|
+
"slug": "twitterloginoptions",
|
|
854
|
+
"docs": "",
|
|
855
|
+
"tags": [],
|
|
856
|
+
"methods": [],
|
|
857
|
+
"properties": [
|
|
858
|
+
{
|
|
859
|
+
"name": "scopes",
|
|
860
|
+
"tags": [
|
|
861
|
+
{
|
|
862
|
+
"text": "['tweet.read','users.read','offline.access']",
|
|
863
|
+
"name": "example"
|
|
864
|
+
}
|
|
865
|
+
],
|
|
866
|
+
"docs": "Additional scopes to request during login.\nIf omitted the plugin falls back to the default scopes configured during initialization.",
|
|
867
|
+
"complexTypes": [],
|
|
868
|
+
"type": "string[] | undefined"
|
|
869
|
+
},
|
|
870
|
+
{
|
|
871
|
+
"name": "state",
|
|
872
|
+
"tags": [],
|
|
873
|
+
"docs": "Provide a custom OAuth state value.\nWhen not provided the plugin generates a cryptographically random value.",
|
|
874
|
+
"complexTypes": [],
|
|
875
|
+
"type": "string | undefined"
|
|
876
|
+
},
|
|
877
|
+
{
|
|
878
|
+
"name": "codeVerifier",
|
|
879
|
+
"tags": [],
|
|
880
|
+
"docs": "Provide a pre-computed PKCE code verifier (mostly used for testing).\nWhen omitted the plugin generates a secure verifier automatically.",
|
|
881
|
+
"complexTypes": [],
|
|
882
|
+
"type": "string | undefined"
|
|
883
|
+
},
|
|
884
|
+
{
|
|
885
|
+
"name": "redirectUrl",
|
|
886
|
+
"tags": [],
|
|
887
|
+
"docs": "Override the redirect URI for a single login call.\nUseful when the same app supports multiple callback URLs per platform.",
|
|
888
|
+
"complexTypes": [],
|
|
889
|
+
"type": "string | undefined"
|
|
890
|
+
},
|
|
891
|
+
{
|
|
892
|
+
"name": "forceLogin",
|
|
893
|
+
"tags": [],
|
|
894
|
+
"docs": "Force the consent screen on every attempt, maps to `force_login=true`.",
|
|
895
|
+
"complexTypes": [],
|
|
896
|
+
"type": "boolean | undefined"
|
|
897
|
+
}
|
|
898
|
+
]
|
|
899
|
+
},
|
|
731
900
|
{
|
|
732
901
|
"name": "isLoggedInOptions",
|
|
733
902
|
"slug": "isloggedinoptions",
|
|
@@ -745,7 +914,7 @@
|
|
|
745
914
|
],
|
|
746
915
|
"docs": "Provider",
|
|
747
916
|
"complexTypes": [],
|
|
748
|
-
"type": "'apple' | 'google' | 'facebook'"
|
|
917
|
+
"type": "'apple' | 'google' | 'facebook' | 'twitter'"
|
|
749
918
|
}
|
|
750
919
|
]
|
|
751
920
|
},
|
|
@@ -799,7 +968,7 @@
|
|
|
799
968
|
],
|
|
800
969
|
"docs": "Provider",
|
|
801
970
|
"complexTypes": [],
|
|
802
|
-
"type": "'apple' | 'google' | 'facebook'"
|
|
971
|
+
"type": "'apple' | 'google' | 'facebook' | 'twitter'"
|
|
803
972
|
}
|
|
804
973
|
]
|
|
805
974
|
},
|
|
@@ -865,11 +1034,12 @@
|
|
|
865
1034
|
"docs": "",
|
|
866
1035
|
"types": [
|
|
867
1036
|
{
|
|
868
|
-
"text": "{\n facebook: FacebookLoginResponse;\n google: GoogleLoginResponse;\n apple: AppleProviderResponse;\n}",
|
|
1037
|
+
"text": "{\n facebook: FacebookLoginResponse;\n google: GoogleLoginResponse;\n apple: AppleProviderResponse;\n twitter: TwitterLoginResponse;\n}",
|
|
869
1038
|
"complexTypes": [
|
|
870
1039
|
"FacebookLoginResponse",
|
|
871
1040
|
"GoogleLoginResponse",
|
|
872
|
-
"AppleProviderResponse"
|
|
1041
|
+
"AppleProviderResponse",
|
|
1042
|
+
"TwitterLoginResponse"
|
|
873
1043
|
]
|
|
874
1044
|
}
|
|
875
1045
|
]
|
|
@@ -915,6 +1085,12 @@
|
|
|
915
1085
|
"complexTypes": [
|
|
916
1086
|
"AppleProviderOptions"
|
|
917
1087
|
]
|
|
1088
|
+
},
|
|
1089
|
+
{
|
|
1090
|
+
"text": "{\n provider: 'twitter';\n options: TwitterLoginOptions;\n }",
|
|
1091
|
+
"complexTypes": [
|
|
1092
|
+
"TwitterLoginOptions"
|
|
1093
|
+
]
|
|
918
1094
|
}
|
|
919
1095
|
]
|
|
920
1096
|
},
|
|
@@ -1,4 +1,33 @@
|
|
|
1
1
|
export interface InitializeOptions {
|
|
2
|
+
twitter?: {
|
|
3
|
+
/**
|
|
4
|
+
* The OAuth 2.0 client identifier issued by X (Twitter) Developer Portal
|
|
5
|
+
* @example 'Y2xpZW50SWQ'
|
|
6
|
+
*/
|
|
7
|
+
clientId: string;
|
|
8
|
+
/**
|
|
9
|
+
* Redirect URL that is registered inside the X Developer Portal.
|
|
10
|
+
* The plugin uses this URL on every platform to receive the authorization code.
|
|
11
|
+
* @example 'myapp://auth/x'
|
|
12
|
+
*/
|
|
13
|
+
redirectUrl: string;
|
|
14
|
+
/**
|
|
15
|
+
* Default scopes appended to every login request when no custom scopes are provided.
|
|
16
|
+
* @description Defaults to the minimum required scopes for Log in with X.
|
|
17
|
+
* @default ['tweet.read','users.read']
|
|
18
|
+
*/
|
|
19
|
+
defaultScopes?: string[];
|
|
20
|
+
/**
|
|
21
|
+
* Force the consent screen to show on every login attempt.
|
|
22
|
+
* Mirrors X's `force_login=true` flag.
|
|
23
|
+
* @default false
|
|
24
|
+
*/
|
|
25
|
+
forceLogin?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Optional audience value when your application has been approved for multi-tenant access.
|
|
28
|
+
*/
|
|
29
|
+
audience?: string;
|
|
30
|
+
};
|
|
2
31
|
facebook?: {
|
|
3
32
|
/**
|
|
4
33
|
* Facebook App ID, provided by Facebook for web, in mobile it's set in the native files
|
|
@@ -165,6 +194,33 @@ export interface FacebookLoginOptions {
|
|
|
165
194
|
*/
|
|
166
195
|
nonce?: string;
|
|
167
196
|
}
|
|
197
|
+
export interface TwitterLoginOptions {
|
|
198
|
+
/**
|
|
199
|
+
* Additional scopes to request during login.
|
|
200
|
+
* If omitted the plugin falls back to the default scopes configured during initialization.
|
|
201
|
+
* @example ['tweet.read','users.read','offline.access']
|
|
202
|
+
*/
|
|
203
|
+
scopes?: string[];
|
|
204
|
+
/**
|
|
205
|
+
* Provide a custom OAuth state value.
|
|
206
|
+
* When not provided the plugin generates a cryptographically random value.
|
|
207
|
+
*/
|
|
208
|
+
state?: string;
|
|
209
|
+
/**
|
|
210
|
+
* Provide a pre-computed PKCE code verifier (mostly used for testing).
|
|
211
|
+
* When omitted the plugin generates a secure verifier automatically.
|
|
212
|
+
*/
|
|
213
|
+
codeVerifier?: string;
|
|
214
|
+
/**
|
|
215
|
+
* Override the redirect URI for a single login call.
|
|
216
|
+
* Useful when the same app supports multiple callback URLs per platform.
|
|
217
|
+
*/
|
|
218
|
+
redirectUrl?: string;
|
|
219
|
+
/**
|
|
220
|
+
* Force the consent screen on every attempt, maps to `force_login=true`.
|
|
221
|
+
*/
|
|
222
|
+
forceLogin?: boolean;
|
|
223
|
+
}
|
|
168
224
|
export interface GoogleLoginOptions {
|
|
169
225
|
/**
|
|
170
226
|
* Specifies the scopes required for accessing Google APIs
|
|
@@ -331,6 +387,9 @@ export type LoginOptions = {
|
|
|
331
387
|
} | {
|
|
332
388
|
provider: 'apple';
|
|
333
389
|
options: AppleProviderOptions;
|
|
390
|
+
} | {
|
|
391
|
+
provider: 'twitter';
|
|
392
|
+
options: TwitterLoginOptions;
|
|
334
393
|
};
|
|
335
394
|
export type LoginResult = {
|
|
336
395
|
provider: 'facebook';
|
|
@@ -341,6 +400,9 @@ export type LoginResult = {
|
|
|
341
400
|
} | {
|
|
342
401
|
provider: 'apple';
|
|
343
402
|
result: AppleProviderResponse;
|
|
403
|
+
} | {
|
|
404
|
+
provider: 'twitter';
|
|
405
|
+
result: TwitterLoginResponse;
|
|
344
406
|
};
|
|
345
407
|
export interface AccessToken {
|
|
346
408
|
applicationId?: string;
|
|
@@ -350,6 +412,7 @@ export interface AccessToken {
|
|
|
350
412
|
lastRefresh?: string;
|
|
351
413
|
permissions?: string[];
|
|
352
414
|
token: string;
|
|
415
|
+
tokenType?: string;
|
|
353
416
|
refreshToken?: string;
|
|
354
417
|
userId?: string;
|
|
355
418
|
}
|
|
@@ -379,6 +442,22 @@ export interface FacebookLoginResponse {
|
|
|
379
442
|
imageURL: string | null;
|
|
380
443
|
};
|
|
381
444
|
}
|
|
445
|
+
export interface TwitterProfile {
|
|
446
|
+
id: string;
|
|
447
|
+
username: string;
|
|
448
|
+
name: string | null;
|
|
449
|
+
profileImageUrl: string | null;
|
|
450
|
+
verified: boolean;
|
|
451
|
+
email?: string | null;
|
|
452
|
+
}
|
|
453
|
+
export interface TwitterLoginResponse {
|
|
454
|
+
accessToken: AccessToken | null;
|
|
455
|
+
refreshToken?: string | null;
|
|
456
|
+
scope: string[];
|
|
457
|
+
tokenType: 'bearer';
|
|
458
|
+
expiresIn?: number | null;
|
|
459
|
+
profile: TwitterProfile;
|
|
460
|
+
}
|
|
382
461
|
export interface AuthorizationCode {
|
|
383
462
|
/**
|
|
384
463
|
* Jwt
|
|
@@ -396,14 +475,14 @@ export interface AuthorizationCodeOptions {
|
|
|
396
475
|
* Provider
|
|
397
476
|
* @description Provider for the authorization code
|
|
398
477
|
*/
|
|
399
|
-
provider: 'apple' | 'google' | 'facebook';
|
|
478
|
+
provider: 'apple' | 'google' | 'facebook' | 'twitter';
|
|
400
479
|
}
|
|
401
480
|
export interface isLoggedInOptions {
|
|
402
481
|
/**
|
|
403
482
|
* Provider
|
|
404
483
|
* @description Provider for the isLoggedIn
|
|
405
484
|
*/
|
|
406
|
-
provider: 'apple' | 'google' | 'facebook';
|
|
485
|
+
provider: 'apple' | 'google' | 'facebook' | 'twitter';
|
|
407
486
|
}
|
|
408
487
|
export type ProviderSpecificCall = 'facebook#getProfile' | 'facebook#requestTracking';
|
|
409
488
|
export interface FacebookGetProfileOptions {
|
|
@@ -453,6 +532,7 @@ export type ProviderResponseMap = {
|
|
|
453
532
|
facebook: FacebookLoginResponse;
|
|
454
533
|
google: GoogleLoginResponse;
|
|
455
534
|
apple: AppleProviderResponse;
|
|
535
|
+
twitter: TwitterLoginResponse;
|
|
456
536
|
};
|
|
457
537
|
export interface SocialLoginPlugin {
|
|
458
538
|
/**
|
|
@@ -481,7 +561,7 @@ export interface SocialLoginPlugin {
|
|
|
481
561
|
* @throws Error if Google provider is in offline mode
|
|
482
562
|
*/
|
|
483
563
|
logout(options: {
|
|
484
|
-
provider: 'apple' | 'google' | 'facebook';
|
|
564
|
+
provider: 'apple' | 'google' | 'facebook' | 'twitter';
|
|
485
565
|
}): Promise<void>;
|
|
486
566
|
/**
|
|
487
567
|
* IsLoggedIn
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["export interface InitializeOptions {\n facebook?: {\n /**\n * Facebook App ID, provided by Facebook for web, in mobile it's set in the native files\n */\n appId: string;\n /**\n * Facebook Client Token, provided by Facebook for web, in mobile it's set in the native files\n */\n clientToken?: string;\n /**\n * Locale\n * @description The locale to use for the Facebook SDK (e.g., 'en_US', 'fr_FR', 'es_ES')\n * @default 'en_US'\n * @example 'fr_FR'\n */\n locale?: string;\n };\n\n google?: {\n /**\n * The app's client ID, found and created in the Google Developers Console.\n * Required for iOS platform.\n * @example xxxxxx-xxxxxxxxxxxxxxxxxx.apps.googleusercontent.com\n * @since 3.1.0\n */\n iOSClientId?: string;\n /**\n * The app's server client ID, required for offline mode on iOS.\n * Should be the same value as webClientId.\n * Found and created in the Google Developers Console.\n * @example xxxxxx-xxxxxxxxxxxxxxxxxx.apps.googleusercontent.com\n * @since 3.1.0\n */\n iOSServerClientId?: string;\n /**\n * The app's web client ID, found and created in the Google Developers Console.\n * Required for Android and Web platforms.\n * @example xxxxxx-xxxxxxxxxxxxxxxxxx.apps.googleusercontent.com\n * @since 3.1.0\n */\n webClientId?: string;\n /**\n * The login mode, can be online or offline.\n *\n * **Online mode (default):**\n * - Returns user profile data and access tokens\n * - Supports all methods: login, logout, isLoggedIn, getAuthorizationCode\n *\n * **Offline mode:**\n * - Returns only serverAuthCode for backend authentication\n * - No user profile data available\n * - **Limitations:** The following methods are NOT supported in offline mode:\n * - `logout()` - Will reject with \"not implemented when using offline mode\"\n * - `isLoggedIn()` - Will reject with \"not implemented when using offline mode\"\n * - `getAuthorizationCode()` - Will reject with \"not implemented when using offline mode\"\n * - Only `login()` method works in offline mode, returning serverAuthCode only\n * - Requires `iOSServerClientId` to be set on iOS\n *\n * @example 'offline'\n * @default 'online'\n * @since 3.1.0\n */\n mode?: 'online' | 'offline';\n /**\n * Filter visible accounts by hosted domain\n * @description filter visible accounts by hosted domain\n */\n hostedDomain?: string;\n /**\n * Google Redirect URL, should be your backend url that is configured in your google app\n */\n redirectUrl?: string;\n };\n apple?: {\n /**\n * Apple Client ID, provided by Apple for web and Android\n */\n clientId?: string;\n /**\n * Apple Redirect URL, should be your backend url that is configured in your apple app\n *\n * **Note**: Use empty string `''` for iOS to prevent redirect.\n * **Note**: Not required when using Broadcast Channel mode on Android.\n */\n redirectUrl?: string;\n /**\n * Use proper token exchange for Apple Sign-In\n * @description Controls how Apple Sign-In tokens are handled and what gets returned:\n *\n * **When `true` (Recommended for new implementations):**\n * - Exchanges authorization code for proper access tokens via Apple's token endpoint\n * - `idToken`: JWT containing user identity information (email, name, user ID)\n * - `accessToken.token`: Proper access token from Apple (short-lived, ~1 hour)\n * - `authorizationCode`: Raw authorization code for backend token exchange\n *\n * **When `false` (Default - Legacy mode):**\n * - Uses authorization code directly as access token for backward compatibility\n * - `idToken`: JWT containing user identity information (email, name, user ID)\n * - `accessToken.token`: The authorization code itself (not a real access token)\n * - `authorizationCode`: undefined\n *\n * @default false\n * @example\n * // Enable proper token exchange (recommended)\n * useProperTokenExchange: true\n * // Result: idToken=JWT, accessToken=real_token, authorizationCode=present\n *\n * // Legacy mode (backward compatibility)\n * useProperTokenExchange: false\n * // Result: idToken=JWT, accessToken=auth_code, authorizationCode=undefined\n */\n useProperTokenExchange?: boolean;\n /**\n * Use Broadcast Channel for Android Apple Sign-In (Recommended)\n * @description When enabled, Android uses Broadcast Channel API instead of URL redirects.\n * This eliminates the need for redirect URL configuration and server-side setup.\n *\n * **Benefits:**\n * - No redirect URL configuration required\n * - No backend server needed for Android\n * - Simpler setup and more reliable communication\n * - Direct client-server communication via Broadcast Channel\n *\n * **When `true`:**\n * - Uses Broadcast Channel for authentication flow\n * - `redirectUrl` is ignored\n * - Requires Broadcast Channel compatible backend or direct token handling\n *\n * **When `false` (Default - Legacy mode):**\n * - Uses traditional URL redirect flow\n * - Requires `redirectUrl` configuration\n * - Requires backend server for token exchange\n *\n * @default false\n * @since 7.10.0\n * @example\n * // Enable Broadcast Channel mode (recommended for new Android implementations)\n * useBroadcastChannel: true\n * // Result: Simplified setup, no redirect URL needed\n *\n * // Legacy mode (backward compatibility)\n * useBroadcastChannel: false\n * // Result: Traditional URL redirect flow with server-side setup\n */\n useBroadcastChannel?: boolean;\n };\n}\n\nexport interface FacebookLoginOptions {\n /**\n * Permissions\n * @description select permissions to login with\n */\n permissions: string[];\n /**\n * Is Limited Login\n * @description use limited login for Facebook iOS only. Important: This is iOS-only and doesn't affect Android.\n * Even if set to false, Facebook will automatically force it to true if App Tracking Transparency (ATT) permission is not granted.\n * Developers should always be prepared to handle both limited and full login scenarios.\n * @default false\n */\n limitedLogin?: boolean;\n /**\n * Nonce\n * @description A custom nonce to use for the login request\n */\n nonce?: string;\n}\n\nexport interface GoogleLoginOptions {\n /**\n * Specifies the scopes required for accessing Google APIs\n * The default is defined in the configuration.\n * @example [\"profile\", \"email\"]\n * @see [Google OAuth2 Scopes](https://developers.google.com/identity/protocols/oauth2/scopes)\n */\n scopes?: string[];\n /**\n * Nonce\n * @description nonce\n */\n nonce?: string;\n /**\n * Force refresh token (only for Android)\n * @description force refresh token\n * @default false\n */\n forceRefreshToken?: boolean;\n /**\n * Force account selection prompt (iOS)\n * @description forces the account selection prompt to appear on iOS\n * @default false\n */\n forcePrompt?: boolean;\n /**\n * Style\n * @description style\n * @default 'standard'\n */\n style?: 'bottom' | 'standard';\n /**\n * Filter by authorized accounts (Android only)\n * @description Only show accounts that have previously been used to sign in to the app.\n * This option is only available for the 'bottom' style.\n * Note: For Family Link supervised accounts, this should be set to false.\n * @default true\n */\n filterByAuthorizedAccounts?: boolean;\n /**\n * Auto select enabled (Android only)\n * @description Automatically select the account if only one Google account is available.\n * This option is only available for the 'bottom' style.\n * @default false\n */\n autoSelectEnabled?: boolean;\n /**\n * Prompt parameter for Google OAuth (Web only)\n * @description A space-delimited, case-sensitive list of prompts to present the user.\n * If you don't specify this parameter, the user will be prompted only the first time your project requests access.\n *\n * **Possible values:**\n * - `none`: Don't display any authentication or consent screens. Must not be specified with other values.\n * - `consent`: Prompt the user for consent.\n * - `select_account`: Prompt the user to select an account.\n *\n * **Examples:**\n * - `prompt: 'consent'` - Always show consent screen\n * - `prompt: 'select_account'` - Always show account selection\n * - `prompt: 'consent select_account'` - Show both consent and account selection\n *\n * **Note:** This parameter only affects web platform behavior. Mobile platforms use their own native prompts.\n *\n * @example 'consent'\n * @example 'select_account'\n * @example 'consent select_account'\n * @see [Google OAuth2 Prompt Parameter](https://developers.google.com/identity/protocols/oauth2/openid-connect#prompt)\n * @since 7.12.0\n */\n prompt?: 'none' | 'consent' | 'select_account' | 'consent select_account' | 'select_account consent';\n}\n\nexport interface GoogleLoginResponseOnline {\n accessToken: AccessToken | null;\n idToken: string | null;\n profile: {\n email: string | null;\n familyName: string | null;\n givenName: string | null;\n id: string | null;\n name: string | null;\n imageUrl: string | null;\n };\n responseType: 'online';\n}\n\nexport interface GoogleLoginResponseOffline {\n serverAuthCode: string;\n responseType: 'offline';\n}\n\nexport type GoogleLoginResponse = GoogleLoginResponseOnline | GoogleLoginResponseOffline;\n\nexport interface AppleProviderOptions {\n /**\n * Scopes\n * @description An array of scopes to request during login\n * @example [\"name\", \"email\"]\n * default: [\"name\", \"email\"]\n */\n scopes?: string[];\n /**\n * Nonce\n * @description nonce\n */\n nonce?: string;\n /**\n * State\n * @description state\n */\n state?: string;\n /**\n * Use Broadcast Channel for authentication flow\n * @description When enabled, uses Broadcast Channel API for communication instead of URL redirects.\n * Only applicable on platforms that support Broadcast Channel (Android).\n * @default false\n */\n useBroadcastChannel?: boolean;\n}\n\nexport interface AppleProviderResponse {\n /**\n * Access token from Apple\n * @description Content depends on `useProperTokenExchange` setting:\n * - When `useProperTokenExchange: true`: Real access token from Apple (~1 hour validity)\n * - When `useProperTokenExchange: false`: Contains authorization code as token (legacy mode)\n * Use `idToken` for user authentication, `accessToken` for API calls when properly exchanged.\n */\n accessToken: AccessToken | null;\n\n /**\n * Identity token (JWT) from Apple\n * @description Always contains the JWT with user identity information including:\n * - User ID (sub claim)\n * - Email (if user granted permission)\n * - Name components (if user granted permission)\n * - Email verification status\n * This is the primary token for user authentication and should be verified on your backend.\n */\n idToken: string | null;\n\n /**\n * User profile information\n * @description Basic user profile data extracted from the identity token and Apple response:\n * - `user`: Apple's user identifier (sub claim from idToken)\n * - `email`: User's email address (if permission granted)\n * - `givenName`: User's first name (if permission granted)\n * - `familyName`: User's last name (if permission granted)\n */\n profile: {\n user: string;\n email: string | null;\n givenName: string | null;\n familyName: string | null;\n };\n\n /**\n * Authorization code for proper token exchange (when useProperTokenExchange is enabled)\n * @description Only present when `useProperTokenExchange` is `true`. This code should be exchanged\n * for proper access tokens on your backend using Apple's token endpoint. Use this for secure\n * server-side token validation and to obtain refresh tokens.\n * @see https://developer.apple.com/documentation/sign_in_with_apple/tokenresponse\n */\n authorizationCode?: string;\n}\n\nexport type LoginOptions =\n | {\n provider: 'facebook';\n options: FacebookLoginOptions;\n }\n | {\n provider: 'google';\n options: GoogleLoginOptions;\n }\n | {\n provider: 'apple';\n options: AppleProviderOptions;\n };\n\nexport type LoginResult =\n | {\n provider: 'facebook';\n result: FacebookLoginResponse;\n }\n | {\n provider: 'google';\n result: GoogleLoginResponse;\n }\n | {\n provider: 'apple';\n result: AppleProviderResponse;\n };\n\nexport interface AccessToken {\n applicationId?: string;\n declinedPermissions?: string[];\n expires?: string;\n isExpired?: boolean;\n lastRefresh?: string;\n permissions?: string[];\n token: string;\n refreshToken?: string;\n userId?: string;\n}\n\nexport interface FacebookLoginResponse {\n accessToken: AccessToken | null;\n idToken: string | null;\n profile: {\n userID: string;\n email: string | null;\n friendIDs: string[];\n birthday: string | null;\n ageRange: { min?: number; max?: number } | null;\n gender: string | null;\n location: { id: string; name: string } | null;\n hometown: { id: string; name: string } | null;\n profileURL: string | null;\n name: string | null;\n imageURL: string | null;\n };\n}\n\nexport interface AuthorizationCode {\n /**\n * Jwt\n * @description A JSON web token\n */\n jwt?: string;\n /**\n * Access Token\n * @description An access token\n */\n accessToken?: string;\n}\n\nexport interface AuthorizationCodeOptions {\n /**\n * Provider\n * @description Provider for the authorization code\n */\n provider: 'apple' | 'google' | 'facebook';\n}\n\nexport interface isLoggedInOptions {\n /**\n * Provider\n * @description Provider for the isLoggedIn\n */\n provider: 'apple' | 'google' | 'facebook';\n}\n\n// Define the provider-specific call types\nexport type ProviderSpecificCall = 'facebook#getProfile' | 'facebook#requestTracking';\n\n// Define the options and response types for each specific call\nexport interface FacebookGetProfileOptions {\n /**\n * Fields to retrieve from Facebook profile\n * @example [\"id\", \"name\", \"email\", \"picture\"]\n */\n fields?: string[];\n}\n\nexport interface FacebookGetProfileResponse {\n /**\n * Facebook profile data\n */\n profile: {\n id: string | null;\n name: string | null;\n email: string | null;\n first_name: string | null;\n last_name: string | null;\n picture?: {\n data: {\n height: number | null;\n is_silhouette: boolean | null;\n url: string | null;\n width: number | null;\n };\n } | null;\n [key: string]: any; // For additional fields that might be requested\n };\n}\n\nexport type FacebookRequestTrackingOptions = Record<string, never>;\n\nexport interface FacebookRequestTrackingResponse {\n /**\n * App tracking authorization status\n */\n status: 'authorized' | 'denied' | 'notDetermined' | 'restricted';\n}\n\n// Map call strings to their options and response types\nexport type ProviderSpecificCallOptionsMap = {\n 'facebook#getProfile': FacebookGetProfileOptions;\n 'facebook#requestTracking': FacebookRequestTrackingOptions;\n};\n\nexport type ProviderSpecificCallResponseMap = {\n 'facebook#getProfile': FacebookGetProfileResponse;\n 'facebook#requestTracking': FacebookRequestTrackingResponse;\n};\n\n// Add a helper type to map providers to their response types\nexport type ProviderResponseMap = {\n facebook: FacebookLoginResponse;\n google: GoogleLoginResponse;\n apple: AppleProviderResponse;\n};\n\nexport interface SocialLoginPlugin {\n /**\n * Initialize the plugin\n * @description initialize the plugin with the required options\n */\n initialize(options: InitializeOptions): Promise<void>;\n /**\n * Login with the selected provider\n * @description login with the selected provider\n */\n login<T extends LoginOptions['provider']>(\n options: Extract<LoginOptions, { provider: T }>,\n ): Promise<{ provider: T; result: ProviderResponseMap[T] }>;\n /**\n * Logout\n * @description Logout the user from the specified provider\n *\n * **Google Offline Mode Limitation:**\n * This method is NOT supported when Google is initialized with `mode: 'offline'`.\n * It will reject with error: \"logout is not implemented when using offline mode\"\n *\n * @throws Error if Google provider is in offline mode\n */\n logout(options: { provider: 'apple' | 'google' | 'facebook' }): Promise<void>;\n /**\n * IsLoggedIn\n * @description Check if the user is currently logged in with the specified provider\n *\n * **Google Offline Mode Limitation:**\n * This method is NOT supported when Google is initialized with `mode: 'offline'`.\n * It will reject with error: \"isLoggedIn is not implemented when using offline mode\"\n *\n * @throws Error if Google provider is in offline mode\n */\n isLoggedIn(options: isLoggedInOptions): Promise<{ isLoggedIn: boolean }>;\n\n /**\n * Get the current authorization code\n * @description Get the authorization code for server-side authentication\n *\n * **Google Offline Mode Limitation:**\n * This method is NOT supported when Google is initialized with `mode: 'offline'`.\n * It will reject with error: \"getAuthorizationCode is not implemented when using offline mode\"\n *\n * In offline mode, the authorization code (serverAuthCode) is already returned by the `login()` method.\n *\n * @throws Error if Google provider is in offline mode\n */\n getAuthorizationCode(options: AuthorizationCodeOptions): Promise<AuthorizationCode>;\n /**\n * Refresh the access token\n * @description refresh the access token\n */\n refresh(options: LoginOptions): Promise<void>;\n\n /**\n * Execute provider-specific calls\n * @description Execute a provider-specific functionality\n */\n providerSpecificCall<T extends ProviderSpecificCall>(options: {\n call: T;\n options: ProviderSpecificCallOptionsMap[T];\n }): Promise<ProviderSpecificCallResponseMap[T]>;\n\n /**\n * Get the native Capacitor plugin version\n *\n * @returns {Promise<{ id: string }>} an Promise with version for this device\n * @throws An error if the something went wrong\n */\n getPluginVersion(): Promise<{ version: string }>;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["export interface InitializeOptions {\n twitter?: {\n /**\n * The OAuth 2.0 client identifier issued by X (Twitter) Developer Portal\n * @example 'Y2xpZW50SWQ'\n */\n clientId: string;\n /**\n * Redirect URL that is registered inside the X Developer Portal.\n * The plugin uses this URL on every platform to receive the authorization code.\n * @example 'myapp://auth/x'\n */\n redirectUrl: string;\n /**\n * Default scopes appended to every login request when no custom scopes are provided.\n * @description Defaults to the minimum required scopes for Log in with X.\n * @default ['tweet.read','users.read']\n */\n defaultScopes?: string[];\n /**\n * Force the consent screen to show on every login attempt.\n * Mirrors X's `force_login=true` flag.\n * @default false\n */\n forceLogin?: boolean;\n /**\n * Optional audience value when your application has been approved for multi-tenant access.\n */\n audience?: string;\n };\n facebook?: {\n /**\n * Facebook App ID, provided by Facebook for web, in mobile it's set in the native files\n */\n appId: string;\n /**\n * Facebook Client Token, provided by Facebook for web, in mobile it's set in the native files\n */\n clientToken?: string;\n /**\n * Locale\n * @description The locale to use for the Facebook SDK (e.g., 'en_US', 'fr_FR', 'es_ES')\n * @default 'en_US'\n * @example 'fr_FR'\n */\n locale?: string;\n };\n\n google?: {\n /**\n * The app's client ID, found and created in the Google Developers Console.\n * Required for iOS platform.\n * @example xxxxxx-xxxxxxxxxxxxxxxxxx.apps.googleusercontent.com\n * @since 3.1.0\n */\n iOSClientId?: string;\n /**\n * The app's server client ID, required for offline mode on iOS.\n * Should be the same value as webClientId.\n * Found and created in the Google Developers Console.\n * @example xxxxxx-xxxxxxxxxxxxxxxxxx.apps.googleusercontent.com\n * @since 3.1.0\n */\n iOSServerClientId?: string;\n /**\n * The app's web client ID, found and created in the Google Developers Console.\n * Required for Android and Web platforms.\n * @example xxxxxx-xxxxxxxxxxxxxxxxxx.apps.googleusercontent.com\n * @since 3.1.0\n */\n webClientId?: string;\n /**\n * The login mode, can be online or offline.\n *\n * **Online mode (default):**\n * - Returns user profile data and access tokens\n * - Supports all methods: login, logout, isLoggedIn, getAuthorizationCode\n *\n * **Offline mode:**\n * - Returns only serverAuthCode for backend authentication\n * - No user profile data available\n * - **Limitations:** The following methods are NOT supported in offline mode:\n * - `logout()` - Will reject with \"not implemented when using offline mode\"\n * - `isLoggedIn()` - Will reject with \"not implemented when using offline mode\"\n * - `getAuthorizationCode()` - Will reject with \"not implemented when using offline mode\"\n * - Only `login()` method works in offline mode, returning serverAuthCode only\n * - Requires `iOSServerClientId` to be set on iOS\n *\n * @example 'offline'\n * @default 'online'\n * @since 3.1.0\n */\n mode?: 'online' | 'offline';\n /**\n * Filter visible accounts by hosted domain\n * @description filter visible accounts by hosted domain\n */\n hostedDomain?: string;\n /**\n * Google Redirect URL, should be your backend url that is configured in your google app\n */\n redirectUrl?: string;\n };\n apple?: {\n /**\n * Apple Client ID, provided by Apple for web and Android\n */\n clientId?: string;\n /**\n * Apple Redirect URL, should be your backend url that is configured in your apple app\n *\n * **Note**: Use empty string `''` for iOS to prevent redirect.\n * **Note**: Not required when using Broadcast Channel mode on Android.\n */\n redirectUrl?: string;\n /**\n * Use proper token exchange for Apple Sign-In\n * @description Controls how Apple Sign-In tokens are handled and what gets returned:\n *\n * **When `true` (Recommended for new implementations):**\n * - Exchanges authorization code for proper access tokens via Apple's token endpoint\n * - `idToken`: JWT containing user identity information (email, name, user ID)\n * - `accessToken.token`: Proper access token from Apple (short-lived, ~1 hour)\n * - `authorizationCode`: Raw authorization code for backend token exchange\n *\n * **When `false` (Default - Legacy mode):**\n * - Uses authorization code directly as access token for backward compatibility\n * - `idToken`: JWT containing user identity information (email, name, user ID)\n * - `accessToken.token`: The authorization code itself (not a real access token)\n * - `authorizationCode`: undefined\n *\n * @default false\n * @example\n * // Enable proper token exchange (recommended)\n * useProperTokenExchange: true\n * // Result: idToken=JWT, accessToken=real_token, authorizationCode=present\n *\n * // Legacy mode (backward compatibility)\n * useProperTokenExchange: false\n * // Result: idToken=JWT, accessToken=auth_code, authorizationCode=undefined\n */\n useProperTokenExchange?: boolean;\n /**\n * Use Broadcast Channel for Android Apple Sign-In (Recommended)\n * @description When enabled, Android uses Broadcast Channel API instead of URL redirects.\n * This eliminates the need for redirect URL configuration and server-side setup.\n *\n * **Benefits:**\n * - No redirect URL configuration required\n * - No backend server needed for Android\n * - Simpler setup and more reliable communication\n * - Direct client-server communication via Broadcast Channel\n *\n * **When `true`:**\n * - Uses Broadcast Channel for authentication flow\n * - `redirectUrl` is ignored\n * - Requires Broadcast Channel compatible backend or direct token handling\n *\n * **When `false` (Default - Legacy mode):**\n * - Uses traditional URL redirect flow\n * - Requires `redirectUrl` configuration\n * - Requires backend server for token exchange\n *\n * @default false\n * @since 7.10.0\n * @example\n * // Enable Broadcast Channel mode (recommended for new Android implementations)\n * useBroadcastChannel: true\n * // Result: Simplified setup, no redirect URL needed\n *\n * // Legacy mode (backward compatibility)\n * useBroadcastChannel: false\n * // Result: Traditional URL redirect flow with server-side setup\n */\n useBroadcastChannel?: boolean;\n };\n}\n\nexport interface FacebookLoginOptions {\n /**\n * Permissions\n * @description select permissions to login with\n */\n permissions: string[];\n /**\n * Is Limited Login\n * @description use limited login for Facebook iOS only. Important: This is iOS-only and doesn't affect Android.\n * Even if set to false, Facebook will automatically force it to true if App Tracking Transparency (ATT) permission is not granted.\n * Developers should always be prepared to handle both limited and full login scenarios.\n * @default false\n */\n limitedLogin?: boolean;\n /**\n * Nonce\n * @description A custom nonce to use for the login request\n */\n nonce?: string;\n}\n\nexport interface TwitterLoginOptions {\n /**\n * Additional scopes to request during login.\n * If omitted the plugin falls back to the default scopes configured during initialization.\n * @example ['tweet.read','users.read','offline.access']\n */\n scopes?: string[];\n /**\n * Provide a custom OAuth state value.\n * When not provided the plugin generates a cryptographically random value.\n */\n state?: string;\n /**\n * Provide a pre-computed PKCE code verifier (mostly used for testing).\n * When omitted the plugin generates a secure verifier automatically.\n */\n codeVerifier?: string;\n /**\n * Override the redirect URI for a single login call.\n * Useful when the same app supports multiple callback URLs per platform.\n */\n redirectUrl?: string;\n /**\n * Force the consent screen on every attempt, maps to `force_login=true`.\n */\n forceLogin?: boolean;\n}\n\nexport interface GoogleLoginOptions {\n /**\n * Specifies the scopes required for accessing Google APIs\n * The default is defined in the configuration.\n * @example [\"profile\", \"email\"]\n * @see [Google OAuth2 Scopes](https://developers.google.com/identity/protocols/oauth2/scopes)\n */\n scopes?: string[];\n /**\n * Nonce\n * @description nonce\n */\n nonce?: string;\n /**\n * Force refresh token (only for Android)\n * @description force refresh token\n * @default false\n */\n forceRefreshToken?: boolean;\n /**\n * Force account selection prompt (iOS)\n * @description forces the account selection prompt to appear on iOS\n * @default false\n */\n forcePrompt?: boolean;\n /**\n * Style\n * @description style\n * @default 'standard'\n */\n style?: 'bottom' | 'standard';\n /**\n * Filter by authorized accounts (Android only)\n * @description Only show accounts that have previously been used to sign in to the app.\n * This option is only available for the 'bottom' style.\n * Note: For Family Link supervised accounts, this should be set to false.\n * @default true\n */\n filterByAuthorizedAccounts?: boolean;\n /**\n * Auto select enabled (Android only)\n * @description Automatically select the account if only one Google account is available.\n * This option is only available for the 'bottom' style.\n * @default false\n */\n autoSelectEnabled?: boolean;\n /**\n * Prompt parameter for Google OAuth (Web only)\n * @description A space-delimited, case-sensitive list of prompts to present the user.\n * If you don't specify this parameter, the user will be prompted only the first time your project requests access.\n *\n * **Possible values:**\n * - `none`: Don't display any authentication or consent screens. Must not be specified with other values.\n * - `consent`: Prompt the user for consent.\n * - `select_account`: Prompt the user to select an account.\n *\n * **Examples:**\n * - `prompt: 'consent'` - Always show consent screen\n * - `prompt: 'select_account'` - Always show account selection\n * - `prompt: 'consent select_account'` - Show both consent and account selection\n *\n * **Note:** This parameter only affects web platform behavior. Mobile platforms use their own native prompts.\n *\n * @example 'consent'\n * @example 'select_account'\n * @example 'consent select_account'\n * @see [Google OAuth2 Prompt Parameter](https://developers.google.com/identity/protocols/oauth2/openid-connect#prompt)\n * @since 7.12.0\n */\n prompt?: 'none' | 'consent' | 'select_account' | 'consent select_account' | 'select_account consent';\n}\n\nexport interface GoogleLoginResponseOnline {\n accessToken: AccessToken | null;\n idToken: string | null;\n profile: {\n email: string | null;\n familyName: string | null;\n givenName: string | null;\n id: string | null;\n name: string | null;\n imageUrl: string | null;\n };\n responseType: 'online';\n}\n\nexport interface GoogleLoginResponseOffline {\n serverAuthCode: string;\n responseType: 'offline';\n}\n\nexport type GoogleLoginResponse = GoogleLoginResponseOnline | GoogleLoginResponseOffline;\n\nexport interface AppleProviderOptions {\n /**\n * Scopes\n * @description An array of scopes to request during login\n * @example [\"name\", \"email\"]\n * default: [\"name\", \"email\"]\n */\n scopes?: string[];\n /**\n * Nonce\n * @description nonce\n */\n nonce?: string;\n /**\n * State\n * @description state\n */\n state?: string;\n /**\n * Use Broadcast Channel for authentication flow\n * @description When enabled, uses Broadcast Channel API for communication instead of URL redirects.\n * Only applicable on platforms that support Broadcast Channel (Android).\n * @default false\n */\n useBroadcastChannel?: boolean;\n}\n\nexport interface AppleProviderResponse {\n /**\n * Access token from Apple\n * @description Content depends on `useProperTokenExchange` setting:\n * - When `useProperTokenExchange: true`: Real access token from Apple (~1 hour validity)\n * - When `useProperTokenExchange: false`: Contains authorization code as token (legacy mode)\n * Use `idToken` for user authentication, `accessToken` for API calls when properly exchanged.\n */\n accessToken: AccessToken | null;\n\n /**\n * Identity token (JWT) from Apple\n * @description Always contains the JWT with user identity information including:\n * - User ID (sub claim)\n * - Email (if user granted permission)\n * - Name components (if user granted permission)\n * - Email verification status\n * This is the primary token for user authentication and should be verified on your backend.\n */\n idToken: string | null;\n\n /**\n * User profile information\n * @description Basic user profile data extracted from the identity token and Apple response:\n * - `user`: Apple's user identifier (sub claim from idToken)\n * - `email`: User's email address (if permission granted)\n * - `givenName`: User's first name (if permission granted)\n * - `familyName`: User's last name (if permission granted)\n */\n profile: {\n user: string;\n email: string | null;\n givenName: string | null;\n familyName: string | null;\n };\n\n /**\n * Authorization code for proper token exchange (when useProperTokenExchange is enabled)\n * @description Only present when `useProperTokenExchange` is `true`. This code should be exchanged\n * for proper access tokens on your backend using Apple's token endpoint. Use this for secure\n * server-side token validation and to obtain refresh tokens.\n * @see https://developer.apple.com/documentation/sign_in_with_apple/tokenresponse\n */\n authorizationCode?: string;\n}\n\nexport type LoginOptions =\n | {\n provider: 'facebook';\n options: FacebookLoginOptions;\n }\n | {\n provider: 'google';\n options: GoogleLoginOptions;\n }\n | {\n provider: 'apple';\n options: AppleProviderOptions;\n }\n | {\n provider: 'twitter';\n options: TwitterLoginOptions;\n };\n\nexport type LoginResult =\n | {\n provider: 'facebook';\n result: FacebookLoginResponse;\n }\n | {\n provider: 'google';\n result: GoogleLoginResponse;\n }\n | {\n provider: 'apple';\n result: AppleProviderResponse;\n }\n | {\n provider: 'twitter';\n result: TwitterLoginResponse;\n };\n\nexport interface AccessToken {\n applicationId?: string;\n declinedPermissions?: string[];\n expires?: string;\n isExpired?: boolean;\n lastRefresh?: string;\n permissions?: string[];\n token: string;\n tokenType?: string;\n refreshToken?: string;\n userId?: string;\n}\n\nexport interface FacebookLoginResponse {\n accessToken: AccessToken | null;\n idToken: string | null;\n profile: {\n userID: string;\n email: string | null;\n friendIDs: string[];\n birthday: string | null;\n ageRange: { min?: number; max?: number } | null;\n gender: string | null;\n location: { id: string; name: string } | null;\n hometown: { id: string; name: string } | null;\n profileURL: string | null;\n name: string | null;\n imageURL: string | null;\n };\n}\n\nexport interface TwitterProfile {\n id: string;\n username: string;\n name: string | null;\n profileImageUrl: string | null;\n verified: boolean;\n email?: string | null;\n}\n\nexport interface TwitterLoginResponse {\n accessToken: AccessToken | null;\n refreshToken?: string | null;\n scope: string[];\n tokenType: 'bearer';\n expiresIn?: number | null;\n profile: TwitterProfile;\n}\n\nexport interface AuthorizationCode {\n /**\n * Jwt\n * @description A JSON web token\n */\n jwt?: string;\n /**\n * Access Token\n * @description An access token\n */\n accessToken?: string;\n}\n\nexport interface AuthorizationCodeOptions {\n /**\n * Provider\n * @description Provider for the authorization code\n */\n provider: 'apple' | 'google' | 'facebook' | 'twitter';\n}\n\nexport interface isLoggedInOptions {\n /**\n * Provider\n * @description Provider for the isLoggedIn\n */\n provider: 'apple' | 'google' | 'facebook' | 'twitter';\n}\n\n// Define the provider-specific call types\nexport type ProviderSpecificCall = 'facebook#getProfile' | 'facebook#requestTracking';\n\n// Define the options and response types for each specific call\nexport interface FacebookGetProfileOptions {\n /**\n * Fields to retrieve from Facebook profile\n * @example [\"id\", \"name\", \"email\", \"picture\"]\n */\n fields?: string[];\n}\n\nexport interface FacebookGetProfileResponse {\n /**\n * Facebook profile data\n */\n profile: {\n id: string | null;\n name: string | null;\n email: string | null;\n first_name: string | null;\n last_name: string | null;\n picture?: {\n data: {\n height: number | null;\n is_silhouette: boolean | null;\n url: string | null;\n width: number | null;\n };\n } | null;\n [key: string]: any; // For additional fields that might be requested\n };\n}\n\nexport type FacebookRequestTrackingOptions = Record<string, never>;\n\nexport interface FacebookRequestTrackingResponse {\n /**\n * App tracking authorization status\n */\n status: 'authorized' | 'denied' | 'notDetermined' | 'restricted';\n}\n\n// Map call strings to their options and response types\nexport type ProviderSpecificCallOptionsMap = {\n 'facebook#getProfile': FacebookGetProfileOptions;\n 'facebook#requestTracking': FacebookRequestTrackingOptions;\n};\n\nexport type ProviderSpecificCallResponseMap = {\n 'facebook#getProfile': FacebookGetProfileResponse;\n 'facebook#requestTracking': FacebookRequestTrackingResponse;\n};\n\n// Add a helper type to map providers to their response types\nexport type ProviderResponseMap = {\n facebook: FacebookLoginResponse;\n google: GoogleLoginResponse;\n apple: AppleProviderResponse;\n twitter: TwitterLoginResponse;\n};\n\nexport interface SocialLoginPlugin {\n /**\n * Initialize the plugin\n * @description initialize the plugin with the required options\n */\n initialize(options: InitializeOptions): Promise<void>;\n /**\n * Login with the selected provider\n * @description login with the selected provider\n */\n login<T extends LoginOptions['provider']>(\n options: Extract<LoginOptions, { provider: T }>,\n ): Promise<{ provider: T; result: ProviderResponseMap[T] }>;\n /**\n * Logout\n * @description Logout the user from the specified provider\n *\n * **Google Offline Mode Limitation:**\n * This method is NOT supported when Google is initialized with `mode: 'offline'`.\n * It will reject with error: \"logout is not implemented when using offline mode\"\n *\n * @throws Error if Google provider is in offline mode\n */\n logout(options: { provider: 'apple' | 'google' | 'facebook' | 'twitter' }): Promise<void>;\n /**\n * IsLoggedIn\n * @description Check if the user is currently logged in with the specified provider\n *\n * **Google Offline Mode Limitation:**\n * This method is NOT supported when Google is initialized with `mode: 'offline'`.\n * It will reject with error: \"isLoggedIn is not implemented when using offline mode\"\n *\n * @throws Error if Google provider is in offline mode\n */\n isLoggedIn(options: isLoggedInOptions): Promise<{ isLoggedIn: boolean }>;\n\n /**\n * Get the current authorization code\n * @description Get the authorization code for server-side authentication\n *\n * **Google Offline Mode Limitation:**\n * This method is NOT supported when Google is initialized with `mode: 'offline'`.\n * It will reject with error: \"getAuthorizationCode is not implemented when using offline mode\"\n *\n * In offline mode, the authorization code (serverAuthCode) is already returned by the `login()` method.\n *\n * @throws Error if Google provider is in offline mode\n */\n getAuthorizationCode(options: AuthorizationCodeOptions): Promise<AuthorizationCode>;\n /**\n * Refresh the access token\n * @description refresh the access token\n */\n refresh(options: LoginOptions): Promise<void>;\n\n /**\n * Execute provider-specific calls\n * @description Execute a provider-specific functionality\n */\n providerSpecificCall<T extends ProviderSpecificCall>(options: {\n call: T;\n options: ProviderSpecificCallOptionsMap[T];\n }): Promise<ProviderSpecificCallResponseMap[T]>;\n\n /**\n * Get the native Capacitor plugin version\n *\n * @returns {Promise<{ id: string }>} an Promise with version for this device\n * @throws An error if the something went wrong\n */\n getPluginVersion(): Promise<{ version: string }>;\n}\n"]}
|
|
@@ -18,7 +18,9 @@ export declare class GoogleSocialLogin extends BaseSocialLogin {
|
|
|
18
18
|
}>;
|
|
19
19
|
getAuthorizationCode(): Promise<AuthorizationCode>;
|
|
20
20
|
refresh(): Promise<void>;
|
|
21
|
-
handleOAuthRedirect(url: URL): LoginResult |
|
|
21
|
+
handleOAuthRedirect(url: URL): LoginResult | {
|
|
22
|
+
error: string;
|
|
23
|
+
} | null;
|
|
22
24
|
private accessTokenIsValid;
|
|
23
25
|
private idTokenValid;
|
|
24
26
|
private rawLogoutGoogle;
|
|
@@ -120,6 +120,13 @@ export class GoogleSocialLogin extends BaseSocialLogin {
|
|
|
120
120
|
}
|
|
121
121
|
handleOAuthRedirect(url) {
|
|
122
122
|
const paramsRaw = url.searchParams;
|
|
123
|
+
// Check for errors in search params first (for offline mode)
|
|
124
|
+
const errorInParams = paramsRaw.get('error');
|
|
125
|
+
if (errorInParams) {
|
|
126
|
+
localStorage.removeItem(BaseSocialLogin.OAUTH_STATE_KEY);
|
|
127
|
+
const errorDescription = paramsRaw.get('error_description') || errorInParams;
|
|
128
|
+
return { error: errorDescription };
|
|
129
|
+
}
|
|
123
130
|
const code = paramsRaw.get('code');
|
|
124
131
|
if (code && paramsRaw.has('scope')) {
|
|
125
132
|
return {
|
|
@@ -134,8 +141,15 @@ export class GoogleSocialLogin extends BaseSocialLogin {
|
|
|
134
141
|
console.log('handleOAuthRedirect', url.hash);
|
|
135
142
|
if (!hash)
|
|
136
143
|
return null;
|
|
137
|
-
console.log('handleOAuthRedirect ok');
|
|
138
144
|
const params = new URLSearchParams(hash);
|
|
145
|
+
// Check for error cases in hash (e.g., user cancelled)
|
|
146
|
+
const error = params.get('error');
|
|
147
|
+
if (error) {
|
|
148
|
+
localStorage.removeItem(BaseSocialLogin.OAUTH_STATE_KEY);
|
|
149
|
+
const errorDescription = params.get('error_description') || error;
|
|
150
|
+
return { error: errorDescription };
|
|
151
|
+
}
|
|
152
|
+
console.log('handleOAuthRedirect ok');
|
|
139
153
|
const accessToken = params.get('access_token');
|
|
140
154
|
const idToken = params.get('id_token');
|
|
141
155
|
if (accessToken && idToken) {
|
|
@@ -286,7 +300,7 @@ export class GoogleSocialLogin extends BaseSocialLogin {
|
|
|
286
300
|
const height = 600;
|
|
287
301
|
const left = window.screenX + (window.outerWidth - width) / 2;
|
|
288
302
|
const top = window.screenY + (window.outerHeight - height) / 2;
|
|
289
|
-
localStorage.setItem(BaseSocialLogin.OAUTH_STATE_KEY, '
|
|
303
|
+
localStorage.setItem(BaseSocialLogin.OAUTH_STATE_KEY, JSON.stringify({ provider: 'google', loginType: this.loginType }));
|
|
290
304
|
const popup = window.open(url, 'Google Sign In', `width=${width},height=${height},left=${left},top=${top},popup=1`);
|
|
291
305
|
let popupClosedInterval;
|
|
292
306
|
let timeoutHandle;
|
|
@@ -297,12 +311,13 @@ export class GoogleSocialLogin extends BaseSocialLogin {
|
|
|
297
311
|
return;
|
|
298
312
|
}
|
|
299
313
|
const handleMessage = (event) => {
|
|
300
|
-
var _a, _b, _c;
|
|
314
|
+
var _a, _b, _c, _d;
|
|
301
315
|
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')))
|
|
302
316
|
return;
|
|
303
317
|
if (((_c = event.data) === null || _c === void 0 ? void 0 : _c.type) === 'oauth-response') {
|
|
304
318
|
window.removeEventListener('message', handleMessage);
|
|
305
319
|
clearInterval(popupClosedInterval);
|
|
320
|
+
clearTimeout(timeoutHandle);
|
|
306
321
|
if (this.loginType === 'online') {
|
|
307
322
|
const { accessToken, idToken } = event.data;
|
|
308
323
|
if (accessToken && idToken) {
|
|
@@ -339,6 +354,13 @@ export class GoogleSocialLogin extends BaseSocialLogin {
|
|
|
339
354
|
});
|
|
340
355
|
}
|
|
341
356
|
}
|
|
357
|
+
else if (((_d = event.data) === null || _d === void 0 ? void 0 : _d.type) === 'oauth-error') {
|
|
358
|
+
window.removeEventListener('message', handleMessage);
|
|
359
|
+
clearInterval(popupClosedInterval);
|
|
360
|
+
clearTimeout(timeoutHandle);
|
|
361
|
+
const errorMessage = event.data.error || 'User cancelled the OAuth flow';
|
|
362
|
+
reject(new Error(errorMessage));
|
|
363
|
+
}
|
|
342
364
|
// Don't reject for non-OAuth messages, just ignore them
|
|
343
365
|
};
|
|
344
366
|
window.addEventListener('message', handleMessage);
|