diff --git a/Sources/Subscription/SubscriptionCookie/HTTPCookieStore.swift b/Sources/Subscription/SubscriptionCookie/HTTPCookieStore.swift index 74fec5568..3b561c637 100644 --- a/Sources/Subscription/SubscriptionCookie/HTTPCookieStore.swift +++ b/Sources/Subscription/SubscriptionCookie/HTTPCookieStore.swift @@ -25,4 +25,36 @@ public protocol HTTPCookieStore { func deleteCookie(_ cookie: HTTPCookie) async } -extension WKHTTPCookieStore: HTTPCookieStore {} +@MainActor +public struct WKHTTPCookieStoreWrapper: HTTPCookieStore { + + let store: WKHTTPCookieStore + + public init(store: WKHTTPCookieStore) { + self.store = store + } + + public func allCookies() async -> [HTTPCookie] { + return await withCheckedContinuation { continuation in + store.getAllCookies { cookies in + continuation.resume(returning: cookies) + } + } + } + + public func setCookie(_ cookie: HTTPCookie) async { + await withCheckedContinuation { continuation in + store.setCookie(cookie) { + continuation.resume() + } + } + } + + public func deleteCookie(_ cookie: HTTPCookie) async { + await withCheckedContinuation { continuation in + store.delete(cookie) { + continuation.resume() + } + } + } +}