@capgo/capacitor-social-login 8.7.7 → 8.7.9

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 CHANGED
@@ -16,6 +16,18 @@ Add Google, Apple, Facebook and other social sign-ins to your Capacitor app with
16
16
  <img src="https://raw.githubusercontent.com/Cap-go/capacitor-social-login/main/assets/github-social-preview.png" alt="@capgo/capacitor-social-login for Capacitor apps" width="300" />
17
17
  </p>
18
18
 
19
+ ## Built and maintained with AI
20
+
21
+ We build, improve and fix our plugins with heavy use of AI, so issues usually get fixed in under a day and pull requests get feedback the same day. A human still reviews and merges 50+ pull requests daily.
22
+
23
+ - Most plugin issues get a fix pull request the same day, often within a couple of hours, and are usually resolved in one to two days.
24
+ - Every pull request goes through our AI review system, usually within minutes.
25
+ - Our AI pre-checks tests, code review, conventions and security, then a human validates and merges.
26
+ - A human, Martin, reviews and merges 50+ pull requests every day.
27
+ - In the last 90 days, 95% of plugin issues were resolved.
28
+
29
+ [Learn more about how we build with AI](https://capgo.app/docs/plugins/ai-engineering/)
30
+
19
31
  ## Key features
20
32
 
21
33
  - **Many providers**: Google, Apple, Facebook, Twitter (X), LinkedIn, TikTok, Telegram and generic OAuth2.
@@ -29,7 +29,7 @@ import org.json.JSONTokener;
29
29
  @CapacitorPlugin(name = "SocialLogin")
30
30
  public class SocialLoginPlugin extends Plugin {
31
31
 
32
- private final String pluginVersion = "8.7.7";
32
+ private final String pluginVersion = "8.7.9";
33
33
 
34
34
  public static String LOG_TAG = "CapgoSocialLogin";
35
35
  private static final String USER_CANCELLED_CODE = "USER_CANCELLED";
@@ -383,7 +383,59 @@ class OAuth2Provider: NSObject {
383
383
  return
384
384
  }
385
385
 
386
- completion(.failure(NSError(domain: "OAuth2Provider", code: -8, userInfo: [NSLocalizedDescriptionKey: "No authorization code or access token in callback."])))
386
+ let description = missingAuthorizationCodeDescription(callbackURL: callbackURL, redirectUri: redirectUri)
387
+ completion(.failure(NSError(domain: "OAuth2Provider", code: -8, userInfo: [NSLocalizedDescriptionKey: description])))
388
+ }
389
+
390
+ private func missingAuthorizationCodeDescription(callbackURL: URL, redirectUri: String) -> String {
391
+ let base = "No authorization code or access token in callback."
392
+ guard !callbackMatchesRedirect(callbackURL, redirectUri: redirectUri) else {
393
+ return base
394
+ }
395
+ return "\(base) Received \(callbackOrigin(callbackURL))."
396
+ }
397
+
398
+ private func callbackMatchesRedirect(_ callbackURL: URL, redirectUri: String) -> Bool {
399
+ guard let expected = URL(string: redirectUri),
400
+ let expectedScheme = expected.scheme,
401
+ let actualScheme = callbackURL.scheme else {
402
+ return true
403
+ }
404
+ if expectedScheme.caseInsensitiveCompare(actualScheme) != .orderedSame {
405
+ return false
406
+ }
407
+ let expectedHost = expected.host ?? ""
408
+ let actualHost = callbackURL.host ?? ""
409
+ if expectedHost.caseInsensitiveCompare(actualHost) != .orderedSame {
410
+ return false
411
+ }
412
+ return callbackPath(expected) == callbackPath(callbackURL)
413
+ }
414
+
415
+ private func callbackOrigin(_ url: URL) -> String {
416
+ var origin = ""
417
+ if let scheme = url.scheme {
418
+ origin += "\(scheme):"
419
+ if url.host != nil {
420
+ origin += "//"
421
+ }
422
+ }
423
+ if let host = url.host {
424
+ origin += host
425
+ }
426
+ let path = callbackPath(url)
427
+ if !path.isEmpty {
428
+ if url.host != nil && !path.hasPrefix("/") {
429
+ origin += "/\(path)"
430
+ } else {
431
+ origin += path
432
+ }
433
+ }
434
+ return origin
435
+ }
436
+
437
+ private func callbackPath(_ url: URL) -> String {
438
+ URLComponents(url: url, resolvingAgainstBaseURL: false)?.percentEncodedPath ?? url.path
387
439
  }
388
440
 
389
441
  func logout(providerId: String, completion: @escaping (Result<Void, Error>) -> Void) {
@@ -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.7"
19
+ private let pluginVersion: String = "8.7.9"
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.7",
3
+ "version": "8.7.9",
4
4
  "description": "All social logins in one plugin",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",