Support selects a credential identity from the QuickType bar
This commit is contained in:
parent
d4669bbfcb
commit
29d74c48e5
6 changed files with 125 additions and 30 deletions
|
|
@ -345,6 +345,17 @@ public class PasswordStore {
|
|||
}
|
||||
}
|
||||
|
||||
public func fetchPasswordEntity(with path: String) -> PasswordEntity? {
|
||||
let passwordEntityFetchRequest = NSFetchRequest<NSFetchRequestResult>(entityName: "PasswordEntity")
|
||||
passwordEntityFetchRequest.predicate = NSPredicate(format: "path = %@", path)
|
||||
do {
|
||||
let passwordEntities = try context.fetch(passwordEntityFetchRequest) as! [PasswordEntity]
|
||||
return passwordEntities.first
|
||||
} catch {
|
||||
fatalError("FailedToFetchPasswords".localize(error))
|
||||
}
|
||||
}
|
||||
|
||||
public func setAllSynced() {
|
||||
let passwordEntities = fetchUnsyncedPasswords()
|
||||
if !passwordEntities.isEmpty {
|
||||
|
|
@ -688,6 +699,13 @@ public class PasswordStore {
|
|||
return Password(name: passwordEntity.getName(), url: url, plainText: plainText)
|
||||
}
|
||||
|
||||
public func decrypt(path: String, keyID: String? = nil, requestPGPKeyPassphrase: @escaping (String) -> String) throws -> Password {
|
||||
guard let passwordEntity = fetchPasswordEntity(with: path) else {
|
||||
throw AppError.decryption
|
||||
}
|
||||
return try decrypt(passwordEntity: passwordEntity, keyID: keyID, requestPGPKeyPassphrase: requestPGPKeyPassphrase)
|
||||
}
|
||||
|
||||
public func encrypt(password: Password, keyID: String? = nil) throws -> Data {
|
||||
let encryptedDataPath = storeURL.appendingPathComponent(password.url.path)
|
||||
let keyID = keyID ?? findGPGID(from: encryptedDataPath)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue