Skip to content

Commit

Permalink
fix platform compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
mikepitre committed Sep 23, 2024
1 parent a686544 commit c32d5e0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
9 changes: 9 additions & 0 deletions Sources/API/Models/SignIn.swift
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,7 @@ public struct SignIn: Codable, Sendable, Equatable, Hashable {
let manager = PasskeyManager()
var authorization: ASAuthorization

#if os(iOS) && !targetEnvironment(macCatalyst)
if autofill {
authorization = try await manager.beginAutoFillAssistedPasskeySignIn(
challenge: challenge
Expand All @@ -481,6 +482,14 @@ public struct SignIn: Codable, Sendable, Equatable, Hashable {
preferImmediatelyAvailableCredentials: preferImmediatelyAvailableCredentials
)
}
#else
authorization = try await manager.signIn(
challenge: challenge,
preferImmediatelyAvailableCredentials: preferImmediatelyAvailableCredentials
)
#endif



guard
let credentialAssertion = authorization.credential as? ASAuthorizationPlatformPublicKeyCredentialAssertion,
Expand Down
2 changes: 1 addition & 1 deletion Sources/API/Utils/PasskeyManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ final class PasskeyManager: NSObject {
}
}

#if !os(macOS) && !os(tvOS)
#if os(iOS) && !targetEnvironment(macCatalyst)
@MainActor
func beginAutoFillAssistedPasskeySignIn(challenge: Data) async throws -> ASAuthorization {
return try await withCheckedThrowingContinuation { continuation in
Expand Down
8 changes: 0 additions & 8 deletions Sources/API/Utils/WebAuthentication.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,6 @@ final class WebAuthentication: NSObject {
Self.currentSession?.start()
}
}

func cancel() {
#if !os(tvOS)
Self.currentSession?.cancel()
#endif
Self.currentSession = nil
}

}

#if !os(watchOS) && !os(tvOS)
Expand Down

0 comments on commit c32d5e0

Please sign in to comment.