@superfan-app/spotify-auth 0.1.80 → 0.1.82

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.
@@ -492,26 +492,40 @@ final class SpotifyAuthAuth: NSObject, SPTSessionManagerDelegate {
492
492
  // URLComponents.percentEncodedQuery properly encodes the values
493
493
  request.httpBody = components.percentEncodedQuery?.data(using: .utf8)
494
494
 
495
+ print("[SpotifyDebug] exchangeCodeForToken: sending request to \(url)")
495
496
  let task = URLSession.shared.dataTask(with: request) { [weak self] data, response, error in
497
+ print("[SpotifyDebug] exchangeCodeForToken: dataTask callback fired, self=\(self != nil), error=\(String(describing: error))")
498
+ if let http = response as? HTTPURLResponse {
499
+ print("[SpotifyDebug] exchangeCodeForToken: HTTP status \(http.statusCode)")
500
+ }
501
+ if let data = data, let body = String(data: data, encoding: .utf8) {
502
+ print("[SpotifyDebug] exchangeCodeForToken: response body = \(body)")
503
+ }
496
504
  do {
497
505
  let responseData = try self?.validateHTTPResponse(data: data, response: response, error: error)
498
- guard let responseData = responseData else { return }
506
+ guard let responseData = responseData else {
507
+ print("[SpotifyDebug] exchangeCodeForToken: responseData is nil (self may be nil)")
508
+ return
509
+ }
499
510
  let parsed = try Self.parseTokenJSON(from: responseData)
500
-
511
+ print("[SpotifyDebug] exchangeCodeForToken: parsed token OK, hasRefreshToken=\(parsed.refreshToken != nil)")
512
+
501
513
  guard let refreshToken = parsed.refreshToken else {
502
514
  throw SpotifyAuthError.tokenError("Missing refresh_token in response")
503
515
  }
504
-
516
+
505
517
  let expirationDate = Date(timeIntervalSinceNow: parsed.expiresIn)
506
518
  let sessionData = SpotifySessionData(accessToken: parsed.accessToken, refreshToken: refreshToken, expirationDate: expirationDate, scope: parsed.scope)
507
519
  DispatchQueue.main.async {
520
+ print("[SpotifyDebug] exchangeCodeForToken: setting currentSession on main thread")
508
521
  self?.currentSession = sessionData
509
522
  }
510
523
  } catch {
524
+ print("[SpotifyDebug] exchangeCodeForToken: caught error: \(error)")
511
525
  self?.handleError(error, context: "token_exchange")
512
526
  }
513
527
  }
514
-
528
+
515
529
  task.resume()
516
530
  }
517
531
 
@@ -79,7 +79,9 @@ public class SpotifyAuthModule: Module {
79
79
 
80
80
  // Update the dismissal function
81
81
  AsyncFunction("dismissAuthSession") {
82
- self.spotifyAuth.cancelWebAuth()
82
+ DispatchQueue.main.async {
83
+ self.spotifyAuth.cancelWebAuth()
84
+ }
83
85
  }
84
86
  }
85
87
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superfan-app/spotify-auth",
3
- "version": "0.1.80",
3
+ "version": "0.1.82",
4
4
  "description": "Spotify OAuth module for Expo",
5
5
  "main": "src/index.tsx",
6
6
  "types": "build/index.d.ts",