@capgo/capacitor-social-login 8.2.21 → 8.2.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +74 -0
- package/android/build.gradle +2 -1
- package/android/src/main/java/ee/forgr/capacitor/social/login/SocialLoginPlugin.java +93 -1
- package/dist/docs.json +70 -0
- package/dist/esm/definitions.d.ts +66 -0
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/web.d.ts +2 -1
- package/dist/esm/web.js +33 -0
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +33 -0
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +33 -0
- package/dist/plugin.js.map +1 -1
- package/ios/Sources/SocialLoginPlugin/SocialLoginPlugin.swift +64 -2
- package/package.json +3 -2
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import Foundation
|
|
2
2
|
import Capacitor
|
|
3
|
+
import AuthenticationServices
|
|
3
4
|
|
|
4
5
|
#if canImport(FBSDKLoginKit)
|
|
5
6
|
import FBSDKLoginKit
|
|
@@ -15,7 +16,7 @@ import GoogleSignIn
|
|
|
15
16
|
*/
|
|
16
17
|
@objc(SocialLoginPlugin)
|
|
17
18
|
public class SocialLoginPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
18
|
-
private let pluginVersion: String = "8.2.
|
|
19
|
+
private let pluginVersion: String = "8.2.23"
|
|
19
20
|
public let identifier = "SocialLoginPlugin"
|
|
20
21
|
public let jsName = "SocialLogin"
|
|
21
22
|
public let pluginMethods: [CAPPluginMethod] = [
|
|
@@ -27,7 +28,8 @@ public class SocialLoginPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
27
28
|
CAPPluginMethod(name: "initialize", returnType: CAPPluginReturnPromise),
|
|
28
29
|
CAPPluginMethod(name: "refresh", returnType: CAPPluginReturnPromise),
|
|
29
30
|
CAPPluginMethod(name: "providerSpecificCall", returnType: CAPPluginReturnPromise),
|
|
30
|
-
CAPPluginMethod(name: "getPluginVersion", returnType: CAPPluginReturnPromise)
|
|
31
|
+
CAPPluginMethod(name: "getPluginVersion", returnType: CAPPluginReturnPromise),
|
|
32
|
+
CAPPluginMethod(name: "openSecureWindow", returnType: CAPPluginReturnPromise)
|
|
31
33
|
]
|
|
32
34
|
|
|
33
35
|
// Providers - conditionally initialized based on available dependencies
|
|
@@ -51,6 +53,7 @@ public class SocialLoginPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
51
53
|
|
|
52
54
|
private let twitter = TwitterProvider()
|
|
53
55
|
private let oauth2 = OAuth2Provider()
|
|
56
|
+
private var openSecureWindowCall: CAPPluginCall?
|
|
54
57
|
|
|
55
58
|
// Helper to get Facebook provider (returns nil if unavailable)
|
|
56
59
|
private var facebookProvider: FacebookProvider? {
|
|
@@ -610,6 +613,59 @@ public class SocialLoginPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
610
613
|
}
|
|
611
614
|
}
|
|
612
615
|
|
|
616
|
+
@objc func openSecureWindow(_ call: CAPPluginCall) {
|
|
617
|
+
guard let urlString = call.getString("authEndpoint") else {
|
|
618
|
+
call.reject("authEndpoint is required")
|
|
619
|
+
return
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
guard let url = URL(string: urlString) else {
|
|
623
|
+
call.reject("Invalid URL")
|
|
624
|
+
return
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
guard let redirectUri = call.getString("redirectUri") else {
|
|
628
|
+
call.reject("Redirect URI is required")
|
|
629
|
+
return
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
// Store the call for later resolution
|
|
633
|
+
self.openSecureWindowCall = call
|
|
634
|
+
|
|
635
|
+
// Open the URL in a secure browser window
|
|
636
|
+
DispatchQueue.main.async {
|
|
637
|
+
let session = ASWebAuthenticationSession(url: url, callbackURLScheme: url.scheme) {
|
|
638
|
+
callbackURL, error in
|
|
639
|
+
|
|
640
|
+
// Clean up the stored call
|
|
641
|
+
self.openSecureWindowCall = nil
|
|
642
|
+
|
|
643
|
+
if let error = error {
|
|
644
|
+
// Handle error (e.g., user cancelled)
|
|
645
|
+
call.reject(error.localizedDescription)
|
|
646
|
+
return
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
guard let callbackURL = callbackURL else {
|
|
650
|
+
call.reject("No callback URL received")
|
|
651
|
+
return
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
if !callbackURL.absoluteString.hasPrefix(redirectUri) {
|
|
655
|
+
call.reject("Redirect URI does not match, expected " + redirectUri + " but got " + callbackURL.absoluteString)
|
|
656
|
+
return
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
// Resolve the call with the callback URL
|
|
660
|
+
call.resolve(["redirectedUri": callbackURL.absoluteString])
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
// Present the session
|
|
664
|
+
session.presentationContextProvider = self
|
|
665
|
+
session.start()
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
|
|
613
669
|
private func handleLogoutResult<T>(_ result: Result<T, Error>, call: CAPPluginCall) {
|
|
614
670
|
switch result {
|
|
615
671
|
case .success:
|
|
@@ -802,6 +858,12 @@ public class SocialLoginPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
802
858
|
}
|
|
803
859
|
}
|
|
804
860
|
|
|
861
|
+
extension SocialLoginPlugin: ASWebAuthenticationPresentationContextProviding {
|
|
862
|
+
public func presentationAnchor(for session: ASWebAuthenticationSession) -> ASPresentationAnchor {
|
|
863
|
+
return self.bridge?.viewController?.view.window ?? ASPresentationAnchor()
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
|
|
805
867
|
struct SocialLoginUser {
|
|
806
868
|
let accessToken: String
|
|
807
869
|
let idToken: String?
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capgo/capacitor-social-login",
|
|
3
|
-
"version": "8.2.
|
|
3
|
+
"version": "8.2.23",
|
|
4
4
|
"description": "All social logins in one plugin",
|
|
5
5
|
"main": "dist/plugin.cjs.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -58,7 +58,8 @@
|
|
|
58
58
|
"build:scripts": "tsc -p scripts/tsconfig.json",
|
|
59
59
|
"clean": "rimraf ./dist",
|
|
60
60
|
"watch": "tsc --watch",
|
|
61
|
-
"prepublishOnly": "npm run build"
|
|
61
|
+
"prepublishOnly": "npm run build",
|
|
62
|
+
"check:wiring": "node scripts/check-capacitor-plugin-wiring.mjs"
|
|
62
63
|
},
|
|
63
64
|
"devDependencies": {
|
|
64
65
|
"@capacitor/android": "^8.0.0",
|