Skip to content

Commit 3de5980

Browse files
authored
Refactor FXIOS-10788 [Logins] Apply necessary adjustments for A-S EncryptorDecryptor update (#24108)
* chore: update EncryptedLogin to Login and fix compile errors * chore: fix tests * fix: lint * fix: address feedback * chore: manually update spm * fix: use isEmpty instead of listLogins * fix: revert spm file * feat: use .data from KeychainWrapper * fix: add mock for MZKeychainWrapper * fix: failing UI test * fix: lint * fix: bump table cell count for BR * fix: remove conditional checking of logins cells * chore: trigger ci
1 parent c4b5ab1 commit 3de5980

File tree

26 files changed

+306
-450
lines changed

26 files changed

+306
-450
lines changed

firefox-ios/Client.xcodeproj/project.pbxproj

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1257,6 +1257,7 @@
12571257
B2FEA68F2B460D9E0058E616 /* AddressAutofillSettingsViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = B2FEA68E2B460D9E0058E616 /* AddressAutofillSettingsViewModel.swift */; };
12581258
B2FEA6912B4661BE0058E616 /* AddressAutofillToggle.swift in Sources */ = {isa = PBXBuildFile; fileRef = B2FEA6902B4661BE0058E616 /* AddressAutofillToggle.swift */; };
12591259
B640467E29B9B58200C5C7B6 /* TabLocationViewTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B640467D29B9B58200C5C7B6 /* TabLocationViewTests.swift */; };
1260+
BA03AE592D41715900C7FA7B /* MockMZKeychainWrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = BA03AE582D41714B00C7FA7B /* MockMZKeychainWrapper.swift */; };
12601261
BA1C68BA2B7E9EA0000D9397 /* WKFrameInfoExtensionsTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = BA1C68B92B7E9EA0000D9397 /* WKFrameInfoExtensionsTest.swift */; };
12611262
BA1C68BC2B7ED153000D9397 /* MockWebKit.swift in Sources */ = {isa = PBXBuildFile; fileRef = BA1C68BB2B7ED153000D9397 /* MockWebKit.swift */; };
12621263
BA7A14842C2CCEB3008DF1D9 /* EditAddressWebViewManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = BA7A14832C2CCEB3008DF1D9 /* EditAddressWebViewManager.swift */; };
@@ -8445,6 +8446,7 @@
84458446
B9CF4F8ABA948EB090A67608 /* cs */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = cs; path = cs.lproj/ClearPrivateDataConfirm.strings; sourceTree = "<group>"; };
84468447
B9D74DA988462CC14EF29D8B /* fil */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fil; path = fil.lproj/Menu.strings; sourceTree = "<group>"; };
84478448
B9F246E38F80F257C59CEC4A /* ast */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ast; path = ast.lproj/HistoryPanel.strings; sourceTree = "<group>"; };
8449+
BA03AE582D41714B00C7FA7B /* MockMZKeychainWrapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MockMZKeychainWrapper.swift; sourceTree = "<group>"; };
84488450
BA05405089CFDC6097258640 /* en-CA */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "en-CA"; path = "en-CA.lproj/3DTouchActions.strings"; sourceTree = "<group>"; };
84498451
BA1C68B92B7E9EA0000D9397 /* WKFrameInfoExtensionsTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WKFrameInfoExtensionsTest.swift; sourceTree = "<group>"; };
84508452
BA1C68BB2B7ED153000D9397 /* MockWebKit.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MockWebKit.swift; sourceTree = "<group>"; };
@@ -10646,6 +10648,7 @@
1064610648
2FCAE21B1ABB51F800877008 /* Storage */ = {
1064710649
isa = PBXGroup;
1064810650
children = (
10651+
BA03AE582D41714B00C7FA7B /* MockMZKeychainWrapper.swift */,
1064910652
D37DE2821CA2047500A5EC69 /* CertStore.swift */,
1065010653
28C4AB711AD42D4300D9ACE3 /* Clients.swift */,
1065110654
2FCAE2411ABB531100877008 /* Cursor.swift */,
@@ -16027,6 +16030,7 @@
1602716030
B2999FED2B044A5900F0FEC1 /* UnencryptedCreditCardFields.swift in Sources */,
1602816031
15DE98FD27FCED4F00F1ECDB /* RustRemoteTabs.swift in Sources */,
1602916032
285D3B901B4386520035FD22 /* SQLiteQueue.swift in Sources */,
16033+
BA03AE592D41715900C7FA7B /* MockMZKeychainWrapper.swift in Sources */,
1603016034
394CF6CF1BAA493C00906917 /* DefaultSuggestedSites.swift in Sources */,
1603116035
B2999FEF2B044B4E00F0FEC1 /* RustAutofillEncryptionKeys.swift in Sources */,
1603216036
2FCAE2781ABB531100877008 /* Visit.swift in Sources */,
@@ -26516,7 +26520,7 @@
2651626520
repositoryURL = "https://github.com/mozilla/rust-components-swift.git";
2651726521
requirement = {
2651826522
kind = exactVersion;
26519-
version = 136.0.20250118050318;
26523+
version = 136.0.20250121100536;
2652026524
};
2652126525
};
2652226526
435C85EE2788F4D00072B526 /* XCRemoteSwiftPackageReference "glean-swift" */ = {

firefox-ios/Client.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

firefox-ios/Client/Coordinators/CredentialAutofillCoordinator.swift

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,7 @@ class CredentialAutofillCoordinator: BaseCoordinator {
133133
logger: logger,
134134
onLoginCellTap: { [weak self] login in
135135
guard let self else { return }
136-
let rustLoginsEncryption = RustLoginEncryptionKeys()
137-
138-
guard let currentTab = self.tabManager.selectedTab,
139-
let decryptLogin = rustLoginsEncryption.decryptSecureFields(login: login)
140-
else {
136+
guard let currentTab = self.tabManager.selectedTab else {
141137
router.dismiss(animated: true)
142138
parentCoordinator?.didFinish(from: self)
143139
return
@@ -148,9 +144,9 @@ class CredentialAutofillCoordinator: BaseCoordinator {
148144
loginData: LoginInjectionData(
149145
requestId: currentRequestId,
150146
logins: [LoginItem(
151-
username: decryptLogin.secFields.username,
152-
password: decryptLogin.secFields.password,
153-
hostname: decryptLogin.fields.origin
147+
username: login.username,
148+
password: login.password,
149+
hostname: login.origin
154150
)]
155151
)
156152
)

firefox-ios/Client/Frontend/Autofill/LoginCellView.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import SwiftUI
66
import Common
77

8-
import struct MozillaAppServices.EncryptedLogin
8+
import struct MozillaAppServices.Login
99

1010
/// A view representing a cell displaying login information.
1111
struct LoginCellView: View {
@@ -19,7 +19,7 @@ struct LoginCellView: View {
1919
@Environment(\.themeManager)
2020
var themeManager
2121

22-
private(set) var login: EncryptedLogin
22+
private(set) var login: Login
2323
private(set) var onTap: () -> Void
2424

2525
// MARK: - Body
@@ -37,8 +37,8 @@ struct LoginCellView: View {
3737
.alignmentGuide(.midIconAndLabel) { $0[VerticalAlignment.center] }
3838
.accessibilityHidden(true)
3939
VStack(alignment: .leading) {
40-
Text(login.decryptedUsername.isEmpty ? String.PasswordAutofill.LoginListCellNoUsername
41-
: login.decryptedUsername)
40+
Text(login.username.isEmpty ? String.PasswordAutofill.LoginListCellNoUsername
41+
: login.username)
4242
.font(.body)
4343
.foregroundColor(textColor)
4444
.alignmentGuide(.midIconAndLabel) { $0[VerticalAlignment.center] }
@@ -95,7 +95,7 @@ struct LoginButtonStyle: ButtonStyle {
9595
struct LoginCellView_Previews: PreviewProvider {
9696
static var previews: some View {
9797
// Create a sample login item
98-
let loginRecord = EncryptedLogin(
98+
let loginRecord = Login(
9999
credentials: URLCredential(
100100
user: "test",
101101
password: "doubletest",

firefox-ios/Client/Frontend/Autofill/LoginListViewModel.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@
55
import Common
66
import Foundation
77

8-
import struct MozillaAppServices.EncryptedLogin
8+
import struct MozillaAppServices.Login
99

1010
@MainActor
1111
class LoginListViewModel: ObservableObject {
12-
@Published var logins: [EncryptedLogin] = []
12+
@Published var logins: [Login] = []
1313

1414
private let tabURL: URL
1515
private let field: FocusFieldType
1616
private let loginStorage: LoginStorage
1717
private let logger: Logger
18-
let onLoginCellTap: (EncryptedLogin) -> Void
18+
let onLoginCellTap: (Login) -> Void
1919
let manageLoginInfoAction: () -> Void
2020

2121
var shortDisplayString: String {
@@ -27,7 +27,7 @@ class LoginListViewModel: ObservableObject {
2727
field: FocusFieldType,
2828
loginStorage: LoginStorage,
2929
logger: Logger,
30-
onLoginCellTap: @escaping (EncryptedLogin) -> Void,
30+
onLoginCellTap: @escaping (Login) -> Void,
3131
manageLoginInfoAction: @escaping () -> Void
3232
) {
3333
self.tabURL = tabURL
@@ -42,7 +42,7 @@ class LoginListViewModel: ObservableObject {
4242
do {
4343
let logins = try await loginStorage.listLogins()
4444
self.logins = logins.filter { login in
45-
if field == FocusFieldType.username && login.decryptedUsername.isEmpty { return false }
45+
if field == FocusFieldType.username && login.username.isEmpty { return false }
4646
guard let recordHostnameURL = URL(string: login.hostname) else { return false }
4747
return recordHostnameURL.baseDomain == tabURL.baseDomain
4848
}

firefox-ios/Client/Frontend/Autofill/LoginStorage.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44

55
import Storage
66

7-
import struct MozillaAppServices.EncryptedLogin
7+
import struct MozillaAppServices.Login
88

99
protocol LoginStorage {
10-
func listLogins() async throws -> [EncryptedLogin]
10+
func listLogins() async throws -> [Login]
1111
}
1212

1313
extension RustLogins: LoginStorage {
14-
func listLogins() async throws -> [EncryptedLogin] {
14+
func listLogins() async throws -> [Login] {
1515
return try await withCheckedThrowingContinuation { continuation in
1616
self.listLogins().upon { result in
1717
switch result {
@@ -27,7 +27,7 @@ extension RustLogins: LoginStorage {
2727

2828
class MockLoginStorage: LoginStorage {
2929
var shouldThrowError = false
30-
func listLogins() async throws -> [EncryptedLogin] {
30+
func listLogins() async throws -> [Login] {
3131
if shouldThrowError {
3232
struct StorageError: Error {}
3333
throw StorageError()
@@ -36,16 +36,16 @@ class MockLoginStorage: LoginStorage {
3636
try await Task.sleep(nanoseconds: 1 * NSEC_PER_SEC) // 0.5 seconds
3737

3838
// Return mock login data
39-
let mockLogins: [EncryptedLogin] = [
40-
EncryptedLogin(
39+
let mockLogins: [Login] = [
40+
Login(
4141
credentials: URLCredential(
4242
user: "test",
4343
password: "doubletest",
4444
persistence: .permanent
4545
),
4646
protectionSpace: URLProtectionSpace.fromOrigin("https://test.com")
4747
),
48-
EncryptedLogin(
48+
Login(
4949
credentials: URLCredential(
5050
user: "test",
5151
password: "doubletest",

firefox-ios/Client/Frontend/Browser/Authenticator.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import Storage
88
import Common
99

1010
import struct MozillaAppServices.LoginEntry
11-
import struct MozillaAppServices.EncryptedLogin
11+
import struct MozillaAppServices.Login
1212

1313
class Authenticator {
1414
fileprivate static let MaxAuthenticationAttempts = 3
@@ -141,14 +141,14 @@ class Authenticator {
141141
}
142142
}
143143

144-
private static func filterHttpAuthLogins(logins: [EncryptedLogin]) -> [EncryptedLogin] {
144+
private static func filterHttpAuthLogins(logins: [Login]) -> [Login] {
145145
return logins.compactMap {
146146
// HTTP Auth must have nil formSubmitUrl and a non-nil httpRealm.
147147
return $0.formSubmitUrl == nil && $0.httpRealm != nil ? $0 : nil
148148
}
149149
}
150150

151-
private static func handleDuplicatedEntries(logins: [EncryptedLogin],
151+
private static func handleDuplicatedEntries(logins: [Login],
152152
challenge: URLAuthenticationChallenge,
153153
loginsProvider: RustLogins) -> URLCredential? {
154154
let credentials = (logins.first(where: { login in
@@ -167,7 +167,7 @@ class Authenticator {
167167
return credentials
168168
}
169169

170-
private static func handleUnmatchedSchemes(logins: [EncryptedLogin],
170+
private static func handleUnmatchedSchemes(logins: [Login],
171171
challenge: URLAuthenticationChallenge,
172172
loginsProvider: RustLogins,
173173
completionHandler: @escaping (Result<URLCredential?, Error>) -> Void) {

firefox-ios/Client/Frontend/Browser/BrowserViewController/Views/BrowserViewController.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import ToolbarKit
1818

1919
import class MozillaAppServices.BookmarkFolderData
2020
import class MozillaAppServices.BookmarkItemData
21-
import struct MozillaAppServices.EncryptedLogin
21+
import struct MozillaAppServices.Login
2222
import enum MozillaAppServices.BookmarkRoots
2323
import enum MozillaAppServices.VisitType
2424

@@ -3585,11 +3585,11 @@ extension BrowserViewController: LegacyTabDelegate {
35853585
tab.addContentScript(FocusHelper(tab: tab), name: FocusHelper.name())
35863586
}
35873587

3588-
private func filterLoginsForCurrentTab(logins: [EncryptedLogin],
3588+
private func filterLoginsForCurrentTab(logins: [Login],
35893589
tabURL: URL,
3590-
field: FocusFieldType) -> [EncryptedLogin] {
3590+
field: FocusFieldType) -> [Login] {
35913591
return logins.filter { login in
3592-
if field == FocusFieldType.username && login.decryptedUsername.isEmpty { return false }
3592+
if field == FocusFieldType.username && login.username.isEmpty { return false }
35933593
guard let recordHostnameURL = URL(string: login.hostname) else { return false }
35943594
return recordHostnameURL.baseDomain == tabURL.baseDomain
35953595
}

firefox-ios/Client/Frontend/PasswordManagement/AddCredentialViewController.swift

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -114,17 +114,15 @@ class AddCredentialViewController: UIViewController, Themeable {
114114
}
115115

116116
dismiss(animated: true) {
117-
let entry = LoginEntryFlattened(
118-
id: "",
119-
hostname: hostname,
120-
password: password,
121-
username: username,
117+
self.didSaveAction(LoginEntry(
118+
origin: hostname,
122119
httpRealm: nil,
123-
formSubmitUrl: hostname,
120+
formActionOrigin: hostname,
124121
usernameField: "",
125-
passwordField: ""
122+
passwordField: "",
123+
password: password,
124+
username: username)
126125
)
127-
self.didSaveAction(LoginEntry(fromLoginEntryFlattened: entry))
128126
}
129127
}
130128

firefox-ios/Client/Frontend/PasswordManagement/LoginDataSource.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class LoginDataSource: NSObject, UITableViewDataSource {
7171
} else if let cell = tableView.dequeueReusableCell(withIdentifier: PasswordManagerTableViewCell.cellIdentifier,
7272
for: indexPath) as? PasswordManagerTableViewCell {
7373
guard let login = viewModel.loginAtIndexPath(indexPath) else { return cell }
74-
let username = login.decryptedUsername
74+
let username = login.username
7575
cell.hostnameLabel.text = login.hostname
7676
cell.usernameLabel.text = username.isEmpty ? "(no username)" : username
7777
if let breaches = viewModel.userBreaches, breaches.contains(login) {

0 commit comments

Comments
 (0)