From 64f856b717ee442b217d766d71c3c85ea7586152 Mon Sep 17 00:00:00 2001 From: Shane Osbourne Date: Tue, 19 Nov 2024 15:58:00 +0000 Subject: [PATCH] [macos] adding support for message bridge (#3558) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task/Issue URL: https://app.asana.com/0/0/1208773745506350/f Tech Design URL: CC: **Description**: See the Asana task for more details - but a short version is that a recent change in C-S-S requires another UUID - I deliberately DO NOT want to re-use `sessionKey`, since that's used in other places already and it would be unclear when/where we could change this. - name: `messageSecret` was chosen to match what android already use - where: I placed this on ContentScopePreferences because it gets serialized as JSON into our scripts and is already used for such things - Again, it also matches Android **Steps to test this PR**: (👀 VIDEO below) 1. Use the debug menu to set the AI Chat -> Web Communication -> Set Custom URL - set it to `https://bridge-example.netlify.app/ai-chat.html` 3. Now override remote config to use: - `https://bridge-example.netlify.app/ai-chat.json` 4. visit https://bridge-example.netlify.app/ai-chat.html 5. verify settings are opened 6. verify the data is fetched --- AI Chat -> Web Communication -> Set Custom URL Screenshot 2024-11-15 at 10 42 17 AM https://github.com/user-attachments/assets/9b197aca-965d-4541-9d4b-70b066fc352e **Definition of Done**: * [x] Does this PR satisfy our [Definition of Done](https://app.asana.com/0/1202500774821704/1207634633537039/f)? --- ###### Internal references: [Pull Request Review Checklist](https://app.asana.com/0/1202500774821704/1203764234894239/f) [Software Engineering Expectations](https://app.asana.com/0/59792373528535/199064865822552) [Technical Design Template](https://app.asana.com/0/59792373528535/184709971311943) [Pull Request Documentation](https://app.asana.com/0/1202500774821704/1204012835277482/f) 3. - 8. change the message or4. change the message or **Definition of Done**:**Definition of Done**: * [ ] Does this PR satisfy our [Definition of Done](https://app.asana.com/0/1202500774821704/1207634633537039/f)?* [ ] Does this PR satisfy our [Definition of Done](https://app.asana.com/0/1202500774821704/1207634633537039/f)? ------ ###### Internal references:###### Internal references: [Pull Request Review Checklist](https://app.asana.com/0/1202500774821704/1203764234894239/f)[Pull Request Review Checklist](https://app.asana.com/0/1202500774821704/1203764234894239/f) [Software Engineering Expectations](https://app.asana.com/0/59792373528535/199064865822552)[Software Engineering Expectations](https://app.asana.com/0/59792373528535/199064865822552) [Technical Design Template](https://app.asana.com/0/59792373528535/184709971311943)[Technical Design Template](https://app.asana.com/0/59792373528535/184709971311943) [Pull Request Documentation](https://app.asana.com/0/1202500774821704/1204012835277482/f)[Pull Request Documentation](https://app.asana.com/0/1202500774821704/1204012835277482/f) Co-authored-by: Shane Osbourne --- DuckDuckGo.xcodeproj/project.pbxproj | 2 +- .../xcshareddata/swiftpm/Package.resolved | 12 ++++++------ .../Autofill/ContentOverlayViewController.swift | 1 + .../ContentBlocker/ScriptSourceProviding.swift | 4 ++++ DuckDuckGo/DBP/DBPHomeViewController.swift | 2 ++ .../Tab/TabExtensions/AutofillTabExtension.swift | 1 + DuckDuckGo/Tab/UserScripts/UserScripts.swift | 2 ++ .../DataBrokerProtectionBackgroundManager.swift | 2 ++ LocalPackages/DataBrokerProtection/Package.swift | 2 +- .../DebugUI/DataBrokerRunCustomJSONViewModel.swift | 2 ++ .../Scheduler/DataBrokerProtectionAgentManager.swift | 1 + .../Tests/DataBrokerProtectionTests/Mocks.swift | 1 + LocalPackages/FeatureFlags/Package.swift | 2 +- LocalPackages/NetworkProtectionMac/Package.swift | 2 +- LocalPackages/SubscriptionUI/Package.swift | 2 +- 15 files changed, 27 insertions(+), 11 deletions(-) diff --git a/DuckDuckGo.xcodeproj/project.pbxproj b/DuckDuckGo.xcodeproj/project.pbxproj index 6b91a1ec2b..5d03de7631 100644 --- a/DuckDuckGo.xcodeproj/project.pbxproj +++ b/DuckDuckGo.xcodeproj/project.pbxproj @@ -15097,7 +15097,7 @@ repositoryURL = "https://github.com/duckduckgo/BrowserServicesKit"; requirement = { kind = exactVersion; - version = 210.0.3; + version = 211.0.0; }; }; 9FF521422BAA8FF300B9819B /* XCRemoteSwiftPackageReference "lottie-spm" */ = { diff --git a/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 265c376704..dd114e5ceb 100644 --- a/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -32,8 +32,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/duckduckgo/BrowserServicesKit", "state" : { - "revision" : "a296f015a572fdfe53a81de653efb9a6d7fc3eba", - "version" : "210.0.3" + "revision" : "7033b0d6f166ac8152cff602f1a1301641f4da60", + "version" : "211.0.0" } }, { @@ -41,8 +41,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/duckduckgo/content-scope-scripts", "state" : { - "revision" : "adca39c379b1a124f9990e9d0308c374f32f5018", - "version" : "6.32.0" + "revision" : "f2caf4ff814f4714d07d6fc2cf02498cb54a1389", + "version" : "6.36.0" } }, { @@ -104,8 +104,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/duckduckgo/privacy-dashboard", "state" : { - "revision" : "53fd1a0f8d91fcf475d9220f810141007300dffd", - "version" : "7.1.1" + "revision" : "757bbbae1e2afbb421caee9bfca04ee5c56c3af8", + "version" : "7.2.0" } }, { diff --git a/DuckDuckGo/Autofill/ContentOverlayViewController.swift b/DuckDuckGo/Autofill/ContentOverlayViewController.swift index f4e4b5d12e..9490c14df4 100644 --- a/DuckDuckGo/Autofill/ContentOverlayViewController.swift +++ b/DuckDuckGo/Autofill/ContentOverlayViewController.swift @@ -366,6 +366,7 @@ extension ContentOverlayViewController: SecureVaultManagerDelegate { let isGPCEnabled = WebTrackingProtectionPreferences.shared.isGPCEnabled let properties = ContentScopeProperties(gpcEnabled: isGPCEnabled, sessionKey: topAutofillUserScript?.sessionKey ?? "", + messageSecret: topAutofillUserScript?.messageSecret ?? "", featureToggles: ContentScopeFeatureToggles.supportedFeaturesOnMacOS(privacyConfigurationManager.privacyConfig)) let runtimeConfiguration = DefaultAutofillSourceProvider.Builder(privacyConfigurationManager: privacyConfigurationManager, diff --git a/DuckDuckGo/ContentBlocker/ScriptSourceProviding.swift b/DuckDuckGo/ContentBlocker/ScriptSourceProviding.swift index 4e3cad6696..accea0a6ab 100644 --- a/DuckDuckGo/ContentBlocker/ScriptSourceProviding.swift +++ b/DuckDuckGo/ContentBlocker/ScriptSourceProviding.swift @@ -30,6 +30,7 @@ protocol ScriptSourceProviding { var privacyConfigurationManager: PrivacyConfigurationManaging { get } var autofillSourceProvider: AutofillUserScriptSourceProvider? { get } var sessionKey: String? { get } + var messageSecret: String? { get } var onboardingActionsManager: OnboardingActionsManaging? { get } func buildAutofillSource() -> AutofillUserScriptSourceProvider @@ -47,6 +48,7 @@ struct ScriptSourceProvider: ScriptSourceProviding { private(set) var onboardingActionsManager: OnboardingActionsManaging? private(set) var autofillSourceProvider: AutofillUserScriptSourceProvider? private(set) var sessionKey: String? + private(set) var messageSecret: String? let configStorage: ConfigurationStoring let privacyConfigurationManager: PrivacyConfigurationManaging @@ -73,6 +75,7 @@ struct ScriptSourceProvider: ScriptSourceProviding { self.contentBlockerRulesConfig = buildContentBlockerRulesConfig() self.surrogatesConfig = buildSurrogatesConfig() self.sessionKey = generateSessionKey() + self.messageSecret = generateSessionKey() self.autofillSourceProvider = buildAutofillSource() self.onboardingActionsManager = buildOnboardingActionsManager() } @@ -86,6 +89,7 @@ struct ScriptSourceProvider: ScriptSourceProviding { return DefaultAutofillSourceProvider.Builder(privacyConfigurationManager: privacyConfigurationManager, properties: ContentScopeProperties(gpcEnabled: webTrakcingProtectionPreferences.isGPCEnabled, sessionKey: self.sessionKey ?? "", + messageSecret: self.messageSecret ?? "", featureToggles: ContentScopeFeatureToggles.supportedFeaturesOnMacOS(privacyConfig)), isDebug: AutofillPreferences().debugScriptEnabled) .withJSLoading() diff --git a/DuckDuckGo/DBP/DBPHomeViewController.swift b/DuckDuckGo/DBP/DBPHomeViewController.swift index d9d2e8e18b..96443a61f1 100644 --- a/DuckDuckGo/DBP/DBPHomeViewController.swift +++ b/DuckDuckGo/DBP/DBPHomeViewController.swift @@ -56,8 +56,10 @@ final class DBPHomeViewController: NSViewController { let isGPCEnabled = WebTrackingProtectionPreferences.shared.isGPCEnabled let sessionKey = UUID().uuidString + let messageSecret = UUID().uuidString let prefs = ContentScopeProperties(gpcEnabled: isGPCEnabled, sessionKey: sessionKey, + messageSecret: messageSecret, featureToggles: features) return DataBrokerProtectionViewController( diff --git a/DuckDuckGo/Tab/TabExtensions/AutofillTabExtension.swift b/DuckDuckGo/Tab/TabExtensions/AutofillTabExtension.swift index f1870a7a40..a8c7378596 100644 --- a/DuckDuckGo/Tab/TabExtensions/AutofillTabExtension.swift +++ b/DuckDuckGo/Tab/TabExtensions/AutofillTabExtension.swift @@ -209,6 +209,7 @@ extension AutofillTabExtension: SecureVaultManagerDelegate { return ContentScopeProperties(gpcEnabled: WebTrackingProtectionPreferences.shared.isGPCEnabled, sessionKey: autofillScript?.sessionKey ?? "", + messageSecret: autofillScript?.messageSecret ?? "", featureToggles: supportedFeatures) } } diff --git a/DuckDuckGo/Tab/UserScripts/UserScripts.swift b/DuckDuckGo/Tab/UserScripts/UserScripts.swift index a0444dfef0..f492ec9bac 100644 --- a/DuckDuckGo/Tab/UserScripts/UserScripts.swift +++ b/DuckDuckGo/Tab/UserScripts/UserScripts.swift @@ -62,8 +62,10 @@ final class UserScripts: UserScriptsProvider { let isGPCEnabled = WebTrackingProtectionPreferences.shared.isGPCEnabled let privacyConfig = sourceProvider.privacyConfigurationManager.privacyConfig let sessionKey = sourceProvider.sessionKey ?? "" + let messageSecret = sourceProvider.messageSecret ?? "" let prefs = ContentScopeProperties(gpcEnabled: isGPCEnabled, sessionKey: sessionKey, + messageSecret: messageSecret, featureToggles: ContentScopeFeatureToggles.supportedFeaturesOnMacOS(privacyConfig)) contentScopeUserScript = ContentScopeUserScript(sourceProvider.privacyConfigurationManager, properties: prefs) contentScopeUserScriptIsolated = ContentScopeUserScript(sourceProvider.privacyConfigurationManager, properties: prefs, isIsolated: true) diff --git a/DuckDuckGoDBPBackgroundAgent/DataBrokerProtectionBackgroundManager.swift b/DuckDuckGoDBPBackgroundAgent/DataBrokerProtectionBackgroundManager.swift index 1098fda56b..04e7d75700 100644 --- a/DuckDuckGoDBPBackgroundAgent/DataBrokerProtectionBackgroundManager.swift +++ b/DuckDuckGoDBPBackgroundAgent/DataBrokerProtectionBackgroundManager.swift @@ -51,8 +51,10 @@ public final class DataBrokerProtectionBackgroundManager { thirdPartyCredentialsProvider: false) let sessionKey = UUID().uuidString + let messageSecret = UUID().uuidString let prefs = ContentScopeProperties(gpcEnabled: false, sessionKey: sessionKey, + messageSecret: messageSecret, featureToggles: features) let pixelHandler = DataBrokerProtectionPixelsHandler() diff --git a/LocalPackages/DataBrokerProtection/Package.swift b/LocalPackages/DataBrokerProtection/Package.swift index 2e87539afc..4f857a269b 100644 --- a/LocalPackages/DataBrokerProtection/Package.swift +++ b/LocalPackages/DataBrokerProtection/Package.swift @@ -29,7 +29,7 @@ let package = Package( targets: ["DataBrokerProtection"]) ], dependencies: [ - .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "210.0.3"), + .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "211.0.0"), .package(path: "../SwiftUIExtensions"), .package(path: "../AppKitExtensions"), .package(path: "../XPCHelper"), diff --git a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/DebugUI/DataBrokerRunCustomJSONViewModel.swift b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/DebugUI/DataBrokerRunCustomJSONViewModel.swift index b2e8656204..117ae11d94 100644 --- a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/DebugUI/DataBrokerRunCustomJSONViewModel.swift +++ b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/DebugUI/DataBrokerRunCustomJSONViewModel.swift @@ -168,9 +168,11 @@ final class DataBrokerRunCustomJSONViewModel: ObservableObject { unknownUsernameCategorization: false) let sessionKey = UUID().uuidString + let messageSecret = UUID().uuidString self.authenticationManager = authenticationManager let contentScopeProperties = ContentScopeProperties(gpcEnabled: false, sessionKey: sessionKey, + messageSecret: messageSecret, featureToggles: features) self.runnerProvider = DataBrokerJobRunnerProvider( diff --git a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Scheduler/DataBrokerProtectionAgentManager.swift b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Scheduler/DataBrokerProtectionAgentManager.swift index 4a14c3145f..f125c7b4c5 100644 --- a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Scheduler/DataBrokerProtectionAgentManager.swift +++ b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Scheduler/DataBrokerProtectionAgentManager.swift @@ -61,6 +61,7 @@ public class DataBrokerProtectionAgentManagerProvider { unknownUsernameCategorization: false) let contentScopeProperties = ContentScopeProperties(gpcEnabled: false, sessionKey: UUID().uuidString, + messageSecret: UUID().uuidString, featureToggles: features) let fakeBroker = DataBrokerDebugFlagFakeBroker() diff --git a/LocalPackages/DataBrokerProtection/Tests/DataBrokerProtectionTests/Mocks.swift b/LocalPackages/DataBrokerProtection/Tests/DataBrokerProtectionTests/Mocks.swift index 9b51b42ee9..1e7a7515b8 100644 --- a/LocalPackages/DataBrokerProtection/Tests/DataBrokerProtectionTests/Mocks.swift +++ b/LocalPackages/DataBrokerProtection/Tests/DataBrokerProtectionTests/Mocks.swift @@ -242,6 +242,7 @@ extension ContentScopeProperties { ContentScopeProperties( gpcEnabled: false, sessionKey: "sessionKey", + messageSecret: "messageSecret", featureToggles: ContentScopeFeatureToggles.mock ) } diff --git a/LocalPackages/FeatureFlags/Package.swift b/LocalPackages/FeatureFlags/Package.swift index 69fe9fcde8..d5e8c436b6 100644 --- a/LocalPackages/FeatureFlags/Package.swift +++ b/LocalPackages/FeatureFlags/Package.swift @@ -32,7 +32,7 @@ let package = Package( targets: ["FeatureFlags"]), ], dependencies: [ - .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "210.0.3"), + .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "211.0.0"), ], targets: [ // Targets are the basic building blocks of a package, defining a module or a test suite. diff --git a/LocalPackages/NetworkProtectionMac/Package.swift b/LocalPackages/NetworkProtectionMac/Package.swift index 7d564662eb..6e84cbfd59 100644 --- a/LocalPackages/NetworkProtectionMac/Package.swift +++ b/LocalPackages/NetworkProtectionMac/Package.swift @@ -32,7 +32,7 @@ let package = Package( .library(name: "VPNAppLauncher", targets: ["VPNAppLauncher"]), ], dependencies: [ - .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "210.0.3"), + .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "211.0.0"), .package(url: "https://github.com/airbnb/lottie-spm", exact: "4.4.3"), .package(path: "../AppLauncher"), .package(path: "../UDSHelper"), diff --git a/LocalPackages/SubscriptionUI/Package.swift b/LocalPackages/SubscriptionUI/Package.swift index eee1efdb93..3c9b92e5cf 100644 --- a/LocalPackages/SubscriptionUI/Package.swift +++ b/LocalPackages/SubscriptionUI/Package.swift @@ -12,7 +12,7 @@ let package = Package( targets: ["SubscriptionUI"]), ], dependencies: [ - .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "210.0.3"), + .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "211.0.0"), .package(path: "../SwiftUIExtensions") ], targets: [