Skip to content

Commit

Permalink
Merge tag '219.0.0-1'
Browse files Browse the repository at this point in the history
  • Loading branch information
miasma13 committed Dec 12, 2024
2 parents e8654e1 + 155b47e commit d683458
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions Sources/PrivacyDashboard/PrivacyDashboardUserScript.swift
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@ final class PrivacyDashboardUserScript: NSObject, StaticUserScript {
{"id": "jsPerformance"},
{"id": "openerContext"},
{"id": "userRefreshCount"},
{"id": "locale"},
]
}
window.onGetToggleReportOptionsResponse(json);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import os.log
public enum AppStoreAccountManagementFlowError: Swift.Error {
case noPastTransaction
case authenticatingWithTransactionFailed
case missingAuthTokenOnRefresh
}

@available(macOS 12.0, iOS 15.0, *)
Expand All @@ -46,7 +47,8 @@ public final class DefaultAppStoreAccountManagementFlow: AppStoreAccountManageme
@discardableResult
public func refreshAuthTokenIfNeeded() async -> Result<String, AppStoreAccountManagementFlowError> {
Logger.subscription.info("[AppStoreAccountManagementFlow] refreshAuthTokenIfNeeded")
var authToken = accountManager.authToken ?? ""

guard let authToken = accountManager.authToken else { return .failure(.missingAuthTokenOnRefresh) }

// Check if auth token if still valid
if case let .failure(validateTokenError) = await authEndpointService.validateToken(accessToken: authToken) {
Expand All @@ -58,8 +60,9 @@ public final class DefaultAppStoreAccountManagementFlow: AppStoreAccountManageme
switch await authEndpointService.storeLogin(signature: lastTransactionJWSRepresentation) {
case .success(let response):
if response.externalID == accountManager.externalID {
authToken = response.authToken
accountManager.storeAuthToken(token: authToken)
let refreshedAuthToken = response.authToken
accountManager.storeAuthToken(token: refreshedAuthToken)
return .success(refreshedAuthToken)
}
case .failure(let storeLoginError):
Logger.subscription.error("[AppStoreAccountManagementFlow] storeLogin error: \(String(reflecting: storeLoginError), privacy: .public)")
Expand Down

0 comments on commit d683458

Please sign in to comment.