@capgo/capacitor-social-login 8.3.16 → 8.3.17
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 +5 -1
- package/android/src/main/java/ee/forgr/capacitor/social/login/GoogleProvider.java +4 -1
- package/android/src/main/java/ee/forgr/capacitor/social/login/SocialLoginPlugin.java +1 -1
- package/dist/docs.json +2 -2
- package/dist/esm/definitions.d.ts +10 -2
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/google-provider.js +6 -2
- package/dist/esm/google-provider.js.map +1 -1
- package/dist/esm/index.d.ts +2 -2
- package/dist/esm/index.js +2 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/social-login.d.ts +64 -1
- package/dist/esm/social-login.js +63 -1
- package/dist/esm/social-login.js.map +1 -1
- package/dist/plugin.cjs.js +71 -4
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +71 -4
- package/dist/plugin.js.map +1 -1
- package/ios/Sources/SocialLoginPlugin/GoogleProvider.swift +6 -0
- package/ios/Sources/SocialLoginPlugin/SocialLoginPlugin.swift +1 -1
- package/package.json +1 -1
package/dist/esm/social-login.js
CHANGED
|
@@ -1,5 +1,67 @@
|
|
|
1
1
|
import { registerPlugin } from '@capacitor/core';
|
|
2
|
-
|
|
2
|
+
const GOOGLE_OFFLINE_REFRESH_MESSAGE = "Google refresh() is not available when using offline mode. Offline mode only returns serverAuthCode for backend token exchange. Send serverAuthCode to your backend and refresh tokens there, or switch google.mode to 'online' for client-side refresh.";
|
|
3
|
+
const rawSocialLogin = registerPlugin('SocialLogin', {
|
|
3
4
|
web: () => import('./web').then((m) => new m.SocialLoginWeb()),
|
|
4
5
|
});
|
|
6
|
+
class SocialLoginClient {
|
|
7
|
+
constructor() {
|
|
8
|
+
this.initialize = this.initialize.bind(this);
|
|
9
|
+
this.refresh = this.refresh.bind(this);
|
|
10
|
+
}
|
|
11
|
+
async initialize(options) {
|
|
12
|
+
await rawSocialLogin.initialize(options);
|
|
13
|
+
this.initializeOptions = options;
|
|
14
|
+
}
|
|
15
|
+
async login(options) {
|
|
16
|
+
return rawSocialLogin.login(options);
|
|
17
|
+
}
|
|
18
|
+
async logout(options) {
|
|
19
|
+
return rawSocialLogin.logout(options);
|
|
20
|
+
}
|
|
21
|
+
async isLoggedIn(options) {
|
|
22
|
+
return rawSocialLogin.isLoggedIn(options);
|
|
23
|
+
}
|
|
24
|
+
async getAuthorizationCode(options) {
|
|
25
|
+
return rawSocialLogin.getAuthorizationCode(options);
|
|
26
|
+
}
|
|
27
|
+
async refresh(options) {
|
|
28
|
+
var _a, _b;
|
|
29
|
+
if (options.provider === 'google' && ((_b = (_a = this.initializeOptions) === null || _a === void 0 ? void 0 : _a.google) === null || _b === void 0 ? void 0 : _b.mode) === 'offline') {
|
|
30
|
+
console.warn(`[SocialLogin] ${GOOGLE_OFFLINE_REFRESH_MESSAGE}`);
|
|
31
|
+
}
|
|
32
|
+
return rawSocialLogin.refresh(options);
|
|
33
|
+
}
|
|
34
|
+
async refreshToken(options) {
|
|
35
|
+
return rawSocialLogin.refreshToken(options);
|
|
36
|
+
}
|
|
37
|
+
async handleRedirectCallback() {
|
|
38
|
+
return rawSocialLogin.handleRedirectCallback();
|
|
39
|
+
}
|
|
40
|
+
async decodeIdToken(options) {
|
|
41
|
+
return rawSocialLogin.decodeIdToken(options);
|
|
42
|
+
}
|
|
43
|
+
async getAccessTokenExpirationDate(options) {
|
|
44
|
+
return rawSocialLogin.getAccessTokenExpirationDate(options);
|
|
45
|
+
}
|
|
46
|
+
async isAccessTokenAvailable(options) {
|
|
47
|
+
return rawSocialLogin.isAccessTokenAvailable(options);
|
|
48
|
+
}
|
|
49
|
+
async isAccessTokenExpired(options) {
|
|
50
|
+
return rawSocialLogin.isAccessTokenExpired(options);
|
|
51
|
+
}
|
|
52
|
+
async isRefreshTokenAvailable(options) {
|
|
53
|
+
return rawSocialLogin.isRefreshTokenAvailable(options);
|
|
54
|
+
}
|
|
55
|
+
async providerSpecificCall(options) {
|
|
56
|
+
return rawSocialLogin.providerSpecificCall(options);
|
|
57
|
+
}
|
|
58
|
+
async getPluginVersion() {
|
|
59
|
+
return rawSocialLogin.getPluginVersion();
|
|
60
|
+
}
|
|
61
|
+
async openSecureWindow(options) {
|
|
62
|
+
return rawSocialLogin.openSecureWindow(options);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
export const SocialLoginBase = rawSocialLogin;
|
|
66
|
+
export const SocialLogin = new SocialLoginClient();
|
|
5
67
|
//# sourceMappingURL=social-login.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"social-login.js","sourceRoot":"","sources":["../../src/social-login.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"social-login.js","sourceRoot":"","sources":["../../src/social-login.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAkBjD,MAAM,8BAA8B,GAClC,0PAA0P,CAAC;AAE7P,MAAM,cAAc,GAAG,cAAc,CAAoB,aAAa,EAAE;IACtE,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,cAAc,EAAE,CAAC;CAC/D,CAAC,CAAC;AAEH,MAAM,iBAAiB;IAGrB;QACE,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC7C,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACzC,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,OAA0B;QACzC,MAAM,cAAc,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QACzC,IAAI,CAAC,iBAAiB,GAAG,OAAO,CAAC;IACn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AAC;IACxD,CAAC;IAED,KAAK,CAAC,oBAAoB,CAAC,OAA8C;QACvE,OAAO,cAAc,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC;IACtD,CAAC;IAED,KAAK,CAAC,uBAAuB,CAAC,OAAwC;QACpE,OAAO,cAAc,CAAC,uBAAuB,CAAC,OAAO,CAAC,CAAC;IACzD,CAAC;IAED,KAAK,CAAC,oBAAoB,CAAiC,OAG1D;QACC,OAAO,cAAc,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC;IACtD,CAAC;IAED,KAAK,CAAC,gBAAgB;QACpB,OAAO,cAAc,CAAC,gBAAgB,EAAE,CAAC;IAC3C,CAAC;IAED,KAAK,CAAC,gBAAgB,CAAC,OAAgC;QACrD,OAAO,cAAc,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;IAClD,CAAC;CACF;AAED,MAAM,CAAC,MAAM,eAAe,GAAG,cAAc,CAAC;AAC9C,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,iBAAiB,EAAE,CAAC","sourcesContent":["import { registerPlugin } from '@capacitor/core';\n\nimport type {\n AuthorizationCode,\n AuthorizationCodeOptions,\n InitializeOptions,\n LoginOptions,\n OpenSecureWindowOptions,\n OpenSecureWindowResponse,\n OAuth2LoginResponse,\n ProviderResponseMap,\n ProviderSpecificCall,\n ProviderSpecificCallOptionsMap,\n ProviderSpecificCallResponseMap,\n SocialLoginPlugin,\n isLoggedInOptions,\n} from './definitions';\n\nconst GOOGLE_OFFLINE_REFRESH_MESSAGE =\n \"Google refresh() is not available when using offline mode. Offline mode only returns serverAuthCode for backend token exchange. Send serverAuthCode to your backend and refresh tokens there, or switch google.mode to 'online' for client-side refresh.\";\n\nconst rawSocialLogin = registerPlugin<SocialLoginPlugin>('SocialLogin', {\n web: () => import('./web').then((m) => new m.SocialLoginWeb()),\n});\n\nclass SocialLoginClient implements SocialLoginPlugin {\n private initializeOptions?: InitializeOptions;\n\n constructor() {\n this.initialize = this.initialize.bind(this);\n this.refresh = this.refresh.bind(this);\n }\n\n async initialize(options: InitializeOptions): Promise<void> {\n await rawSocialLogin.initialize(options);\n this.initializeOptions = options;\n }\n\n async login<T extends LoginOptions['provider']>(\n options: Extract<LoginOptions, { provider: T }>,\n ): Promise<{ provider: T; result: ProviderResponseMap[T] }> {\n return rawSocialLogin.login(options);\n }\n\n async logout(options: {\n provider: 'apple' | 'google' | 'facebook' | 'twitter' | 'oauth2';\n providerId?: string;\n }): Promise<void> {\n return rawSocialLogin.logout(options);\n }\n\n async isLoggedIn(options: isLoggedInOptions): Promise<{ isLoggedIn: boolean }> {\n return rawSocialLogin.isLoggedIn(options);\n }\n\n async getAuthorizationCode(options: AuthorizationCodeOptions): Promise<AuthorizationCode> {\n return rawSocialLogin.getAuthorizationCode(options);\n }\n\n async refresh(options: LoginOptions): Promise<void> {\n if (options.provider === 'google' && this.initializeOptions?.google?.mode === 'offline') {\n console.warn(`[SocialLogin] ${GOOGLE_OFFLINE_REFRESH_MESSAGE}`);\n }\n return rawSocialLogin.refresh(options);\n }\n\n async refreshToken(options: {\n provider: 'oauth2';\n providerId: string;\n refreshToken?: string;\n additionalParameters?: Record<string, string>;\n }): Promise<OAuth2LoginResponse> {\n return rawSocialLogin.refreshToken(options);\n }\n\n async handleRedirectCallback() {\n return rawSocialLogin.handleRedirectCallback();\n }\n\n async decodeIdToken(options: { idToken?: string; token?: string }): Promise<{ claims: Record<string, any> }> {\n return rawSocialLogin.decodeIdToken(options);\n }\n\n async getAccessTokenExpirationDate(options: { accessTokenExpirationDate: number }): Promise<{ date: string }> {\n return rawSocialLogin.getAccessTokenExpirationDate(options);\n }\n\n async isAccessTokenAvailable(options: { accessToken: string | null }): Promise<{ isAvailable: boolean }> {\n return rawSocialLogin.isAccessTokenAvailable(options);\n }\n\n async isAccessTokenExpired(options: { accessTokenExpirationDate: number }): Promise<{ isExpired: boolean }> {\n return rawSocialLogin.isAccessTokenExpired(options);\n }\n\n async isRefreshTokenAvailable(options: { refreshToken: string | null }): Promise<{ isAvailable: boolean }> {\n return rawSocialLogin.isRefreshTokenAvailable(options);\n }\n\n async providerSpecificCall<T extends ProviderSpecificCall>(options: {\n call: T;\n options: ProviderSpecificCallOptionsMap[T];\n }): Promise<ProviderSpecificCallResponseMap[T]> {\n return rawSocialLogin.providerSpecificCall(options);\n }\n\n async getPluginVersion(): Promise<{ version: string }> {\n return rawSocialLogin.getPluginVersion();\n }\n\n async openSecureWindow(options: OpenSecureWindowOptions): Promise<OpenSecureWindowResponse> {\n return rawSocialLogin.openSecureWindow(options);\n }\n}\n\nexport const SocialLoginBase = rawSocialLogin;\nexport const SocialLogin = new SocialLoginClient();\n"]}
|
package/dist/plugin.cjs.js
CHANGED
|
@@ -2,9 +2,71 @@
|
|
|
2
2
|
|
|
3
3
|
var core = require('@capacitor/core');
|
|
4
4
|
|
|
5
|
-
const
|
|
5
|
+
const GOOGLE_OFFLINE_REFRESH_MESSAGE$1 = "Google refresh() is not available when using offline mode. Offline mode only returns serverAuthCode for backend token exchange. Send serverAuthCode to your backend and refresh tokens there, or switch google.mode to 'online' for client-side refresh.";
|
|
6
|
+
const rawSocialLogin = core.registerPlugin('SocialLogin', {
|
|
6
7
|
web: () => Promise.resolve().then(function () { return web; }).then((m) => new m.SocialLoginWeb()),
|
|
7
8
|
});
|
|
9
|
+
class SocialLoginClient {
|
|
10
|
+
constructor() {
|
|
11
|
+
this.initialize = this.initialize.bind(this);
|
|
12
|
+
this.refresh = this.refresh.bind(this);
|
|
13
|
+
}
|
|
14
|
+
async initialize(options) {
|
|
15
|
+
await rawSocialLogin.initialize(options);
|
|
16
|
+
this.initializeOptions = options;
|
|
17
|
+
}
|
|
18
|
+
async login(options) {
|
|
19
|
+
return rawSocialLogin.login(options);
|
|
20
|
+
}
|
|
21
|
+
async logout(options) {
|
|
22
|
+
return rawSocialLogin.logout(options);
|
|
23
|
+
}
|
|
24
|
+
async isLoggedIn(options) {
|
|
25
|
+
return rawSocialLogin.isLoggedIn(options);
|
|
26
|
+
}
|
|
27
|
+
async getAuthorizationCode(options) {
|
|
28
|
+
return rawSocialLogin.getAuthorizationCode(options);
|
|
29
|
+
}
|
|
30
|
+
async refresh(options) {
|
|
31
|
+
var _a, _b;
|
|
32
|
+
if (options.provider === 'google' && ((_b = (_a = this.initializeOptions) === null || _a === void 0 ? void 0 : _a.google) === null || _b === void 0 ? void 0 : _b.mode) === 'offline') {
|
|
33
|
+
console.warn(`[SocialLogin] ${GOOGLE_OFFLINE_REFRESH_MESSAGE$1}`);
|
|
34
|
+
}
|
|
35
|
+
return rawSocialLogin.refresh(options);
|
|
36
|
+
}
|
|
37
|
+
async refreshToken(options) {
|
|
38
|
+
return rawSocialLogin.refreshToken(options);
|
|
39
|
+
}
|
|
40
|
+
async handleRedirectCallback() {
|
|
41
|
+
return rawSocialLogin.handleRedirectCallback();
|
|
42
|
+
}
|
|
43
|
+
async decodeIdToken(options) {
|
|
44
|
+
return rawSocialLogin.decodeIdToken(options);
|
|
45
|
+
}
|
|
46
|
+
async getAccessTokenExpirationDate(options) {
|
|
47
|
+
return rawSocialLogin.getAccessTokenExpirationDate(options);
|
|
48
|
+
}
|
|
49
|
+
async isAccessTokenAvailable(options) {
|
|
50
|
+
return rawSocialLogin.isAccessTokenAvailable(options);
|
|
51
|
+
}
|
|
52
|
+
async isAccessTokenExpired(options) {
|
|
53
|
+
return rawSocialLogin.isAccessTokenExpired(options);
|
|
54
|
+
}
|
|
55
|
+
async isRefreshTokenAvailable(options) {
|
|
56
|
+
return rawSocialLogin.isRefreshTokenAvailable(options);
|
|
57
|
+
}
|
|
58
|
+
async providerSpecificCall(options) {
|
|
59
|
+
return rawSocialLogin.providerSpecificCall(options);
|
|
60
|
+
}
|
|
61
|
+
async getPluginVersion() {
|
|
62
|
+
return rawSocialLogin.getPluginVersion();
|
|
63
|
+
}
|
|
64
|
+
async openSecureWindow(options) {
|
|
65
|
+
return rawSocialLogin.openSecureWindow(options);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
const SocialLoginBase = rawSocialLogin;
|
|
69
|
+
const SocialLogin = new SocialLoginClient();
|
|
8
70
|
|
|
9
71
|
/******************************************************************************
|
|
10
72
|
Copyright (c) Microsoft Corporation.
|
|
@@ -469,6 +531,7 @@ class FacebookSocialLogin extends BaseSocialLogin {
|
|
|
469
531
|
}
|
|
470
532
|
}
|
|
471
533
|
|
|
534
|
+
const GOOGLE_OFFLINE_REFRESH_MESSAGE = "Google refresh() is not available when using offline mode. Offline mode only returns serverAuthCode for backend token exchange. Send serverAuthCode to your backend and refresh tokens there, or switch google.mode to 'online' for client-side refresh.";
|
|
472
535
|
class GoogleSocialLogin extends BaseSocialLogin {
|
|
473
536
|
constructor() {
|
|
474
537
|
super(...arguments);
|
|
@@ -585,8 +648,11 @@ class GoogleSocialLogin extends BaseSocialLogin {
|
|
|
585
648
|
}
|
|
586
649
|
}
|
|
587
650
|
async refresh() {
|
|
588
|
-
|
|
589
|
-
|
|
651
|
+
if (this.loginType === 'offline') {
|
|
652
|
+
console.warn(`[SocialLogin] ${GOOGLE_OFFLINE_REFRESH_MESSAGE}`);
|
|
653
|
+
return Promise.reject(new Error(GOOGLE_OFFLINE_REFRESH_MESSAGE));
|
|
654
|
+
}
|
|
655
|
+
return Promise.reject(new Error('Google refresh is not implemented on web. Use login() again to obtain a new token.'));
|
|
590
656
|
}
|
|
591
657
|
handleOAuthRedirect(url) {
|
|
592
658
|
const paramsRaw = url.searchParams;
|
|
@@ -2258,7 +2324,8 @@ var web = /*#__PURE__*/Object.freeze({
|
|
|
2258
2324
|
SocialLoginWeb: SocialLoginWeb
|
|
2259
2325
|
});
|
|
2260
2326
|
|
|
2261
|
-
exports.SocialLogin =
|
|
2327
|
+
exports.SocialLogin = SocialLogin;
|
|
2262
2328
|
exports.SocialLoginAuthConnect = SocialLoginAuthConnect;
|
|
2329
|
+
exports.SocialLoginBase = SocialLoginBase;
|
|
2263
2330
|
exports.createAuthConnectClient = createAuthConnectClient;
|
|
2264
2331
|
//# sourceMappingURL=plugin.cjs.js.map
|