Refactor YubiKey decryptor (#663)
- Add YKFSmartCardInterface extension to simplify smart card related calls - Use async/await to rewrite callback closures - Update YubiKeyConnection - Better error handling
This commit is contained in:
parent
fc35805565
commit
a410c9480a
9 changed files with 344 additions and 320 deletions
|
|
@ -36,12 +36,13 @@ public enum YubiKeyError: Error, Equatable {
|
|||
case selectApplication(message: String)
|
||||
case verify(message: String)
|
||||
case decipher(message: String)
|
||||
case other(message: String)
|
||||
}
|
||||
|
||||
extension YubiKeyError: LocalizedError {
|
||||
public var errorDescription: String? {
|
||||
switch self {
|
||||
case let .connection(message), let .decipher(message), let .selectApplication(message), let .verify(message):
|
||||
case let .connection(message), let .decipher(message), let .other(message), let .selectApplication(message), let .verify(message):
|
||||
return message
|
||||
}
|
||||
}
|
||||
|
|
@ -56,6 +57,8 @@ extension AppError: LocalizedError {
|
|||
return localizationKey.localize(name)
|
||||
case let .pgpPrivateKeyNotFound(keyID), let .pgpPublicKeyNotFound(keyID):
|
||||
return localizationKey.localize(keyID)
|
||||
case let .yubiKey(error):
|
||||
return error.errorDescription
|
||||
case let .other(message):
|
||||
return message.localize()
|
||||
default:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue