Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to AutofillCredentialIdentityStoreManager for lazy vault initialisation #3763

Merged
merged 5 commits into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,11 @@ class CredentialProviderViewController: ASCredentialProviderViewController {
private lazy var authenticator = UserAuthenticator(reason: UserText.credentialProviderListAuthenticationReason,
cancelTitle: UserText.credentialProviderListAuthenticationCancelButton)

private lazy var credentialIdentityStoreManager: AutofillCredentialIdentityStoreManaging = AutofillCredentialIdentityStoreManager(credentialStore: ASCredentialIdentityStore.shared,
vault: secureVault,
tld: tld)
private lazy var credentialIdentityStoreManager: AutofillCredentialIdentityStoreManaging = AutofillCredentialIdentityStoreManager(
credentialStore: ASCredentialIdentityStore.shared,
vault: secureVault,
reporter: SecureVaultReporter(),
tld: tld)

private lazy var secureVault: (any AutofillSecureVault)? = {
if findKeychainItemsWithV4() {
Expand Down
3 changes: 1 addition & 2 deletions Core/SyncCredentialsAdapter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ public final class SyncCredentialsAdapter {
secureVaultErrorReporter: secureVaultErrorReporter,
errorEvents: CredentialsCleanupErrorHandling()
)
credentialIdentityStoreManager = AutofillCredentialIdentityStoreManager(
vault: try? secureVaultFactory.makeVault(reporter: secureVaultErrorReporter), tld: tld)
credentialIdentityStoreManager = AutofillCredentialIdentityStoreManager(reporter: secureVaultErrorReporter, tld: tld)
}

public func cleanUpDatabaseAndUpdateSchedule(shouldEnable: Bool) {
Expand Down
2 changes: 1 addition & 1 deletion DuckDuckGo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -11865,7 +11865,7 @@
repositoryURL = "https://github.com/DuckDuckGo/BrowserServicesKit";
requirement = {
kind = exactVersion;
version = 224.0.0;
version = 224.1.0;
};
};
9F8FE9472BAE50E50071E372 /* XCRemoteSwiftPackageReference "lottie-spm" */ = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/DuckDuckGo/BrowserServicesKit",
"state" : {
"revision" : "bb43f0c2a489d7eed4b33baf2201f9b2b6512588",
"version" : "224.0.0"
"revision" : "14384f05a6e43842c4626e06736e2c4f5d758057",
"version" : "224.1.0"
}
},
{
Expand All @@ -59,8 +59,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/duckduckgo/duckduckgo-autofill.git",
"state" : {
"revision" : "88982a3802ac504e2f1a118a73bfdf2d8f4a7735",
"version" : "16.0.0"
"revision" : "47c26dc32b94cdbcef3e6157497147917678c25c",
"version" : "16.1.0"
}
},
{
Expand Down
4 changes: 3 additions & 1 deletion DuckDuckGo/AutofillLoginListViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ final class AutofillLoginListViewModel: ObservableObject {
return settings["monitorIntervalDays"] as? Int ?? 42
}()

private lazy var credentialIdentityStoreManager: AutofillCredentialIdentityStoreManaging = AutofillCredentialIdentityStoreManager(vault: secureVault, tld: tld)
private lazy var credentialIdentityStoreManager: AutofillCredentialIdentityStoreManaging = AutofillCredentialIdentityStoreManager(vault: secureVault,
reporter: SecureVaultReporter(),
tld: tld)

private lazy var syncPromoManager: SyncPromoManaging = SyncPromoManager(syncService: syncService)

Expand Down
10 changes: 3 additions & 7 deletions DuckDuckGo/AutofillUsageMonitor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,8 @@ import BrowserServicesKit

final class AutofillUsageMonitor {

private lazy var credentialIdentityStoreManager: AutofillCredentialIdentityStoreManager? = {
guard let vault = try? AutofillSecureVaultFactory.makeVault(reporter: SecureVaultReporter()) else {
return nil
}

return AutofillCredentialIdentityStoreManager(vault: vault,
private lazy var credentialIdentityStoreManager: AutofillCredentialIdentityStoreManager = {
return AutofillCredentialIdentityStoreManager(reporter: SecureVaultReporter(),
tld: AppDependencyProvider.shared.storageCache.tld)
}()

Expand All @@ -43,7 +39,7 @@ final class AutofillUsageMonitor {
if state.isEnabled {
if self?.autofillExtensionEnabled == nil {
Task {
await self?.credentialIdentityStoreManager?.populateCredentialStore()
await self?.credentialIdentityStoreManager.populateCredentialStore()
}
}
self?.autofillExtensionEnabled = true
Expand Down
12 changes: 4 additions & 8 deletions DuckDuckGo/TabViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -276,12 +276,8 @@ class TabViewController: UIViewController {
return manager
}()

private lazy var credentialIdentityStoreManager: AutofillCredentialIdentityStoreManager? = {
guard let vault = try? AutofillSecureVaultFactory.makeVault(reporter: SecureVaultReporter()) else {
return nil
}

return AutofillCredentialIdentityStoreManager(vault: vault,
private lazy var credentialIdentityStoreManager: AutofillCredentialIdentityStoreManager = {
return AutofillCredentialIdentityStoreManager(reporter: SecureVaultReporter(),
tld: AppDependencyProvider.shared.storageCache.tld)
}()

Expand Down Expand Up @@ -2851,7 +2847,7 @@ extension TabViewController: SecureVaultManagerDelegate {

guard let domain = account?.domain else { return }
Task {
await self?.credentialIdentityStoreManager?.updateCredentialStore(for: domain)
await self?.credentialIdentityStoreManager.updateCredentialStore(for: domain)
}
} completionHandler: { account in
if account != nil {
Expand Down Expand Up @@ -3049,7 +3045,7 @@ extension TabViewController: SaveLoginViewControllerDelegate {

guard let domain = newCredential.account.domain else { return }
Task {
await credentialIdentityStoreManager?.updateCredentialStore(for: domain)
await credentialIdentityStoreManager.updateCredentialStore(for: domain)
}
}
} catch {
Expand Down
Loading