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

Check entitlement periodically and while rekeying NetP (iOS) #2167

Merged
merged 18 commits into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from 14 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 DuckDuckGo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -13583,8 +13583,8 @@
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/duckduckgo/BrowserServicesKit";
requirement = {
kind = exactVersion;
version = 111.1.1;
branch = "anh/netp-check-entitlement-periodically";
kind = branch;
};
};
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" : "e3140633373b14b3d1fca25b098869cdaa753913",
"version" : "111.1.1"
"branch" : "anh/netp-check-entitlement-periodically",
"revision" : "fad4db675d9821a0c9bc3ba5280db4bbddff9cea"
}
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ extension EventMapping where Event == NetworkProtectionError {
domainEvent = .networkProtectionUnhandledError(function: function, line: line, error: error)
frequency = .standard
return
case .vpnAccessRevoked:
// todo
return
}

let debugEvent = DebugEvent(eventType: .custom(domainEvent))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ extension NetworkProtectionDeviceManager {
let settings = VPNSettings(defaults: .netP)
let keyStore = NetworkProtectionKeychainKeyStore()
let tokenStore = NetworkProtectionKeychainTokenStore()
return NetworkProtectionDeviceManager(environment: settings.selectedEnvironment, tokenStore: tokenStore, keyStore: keyStore, errorEvents: .networkProtectionAppDebugEvents)
return NetworkProtectionDeviceManager(environment: settings.selectedEnvironment,
tokenStore: tokenStore,
keyStore: keyStore,
errorEvents: .networkProtectionAppDebugEvents,
isSubscriptionEnabled: false)
}
}

Expand All @@ -37,14 +41,16 @@ extension NetworkProtectionCodeRedemptionCoordinator {
let settings = VPNSettings(defaults: .netP)
self.init(environment: settings.selectedEnvironment,
tokenStore: NetworkProtectionKeychainTokenStore(),
errorEvents: .networkProtectionAppDebugEvents)
errorEvents: .networkProtectionAppDebugEvents,
isSubscriptionEnabled: false)
}
}

extension NetworkProtectionKeychainTokenStore {
convenience init() {
self.init(keychainType: .default,
errorEvents: .networkProtectionAppDebugEvents)
errorEvents: .networkProtectionAppDebugEvents,
isSubscriptionEnabled: false)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,9 @@ final class NetworkProtectionTunnelController: TunnelController, TunnelSessionPr
.setDisableRekeying:
// Intentional no-op as this is handled by the extension or the agent's app delegate
break
case .setShouldShowExpiredEntitlementMessaging:
// todo
break
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,8 @@ extension NetworkProtectionLocationListCompositeRepository {
self.init(
environment: settings.selectedEnvironment,
tokenStore: NetworkProtectionKeychainTokenStore(),
errorEvents: .networkProtectionAppDebugEvents
errorEvents: .networkProtectionAppDebugEvents,
isSubscriptionEnabled: false
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@

/// This class takes care of requesting the presentation of notifications using UNNotificationCenter
///
final class NetworkProtectionUNNotificationsPresenter: NSObject, NetworkProtectionNotificationsPresenter {

Check failure on line 48 in DuckDuckGo/NetworkProtection/NetworkExtensionTargets/AppExtensionAndNotificationTargets/NetworkProtectionUNNotificationsPresenter.swift

View workflow job for this annotation

GitHub Actions / Make Release Build (DuckDuckGo Privacy Browser)

type 'NetworkProtectionUNNotificationsPresenter' does not conform to protocol 'NetworkProtectionNotificationsPresenter'

Check failure on line 48 in DuckDuckGo/NetworkProtection/NetworkExtensionTargets/AppExtensionAndNotificationTargets/NetworkProtectionUNNotificationsPresenter.swift

View workflow job for this annotation

GitHub Actions / Make Release Build (DuckDuckGo Privacy Pro)

type 'NetworkProtectionUNNotificationsPresenter' does not conform to protocol 'NetworkProtectionNotificationsPresenter'

Check failure on line 48 in DuckDuckGo/NetworkProtection/NetworkExtensionTargets/AppExtensionAndNotificationTargets/NetworkProtectionUNNotificationsPresenter.swift

View workflow job for this annotation

GitHub Actions / Test (Sandbox)

type 'NetworkProtectionUNNotificationsPresenter' does not conform to protocol 'NetworkProtectionNotificationsPresenter'

Check failure on line 48 in DuckDuckGo/NetworkProtection/NetworkExtensionTargets/AppExtensionAndNotificationTargets/NetworkProtectionUNNotificationsPresenter.swift

View workflow job for this annotation

GitHub Actions / Test (Non-Sandbox)

type 'NetworkProtectionUNNotificationsPresenter' does not conform to protocol 'NetworkProtectionNotificationsPresenter'
private static let threadIdentifier = "com.duckduckgo.NetworkProtectionNotificationsManager.threadIdentifier"

private let appLauncher: AppLauncher
Expand Down Expand Up @@ -140,6 +140,10 @@
showNotification(.test, content)
}

func showExpiredEntitlementNotification() {
// todo
}

private func showNotification(_ identifier: NetworkProtectionNotificationIdentifier, _ content: UNNotificationContent) {
let request = UNNotificationRequest(identifier: identifier.rawValue, content: content, trigger: .none)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ final class MacPacketTunnelProvider: PacketTunnelProvider {
.failedToParseLocationListResponse:
// Needs Privacy triage for macOS Geoswitching pixels
return
case .vpnAccessRevoked:
// todo
return
}

PixelKit.fire(domainEvent, frequency: .dailyAndContinuous, includeAppVersionParameter: true)
Expand Down Expand Up @@ -226,7 +229,8 @@ final class MacPacketTunnelProvider: PacketTunnelProvider {
let debugEvents = Self.networkProtectionDebugEvents(controllerErrorStore: controllerErrorStore)
let tokenStore = NetworkProtectionKeychainTokenStore(keychainType: Bundle.keychainType,
serviceName: Self.tokenServiceName,
errorEvents: debugEvents)
errorEvents: debugEvents,
isSubscriptionEnabled: false)
let notificationsPresenter = NetworkProtectionNotificationsPresenterFactory().make(settings: settings)

super.init(notificationsPresenter: notificationsPresenter,
Expand All @@ -236,7 +240,9 @@ final class MacPacketTunnelProvider: PacketTunnelProvider {
tokenStore: tokenStore,
debugEvents: debugEvents,
providerEvents: Self.packetTunnelProviderEvents,
settings: settings)
settings: settings,
isSubscriptionEnabled: false,
entitlementCheck: nil)

observeServerChanges()
observeStatusUpdateRequests()
Expand Down
2 changes: 1 addition & 1 deletion DuckDuckGoVPN/NetworkProtectionBouncer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ final class NetworkProtectionBouncer {
/// current app.
///
func requireAuthTokenOrKillApp() {
let keychainStore = NetworkProtectionKeychainTokenStore(keychainType: .default, errorEvents: nil)
let keychainStore = NetworkProtectionKeychainTokenStore(keychainType: .default, errorEvents: nil, isSubscriptionEnabled: false)

guard keychainStore.isFeatureActivated else {
os_log(.error, log: .networkProtection, "🔴 Stopping: Network Protection not authorized.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,8 @@ final class NetworkProtectionAgentNotificationsPresenter: NetworkProtectionNotif
func showTestNotification() {
notificationCenter.post(.showTestNotification)
}

func showExpiredEntitlementNotification() {
// todo
}
}
Loading