Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ public enum LocalAuthenticationError: Error {
/// The user tapped the fallback button in the authentication dialog, but no fallback is available for the authentication policy.
case userFallback

/// The authentication failed because the companion device (e.g., Apple Watch) is not available.
case companionNotAvailable

/// An underlying error occurred.
///
/// - Parameter error: The underlying error.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,22 @@ public final class LocalAuthenticationProvider: LocalAuthenticationProviderProto
logger.error("Biometric sensor data has invalid dimensions: \(localizedDescription)")
return .invalidDimensions
#endif
default:
#if compiler(>=6.0)
case .companionNotAvailable:
if #available(iOS 18.0, *) {
logger.error("Companion device not available: \(localizedDescription)")
return .companionNotAvailable
} else {
logger.error("Unknown LAError: \(localizedDescription)")
return .error(laError)
}
#endif
@unknown default:
logger.error("Unknown LAError: \(localizedDescription)")
return .error(laError)
// .touchIDLockout (depricated)
// .touchIDNotEnrolled (depricated)
// .touchIDNotAvailable (depricated)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,23 @@ final class LocalAuthProviderLAErrorCasesTests: XCTestCase {
} catch {
}
}
#if compiler(>=6.0)
@available(iOS 18.0, *)
func testMapToLocalAuthenticationErrorCompanionNotAvailable() async {
let context = MockLAContext(
canEvaluatePolicies: [.deviceOwnerAuthenticationWithBiometrics],
biometryType: .faceID,
evaluatePolicyError: LAError(.companionNotAvailable)
)
let provider = LocalAuthenticationProvider(context: context)
do {
_ = try await provider.authenticate(localizedReason: "Test")
XCTFail("Error must be thrown")
} catch LocalAuthenticationError.companionNotAvailable {
} catch {
}
}
#endif
#if os(macOS)
func testMapToLocalAuthenticationErrorBiometryDisconnected() async {
let context = MockLAContext(
Expand Down
Loading