Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,8 @@ extension Legendary {
let clientID: String
/// Client service name (e.g., "launcher")
let clientService: String
/// Unique device identifier
let deviceID: String
/// Unique device identifier (no longer included in newer Epic tokens)
let deviceID: String?
/// User's display name
let displayName: String
/// Access token expiration timestamp (ISO 8601 format)
Expand Down Expand Up @@ -330,7 +330,7 @@ extension Legendary {

clientID = try container.decode(String.self, forKey: .clientID)
clientService = try container.decode(String.self, forKey: .clientService)
deviceID = try container.decode(String.self, forKey: .deviceID)
deviceID = try container.decodeIfPresent(String.self, forKey: .deviceID)
displayName = try container.decode(String.self, forKey: .displayName)

let expiresAtString = try container.decode(String.self, forKey: .expiresAt)
Expand Down Expand Up @@ -371,7 +371,7 @@ extension Legendary {
try container.encode(dateFormatter.string(from: authTime), forKey: .authTime)
try container.encode(clientID, forKey: .clientID)
try container.encode(clientService, forKey: .clientService)
try container.encode(deviceID, forKey: .deviceID)
try container.encodeIfPresent(deviceID, forKey: .deviceID)
try container.encode(displayName, forKey: .displayName)
try container.encode(dateFormatter.string(from: expiresAt), forKey: .expiresAt)
try container.encode(expiresIn, forKey: .expiresIn)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,8 @@ final class Legendary {
return String(username)
}

// surface legendary's own error (e.g. rejected/expired code) instead of a generic failure
try handleCLIErrorOutput(fromStandardErrorOutput: result.standardError ?? .init())
throw SignInError()
}

Expand Down
8 changes: 7 additions & 1 deletion Mythic/Views/Unified/Windows/EpicWebAuthView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,17 @@ private struct EpicInterceptorWebView: NSViewRepresentable {
return
}

// WebKit may wrap JSON responses in its own viewer, so isolate the JSON object itself
guard
let content = result as? String,
let data = content.data(using: .utf8),
let start = content.firstIndex(of: "{"),
let end = content.lastIndex(of: "}"),
let data = String(content[start...end]).data(using: .utf8),
let json = try? JSON(data: data)
else {
if let content = result as? String, content.contains("authorizationCode") {
Logger.app.error("Epic sign-in page returned an authorization code, but it couldn't be parsed.")
}
return
}

Expand Down