mount public data from the atmosphere to a virtual filesystem (macos only) pdfs.at
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat(atproto/oauth): add BrowserDriver protocol + test stub

+29
+29
Packages/ATProto/Sources/ATProto/OAuth/BrowserDriver.swift
··· 1 + import Foundation 2 + 3 + public protocol BrowserDriver: Sendable { 4 + /// Presents the given authorization URL to the user and returns the 5 + /// callback URL the OAuth server redirected to. The host app implements 6 + /// this via `ASWebAuthenticationSession`; tests use `StubBrowserDriver`. 7 + /// - Parameter redirectScheme: the custom URL scheme to listen for 8 + /// (e.g. `"pdfs"` for `pdfs://oauth/callback`). 9 + func authenticate( 10 + authorizationURL: URL, 11 + redirectScheme: String 12 + ) async throws -> URL 13 + } 14 + 15 + /// Test helper that runs a pre-configured handler when `authenticate` is called. 16 + /// Host code uses `ASWebAuthenticationSessionBrowserDriver` (to be added 17 + /// alongside the macOS host app). Tests pass a closure that inspects the 18 + /// authorization URL and returns a fabricated callback. 19 + public struct StubBrowserDriver: BrowserDriver { 20 + public let handler: @Sendable (URL, String) async throws -> URL 21 + 22 + public init(handler: @escaping @Sendable (URL, String) async throws -> URL) { 23 + self.handler = handler 24 + } 25 + 26 + public func authenticate(authorizationURL: URL, redirectScheme: String) async throws -> URL { 27 + try await handler(authorizationURL, redirectScheme) 28 + } 29 + }