@capgo/capacitor-social-login 8.5.10 → 8.5.11
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/android/src/main/java/ee/forgr/capacitor/social/login/SocialLoginPlugin.java +1 -1
- package/ios/Sources/SocialLoginPlugin/AppleProvider.swift +26 -15
- package/ios/Sources/SocialLoginPlugin/FacebookProvider.swift +12 -7
- package/ios/Sources/SocialLoginPlugin/SocialLoginPlugin.swift +1 -1
- package/package.json +1 -1
|
@@ -24,7 +24,7 @@ import org.json.JSONObject;
|
|
|
24
24
|
@CapacitorPlugin(name = "SocialLogin")
|
|
25
25
|
public class SocialLoginPlugin extends Plugin {
|
|
26
26
|
|
|
27
|
-
private final String pluginVersion = "8.5.
|
|
27
|
+
private final String pluginVersion = "8.5.11";
|
|
28
28
|
|
|
29
29
|
public static String LOG_TAG = "CapgoSocialLogin";
|
|
30
30
|
public HashMap<String, SocialProvider> socialProviderHashMap = new HashMap<>();
|
|
@@ -201,23 +201,30 @@ class AppleProvider: NSObject, ASAuthorizationControllerDelegate, ASAuthorizatio
|
|
|
201
201
|
func login(payload: [String: Any], completion: @escaping (Result<AppleProviderResponse, Error>) -> Void) {
|
|
202
202
|
self.completion = completion
|
|
203
203
|
|
|
204
|
-
|
|
205
|
-
|
|
204
|
+
DispatchQueue.main.async { [weak self] in
|
|
205
|
+
guard let self = self else {
|
|
206
|
+
completion(.failure(NSError(domain: "AppleProvider", code: -1, userInfo: [NSLocalizedDescriptionKey: "AppleProvider was deallocated before login could run."])))
|
|
207
|
+
return
|
|
208
|
+
}
|
|
206
209
|
|
|
207
|
-
|
|
208
|
-
request
|
|
209
|
-
} else {
|
|
210
|
-
request.requestedScopes = [.fullName, .email]
|
|
211
|
-
}
|
|
210
|
+
let appleIDProvider = ASAuthorizationAppleIDProvider()
|
|
211
|
+
let request = appleIDProvider.createRequest()
|
|
212
212
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
213
|
+
if let scopes = payload["scopes"] as? [ASAuthorization.Scope] {
|
|
214
|
+
request.requestedScopes = scopes
|
|
215
|
+
} else {
|
|
216
|
+
request.requestedScopes = [.fullName, .email]
|
|
217
|
+
}
|
|
216
218
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
219
|
+
if let nonce = payload["nonce"] as? String {
|
|
220
|
+
request.nonce = nonce
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
let authorizationController = ASAuthorizationController(authorizationRequests: [request])
|
|
224
|
+
authorizationController.delegate = self
|
|
225
|
+
authorizationController.presentationContextProvider = self
|
|
226
|
+
authorizationController.performRequests()
|
|
227
|
+
}
|
|
221
228
|
}
|
|
222
229
|
|
|
223
230
|
func logout(completion: @escaping (Result<Void, Error>) -> Void) {
|
|
@@ -608,7 +615,11 @@ class AppleProvider: NSObject, ASAuthorizationControllerDelegate, ASAuthorizatio
|
|
|
608
615
|
// MARK: - ASAuthorizationControllerPresentationContextProviding
|
|
609
616
|
|
|
610
617
|
func presentationAnchor(for controller: ASAuthorizationController) -> ASPresentationAnchor {
|
|
611
|
-
|
|
618
|
+
let windows = UIApplication.shared.connectedScenes
|
|
619
|
+
.compactMap { $0 as? UIWindowScene }
|
|
620
|
+
.filter { $0.activationState == .foregroundActive || $0.activationState == .foregroundInactive }
|
|
621
|
+
.flatMap { $0.windows }
|
|
622
|
+
return windows.first { $0.isKeyWindow } ?? windows.first ?? UIApplication.shared.windows.first ?? ASPresentationAnchor()
|
|
612
623
|
}
|
|
613
624
|
|
|
614
625
|
private func persistName(userId: String, givenName: String?, familyName: String?) {
|
|
@@ -99,10 +99,12 @@ class FacebookProvider {
|
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
private func isLimitedLoginSession() -> Bool {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
102
|
+
// A classic (.enabled) login also yields an AuthenticationToken: FBSDK always inserts
|
|
103
|
+
// `openid` into the requested permissions and asks for an id_token in response_type,
|
|
104
|
+
// so the presence of that token says nothing about the tracking mode.
|
|
105
|
+
// Only the absence of a Graph access token identifies a Limited Login session -
|
|
106
|
+
// including when Facebook forces limited because ATT was not granted.
|
|
107
|
+
return AccessToken.current == nil
|
|
106
108
|
}
|
|
107
109
|
|
|
108
110
|
private func createLoginResponse() -> FacebookLoginResponse {
|
|
@@ -218,10 +220,13 @@ class FacebookProvider {
|
|
|
218
220
|
}
|
|
219
221
|
|
|
220
222
|
func getAuthorizationCode(completion: @escaping (Result<(accessToken: String?, jwt: String?), Error>) -> Void) {
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
223
|
+
// Prefer the Graph access token: a classic login populates both tokens, and callers
|
|
224
|
+
// asking for an authorization code need the Graph one. Falling through to the OIDC
|
|
225
|
+
// token first hands out a JWT that cannot read pages or mint page tokens.
|
|
226
|
+
if let accessToken = AccessToken.current, !accessToken.isExpired {
|
|
224
227
|
completion(.success((accessToken: accessToken.tokenString, jwt: nil)))
|
|
228
|
+
} else if let authToken = AuthenticationToken.current, !authToken.tokenString.isEmpty {
|
|
229
|
+
completion(.success((accessToken: nil, jwt: authToken.tokenString)))
|
|
225
230
|
} else {
|
|
226
231
|
completion(.failure(NSError(domain: "FacebookProvider", code: 0, userInfo: [NSLocalizedDescriptionKey: "No Facebook authorization code available"])))
|
|
227
232
|
}
|
|
@@ -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.5.
|
|
19
|
+
private let pluginVersion: String = "8.5.11"
|
|
20
20
|
public let identifier = "SocialLoginPlugin"
|
|
21
21
|
public let jsName = "SocialLogin"
|
|
22
22
|
private static let userCancelledCode = "USER_CANCELLED"
|