Skip to content

Commit b49593e

Browse files
committed
Rename ignore .gpg-id switch to enalbe .gpg-id
1 parent f539d2c commit b49593e

File tree

5 files changed

+21
-21
lines changed

5 files changed

+21
-21
lines changed

pass/Controllers/GeneralSettingsTableViewController.swift

+8-8
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ class GeneralSettingsTableViewController: BasicStaticTableViewController {
4646
return uiSwitch
4747
}()
4848

49-
let ignoreGPGIDSwitch: UISwitch = {
49+
let enableGPGIDSwitch: UISwitch = {
5050
let uiSwitch = UISwitch()
5151
uiSwitch.onTintColor = Colors.systemBlue
5252
uiSwitch.sizeToFit()
53-
uiSwitch.addTarget(self, action: #selector(ignoreGPGIDSwitchAction(_:)), for: UIControl.Event.valueChanged)
54-
uiSwitch.isOn = Defaults.isIgnoreGPGIDOn
53+
uiSwitch.addTarget(self, action: #selector(enableGPGIDSwitchAction(_:)), for: UIControl.Event.valueChanged)
54+
uiSwitch.isOn = Defaults.isEnableGPGIDOn
5555
return uiSwitch
5656
}()
5757

@@ -86,7 +86,7 @@ class GeneralSettingsTableViewController: BasicStaticTableViewController {
8686

8787
// section 2
8888
[
89-
[.title: "IgnoreGPGID".localize(), .action: "none"],
89+
[.title: "EnableGPGID".localize(), .action: "none"],
9090
[.title: "ShowFolders".localize(), .action: "none"],
9191
[.title: "HidePasswordImages".localize(), .action: "none"],
9292
[.title: "HideUnknownFields".localize(), .action: "none"],
@@ -139,10 +139,10 @@ class GeneralSettingsTableViewController: BasicStaticTableViewController {
139139
cell.accessoryType = .none
140140
cell.selectionStyle = .none
141141
cell.accessoryView = showFolderSwitch
142-
case "IgnoreGPGID".localize():
142+
case "EnableGPGID".localize():
143143
cell.accessoryType = .none
144144
cell.selectionStyle = .none
145-
cell.accessoryView = ignoreGPGIDSwitch
145+
cell.accessoryView = enableGPGIDSwitch
146146
case "HidePasswordImages".localize():
147147
cell.accessoryType = .none
148148
let detailButton = UIButton(type: .detailDisclosure)
@@ -221,8 +221,8 @@ class GeneralSettingsTableViewController: BasicStaticTableViewController {
221221
}
222222

223223
@objc
224-
func ignoreGPGIDSwitchAction(_: Any?) {
225-
Defaults.isIgnoreGPGIDOn = ignoreGPGIDSwitch.isOn
224+
func enableGPGIDSwitchAction(_: Any?) {
225+
Defaults.isEnableGPGIDOn = enableGPGIDSwitch.isOn
226226
}
227227

228228
@objc

pass/en.lproj/Localizable.strings

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"PasswordGeneratorFlavor" = "Style";
4242
"RememberPgpKeyPassphrase" = "Remember PGP Key Passphrase";
4343
"RememberGitCredentialPassphrase" = "Remember Git Credential Passphrase";
44-
"IgnoreGPGID" = "Ignore .gpg-id";
44+
"EnableGPGID" = "Enable .gpg-id (Experiment)";
4545
"ShowFolders" = "Show Folders";
4646
"HidePasswordImages" = "Hide Password Images";
4747
"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.";

passKit/Helpers/DefaultsKeys.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public extension DefaultsKeys {
5050
var isHideOTPOn: DefaultsKey<Bool> { .init("isHideOTPOn", defaultValue: false) }
5151
var isRememberPGPPassphraseOn: DefaultsKey<Bool> { .init("isRememberPGPPassphraseOn", defaultValue: false) }
5252
var isRememberGitCredentialPassphraseOn: DefaultsKey<Bool> { .init("isRememberGitCredentialPassphraseOn", defaultValue: false) }
53-
var isIgnoreGPGIDOn: DefaultsKey<Bool> { .init("isIgnoreGPGIDOn", defaultValue: true) }
53+
var isEnableGPGIDOn: DefaultsKey<Bool> { .init("isEnableGPGIDOn", defaultValue: false) }
5454
var isShowFolderOn: DefaultsKey<Bool> { .init("isShowFolderOn", defaultValue: true) }
5555
var isHidePasswordImagesOn: DefaultsKey<Bool> { .init("isHidePasswordImagesOn", defaultValue: false) }
5656
var searchDefault: DefaultsKey<SearchBarScope?> { .init("searchDefault", defaultValue: .all) }

passKit/Models/PasswordStore.swift

+9-9
Original file line numberDiff line numberDiff line change
@@ -691,11 +691,11 @@ public class PasswordStore {
691691
let encryptedDataPath = storeURL.appendingPathComponent(passwordEntity.getPath())
692692
let encryptedData = try Data(contentsOf: encryptedDataPath)
693693
let data: Data? = try {
694-
if Defaults.isIgnoreGPGIDOn {
695-
return try PGPAgent.shared.decrypt(encryptedData: encryptedData, requestPGPKeyPassphrase: requestPGPKeyPassphrase)
696-
} else {
694+
if Defaults.isEnableGPGIDOn {
697695
let keyID = keyID ?? findGPGID(from: encryptedDataPath)
698696
return try PGPAgent.shared.decrypt(encryptedData: encryptedData, keyID: keyID, requestPGPKeyPassphrase: requestPGPKeyPassphrase)
697+
} else {
698+
return try PGPAgent.shared.decrypt(encryptedData: encryptedData, requestPGPKeyPassphrase: requestPGPKeyPassphrase)
699699
}
700700
}()
701701
guard let decryptedData = data else {
@@ -710,20 +710,20 @@ public class PasswordStore {
710710
guard let passwordEntity = fetchPasswordEntity(with: path) else {
711711
throw AppError.decryption
712712
}
713-
if Defaults.isIgnoreGPGIDOn {
714-
return try decrypt(passwordEntity: passwordEntity, requestPGPKeyPassphrase: requestPGPKeyPassphrase)
715-
} else {
713+
if Defaults.isEnableGPGIDOn {
716714
return try decrypt(passwordEntity: passwordEntity, keyID: keyID, requestPGPKeyPassphrase: requestPGPKeyPassphrase)
715+
} else {
716+
return try decrypt(passwordEntity: passwordEntity, requestPGPKeyPassphrase: requestPGPKeyPassphrase)
717717
}
718718
}
719719

720720
public func encrypt(password: Password, keyID: String? = nil) throws -> Data {
721721
let encryptedDataPath = storeURL.appendingPathComponent(password.url.path)
722722
let keyID = keyID ?? findGPGID(from: encryptedDataPath)
723-
if Defaults.isIgnoreGPGIDOn {
724-
return try PGPAgent.shared.encrypt(plainData: password.plainData)
725-
} else {
723+
if Defaults.isEnableGPGIDOn {
726724
return try PGPAgent.shared.encrypt(plainData: password.plainData, keyID: keyID)
725+
} else {
726+
return try PGPAgent.shared.encrypt(plainData: password.plainData)
727727
}
728728
}
729729

passKitTests/Models/PasswordStoreTest.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class PasswordStoreTest: XCTestCase {
1616

1717
func testCloneAndDecryptMultiKeys() throws {
1818
let url = URL(fileURLWithPath: "\(Globals.repositoryPath)-test")
19-
Defaults.isIgnoreGPGIDOn = false
19+
Defaults.isEnableGPGIDOn = true
2020
let passwordStore = PasswordStore(url: url)
2121
try passwordStore.cloneRepository(remoteRepoURL: remoteRepoURL, branchName: "master")
2222
expectation(for: NSPredicate { _, _ in FileManager.default.fileExists(atPath: url.path) }, evaluatedWith: nil)
@@ -47,7 +47,7 @@ class PasswordStoreTest: XCTestCase {
4747
XCTAssertEqual(testPasswordPlain.plainText, "testpassword")
4848

4949
passwordStore.erase()
50-
Defaults.isIgnoreGPGIDOn = true
50+
Defaults.isEnableGPGIDOn = false
5151
}
5252

5353
private func decrypt(passwordStore: PasswordStore, path: String, passphrase _: String) throws -> Password {

0 commit comments

Comments
 (0)