@capgo/capacitor-social-login 8.5.10 → 8.5.12
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/CapgoCapacitorSocialLogin.podspec +0 -1
- package/Package.swift +2 -5
- package/README.md +2 -2
- package/android/src/main/java/ee/forgr/capacitor/social/login/SocialLoginPlugin.java +1 -1
- package/ios/Sources/SocialLoginPlugin/AppleProvider.swift +150 -65
- package/ios/Sources/SocialLoginPlugin/FacebookProvider.swift +12 -7
- package/ios/Sources/SocialLoginPlugin/SocialLoginPlugin.swift +2 -8
- package/package.json +1 -1
- package/scripts/configure-dependencies.js +0 -19
package/Package.swift
CHANGED
|
@@ -14,9 +14,7 @@ let package = Package(
|
|
|
14
14
|
// FBSDKCoreKit and FBSDKLoginKit
|
|
15
15
|
.package(url: "https://github.com/facebook/facebook-ios-sdk.git", .upToNextMajor(from: "18.0.3")),
|
|
16
16
|
// Add Google Sign-In dependency
|
|
17
|
-
.package(url: "https://github.com/google/GoogleSignIn-iOS.git", .upToNextMajor(from: "9.0.0"))
|
|
18
|
-
// Alamofire
|
|
19
|
-
.package(url: "https://github.com/Alamofire/Alamofire.git", .upToNextMajor(from: "5.11.2"))
|
|
17
|
+
.package(url: "https://github.com/google/GoogleSignIn-iOS.git", .upToNextMajor(from: "9.0.0"))
|
|
20
18
|
],
|
|
21
19
|
targets: [
|
|
22
20
|
.target(
|
|
@@ -26,8 +24,7 @@ let package = Package(
|
|
|
26
24
|
.product(name: "Cordova", package: "capacitor-swift-pm"),
|
|
27
25
|
.product(name: "FacebookCore", package: "facebook-ios-sdk"),
|
|
28
26
|
.product(name: "FacebookLogin", package: "facebook-ios-sdk"),
|
|
29
|
-
.product(name: "GoogleSignIn", package: "GoogleSignIn-iOS")
|
|
30
|
-
.product(name: "Alamofire", package: "Alamofire")
|
|
27
|
+
.product(name: "GoogleSignIn", package: "GoogleSignIn-iOS")
|
|
31
28
|
],
|
|
32
29
|
path: "ios/Sources/SocialLoginPlugin"),
|
|
33
30
|
.testTarget(
|
package/README.md
CHANGED
|
@@ -94,7 +94,7 @@ const config: CapacitorConfig = {
|
|
|
94
94
|
providers: {
|
|
95
95
|
google: true, // true = enabled (bundled), false = disabled (not bundled)
|
|
96
96
|
facebook: true, // Use false to reduce app size
|
|
97
|
-
apple: true, // Apple uses system APIs
|
|
97
|
+
apple: true, // Apple uses system APIs only (no third-party networking dependency)
|
|
98
98
|
twitter: false // false = disabled (not bundled)
|
|
99
99
|
},
|
|
100
100
|
logLevel: 1 // Warnings and errors only
|
|
@@ -118,7 +118,7 @@ export default config;
|
|
|
118
118
|
- This configuration only affects iOS and Android platforms; it does not affect the web platform.
|
|
119
119
|
- **Important**: Using `false` means the dependency won't be bundled, but the plugin code still compiles against it. Ensure the consuming app includes the dependency if needed.
|
|
120
120
|
- **Facebook**: When `facebook: false`, the Facebook SDK is omitted and the plugin compiles a provider stub in its own package — no `com.facebook.*` classes are shipped (avoids privacy-scanner false positives).
|
|
121
|
-
- **Apple (iOS)**: `apple: true` enables Sign in with Apple (AuthenticationServices
|
|
121
|
+
- **Apple (iOS)**: `apple: true` enables Sign in with Apple (AuthenticationServices). Redirect URL and backend token exchange use Foundation URLSession, so no third-party networking library is required. `apple: false` disables Apple authentication at runtime, including basic Sign in with Apple, consistent with the rule above that `false` providers are unavailable at runtime.
|
|
122
122
|
- Apple Sign-In on Android uses OAuth flow without external SDK dependencies
|
|
123
123
|
- Twitter uses standard OAuth 2.0 flow without external SDK dependencies
|
|
124
124
|
|
|
@@ -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.12";
|
|
28
28
|
|
|
29
29
|
public static String LOG_TAG = "CapgoSocialLogin";
|
|
30
30
|
public HashMap<String, SocialProvider> socialProviderHashMap = new HashMap<>();
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import Foundation
|
|
2
2
|
import AuthenticationServices
|
|
3
3
|
|
|
4
|
-
#if canImport(Alamofire)
|
|
5
|
-
import Alamofire
|
|
6
|
-
#endif
|
|
7
|
-
|
|
8
4
|
import UIKit
|
|
9
5
|
import Security
|
|
10
6
|
|
|
@@ -60,7 +56,6 @@ enum AppleProviderError: Error {
|
|
|
60
56
|
case missingUserId
|
|
61
57
|
case unknownError
|
|
62
58
|
case invalidIdToken
|
|
63
|
-
case alamofireNotAvailable
|
|
64
59
|
}
|
|
65
60
|
|
|
66
61
|
// Implement LocalizedError for AppleProviderError
|
|
@@ -99,14 +94,56 @@ extension AppleProviderError: LocalizedError {
|
|
|
99
94
|
return NSLocalizedString("User ID not found in ID token.", comment: "")
|
|
100
95
|
case .invalidIdToken:
|
|
101
96
|
return NSLocalizedString("Invalid ID token format.", comment: "")
|
|
102
|
-
case .alamofireNotAvailable:
|
|
103
|
-
return NSLocalizedString("Apple redirectUrl / backend token exchange requires Alamofire. Add Alamofire to your Podfile or Package.swift, or remove redirectUrl to use basic Sign in with Apple.", comment: "")
|
|
104
97
|
}
|
|
105
98
|
}
|
|
106
99
|
}
|
|
107
100
|
|
|
101
|
+
private final class NoRedirectURLSessionDelegate: NSObject, URLSessionTaskDelegate {
|
|
102
|
+
func urlSession(
|
|
103
|
+
_ session: URLSession,
|
|
104
|
+
task: URLSessionTask,
|
|
105
|
+
willPerformHTTPRedirection response: HTTPURLResponse,
|
|
106
|
+
newRequest request: URLRequest,
|
|
107
|
+
completionHandler: @escaping (URLRequest?) -> Void
|
|
108
|
+
) {
|
|
109
|
+
completionHandler(nil)
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
private enum AppleProviderHTTP {
|
|
114
|
+
private static var formAllowedCharacters: CharacterSet {
|
|
115
|
+
var allowed = CharacterSet.alphanumerics
|
|
116
|
+
allowed.insert(charactersIn: "-._* ")
|
|
117
|
+
return allowed
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
static func applicationFormURLEncodedBody(from parameters: [String: String]) -> Data? {
|
|
121
|
+
let pairs = parameters.keys.sorted().compactMap { key -> String? in
|
|
122
|
+
guard let value = parameters[key] else { return nil }
|
|
123
|
+
let encodedKey = key.addingPercentEncoding(withAllowedCharacters: formAllowedCharacters)?.replacingOccurrences(of: " ", with: "+") ?? key
|
|
124
|
+
let encodedValue = value.addingPercentEncoding(withAllowedCharacters: formAllowedCharacters)?.replacingOccurrences(of: " ", with: "+") ?? value
|
|
125
|
+
return "\(encodedKey)=\(encodedValue)"
|
|
126
|
+
}
|
|
127
|
+
return pairs.joined(separator: "&").data(using: .utf8)
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
private static let sharedTokenExchangeSession: URLSession = {
|
|
131
|
+
URLSession(configuration: .default)
|
|
132
|
+
}()
|
|
133
|
+
|
|
134
|
+
static func tokenExchangeSession() -> URLSession {
|
|
135
|
+
sharedTokenExchangeSession
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
static func noRedirectSession() -> (session: URLSession, keeper: NoRedirectURLSessionDelegate) {
|
|
139
|
+
let delegate = NoRedirectURLSessionDelegate()
|
|
140
|
+
let session = URLSession(configuration: .default, delegate: delegate, delegateQueue: nil)
|
|
141
|
+
return (session, delegate)
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
108
145
|
// Basic Sign in with Apple uses AuthenticationServices only.
|
|
109
|
-
//
|
|
146
|
+
// redirectUrl / backend token-exchange flows use URLSession (Foundation).
|
|
110
147
|
class AppleProvider: NSObject, ASAuthorizationControllerDelegate, ASAuthorizationControllerPresentationContextProviding {
|
|
111
148
|
private var completion: ((Result<AppleProviderResponse, Error>) -> Void)?
|
|
112
149
|
|
|
@@ -201,23 +238,30 @@ class AppleProvider: NSObject, ASAuthorizationControllerDelegate, ASAuthorizatio
|
|
|
201
238
|
func login(payload: [String: Any], completion: @escaping (Result<AppleProviderResponse, Error>) -> Void) {
|
|
202
239
|
self.completion = completion
|
|
203
240
|
|
|
204
|
-
|
|
205
|
-
|
|
241
|
+
DispatchQueue.main.async { [weak self] in
|
|
242
|
+
guard let self = self else {
|
|
243
|
+
completion(.failure(NSError(domain: "AppleProvider", code: -1, userInfo: [NSLocalizedDescriptionKey: "AppleProvider was deallocated before login could run."])))
|
|
244
|
+
return
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
let appleIDProvider = ASAuthorizationAppleIDProvider()
|
|
248
|
+
let request = appleIDProvider.createRequest()
|
|
206
249
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
250
|
+
if let scopes = payload["scopes"] as? [ASAuthorization.Scope] {
|
|
251
|
+
request.requestedScopes = scopes
|
|
252
|
+
} else {
|
|
253
|
+
request.requestedScopes = [.fullName, .email]
|
|
254
|
+
}
|
|
212
255
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
256
|
+
if let nonce = payload["nonce"] as? String {
|
|
257
|
+
request.nonce = nonce
|
|
258
|
+
}
|
|
216
259
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
260
|
+
let authorizationController = ASAuthorizationController(authorizationRequests: [request])
|
|
261
|
+
authorizationController.delegate = self
|
|
262
|
+
authorizationController.presentationContextProvider = self
|
|
263
|
+
authorizationController.performRequests()
|
|
264
|
+
}
|
|
221
265
|
}
|
|
222
266
|
|
|
223
267
|
func logout(completion: @escaping (Result<Void, Error>) -> Void) {
|
|
@@ -308,7 +352,6 @@ class AppleProvider: NSObject, ASAuthorizationControllerDelegate, ASAuthorizatio
|
|
|
308
352
|
)
|
|
309
353
|
|
|
310
354
|
if !self.redirectUrl.isEmpty {
|
|
311
|
-
#if canImport(Alamofire)
|
|
312
355
|
let firstName = fullName?.givenName ?? ""
|
|
313
356
|
let lastName = fullName?.familyName ?? ""
|
|
314
357
|
|
|
@@ -320,9 +363,6 @@ class AppleProvider: NSObject, ASAuthorizationControllerDelegate, ASAuthorizatio
|
|
|
320
363
|
self.completion?(.failure(error))
|
|
321
364
|
}
|
|
322
365
|
}, skipUser: fullName?.givenName == nil)
|
|
323
|
-
#else
|
|
324
|
-
self.completion?(.failure(AppleProviderError.alamofireNotAvailable))
|
|
325
|
-
#endif
|
|
326
366
|
} else {
|
|
327
367
|
do {
|
|
328
368
|
try self.persistState(idToken: response.idToken ?? "", refreshToken: "", accessToken: "")
|
|
@@ -335,7 +375,6 @@ class AppleProvider: NSObject, ASAuthorizationControllerDelegate, ASAuthorizatio
|
|
|
335
375
|
}
|
|
336
376
|
|
|
337
377
|
// identityToken is the JWT generated by apple
|
|
338
|
-
#if canImport(Alamofire)
|
|
339
378
|
func sendRequest(
|
|
340
379
|
code: String,
|
|
341
380
|
identityToken: String,
|
|
@@ -369,23 +408,40 @@ class AppleProvider: NSObject, ASAuthorizationControllerDelegate, ASAuthorizatio
|
|
|
369
408
|
parameters["user"] = userJSONString
|
|
370
409
|
}
|
|
371
410
|
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
.
|
|
382
|
-
|
|
383
|
-
|
|
411
|
+
guard let url = URL(string: self.redirectUrl),
|
|
412
|
+
let body = AppleProviderHTTP.applicationFormURLEncodedBody(from: parameters) else {
|
|
413
|
+
DispatchQueue.main.async {
|
|
414
|
+
completion(.failure(.responseError(NSError(domain: "AppleProvider", code: -1, userInfo: [NSLocalizedDescriptionKey: "Invalid redirect URL"]))))
|
|
415
|
+
}
|
|
416
|
+
return
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
var request = URLRequest(url: url)
|
|
420
|
+
request.httpMethod = "POST"
|
|
421
|
+
request.httpBody = body
|
|
422
|
+
request.setValue("application/x-www-form-urlencoded; charset=utf-8", forHTTPHeaderField: "Content-Type")
|
|
423
|
+
request.setValue("0.0.0", forHTTPHeaderField: "ios-plugin-version")
|
|
424
|
+
|
|
425
|
+
let redirectSession = AppleProviderHTTP.noRedirectSession()
|
|
426
|
+
|
|
427
|
+
redirectSession.session.dataTask(with: request) { data, response, error in
|
|
428
|
+
DispatchQueue.main.async {
|
|
429
|
+
if let error = error {
|
|
430
|
+
completion(.failure(.responseError(error)))
|
|
431
|
+
print("Error: \(error)")
|
|
432
|
+
return
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
guard let httpResponse = response as? HTTPURLResponse else {
|
|
436
|
+
completion(.failure(.unknownError))
|
|
437
|
+
return
|
|
438
|
+
}
|
|
439
|
+
|
|
384
440
|
print("Status Code: \(httpResponse.statusCode)")
|
|
385
441
|
|
|
386
442
|
// Check if the response is a redirect
|
|
387
443
|
if (300...399).contains(httpResponse.statusCode) {
|
|
388
|
-
if let location = httpResponse.
|
|
444
|
+
if let location = httpResponse.value(forHTTPHeaderField: "Location") {
|
|
389
445
|
print("Redirect Location: \(location)")
|
|
390
446
|
|
|
391
447
|
// Parse the redirect URL
|
|
@@ -486,7 +542,7 @@ class AppleProvider: NSObject, ASAuthorizationControllerDelegate, ASAuthorizatio
|
|
|
486
542
|
}
|
|
487
543
|
} else {
|
|
488
544
|
// Handle non-redirect responses
|
|
489
|
-
if let data =
|
|
545
|
+
if let data = data,
|
|
490
546
|
let responseString = String(data: data, encoding: .utf8) {
|
|
491
547
|
print("Response: \(responseString)")
|
|
492
548
|
} else {
|
|
@@ -495,11 +551,10 @@ class AppleProvider: NSObject, ASAuthorizationControllerDelegate, ASAuthorizatio
|
|
|
495
551
|
|
|
496
552
|
completion(.failure(.invalidResponseCode(statusCode: httpResponse.statusCode)))
|
|
497
553
|
}
|
|
498
|
-
} else if let error = response.error {
|
|
499
|
-
completion(.failure(.responseError(error)))
|
|
500
|
-
print("Error: \(error)")
|
|
501
554
|
}
|
|
502
|
-
|
|
555
|
+
_ = redirectSession.keeper
|
|
556
|
+
}.resume()
|
|
557
|
+
redirectSession.session.finishTasksAndInvalidate()
|
|
503
558
|
}
|
|
504
559
|
|
|
505
560
|
func exchangeCodeForTokens(clientSecret: String, code: String, completion: @escaping ((Result<AppleProviderResponse, AppleProviderError>) -> Void)) {
|
|
@@ -511,16 +566,50 @@ class AppleProvider: NSObject, ASAuthorizationControllerDelegate, ASAuthorizatio
|
|
|
511
566
|
"grant_type": "authorization_code"
|
|
512
567
|
]
|
|
513
568
|
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
569
|
+
guard let url = URL(string: TOKEN_URL),
|
|
570
|
+
let body = AppleProviderHTTP.applicationFormURLEncodedBody(from: parameters) else {
|
|
571
|
+
DispatchQueue.main.async {
|
|
572
|
+
completion(.failure(.responseError(NSError(domain: "AppleProvider", code: -1, userInfo: [NSLocalizedDescriptionKey: "Invalid token URL"]))))
|
|
573
|
+
}
|
|
574
|
+
return
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
var request = URLRequest(url: url)
|
|
578
|
+
request.httpMethod = "POST"
|
|
579
|
+
request.httpBody = body
|
|
580
|
+
request.setValue("application/x-www-form-urlencoded; charset=utf-8", forHTTPHeaderField: "Content-Type")
|
|
581
|
+
|
|
582
|
+
AppleProviderHTTP.tokenExchangeSession().dataTask(with: request) { data, response, error in
|
|
583
|
+
DispatchQueue.main.async {
|
|
584
|
+
if let error = error {
|
|
585
|
+
completion(.failure(.responseError(error)))
|
|
586
|
+
return
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
guard let httpResponse = response as? HTTPURLResponse else {
|
|
590
|
+
completion(.failure(.unknownError))
|
|
591
|
+
return
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
guard (200..<300).contains(httpResponse.statusCode) else {
|
|
595
|
+
print("error", HTTPURLResponse.localizedString(forStatusCode: httpResponse.statusCode))
|
|
596
|
+
completion(.failure(.invalidResponseCode(statusCode: httpResponse.statusCode)))
|
|
597
|
+
return
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
guard let data = data else {
|
|
601
|
+
completion(.failure(.jsonParsingError))
|
|
602
|
+
return
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
let tokenResponse: TokenResponse
|
|
606
|
+
do {
|
|
607
|
+
tokenResponse = try JSONDecoder().decode(TokenResponse.self, from: data)
|
|
608
|
+
} catch {
|
|
609
|
+
completion(.failure(.jsonParsingError))
|
|
610
|
+
return
|
|
611
|
+
}
|
|
612
|
+
|
|
524
613
|
// Extract tokens from the response
|
|
525
614
|
guard let accessToken = tokenResponse.access_token else {
|
|
526
615
|
completion(.failure(.missingAccessToken))
|
|
@@ -589,17 +678,9 @@ class AppleProvider: NSObject, ASAuthorizationControllerDelegate, ASAuthorizatio
|
|
|
589
678
|
} else {
|
|
590
679
|
completion(.failure(.invalidIdToken))
|
|
591
680
|
}
|
|
592
|
-
case .failure(let error):
|
|
593
|
-
if let statusCode = response.response?.statusCode {
|
|
594
|
-
print("error", response.debugDescription)
|
|
595
|
-
completion(.failure(.invalidResponseCode(statusCode: statusCode)))
|
|
596
|
-
} else {
|
|
597
|
-
completion(.failure(.responseError(error)))
|
|
598
|
-
}
|
|
599
681
|
}
|
|
600
|
-
}
|
|
682
|
+
}.resume()
|
|
601
683
|
}
|
|
602
|
-
#endif
|
|
603
684
|
|
|
604
685
|
func authorizationController(controller: ASAuthorizationController, didCompleteWithError error: Error) {
|
|
605
686
|
completion?(.failure(error))
|
|
@@ -608,7 +689,11 @@ class AppleProvider: NSObject, ASAuthorizationControllerDelegate, ASAuthorizatio
|
|
|
608
689
|
// MARK: - ASAuthorizationControllerPresentationContextProviding
|
|
609
690
|
|
|
610
691
|
func presentationAnchor(for controller: ASAuthorizationController) -> ASPresentationAnchor {
|
|
611
|
-
|
|
692
|
+
let windows = UIApplication.shared.connectedScenes
|
|
693
|
+
.compactMap { $0 as? UIWindowScene }
|
|
694
|
+
.filter { $0.activationState == .foregroundActive || $0.activationState == .foregroundInactive }
|
|
695
|
+
.flatMap { $0.windows }
|
|
696
|
+
return windows.first { $0.isKeyWindow } ?? windows.first ?? UIApplication.shared.windows.first ?? ASPresentationAnchor()
|
|
612
697
|
}
|
|
613
698
|
|
|
614
699
|
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.12"
|
|
20
20
|
public let identifier = "SocialLoginPlugin"
|
|
21
21
|
public let jsName = "SocialLogin"
|
|
22
22
|
private static let userCancelledCode = "USER_CANCELLED"
|
|
@@ -44,7 +44,7 @@ public class SocialLoginPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
44
44
|
]
|
|
45
45
|
|
|
46
46
|
// Providers - conditionally initialized based on available dependencies
|
|
47
|
-
// Apple uses AuthenticationServices;
|
|
47
|
+
// Apple uses AuthenticationServices; redirectUrl flows use URLSession (Foundation)
|
|
48
48
|
private let apple = AppleProvider()
|
|
49
49
|
|
|
50
50
|
#if canImport(FBSDKLoginKit)
|
|
@@ -193,12 +193,6 @@ public class SocialLoginPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
193
193
|
}
|
|
194
194
|
let redirectUrl = appleSettings["redirectUrl"] as? String
|
|
195
195
|
let useProperTokenExchange = appleSettings["useProperTokenExchange"] as? Bool ?? false
|
|
196
|
-
#if !canImport(Alamofire)
|
|
197
|
-
if let redirectUrl = redirectUrl, !redirectUrl.isEmpty {
|
|
198
|
-
call.reject("Apple redirectUrl requires Alamofire. Add Alamofire to your Podfile or Package.swift, or omit redirectUrl for basic Sign in with Apple.")
|
|
199
|
-
return
|
|
200
|
-
}
|
|
201
|
-
#endif
|
|
202
196
|
apple.initialize(redirectUrl: redirectUrl, useProperTokenExchange: useProperTokenExchange)
|
|
203
197
|
initialized = true
|
|
204
198
|
}
|
package/package.json
CHANGED
|
@@ -289,13 +289,6 @@ function getPodspecReplacements(providerConfig) {
|
|
|
289
289
|
? `s.dependency 'FBSDKLoginKit', '~> 18.0'`
|
|
290
290
|
: `# s.dependency 'FBSDKLoginKit', '~> 18.0' # Disabled via config (compileOnly)`,
|
|
291
291
|
},
|
|
292
|
-
{
|
|
293
|
-
// Alamofire (for Apple) - handle both active and commented (including existing disabled comments)
|
|
294
|
-
old: new RegExp(`(#[ \\t]*)?s\\.dependency\\s+'Alamofire',\\s*'~>\\s*5\\.10\\.2'${podspecTrailingComment}`),
|
|
295
|
-
new: providerConfig.apple === 'implementation'
|
|
296
|
-
? `s.dependency 'Alamofire', '~> 5.10.2'`
|
|
297
|
-
: `# s.dependency 'Alamofire', '~> 5.10.2' # Disabled via config (compileOnly)`,
|
|
298
|
-
},
|
|
299
292
|
];
|
|
300
293
|
}
|
|
301
294
|
function getPackageSwiftReplacements(providerConfig) {
|
|
@@ -314,12 +307,6 @@ function getPackageSwiftReplacements(providerConfig) {
|
|
|
314
307
|
? `.package(url: "https://github.com/google/GoogleSignIn-iOS.git", .upToNextMajor(from: "9.0.0")),`
|
|
315
308
|
: `// .package(url: "https://github.com/google/GoogleSignIn-iOS.git", .upToNextMajor(from: "9.0.0")), // Disabled via config (compileOnly)`,
|
|
316
309
|
},
|
|
317
|
-
{
|
|
318
|
-
old: new RegExp(`${swiftCommentPrefix}\\.package\\(url:\\s*"https:\\/\\/github\\.com\\/Alamofire\\/Alamofire\\.git",\\s*\\.upToNextMajor\\(from:\\s*"[^"]+"\\)\\)${swiftTrailingComment}`),
|
|
319
|
-
new: providerConfig.apple === 'implementation'
|
|
320
|
-
? `.package(url: "https://github.com/Alamofire/Alamofire.git", .upToNextMajor(from: "5.11.2"))`
|
|
321
|
-
: `// .package(url: "https://github.com/Alamofire/Alamofire.git", .upToNextMajor(from: "5.11.2")) // Disabled via config (compileOnly)`,
|
|
322
|
-
},
|
|
323
310
|
{
|
|
324
311
|
old: new RegExp(`${swiftCommentPrefix}\\.product\\(name:\\s*"FacebookCore",\\s*package:\\s*"facebook-ios-sdk"\\),${swiftTrailingComment}`),
|
|
325
312
|
new: providerConfig.facebook === 'implementation'
|
|
@@ -338,12 +325,6 @@ function getPackageSwiftReplacements(providerConfig) {
|
|
|
338
325
|
? `.product(name: "GoogleSignIn", package: "GoogleSignIn-iOS"),`
|
|
339
326
|
: `// .product(name: "GoogleSignIn", package: "GoogleSignIn-iOS"), // Disabled via config (compileOnly)`,
|
|
340
327
|
},
|
|
341
|
-
{
|
|
342
|
-
old: new RegExp(`${swiftCommentPrefix}\\.product\\(name:\\s*"Alamofire",\\s*package:\\s*"Alamofire"\\)${swiftTrailingComment}`),
|
|
343
|
-
new: providerConfig.apple === 'implementation'
|
|
344
|
-
? `.product(name: "Alamofire", package: "Alamofire")`
|
|
345
|
-
: `// .product(name: "Alamofire", package: "Alamofire") // Disabled via config (compileOnly)`,
|
|
346
|
-
},
|
|
347
328
|
];
|
|
348
329
|
}
|
|
349
330
|
/**
|