Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into autofill/anya-logins-…
Browse files Browse the repository at this point in the history
…to-passwords

# Conflicts:
#	DuckDuckGo/Common/Localizables/UserText.swift
  • Loading branch information
amddg44 committed Dec 8, 2023
2 parents a099432 + b4d3a3e commit 534d18e
Show file tree
Hide file tree
Showing 28 changed files with 282 additions and 394 deletions.
1 change: 1 addition & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,4 @@ excluded:
- UITests
- vendor
- DerivedData
- .ruby-lsp
2 changes: 0 additions & 2 deletions Configuration/App/AppTargetsBase.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES
CODE_SIGN_STYLE[sdk=*] = Manual
CODE_SIGN_STYLE[config=Debug][sdk=*] = Automatic

CURRENT_PROJECT_VERSION = $(MARKETING_VERSION)

ENABLE_HARDENED_RUNTIME = YES

INFOPLIST_FILE = DuckDuckGo/Info.plist
Expand Down
2 changes: 1 addition & 1 deletion Configuration/AppStore.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// limitations under the License.
//

#include "AppStoreBuildNumber.xcconfig"
#include "BuildNumber.xcconfig"

MAIN_BUNDLE_IDENTIFIER_PREFIX = com.duckduckgo.mobile.ios

Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions Configuration/Common.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
//

#include "Version.xcconfig"
#include "BuildNumber.xcconfig"

COMBINE_HIDPI_IMAGES = YES

Expand Down
2 changes: 0 additions & 2 deletions Configuration/Extensions/ExtensionBase.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES

CODE_SIGN_STYLE[sdk=*] = Manual

CURRENT_PROJECT_VERSION = $(MARKETING_VERSION)

ENABLE_HARDENED_RUNTIME = YES

PRODUCT_BUNDLE_IDENTIFIER[sdk=*] = $(BUNDLE_IDENTIFIER_PREFIX)
Expand Down
6 changes: 3 additions & 3 deletions DuckDuckGo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3214,7 +3214,7 @@
3767190128E724B2003A2A15 /* DuckPlayerURLExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DuckPlayerURLExtension.swift; sourceTree = "<group>"; };
376C4DB828A1A48A00CC0F5B /* FirePopoverViewModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FirePopoverViewModelTests.swift; sourceTree = "<group>"; };
376CC8B4296EB630006B63A7 /* AppStore.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = AppStore.xcconfig; sourceTree = "<group>"; };
376CC8B5296EBA8F006B63A7 /* AppStoreBuildNumber.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = AppStoreBuildNumber.xcconfig; sourceTree = "<group>"; };
376CC8B5296EBA8F006B63A7 /* BuildNumber.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = BuildNumber.xcconfig; sourceTree = "<group>"; };
37717E66296B5A20002FAEDF /* Global.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Global.xcconfig; sourceTree = "<group>"; };
3775912C29AAC72700E26367 /* SyncPreferences.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SyncPreferences.swift; sourceTree = "<group>"; };
3775913529AB9A1C00E26367 /* SyncManagementDialogViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SyncManagementDialogViewController.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -4757,8 +4757,8 @@
37717E66296B5A20002FAEDF /* Global.xcconfig */,
378B5888295CF2A4002C0CC0 /* Common.xcconfig */,
378B5887295CF2A4002C0CC0 /* Version.xcconfig */,
376CC8B5296EBA8F006B63A7 /* BuildNumber.xcconfig */,
376CC8B4296EB630006B63A7 /* AppStore.xcconfig */,
376CC8B5296EBA8F006B63A7 /* AppStoreBuildNumber.xcconfig */,
7B5291892A169BC90022E406 /* DeveloperID.xcconfig */,
378C76D8296842FD0092E949 /* App */,
4B4D604E2A0B293C00BCD287 /* Extensions */,
Expand Down Expand Up @@ -12752,7 +12752,7 @@
repositoryURL = "https://github.com/duckduckgo/BrowserServicesKit";
requirement = {
kind = exactVersion;
version = 92.0.3;
version = 92.0.4;
};
};
AA06B6B52672AF8100F541C5 /* XCRemoteSwiftPackageReference "Sparkle" */ = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/duckduckgo/BrowserServicesKit",
"state" : {
"revision" : "5ca0b3d915ab73de43744db40edf41c1d5060034",
"version" : "92.0.3"
"revision" : "33e55105acc9d6d69ae1326fd5c506cefb89d5cc",
"version" : "92.0.4"
}
},
{
Expand All @@ -32,8 +32,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/duckduckgo/duckduckgo-autofill.git",
"state" : {
"revision" : "93677cc02cfe650ce7f417246afd0e8e972cd83e",
"version" : "10.0.0"
"revision" : "dbecae0df07650a21b5632a92fa2e498c96af7b5",
"version" : "10.0.1"
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion DuckDuckGo/Autofill/ContentOverlayViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ extension ContentOverlayViewController: SecureVaultManagerDelegate {
}

public func secureVaultManager(_: SecureVaultManager, didRequestAuthenticationWithCompletionHandler handler: @escaping (Bool) -> Void) {
DeviceAuthenticator.shared.authenticateUser(reason: .autofill) { authenticationResult in
DeviceAuthenticator.shared.authenticateUser(reason: .autofillCreditCards) { authenticationResult in
handler(authenticationResult.authenticated)
}
}
Expand Down
4 changes: 2 additions & 2 deletions DuckDuckGo/Common/Localizables/UserText.swift
Original file line number Diff line number Diff line change
Expand Up @@ -374,8 +374,8 @@ struct UserText {
static let autofillAutoLock = NSLocalizedString("autofill.auto-lock", value: "Auto-lock", comment: "Autofill settings section title")
static let autofillLockWhenIdle = NSLocalizedString("autofill.lock-when-idle", value: "Lock autofill after computer is idle for", comment: "Autofill auto-lock setting")
static let autofillNeverLock = NSLocalizedString("autofill.never-lock", value: "Never lock autofill", comment: "Autofill auto-lock setting")
static let autofillNeverLockWarning = NSLocalizedString("autofill.never-lock-warning", value: "Anyone will access to your device will be able to use and modify your autofill data if not locked.", comment: "Autofill disabled auto-lock warning")
static let autolockLocksFormFill = NSLocalizedString("autofill.autolock-locks-form-filling", value: "Also lock access to password and credit card form fill.", comment: "Lock form filling when auto-lock is active text")
static let autofillNeverLockWarning = NSLocalizedString("autofill.never-lock-warning", value: "If not locked, anyone with access to your device will be able to use and modify your autofill data. For security purposes, credit card form fill always requires authentication.", comment: "Autofill disabled auto-lock warning")
static let autolockLocksFormFill = NSLocalizedString("autofill.autolock-locks-form-filling", value: "Also lock password form fill", comment: "Lock form filling when auto-lock is active text")


static let downloadsLocation = NSLocalizedString("downloads.location", value: "Location", comment: "Downloads directory location")
Expand Down
40 changes: 38 additions & 2 deletions DuckDuckGo/DeviceAuthentication/DeviceAuthenticator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,14 @@ final class DeviceAuthenticator: UserAuthenticating {

enum AuthenticationReason {
case autofill
case autofillCreditCards
case changeLoginsSettings
case unlockLogins
case exportLogins

var localizedDescription: String {
switch self {
case .autofill: return UserText.pmAutoLockPromptAutofill
case .autofill, .autofillCreditCards: return UserText.pmAutoLockPromptAutofill
case .changeLoginsSettings: return UserText.pmAutoLockPromptChangeLoginsSettings
case .unlockLogins: return UserText.pmAutoLockPromptUnlockLogins
case .exportLogins: return UserText.pmAutoLockPromptExportLogins
Expand All @@ -50,6 +51,7 @@ final class DeviceAuthenticator: UserAuthenticating {

internal enum Constants {
static var intervalBetweenIdleChecks: TimeInterval = 1
static var intervalBetweenCreditCardAutofillChecks: TimeInterval = 10
}

static var deviceSupportsBiometrics: Bool {
Expand Down Expand Up @@ -91,6 +93,7 @@ final class DeviceAuthenticator: UserAuthenticating {
private let queue = DispatchQueue(label: "Device Authenticator Queue")

private var timer: Timer?
private var timerCreditCard: Timer?

private var _isAuthenticating: Bool = false
private var _deviceIsLocked: Bool = false
Expand Down Expand Up @@ -144,7 +147,7 @@ final class DeviceAuthenticator: UserAuthenticating {
}

func authenticateUser(reason: AuthenticationReason, result: @escaping (DeviceAuthenticationResult) -> Void) {
guard requiresAuthentication else {
guard (reason == .autofillCreditCards && creditCardTimeIntervalExpired()) || requiresAuthentication else {
result(.success)
return
}
Expand All @@ -162,6 +165,7 @@ final class DeviceAuthenticator: UserAuthenticating {
if authenticationResult.authenticated {
// Now that the user has unlocked the device, begin the idle timer again.
self.beginIdleCheckTimer()
self.beginCreditCardAutofillTimer()
}

result(authenticationResult)
Expand Down Expand Up @@ -233,4 +237,36 @@ final class DeviceAuthenticator: UserAuthenticating {
}
}

// MARK: - Credit Card Autofill Timer

private func beginCreditCardAutofillTimer() {
os_log("Beginning credit card autofill timer", log: .autoLock)

self.timerCreditCard?.invalidate()
self.timerCreditCard = nil

let timer = Timer(timeInterval: Constants.intervalBetweenCreditCardAutofillChecks, repeats: false) { [weak self] _ in
guard let self = self else {
return
}
self.cancelCreditCardAutofillTimer()
}

self.timerCreditCard = timer
RunLoop.current.add(timer, forMode: .common)
}

private func cancelCreditCardAutofillTimer() {
os_log("Cancelling credit card autofill timer", log: .autoLock)
self.timerCreditCard?.invalidate()
self.timerCreditCard = nil
}

private func creditCardTimeIntervalExpired() -> Bool {
guard let timer = timerCreditCard else {
return true
}
return timer.timeInterval >= Constants.intervalBetweenCreditCardAutofillChecks
}

}
1 change: 1 addition & 0 deletions DuckDuckGo/Tab/View/BrowserTabViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,7 @@ final class BrowserTabViewController: NSViewController {
bookmarksViewController?.removeCompletely()
#if DBP
dataBrokerProtectionHomeViewController?.removeCompletely()
dataBrokerProtectionHomeViewController = nil
#endif
if includingWebView {
self.removeWebViewFromHierarchy()
Expand Down
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
source 'https://rubygems.org'

gem 'fastlane', '2.217.0'
gem 'httparty'
5 changes: 5 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,17 @@ GEM
highline (2.0.3)
http-cookie (1.0.5)
domain_name (~> 0.5)
httparty (0.21.0)
mini_mime (>= 1.0.0)
multi_xml (>= 0.5.2)
httpclient (2.8.3)
jmespath (1.6.2)
json (2.6.3)
jwt (2.7.1)
mini_magick (4.12.0)
mini_mime (1.1.5)
multi_json (1.15.0)
multi_xml (0.6.0)
multipart-post (2.3.0)
nanaimo (0.3.0)
naturally (2.2.1)
Expand Down Expand Up @@ -208,6 +212,7 @@ PLATFORMS

DEPENDENCIES
fastlane (= 2.217.0)
httparty

BUNDLED WITH
2.3.26
2 changes: 1 addition & 1 deletion LocalPackages/Account/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ let package = Package(
targets: ["Account"]),
],
dependencies: [
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "92.0.3"),
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "92.0.4"),
.package(path: "../Purchase")
],
targets: [
Expand Down
2 changes: 1 addition & 1 deletion LocalPackages/DataBrokerProtection/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ let package = Package(
targets: ["DataBrokerProtection"])
],
dependencies: [
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "92.0.3"),
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "92.0.4"),
.package(path: "../PixelKit"),
.package(path: "../SwiftUIExtensions"),
.package(path: "../XPCHelper")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,9 @@ fileprivate extension Array where Element == BrokerProfileQueryData {
guard let broker = self.first?.dataBroker else { return 0 }

let areAllQueriesDeprecated = allSatisfy { $0.profileQuery.deprecated }
let areAllQueriesNotStartedScanning = allSatisfy { $0.scanOperationData.lastRunDate == nil }
let didAllQueriesFinished = allSatisfy { $0.scanOperationData.lastRunDate != nil }

if areAllQueriesDeprecated || areAllQueriesNotStartedScanning {
if areAllQueriesDeprecated || !didAllQueriesFinished {
return 0
} else {
return 1 + broker.mirrorSites.filter { $0.shouldWeIncludeMirrorSite() }.count
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ final class MapperToUITests: XCTestCase {
XCTAssertEqual(result.scanProgress.totalScans, 2)
}

func testWhenAScanRanOnOneBroker_thenCurrentScansReflectsThatScansWereDoneOnThatBroker() {
func testWhenAScanRanOnAllProfileQueriesOnTheSameBroker_thenCurrentScansReflectsThatScansWereDoneOnThatBroker() {
let brokerProfileQueryData: [BrokerProfileQueryData] = [
.mock(dataBrokerName: "Broker #1"),
.mock(dataBrokerName: "Broker #1", lastRunDate: Date()),
.mock(dataBrokerName: "Broker #1", lastRunDate: Date()),
.mock(dataBrokerName: "Broker #2")
]
Expand Down Expand Up @@ -205,10 +205,15 @@ final class MapperToUITests: XCTestCase {

func testWhenMirrorSiteIsInRemovedPeriod_thenItShouldNotBeAddedToCurrentScans() {
let brokerWithMirrorSiteRemovedAndWithScan = BrokerProfileQueryData.mock(
dataBrokerName: "Broker #2",
lastRunDate: Date(),
mirrorSites: [.init(name: "mirror", addedAt: Date(), removedAt: Date().yesterday)]
)
let brokerProfileQueryData: [BrokerProfileQueryData] = [.mock(), .mock(), brokerWithMirrorSiteRemovedAndWithScan]
let brokerProfileQueryData: [BrokerProfileQueryData] = [
.mock(dataBrokerName: "Broker #1"),
.mock(dataBrokerName: "Broker #1"),
brokerWithMirrorSiteRemovedAndWithScan
]

let result = sut.initialScanState(brokerProfileQueryData)

Expand Down
2 changes: 1 addition & 1 deletion LocalPackages/NetworkProtectionMac/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ let package = Package(
.library(name: "NetworkProtectionUI", targets: ["NetworkProtectionUI"])
],
dependencies: [
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "92.0.3"),
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "92.0.4"),
.package(path: "../XPCHelper"),
.package(path: "../SwiftUIExtensions")
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ import SwiftUI
import CoreImage

struct QRCode: View {
@Environment(\.colorScheme) var colorScheme

let string: String
let size: CGSize

Expand Down Expand Up @@ -58,8 +56,8 @@ struct QRCode: View {
}

let colorParameters: [String: Any] = [
"inputColor0": CIColor(color: colorScheme == .light ? NSColor.black : NSColor.white)!,
"inputColor1": CIColor(color: NSColor.clear)!
"inputColor0": CIColor(color: NSColor.black)!,
"inputColor1": CIColor(color: NSColor.white)!
]
let coloredImage = outputImage.applyingFilter("CIFalseColor", parameters: colorParameters)

Expand Down
Loading

0 comments on commit 534d18e

Please sign in to comment.