@capgo/capacitor-social-login 0.0.77-alpha.0 → 0.0.77-alpha.2

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/Package.swift CHANGED
@@ -12,11 +12,11 @@ let package = Package(
12
12
  dependencies: [
13
13
  .package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", branch: "main"),
14
14
  // FBSDKCoreKit and FBSDKLoginKit
15
- .package(url: "https://github.com/facebook/facebook-ios-sdk.git", .upToNextMajor(from: "17.3.0")),
15
+ .package(url: "https://github.com/facebook/facebook-ios-sdk.git", .upToNextMajor(from: "17.4.0")),
16
16
  // Add Google Sign-In dependency
17
17
  .package(url: "https://github.com/google/GoogleSignIn-iOS.git", .upToNextMajor(from: "8.0.0")),
18
18
  // Alamofire
19
- .package(url: "https://github.com/Alamofire/Alamofire.git", .upToNextMajor(from: "5.9.1"))
19
+ .package(url: "https://github.com/Alamofire/Alamofire.git", .upToNextMajor(from: "5.10.2"))
20
20
  ],
21
21
  targets: [
22
22
  .target(
package/README.md CHANGED
@@ -15,6 +15,8 @@ This plugin implement social auth for:
15
15
 
16
16
  We plan in the future to keep adding others social login and make this plugin the all in one solution.
17
17
 
18
+ This plugin is the only one who implement all 3 majors social login on WEB, IOS and Android
19
+
18
20
  ## Install
19
21
 
20
22
  ```bash
@@ -43,7 +45,7 @@ await SocialLogin.initialize({
43
45
  const res = await SocialLogin.login({
44
46
  provider: 'apple',
45
47
  options: {
46
- scopes: ['email', 'profile'],
48
+ scopes: ['email', 'name'],
47
49
  },
48
50
  });
49
51
  ```
@@ -61,7 +63,7 @@ await SocialLogin.initialize({
61
63
  const res = await SocialLogin.login({
62
64
  provider: 'apple',
63
65
  options: {
64
- scopes: ['email', 'profile'],
66
+ scopes: ['email', 'name'],
65
67
  },
66
68
  });
67
69
  ```
@@ -473,3 +475,8 @@ Refresh the access token
473
475
  <code>T extends U ? T : never</code>
474
476
 
475
477
  </docgen-api>
478
+
479
+ ### Credits
480
+
481
+ This plugin implementation of google is based on [CapacitorGoogleAuth](https://github.com/CodetrixStudio/CapacitorGoogleAuth) with a lot of rework, the current maintainer is unreachable, we are thankful for his work and are now going forward on our own!
482
+ Thanks to [reslear](https://github.com/reslear) for helping to tranfer users to this plugin from the old one and all the work.
@@ -53,13 +53,13 @@ dependencies {
53
53
  implementation project(':capacitor-android')
54
54
  implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
55
55
  implementation 'com.facebook.android:facebook-login:17.0.2'
56
- implementation 'com.squareup.okhttp3:okhttp:4.9.1'
56
+ implementation 'com.squareup.okhttp3:okhttp:4.12.0'
57
57
  implementation 'com.auth0.android:jwtdecode:2.0.2'
58
58
  implementation "androidx.credentials:credentials:1.3.0"
59
59
  implementation 'com.google.android.gms:play-services-auth:21.2.0'
60
60
  implementation "androidx.credentials:credentials-play-services-auth:1.3.0"
61
61
  implementation "com.google.android.libraries.identity.googleid:googleid:1.1.1"
62
- implementation 'com.google.androidbrowserhelper:androidbrowserhelper:2.4.0'
62
+ implementation 'com.google.androidbrowserhelper:androidbrowserhelper:2.5.0'
63
63
  testImplementation "junit:junit:$junitVersion"
64
64
  androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
65
65
  androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
@@ -1,4 +1,13 @@
1
- <manifest xmlns:android="http://schemas.android.com/apk/res/android">
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android"
2
+ xmlns:tools="http://schemas.android.com/tools">
2
3
  <uses-permission android:name="android.permission.USE_CREDENTIALS" />
3
4
  <uses-permission android:name="android.permission.INTERNET"/>
5
+
6
+ <application>
7
+ <provider
8
+ android:name="com.facebook.internal.FacebookInitProvider"
9
+ android:authorities="${applicationId}.FacebookInitProvider"
10
+ android:exported="false"
11
+ tools:node="remove" />
12
+ </application>
4
13
  </manifest>
@@ -5,6 +5,7 @@ import android.content.Intent;
5
5
  import android.os.Bundle;
6
6
  import android.util.Log;
7
7
  import androidx.activity.result.ActivityResultRegistryOwner;
8
+ import androidx.annotation.Nullable;
8
9
  import com.facebook.AccessToken;
9
10
  import com.facebook.CallbackManager;
10
11
  import com.facebook.FacebookCallback;
@@ -179,7 +180,43 @@ public class FacebookProvider implements SocialProvider {
179
180
  @Override
180
181
  public void refresh(PluginCall call) {
181
182
  // Not implemented for Facebook
182
- call.reject("Not implemented");
183
+ AccessToken accessToken = AccessToken.getCurrentAccessToken();
184
+ if (accessToken == null) {
185
+ call.reject("No access token?");
186
+ return;
187
+ }
188
+ if (!accessToken.isDataAccessExpired() && !accessToken.isExpired()) {
189
+ JSObject ret = new JSObject();
190
+ ret.put("accessToken", accessToken.getToken());
191
+ call.resolve(ret);
192
+ return;
193
+ }
194
+ AccessToken.refreshCurrentAccessTokenAsync(
195
+ new AccessToken.AccessTokenRefreshCallback() {
196
+ @Override
197
+ public void OnTokenRefreshed(@Nullable AccessToken accessToken) {
198
+ if (accessToken == null) {
199
+ call.reject("Success, but refresh token is null ???");
200
+ return;
201
+ }
202
+ JSObject ret = new JSObject();
203
+ ret.put("accessToken", accessToken.getToken());
204
+ call.resolve(ret);
205
+ }
206
+
207
+ @Override
208
+ public void OnTokenRefreshFailed(@Nullable FacebookException e) {
209
+ if (e != null) {
210
+ Log.e(SocialLoginPlugin.LOG_TAG, "Facebook token refresh error", e);
211
+ call.reject(
212
+ String.format("Cannot refresh token. %s", e.toString())
213
+ );
214
+ } else {
215
+ call.reject("Cannot refresh token");
216
+ }
217
+ }
218
+ }
219
+ );
183
220
  }
184
221
 
185
222
  public boolean handleOnActivityResult(
@@ -322,9 +322,17 @@ public class GoogleProvider implements SocialProvider {
322
322
 
323
323
  String nonce = call.getString("nonce");
324
324
 
325
- // Extract scopes from the config
326
325
  // Extract scopes from the config
327
326
  JSONArray scopesArray = config.optJSONArray("scopes");
327
+
328
+ // Remove duplicates from scopes array
329
+ if (scopesArray != null) {
330
+ Set<String> uniqueScopes = new HashSet<>();
331
+ for (int i = 0; i < scopesArray.length(); i++) {
332
+ uniqueScopes.add(scopesArray.optString(i));
333
+ }
334
+ scopesArray = new JSONArray(uniqueScopes);
335
+ }
328
336
  if (scopesArray != null) {
329
337
  if (
330
338
  !(this.activity instanceof ModifiedMainActivityForSocialLoginPlugin)
@@ -177,18 +177,18 @@ public class SocialLoginPlugin extends Plugin {
177
177
 
178
178
  @PluginMethod
179
179
  public void refresh(PluginCall call) {
180
- String provider = call.getString("provider");
181
- // if (provider.equals("facebook")) {
182
- // facebookProvider.refresh(call);
183
- // } else if (provider.equals("google")) {
184
- // googleProvider.refresh(call);
185
- // } else if (provider.equals("twitter")) {
186
- // twitterProvider.refresh(call);
187
- // } else if (provider.equals("apple")) {
188
- // appleProvider.refresh(call);
189
- // } else {
190
- // call.reject("Unsupported social login provider: " + provider);
191
- // }
180
+ String providerStr = call.getString("provider", "");
181
+ if (providerStr == null || providerStr.isEmpty()) {
182
+ call.reject("provider not provided");
183
+ }
184
+
185
+ SocialProvider provider = this.socialProviderHashMap.get(providerStr);
186
+ if (provider == null) {
187
+ call.reject(String.format("Cannot find provider '%s'", providerStr));
188
+ return;
189
+ }
190
+
191
+ provider.refresh(call);
192
192
  }
193
193
 
194
194
  public void handleGoogleLoginIntent(int requestCode, Intent intent) {
package/dist/esm/web.js CHANGED
@@ -113,6 +113,7 @@ export class SocialLoginWeb extends WebPlugin {
113
113
  // Google doesn't have a specific logout method for web
114
114
  // We can revoke the token if we have it stored
115
115
  console.log("Google logout: Id token should be revoked on the client side if stored");
116
+ // eslint-disable-next-line
116
117
  const state = this.getGoogleState();
117
118
  if (!state)
118
119
  return;
@@ -220,6 +221,7 @@ export class SocialLoginWeb extends WebPlugin {
220
221
  return Promise.reject("Offline login doesn't store tokens. isLoggedIn is not available");
221
222
  }
222
223
  // For Google, we can check if there's a valid token
224
+ // eslint-disable-next-line
223
225
  const state = this.getGoogleState();
224
226
  if (!state)
225
227
  return { isLoggedIn: false };
@@ -264,6 +266,7 @@ export class SocialLoginWeb extends WebPlugin {
264
266
  return Promise.reject("Offline login doesn't store tokens. getAuthorizationCode is not available");
265
267
  }
266
268
  // For Google, we can use the id_token as the authorization code
269
+ // eslint-disable-next-line
267
270
  const state = this.getGoogleState();
268
271
  if (!state)
269
272
  throw new Error("No Google authorization code available");
@@ -1 +1 @@
1
- {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AA2C5C,MAAM,OAAO,cAAe,SAAQ,SAAS;IAe3C;;QACE,KAAK,EAAE,CAAC;QAbF,mBAAc,GAAkB,IAAI,CAAC;QACrC,kBAAa,GAAkB,IAAI,CAAC;QACpC,uBAAkB,GAAG,KAAK,CAAC;QAC3B,oBAAe,GAAyB,QAAQ,CAAC;QACjD,sBAAiB,GAAG,KAAK,CAAC;QAC1B,mBAAc,GACpB,sFAAsF,CAAC;QACjF,6BAAwB,GAC9B,gDAAgD,CAAC;QAC3C,kBAAa,GAAkB,IAAI,CAAC;QACpC,yBAAoB,GAAG,KAAK,CAAC;QAInC,sEAAsE;QACtE,IAAI,YAAY,CAAC,OAAO,CAAC,cAAc,CAAC,eAAe,CAAC,EAAE;YACxD,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;YACrC,MAAM,MAAM,GAAG,IAAI,CAAC,mBAAmB,EAAE,CAAC;YAC1C,IAAI,MAAM,EAAE;gBACV,MAAA,MAAM,CAAC,MAAM,0CAAE,WAAW,iBAEtB,IAAI,EAAE,gBAAgB,IACnB,MAAM,CAAC,MAAM,GAElB,MAAM,CAAC,QAAQ,CAAC,MAAM,CACvB,CAAC;gBACF,MAAM,CAAC,KAAK,EAAE,CAAC;aAChB;SACF;IACH,CAAC;IAEO,mBAAmB;QACzB,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,YAAY,CAAC;QAC7D,MAAM,IAAI,GA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core\";\n\nimport type {\n SocialLoginPlugin,\n InitializeOptions,\n LoginOptions,\n LoginResult,\n AuthorizationCode,\n GoogleLoginResponse,\n AppleProviderResponse,\n isLoggedInOptions,\n AuthorizationCodeOptions,\n FacebookLoginOptions,\n FacebookLoginResponse,\n GoogleLoginOptions,\n ProviderResponseMap,\n} from \"./definitions\";\n\ndeclare const AppleID: any;\n\ndeclare const FB: {\n init(options: any): void;\n login(\n callback: (response: {\n status: string;\n authResponse: { accessToken: string; userID: string };\n }) => void,\n options?: { scope: string },\n ): void;\n logout(callback: () => void): void;\n api(\n path: string,\n params: { fields: string },\n callback: (response: any) => void,\n ): void;\n getLoginStatus(\n callback: (response: {\n status: string;\n authResponse?: { accessToken: string };\n }) => void,\n ): void;\n};\n\nexport class SocialLoginWeb extends WebPlugin implements SocialLoginPlugin {\n private static readonly OAUTH_STATE_KEY = \"social_login_oauth_pending\";\n\n private googleClientId: string | null = null;\n private appleClientId: string | null = null;\n private googleScriptLoaded = false;\n private googleLoginType: \"online\" | \"offline\" = \"online\";\n private appleScriptLoaded = false;\n private appleScriptUrl =\n \"https://appleid.cdn-apple.com/appleauth/static/jsapi/appleid/1/en_US/appleid.auth.js\";\n private GOOGLE_TOKEN_REQUEST_URL =\n \"https://www.googleapis.com/oauth2/v3/tokeninfo\";\n private facebookAppId: string | null = null;\n private facebookScriptLoaded = false;\n\n constructor() {\n super();\n // Set up listener for OAuth redirects if we have a pending OAuth flow\n if (localStorage.getItem(SocialLoginWeb.OAUTH_STATE_KEY)) {\n console.log(\"OAUTH_STATE_KEY found\");\n const result = this.handleOAuthRedirect();\n if (result) {\n window.opener?.postMessage(\n {\n type: \"oauth-response\",\n ...result.result,\n },\n window.location.origin,\n );\n window.close();\n }\n }\n }\n\n private handleOAuthRedirect() {\n const paramsRaw = new URL(window.location.href).searchParams;\n const code = paramsRaw.get(\"code\");\n if (code && paramsRaw.has(\"scope\")) {\n return {\n provider: \"google\" as const,\n result: {\n provider: \"google\" as const,\n result: {\n serverAuthCode: code,\n },\n },\n };\n }\n\n const hash = window.location.hash.substring(1);\n console.log(\"handleOAuthRedirect\", window.location.hash);\n if (!hash) return;\n console.log(\"handleOAuthRedirect ok\");\n\n const params = new URLSearchParams(hash);\n const accessToken = params.get(\"access_token\");\n const idToken = params.get(\"id_token\");\n\n if (accessToken && idToken) {\n localStorage.removeItem(SocialLoginWeb.OAUTH_STATE_KEY);\n const profile = this.parseJwt(idToken);\n return {\n provider: \"google\" as const,\n result: {\n accessToken: {\n token: accessToken,\n },\n idToken,\n profile: {\n email: profile.email || null,\n familyName: profile.family_name || null,\n givenName: profile.given_name || null,\n id: profile.sub || null,\n name: profile.name || null,\n imageUrl: profile.picture || null,\n },\n },\n };\n }\n return null;\n }\n\n async initialize(options: InitializeOptions): Promise<void> {\n if (options.google?.webClientId) {\n this.googleClientId = options.google.webClientId;\n if (options.google.mode) {\n this.googleLoginType = options.google.mode;\n }\n\n await this.loadGoogleScript();\n }\n if (options.apple?.clientId) {\n this.appleClientId = options.apple.clientId;\n await this.loadAppleScript();\n }\n if (options.facebook?.appId) {\n this.facebookAppId = options.facebook.appId;\n await this.loadFacebookScript();\n FB.init({\n appId: this.facebookAppId,\n version: \"v17.0\",\n xfbml: true,\n cookie: true,\n });\n }\n // Implement initialization for other providers if needed\n }\n\n async login<T extends LoginOptions[\"provider\"]>(\n options: Extract<LoginOptions, { provider: T }>,\n ): Promise<{ provider: T; result: ProviderResponseMap[T] }> {\n switch (options.provider) {\n case \"google\":\n return this.loginWithGoogle(options.options) as Promise<{\n provider: T;\n result: ProviderResponseMap[T];\n }>;\n case \"apple\":\n return this.loginWithApple(options.options) as Promise<{\n provider: T;\n result: ProviderResponseMap[T];\n }>;\n case \"facebook\":\n return this.loginWithFacebook(\n options.options as FacebookLoginOptions,\n ) as Promise<{ provider: T; result: ProviderResponseMap[T] }>;\n default:\n throw new Error(\n `Login for ${options.provider} is not implemented on web`,\n );\n }\n }\n\n async logout(options: {\n provider: \"apple\" | \"google\" | \"facebook\";\n }): Promise<void> {\n switch (options.provider) {\n case \"google\":\n if (this.googleLoginType === \"offline\") {\n return Promise.reject(\n \"Offline login doesn't store tokens. logout is not available\",\n );\n }\n // Google doesn't have a specific logout method for web\n // We can revoke the token if we have it stored\n console.log(\n \"Google logout: Id token should be revoked on the client side if stored\",\n );\n const state = this.getGoogleState();\n if (!state) return;\n await this.rawLogoutGoogle(state.accessToken);\n break;\n case \"apple\":\n // Apple doesn't provide a logout method for web\n console.log(\n \"Apple logout: Session should be managed on the client side\",\n );\n break;\n case \"facebook\":\n return new Promise<void>((resolve) => {\n FB.logout(() => resolve());\n });\n default:\n throw new Error(`Logout for ${options.provider} is not implemented`);\n }\n }\n\n private async accessTokenIsValid(accessToken: string): Promise<boolean> {\n const url = `${this.GOOGLE_TOKEN_REQUEST_URL}?access_token=${encodeURIComponent(accessToken)}`;\n\n try {\n // Make the GET request using fetch\n const response = await fetch(url);\n\n // Check if the response is successful\n if (!response.ok) {\n console.log(\n `Invalid response from ${this.GOOGLE_TOKEN_REQUEST_URL}. Response not successful. Status code: ${response.status}. Assuming that the token is not valid`,\n );\n return false;\n }\n\n // Get the response body as text\n const responseBody = await response.text();\n\n if (!responseBody) {\n console.error(\n `Invalid response from ${this.GOOGLE_TOKEN_REQUEST_URL}. Response body is null`,\n );\n throw new Error(\n `Invalid response from ${this.GOOGLE_TOKEN_REQUEST_URL}. Response body is null`,\n );\n }\n\n // Parse the response body as JSON\n let jsonObject: any;\n try {\n jsonObject = JSON.parse(responseBody);\n } catch (e) {\n console.error(\n `Invalid response from ${this.GOOGLE_TOKEN_REQUEST_URL}. Response body is not valid JSON. Error: ${e}`,\n );\n throw new Error(\n `Invalid response from ${this.GOOGLE_TOKEN_REQUEST_URL}. Response body is not valid JSON. Error: ${e}`,\n );\n }\n\n // Extract the 'expires_in' field\n const expiresInStr = jsonObject[\"expires_in\"];\n\n if (expiresInStr === undefined || expiresInStr === null) {\n console.error(\n `Invalid response from ${this.GOOGLE_TOKEN_REQUEST_URL}. Response JSON does not include 'expires_in'.`,\n );\n throw new Error(\n `Invalid response from ${this.GOOGLE_TOKEN_REQUEST_URL}. Response JSON does not include 'expires_in'.`,\n );\n }\n\n // Parse 'expires_in' as an integer\n let expiresInInt: number;\n try {\n expiresInInt = parseInt(expiresInStr, 10);\n if (isNaN(expiresInInt)) {\n throw new Error(`'expires_in' is not a valid integer`);\n }\n } catch (e) {\n console.error(\n `Invalid response from ${this.GOOGLE_TOKEN_REQUEST_URL}. 'expires_in': ${expiresInStr} is not a valid integer. Error: ${e}`,\n );\n throw new Error(\n `Invalid response from ${this.GOOGLE_TOKEN_REQUEST_URL}. 'expires_in': ${expiresInStr} is not a valid integer. Error: ${e}`,\n );\n }\n\n // Determine if the access token is valid based on 'expires_in'\n return expiresInInt > 5;\n } catch (error) {\n console.error(error);\n throw error;\n }\n }\n\n private idTokenValid(idToken: string): boolean {\n try {\n const parsed = this.parseJwt(idToken);\n const currentTime = Math.ceil(Date.now() / 1000) + 5; // Convert current time to seconds since epoch\n return parsed.exp && currentTime < parsed.exp;\n } catch (e) {\n return false;\n }\n }\n\n private async rawLogoutGoogle(\n accessToken: string,\n tokenValid: boolean | null = null,\n ) {\n if (tokenValid === null) {\n tokenValid = await this.accessTokenIsValid(accessToken);\n }\n\n if (tokenValid === true) {\n return new Promise<void>((resolve, reject) => {\n try {\n google.accounts.oauth2.revoke(accessToken, async () => {\n this.clearStateGoogle();\n resolve();\n });\n } catch (e) {\n reject(e);\n }\n });\n } else {\n this.clearStateGoogle();\n return;\n }\n }\n\n async isLoggedIn(\n options: isLoggedInOptions,\n ): Promise<{ isLoggedIn: boolean }> {\n switch (options.provider) {\n case \"google\":\n if (this.googleLoginType === \"offline\") {\n return Promise.reject(\n \"Offline login doesn't store tokens. isLoggedIn is not available\",\n );\n }\n // For Google, we can check if there's a valid token\n const state = this.getGoogleState();\n if (!state) return { isLoggedIn: false };\n\n try {\n // todo: cache accessTokenIsValid calls\n const isValidAccessToken = await this.accessTokenIsValid(\n state.accessToken,\n );\n const isValidIdToken = this.idTokenValid(state.idToken);\n if (isValidAccessToken && isValidIdToken) {\n return { isLoggedIn: true };\n } else {\n try {\n await this.rawLogoutGoogle(state.accessToken, false);\n } catch (e) {\n console.error(\"Access token is not valid, but cannot logout\", e);\n }\n return { isLoggedIn: false };\n }\n } catch (e) {\n return Promise.reject(e);\n }\n case \"apple\":\n // Apple doesn't provide a method to check login status on web\n console.log(\"Apple login status should be managed on the client side\");\n return { isLoggedIn: false };\n case \"facebook\":\n return new Promise((resolve) => {\n FB.getLoginStatus((response) => {\n resolve({ isLoggedIn: response.status === \"connected\" });\n });\n });\n default:\n throw new Error(\n `isLoggedIn for ${options.provider} is not implemented`,\n );\n }\n }\n\n async getAuthorizationCode(\n options: AuthorizationCodeOptions,\n ): Promise<AuthorizationCode> {\n switch (options.provider) {\n case \"google\":\n if (this.googleLoginType === \"offline\") {\n return Promise.reject(\n \"Offline login doesn't store tokens. getAuthorizationCode is not available\",\n );\n }\n // For Google, we can use the id_token as the authorization code\n const state = this.getGoogleState();\n if (!state) throw new Error(\"No Google authorization code available\");\n\n try {\n // todo: cache accessTokenIsValid calls\n const isValidAccessToken = await this.accessTokenIsValid(\n state.accessToken,\n );\n const isValidIdToken = this.idTokenValid(state.idToken);\n if (isValidAccessToken && isValidIdToken) {\n return { accessToken: state.accessToken, jwt: state.idToken };\n } else {\n try {\n await this.rawLogoutGoogle(state.accessToken, false);\n } catch (e) {\n console.error(\"Access token is not valid, but cannot logout\", e);\n }\n throw new Error(\"No Google authorization code available\");\n }\n } catch (e) {\n return Promise.reject(e);\n }\n case \"apple\":\n // Apple authorization code should be obtained during login\n console.log(\"Apple authorization code should be stored during login\");\n throw new Error(\"Apple authorization code not available\");\n case \"facebook\":\n return new Promise((resolve, reject) => {\n FB.getLoginStatus((response) => {\n if (response.status === \"connected\") {\n resolve({ jwt: response.authResponse?.accessToken || \"\" });\n } else {\n reject(new Error(\"No Facebook authorization code available\"));\n }\n });\n });\n default:\n throw new Error(\n `getAuthorizationCode for ${options.provider} is not implemented`,\n );\n }\n }\n\n async refresh(options: LoginOptions): Promise<void> {\n switch (options.provider) {\n case \"google\":\n // For Google, we can prompt for re-authentication\n return Promise.reject(\"Not implemented\");\n case \"apple\":\n // Apple doesn't provide a refresh method for web\n console.log(\"Apple refresh not available on web\");\n break;\n case \"facebook\":\n await this.loginWithFacebook(options.options as FacebookLoginOptions);\n break;\n default:\n throw new Error(\n `Refresh for ${(options as any).provider} is not implemented`,\n );\n }\n }\n\n private loginWithGoogle<T extends \"google\">(\n options: GoogleLoginOptions,\n ): Promise<{ provider: T; result: ProviderResponseMap[T] }> {\n if (!this.googleClientId) {\n throw new Error(\"Google Client ID not set. Call initialize() first.\");\n }\n\n let scopes = options.scopes || [];\n\n if (scopes.length > 0) {\n // If scopes are provided, directly use the traditional OAuth flow\n if (!scopes.includes(\"https://www.googleapis.com/auth/userinfo.email\")) {\n scopes.push(\"https://www.googleapis.com/auth/userinfo.email\");\n }\n if (\n !scopes.includes(\"https://www.googleapis.com/auth/userinfo.profile\")\n ) {\n scopes.push(\"https://www.googleapis.com/auth/userinfo.profile\");\n }\n if (!scopes.includes(\"openid\")) {\n scopes.push(\"openid\");\n }\n } else {\n scopes = [\n \"https://www.googleapis.com/auth/userinfo.email\",\n \"https://www.googleapis.com/auth/userinfo.profile\",\n \"openid\",\n ];\n }\n\n if (scopes.length > 3 || this.googleLoginType === \"offline\") {\n // If scopes are provided, directly use the traditional OAuth flow\n return this.fallbackToTraditionalOAuth(scopes);\n }\n\n return new Promise((resolve, reject) => {\n google.accounts.id.initialize({\n client_id: this.googleClientId!,\n callback: (response) => {\n console.log(\"google.accounts.id.initialize callback\", response);\n if ((response as any).error) {\n // we use any because type fail but we need to double check if that works\n reject((response as any).error);\n } else {\n const payload = this.parseJwt(response.credential);\n const result: GoogleLoginResponse = {\n accessToken: null,\n responseType: \"online\",\n idToken: response.credential,\n profile: {\n email: payload.email || null,\n familyName: payload.family_name || null,\n givenName: payload.given_name || null,\n id: payload.sub || null,\n name: payload.name || null,\n imageUrl: payload.picture || null,\n },\n };\n resolve({ provider: \"google\" as T, result });\n }\n },\n auto_select: true,\n });\n\n google.accounts.id.prompt((notification) => {\n if (notification.isNotDisplayed() || notification.isSkippedMoment()) {\n console.log(\"OneTap is not displayed or skipped\");\n // Fallback to traditional OAuth if One Tap is not available\n this.fallbackToTraditionalOAuth(scopes)\n .then((r) => resolve({ provider: \"google\" as T, result: r.result }))\n .catch(reject);\n } else {\n console.log(\"OneTap is displayed\");\n }\n });\n });\n }\n\n private parseJwt(token: string) {\n const base64Url = token.split(\".\")[1];\n const base64 = base64Url.replace(/-/g, \"+\").replace(/_/g, \"/\");\n const jsonPayload = decodeURIComponent(\n atob(base64)\n .split(\"\")\n .map((c) => {\n return \"%\" + (\"00\" + c.charCodeAt(0).toString(16)).slice(-2);\n })\n .join(\"\"),\n );\n return JSON.parse(jsonPayload);\n }\n\n private async loadGoogleScript(): Promise<void> {\n if (this.googleScriptLoaded) return;\n\n return new Promise((resolve, reject) => {\n const script = document.createElement(\"script\");\n script.src = \"https://accounts.google.com/gsi/client\";\n script.async = true;\n script.onload = () => {\n this.googleScriptLoaded = true;\n resolve();\n };\n script.onerror = reject;\n document.body.appendChild(script);\n });\n }\n\n private async loginWithApple(options: any): Promise<LoginResult> {\n if (!this.appleClientId) {\n throw new Error(\"Apple Client ID not set. Call initialize() first.\");\n }\n\n if (!this.appleScriptLoaded) {\n throw new Error(\"Apple Sign-In script not loaded.\");\n }\n\n return new Promise((resolve, reject) => {\n AppleID.auth.init({\n clientId: this.appleClientId!,\n scope: options.scopes?.join(\" \") || \"name email\",\n redirectURI: options.redirectUrl || window.location.href,\n state: options.state,\n nonce: options.nonce,\n usePopup: true,\n });\n\n AppleID.auth\n .signIn()\n .then((res: any) => {\n const result: AppleProviderResponse = {\n profile: {\n user: res.user?.name?.firstName\n ? `${res.user.name.firstName} ${res.user.name.lastName}`\n : \"\",\n email: res.user?.email || null,\n givenName: res.user?.name?.firstName || null,\n familyName: res.user?.name?.lastName || null,\n },\n accessToken: {\n token: res.authorization.code, // TODO: to fix and find the correct token\n },\n idToken: res.authorization.id_token || null,\n };\n resolve({ provider: \"apple\", result });\n })\n .catch((error: any) => {\n reject(error);\n });\n });\n }\n\n private async loadAppleScript(): Promise<void> {\n if (this.appleScriptLoaded) return;\n\n return new Promise((resolve, reject) => {\n const script = document.createElement(\"script\");\n script.src = this.appleScriptUrl;\n script.async = true;\n script.onload = () => {\n this.appleScriptLoaded = true;\n resolve();\n };\n script.onerror = reject;\n document.body.appendChild(script);\n });\n }\n\n private persistStateGoogle(accessToken: string, idToken: string) {\n try {\n window.localStorage.setItem(\n \"capgo_social_login_google_state\",\n JSON.stringify({ accessToken, idToken }),\n );\n } catch (e) {\n console.error(\"Cannot persist state google\", e);\n }\n }\n\n private clearStateGoogle() {\n try {\n window.localStorage.removeItem(\"capgo_social_login_google_state\");\n } catch (e) {\n console.error(\"Cannot clear state google\", e);\n }\n }\n\n private getGoogleState(): { accessToken: string; idToken: string } | null {\n try {\n const state = window.localStorage.getItem(\n \"capgo_social_login_google_state\",\n );\n if (!state) return null;\n const { accessToken, idToken } = JSON.parse(state);\n return { accessToken, idToken };\n } catch (e) {\n console.error(\"Cannot get state google\", e);\n return null;\n }\n }\n\n private async loadFacebookScript(): Promise<void> {\n if (this.facebookScriptLoaded) return;\n\n return new Promise((resolve, reject) => {\n const script = document.createElement(\"script\");\n script.src = \"https://connect.facebook.net/en_US/sdk.js\";\n script.async = true;\n script.defer = true;\n script.onload = () => {\n this.facebookScriptLoaded = true;\n resolve();\n };\n script.onerror = reject;\n document.body.appendChild(script);\n });\n }\n\n private async loginWithFacebook(\n options: FacebookLoginOptions,\n ): Promise<LoginResult> {\n if (!this.facebookAppId) {\n throw new Error(\"Facebook App ID not set. Call initialize() first.\");\n }\n\n return new Promise((resolve, reject) => {\n FB.login(\n (response) => {\n if (response.status === \"connected\") {\n FB.api(\n \"/me\",\n { fields: \"id,name,email,picture\" },\n (userInfo: any) => {\n const result: FacebookLoginResponse = {\n accessToken: {\n token: response.authResponse.accessToken,\n userId: response.authResponse.userID,\n },\n profile: {\n userID: userInfo.id,\n name: userInfo.name,\n email: userInfo.email || null,\n imageURL: userInfo.picture?.data?.url || null,\n friendIDs: [],\n birthday: null,\n ageRange: null,\n gender: null,\n location: null,\n hometown: null,\n profileURL: null,\n },\n idToken: null,\n };\n resolve({ provider: \"facebook\", result });\n },\n );\n } else {\n reject(new Error(\"Facebook login failed\"));\n }\n },\n { scope: options.permissions.join(\",\") },\n );\n });\n }\n\n private async fallbackToTraditionalOAuth<T extends \"google\">(\n scopes: string[],\n ): Promise<{ provider: T; result: ProviderResponseMap[T] }> {\n const uniqueScopes = [...new Set([...scopes, \"openid\"])];\n\n const params = new URLSearchParams({\n client_id: this.googleClientId!,\n redirect_uri: window.location.href,\n response_type:\n this.googleLoginType === \"offline\" ? \"code\" : \"token id_token\",\n scope: uniqueScopes.join(\" \"),\n nonce: Math.random().toString(36).substring(2),\n include_granted_scopes: \"true\",\n state: \"popup\",\n });\n\n const url = `https://accounts.google.com/o/oauth2/v2/auth?${params.toString()}`;\n const width = 500;\n const height = 600;\n const left = window.screenX + (window.outerWidth - width) / 2;\n const top = window.screenY + (window.outerHeight - height) / 2;\n localStorage.setItem(SocialLoginWeb.OAUTH_STATE_KEY, \"true\");\n const popup = window.open(\n url,\n \"Google Sign In\",\n `width=${width},height=${height},left=${left},top=${top},popup=1`,\n );\n\n // This may never return...\n return new Promise((resolve, reject) => {\n if (!popup) {\n reject(new Error(\"Failed to open popup\"));\n return;\n }\n\n const handleMessage = (event: MessageEvent) => {\n if (event.origin !== window.location.origin) return;\n\n if (event.data?.type === \"oauth-response\") {\n window.removeEventListener(\"message\", handleMessage);\n\n if (this.googleLoginType === \"online\") {\n const { accessToken, idToken } = event.data;\n if (accessToken && idToken) {\n const profile = this.parseJwt(idToken);\n this.persistStateGoogle(accessToken.token, idToken);\n resolve({\n provider: \"google\" as T,\n result: {\n accessToken: {\n token: accessToken.token,\n },\n idToken,\n profile: {\n email: profile.email || null,\n familyName: profile.family_name || null,\n givenName: profile.given_name || null,\n id: profile.sub || null,\n name: profile.name || null,\n imageUrl: profile.picture || null,\n },\n responseType: \"online\",\n },\n });\n }\n } else {\n const { serverAuthCode } = event.data.result as {\n serverAuthCode: string;\n };\n resolve({\n provider: \"google\" as T,\n result: {\n responseType: \"offline\",\n serverAuthCode,\n },\n });\n }\n } else {\n reject(new Error(\"Login failed\"));\n }\n };\n\n window.addEventListener(\"message\", handleMessage);\n\n // Timeout after 5 minutes\n setTimeout(() => {\n window.removeEventListener(\"message\", handleMessage);\n popup.close();\n reject(new Error(\"OAuth timeout\"));\n }, 300000);\n });\n }\n}\n"]}
1
+ {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AA2C5C,MAAM,OAAO,cAAe,SAAQ,SAAS;IAe3C;;QACE,KAAK,EAAE,CAAC;QAbF,mBAAc,GAAkB,IAAI,CAAC;QACrC,kBAAa,GAAkB,IAAI,CAAC;QACpC,uBAAkB,GAAG,KAAK,CAAC;QAC3B,oBAAe,GAAyB,QAAQ,CAAC;QACjD,sBAAiB,GAAG,KAAK,CAAC;QAC1B,mBAAc,GACpB,sFAAsF,CAAC;QACjF,6BAAwB,GAC9B,gDAAgD,CAAC;QAC3C,kBAAa,GAAkB,IAAI,CAAC;QACpC,yBAAoB,GAAG,KAAK,CAAC;QAInC,sEAAsE;QACtE,IAAI,YAAY,CAAC,OAAO,CAAC,cAAc,CAAC,eAAe,CAAC,EAAE,CAAC;YACzD,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;YACrC,MAAM,MAAM,GAAG,IAAI,CAAC,mBAAmB,EAAE,CAAC;YAC1C,IAAI,MAAM,EAAE,CAAC;gBACX,MAAA,MAAM,CAAC,MAAM,0CAAE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lugin } from \"@capacitor/core\";\n\nimport type {\n SocialLoginPlugin,\n InitializeOptions,\n LoginOptions,\n LoginResult,\n AuthorizationCode,\n GoogleLoginResponse,\n AppleProviderResponse,\n isLoggedInOptions,\n AuthorizationCodeOptions,\n FacebookLoginOptions,\n FacebookLoginResponse,\n GoogleLoginOptions,\n ProviderResponseMap,\n} from \"./definitions\";\n\ndeclare const AppleID: any;\n\ndeclare const FB: {\n init(options: any): void;\n login(\n callback: (response: {\n status: string;\n authResponse: { accessToken: string; userID: string };\n }) => void,\n options?: { scope: string },\n ): void;\n logout(callback: () => void): void;\n api(\n path: string,\n params: { fields: string },\n callback: (response: any) => void,\n ): void;\n getLoginStatus(\n callback: (response: {\n status: string;\n authResponse?: { accessToken: string };\n }) => void,\n ): void;\n};\n\nexport class SocialLoginWeb extends WebPlugin implements SocialLoginPlugin {\n private static readonly OAUTH_STATE_KEY = \"social_login_oauth_pending\";\n\n private googleClientId: string | null = null;\n private appleClientId: string | null = null;\n private googleScriptLoaded = false;\n private googleLoginType: \"online\" | \"offline\" = \"online\";\n private appleScriptLoaded = false;\n private appleScriptUrl =\n \"https://appleid.cdn-apple.com/appleauth/static/jsapi/appleid/1/en_US/appleid.auth.js\";\n private GOOGLE_TOKEN_REQUEST_URL =\n \"https://www.googleapis.com/oauth2/v3/tokeninfo\";\n private facebookAppId: string | null = null;\n private facebookScriptLoaded = false;\n\n constructor() {\n super();\n // Set up listener for OAuth redirects if we have a pending OAuth flow\n if (localStorage.getItem(SocialLoginWeb.OAUTH_STATE_KEY)) {\n console.log(\"OAUTH_STATE_KEY found\");\n const result = this.handleOAuthRedirect();\n if (result) {\n window.opener?.postMessage(\n {\n type: \"oauth-response\",\n ...result.result,\n },\n window.location.origin,\n );\n window.close();\n }\n }\n }\n\n private handleOAuthRedirect() {\n const paramsRaw = new URL(window.location.href).searchParams;\n const code = paramsRaw.get(\"code\");\n if (code && paramsRaw.has(\"scope\")) {\n return {\n provider: \"google\" as const,\n result: {\n provider: \"google\" as const,\n result: {\n serverAuthCode: code,\n },\n },\n };\n }\n\n const hash = window.location.hash.substring(1);\n console.log(\"handleOAuthRedirect\", window.location.hash);\n if (!hash) return;\n console.log(\"handleOAuthRedirect ok\");\n\n const params = new URLSearchParams(hash);\n const accessToken = params.get(\"access_token\");\n const idToken = params.get(\"id_token\");\n\n if (accessToken && idToken) {\n localStorage.removeItem(SocialLoginWeb.OAUTH_STATE_KEY);\n const profile = this.parseJwt(idToken);\n return {\n provider: \"google\" as const,\n result: {\n accessToken: {\n token: accessToken,\n },\n idToken,\n profile: {\n email: profile.email || null,\n familyName: profile.family_name || null,\n givenName: profile.given_name || null,\n id: profile.sub || null,\n name: profile.name || null,\n imageUrl: profile.picture || null,\n },\n },\n };\n }\n return null;\n }\n\n async initialize(options: InitializeOptions): Promise<void> {\n if (options.google?.webClientId) {\n this.googleClientId = options.google.webClientId;\n if (options.google.mode) {\n this.googleLoginType = options.google.mode;\n }\n\n await this.loadGoogleScript();\n }\n if (options.apple?.clientId) {\n this.appleClientId = options.apple.clientId;\n await this.loadAppleScript();\n }\n if (options.facebook?.appId) {\n this.facebookAppId = options.facebook.appId;\n await this.loadFacebookScript();\n FB.init({\n appId: this.facebookAppId,\n version: \"v17.0\",\n xfbml: true,\n cookie: true,\n });\n }\n // Implement initialization for other providers if needed\n }\n\n async login<T extends LoginOptions[\"provider\"]>(\n options: Extract<LoginOptions, { provider: T }>,\n ): Promise<{ provider: T; result: ProviderResponseMap[T] }> {\n switch (options.provider) {\n case \"google\":\n return this.loginWithGoogle(options.options) as Promise<{\n provider: T;\n result: ProviderResponseMap[T];\n }>;\n case \"apple\":\n return this.loginWithApple(options.options) as Promise<{\n provider: T;\n result: ProviderResponseMap[T];\n }>;\n case \"facebook\":\n return this.loginWithFacebook(\n options.options as FacebookLoginOptions,\n ) as Promise<{ provider: T; result: ProviderResponseMap[T] }>;\n default:\n throw new Error(\n `Login for ${options.provider} is not implemented on web`,\n );\n }\n }\n\n async logout(options: {\n provider: \"apple\" | \"google\" | \"facebook\";\n }): Promise<void> {\n switch (options.provider) {\n case \"google\":\n if (this.googleLoginType === \"offline\") {\n return Promise.reject(\n \"Offline login doesn't store tokens. logout is not available\",\n );\n }\n // Google doesn't have a specific logout method for web\n // We can revoke the token if we have it stored\n console.log(\n \"Google logout: Id token should be revoked on the client side if stored\",\n );\n // eslint-disable-next-line\n const state = this.getGoogleState();\n if (!state) return;\n await this.rawLogoutGoogle(state.accessToken);\n break;\n case \"apple\":\n // Apple doesn't provide a logout method for web\n console.log(\n \"Apple logout: Session should be managed on the client side\",\n );\n break;\n case \"facebook\":\n return new Promise<void>((resolve) => {\n FB.logout(() => resolve());\n });\n default:\n throw new Error(`Logout for ${options.provider} is not implemented`);\n }\n }\n\n private async accessTokenIsValid(accessToken: string): Promise<boolean> {\n const url = `${this.GOOGLE_TOKEN_REQUEST_URL}?access_token=${encodeURIComponent(accessToken)}`;\n\n try {\n // Make the GET request using fetch\n const response = await fetch(url);\n\n // Check if the response is successful\n if (!response.ok) {\n console.log(\n `Invalid response from ${this.GOOGLE_TOKEN_REQUEST_URL}. Response not successful. Status code: ${response.status}. Assuming that the token is not valid`,\n );\n return false;\n }\n\n // Get the response body as text\n const responseBody = await response.text();\n\n if (!responseBody) {\n console.error(\n `Invalid response from ${this.GOOGLE_TOKEN_REQUEST_URL}. Response body is null`,\n );\n throw new Error(\n `Invalid response from ${this.GOOGLE_TOKEN_REQUEST_URL}. Response body is null`,\n );\n }\n\n // Parse the response body as JSON\n let jsonObject: any;\n try {\n jsonObject = JSON.parse(responseBody);\n } catch (e) {\n console.error(\n `Invalid response from ${this.GOOGLE_TOKEN_REQUEST_URL}. Response body is not valid JSON. Error: ${e}`,\n );\n throw new Error(\n `Invalid response from ${this.GOOGLE_TOKEN_REQUEST_URL}. Response body is not valid JSON. Error: ${e}`,\n );\n }\n\n // Extract the 'expires_in' field\n const expiresInStr = jsonObject[\"expires_in\"];\n\n if (expiresInStr === undefined || expiresInStr === null) {\n console.error(\n `Invalid response from ${this.GOOGLE_TOKEN_REQUEST_URL}. Response JSON does not include 'expires_in'.`,\n );\n throw new Error(\n `Invalid response from ${this.GOOGLE_TOKEN_REQUEST_URL}. Response JSON does not include 'expires_in'.`,\n );\n }\n\n // Parse 'expires_in' as an integer\n let expiresInInt: number;\n try {\n expiresInInt = parseInt(expiresInStr, 10);\n if (isNaN(expiresInInt)) {\n throw new Error(`'expires_in' is not a valid integer`);\n }\n } catch (e) {\n console.error(\n `Invalid response from ${this.GOOGLE_TOKEN_REQUEST_URL}. 'expires_in': ${expiresInStr} is not a valid integer. Error: ${e}`,\n );\n throw new Error(\n `Invalid response from ${this.GOOGLE_TOKEN_REQUEST_URL}. 'expires_in': ${expiresInStr} is not a valid integer. Error: ${e}`,\n );\n }\n\n // Determine if the access token is valid based on 'expires_in'\n return expiresInInt > 5;\n } catch (error) {\n console.error(error);\n throw error;\n }\n }\n\n private idTokenValid(idToken: string): boolean {\n try {\n const parsed = this.parseJwt(idToken);\n const currentTime = Math.ceil(Date.now() / 1000) + 5; // Convert current time to seconds since epoch\n return parsed.exp && currentTime < parsed.exp;\n } catch (e) {\n return false;\n }\n }\n\n private async rawLogoutGoogle(\n accessToken: string,\n tokenValid: boolean | null = null,\n ) {\n if (tokenValid === null) {\n tokenValid = await this.accessTokenIsValid(accessToken);\n }\n\n if (tokenValid === true) {\n return new Promise<void>((resolve, reject) => {\n try {\n google.accounts.oauth2.revoke(accessToken, async () => {\n this.clearStateGoogle();\n resolve();\n });\n } catch (e) {\n reject(e);\n }\n });\n } else {\n this.clearStateGoogle();\n return;\n }\n }\n\n async isLoggedIn(\n options: isLoggedInOptions,\n ): Promise<{ isLoggedIn: boolean }> {\n switch (options.provider) {\n case \"google\":\n if (this.googleLoginType === \"offline\") {\n return Promise.reject(\n \"Offline login doesn't store tokens. isLoggedIn is not available\",\n );\n }\n // For Google, we can check if there's a valid token\n // eslint-disable-next-line\n const state = this.getGoogleState();\n if (!state) return { isLoggedIn: false };\n\n try {\n // todo: cache accessTokenIsValid calls\n const isValidAccessToken = await this.accessTokenIsValid(\n state.accessToken,\n );\n const isValidIdToken = this.idTokenValid(state.idToken);\n if (isValidAccessToken && isValidIdToken) {\n return { isLoggedIn: true };\n } else {\n try {\n await this.rawLogoutGoogle(state.accessToken, false);\n } catch (e) {\n console.error(\"Access token is not valid, but cannot logout\", e);\n }\n return { isLoggedIn: false };\n }\n } catch (e) {\n return Promise.reject(e);\n }\n case \"apple\":\n // Apple doesn't provide a method to check login status on web\n console.log(\"Apple login status should be managed on the client side\");\n return { isLoggedIn: false };\n case \"facebook\":\n return new Promise((resolve) => {\n FB.getLoginStatus((response) => {\n resolve({ isLoggedIn: response.status === \"connected\" });\n });\n });\n default:\n throw new Error(\n `isLoggedIn for ${options.provider} is not implemented`,\n );\n }\n }\n\n async getAuthorizationCode(\n options: AuthorizationCodeOptions,\n ): Promise<AuthorizationCode> {\n switch (options.provider) {\n case \"google\":\n if (this.googleLoginType === \"offline\") {\n return Promise.reject(\n \"Offline login doesn't store tokens. getAuthorizationCode is not available\",\n );\n }\n // For Google, we can use the id_token as the authorization code\n // eslint-disable-next-line\n const state = this.getGoogleState();\n if (!state) throw new Error(\"No Google authorization code available\");\n\n try {\n // todo: cache accessTokenIsValid calls\n const isValidAccessToken = await this.accessTokenIsValid(\n state.accessToken,\n );\n const isValidIdToken = this.idTokenValid(state.idToken);\n if (isValidAccessToken && isValidIdToken) {\n return { accessToken: state.accessToken, jwt: state.idToken };\n } else {\n try {\n await this.rawLogoutGoogle(state.accessToken, false);\n } catch (e) {\n console.error(\"Access token is not valid, but cannot logout\", e);\n }\n throw new Error(\"No Google authorization code available\");\n }\n } catch (e) {\n return Promise.reject(e);\n }\n case \"apple\":\n // Apple authorization code should be obtained during login\n console.log(\"Apple authorization code should be stored during login\");\n throw new Error(\"Apple authorization code not available\");\n case \"facebook\":\n return new Promise((resolve, reject) => {\n FB.getLoginStatus((response) => {\n if (response.status === \"connected\") {\n resolve({ jwt: response.authResponse?.accessToken || \"\" });\n } else {\n reject(new Error(\"No Facebook authorization code available\"));\n }\n });\n });\n default:\n throw new Error(\n `getAuthorizationCode for ${options.provider} is not implemented`,\n );\n }\n }\n\n async refresh(options: LoginOptions): Promise<void> {\n switch (options.provider) {\n case \"google\":\n // For Google, we can prompt for re-authentication\n return Promise.reject(\"Not implemented\");\n case \"apple\":\n // Apple doesn't provide a refresh method for web\n console.log(\"Apple refresh not available on web\");\n break;\n case \"facebook\":\n await this.loginWithFacebook(options.options as FacebookLoginOptions);\n break;\n default:\n throw new Error(\n `Refresh for ${(options as any).provider} is not implemented`,\n );\n }\n }\n\n private loginWithGoogle<T extends \"google\">(\n options: GoogleLoginOptions,\n ): Promise<{ provider: T; result: ProviderResponseMap[T] }> {\n if (!this.googleClientId) {\n throw new Error(\"Google Client ID not set. Call initialize() first.\");\n }\n\n let scopes = options.scopes || [];\n\n if (scopes.length > 0) {\n // If scopes are provided, directly use the traditional OAuth flow\n if (!scopes.includes(\"https://www.googleapis.com/auth/userinfo.email\")) {\n scopes.push(\"https://www.googleapis.com/auth/userinfo.email\");\n }\n if (\n !scopes.includes(\"https://www.googleapis.com/auth/userinfo.profile\")\n ) {\n scopes.push(\"https://www.googleapis.com/auth/userinfo.profile\");\n }\n if (!scopes.includes(\"openid\")) {\n scopes.push(\"openid\");\n }\n } else {\n scopes = [\n \"https://www.googleapis.com/auth/userinfo.email\",\n \"https://www.googleapis.com/auth/userinfo.profile\",\n \"openid\",\n ];\n }\n\n if (scopes.length > 3 || this.googleLoginType === \"offline\") {\n // If scopes are provided, directly use the traditional OAuth flow\n return this.fallbackToTraditionalOAuth(scopes);\n }\n\n return new Promise((resolve, reject) => {\n google.accounts.id.initialize({\n client_id: this.googleClientId!,\n callback: (response) => {\n console.log(\"google.accounts.id.initialize callback\", response);\n if ((response as any).error) {\n // we use any because type fail but we need to double check if that works\n reject((response as any).error);\n } else {\n const payload = this.parseJwt(response.credential);\n const result: GoogleLoginResponse = {\n accessToken: null,\n responseType: \"online\",\n idToken: response.credential,\n profile: {\n email: payload.email || null,\n familyName: payload.family_name || null,\n givenName: payload.given_name || null,\n id: payload.sub || null,\n name: payload.name || null,\n imageUrl: payload.picture || null,\n },\n };\n resolve({ provider: \"google\" as T, result });\n }\n },\n auto_select: true,\n });\n\n google.accounts.id.prompt((notification) => {\n if (notification.isNotDisplayed() || notification.isSkippedMoment()) {\n console.log(\"OneTap is not displayed or skipped\");\n // Fallback to traditional OAuth if One Tap is not available\n this.fallbackToTraditionalOAuth(scopes)\n .then((r) => resolve({ provider: \"google\" as T, result: r.result }))\n .catch(reject);\n } else {\n console.log(\"OneTap is displayed\");\n }\n });\n });\n }\n\n private parseJwt(token: string) {\n const base64Url = token.split(\".\")[1];\n const base64 = base64Url.replace(/-/g, \"+\").replace(/_/g, \"/\");\n const jsonPayload = decodeURIComponent(\n atob(base64)\n .split(\"\")\n .map((c) => {\n return \"%\" + (\"00\" + c.charCodeAt(0).toString(16)).slice(-2);\n })\n .join(\"\"),\n );\n return JSON.parse(jsonPayload);\n }\n\n private async loadGoogleScript(): Promise<void> {\n if (this.googleScriptLoaded) return;\n\n return new Promise((resolve, reject) => {\n const script = document.createElement(\"script\");\n script.src = \"https://accounts.google.com/gsi/client\";\n script.async = true;\n script.onload = () => {\n this.googleScriptLoaded = true;\n resolve();\n };\n script.onerror = reject;\n document.body.appendChild(script);\n });\n }\n\n private async loginWithApple(options: any): Promise<LoginResult> {\n if (!this.appleClientId) {\n throw new Error(\"Apple Client ID not set. Call initialize() first.\");\n }\n\n if (!this.appleScriptLoaded) {\n throw new Error(\"Apple Sign-In script not loaded.\");\n }\n\n return new Promise((resolve, reject) => {\n AppleID.auth.init({\n clientId: this.appleClientId!,\n scope: options.scopes?.join(\" \") || \"name email\",\n redirectURI: options.redirectUrl || window.location.href,\n state: options.state,\n nonce: options.nonce,\n usePopup: true,\n });\n\n AppleID.auth\n .signIn()\n .then((res: any) => {\n const result: AppleProviderResponse = {\n profile: {\n user: res.user?.name?.firstName\n ? `${res.user.name.firstName} ${res.user.name.lastName}`\n : \"\",\n email: res.user?.email || null,\n givenName: res.user?.name?.firstName || null,\n familyName: res.user?.name?.lastName || null,\n },\n accessToken: {\n token: res.authorization.code, // TODO: to fix and find the correct token\n },\n idToken: res.authorization.id_token || null,\n };\n resolve({ provider: \"apple\", result });\n })\n .catch((error: any) => {\n reject(error);\n });\n });\n }\n\n private async loadAppleScript(): Promise<void> {\n if (this.appleScriptLoaded) return;\n\n return new Promise((resolve, reject) => {\n const script = document.createElement(\"script\");\n script.src = this.appleScriptUrl;\n script.async = true;\n script.onload = () => {\n this.appleScriptLoaded = true;\n resolve();\n };\n script.onerror = reject;\n document.body.appendChild(script);\n });\n }\n\n private persistStateGoogle(accessToken: string, idToken: string) {\n try {\n window.localStorage.setItem(\n \"capgo_social_login_google_state\",\n JSON.stringify({ accessToken, idToken }),\n );\n } catch (e) {\n console.error(\"Cannot persist state google\", e);\n }\n }\n\n private clearStateGoogle() {\n try {\n window.localStorage.removeItem(\"capgo_social_login_google_state\");\n } catch (e) {\n console.error(\"Cannot clear state google\", e);\n }\n }\n\n private getGoogleState(): { accessToken: string; idToken: string } | null {\n try {\n const state = window.localStorage.getItem(\n \"capgo_social_login_google_state\",\n );\n if (!state) return null;\n const { accessToken, idToken } = JSON.parse(state);\n return { accessToken, idToken };\n } catch (e) {\n console.error(\"Cannot get state google\", e);\n return null;\n }\n }\n\n private async loadFacebookScript(): Promise<void> {\n if (this.facebookScriptLoaded) return;\n\n return new Promise((resolve, reject) => {\n const script = document.createElement(\"script\");\n script.src = \"https://connect.facebook.net/en_US/sdk.js\";\n script.async = true;\n script.defer = true;\n script.onload = () => {\n this.facebookScriptLoaded = true;\n resolve();\n };\n script.onerror = reject;\n document.body.appendChild(script);\n });\n }\n\n private async loginWithFacebook(\n options: FacebookLoginOptions,\n ): Promise<LoginResult> {\n if (!this.facebookAppId) {\n throw new Error(\"Facebook App ID not set. Call initialize() first.\");\n }\n\n return new Promise((resolve, reject) => {\n FB.login(\n (response) => {\n if (response.status === \"connected\") {\n FB.api(\n \"/me\",\n { fields: \"id,name,email,picture\" },\n (userInfo: any) => {\n const result: FacebookLoginResponse = {\n accessToken: {\n token: response.authResponse.accessToken,\n userId: response.authResponse.userID,\n },\n profile: {\n userID: userInfo.id,\n name: userInfo.name,\n email: userInfo.email || null,\n imageURL: userInfo.picture?.data?.url || null,\n friendIDs: [],\n birthday: null,\n ageRange: null,\n gender: null,\n location: null,\n hometown: null,\n profileURL: null,\n },\n idToken: null,\n };\n resolve({ provider: \"facebook\", result });\n },\n );\n } else {\n reject(new Error(\"Facebook login failed\"));\n }\n },\n { scope: options.permissions.join(\",\") },\n );\n });\n }\n\n private async fallbackToTraditionalOAuth<T extends \"google\">(\n scopes: string[],\n ): Promise<{ provider: T; result: ProviderResponseMap[T] }> {\n const uniqueScopes = [...new Set([...scopes, \"openid\"])];\n\n const params = new URLSearchParams({\n client_id: this.googleClientId!,\n redirect_uri: window.location.href,\n response_type:\n this.googleLoginType === \"offline\" ? \"code\" : \"token id_token\",\n scope: uniqueScopes.join(\" \"),\n nonce: Math.random().toString(36).substring(2),\n include_granted_scopes: \"true\",\n state: \"popup\",\n });\n\n const url = `https://accounts.google.com/o/oauth2/v2/auth?${params.toString()}`;\n const width = 500;\n const height = 600;\n const left = window.screenX + (window.outerWidth - width) / 2;\n const top = window.screenY + (window.outerHeight - height) / 2;\n localStorage.setItem(SocialLoginWeb.OAUTH_STATE_KEY, \"true\");\n const popup = window.open(\n url,\n \"Google Sign In\",\n `width=${width},height=${height},left=${left},top=${top},popup=1`,\n );\n\n // This may never return...\n return new Promise((resolve, reject) => {\n if (!popup) {\n reject(new Error(\"Failed to open popup\"));\n return;\n }\n\n const handleMessage = (event: MessageEvent) => {\n if (event.origin !== window.location.origin) return;\n\n if (event.data?.type === \"oauth-response\") {\n window.removeEventListener(\"message\", handleMessage);\n\n if (this.googleLoginType === \"online\") {\n const { accessToken, idToken } = event.data;\n if (accessToken && idToken) {\n const profile = this.parseJwt(idToken);\n this.persistStateGoogle(accessToken.token, idToken);\n resolve({\n provider: \"google\" as T,\n result: {\n accessToken: {\n token: accessToken.token,\n },\n idToken,\n profile: {\n email: profile.email || null,\n familyName: profile.family_name || null,\n givenName: profile.given_name || null,\n id: profile.sub || null,\n name: profile.name || null,\n imageUrl: profile.picture || null,\n },\n responseType: \"online\",\n },\n });\n }\n } else {\n const { serverAuthCode } = event.data.result as {\n serverAuthCode: string;\n };\n resolve({\n provider: \"google\" as T,\n result: {\n responseType: \"offline\",\n serverAuthCode,\n },\n });\n }\n } else {\n reject(new Error(\"Login failed\"));\n }\n };\n\n window.addEventListener(\"message\", handleMessage);\n\n // Timeout after 5 minutes\n setTimeout(() => {\n window.removeEventListener(\"message\", handleMessage);\n popup.close();\n reject(new Error(\"OAuth timeout\"));\n }, 300000);\n });\n }\n}\n"]}
@@ -120,6 +120,7 @@ class SocialLoginWeb extends core.WebPlugin {
120
120
  // Google doesn't have a specific logout method for web
121
121
  // We can revoke the token if we have it stored
122
122
  console.log("Google logout: Id token should be revoked on the client side if stored");
123
+ // eslint-disable-next-line
123
124
  const state = this.getGoogleState();
124
125
  if (!state)
125
126
  return;
@@ -227,6 +228,7 @@ class SocialLoginWeb extends core.WebPlugin {
227
228
  return Promise.reject("Offline login doesn't store tokens. isLoggedIn is not available");
228
229
  }
229
230
  // For Google, we can check if there's a valid token
231
+ // eslint-disable-next-line
230
232
  const state = this.getGoogleState();
231
233
  if (!state)
232
234
  return { isLoggedIn: false };
@@ -271,6 +273,7 @@ class SocialLoginWeb extends core.WebPlugin {
271
273
  return Promise.reject("Offline login doesn't store tokens. getAuthorizationCode is not available");
272
274
  }
273
275
  // For Google, we can use the id_token as the authorization code
276
+ // eslint-disable-next-line
274
277
  const state = this.getGoogleState();
275
278
  if (!state)
276
279
  throw new Error("No Google authorization code available");
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from \"@capacitor/core\";\nconst SocialLogin = registerPlugin(\"SocialLogin\", {\n web: () => import(\"./web\").then((m) => new m.SocialLoginWeb()),\n});\nexport * from \"./definitions\";\nexport { SocialLogin };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from \"@capacitor/core\";\nexport class SocialLoginWeb extends WebPlugin {\n constructor() {\n var _a;\n super();\n this.googleClientId = null;\n this.appleClientId = null;\n this.googleScriptLoaded = false;\n this.googleLoginType = \"online\";\n this.appleScriptLoaded = false;\n this.appleScriptUrl = \"https://appleid.cdn-apple.com/appleauth/static/jsapi/appleid/1/en_US/appleid.auth.js\";\n this.GOOGLE_TOKEN_REQUEST_URL = \"https://www.googleapis.com/oauth2/v3/tokeninfo\";\n this.facebookAppId = null;\n this.facebookScriptLoaded = false;\n // Set up listener for OAuth redirects if we have a pending OAuth flow\n if (localStorage.getItem(SocialLoginWeb.OAUTH_STATE_KEY)) {\n console.log(\"OAUTH_STATE_KEY found\");\n const result = this.handleOAuthRedirect();\n if (result) {\n (_a = window.opener) === null || _a === void 0 ? void 0 : _a.postMessage(Object.assign({ type: \"oauth-response\" }, result.result), window.location.origin);\n window.close();\n }\n }\n }\n handleOAuthRedirect() {\n const paramsRaw = new URL(window.location.href).searchParams;\n const code = paramsRaw.get(\"code\");\n if (code && paramsRaw.has(\"scope\")) {\n return {\n provider: \"google\",\n result: {\n provider: \"google\",\n result: {\n serverAuthCode: code,\n },\n },\n };\n }\n const hash = window.location.hash.substring(1);\n console.log(\"handleOAuthRedirect\", window.location.hash);\n if (!hash)\n return;\n console.log(\"handleOAuthRedirect ok\");\n const params = new URLSearchParams(hash);\n const accessToken = params.get(\"access_token\");\n const idToken = params.get(\"id_token\");\n if (accessToken && idToken) {\n localStorage.removeItem(SocialLoginWeb.OAUTH_STATE_KEY);\n const profile = this.parseJwt(idToken);\n return {\n provider: \"google\",\n result: {\n accessToken: {\n token: accessToken,\n },\n idToken,\n profile: {\n email: profile.email || null,\n familyName: profile.family_name || null,\n givenName: profile.given_name || null,\n id: profile.sub || null,\n name: profile.name || null,\n imageUrl: profile.picture || null,\n },\n },\n };\n }\n return null;\n }\n async initialize(options) {\n var _a, _b, _c;\n if ((_a = options.google) === null || _a === void 0 ? void 0 : _a.webClientId) {\n this.googleClientId = options.google.webClientId;\n if (options.google.mode) {\n this.googleLoginType = options.google.mode;\n }\n await this.loadGoogleScript();\n }\n if ((_b = options.apple) === null || _b === void 0 ? void 0 : _b.clientId) {\n this.appleClientId = options.apple.clientId;\n await this.loadAppleScript();\n }\n if ((_c = options.facebook) === null || _c === void 0 ? void 0 : _c.appId) {\n this.facebookAppId = options.facebook.appId;\n await this.loadFacebookScript();\n FB.init({\n appId: this.facebookAppId,\n version: \"v17.0\",\n xfbml: true,\n cookie: true,\n });\n }\n // Implement initialization for other providers if needed\n }\n async login(options) {\n switch (options.provider) {\n case \"google\":\n return this.loginWithGoogle(options.options);\n case \"apple\":\n return this.loginWithApple(options.options);\n case \"facebook\":\n return this.loginWithFacebook(options.options);\n default:\n throw new Error(`Login for ${options.provider} is not implemented on web`);\n }\n }\n async logout(options) {\n switch (options.provider) {\n case \"google\":\n if (this.googleLoginType === \"offline\") {\n return Promise.reject(\"Offline login doesn't store tokens. logout is not available\");\n }\n // Google doesn't have a specific logout method for web\n // We can revoke the token if we have it stored\n console.log(\"Google logout: Id token should be revoked on the client side if stored\");\n const state = this.getGoogleState();\n if (!state)\n return;\n await this.rawLogoutGoogle(state.accessToken);\n break;\n case \"apple\":\n // Apple doesn't provide a logout method for web\n console.log(\"Apple logout: Session should be managed on the client side\");\n break;\n case \"facebook\":\n return new Promise((resolve) => {\n FB.logout(() => resolve());\n });\n default:\n throw new Error(`Logout for ${options.provider} is not implemented`);\n }\n }\n async accessTokenIsValid(accessToken) {\n const url = `${this.GOOGLE_TOKEN_REQUEST_URL}?access_token=${encodeURIComponent(accessToken)}`;\n try {\n // Make the GET request using fetch\n const response = await fetch(url);\n // Check if the response is successful\n if (!response.ok) {\n console.log(`Invalid response from ${this.GOOGLE_TOKEN_REQUEST_URL}. Response not successful. Status code: ${response.status}. Assuming that the token is not valid`);\n return false;\n }\n // Get the response body as text\n const responseBody = await response.text();\n if (!responseBody) {\n console.error(`Invalid response from ${this.GOOGLE_TOKEN_REQUEST_URL}. Response body is null`);\n throw new Error(`Invalid response from ${this.GOOGLE_TOKEN_REQUEST_URL}. Response body is null`);\n }\n // Parse the response body as JSON\n let jsonObject;\n try {\n jsonObject = JSON.parse(responseBody);\n }\n catch (e) {\n console.error(`Invalid response from ${this.GOOGLE_TOKEN_REQUEST_URL}. Response body is not valid JSON. Error: ${e}`);\n throw new Error(`Invalid response from ${this.GOOGLE_TOKEN_REQUEST_URL}. Response body is not valid JSON. Error: ${e}`);\n }\n // Extract the 'expires_in' field\n const expiresInStr = jsonObject[\"expires_in\"];\n if (expiresInStr === undefined || expiresInStr === null) {\n console.error(`Invalid response from ${this.GOOGLE_TOKEN_REQUEST_URL}. Response JSON does not include 'expires_in'.`);\n throw new Error(`Invalid response from ${this.GOOGLE_TOKEN_REQUEST_URL}. Response JSON does not include 'expires_in'.`);\n }\n // Parse 'expires_in' as an integer\n let expiresInInt;\n try {\n expiresInInt = parseInt(expiresInStr, 10);\n if (isNaN(expiresInInt)) {\n throw new Error(`'expires_in' is not a valid integer`);\n }\n }\n catch (e) {\n console.error(`Invalid response from ${this.GOOGLE_TOKEN_REQUEST_URL}. 'expires_in': ${expiresInStr} is not a valid integer. Error: ${e}`);\n throw new Error(`Invalid response from ${this.GOOGLE_TOKEN_REQUEST_URL}. 'expires_in': ${expiresInStr} is not a valid integer. Error: ${e}`);\n }\n // Determine if the access token is valid based on 'expires_in'\n return expiresInInt > 5;\n }\n catch (error) {\n console.error(error);\n throw error;\n }\n }\n idTokenValid(idToken) {\n try {\n const parsed = this.parseJwt(idToken);\n const currentTime = Math.ceil(Date.now() / 1000) + 5; // Convert current time to seconds since epoch\n return parsed.exp && currentTime < parsed.exp;\n }\n catch (e) {\n return false;\n }\n }\n async rawLogoutGoogle(accessToken, tokenValid = null) {\n if (tokenValid === null) {\n tokenValid = await this.accessTokenIsValid(accessToken);\n }\n if (tokenValid === true) {\n return new Promise((resolve, reject) => {\n try {\n google.accounts.oauth2.revoke(accessToken, async () => {\n this.clearStateGoogle();\n resolve();\n });\n }\n catch (e) {\n reject(e);\n }\n });\n }\n else {\n this.clearStateGoogle();\n return;\n }\n }\n async isLoggedIn(options) {\n switch (options.provider) {\n case \"google\":\n if (this.googleLoginType === \"offline\") {\n return Promise.reject(\"Offline login doesn't store tokens. isLoggedIn is not available\");\n }\n // For Google, we can check if there's a valid token\n const state = this.getGoogleState();\n if (!state)\n return { isLoggedIn: false };\n try {\n // todo: cache accessTokenIsValid calls\n const isValidAccessToken = await this.accessTokenIsValid(state.accessToken);\n const isValidIdToken = this.idTokenValid(state.idToken);\n if (isValidAccessToken && isValidIdToken) {\n return { isLoggedIn: true };\n }\n else {\n try {\n await this.rawLogoutGoogle(state.accessToken, false);\n }\n catch (e) {\n console.error(\"Access token is not valid, but cannot logout\", e);\n }\n return { isLoggedIn: false };\n }\n }\n catch (e) {\n return Promise.reject(e);\n }\n case \"apple\":\n // Apple doesn't provide a method to check login status on web\n console.log(\"Apple login status should be managed on the client side\");\n return { isLoggedIn: false };\n case \"facebook\":\n return new Promise((resolve) => {\n FB.getLoginStatus((response) => {\n resolve({ isLoggedIn: response.status === \"connected\" });\n });\n });\n default:\n throw new Error(`isLoggedIn for ${options.provider} is not implemented`);\n }\n }\n async getAuthorizationCode(options) {\n switch (options.provider) {\n case \"google\":\n if (this.googleLoginType === \"offline\") {\n return Promise.reject(\"Offline login doesn't store tokens. getAuthorizationCode is not available\");\n }\n // For Google, we can use the id_token as the authorization code\n const state = this.getGoogleState();\n if (!state)\n throw new Error(\"No Google authorization code available\");\n try {\n // todo: cache accessTokenIsValid calls\n const isValidAccessToken = await this.accessTokenIsValid(state.accessToken);\n const isValidIdToken = this.idTokenValid(state.idToken);\n if (isValidAccessToken && isValidIdToken) {\n return { accessToken: state.accessToken, jwt: state.idToken };\n }\n else {\n try {\n await this.rawLogoutGoogle(state.accessToken, false);\n }\n catch (e) {\n console.error(\"Access token is not valid, but cannot logout\", e);\n }\n throw new Error(\"No Google authorization code available\");\n }\n }\n catch (e) {\n return Promise.reject(e);\n }\n case \"apple\":\n // Apple authorization code should be obtained during login\n console.log(\"Apple authorization code should be stored during login\");\n throw new Error(\"Apple authorization code not available\");\n case \"facebook\":\n return new Promise((resolve, reject) => {\n FB.getLoginStatus((response) => {\n var _a;\n if (response.status === \"connected\") {\n resolve({ jwt: ((_a = response.authResponse) === null || _a === void 0 ? void 0 : _a.accessToken) || \"\" });\n }\n else {\n reject(new Error(\"No Facebook authorization code available\"));\n }\n });\n });\n default:\n throw new Error(`getAuthorizationCode for ${options.provider} is not implemented`);\n }\n }\n async refresh(options) {\n switch (options.provider) {\n case \"google\":\n // For Google, we can prompt for re-authentication\n return Promise.reject(\"Not implemented\");\n case \"apple\":\n // Apple doesn't provide a refresh method for web\n console.log(\"Apple refresh not available on web\");\n break;\n case \"facebook\":\n await this.loginWithFacebook(options.options);\n break;\n default:\n throw new Error(`Refresh for ${options.provider} is not implemented`);\n }\n }\n loginWithGoogle(options) {\n if (!this.googleClientId) {\n throw new Error(\"Google Client ID not set. Call initialize() first.\");\n }\n let scopes = options.scopes || [];\n if (scopes.length > 0) {\n // If scopes are provided, directly use the traditional OAuth flow\n if (!scopes.includes(\"https://www.googleapis.com/auth/userinfo.email\")) {\n scopes.push(\"https://www.googleapis.com/auth/userinfo.email\");\n }\n if (!scopes.includes(\"https://www.googleapis.com/auth/userinfo.profile\")) {\n scopes.push(\"https://www.googleapis.com/auth/userinfo.profile\");\n }\n if (!scopes.includes(\"openid\")) {\n scopes.push(\"openid\");\n }\n }\n else {\n scopes = [\n \"https://www.googleapis.com/auth/userinfo.email\",\n \"https://www.googleapis.com/auth/userinfo.profile\",\n \"openid\",\n ];\n }\n if (scopes.length > 3 || this.googleLoginType === \"offline\") {\n // If scopes are provided, directly use the traditional OAuth flow\n return this.fallbackToTraditionalOAuth(scopes);\n }\n return new Promise((resolve, reject) => {\n google.accounts.id.initialize({\n client_id: this.googleClientId,\n callback: (response) => {\n console.log(\"google.accounts.id.initialize callback\", response);\n if (response.error) {\n // we use any because type fail but we need to double check if that works\n reject(response.error);\n }\n else {\n const payload = this.parseJwt(response.credential);\n const result = {\n accessToken: null,\n responseType: \"online\",\n idToken: response.credential,\n profile: {\n email: payload.email || null,\n familyName: payload.family_name || null,\n givenName: payload.given_name || null,\n id: payload.sub || null,\n name: payload.name || null,\n imageUrl: payload.picture || null,\n },\n };\n resolve({ provider: \"google\", result });\n }\n },\n auto_select: true,\n });\n google.accounts.id.prompt((notification) => {\n if (notification.isNotDisplayed() || notification.isSkippedMoment()) {\n console.log(\"OneTap is not displayed or skipped\");\n // Fallback to traditional OAuth if One Tap is not available\n this.fallbackToTraditionalOAuth(scopes)\n .then((r) => resolve({ provider: \"google\", result: r.result }))\n .catch(reject);\n }\n else {\n console.log(\"OneTap is displayed\");\n }\n });\n });\n }\n parseJwt(token) {\n const base64Url = token.split(\".\")[1];\n const base64 = base64Url.replace(/-/g, \"+\").replace(/_/g, \"/\");\n const jsonPayload = decodeURIComponent(atob(base64)\n .split(\"\")\n .map((c) => {\n return \"%\" + (\"00\" + c.charCodeAt(0).toString(16)).slice(-2);\n })\n .join(\"\"));\n return JSON.parse(jsonPayload);\n }\n async loadGoogleScript() {\n if (this.googleScriptLoaded)\n return;\n return new Promise((resolve, reject) => {\n const script = document.createElement(\"script\");\n script.src = \"https://accounts.google.com/gsi/client\";\n script.async = true;\n script.onload = () => {\n this.googleScriptLoaded = true;\n resolve();\n };\n script.onerror = reject;\n document.body.appendChild(script);\n });\n }\n async loginWithApple(options) {\n if (!this.appleClientId) {\n throw new Error(\"Apple Client ID not set. Call initialize() first.\");\n }\n if (!this.appleScriptLoaded) {\n throw new Error(\"Apple Sign-In script not loaded.\");\n }\n return new Promise((resolve, reject) => {\n var _a;\n AppleID.auth.init({\n clientId: this.appleClientId,\n scope: ((_a = options.scopes) === null || _a === void 0 ? void 0 : _a.join(\" \")) || \"name email\",\n redirectURI: options.redirectUrl || window.location.href,\n state: options.state,\n nonce: options.nonce,\n usePopup: true,\n });\n AppleID.auth\n .signIn()\n .then((res) => {\n var _a, _b, _c, _d, _e, _f, _g;\n const result = {\n profile: {\n user: ((_b = (_a = res.user) === null || _a === void 0 ? void 0 : _a.name) === null || _b === void 0 ? void 0 : _b.firstName)\n ? `${res.user.name.firstName} ${res.user.name.lastName}`\n : \"\",\n email: ((_c = res.user) === null || _c === void 0 ? void 0 : _c.email) || null,\n givenName: ((_e = (_d = res.user) === null || _d === void 0 ? void 0 : _d.name) === null || _e === void 0 ? void 0 : _e.firstName) || null,\n familyName: ((_g = (_f = res.user) === null || _f === void 0 ? void 0 : _f.name) === null || _g === void 0 ? void 0 : _g.lastName) || null,\n },\n accessToken: {\n token: res.authorization.code, // TODO: to fix and find the correct token\n },\n idToken: res.authorization.id_token || null,\n };\n resolve({ provider: \"apple\", result });\n })\n .catch((error) => {\n reject(error);\n });\n });\n }\n async loadAppleScript() {\n if (this.appleScriptLoaded)\n return;\n return new Promise((resolve, reject) => {\n const script = document.createElement(\"script\");\n script.src = this.appleScriptUrl;\n script.async = true;\n script.onload = () => {\n this.appleScriptLoaded = true;\n resolve();\n };\n script.onerror = reject;\n document.body.appendChild(script);\n });\n }\n persistStateGoogle(accessToken, idToken) {\n try {\n window.localStorage.setItem(\"capgo_social_login_google_state\", JSON.stringify({ accessToken, idToken }));\n }\n catch (e) {\n console.error(\"Cannot persist state google\", e);\n }\n }\n clearStateGoogle() {\n try {\n window.localStorage.removeItem(\"capgo_social_login_google_state\");\n }\n catch (e) {\n console.error(\"Cannot clear state google\", e);\n }\n }\n getGoogleState() {\n try {\n const state = window.localStorage.getItem(\"capgo_social_login_google_state\");\n if (!state)\n return null;\n const { accessToken, idToken } = JSON.parse(state);\n return { accessToken, idToken };\n }\n catch (e) {\n console.error(\"Cannot get state google\", e);\n return null;\n }\n }\n async loadFacebookScript() {\n if (this.facebookScriptLoaded)\n return;\n return new Promise((resolve, reject) => {\n const script = document.createElement(\"script\");\n script.src = \"https://connect.facebook.net/en_US/sdk.js\";\n script.async = true;\n script.defer = true;\n script.onload = () => {\n this.facebookScriptLoaded = true;\n resolve();\n };\n script.onerror = reject;\n document.body.appendChild(script);\n });\n }\n async loginWithFacebook(options) {\n if (!this.facebookAppId) {\n throw new Error(\"Facebook App ID not set. Call initialize() first.\");\n }\n return new Promise((resolve, reject) => {\n FB.login((response) => {\n if (response.status === \"connected\") {\n FB.api(\"/me\", { fields: \"id,name,email,picture\" }, (userInfo) => {\n var _a, _b;\n const result = {\n accessToken: {\n token: response.authResponse.accessToken,\n userId: response.authResponse.userID,\n },\n profile: {\n userID: userInfo.id,\n name: userInfo.name,\n email: userInfo.email || null,\n imageURL: ((_b = (_a = userInfo.picture) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.url) || null,\n friendIDs: [],\n birthday: null,\n ageRange: null,\n gender: null,\n location: null,\n hometown: null,\n profileURL: null,\n },\n idToken: null,\n };\n resolve({ provider: \"facebook\", result });\n });\n }\n else {\n reject(new Error(\"Facebook login failed\"));\n }\n }, { scope: options.permissions.join(\",\") });\n });\n }\n async fallbackToTraditionalOAuth(scopes) {\n const uniqueScopes = [...new Set([...scopes, \"openid\"])];\n const params = new URLSearchParams({\n client_id: this.googleClientId,\n redirect_uri: window.location.href,\n response_type: this.googleLoginType === \"offline\" ? \"code\" : \"token id_token\",\n scope: uniqueScopes.join(\" \"),\n nonce: Math.random().toString(36).substring(2),\n include_granted_scopes: \"true\",\n state: \"popup\",\n });\n const url = `https://accounts.google.com/o/oauth2/v2/auth?${params.toString()}`;\n const width = 500;\n const height = 600;\n const left = window.screenX + (window.outerWidth - width) / 2;\n const top = window.screenY + (window.outerHeight - height) / 2;\n localStorage.setItem(SocialLoginWeb.OAUTH_STATE_KEY, \"true\");\n const popup = window.open(url, \"Google Sign In\", `width=${width},height=${height},left=${left},top=${top},popup=1`);\n // This may never return...\n return new Promise((resolve, reject) => {\n if (!popup) {\n reject(new Error(\"Failed to open popup\"));\n return;\n }\n const handleMessage = (event) => {\n var _a;\n if (event.origin !== window.location.origin)\n return;\n if (((_a = event.data) === null || _a === void 0 ? void 0 : _a.type) === \"oauth-response\") {\n window.removeEventListener(\"message\", handleMessage);\n if (this.googleLoginType === \"online\") {\n const { accessToken, idToken } = event.data;\n if (accessToken && idToken) {\n const profile = this.parseJwt(idToken);\n this.persistStateGoogle(accessToken.token, idToken);\n resolve({\n provider: \"google\",\n result: {\n accessToken: {\n token: accessToken.token,\n },\n idToken,\n profile: {\n email: profile.email || null,\n familyName: profile.family_name || null,\n givenName: profile.given_name || null,\n id: profile.sub || null,\n name: profile.name || null,\n imageUrl: profile.picture || null,\n },\n responseType: \"online\",\n },\n });\n }\n }\n else {\n const { serverAuthCode } = event.data.result;\n resolve({\n provider: \"google\",\n result: {\n responseType: \"offline\",\n serverAuthCode,\n },\n });\n }\n }\n else {\n reject(new Error(\"Login failed\"));\n }\n };\n window.addEventListener(\"message\", handleMessage);\n // Timeout after 5 minutes\n setTimeout(() => {\n window.removeEventListener(\"message\", handleMessage);\n popup.close();\n reject(new Error(\"OAuth timeout\"));\n }, 300000);\n });\n }\n}\nSocialLoginWeb.OAUTH_STATE_KEY = \"social_login_oauth_pending\";\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;AACK,MAAC,WAAW,GAAGA,mBAAc,CAAC,aAAa,EAAE;AAClD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,cAAc,EAAE,CAAC;AAClE,CAAC;;ACFM,MAAM,cAAc,SAASC,cAAS,CAAC;AAC9C,IAAI,WAAW,GAAG;AAClB,QAAQ,IAAI,EAAE;AACd,QAAQ,KAAK,EAAE;AAC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;AAC9B;AACA;AACA,yBAAyB;AACzB,wBAAwB,MAAM,EAAE,cAAc,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM;AACpE,wBAAwB,OAAO,CAAC;AAChC,4BAA4B,QAAQ,EAAE,QAAQ;AAC9C,4BAA4B,MAAM,EAAE;AACpC,gCAAgC,YAAY,EAAE,SAAS;AACvD,gCAAgC,cAAc;AAC9C,6BAA6B;AAC7B,yBAAyB,CAAC;AAC1B;AACA;AACA,qBAAqB;AACrB,oBAAoB,MAAM,CAAC,IAAI,KAAK,CAAC,cAAc,CAAC,CAAC;AACrD;AACA,aAAa;AACb,YAAY,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,aAAa,CAAC;AAC7D;AACA,YAAY,UAAU,CAAC,MAAM;AAC7B,gBAAgB,MAAM,CAAC,mBAAmB,CAAC,SAAS,EAAE,aAAa,CAAC;AACpE,gBAAgB,KAAK,CAAC,KAAK,EAAE;AAC7B,gBAAgB,MAAM,CAAC,IAAI,KAAK,CAAC,eAAe,CAAC,CAAC;AAClD,aAAa,EAAE,MAAM,CAAC;AACtB,SAAS,CAAC;AACV;AACA;AACA,cAAc,CAAC,eAAe,GAAG,4BAA4B;;;;;;;;;"}
1
+ {"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from \"@capacitor/core\";\nconst SocialLogin = registerPlugin(\"SocialLogin\", {\n web: () => import(\"./web\").then((m) => new m.SocialLoginWeb()),\n});\nexport * from \"./definitions\";\nexport { SocialLogin };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from \"@capacitor/core\";\nexport class SocialLoginWeb extends WebPlugin {\n constructor() {\n var _a;\n super();\n this.googleClientId = null;\n this.appleClientId = null;\n this.googleScriptLoaded = false;\n this.googleLoginType = \"online\";\n this.appleScriptLoaded = false;\n this.appleScriptUrl = \"https://appleid.cdn-apple.com/appleauth/static/jsapi/appleid/1/en_US/appleid.auth.js\";\n this.GOOGLE_TOKEN_REQUEST_URL = \"https://www.googleapis.com/oauth2/v3/tokeninfo\";\n this.facebookAppId = null;\n this.facebookScriptLoaded = false;\n // Set up listener for OAuth redirects if we have a pending OAuth flow\n if (localStorage.getItem(SocialLoginWeb.OAUTH_STATE_KEY)) {\n console.log(\"OAUTH_STATE_KEY found\");\n const result = this.handleOAuthRedirect();\n if (result) {\n (_a = window.opener) === null || _a === void 0 ? void 0 : _a.postMessage(Object.assign({ type: \"oauth-response\" }, result.result), window.location.origin);\n window.close();\n }\n }\n }\n handleOAuthRedirect() {\n const paramsRaw = new URL(window.location.href).searchParams;\n const code = paramsRaw.get(\"code\");\n if (code && paramsRaw.has(\"scope\")) {\n return {\n provider: \"google\",\n result: {\n provider: \"google\",\n result: {\n serverAuthCode: code,\n },\n },\n };\n }\n const hash = window.location.hash.substring(1);\n console.log(\"handleOAuthRedirect\", window.location.hash);\n if (!hash)\n return;\n console.log(\"handleOAuthRedirect ok\");\n const params = new URLSearchParams(hash);\n const accessToken = params.get(\"access_token\");\n const idToken = params.get(\"id_token\");\n if (accessToken && idToken) {\n localStorage.removeItem(SocialLoginWeb.OAUTH_STATE_KEY);\n const profile = this.parseJwt(idToken);\n return {\n provider: \"google\",\n result: {\n accessToken: {\n token: accessToken,\n },\n idToken,\n profile: {\n email: profile.email || null,\n familyName: profile.family_name || null,\n givenName: profile.given_name || null,\n id: profile.sub || null,\n name: profile.name || null,\n imageUrl: profile.picture || null,\n },\n },\n };\n }\n return null;\n }\n async initialize(options) {\n var _a, _b, _c;\n if ((_a = options.google) === null || _a === void 0 ? void 0 : _a.webClientId) {\n this.googleClientId = options.google.webClientId;\n if (options.google.mode) {\n this.googleLoginType = options.google.mode;\n }\n await this.loadGoogleScript();\n }\n if ((_b = options.apple) === null || _b === void 0 ? void 0 : _b.clientId) {\n this.appleClientId = options.apple.clientId;\n await this.loadAppleScript();\n }\n if ((_c = options.facebook) === null || _c === void 0 ? void 0 : _c.appId) {\n this.facebookAppId = options.facebook.appId;\n await this.loadFacebookScript();\n FB.init({\n appId: this.facebookAppId,\n version: \"v17.0\",\n xfbml: true,\n cookie: true,\n });\n }\n // Implement initialization for other providers if needed\n }\n async login(options) {\n switch (options.provider) {\n case \"google\":\n return this.loginWithGoogle(options.options);\n case \"apple\":\n return this.loginWithApple(options.options);\n case \"facebook\":\n return this.loginWithFacebook(options.options);\n default:\n throw new Error(`Login for ${options.provider} is not implemented on web`);\n }\n }\n async logout(options) {\n switch (options.provider) {\n case \"google\":\n if (this.googleLoginType === \"offline\") {\n return Promise.reject(\"Offline login doesn't store tokens. logout is not available\");\n }\n // Google doesn't have a specific logout method for web\n // We can revoke the token if we have it stored\n console.log(\"Google logout: Id token should be revoked on the client side if stored\");\n // eslint-disable-next-line\n const state = this.getGoogleState();\n if (!state)\n return;\n await this.rawLogoutGoogle(state.accessToken);\n break;\n case \"apple\":\n // Apple doesn't provide a logout method for web\n console.log(\"Apple logout: Session should be managed on the client side\");\n break;\n case \"facebook\":\n return new Promise((resolve) => {\n FB.logout(() => resolve());\n });\n default:\n throw new Error(`Logout for ${options.provider} is not implemented`);\n }\n }\n async accessTokenIsValid(accessToken) {\n const url = `${this.GOOGLE_TOKEN_REQUEST_URL}?access_token=${encodeURIComponent(accessToken)}`;\n try {\n // Make the GET request using fetch\n const response = await fetch(url);\n // Check if the response is successful\n if (!response.ok) {\n console.log(`Invalid response from ${this.GOOGLE_TOKEN_REQUEST_URL}. Response not successful. Status code: ${response.status}. Assuming that the token is not valid`);\n return false;\n }\n // Get the response body as text\n const responseBody = await response.text();\n if (!responseBody) {\n console.error(`Invalid response from ${this.GOOGLE_TOKEN_REQUEST_URL}. Response body is null`);\n throw new Error(`Invalid response from ${this.GOOGLE_TOKEN_REQUEST_URL}. Response body is null`);\n }\n // Parse the response body as JSON\n let jsonObject;\n try {\n jsonObject = JSON.parse(responseBody);\n }\n catch (e) {\n console.error(`Invalid response from ${this.GOOGLE_TOKEN_REQUEST_URL}. Response body is not valid JSON. Error: ${e}`);\n throw new Error(`Invalid response from ${this.GOOGLE_TOKEN_REQUEST_URL}. Response body is not valid JSON. Error: ${e}`);\n }\n // Extract the 'expires_in' field\n const expiresInStr = jsonObject[\"expires_in\"];\n if (expiresInStr === undefined || expiresInStr === null) {\n console.error(`Invalid response from ${this.GOOGLE_TOKEN_REQUEST_URL}. Response JSON does not include 'expires_in'.`);\n throw new Error(`Invalid response from ${this.GOOGLE_TOKEN_REQUEST_URL}. Response JSON does not include 'expires_in'.`);\n }\n // Parse 'expires_in' as an integer\n let expiresInInt;\n try {\n expiresInInt = parseInt(expiresInStr, 10);\n if (isNaN(expiresInInt)) {\n throw new Error(`'expires_in' is not a valid integer`);\n }\n }\n catch (e) {\n console.error(`Invalid response from ${this.GOOGLE_TOKEN_REQUEST_URL}. 'expires_in': ${expiresInStr} is not a valid integer. Error: ${e}`);\n throw new Error(`Invalid response from ${this.GOOGLE_TOKEN_REQUEST_URL}. 'expires_in': ${expiresInStr} is not a valid integer. Error: ${e}`);\n }\n // Determine if the access token is valid based on 'expires_in'\n return expiresInInt > 5;\n }\n catch (error) {\n console.error(error);\n throw error;\n }\n }\n idTokenValid(idToken) {\n try {\n const parsed = this.parseJwt(idToken);\n const currentTime = Math.ceil(Date.now() / 1000) + 5; // Convert current time to seconds since epoch\n return parsed.exp && currentTime < parsed.exp;\n }\n catch (e) {\n return false;\n }\n }\n async rawLogoutGoogle(accessToken, tokenValid = null) {\n if (tokenValid === null) {\n tokenValid = await this.accessTokenIsValid(accessToken);\n }\n if (tokenValid === true) {\n return new Promise((resolve, reject) => {\n try {\n google.accounts.oauth2.revoke(accessToken, async () => {\n this.clearStateGoogle();\n resolve();\n });\n }\n catch (e) {\n reject(e);\n }\n });\n }\n else {\n this.clearStateGoogle();\n return;\n }\n }\n async isLoggedIn(options) {\n switch (options.provider) {\n case \"google\":\n if (this.googleLoginType === \"offline\") {\n return Promise.reject(\"Offline login doesn't store tokens. isLoggedIn is not available\");\n }\n // For Google, we can check if there's a valid token\n // eslint-disable-next-line\n const state = this.getGoogleState();\n if (!state)\n return { isLoggedIn: false };\n try {\n // todo: cache accessTokenIsValid calls\n const isValidAccessToken = await this.accessTokenIsValid(state.accessToken);\n const isValidIdToken = this.idTokenValid(state.idToken);\n if (isValidAccessToken && isValidIdToken) {\n return { isLoggedIn: true };\n }\n else {\n try {\n await this.rawLogoutGoogle(state.accessToken, false);\n }\n catch (e) {\n console.error(\"Access token is not valid, but cannot logout\", e);\n }\n return { isLoggedIn: false };\n }\n }\n catch (e) {\n return Promise.reject(e);\n }\n case \"apple\":\n // Apple doesn't provide a method to check login status on web\n console.log(\"Apple login status should be managed on the client side\");\n return { isLoggedIn: false };\n case \"facebook\":\n return new Promise((resolve) => {\n FB.getLoginStatus((response) => {\n resolve({ isLoggedIn: response.status === \"connected\" });\n });\n });\n default:\n throw new Error(`isLoggedIn for ${options.provider} is not implemented`);\n }\n }\n async getAuthorizationCode(options) {\n switch (options.provider) {\n case \"google\":\n if (this.googleLoginType === \"offline\") {\n return Promise.reject(\"Offline login doesn't store tokens. getAuthorizationCode is not available\");\n }\n // For Google, we can use the id_token as the authorization code\n // eslint-disable-next-line\n const state = this.getGoogleState();\n if (!state)\n throw new Error(\"No Google authorization code available\");\n try {\n // todo: cache accessTokenIsValid calls\n const isValidAccessToken = await this.accessTokenIsValid(state.accessToken);\n const isValidIdToken = this.idTokenValid(state.idToken);\n if (isValidAccessToken && isValidIdToken) {\n return { accessToken: state.accessToken, jwt: state.idToken };\n }\n else {\n try {\n await this.rawLogoutGoogle(state.accessToken, false);\n }\n catch (e) {\n console.error(\"Access token is not valid, but cannot logout\", e);\n }\n throw new Error(\"No Google authorization code available\");\n }\n }\n catch (e) {\n return Promise.reject(e);\n }\n case \"apple\":\n // Apple authorization code should be obtained during login\n console.log(\"Apple authorization code should be stored during login\");\n throw new Error(\"Apple authorization code not available\");\n case \"facebook\":\n return new Promise((resolve, reject) => {\n FB.getLoginStatus((response) => {\n var _a;\n if (response.status === \"connected\") {\n resolve({ jwt: ((_a = response.authResponse) === null || _a === void 0 ? void 0 : _a.accessToken) || \"\" });\n }\n else {\n reject(new Error(\"No Facebook authorization code available\"));\n }\n });\n });\n default:\n throw new Error(`getAuthorizationCode for ${options.provider} is not implemented`);\n }\n }\n async refresh(options) {\n switch (options.provider) {\n case \"google\":\n // For Google, we can prompt for re-authentication\n return Promise.reject(\"Not implemented\");\n case \"apple\":\n // Apple doesn't provide a refresh method for web\n console.log(\"Apple refresh not available on web\");\n break;\n case \"facebook\":\n await this.loginWithFacebook(options.options);\n break;\n default:\n throw new Error(`Refresh for ${options.provider} is not implemented`);\n }\n }\n loginWithGoogle(options) {\n if (!this.googleClientId) {\n throw new Error(\"Google Client ID not set. Call initialize() first.\");\n }\n let scopes = options.scopes || [];\n if (scopes.length > 0) {\n // If scopes are provided, directly use the traditional OAuth flow\n if (!scopes.includes(\"https://www.googleapis.com/auth/userinfo.email\")) {\n scopes.push(\"https://www.googleapis.com/auth/userinfo.email\");\n }\n if (!scopes.includes(\"https://www.googleapis.com/auth/userinfo.profile\")) {\n scopes.push(\"https://www.googleapis.com/auth/userinfo.profile\");\n }\n if (!scopes.includes(\"openid\")) {\n scopes.push(\"openid\");\n }\n }\n else {\n scopes = [\n \"https://www.googleapis.com/auth/userinfo.email\",\n \"https://www.googleapis.com/auth/userinfo.profile\",\n \"openid\",\n ];\n }\n if (scopes.length > 3 || this.googleLoginType === \"offline\") {\n // If scopes are provided, directly use the traditional OAuth flow\n return this.fallbackToTraditionalOAuth(scopes);\n }\n return new Promise((resolve, reject) => {\n google.accounts.id.initialize({\n client_id: this.googleClientId,\n callback: (response) => {\n console.log(\"google.accounts.id.initialize callback\", response);\n if (response.error) {\n // we use any because type fail but we need to double check if that works\n reject(response.error);\n }\n else {\n const payload = this.parseJwt(response.credential);\n const result = {\n accessToken: null,\n responseType: \"online\",\n idToken: response.credential,\n profile: {\n email: payload.email || null,\n familyName: payload.family_name || null,\n givenName: payload.given_name || null,\n id: payload.sub || null,\n name: payload.name || null,\n imageUrl: payload.picture || null,\n },\n };\n resolve({ provider: \"google\", result });\n }\n },\n auto_select: true,\n });\n google.accounts.id.prompt((notification) => {\n if (notification.isNotDisplayed() || notification.isSkippedMoment()) {\n console.log(\"OneTap is not displayed or skipped\");\n // Fallback to traditional OAuth if One Tap is not available\n this.fallbackToTraditionalOAuth(scopes)\n .then((r) => resolve({ provider: \"google\", result: r.result }))\n .catch(reject);\n }\n else {\n console.log(\"OneTap is displayed\");\n }\n });\n });\n }\n parseJwt(token) {\n const base64Url = token.split(\".\")[1];\n const base64 = base64Url.replace(/-/g, \"+\").replace(/_/g, \"/\");\n const jsonPayload = decodeURIComponent(atob(base64)\n .split(\"\")\n .map((c) => {\n return \"%\" + (\"00\" + c.charCodeAt(0).toString(16)).slice(-2);\n })\n .join(\"\"));\n return JSON.parse(jsonPayload);\n }\n async loadGoogleScript() {\n if (this.googleScriptLoaded)\n return;\n return new Promise((resolve, reject) => {\n const script = document.createElement(\"script\");\n script.src = \"https://accounts.google.com/gsi/client\";\n script.async = true;\n script.onload = () => {\n this.googleScriptLoaded = true;\n resolve();\n };\n script.onerror = reject;\n document.body.appendChild(script);\n });\n }\n async loginWithApple(options) {\n if (!this.appleClientId) {\n throw new Error(\"Apple Client ID not set. Call initialize() first.\");\n }\n if (!this.appleScriptLoaded) {\n throw new Error(\"Apple Sign-In script not loaded.\");\n }\n return new Promise((resolve, reject) => {\n var _a;\n AppleID.auth.init({\n clientId: this.appleClientId,\n scope: ((_a = options.scopes) === null || _a === void 0 ? void 0 : _a.join(\" \")) || \"name email\",\n redirectURI: options.redirectUrl || window.location.href,\n state: options.state,\n nonce: options.nonce,\n usePopup: true,\n });\n AppleID.auth\n .signIn()\n .then((res) => {\n var _a, _b, _c, _d, _e, _f, _g;\n const result = {\n profile: {\n user: ((_b = (_a = res.user) === null || _a === void 0 ? void 0 : _a.name) === null || _b === void 0 ? void 0 : _b.firstName)\n ? `${res.user.name.firstName} ${res.user.name.lastName}`\n : \"\",\n email: ((_c = res.user) === null || _c === void 0 ? void 0 : _c.email) || null,\n givenName: ((_e = (_d = res.user) === null || _d === void 0 ? void 0 : _d.name) === null || _e === void 0 ? void 0 : _e.firstName) || null,\n familyName: ((_g = (_f = res.user) === null || _f === void 0 ? void 0 : _f.name) === null || _g === void 0 ? void 0 : _g.lastName) || null,\n },\n accessToken: {\n token: res.authorization.code, // TODO: to fix and find the correct token\n },\n idToken: res.authorization.id_token || null,\n };\n resolve({ provider: \"apple\", result });\n })\n .catch((error) => {\n reject(error);\n });\n });\n }\n async loadAppleScript() {\n if (this.appleScriptLoaded)\n return;\n return new Promise((resolve, reject) => {\n const script = document.createElement(\"script\");\n script.src = this.appleScriptUrl;\n script.async = true;\n script.onload = () => {\n this.appleScriptLoaded = true;\n resolve();\n };\n script.onerror = reject;\n document.body.appendChild(script);\n });\n }\n persistStateGoogle(accessToken, idToken) {\n try {\n window.localStorage.setItem(\"capgo_social_login_google_state\", JSON.stringify({ accessToken, idToken }));\n }\n catch (e) {\n console.error(\"Cannot persist state google\", e);\n }\n }\n clearStateGoogle() {\n try {\n window.localStorage.removeItem(\"capgo_social_login_google_state\");\n }\n catch (e) {\n console.error(\"Cannot clear state google\", e);\n }\n }\n getGoogleState() {\n try {\n const state = window.localStorage.getItem(\"capgo_social_login_google_state\");\n if (!state)\n return null;\n const { accessToken, idToken } = JSON.parse(state);\n return { accessToken, idToken };\n }\n catch (e) {\n console.error(\"Cannot get state google\", e);\n return null;\n }\n }\n async loadFacebookScript() {\n if (this.facebookScriptLoaded)\n return;\n return new Promise((resolve, reject) => {\n const script = document.createElement(\"script\");\n script.src = \"https://connect.facebook.net/en_US/sdk.js\";\n script.async = true;\n script.defer = true;\n script.onload = () => {\n this.facebookScriptLoaded = true;\n resolve();\n };\n script.onerror = reject;\n document.body.appendChild(script);\n });\n }\n async loginWithFacebook(options) {\n if (!this.facebookAppId) {\n throw new Error(\"Facebook App ID not set. Call initialize() first.\");\n }\n return new Promise((resolve, reject) => {\n FB.login((response) => {\n if (response.status === \"connected\") {\n FB.api(\"/me\", { fields: \"id,name,email,picture\" }, (userInfo) => {\n var _a, _b;\n const result = {\n accessToken: {\n token: response.authResponse.accessToken,\n userId: response.authResponse.userID,\n },\n profile: {\n userID: userInfo.id,\n name: userInfo.name,\n email: userInfo.email || null,\n imageURL: ((_b = (_a = userInfo.picture) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.url) || null,\n friendIDs: [],\n birthday: null,\n ageRange: null,\n gender: null,\n location: null,\n hometown: null,\n profileURL: null,\n },\n idToken: null,\n };\n resolve({ provider: \"facebook\", result });\n });\n }\n else {\n reject(new Error(\"Facebook login failed\"));\n }\n }, { scope: options.permissions.join(\",\") });\n });\n }\n async fallbackToTraditionalOAuth(scopes) {\n const uniqueScopes = [...new Set([...scopes, \"openid\"])];\n const params = new URLSearchParams({\n client_id: this.googleClientId,\n redirect_uri: window.location.href,\n response_type: this.googleLoginType === \"offline\" ? \"code\" : \"token id_token\",\n scope: uniqueScopes.join(\" \"),\n nonce: Math.random().toString(36).substring(2),\n include_granted_scopes: \"true\",\n state: \"popup\",\n });\n const url = `https://accounts.google.com/o/oauth2/v2/auth?${params.toString()}`;\n const width = 500;\n const height = 600;\n const left = window.screenX + (window.outerWidth - width) / 2;\n const top = window.screenY + (window.outerHeight - height) / 2;\n localStorage.setItem(SocialLoginWeb.OAUTH_STATE_KEY, \"true\");\n const popup = window.open(url, \"Google Sign In\", `width=${width},height=${height},left=${left},top=${top},popup=1`);\n // This may never return...\n return new Promise((resolve, reject) => {\n if (!popup) {\n reject(new Error(\"Failed to open popup\"));\n return;\n }\n const handleMessage = (event) => {\n var _a;\n if (event.origin !== window.location.origin)\n return;\n if (((_a = event.data) === null || _a === void 0 ? void 0 : _a.type) === \"oauth-response\") {\n window.removeEventListener(\"message\", handleMessage);\n if (this.googleLoginType === \"online\") {\n const { accessToken, idToken } = event.data;\n if (accessToken && idToken) {\n const profile = this.parseJwt(idToken);\n this.persistStateGoogle(accessToken.token, idToken);\n resolve({\n provider: \"google\",\n result: {\n accessToken: {\n token: accessToken.token,\n },\n idToken,\n profile: {\n email: profile.email || null,\n familyName: profile.family_name || null,\n givenName: profile.given_name || null,\n id: profile.sub || null,\n name: profile.name || null,\n imageUrl: profile.picture || null,\n },\n responseType: \"online\",\n },\n });\n }\n }\n else {\n const { serverAuthCode } = event.data.result;\n resolve({\n provider: \"google\",\n result: {\n responseType: \"offline\",\n serverAuthCode,\n },\n });\n }\n }\n else {\n reject(new Error(\"Login failed\"));\n }\n };\n window.addEventListener(\"message\", handleMessage);\n // Timeout after 5 minutes\n setTimeout(() => {\n window.removeEventListener(\"message\", handleMessage);\n popup.close();\n reject(new Error(\"OAuth timeout\"));\n }, 300000);\n });\n }\n}\nSocialLoginWeb.OAUTH_STATE_KEY = \"social_login_oauth_pending\";\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;AACK,MAAC,WAAW,GAAGA,mBAAc,CAAC,aAAa,EAAE;AAClD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,cAAc,EAAE,CAAC;AAClE,CAAC;;ACFM,MAAM,cAAc,SAASC,cAAS,CAAC;AAC9C,IAAI,WAAW,GAAG;AAClB,QAAQ,IAAI,EAAE;AACd,QAAQ,KAAK,EAAE;AACf,QAAQ,IAAI,CAAC,cAAc,GAAG,IAAI;AAClC,QAAQ,IAAI,CAAC,aAAa,GAAG,IAAI;AACjC,QAAQ,IAAI,CAAC,kBAAkB,GAAG,KAAK;AACvC,QAAQ,IAAI,CAAC,eAAe,GAAG,QAAQ;AACvC,QAAQ,IAAI,CAAC,iBAAiB,GAAG,KAAK;AACtC,QAAQ,IAAI,CAAC,cAAc,GAAG,sFAAsF;AACpH,QAAQ,IAAI,CAAC,wBAAwB,GAAG,gDAAgD;AACxF,QAAQ,IAAI,CAAC,aAAa,GAAG,IAAI;AACjC,Q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,cAAc,CAAC,CAAC;AACrD;AACA,aAAa;AACb,YAAY,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,aAAa,CAAC;AAC7D;AACA,YAAY,UAAU,CAAC,MAAM;AAC7B,gBAAgB,MAAM,CAAC,mBAAmB,CAAC,SAAS,EAAE,aAAa,CAAC;AACpE,gBAAgB,KAAK,CAAC,KAAK,EAAE;AAC7B,gBAAgB,MAAM,CAAC,IAAI,KAAK,CAAC,eAAe,CAAC,CAAC;AAClD,aAAa,EAAE,MAAM,CAAC;AACtB,SAAS,CAAC;AACV;AACA;AACA,cAAc,CAAC,eAAe,GAAG,4BAA4B;;;;;;;;;"}
package/dist/plugin.js CHANGED
@@ -119,6 +119,7 @@ var capacitorCapacitorUpdater = (function (exports, core) {
119
119
  // Google doesn't have a specific logout method for web
120
120
  // We can revoke the token if we have it stored
121
121
  console.log("Google logout: Id token should be revoked on the client side if stored");
122
+ // eslint-disable-next-line
122
123
  const state = this.getGoogleState();
123
124
  if (!state)
124
125
  return;
@@ -226,6 +227,7 @@ var capacitorCapacitorUpdater = (function (exports, core) {
226
227
  return Promise.reject("Offline login doesn't store tokens. isLoggedIn is not available");
227
228
  }
228
229
  // For Google, we can check if there's a valid token
230
+ // eslint-disable-next-line
229
231
  const state = this.getGoogleState();
230
232
  if (!state)
231
233
  return { isLoggedIn: false };
@@ -270,6 +272,7 @@ var capacitorCapacitorUpdater = (function (exports, core) {
270
272
  return Promise.reject("Offline login doesn't store tokens. getAuthorizationCode is not available");
271
273
  }
272
274
  // For Google, we can use the id_token as the authorization code
275
+ // eslint-disable-next-line
273
276
  const state = this.getGoogleState();
274
277
  if (!state)
275
278
  throw new Error("No Google authorization code available");
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from \"@capacitor/core\";\nconst SocialLogin = registerPlugin(\"SocialLogin\", {\n web: () => import(\"./web\").then((m) => new m.SocialLoginWeb()),\n});\nexport * from \"./definitions\";\nexport { SocialLogin };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from \"@capacitor/core\";\nexport class SocialLoginWeb extends WebPlugin {\n constructor() {\n var _a;\n super();\n this.googleClientId = null;\n this.appleClientId = null;\n this.googleScriptLoaded = false;\n this.googleLoginType = \"online\";\n this.appleScriptLoaded = false;\n this.appleScriptUrl = \"https://appleid.cdn-apple.com/appleauth/static/jsapi/appleid/1/en_US/appleid.auth.js\";\n this.GOOGLE_TOKEN_REQUEST_URL = \"https://www.googleapis.com/oauth2/v3/tokeninfo\";\n this.facebookAppId = null;\n this.facebookScriptLoaded = false;\n // Set up listener for OAuth redirects if we have a pending OAuth flow\n if (localStorage.getItem(SocialLoginWeb.OAUTH_STATE_KEY)) {\n console.log(\"OAUTH_STATE_KEY found\");\n const result = this.handleOAuthRedirect();\n if (result) {\n (_a = window.opener) === null || _a === void 0 ? void 0 : _a.postMessage(Object.assign({ type: \"oauth-response\" }, result.result), window.location.origin);\n window.close();\n }\n }\n }\n handleOAuthRedirect() {\n const paramsRaw = new URL(window.location.href).searchParams;\n const code = paramsRaw.get(\"code\");\n if (code && paramsRaw.has(\"scope\")) {\n return {\n provider: \"google\",\n result: {\n provider: \"google\",\n result: {\n serverAuthCode: code,\n },\n },\n };\n }\n const hash = window.location.hash.substring(1);\n console.log(\"handleOAuthRedirect\", window.location.hash);\n if (!hash)\n return;\n console.log(\"handleOAuthRedirect ok\");\n const params = new URLSearchParams(hash);\n const accessToken = params.get(\"access_token\");\n const idToken = params.get(\"id_token\");\n if (accessToken && idToken) {\n localStorage.removeItem(SocialLoginWeb.OAUTH_STATE_KEY);\n const profile = this.parseJwt(idToken);\n return {\n provider: \"google\",\n result: {\n accessToken: {\n token: accessToken,\n },\n idToken,\n profile: {\n email: profile.email || null,\n familyName: profile.family_name || null,\n givenName: profile.given_name || null,\n id: profile.sub || null,\n name: profile.name || null,\n imageUrl: profile.picture || null,\n },\n },\n };\n }\n return null;\n }\n async initialize(options) {\n var _a, _b, _c;\n if ((_a = options.google) === null || _a === void 0 ? void 0 : _a.webClientId) {\n this.googleClientId = options.google.webClientId;\n if (options.google.mode) {\n this.googleLoginType = options.google.mode;\n }\n await this.loadGoogleScript();\n }\n if ((_b = options.apple) === null || _b === void 0 ? void 0 : _b.clientId) {\n this.appleClientId = options.apple.clientId;\n await this.loadAppleScript();\n }\n if ((_c = options.facebook) === null || _c === void 0 ? void 0 : _c.appId) {\n this.facebookAppId = options.facebook.appId;\n await this.loadFacebookScript();\n FB.init({\n appId: this.facebookAppId,\n version: \"v17.0\",\n xfbml: true,\n cookie: true,\n });\n }\n // Implement initialization for other providers if needed\n }\n async login(options) {\n switch (options.provider) {\n case \"google\":\n return this.loginWithGoogle(options.options);\n case \"apple\":\n return this.loginWithApple(options.options);\n case \"facebook\":\n return this.loginWithFacebook(options.options);\n default:\n throw new Error(`Login for ${options.provider} is not implemented on web`);\n }\n }\n async logout(options) {\n switch (options.provider) {\n case \"google\":\n if (this.googleLoginType === \"offline\") {\n return Promise.reject(\"Offline login doesn't store tokens. logout is not available\");\n }\n // Google doesn't have a specific logout method for web\n // We can revoke the token if we have it stored\n console.log(\"Google logout: Id token should be revoked on the client side if stored\");\n const state = this.getGoogleState();\n if (!state)\n return;\n await this.rawLogoutGoogle(state.accessToken);\n break;\n case \"apple\":\n // Apple doesn't provide a logout method for web\n console.log(\"Apple logout: Session should be managed on the client side\");\n break;\n case \"facebook\":\n return new Promise((resolve) => {\n FB.logout(() => resolve());\n });\n default:\n throw new Error(`Logout for ${options.provider} is not implemented`);\n }\n }\n async accessTokenIsValid(accessToken) {\n const url = `${this.GOOGLE_TOKEN_REQUEST_URL}?access_token=${encodeURIComponent(accessToken)}`;\n try {\n // Make the GET request using fetch\n const response = await fetch(url);\n // Check if the response is successful\n if (!response.ok) {\n console.log(`Invalid response from ${this.GOOGLE_TOKEN_REQUEST_URL}. Response not successful. Status code: ${response.status}. Assuming that the token is not valid`);\n return false;\n }\n // Get the response body as text\n const responseBody = await response.text();\n if (!responseBody) {\n console.error(`Invalid response from ${this.GOOGLE_TOKEN_REQUEST_URL}. Response body is null`);\n throw new Error(`Invalid response from ${this.GOOGLE_TOKEN_REQUEST_URL}. Response body is null`);\n }\n // Parse the response body as JSON\n let jsonObject;\n try {\n jsonObject = JSON.parse(responseBody);\n }\n catch (e) {\n console.error(`Invalid response from ${this.GOOGLE_TOKEN_REQUEST_URL}. Response body is not valid JSON. Error: ${e}`);\n throw new Error(`Invalid response from ${this.GOOGLE_TOKEN_REQUEST_URL}. Response body is not valid JSON. Error: ${e}`);\n }\n // Extract the 'expires_in' field\n const expiresInStr = jsonObject[\"expires_in\"];\n if (expiresInStr === undefined || expiresInStr === null) {\n console.error(`Invalid response from ${this.GOOGLE_TOKEN_REQUEST_URL}. Response JSON does not include 'expires_in'.`);\n throw new Error(`Invalid response from ${this.GOOGLE_TOKEN_REQUEST_URL}. Response JSON does not include 'expires_in'.`);\n }\n // Parse 'expires_in' as an integer\n let expiresInInt;\n try {\n expiresInInt = parseInt(expiresInStr, 10);\n if (isNaN(expiresInInt)) {\n throw new Error(`'expires_in' is not a valid integer`);\n }\n }\n catch (e) {\n console.error(`Invalid response from ${this.GOOGLE_TOKEN_REQUEST_URL}. 'expires_in': ${expiresInStr} is not a valid integer. Error: ${e}`);\n throw new Error(`Invalid response from ${this.GOOGLE_TOKEN_REQUEST_URL}. 'expires_in': ${expiresInStr} is not a valid integer. Error: ${e}`);\n }\n // Determine if the access token is valid based on 'expires_in'\n return expiresInInt > 5;\n }\n catch (error) {\n console.error(error);\n throw error;\n }\n }\n idTokenValid(idToken) {\n try {\n const parsed = this.parseJwt(idToken);\n const currentTime = Math.ceil(Date.now() / 1000) + 5; // Convert current time to seconds since epoch\n return parsed.exp && currentTime < parsed.exp;\n }\n catch (e) {\n return false;\n }\n }\n async rawLogoutGoogle(accessToken, tokenValid = null) {\n if (tokenValid === null) {\n tokenValid = await this.accessTokenIsValid(accessToken);\n }\n if (tokenValid === true) {\n return new Promise((resolve, reject) => {\n try {\n google.accounts.oauth2.revoke(accessToken, async () => {\n this.clearStateGoogle();\n resolve();\n });\n }\n catch (e) {\n reject(e);\n }\n });\n }\n else {\n this.clearStateGoogle();\n return;\n }\n }\n async isLoggedIn(options) {\n switch (options.provider) {\n case \"google\":\n if (this.googleLoginType === \"offline\") {\n return Promise.reject(\"Offline login doesn't store tokens. isLoggedIn is not available\");\n }\n // For Google, we can check if there's a valid token\n const state = this.getGoogleState();\n if (!state)\n return { isLoggedIn: false };\n try {\n // todo: cache accessTokenIsValid calls\n const isValidAccessToken = await this.accessTokenIsValid(state.accessToken);\n const isValidIdToken = this.idTokenValid(state.idToken);\n if (isValidAccessToken && isValidIdToken) {\n return { isLoggedIn: true };\n }\n else {\n try {\n await this.rawLogoutGoogle(state.accessToken, false);\n }\n catch (e) {\n console.error(\"Access token is not valid, but cannot logout\", e);\n }\n return { isLoggedIn: false };\n }\n }\n catch (e) {\n return Promise.reject(e);\n }\n case \"apple\":\n // Apple doesn't provide a method to check login status on web\n console.log(\"Apple login status should be managed on the client side\");\n return { isLoggedIn: false };\n case \"facebook\":\n return new Promise((resolve) => {\n FB.getLoginStatus((response) => {\n resolve({ isLoggedIn: response.status === \"connected\" });\n });\n });\n default:\n throw new Error(`isLoggedIn for ${options.provider} is not implemented`);\n }\n }\n async getAuthorizationCode(options) {\n switch (options.provider) {\n case \"google\":\n if (this.googleLoginType === \"offline\") {\n return Promise.reject(\"Offline login doesn't store tokens. getAuthorizationCode is not available\");\n }\n // For Google, we can use the id_token as the authorization code\n const state = this.getGoogleState();\n if (!state)\n throw new Error(\"No Google authorization code available\");\n try {\n // todo: cache accessTokenIsValid calls\n const isValidAccessToken = await this.accessTokenIsValid(state.accessToken);\n const isValidIdToken = this.idTokenValid(state.idToken);\n if (isValidAccessToken && isValidIdToken) {\n return { accessToken: state.accessToken, jwt: state.idToken };\n }\n else {\n try {\n await this.rawLogoutGoogle(state.accessToken, false);\n }\n catch (e) {\n console.error(\"Access token is not valid, but cannot logout\", e);\n }\n throw new Error(\"No Google authorization code available\");\n }\n }\n catch (e) {\n return Promise.reject(e);\n }\n case \"apple\":\n // Apple authorization code should be obtained during login\n console.log(\"Apple authorization code should be stored during login\");\n throw new Error(\"Apple authorization code not available\");\n case \"facebook\":\n return new Promise((resolve, reject) => {\n FB.getLoginStatus((response) => {\n var _a;\n if (response.status === \"connected\") {\n resolve({ jwt: ((_a = response.authResponse) === null || _a === void 0 ? void 0 : _a.accessToken) || \"\" });\n }\n else {\n reject(new Error(\"No Facebook authorization code available\"));\n }\n });\n });\n default:\n throw new Error(`getAuthorizationCode for ${options.provider} is not implemented`);\n }\n }\n async refresh(options) {\n switch (options.provider) {\n case \"google\":\n // For Google, we can prompt for re-authentication\n return Promise.reject(\"Not implemented\");\n case \"apple\":\n // Apple doesn't provide a refresh method for web\n console.log(\"Apple refresh not available on web\");\n break;\n case \"facebook\":\n await this.loginWithFacebook(options.options);\n break;\n default:\n throw new Error(`Refresh for ${options.provider} is not implemented`);\n }\n }\n loginWithGoogle(options) {\n if (!this.googleClientId) {\n throw new Error(\"Google Client ID not set. Call initialize() first.\");\n }\n let scopes = options.scopes || [];\n if (scopes.length > 0) {\n // If scopes are provided, directly use the traditional OAuth flow\n if (!scopes.includes(\"https://www.googleapis.com/auth/userinfo.email\")) {\n scopes.push(\"https://www.googleapis.com/auth/userinfo.email\");\n }\n if (!scopes.includes(\"https://www.googleapis.com/auth/userinfo.profile\")) {\n scopes.push(\"https://www.googleapis.com/auth/userinfo.profile\");\n }\n if (!scopes.includes(\"openid\")) {\n scopes.push(\"openid\");\n }\n }\n else {\n scopes = [\n \"https://www.googleapis.com/auth/userinfo.email\",\n \"https://www.googleapis.com/auth/userinfo.profile\",\n \"openid\",\n ];\n }\n if (scopes.length > 3 || this.googleLoginType === \"offline\") {\n // If scopes are provided, directly use the traditional OAuth flow\n return this.fallbackToTraditionalOAuth(scopes);\n }\n return new Promise((resolve, reject) => {\n google.accounts.id.initialize({\n client_id: this.googleClientId,\n callback: (response) => {\n console.log(\"google.accounts.id.initialize callback\", response);\n if (response.error) {\n // we use any because type fail but we need to double check if that works\n reject(response.error);\n }\n else {\n const payload = this.parseJwt(response.credential);\n const result = {\n accessToken: null,\n responseType: \"online\",\n idToken: response.credential,\n profile: {\n email: payload.email || null,\n familyName: payload.family_name || null,\n givenName: payload.given_name || null,\n id: payload.sub || null,\n name: payload.name || null,\n imageUrl: payload.picture || null,\n },\n };\n resolve({ provider: \"google\", result });\n }\n },\n auto_select: true,\n });\n google.accounts.id.prompt((notification) => {\n if (notification.isNotDisplayed() || notification.isSkippedMoment()) {\n console.log(\"OneTap is not displayed or skipped\");\n // Fallback to traditional OAuth if One Tap is not available\n this.fallbackToTraditionalOAuth(scopes)\n .then((r) => resolve({ provider: \"google\", result: r.result }))\n .catch(reject);\n }\n else {\n console.log(\"OneTap is displayed\");\n }\n });\n });\n }\n parseJwt(token) {\n const base64Url = token.split(\".\")[1];\n const base64 = base64Url.replace(/-/g, \"+\").replace(/_/g, \"/\");\n const jsonPayload = decodeURIComponent(atob(base64)\n .split(\"\")\n .map((c) => {\n return \"%\" + (\"00\" + c.charCodeAt(0).toString(16)).slice(-2);\n })\n .join(\"\"));\n return JSON.parse(jsonPayload);\n }\n async loadGoogleScript() {\n if (this.googleScriptLoaded)\n return;\n return new Promise((resolve, reject) => {\n const script = document.createElement(\"script\");\n script.src = \"https://accounts.google.com/gsi/client\";\n script.async = true;\n script.onload = () => {\n this.googleScriptLoaded = true;\n resolve();\n };\n script.onerror = reject;\n document.body.appendChild(script);\n });\n }\n async loginWithApple(options) {\n if (!this.appleClientId) {\n throw new Error(\"Apple Client ID not set. Call initialize() first.\");\n }\n if (!this.appleScriptLoaded) {\n throw new Error(\"Apple Sign-In script not loaded.\");\n }\n return new Promise((resolve, reject) => {\n var _a;\n AppleID.auth.init({\n clientId: this.appleClientId,\n scope: ((_a = options.scopes) === null || _a === void 0 ? void 0 : _a.join(\" \")) || \"name email\",\n redirectURI: options.redirectUrl || window.location.href,\n state: options.state,\n nonce: options.nonce,\n usePopup: true,\n });\n AppleID.auth\n .signIn()\n .then((res) => {\n var _a, _b, _c, _d, _e, _f, _g;\n const result = {\n profile: {\n user: ((_b = (_a = res.user) === null || _a === void 0 ? void 0 : _a.name) === null || _b === void 0 ? void 0 : _b.firstName)\n ? `${res.user.name.firstName} ${res.user.name.lastName}`\n : \"\",\n email: ((_c = res.user) === null || _c === void 0 ? void 0 : _c.email) || null,\n givenName: ((_e = (_d = res.user) === null || _d === void 0 ? void 0 : _d.name) === null || _e === void 0 ? void 0 : _e.firstName) || null,\n familyName: ((_g = (_f = res.user) === null || _f === void 0 ? void 0 : _f.name) === null || _g === void 0 ? void 0 : _g.lastName) || null,\n },\n accessToken: {\n token: res.authorization.code, // TODO: to fix and find the correct token\n },\n idToken: res.authorization.id_token || null,\n };\n resolve({ provider: \"apple\", result });\n })\n .catch((error) => {\n reject(error);\n });\n });\n }\n async loadAppleScript() {\n if (this.appleScriptLoaded)\n return;\n return new Promise((resolve, reject) => {\n const script = document.createElement(\"script\");\n script.src = this.appleScriptUrl;\n script.async = true;\n script.onload = () => {\n this.appleScriptLoaded = true;\n resolve();\n };\n script.onerror = reject;\n document.body.appendChild(script);\n });\n }\n persistStateGoogle(accessToken, idToken) {\n try {\n window.localStorage.setItem(\"capgo_social_login_google_state\", JSON.stringify({ accessToken, idToken }));\n }\n catch (e) {\n console.error(\"Cannot persist state google\", e);\n }\n }\n clearStateGoogle() {\n try {\n window.localStorage.removeItem(\"capgo_social_login_google_state\");\n }\n catch (e) {\n console.error(\"Cannot clear state google\", e);\n }\n }\n getGoogleState() {\n try {\n const state = window.localStorage.getItem(\"capgo_social_login_google_state\");\n if (!state)\n return null;\n const { accessToken, idToken } = JSON.parse(state);\n return { accessToken, idToken };\n }\n catch (e) {\n console.error(\"Cannot get state google\", e);\n return null;\n }\n }\n async loadFacebookScript() {\n if (this.facebookScriptLoaded)\n return;\n return new Promise((resolve, reject) => {\n const script = document.createElement(\"script\");\n script.src = \"https://connect.facebook.net/en_US/sdk.js\";\n script.async = true;\n script.defer = true;\n script.onload = () => {\n this.facebookScriptLoaded = true;\n resolve();\n };\n script.onerror = reject;\n document.body.appendChild(script);\n });\n }\n async loginWithFacebook(options) {\n if (!this.facebookAppId) {\n throw new Error(\"Facebook App ID not set. Call initialize() first.\");\n }\n return new Promise((resolve, reject) => {\n FB.login((response) => {\n if (response.status === \"connected\") {\n FB.api(\"/me\", { fields: \"id,name,email,picture\" }, (userInfo) => {\n var _a, _b;\n const result = {\n accessToken: {\n token: response.authResponse.accessToken,\n userId: response.authResponse.userID,\n },\n profile: {\n userID: userInfo.id,\n name: userInfo.name,\n email: userInfo.email || null,\n imageURL: ((_b = (_a = userInfo.picture) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.url) || null,\n friendIDs: [],\n birthday: null,\n ageRange: null,\n gender: null,\n location: null,\n hometown: null,\n profileURL: null,\n },\n idToken: null,\n };\n resolve({ provider: \"facebook\", result });\n });\n }\n else {\n reject(new Error(\"Facebook login failed\"));\n }\n }, { scope: options.permissions.join(\",\") });\n });\n }\n async fallbackToTraditionalOAuth(scopes) {\n const uniqueScopes = [...new Set([...scopes, \"openid\"])];\n const params = new URLSearchParams({\n client_id: this.googleClientId,\n redirect_uri: window.location.href,\n response_type: this.googleLoginType === \"offline\" ? \"code\" : \"token id_token\",\n scope: uniqueScopes.join(\" \"),\n nonce: Math.random().toString(36).substring(2),\n include_granted_scopes: \"true\",\n state: \"popup\",\n });\n const url = `https://accounts.google.com/o/oauth2/v2/auth?${params.toString()}`;\n const width = 500;\n const height = 600;\n const left = window.screenX + (window.outerWidth - width) / 2;\n const top = window.screenY + (window.outerHeight - height) / 2;\n localStorage.setItem(SocialLoginWeb.OAUTH_STATE_KEY, \"true\");\n const popup = window.open(url, \"Google Sign In\", `width=${width},height=${height},left=${left},top=${top},popup=1`);\n // This may never return...\n return new Promise((resolve, reject) => {\n if (!popup) {\n reject(new Error(\"Failed to open popup\"));\n return;\n }\n const handleMessage = (event) => {\n var _a;\n if (event.origin !== window.location.origin)\n return;\n if (((_a = event.data) === null || _a === void 0 ? void 0 : _a.type) === \"oauth-response\") {\n window.removeEventListener(\"message\", handleMessage);\n if (this.googleLoginType === \"online\") {\n const { accessToken, idToken } = event.data;\n if (accessToken && idToken) {\n const profile = this.parseJwt(idToken);\n this.persistStateGoogle(accessToken.token, idToken);\n resolve({\n provider: \"google\",\n result: {\n accessToken: {\n token: accessToken.token,\n },\n idToken,\n profile: {\n email: profile.email || null,\n familyName: profile.family_name || null,\n givenName: profile.given_name || null,\n id: profile.sub || null,\n name: profile.name || null,\n imageUrl: profile.picture || null,\n },\n responseType: \"online\",\n },\n });\n }\n }\n else {\n const { serverAuthCode } = event.data.result;\n resolve({\n provider: \"google\",\n result: {\n responseType: \"offline\",\n serverAuthCode,\n },\n });\n }\n }\n else {\n reject(new Error(\"Login failed\"));\n }\n };\n window.addEventListener(\"message\", handleMessage);\n // Timeout after 5 minutes\n setTimeout(() => {\n window.removeEventListener(\"message\", handleMessage);\n popup.close();\n reject(new Error(\"OAuth timeout\"));\n }, 300000);\n });\n }\n}\nSocialLoginWeb.OAUTH_STATE_KEY = \"social_login_oauth_pending\";\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;AACK,UAAC,WAAW,GAAGA,mBAAc,CAAC,aAAa,EAAE;IAClD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,cAAc,EAAE,CAAC;IAClE,CAAC;;ICFM,MAAM,cAAc,SAASC,cAAS,CAAC;IAC9C,IAAI,WAAW,GAAG;IAClB,QAAQ,IAAI,EAAE;IACd,QAAQ,KAAK,EAAE;IACf,QAAQ,IAAI,CAAC,cAAc,GAAG,IAAI;IAClC,QAAQ,IAAI,CAAC,aAAa,GAAG,IAAI;IACjC,QAAQ,IAAI,CAAC,kBAA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B,OAAO,CAAC;IAChC,4BAA4B,QAAQ,EAAE,QAAQ;IAC9C,4BAA4B,MAAM,EAAE;IACpC,gCAAgC,YAAY,EAAE,SAAS;IACvD,gCAAgC,cAAc;IAC9C,6BAA6B;IAC7B,yBAAyB,CAAC;IAC1B;IACA;IACA,qBAAqB;IACrB,oBAAoB,MAAM,CAAC,IAAI,KAAK,CAAC,cAAc,CAAC,CAAC;IACrD;IACA,aAAa;IACb,YAAY,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,aAAa,CAAC;IAC7D;IACA,YAAY,UAAU,CAAC,MAAM;IAC7B,gBAAgB,MAAM,CAAC,mBAAmB,CAAC,SAAS,EAAE,aAAa,CAAC;IACpE,gBAAgB,KAAK,CAAC,KAAK,EAAE;IAC7B,gBAAgB,MAAM,CAAC,IAAI,KAAK,CAAC,eAAe,CAAC,CAAC;IAClD,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC;IACV;IACA;IACA,cAAc,CAAC,eAAe,GAAG,4BAA4B;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from \"@capacitor/core\";\nconst SocialLogin = registerPlugin(\"SocialLogin\", {\n web: () => import(\"./web\").then((m) => new m.SocialLoginWeb()),\n});\nexport * from \"./definitions\";\nexport { SocialLogin };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from \"@capacitor/core\";\nexport class SocialLoginWeb extends WebPlugin {\n constructor() {\n var _a;\n super();\n this.googleClientId = null;\n this.appleClientId = null;\n this.googleScriptLoaded = false;\n this.googleLoginType = \"online\";\n this.appleScriptLoaded = false;\n this.appleScriptUrl = \"https://appleid.cdn-apple.com/appleauth/static/jsapi/appleid/1/en_US/appleid.auth.js\";\n this.GOOGLE_TOKEN_REQUEST_URL = \"https://www.googleapis.com/oauth2/v3/tokeninfo\";\n this.facebookAppId = null;\n this.facebookScriptLoaded = false;\n // Set up listener for OAuth redirects if we have a pending OAuth flow\n if (localStorage.getItem(SocialLoginWeb.OAUTH_STATE_KEY)) {\n console.log(\"OAUTH_STATE_KEY found\");\n const result = this.handleOAuthRedirect();\n if (result) {\n (_a = window.opener) === null || _a === void 0 ? void 0 : _a.postMessage(Object.assign({ type: \"oauth-response\" }, result.result), window.location.origin);\n window.close();\n }\n }\n }\n handleOAuthRedirect() {\n const paramsRaw = new URL(window.location.href).searchParams;\n const code = paramsRaw.get(\"code\");\n if (code && paramsRaw.has(\"scope\")) {\n return {\n provider: \"google\",\n result: {\n provider: \"google\",\n result: {\n serverAuthCode: code,\n },\n },\n };\n }\n const hash = window.location.hash.substring(1);\n console.log(\"handleOAuthRedirect\", window.location.hash);\n if (!hash)\n return;\n console.log(\"handleOAuthRedirect ok\");\n const params = new URLSearchParams(hash);\n const accessToken = params.get(\"access_token\");\n const idToken = params.get(\"id_token\");\n if (accessToken && idToken) {\n localStorage.removeItem(SocialLoginWeb.OAUTH_STATE_KEY);\n const profile = this.parseJwt(idToken);\n return {\n provider: \"google\",\n result: {\n accessToken: {\n token: accessToken,\n },\n idToken,\n profile: {\n email: profile.email || null,\n familyName: profile.family_name || null,\n givenName: profile.given_name || null,\n id: profile.sub || null,\n name: profile.name || null,\n imageUrl: profile.picture || null,\n },\n },\n };\n }\n return null;\n }\n async initialize(options) {\n var _a, _b, _c;\n if ((_a = options.google) === null || _a === void 0 ? void 0 : _a.webClientId) {\n this.googleClientId = options.google.webClientId;\n if (options.google.mode) {\n this.googleLoginType = options.google.mode;\n }\n await this.loadGoogleScript();\n }\n if ((_b = options.apple) === null || _b === void 0 ? void 0 : _b.clientId) {\n this.appleClientId = options.apple.clientId;\n await this.loadAppleScript();\n }\n if ((_c = options.facebook) === null || _c === void 0 ? void 0 : _c.appId) {\n this.facebookAppId = options.facebook.appId;\n await this.loadFacebookScript();\n FB.init({\n appId: this.facebookAppId,\n version: \"v17.0\",\n xfbml: true,\n cookie: true,\n });\n }\n // Implement initialization for other providers if needed\n }\n async login(options) {\n switch (options.provider) {\n case \"google\":\n return this.loginWithGoogle(options.options);\n case \"apple\":\n return this.loginWithApple(options.options);\n case \"facebook\":\n return this.loginWithFacebook(options.options);\n default:\n throw new Error(`Login for ${options.provider} is not implemented on web`);\n }\n }\n async logout(options) {\n switch (options.provider) {\n case \"google\":\n if (this.googleLoginType === \"offline\") {\n return Promise.reject(\"Offline login doesn't store tokens. logout is not available\");\n }\n // Google doesn't have a specific logout method for web\n // We can revoke the token if we have it stored\n console.log(\"Google logout: Id token should be revoked on the client side if stored\");\n // eslint-disable-next-line\n const state = this.getGoogleState();\n if (!state)\n return;\n await this.rawLogoutGoogle(state.accessToken);\n break;\n case \"apple\":\n // Apple doesn't provide a logout method for web\n console.log(\"Apple logout: Session should be managed on the client side\");\n break;\n case \"facebook\":\n return new Promise((resolve) => {\n FB.logout(() => resolve());\n });\n default:\n throw new Error(`Logout for ${options.provider} is not implemented`);\n }\n }\n async accessTokenIsValid(accessToken) {\n const url = `${this.GOOGLE_TOKEN_REQUEST_URL}?access_token=${encodeURIComponent(accessToken)}`;\n try {\n // Make the GET request using fetch\n const response = await fetch(url);\n // Check if the response is successful\n if (!response.ok) {\n console.log(`Invalid response from ${this.GOOGLE_TOKEN_REQUEST_URL}. Response not successful. Status code: ${response.status}. Assuming that the token is not valid`);\n return false;\n }\n // Get the response body as text\n const responseBody = await response.text();\n if (!responseBody) {\n console.error(`Invalid response from ${this.GOOGLE_TOKEN_REQUEST_URL}. Response body is null`);\n throw new Error(`Invalid response from ${this.GOOGLE_TOKEN_REQUEST_URL}. Response body is null`);\n }\n // Parse the response body as JSON\n let jsonObject;\n try {\n jsonObject = JSON.parse(responseBody);\n }\n catch (e) {\n console.error(`Invalid response from ${this.GOOGLE_TOKEN_REQUEST_URL}. Response body is not valid JSON. Error: ${e}`);\n throw new Error(`Invalid response from ${this.GOOGLE_TOKEN_REQUEST_URL}. Response body is not valid JSON. Error: ${e}`);\n }\n // Extract the 'expires_in' field\n const expiresInStr = jsonObject[\"expires_in\"];\n if (expiresInStr === undefined || expiresInStr === null) {\n console.error(`Invalid response from ${this.GOOGLE_TOKEN_REQUEST_URL}. Response JSON does not include 'expires_in'.`);\n throw new Error(`Invalid response from ${this.GOOGLE_TOKEN_REQUEST_URL}. Response JSON does not include 'expires_in'.`);\n }\n // Parse 'expires_in' as an integer\n let expiresInInt;\n try {\n expiresInInt = parseInt(expiresInStr, 10);\n if (isNaN(expiresInInt)) {\n throw new Error(`'expires_in' is not a valid integer`);\n }\n }\n catch (e) {\n console.error(`Invalid response from ${this.GOOGLE_TOKEN_REQUEST_URL}. 'expires_in': ${expiresInStr} is not a valid integer. Error: ${e}`);\n throw new Error(`Invalid response from ${this.GOOGLE_TOKEN_REQUEST_URL}. 'expires_in': ${expiresInStr} is not a valid integer. Error: ${e}`);\n }\n // Determine if the access token is valid based on 'expires_in'\n return expiresInInt > 5;\n }\n catch (error) {\n console.error(error);\n throw error;\n }\n }\n idTokenValid(idToken) {\n try {\n const parsed = this.parseJwt(idToken);\n const currentTime = Math.ceil(Date.now() / 1000) + 5; // Convert current time to seconds since epoch\n return parsed.exp && currentTime < parsed.exp;\n }\n catch (e) {\n return false;\n }\n }\n async rawLogoutGoogle(accessToken, tokenValid = null) {\n if (tokenValid === null) {\n tokenValid = await this.accessTokenIsValid(accessToken);\n }\n if (tokenValid === true) {\n return new Promise((resolve, reject) => {\n try {\n google.accounts.oauth2.revoke(accessToken, async () => {\n this.clearStateGoogle();\n resolve();\n });\n }\n catch (e) {\n reject(e);\n }\n });\n }\n else {\n this.clearStateGoogle();\n return;\n }\n }\n async isLoggedIn(options) {\n switch (options.provider) {\n case \"google\":\n if (this.googleLoginType === \"offline\") {\n return Promise.reject(\"Offline login doesn't store tokens. isLoggedIn is not available\");\n }\n // For Google, we can check if there's a valid token\n // eslint-disable-next-line\n const state = this.getGoogleState();\n if (!state)\n return { isLoggedIn: false };\n try {\n // todo: cache accessTokenIsValid calls\n const isValidAccessToken = await this.accessTokenIsValid(state.accessToken);\n const isValidIdToken = this.idTokenValid(state.idToken);\n if (isValidAccessToken && isValidIdToken) {\n return { isLoggedIn: true };\n }\n else {\n try {\n await this.rawLogoutGoogle(state.accessToken, false);\n }\n catch (e) {\n console.error(\"Access token is not valid, but cannot logout\", e);\n }\n return { isLoggedIn: false };\n }\n }\n catch (e) {\n return Promise.reject(e);\n }\n case \"apple\":\n // Apple doesn't provide a method to check login status on web\n console.log(\"Apple login status should be managed on the client side\");\n return { isLoggedIn: false };\n case \"facebook\":\n return new Promise((resolve) => {\n FB.getLoginStatus((response) => {\n resolve({ isLoggedIn: response.status === \"connected\" });\n });\n });\n default:\n throw new Error(`isLoggedIn for ${options.provider} is not implemented`);\n }\n }\n async getAuthorizationCode(options) {\n switch (options.provider) {\n case \"google\":\n if (this.googleLoginType === \"offline\") {\n return Promise.reject(\"Offline login doesn't store tokens. getAuthorizationCode is not available\");\n }\n // For Google, we can use the id_token as the authorization code\n // eslint-disable-next-line\n const state = this.getGoogleState();\n if (!state)\n throw new Error(\"No Google authorization code available\");\n try {\n // todo: cache accessTokenIsValid calls\n const isValidAccessToken = await this.accessTokenIsValid(state.accessToken);\n const isValidIdToken = this.idTokenValid(state.idToken);\n if (isValidAccessToken && isValidIdToken) {\n return { accessToken: state.accessToken, jwt: state.idToken };\n }\n else {\n try {\n await this.rawLogoutGoogle(state.accessToken, false);\n }\n catch (e) {\n console.error(\"Access token is not valid, but cannot logout\", e);\n }\n throw new Error(\"No Google authorization code available\");\n }\n }\n catch (e) {\n return Promise.reject(e);\n }\n case \"apple\":\n // Apple authorization code should be obtained during login\n console.log(\"Apple authorization code should be stored during login\");\n throw new Error(\"Apple authorization code not available\");\n case \"facebook\":\n return new Promise((resolve, reject) => {\n FB.getLoginStatus((response) => {\n var _a;\n if (response.status === \"connected\") {\n resolve({ jwt: ((_a = response.authResponse) === null || _a === void 0 ? void 0 : _a.accessToken) || \"\" });\n }\n else {\n reject(new Error(\"No Facebook authorization code available\"));\n }\n });\n });\n default:\n throw new Error(`getAuthorizationCode for ${options.provider} is not implemented`);\n }\n }\n async refresh(options) {\n switch (options.provider) {\n case \"google\":\n // For Google, we can prompt for re-authentication\n return Promise.reject(\"Not implemented\");\n case \"apple\":\n // Apple doesn't provide a refresh method for web\n console.log(\"Apple refresh not available on web\");\n break;\n case \"facebook\":\n await this.loginWithFacebook(options.options);\n break;\n default:\n throw new Error(`Refresh for ${options.provider} is not implemented`);\n }\n }\n loginWithGoogle(options) {\n if (!this.googleClientId) {\n throw new Error(\"Google Client ID not set. Call initialize() first.\");\n }\n let scopes = options.scopes || [];\n if (scopes.length > 0) {\n // If scopes are provided, directly use the traditional OAuth flow\n if (!scopes.includes(\"https://www.googleapis.com/auth/userinfo.email\")) {\n scopes.push(\"https://www.googleapis.com/auth/userinfo.email\");\n }\n if (!scopes.includes(\"https://www.googleapis.com/auth/userinfo.profile\")) {\n scopes.push(\"https://www.googleapis.com/auth/userinfo.profile\");\n }\n if (!scopes.includes(\"openid\")) {\n scopes.push(\"openid\");\n }\n }\n else {\n scopes = [\n \"https://www.googleapis.com/auth/userinfo.email\",\n \"https://www.googleapis.com/auth/userinfo.profile\",\n \"openid\",\n ];\n }\n if (scopes.length > 3 || this.googleLoginType === \"offline\") {\n // If scopes are provided, directly use the traditional OAuth flow\n return this.fallbackToTraditionalOAuth(scopes);\n }\n return new Promise((resolve, reject) => {\n google.accounts.id.initialize({\n client_id: this.googleClientId,\n callback: (response) => {\n console.log(\"google.accounts.id.initialize callback\", response);\n if (response.error) {\n // we use any because type fail but we need to double check if that works\n reject(response.error);\n }\n else {\n const payload = this.parseJwt(response.credential);\n const result = {\n accessToken: null,\n responseType: \"online\",\n idToken: response.credential,\n profile: {\n email: payload.email || null,\n familyName: payload.family_name || null,\n givenName: payload.given_name || null,\n id: payload.sub || null,\n name: payload.name || null,\n imageUrl: payload.picture || null,\n },\n };\n resolve({ provider: \"google\", result });\n }\n },\n auto_select: true,\n });\n google.accounts.id.prompt((notification) => {\n if (notification.isNotDisplayed() || notification.isSkippedMoment()) {\n console.log(\"OneTap is not displayed or skipped\");\n // Fallback to traditional OAuth if One Tap is not available\n this.fallbackToTraditionalOAuth(scopes)\n .then((r) => resolve({ provider: \"google\", result: r.result }))\n .catch(reject);\n }\n else {\n console.log(\"OneTap is displayed\");\n }\n });\n });\n }\n parseJwt(token) {\n const base64Url = token.split(\".\")[1];\n const base64 = base64Url.replace(/-/g, \"+\").replace(/_/g, \"/\");\n const jsonPayload = decodeURIComponent(atob(base64)\n .split(\"\")\n .map((c) => {\n return \"%\" + (\"00\" + c.charCodeAt(0).toString(16)).slice(-2);\n })\n .join(\"\"));\n return JSON.parse(jsonPayload);\n }\n async loadGoogleScript() {\n if (this.googleScriptLoaded)\n return;\n return new Promise((resolve, reject) => {\n const script = document.createElement(\"script\");\n script.src = \"https://accounts.google.com/gsi/client\";\n script.async = true;\n script.onload = () => {\n this.googleScriptLoaded = true;\n resolve();\n };\n script.onerror = reject;\n document.body.appendChild(script);\n });\n }\n async loginWithApple(options) {\n if (!this.appleClientId) {\n throw new Error(\"Apple Client ID not set. Call initialize() first.\");\n }\n if (!this.appleScriptLoaded) {\n throw new Error(\"Apple Sign-In script not loaded.\");\n }\n return new Promise((resolve, reject) => {\n var _a;\n AppleID.auth.init({\n clientId: this.appleClientId,\n scope: ((_a = options.scopes) === null || _a === void 0 ? void 0 : _a.join(\" \")) || \"name email\",\n redirectURI: options.redirectUrl || window.location.href,\n state: options.state,\n nonce: options.nonce,\n usePopup: true,\n });\n AppleID.auth\n .signIn()\n .then((res) => {\n var _a, _b, _c, _d, _e, _f, _g;\n const result = {\n profile: {\n user: ((_b = (_a = res.user) === null || _a === void 0 ? void 0 : _a.name) === null || _b === void 0 ? void 0 : _b.firstName)\n ? `${res.user.name.firstName} ${res.user.name.lastName}`\n : \"\",\n email: ((_c = res.user) === null || _c === void 0 ? void 0 : _c.email) || null,\n givenName: ((_e = (_d = res.user) === null || _d === void 0 ? void 0 : _d.name) === null || _e === void 0 ? void 0 : _e.firstName) || null,\n familyName: ((_g = (_f = res.user) === null || _f === void 0 ? void 0 : _f.name) === null || _g === void 0 ? void 0 : _g.lastName) || null,\n },\n accessToken: {\n token: res.authorization.code, // TODO: to fix and find the correct token\n },\n idToken: res.authorization.id_token || null,\n };\n resolve({ provider: \"apple\", result });\n })\n .catch((error) => {\n reject(error);\n });\n });\n }\n async loadAppleScript() {\n if (this.appleScriptLoaded)\n return;\n return new Promise((resolve, reject) => {\n const script = document.createElement(\"script\");\n script.src = this.appleScriptUrl;\n script.async = true;\n script.onload = () => {\n this.appleScriptLoaded = true;\n resolve();\n };\n script.onerror = reject;\n document.body.appendChild(script);\n });\n }\n persistStateGoogle(accessToken, idToken) {\n try {\n window.localStorage.setItem(\"capgo_social_login_google_state\", JSON.stringify({ accessToken, idToken }));\n }\n catch (e) {\n console.error(\"Cannot persist state google\", e);\n }\n }\n clearStateGoogle() {\n try {\n window.localStorage.removeItem(\"capgo_social_login_google_state\");\n }\n catch (e) {\n console.error(\"Cannot clear state google\", e);\n }\n }\n getGoogleState() {\n try {\n const state = window.localStorage.getItem(\"capgo_social_login_google_state\");\n if (!state)\n return null;\n const { accessToken, idToken } = JSON.parse(state);\n return { accessToken, idToken };\n }\n catch (e) {\n console.error(\"Cannot get state google\", e);\n return null;\n }\n }\n async loadFacebookScript() {\n if (this.facebookScriptLoaded)\n return;\n return new Promise((resolve, reject) => {\n const script = document.createElement(\"script\");\n script.src = \"https://connect.facebook.net/en_US/sdk.js\";\n script.async = true;\n script.defer = true;\n script.onload = () => {\n this.facebookScriptLoaded = true;\n resolve();\n };\n script.onerror = reject;\n document.body.appendChild(script);\n });\n }\n async loginWithFacebook(options) {\n if (!this.facebookAppId) {\n throw new Error(\"Facebook App ID not set. Call initialize() first.\");\n }\n return new Promise((resolve, reject) => {\n FB.login((response) => {\n if (response.status === \"connected\") {\n FB.api(\"/me\", { fields: \"id,name,email,picture\" }, (userInfo) => {\n var _a, _b;\n const result = {\n accessToken: {\n token: response.authResponse.accessToken,\n userId: response.authResponse.userID,\n },\n profile: {\n userID: userInfo.id,\n name: userInfo.name,\n email: userInfo.email || null,\n imageURL: ((_b = (_a = userInfo.picture) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.url) || null,\n friendIDs: [],\n birthday: null,\n ageRange: null,\n gender: null,\n location: null,\n hometown: null,\n profileURL: null,\n },\n idToken: null,\n };\n resolve({ provider: \"facebook\", result });\n });\n }\n else {\n reject(new Error(\"Facebook login failed\"));\n }\n }, { scope: options.permissions.join(\",\") });\n });\n }\n async fallbackToTraditionalOAuth(scopes) {\n const uniqueScopes = [...new Set([...scopes, \"openid\"])];\n const params = new URLSearchParams({\n client_id: this.googleClientId,\n redirect_uri: window.location.href,\n response_type: this.googleLoginType === \"offline\" ? \"code\" : \"token id_token\",\n scope: uniqueScopes.join(\" \"),\n nonce: Math.random().toString(36).substring(2),\n include_granted_scopes: \"true\",\n state: \"popup\",\n });\n const url = `https://accounts.google.com/o/oauth2/v2/auth?${params.toString()}`;\n const width = 500;\n const height = 600;\n const left = window.screenX + (window.outerWidth - width) / 2;\n const top = window.screenY + (window.outerHeight - height) / 2;\n localStorage.setItem(SocialLoginWeb.OAUTH_STATE_KEY, \"true\");\n const popup = window.open(url, \"Google Sign In\", `width=${width},height=${height},left=${left},top=${top},popup=1`);\n // This may never return...\n return new Promise((resolve, reject) => {\n if (!popup) {\n reject(new Error(\"Failed to open popup\"));\n return;\n }\n const handleMessage = (event) => {\n var _a;\n if (event.origin !== window.location.origin)\n return;\n if (((_a = event.data) === null || _a === void 0 ? void 0 : _a.type) === \"oauth-response\") {\n window.removeEventListener(\"message\", handleMessage);\n if (this.googleLoginType === \"online\") {\n const { accessToken, idToken } = event.data;\n if (accessToken && idToken) {\n const profile = this.parseJwt(idToken);\n this.persistStateGoogle(accessToken.token, idToken);\n resolve({\n provider: \"google\",\n result: {\n accessToken: {\n token: accessToken.token,\n },\n idToken,\n profile: {\n email: profile.email || null,\n familyName: profile.family_name || null,\n givenName: profile.given_name || null,\n id: profile.sub || null,\n name: profile.name || null,\n imageUrl: profile.picture || null,\n },\n responseType: \"online\",\n },\n });\n }\n }\n else {\n const { serverAuthCode } = event.data.result;\n resolve({\n provider: \"google\",\n result: {\n responseType: \"offline\",\n serverAuthCode,\n },\n });\n }\n }\n else {\n reject(new Error(\"Login failed\"));\n }\n };\n window.addEventListener(\"message\", handleMessage);\n // Timeout after 5 minutes\n setTimeout(() => {\n window.removeEventListener(\"message\", handleMessage);\n popup.close();\n reject(new Error(\"OAuth timeout\"));\n }, 300000);\n });\n }\n}\nSocialLoginWeb.OAUTH_STATE_KEY = \"social_login_oauth_pending\";\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;AACK,UAAC,WAAW,GAAGA,mBAAc,CAAC,aAAa,EAAE;IAClD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,cAAc,EAAE,CAAC;IAClE,CAAC;;ICFM,MAAM,cAAc,SAASC,cAAS,CAAC;IAC9C,IAAI,WAAW,GAAG;IAClB,QAAQ,IAAI,EAAE;IACd,QAAQ,KAAK,EAAE;IACf,QAAQ,IAAI,CAAC,cAAc,GAAG,IAAI;IAClC,QAAQ,IAAI,CAAC,aAAa,GAAG,IAAI;IACjC,QAAQ,IAAI,CAAC,kBAAkB,GAAG,KAAK;IACvC,QAAQ,IAAI,CAAC,eAAe,GAAG,QAAQ;IACvC,QAAQ,IAAI,CAAC,iBAAiB,GAAG,KAAK;IACtC,QAAQ,IAAI,CAAC,cAAc,GAAG,sFAAsF;IACpH,QAAQ,IAAI,CAAC,wBAAwB,GAAG,gDAAgD;IACxF,QAAQ,IAAI,CAAC,aAAa,GAAG,IAAI;IACjC,QAAQ,IAAI,CAAC,oBAAoB,GAAG,KAAK;IACzC;IACA,QAAQ,IAAI,YAAY,CAAC,OAAO,CAAC,cAAc,CAAC,eAAe,CAAC,E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AY,UAAU,CAAC,MAAM;IAC7B,gBAAgB,MAAM,CAAC,mBAAmB,CAAC,SAAS,EAAE,aAAa,CAAC;IACpE,gBAAgB,KAAK,CAAC,KAAK,EAAE;IAC7B,gBAAgB,MAAM,CAAC,IAAI,KAAK,CAAC,eAAe,CAAC,CAAC;IAClD,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC;IACV;IACA;IACA,cAAc,CAAC,eAAe,GAAG,4BAA4B;;;;;;;;;;;;;;;"}
@@ -138,14 +138,15 @@ class FacebookProvider {
138
138
  }
139
139
  }
140
140
 
141
- func refresh(viewController: UIViewController?, completion: @escaping (Result<Void, Error>) -> Void) {
141
+ func refresh(viewController: UIViewController?, completion: @escaping (Result<SocialLoginUser, Error>) -> Void) {
142
142
  DispatchQueue.main.async {
143
- if let token = AccessToken.current, !token.isExpired {
144
- completion(.success(()))
143
+ if let token = AccessToken.current, !token.isExpired, !token.isDataAccessExpired {
144
+ // let expiresIn = Int(token.expirationDate.timeIntervalSinceNow)
145
+ completion(.success(SocialLoginUser(accessToken: token.tokenString, idToken: nil, refreshToken: nil, expiresIn: nil)))
145
146
  } else {
146
147
  self.loginManager.reauthorizeDataAccess(from: viewController!) { loginResult, error in
147
- if let _ = loginResult?.token {
148
- completion(.success(()))
148
+ if let token = loginResult?.token {
149
+ completion(.success(SocialLoginUser(accessToken: token.tokenString, idToken: nil, refreshToken: nil, expiresIn: nil)))
149
150
  } else {
150
151
  completion(.failure(error ?? NSError(domain: "FacebookProvider", code: 0, userInfo: [NSLocalizedDescriptionKey: "Reauthorization failed"])))
151
152
  }
@@ -15,7 +15,9 @@ public class SocialLoginPlugin: CAPPlugin, CAPBridgedPlugin {
15
15
  CAPPluginMethod(name: "isLoggedIn", returnType: CAPPluginReturnPromise),
16
16
  CAPPluginMethod(name: "getAuthorizationCode", returnType: CAPPluginReturnPromise),
17
17
  CAPPluginMethod(name: "getUserInfo", returnType: CAPPluginReturnPromise),
18
- CAPPluginMethod(name: "initialize", returnType: CAPPluginReturnPromise)
18
+ CAPPluginMethod(name: "initialize", returnType: CAPPluginReturnPromise),
19
+ CAPPluginMethod(name: "refresh", returnType: CAPPluginReturnPromise)
20
+
19
21
  ]
20
22
  private let apple = AppleProvider()
21
23
  private let facebook = FacebookProvider()
@@ -39,10 +41,10 @@ public class SocialLoginPlugin: CAPPlugin, CAPBridgedPlugin {
39
41
  var mode = GoogleProviderLoginType.ONLINE
40
42
  if let modeStr = modeStr {
41
43
  switch modeStr {
42
- case "online":
43
- mode = GoogleProviderLoginType.ONLINE
44
- case "offline":
45
- mode = GoogleProviderLoginType.OFFLINE
44
+ case "online":
45
+ mode = GoogleProviderLoginType.ONLINE
46
+ case "offline":
47
+ mode = GoogleProviderLoginType.OFFLINE
46
48
  case _:
47
49
  call.reject("google.mode != (online || offline)")
48
50
  return
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/capacitor-social-login",
3
- "version": "0.0.77-alpha.0",
3
+ "version": "0.0.77-alpha.2",
4
4
  "description": "All social logins in one plugin",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",
@@ -57,15 +57,15 @@
57
57
  "@ionic/prettier-config": "^4.0.0",
58
58
  "@ionic/swiftlint-config": "^2.0.0",
59
59
  "@types/google.accounts": "^0.0.15",
60
- "@types/node": "^20.12.12",
60
+ "@types/node": "^22.10.1",
61
61
  "eslint": "^8.57.1",
62
- "eslint-plugin-import": "^2.29.1",
63
- "prettier": "^3.3.3",
62
+ "eslint-plugin-import": "^2.31.0",
63
+ "prettier": "^3.4.2",
64
64
  "prettier-plugin-java": "^2.6.5",
65
65
  "rimraf": "^6.0.1",
66
- "rollup": "^4.27.4",
66
+ "rollup": "^4.28.1",
67
67
  "swiftlint": "^2.0.0",
68
- "typescript": "5.1.6"
68
+ "typescript": "5.7.2"
69
69
  },
70
70
  "peerDependencies": {
71
71
  "@capacitor/core": "^6.0.0"
@@ -83,5 +83,5 @@
83
83
  "src": "android"
84
84
  }
85
85
  },
86
- "packageManager": "pnpm@9.12.2+sha512.22721b3a11f81661ae1ec68ce1a7b879425a1ca5b991c975b074ac220b187ce56c708fe5db69f4c962c989452eee76c82877f4ee80f474cebd61ee13461b6228"
86
+ "packageManager": "pnpm@9.15.0"
87
87
  }