Rename ignore .gpg-id switch to enalbe .gpg-id
This commit is contained in:
parent
f539d2ccfc
commit
b49593e87f
5 changed files with 21 additions and 21 deletions
|
|
@ -46,12 +46,12 @@ class GeneralSettingsTableViewController: BasicStaticTableViewController {
|
|||
return uiSwitch
|
||||
}()
|
||||
|
||||
let ignoreGPGIDSwitch: UISwitch = {
|
||||
let enableGPGIDSwitch: UISwitch = {
|
||||
let uiSwitch = UISwitch()
|
||||
uiSwitch.onTintColor = Colors.systemBlue
|
||||
uiSwitch.sizeToFit()
|
||||
uiSwitch.addTarget(self, action: #selector(ignoreGPGIDSwitchAction(_:)), for: UIControl.Event.valueChanged)
|
||||
uiSwitch.isOn = Defaults.isIgnoreGPGIDOn
|
||||
uiSwitch.addTarget(self, action: #selector(enableGPGIDSwitchAction(_:)), for: UIControl.Event.valueChanged)
|
||||
uiSwitch.isOn = Defaults.isEnableGPGIDOn
|
||||
return uiSwitch
|
||||
}()
|
||||
|
||||
|
|
@ -86,7 +86,7 @@ class GeneralSettingsTableViewController: BasicStaticTableViewController {
|
|||
|
||||
// section 2
|
||||
[
|
||||
[.title: "IgnoreGPGID".localize(), .action: "none"],
|
||||
[.title: "EnableGPGID".localize(), .action: "none"],
|
||||
[.title: "ShowFolders".localize(), .action: "none"],
|
||||
[.title: "HidePasswordImages".localize(), .action: "none"],
|
||||
[.title: "HideUnknownFields".localize(), .action: "none"],
|
||||
|
|
@ -139,10 +139,10 @@ class GeneralSettingsTableViewController: BasicStaticTableViewController {
|
|||
cell.accessoryType = .none
|
||||
cell.selectionStyle = .none
|
||||
cell.accessoryView = showFolderSwitch
|
||||
case "IgnoreGPGID".localize():
|
||||
case "EnableGPGID".localize():
|
||||
cell.accessoryType = .none
|
||||
cell.selectionStyle = .none
|
||||
cell.accessoryView = ignoreGPGIDSwitch
|
||||
cell.accessoryView = enableGPGIDSwitch
|
||||
case "HidePasswordImages".localize():
|
||||
cell.accessoryType = .none
|
||||
let detailButton = UIButton(type: .detailDisclosure)
|
||||
|
|
@ -221,8 +221,8 @@ class GeneralSettingsTableViewController: BasicStaticTableViewController {
|
|||
}
|
||||
|
||||
@objc
|
||||
func ignoreGPGIDSwitchAction(_: Any?) {
|
||||
Defaults.isIgnoreGPGIDOn = ignoreGPGIDSwitch.isOn
|
||||
func enableGPGIDSwitchAction(_: Any?) {
|
||||
Defaults.isEnableGPGIDOn = enableGPGIDSwitch.isOn
|
||||
}
|
||||
|
||||
@objc
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@
|
|||
"PasswordGeneratorFlavor" = "Style";
|
||||
"RememberPgpKeyPassphrase" = "Remember PGP Key Passphrase";
|
||||
"RememberGitCredentialPassphrase" = "Remember Git Credential Passphrase";
|
||||
"IgnoreGPGID" = "Ignore .gpg-id";
|
||||
"EnableGPGID" = "Enable .gpg-id (Experiment)";
|
||||
"ShowFolders" = "Show Folders";
|
||||
"HidePasswordImages" = "Hide Password Images";
|
||||
"HidePasswordImagesExplanation." = "Associated favicon images are loaded and shown based upon the URL associated with an entry. Enable this option to hide these images and prevent them from being loaded.";
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ public extension DefaultsKeys {
|
|||
var isHideOTPOn: DefaultsKey<Bool> { .init("isHideOTPOn", defaultValue: false) }
|
||||
var isRememberPGPPassphraseOn: DefaultsKey<Bool> { .init("isRememberPGPPassphraseOn", defaultValue: false) }
|
||||
var isRememberGitCredentialPassphraseOn: DefaultsKey<Bool> { .init("isRememberGitCredentialPassphraseOn", defaultValue: false) }
|
||||
var isIgnoreGPGIDOn: DefaultsKey<Bool> { .init("isIgnoreGPGIDOn", defaultValue: true) }
|
||||
var isEnableGPGIDOn: DefaultsKey<Bool> { .init("isEnableGPGIDOn", defaultValue: false) }
|
||||
var isShowFolderOn: DefaultsKey<Bool> { .init("isShowFolderOn", defaultValue: true) }
|
||||
var isHidePasswordImagesOn: DefaultsKey<Bool> { .init("isHidePasswordImagesOn", defaultValue: false) }
|
||||
var searchDefault: DefaultsKey<SearchBarScope?> { .init("searchDefault", defaultValue: .all) }
|
||||
|
|
|
|||
|
|
@ -691,11 +691,11 @@ public class PasswordStore {
|
|||
let encryptedDataPath = storeURL.appendingPathComponent(passwordEntity.getPath())
|
||||
let encryptedData = try Data(contentsOf: encryptedDataPath)
|
||||
let data: Data? = try {
|
||||
if Defaults.isIgnoreGPGIDOn {
|
||||
return try PGPAgent.shared.decrypt(encryptedData: encryptedData, requestPGPKeyPassphrase: requestPGPKeyPassphrase)
|
||||
} else {
|
||||
if Defaults.isEnableGPGIDOn {
|
||||
let keyID = keyID ?? findGPGID(from: encryptedDataPath)
|
||||
return try PGPAgent.shared.decrypt(encryptedData: encryptedData, keyID: keyID, requestPGPKeyPassphrase: requestPGPKeyPassphrase)
|
||||
} else {
|
||||
return try PGPAgent.shared.decrypt(encryptedData: encryptedData, requestPGPKeyPassphrase: requestPGPKeyPassphrase)
|
||||
}
|
||||
}()
|
||||
guard let decryptedData = data else {
|
||||
|
|
@ -710,20 +710,20 @@ public class PasswordStore {
|
|||
guard let passwordEntity = fetchPasswordEntity(with: path) else {
|
||||
throw AppError.decryption
|
||||
}
|
||||
if Defaults.isIgnoreGPGIDOn {
|
||||
return try decrypt(passwordEntity: passwordEntity, requestPGPKeyPassphrase: requestPGPKeyPassphrase)
|
||||
} else {
|
||||
if Defaults.isEnableGPGIDOn {
|
||||
return try decrypt(passwordEntity: passwordEntity, keyID: keyID, requestPGPKeyPassphrase: requestPGPKeyPassphrase)
|
||||
} else {
|
||||
return try decrypt(passwordEntity: passwordEntity, 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)
|
||||
if Defaults.isIgnoreGPGIDOn {
|
||||
return try PGPAgent.shared.encrypt(plainData: password.plainData)
|
||||
} else {
|
||||
if Defaults.isEnableGPGIDOn {
|
||||
return try PGPAgent.shared.encrypt(plainData: password.plainData, keyID: keyID)
|
||||
} else {
|
||||
return try PGPAgent.shared.encrypt(plainData: password.plainData)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ class PasswordStoreTest: XCTestCase {
|
|||
|
||||
func testCloneAndDecryptMultiKeys() throws {
|
||||
let url = URL(fileURLWithPath: "\(Globals.repositoryPath)-test")
|
||||
Defaults.isIgnoreGPGIDOn = false
|
||||
Defaults.isEnableGPGIDOn = true
|
||||
let passwordStore = PasswordStore(url: url)
|
||||
try passwordStore.cloneRepository(remoteRepoURL: remoteRepoURL, branchName: "master")
|
||||
expectation(for: NSPredicate { _, _ in FileManager.default.fileExists(atPath: url.path) }, evaluatedWith: nil)
|
||||
|
|
@ -47,7 +47,7 @@ class PasswordStoreTest: XCTestCase {
|
|||
XCTAssertEqual(testPasswordPlain.plainText, "testpassword")
|
||||
|
||||
passwordStore.erase()
|
||||
Defaults.isIgnoreGPGIDOn = true
|
||||
Defaults.isEnableGPGIDOn = false
|
||||
}
|
||||
|
||||
private func decrypt(passwordStore: PasswordStore, path: String, passphrase _: String) throws -> Password {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue