@capgo/capacitor-social-login 8.7.0 → 8.7.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.
@@ -40,6 +40,9 @@ class GoogleProvider {
40
40
  self.forceAuthCode = false
41
41
  }
42
42
 
43
+ // Extract nonce from payload if provided
44
+ let nonce = payload["nonce"] as? String
45
+
43
46
  func login() {
44
47
  guard let presentingVc = PresentationWindowResolver
45
48
  .window(hostViewController: self.hostViewController)?.rootViewController else {
@@ -53,9 +56,6 @@ class GoogleProvider {
53
56
  scopes = Array(Set(scopes + ["offline_access"]))
54
57
  }
55
58
 
56
- // Extract nonce from payload if provided
57
- let nonce = payload["nonce"] as? String
58
-
59
59
  GIDSignIn.sharedInstance.signIn(
60
60
  withPresenting: presentingVc,
61
61
  hint: nil,
@@ -82,7 +82,9 @@ class GoogleProvider {
82
82
  }
83
83
  }
84
84
 
85
- if GIDSignIn.sharedInstance.hasPreviousSignIn() && !self.forceAuthCode && self.mode != .OFFLINE {
85
+ // A restored sign-in returns an ID token minted without this call's nonce, which a
86
+ // backend that checks the nonce rejects. So a login with a nonce always signs in.
87
+ if GIDSignIn.sharedInstance.hasPreviousSignIn() && !self.forceAuthCode && self.mode != .OFFLINE && nonce == nil {
86
88
  GIDSignIn.sharedInstance.restorePreviousSignIn { user, error in
87
89
  if error != nil {
88
90
  // Retry interactive login when restoring the previous session fails.
@@ -16,7 +16,7 @@ import GoogleSignIn
16
16
  */
17
17
  @objc(SocialLoginPlugin)
18
18
  public class SocialLoginPlugin: CAPPlugin, CAPBridgedPlugin {
19
- private let pluginVersion: String = "8.7.0"
19
+ private let pluginVersion: String = "8.7.2"
20
20
  public let identifier = "SocialLoginPlugin"
21
21
  public let jsName = "SocialLogin"
22
22
  private static let userCancelledCode = "USER_CANCELLED"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/capacitor-social-login",
3
- "version": "8.7.0",
3
+ "version": "8.7.2",
4
4
  "description": "All social logins in one plugin",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",