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

Password manager survey update #811

Merged
merged 2 commits into from
May 9, 2024
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
4 changes: 2 additions & 2 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/duckduckgo/duckduckgo-autofill.git",
"state" : {
"revision" : "6053999d6af384a716ab0ce7205dbab5d70ed1b3",
"version" : "11.0.1"
"revision" : "10aeff1ec7f533d1705233a9b14f9393a699b1c0",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is an update to the Autofill JS version as the survey was triggering 'Save Login' prompts when completing it

"version" : "11.0.2"
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ let package = Package(
.library(name: "PixelKitTestingUtilities", targets: ["PixelKitTestingUtilities"]),
],
dependencies: [
.package(url: "https://github.com/duckduckgo/duckduckgo-autofill.git", exact: "11.0.1"),
.package(url: "https://github.com/duckduckgo/duckduckgo-autofill.git", exact: "11.0.2"),
.package(url: "https://github.com/duckduckgo/GRDB.swift.git", exact: "2.3.0"),
.package(url: "https://github.com/duckduckgo/TrackerRadarKit", exact: "2.0.0"),
.package(url: "https://github.com/duckduckgo/sync_crypto", exact: "0.2.0"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import SecureStorage
public protocol AutofillDatabaseProvider: SecureStorageDatabaseProvider {

func accounts() throws -> [SecureVaultModels.WebsiteAccount]
func accountsCount() throws -> Int
func hasAccountFor(username: String?, domain: String?) throws -> Bool

@discardableResult
Expand Down Expand Up @@ -119,6 +120,13 @@ public final class DefaultAutofillDatabaseProvider: GRDBSecureStorageDatabasePro
}
}

public func accountsCount() throws -> Int {
let count = try db.read {
try SecureVaultModels.WebsiteAccount.fetchCount($0)
}
return count
}

public func hasAccountFor(username: String?, domain: String?) throws -> Bool {
let account = try db.read {
try SecureVaultModels.WebsiteAccount
Expand Down
29 changes: 29 additions & 0 deletions Sources/BrowserServicesKit/SecureVault/AutofillSecureVault.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ public protocol AutofillSecureVault: SecureVault {
func resetL2Password(oldPassword: Data?, newPassword: Data) throws

func accounts() throws -> [SecureVaultModels.WebsiteAccount]
func accountsCount() throws -> Int
func accountsCountBucket() throws -> String
func accountsFor(domain: String) throws -> [SecureVaultModels.WebsiteAccount]
func accountsWithPartialMatchesFor(eTLDplus1: String) throws -> [SecureVaultModels.WebsiteAccount]
func hasAccountFor(username: String?, domain: String?) throws -> Bool
Expand Down Expand Up @@ -228,6 +230,33 @@ public class DefaultAutofillSecureVault<T: AutofillDatabaseProvider>: AutofillSe
}
}

public func accountsCount() throws -> Int {
lock.lock()
defer {
lock.unlock()
}

do {
return try self.providers.database.accountsCount()
} catch {
throw SecureStorageError.databaseError(cause: error)
}
}

public func accountsCountBucket() throws -> String {
let accountsCount = try accountsCount()

if accountsCount < 3 {
return "none"
} else if accountsCount < 11 {
return "some"
} else if accountsCount < 50 {
return "many"
} else {
return "lots"
}
}

public func accountsFor(domain: String) throws -> [SecureVaultModels.WebsiteAccount] {
lock.lock()
defer {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ internal class MockAutofillDatabaseProvider: AutofillDatabaseProvider {
return _accounts
}

func accountsCount() throws -> Int {
return _accounts.count
}

func notes() throws -> [SecureVaultModels.Note] {
return _notes
}
Expand Down
Loading