Skip to content

Commit

Permalink
Merge branch 'hotfix/211.0.0-2'
Browse files Browse the repository at this point in the history
  • Loading branch information
ayoy committed Nov 26, 2024
2 parents deacf61 + c99d4e9 commit f83b1f5
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion Sources/Subscription/SubscriptionCookie/HTTPCookieStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}
}
}

0 comments on commit f83b1f5

Please sign in to comment.