From 5cf7c4836594f3e13f4d519b47cd890650530e6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20T=C3=A4kker?= Date: Fri, 9 Oct 2026 01:18:31 +0200 Subject: [PATCH] Remove auth cookie persistence logs --- Music/Utils/API/APIClient.swift | 6 ------ Music/Utils/API/AuthCookiePersistence.swift | 24 +-------------------- 2 files changed, 1 insertion(+), 29 deletions(-) diff --git a/Music/Utils/API/APIClient.swift b/Music/Utils/API/APIClient.swift index 5e4b25d..025dc3a 100644 --- a/Music/Utils/API/APIClient.swift +++ b/Music/Utils/API/APIClient.swift @@ -110,9 +110,6 @@ public final class APIClient: @unchecked Sendable { guard let url = components.url else { throw APIError.invalidURL } if let cookieStorage = session.configuration.httpCookieStorage { AuthCookiePersistence.restore(into: cookieStorage, for: url) - if path.hasPrefix("auth/") { - AuthCookiePersistence.logRequestCookies(from: cookieStorage, for: url, phase: "before \(path)") - } } var request = URLRequest(url: url) request.httpMethod = method @@ -130,9 +127,6 @@ public final class APIClient: @unchecked Sendable { let (data, rawResponse) = try await session.data(for: request) if let cookieStorage = session.configuration.httpCookieStorage { AuthCookiePersistence.save(from: cookieStorage, for: url) - if path.hasPrefix("auth/") { - AuthCookiePersistence.logRequestCookies(from: cookieStorage, for: url, phase: "after \(path)") - } } guard let http = rawResponse as? HTTPURLResponse else { throw APIError.nonHTTPResponse } guard (200..<300).contains(http.statusCode) else { diff --git a/Music/Utils/API/AuthCookiePersistence.swift b/Music/Utils/API/AuthCookiePersistence.swift index abb0647..6c9d45c 100644 --- a/Music/Utils/API/AuthCookiePersistence.swift +++ b/Music/Utils/API/AuthCookiePersistence.swift @@ -9,19 +9,16 @@ enum AuthCookiePersistence { static func restore(into storage: HTTPCookieStorage, for url: URL) { guard let data = read() else { - debug("restore: no Keychain record for host=\(url.host ?? "?")") return } guard let properties = try? PropertyListSerialization.propertyList( from: data, options: [], format: nil) as? [[HTTPCookiePropertyKey: Any]] else { - debug("restore: Keychain data could not be decoded (\(data.count) bytes)") return } let cookies = properties.compactMap(HTTPCookie.init(properties:)) .filter { $0.domain.hasSuffix("music.lucasskt.dk") && $0.expiresDate.map { $0 > Date() } ?? true } storage.setCookies(cookies, for: url, mainDocumentURL: nil) - debug("restore: loaded \(cookies.count) cookies [\(cookieNames(cookies))] for host=\(url.host ?? "?")") } static func save(from storage: HTTPCookieStorage, for url: URL) { @@ -31,7 +28,6 @@ enum AuthCookiePersistence { guard let data = try? PropertyListSerialization.data( fromPropertyList: properties, format: .binary, options: 0) else { - debug("save: cookie properties could not be encoded [\(cookieNames(storage.cookies(for: url) ?? []))]") return } @@ -46,16 +42,10 @@ enum AuthCookiePersistence { var insert = query insert[kSecValueData as String] = data insert[kSecAttrAccessible as String] = kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly - let addStatus = SecItemAdd(insert as CFDictionary, nil) - debug("save: insert status=\(addStatus), cookies=\(properties.count) [\(cookieNames(storage.cookies(for: url) ?? []))]") - } else { - debug("save: update status=\(status), cookies=\(properties.count) [\(cookieNames(storage.cookies(for: url) ?? []))]") + SecItemAdd(insert as CFDictionary, nil) } } - static func logRequestCookies(from storage: HTTPCookieStorage, for url: URL, phase: String) { - debug("\(phase): request cookie names [\(cookieNames(storage.cookies(for: url) ?? []))] host=\(url.host ?? "?")") - } static func clear() { SecItemDelete([ @@ -77,20 +67,8 @@ enum AuthCookiePersistence { var result: CFTypeRef? let status = SecItemCopyMatching(query as CFDictionary, &result) guard status == errSecSuccess else { - debug("read: Keychain status=\(status)") return nil } - debug("read: Keychain success") return result as? Data } - - private static func cookieNames(_ cookies: [HTTPCookie]) -> String { - cookies.map(\.name).sorted().joined(separator: ",") - } - - private static func debug(_ message: String) { - #if DEBUG - print("[AuthCookiePersistence] pid=\(ProcessInfo.processInfo.processIdentifier) bundle=\(Bundle.main.bundleIdentifier ?? "?") \(message)") - #endif - } }