Skip to content

Commit d102f8a

Browse files
authored
Add FXIOS-13673 [Debug Menu] New item to remove credit card encryption keys for testing (#29656)
1 parent c12ede9 commit d102f8a

File tree

5 files changed

+36
-0
lines changed

5 files changed

+36
-0
lines changed

firefox-ios/Client.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2154,6 +2154,7 @@
21542154
F80D53CF2A09A3350047ED14 /* RustSyncManagerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F80D53CD2A09A30F0047ED14 /* RustSyncManagerTests.swift */; };
21552155
F80DF7412703BC8E00E4C37D /* CredentialPasscodeRequirementViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F80DF7402703BC8E00E4C37D /* CredentialPasscodeRequirementViewController.swift */; };
21562156
F80DF74B270CB9CA00E4C37D /* AppAuthenticator.swift in Sources */ = {isa = PBXBuildFile; fileRef = E65D89171C8647420006EA35 /* AppAuthenticator.swift */; };
2157+
F82F68B12E86EF5F002E42D1 /* DeleteAutofillKeysSetting.swift in Sources */ = {isa = PBXBuildFile; fileRef = F82F68B02E86EF4D002E42D1 /* DeleteAutofillKeysSetting.swift */; };
21572158
F8324A072649A188007E4BFA /* AuthenticationServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F8324A062649A188007E4BFA /* AuthenticationServices.framework */; };
21582159
F8324A0A2649A188007E4BFA /* CredentialProviderViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F8324A092649A188007E4BFA /* CredentialProviderViewController.swift */; };
21592160
F8324A122649A188007E4BFA /* CredentialProvider.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = F8324A052649A188007E4BFA /* CredentialProvider.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
@@ -11024,6 +11025,7 @@
1102411025
F80D53CD2A09A30F0047ED14 /* RustSyncManagerTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RustSyncManagerTests.swift; sourceTree = "<group>"; };
1102511026
F80DF7402703BC8E00E4C37D /* CredentialPasscodeRequirementViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CredentialPasscodeRequirementViewController.swift; sourceTree = "<group>"; };
1102611027
F82F4AB9A3C09B181AB61F73 /* pt-BR */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "pt-BR"; path = "pt-BR.lproj/Shared.strings"; sourceTree = "<group>"; };
11028+
F82F68B02E86EF4D002E42D1 /* DeleteAutofillKeysSetting.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeleteAutofillKeysSetting.swift; sourceTree = "<group>"; };
1102711029
F8324A052649A188007E4BFA /* CredentialProvider.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = CredentialProvider.appex; sourceTree = BUILT_PRODUCTS_DIR; };
1102811030
F8324A062649A188007E4BFA /* AuthenticationServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AuthenticationServices.framework; path = System/Library/Frameworks/AuthenticationServices.framework; sourceTree = SDKROOT; };
1102911031
F8324A092649A188007E4BFA /* CredentialProviderViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CredentialProviderViewController.swift; sourceTree = "<group>"; };
@@ -13083,6 +13085,7 @@
1308313085
8A3EF7EE2A2FCF0000796E3A /* Debug */ = {
1308413086
isa = PBXGroup;
1308513087
children = (
13088+
F82F68B02E86EF4D002E42D1 /* DeleteAutofillKeysSetting.swift */,
1308613089
033A61FF2E77FE9900A84E8A /* ResetTermsOfServiceAcceptancePage.swift */,
1308713090
0BD049CD2DFC4A9C00614E61 /* PopupHTMLSetting.swift */,
1308813091
1DC598B52DC53CED0037D263 /* Performance */,
@@ -19157,6 +19160,7 @@
1915719160
8A19ACB62A3290F9001C2147 /* NotificationsSetting.swift in Sources */,
1915819161
43D16B8229831E6A009F8279 /* CreditCardInputField.swift in Sources */,
1915919162
8187561A2BB4618500DCD1F3 /* OnboardingViewControllerState.swift in Sources */,
19163+
F82F68B12E86EF5F002E42D1 /* DeleteAutofillKeysSetting.swift in Sources */,
1916019164
EB98550124226EF70040F24B /* AppDelegate+SyncSentTabs.swift in Sources */,
1916119165
0BD049CE2DFC4AAE00614E61 /* PopupHTMLSetting.swift in Sources */,
1916219166
744ED5611DBFEB8D00A2B5BE /* MailtoLinkHandler.swift in Sources */,

firefox-ios/Client/Frontend/Settings/Main/AppSettingsTableViewController.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,7 @@ class AppSettingsTableViewController: SettingsTableViewController,
488488
FirefoxSuggestSettings(settings: self, settingsDelegate: self),
489489
ScreenshotSetting(settings: self),
490490
DeleteLoginsKeysSetting(settings: self),
491+
DeleteAutofillKeysSetting(settings: self),
491492
ChangeRSServerSetting(settings: self),
492493
PopupHTMLSetting(settings: self),
493494
AddShortcutsSetting(settings: self, settingsDelegate: self)
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// This Source Code Form is subject to the terms of the Mozilla Public
2+
// License, v. 2.0. If a copy of the MPL was not distributed with this
3+
// file, You can obtain one at http://mozilla.org/MPL/2.0/
4+
5+
import Foundation
6+
import Storage
7+
8+
class DeleteAutofillKeysSetting: HiddenSetting {
9+
override var title: NSAttributedString? {
10+
guard let theme else { return nil }
11+
return NSAttributedString(
12+
string: "Delete autofill encryption keys (causes data loss) ⚠️",
13+
attributes: [NSAttributedString.Key.foregroundColor: theme.colors.textPrimary]
14+
)
15+
}
16+
17+
override func onClick(_ navigationController: UINavigationController?) {
18+
KeychainManager.shared.removeAutofillKeysForDebugMenuItem()
19+
}
20+
}

firefox-ios/Storage/MockRustKeychain.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ class MockRustKeychain: @unchecked Sendable, KeychainProtocol {
2626
removeObject(key: loginsCanaryKeyIdentifier)
2727
}
2828

29+
public func removeAutofillKeysForDebugMenuItem() {
30+
removeObject(key: creditCardKeyIdentifier)
31+
removeObject(key: creditCardCanaryKeyIdentifier)
32+
}
33+
2934
public func removeAllKeys() {
3035
storage.removeAll()
3136
}

firefox-ios/Storage/RustKeychain.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ public protocol KeychainProtocol: Sendable {
4646
var loginsKeyIdentifier: String { get }
4747
func removeObject(key: String)
4848
func removeLoginsKeysForDebugMenuItem()
49+
func removeAutofillKeysForDebugMenuItem()
4950
func removeAllKeys()
5051
func setLoginsKeyData(keyValue: String, canaryValue: String)
5152
func setCreditCardsKeyData(keyValue: String, canaryValue: String)
@@ -109,6 +110,11 @@ public final class RustKeychain: KeychainProtocol {
109110
removeObject(key: loginsCanaryKeyIdentifier)
110111
}
111112

113+
public func removeAutofillKeysForDebugMenuItem() {
114+
removeObject(key: creditCardKeyIdentifier)
115+
removeObject(key: creditCardCanaryKeyIdentifier)
116+
}
117+
112118
public func removeAllKeys() {
113119
var keychainQueryDictionary: [String: Any] = [kSecClass as String: kSecClassGenericPassword,
114120
kSecAttrService as String: serviceName]

0 commit comments

Comments
 (0)