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

Adds the networkProtection remote subfeatures #483

Merged
merged 12 commits into from
Sep 3, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,11 @@ public struct AppPrivacyConfiguration: PrivacyConfiguration {
public func isSubfeatureEnabled(_ subfeature: any PrivacySubfeature,
versionProvider: AppVersionProvider,
randomizer: (Range<Double>) -> Double) -> Bool {
// TODO: Do not ship this - temporary, only for testing
if let networkProtectionSubfeature = subfeature as? NetworkProtectionSubfeature, networkProtectionSubfeature == NetworkProtectionSubfeature.waitlist {
return true
samsymons marked this conversation as resolved.
Show resolved Hide resolved
}

guard isEnabled(featureKey: subfeature.parent, versionProvider: versionProvider) else {
return false
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public enum PrivacyFeature: String {
case windowsDownloadLink
case incontextSignup
case newTabContinueSetUp
case networkProtection
case incrementalRolloutTest // Temporary feature flag for testing incremental rollouts
}

Expand All @@ -64,6 +65,15 @@ public enum AutofillSubfeature: String, PrivacySubfeature {
case autofillPasswordGeneration
}

public enum NetworkProtectionSubfeature: String, Equatable, PrivacySubfeature {
public var parent: PrivacyFeature {
.networkProtection
}

case waitlist
samsymons marked this conversation as resolved.
Show resolved Hide resolved
case waitlistBetaActive
}

public enum IncrementalRolloutTestSubfeature: String, PrivacySubfeature {
public var parent: PrivacyFeature {
.incrementalRolloutTest
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// NetworkProtectionFeatureVisibility.swift
// NetworkProtectionFeatureActivation.swift
//
// Copyright © 2023 DuckDuckGo. All rights reserved.
//
Expand All @@ -18,14 +18,14 @@

import Foundation

public protocol NetworkProtectionFeatureVisibility {
public protocol NetworkProtectionFeatureActivation {

/// Has the invite code flow been completed and an oAuth token stored?
///
var isFeatureActivated: Bool { get }
}

extension NetworkProtectionKeychainTokenStore: NetworkProtectionFeatureVisibility {
extension NetworkProtectionKeychainTokenStore: NetworkProtectionFeatureActivation {
public var isFeatureActivated: Bool {
do {
return try fetchToken() != nil
Expand Down