diff --git a/Core/PixelEvent.swift b/Core/PixelEvent.swift index 8e449ec840..92abe4c7ac 100644 --- a/Core/PixelEvent.swift +++ b/Core/PixelEvent.swift @@ -312,6 +312,7 @@ extension Pixel { case networkProtectionKeychainErrorFailedToCastKeychainValueToData case networkProtectionKeychainReadError case networkProtectionKeychainWriteError + case networkProtectionKeychainUpdateError case networkProtectionKeychainDeleteError case networkProtectionWireguardErrorCannotLocateTunnelFileDescriptor @@ -810,6 +811,7 @@ extension Pixel.Event { case .networkProtectionKeychainErrorFailedToCastKeychainValueToData: return "m_netp_keychain_error_failed_to_cast_keychain_value_to_data" case .networkProtectionKeychainReadError: return "m_netp_keychain_error_read_failed" case .networkProtectionKeychainWriteError: return "m_netp_keychain_error_write_failed" + case .networkProtectionKeychainUpdateError: return "m_netp_keychain_error_update_failed" case .networkProtectionKeychainDeleteError: return "m_netp_keychain_error_delete_failed" case .networkProtectionWireguardErrorCannotLocateTunnelFileDescriptor: return "m_netp_wireguard_error_cannot_locate_tunnel_file_descriptor" case .networkProtectionWireguardErrorInvalidState: return "m_netp_wireguard_error_invalid_state" diff --git a/DuckDuckGo.xcodeproj/project.pbxproj b/DuckDuckGo.xcodeproj/project.pbxproj index 15116bfef5..9d2f358bca 100644 --- a/DuckDuckGo.xcodeproj/project.pbxproj +++ b/DuckDuckGo.xcodeproj/project.pbxproj @@ -9977,7 +9977,7 @@ repositoryURL = "https://github.com/DuckDuckGo/BrowserServicesKit"; requirement = { kind = exactVersion; - version = 103.0.2; + version = 104.0.0; }; }; C14882EB27F211A000D59F0C /* XCRemoteSwiftPackageReference "SwiftSoup" */ = { diff --git a/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 380a78393d..b0872e7a5c 100644 --- a/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -14,8 +14,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/DuckDuckGo/BrowserServicesKit", "state" : { - "revision" : "1f7a1b5fe1c404d331fe34e55c99296828107c1d", - "version" : "103.0.2" + "revision" : "872090e651ad8e26ca9903a95f3d094b21d48e23", + "version" : "104.0.0" } }, { diff --git a/DuckDuckGo/AppDelegate+Waitlists.swift b/DuckDuckGo/AppDelegate+Waitlists.swift index 598131d836..9370756149 100644 --- a/DuckDuckGo/AppDelegate+Waitlists.swift +++ b/DuckDuckGo/AppDelegate+Waitlists.swift @@ -51,7 +51,7 @@ extension AppDelegate { VPNWaitlist.shared.fetchInviteCodeIfAvailable { [weak self] error in guard error == nil else { #if !DEBUG - if error == .alreadyHasInviteCode { + if error == .alreadyHasInviteCode, UIApplication.shared.applicationState == .active { // If the user already has an invite code but their auth token has gone missing, attempt to redeem it again. let tokenStore = NetworkProtectionKeychainTokenStore() let waitlistStorage = VPNWaitlist.shared.waitlistStorage diff --git a/DuckDuckGo/EventMapping+NetworkProtectionError.swift b/DuckDuckGo/EventMapping+NetworkProtectionError.swift index a139b4c9a2..2f465c4113 100644 --- a/DuckDuckGo/EventMapping+NetworkProtectionError.swift +++ b/DuckDuckGo/EventMapping+NetworkProtectionError.swift @@ -61,6 +61,10 @@ extension EventMapping where Event == NetworkProtectionError { pixelEvent = .networkProtectionKeychainWriteError params[PixelParameters.keychainFieldName] = field params[PixelParameters.keychainErrorCode] = String(status) + case .keychainUpdateError(field: let field, status: let status): + pixelEvent = .networkProtectionKeychainUpdateError + params[PixelParameters.keychainFieldName] = field + params[PixelParameters.keychainErrorCode] = String(status) case .keychainDeleteError(status: let status): pixelEvent = .networkProtectionKeychainDeleteError params[PixelParameters.keychainErrorCode] = String(status) diff --git a/DuckDuckGo/KeychainItemsDebugViewController.swift b/DuckDuckGo/KeychainItemsDebugViewController.swift index 8caa29ec13..86bdf02dd0 100644 --- a/DuckDuckGo/KeychainItemsDebugViewController.swift +++ b/DuckDuckGo/KeychainItemsDebugViewController.swift @@ -26,6 +26,7 @@ private struct KeychainItem { let secClass: SecClass let service: String? let account: String? + let accessGroup: String? let valueData: Data? let creationDate: Any? let modificationDate: Any? @@ -39,6 +40,7 @@ private struct KeychainItem { return """ Service: \(service ?? "nil") Account: \(account ?? "nil") + Access Group: \(accessGroup ?? "nil") Value as String: \(value ?? "nil") Value data: \(String(describing: valueData)) Creation date: \(String(describing: creationDate)) @@ -54,7 +56,8 @@ private enum SecClass: CaseIterable { case classCertificate case classKey case classIdentity - + case accessGroup + var secClassCFString: CFString { switch self { case .internetPassword: @@ -67,6 +70,8 @@ private enum SecClass: CaseIterable { return kSecClassKey case .classIdentity: return kSecClassIdentity + case .accessGroup: + return kSecAttrAccessGroup } } @@ -82,6 +87,8 @@ private enum SecClass: CaseIterable { return "kSecClassKey" case .classIdentity: return "kSecClassIdentity" + case .accessGroup: + return "kSecAttrAccessGroup" } } @@ -106,6 +113,7 @@ private enum SecClass: CaseIterable { KeychainItem(secClass: self, service: $0[kSecAttrService as String] as? String, account: $0[kSecAttrAccount as String] as? String, + accessGroup: $0[kSecAttrAccessGroup as String] as? String, valueData: $0[kSecValueData as String] as? Data, creationDate: $0[kSecAttrCreationDate as String, default: "no creation"], modificationDate: $0[kSecAttrModificationDate as String, default: "no modification"]) diff --git a/DuckDuckGo/MainViewController.swift b/DuckDuckGo/MainViewController.swift index ea83e4a139..85a9d33e09 100644 --- a/DuckDuckGo/MainViewController.swift +++ b/DuckDuckGo/MainViewController.swift @@ -252,7 +252,7 @@ class MainViewController: UIViewController { addLaunchTabNotificationObserver() subscribeToEmailProtectionStatusNotifications() -#if NETWORK_PROTECTION +#if NETWORK_PROTECTION && SUBSCRIPTION subscribeToNetworkProtectionSubscriptionEvents() #endif @@ -1238,7 +1238,7 @@ class MainViewController: UIViewController { .store(in: &emailCancellables) } -#if NETWORK_PROTECTION +#if NETWORK_PROTECTION && SUBSCRIPTION private func subscribeToNetworkProtectionSubscriptionEvents() { NotificationCenter.default.publisher(for: .accountDidSignIn) .receive(on: DispatchQueue.main) diff --git a/DuckDuckGo/NetworkProtectionConvenienceInitialisers.swift b/DuckDuckGo/NetworkProtectionConvenienceInitialisers.swift index 18e83a83a9..8698a6df68 100644 --- a/DuckDuckGo/NetworkProtectionConvenienceInitialisers.swift +++ b/DuckDuckGo/NetworkProtectionConvenienceInitialisers.swift @@ -53,11 +53,12 @@ extension NetworkProtectionKeychainTokenStore { } extension NetworkProtectionCodeRedemptionCoordinator { - convenience init() { + convenience init(isManualCodeRedemptionFlow: Bool = false) { let settings = VPNSettings(defaults: .networkProtectionGroupDefaults) self.init( environment: settings.selectedEnvironment, tokenStore: NetworkProtectionKeychainTokenStore(), + isManualCodeRedemptionFlow: isManualCodeRedemptionFlow, errorEvents: .networkProtectionAppDebugEvents ) } diff --git a/DuckDuckGo/NetworkProtectionInviteViewModel.swift b/DuckDuckGo/NetworkProtectionInviteViewModel.swift index 62b82becb7..0ee06a582e 100644 --- a/DuckDuckGo/NetworkProtectionInviteViewModel.swift +++ b/DuckDuckGo/NetworkProtectionInviteViewModel.swift @@ -84,19 +84,6 @@ final class NetworkProtectionInviteViewModel: ObservableObject { completion() } - // MARK: Dev only. Will be removed during https://app.asana.com/0/0/1205084446087078/f - - @MainActor - func clear() async { - errorText = "" - do { - try NetworkProtectionKeychainTokenStore().deleteToken() - updateAuthenticatedText() - } catch { - errorText = "Could not clear token" - } - } - @Published var redeemedText: String? private func updateAuthenticatedText() { diff --git a/DuckDuckGo/NetworkProtectionRootView.swift b/DuckDuckGo/NetworkProtectionRootView.swift index 0ec4d60535..0be2ed7b31 100644 --- a/DuckDuckGo/NetworkProtectionRootView.swift +++ b/DuckDuckGo/NetworkProtectionRootView.swift @@ -29,7 +29,7 @@ struct NetworkProtectionRootView: View { var body: some View { let inviteViewModel = NetworkProtectionInviteViewModel( - redemptionCoordinator: NetworkProtectionCodeRedemptionCoordinator(), + redemptionCoordinator: NetworkProtectionCodeRedemptionCoordinator(isManualCodeRedemptionFlow: true), completion: inviteCompletion ) switch model.initialViewKind { diff --git a/LocalPackages/DuckUI/Package.swift b/LocalPackages/DuckUI/Package.swift index 7ce1b6c05c..5444c96dd6 100644 --- a/LocalPackages/DuckUI/Package.swift +++ b/LocalPackages/DuckUI/Package.swift @@ -31,7 +31,7 @@ let package = Package( targets: ["DuckUI"]) ], dependencies: [ - .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "103.0.2"), + .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "104.0.0"), ], targets: [ .target( diff --git a/LocalPackages/SyncUI/Package.swift b/LocalPackages/SyncUI/Package.swift index 01b217c311..010012fb5c 100644 --- a/LocalPackages/SyncUI/Package.swift +++ b/LocalPackages/SyncUI/Package.swift @@ -33,7 +33,7 @@ let package = Package( ], dependencies: [ .package(path: "../DuckUI"), - .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "103.0.2"), + .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "104.0.0"), .package(url: "https://github.com/duckduckgo/DesignResourcesKit", exact: "2.0.0") ], targets: [ diff --git a/LocalPackages/Waitlist/Package.swift b/LocalPackages/Waitlist/Package.swift index 077881488e..e3ce289fce 100644 --- a/LocalPackages/Waitlist/Package.swift +++ b/LocalPackages/Waitlist/Package.swift @@ -15,7 +15,7 @@ let package = Package( targets: ["Waitlist", "WaitlistMocks"]) ], dependencies: [ - .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "103.0.2"), + .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "104.0.0"), .package(url: "https://github.com/duckduckgo/DesignResourcesKit", exact: "2.0.0") ], targets: [ diff --git a/PacketTunnelProvider/NetworkProtection/NetworkProtectionPacketTunnelProvider.swift b/PacketTunnelProvider/NetworkProtection/NetworkProtectionPacketTunnelProvider.swift index 180342ab9c..f127d65a7d 100644 --- a/PacketTunnelProvider/NetworkProtection/NetworkProtectionPacketTunnelProvider.swift +++ b/PacketTunnelProvider/NetworkProtection/NetworkProtectionPacketTunnelProvider.swift @@ -140,6 +140,10 @@ final class NetworkProtectionPacketTunnelProvider: PacketTunnelProvider { pixelEvent = .networkProtectionKeychainWriteError params[PixelParameters.keychainFieldName] = field params[PixelParameters.keychainErrorCode] = String(status) + case .keychainUpdateError(let field, let status): + pixelEvent = .networkProtectionKeychainUpdateError + params[PixelParameters.keychainFieldName] = field + params[PixelParameters.keychainErrorCode] = String(status) case .keychainDeleteError(let status): // TODO: Check whether field needed here pixelEvent = .networkProtectionKeychainDeleteError params[PixelParameters.keychainErrorCode] = String(status)