-
Notifications
You must be signed in to change notification settings - Fork 169
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: ios: authenticate user before clearing logs
- Loading branch information
Showing
5 changed files
with
57 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
ios/PolkadotVault/Core/Authentication/DevicePasscodeAuthenticator.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// | ||
// DevicePasscodeAuthenticator.swift | ||
// PolkadotVault | ||
// | ||
// Created by Krzysztof Rodak on 28/12/2023. | ||
// | ||
|
||
import Foundation | ||
import LocalAuthentication | ||
|
||
protocol DevicePasscodeAuthenticatorProtocol { | ||
/// This methods trigger passcode screen to authenticate user, if failed, will bring back "Unlock app" screen | ||
/// | ||
/// As we can't use `LAContext` to properly evaluate user authentication, as this would trigger biometry check | ||
/// if set up. Hence we need to rely on fetching some seed from Keychain and with assumption that authentication | ||
/// is used only when some seed is present this satisfies our requirements | ||
/// - Returns: whether user is authenticated or not | ||
func authenticateUser() -> Bool | ||
} | ||
|
||
final class DevicePasscodeAuthenticator: DevicePasscodeAuthenticatorProtocol { | ||
private let seedsMediator: SeedsMediating | ||
|
||
init( | ||
seedsMediator: SeedsMediating = ServiceLocator.seedsMediator | ||
) { | ||
self.seedsMediator = seedsMediator | ||
} | ||
|
||
func authenticateUser() -> Bool { | ||
guard let seedName = seedsMediator.seedNames.first else { return true } | ||
return !seedsMediator.getSeed(seedName: seedName).isEmpty | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters