Skip to content

Commit

Permalink
adding support for message bridge
Browse files Browse the repository at this point in the history
  • Loading branch information
Shane Osbourne committed Nov 18, 2024
1 parent dd2354e commit 27dd563
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 6 deletions.
4 changes: 2 additions & 2 deletions DuckDuckGo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -15075,8 +15075,8 @@
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/duckduckgo/BrowserServicesKit";
requirement = {
kind = exactVersion;
version = 210.0.3;
branch = "11-14-css_adding_a_new_messagesecret_properties_for_injected_scripts";
kind = branch;
};
};
9FF521422BAA8FF300B9819B /* XCRemoteSwiftPackageReference "lottie-spm" */ = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,17 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/duckduckgo/BrowserServicesKit",
"state" : {
"revision" : "a296f015a572fdfe53a81de653efb9a6d7fc3eba",
"version" : "210.0.3"
"branch" : "11-14-css_adding_a_new_messagesecret_properties_for_injected_scripts",
"revision" : "e52b8c7c20e2f4c16781f694a3d596dc8df4d201"
}
},
{
"identity" : "content-scope-scripts",
"kind" : "remoteSourceControl",
"location" : "https://github.com/duckduckgo/content-scope-scripts",
"state" : {
"revision" : "adca39c379b1a124f9990e9d0308c374f32f5018",
"version" : "6.32.0"
"revision" : "f2caf4ff814f4714d07d6fc2cf02498cb54a1389",
"version" : "6.36.0"
}
},
{
Expand Down
1 change: 1 addition & 0 deletions DuckDuckGo/Autofill/ContentOverlayViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 4 additions & 0 deletions DuckDuckGo/ContentBlocker/ScriptSourceProviding.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand All @@ -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()
}
Expand All @@ -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()
Expand Down
2 changes: 2 additions & 0 deletions DuckDuckGo/DBP/DBPHomeViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
1 change: 1 addition & 0 deletions DuckDuckGo/Tab/TabExtensions/AutofillTabExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ extension AutofillTabExtension: SecureVaultManagerDelegate {

return ContentScopeProperties(gpcEnabled: WebTrackingProtectionPreferences.shared.isGPCEnabled,
sessionKey: autofillScript?.sessionKey ?? "",
messageSecret: autofillScript?.messageSecret ?? "",
featureToggles: supportedFeatures)
}
}
Expand Down
2 changes: 2 additions & 0 deletions DuckDuckGo/Tab/UserScripts/UserScripts.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ extension ContentScopeProperties {
ContentScopeProperties(
gpcEnabled: false,
sessionKey: "sessionKey",
messageSecret: "messageSecret",
featureToggles: ContentScopeFeatureToggles.mock
)
}
Expand Down

0 comments on commit 27dd563

Please sign in to comment.