Skip to content

Commit

Permalink
CSS: adding a new messageSecret properties for injected scripts (#1077)
Browse files Browse the repository at this point in the history
<!--
Note: This checklist is a reminder of our shared engineering
expectations.
-->

Please review the release process for BrowserServicesKit
[here](https://app.asana.com/0/1200194497630846/1200837094583426).

**Required**:

Task/Issue URL: https://app.asana.com/0/0/1208773745506348/f
iOS PR: duckduckgo/iOS#3588
macOS PR: duckduckgo/macos-browser#3558
What kind of version bump will this require?: Major/Minor/Patch

**Optional**:

Tech Design URL:
CC:

**Description**:

<!--
Tagging instructions
If this PR isn't ready to be merged for whatever reason it should be
marked with the `DO NOT MERGE` label (particularly if it's a draft)
If it's pending Product Review/PFR, please add the `Pending Product
Review` label.

If at any point it isn't actively being worked on/ready for
review/otherwise moving forward (besides the above PR/PFR exception)
strongly consider closing it (or not opening it in the first place). If
you decide not to close it, make sure it's labelled to make it clear the
PRs state and comment with more information.
-->

**Steps to test this PR**:
1. See the macOS PR
duckduckgo/macos-browser#3558

<!--
Before submitting a PR, please ensure you have tested the combinations
you expect the reviewer to test, then delete configurations you *know*
do not need explicit testing.

Using a simulator where a physical device is unavailable is acceptable.
-->

**OS Testing**:

* [ ] iOS 14
* [ ] iOS 15
* [ ] iOS 16
* [ ] macOS 10.15
* [ ] macOS 11
* [ ] macOS 12

---
###### Internal references:
[Software Engineering
Expectations](https://app.asana.com/0/59792373528535/199064865822552)
[Technical Design
Template](https://app.asana.com/0/59792373528535/184709971311943)

Co-authored-by: Shane Osbourne <[email protected]>
  • Loading branch information
shakyShane and Shane Osbourne authored Nov 19, 2024
1 parent 108dff9 commit 7033b0d
Show file tree
Hide file tree
Showing 12 changed files with 16 additions and 9 deletions.
4 changes: 2 additions & 2 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/duckduckgo/content-scope-scripts",
"state" : {
"revision" : "32c3e2bce3cc20a079d96b3ee23a9cde5d2337c3",
"version" : "6.35.0"
"revision" : "f2caf4ff814f4714d07d6fc2cf02498cb54a1389",
"version" : "6.36.0"
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ let package = Package(
.package(url: "https://github.com/duckduckgo/TrackerRadarKit", exact: "3.0.0"),
.package(url: "https://github.com/duckduckgo/sync_crypto", exact: "0.3.0"),
.package(url: "https://github.com/gumob/PunycodeSwift.git", exact: "3.0.0"),
.package(url: "https://github.com/duckduckgo/content-scope-scripts", exact: "6.35.0"),
.package(url: "https://github.com/duckduckgo/content-scope-scripts", exact: "6.36.0"),
.package(url: "https://github.com/duckduckgo/privacy-dashboard", exact: "7.2.0"),
.package(url: "https://github.com/httpswift/swifter.git", exact: "1.5.0"),
.package(url: "https://github.com/duckduckgo/bloom_cpp.git", exact: "3.0.0"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public class AutofillUserScript: NSObject, UserScript, UserScriptMessageEncrypti
public var isBurnerWindow: Bool = false

public var sessionKey: String?
public var messageSecret: String?

public weak var emailDelegate: AutofillEmailDelegate?
public weak var vaultDelegate: AutofillSecureVaultDelegate?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@ public final class ContentScopeProperties: Encodable {
public let globalPrivacyControlValue: Bool
public let debug: Bool = false
public let sessionKey: String
public let messageSecret: String
public let languageCode: String
public let platform = ContentScopePlatform()
public let features: [String: ContentScopeFeature]

public init(gpcEnabled: Bool, sessionKey: String, featureToggles: ContentScopeFeatureToggles) {
public init(gpcEnabled: Bool, sessionKey: String, messageSecret: String, featureToggles: ContentScopeFeatureToggles) {
self.globalPrivacyControlValue = gpcEnabled
self.sessionKey = sessionKey
self.messageSecret = messageSecret
languageCode = Locale.current.languageCode ?? "en"
features = [
"autofill": ContentScopeFeature(featureToggles: featureToggles)
Expand All @@ -47,6 +49,7 @@ public final class ContentScopeProperties: Encodable {
case globalPrivacyControlValue
case debug
case sessionKey
case messageSecret
case platform
case features
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class AutofillEmailUserScriptTests: XCTestCase {
}
""".data(using: .utf8)!
let privacyConfig = AutofillTestHelper.preparePrivacyConfig(embeddedConfig: embeddedConfig)
let properties = ContentScopeProperties(gpcEnabled: false, sessionKey: "1234", featureToggles: ContentScopeFeatureToggles.allTogglesOn)
let properties = ContentScopeProperties(gpcEnabled: false, sessionKey: "1234", messageSecret: "1234", featureToggles: ContentScopeFeatureToggles.allTogglesOn)
let sourceProvider = DefaultAutofillSourceProvider.Builder(privacyConfigurationManager: privacyConfig,
properties: properties)
.withJSLoading()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ final class AutofillUserScriptSourceProviderTests: XCTestCase {
}
""".data(using: .utf8)!
lazy var privacyConfig = AutofillTestHelper.preparePrivacyConfig(embeddedConfig: embeddedConfig)
let properties = ContentScopeProperties(gpcEnabled: false, sessionKey: "1234", featureToggles: ContentScopeFeatureToggles.allTogglesOn)
let properties = ContentScopeProperties(gpcEnabled: false, sessionKey: "1234", messageSecret: "1234", featureToggles: ContentScopeFeatureToggles.allTogglesOn)

func testWhenBuildWithLoadJSThenSourceStrIsBuilt() {
let autofillSourceProvider = DefaultAutofillSourceProvider.Builder(privacyConfigurationManager: privacyConfig,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class AutofillVaultUserScriptTests: XCTestCase {
}
""".data(using: .utf8)!
let privacyConfig = AutofillTestHelper.preparePrivacyConfig(embeddedConfig: embeddedConfig)
let properties = ContentScopeProperties(gpcEnabled: false, sessionKey: "1234", featureToggles: ContentScopeFeatureToggles.allTogglesOn)
let properties = ContentScopeProperties(gpcEnabled: false, sessionKey: "1234", messageSecret: "1234", featureToggles: ContentScopeFeatureToggles.allTogglesOn)
let sourceProvider = DefaultAutofillSourceProvider(privacyConfigurationManager: privacyConfig,
properties: properties,
isDebug: false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import WebKit

class ContentScopePropertiesTests: XCTestCase {
func testContentScopePropertiesInitializeCorrectly() {
let properties = ContentScopeProperties(gpcEnabled: true, sessionKey: "123456", featureToggles: ContentScopeFeatureToggles.allTogglesOn)
let properties = ContentScopeProperties(gpcEnabled: true, sessionKey: "123456", messageSecret: "123456", featureToggles: ContentScopeFeatureToggles.allTogglesOn)

// ensure the properties can be encoded to valid JSON
XCTAssertNotNil(try? JSONEncoder().encode(properties))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class EmailManagerTests: XCTestCase {
let sourceProvider = DefaultAutofillSourceProvider(privacyConfigurationManager: privacyConfigManager,
properties: ContentScopeProperties(gpcEnabled: false,
sessionKey: "1234",
messageSecret: "1234",
featureToggles: ContentScopeFeatureToggles.allTogglesOn),
isDebug: false)
let userScript = AutofillUserScript(scriptSourceProvider: sourceProvider)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ final class FingerprintingReferenceTests: XCTestCase {

let contentScopeProperties = ContentScopeProperties(gpcEnabled: false,
sessionKey: UUID().uuidString,
messageSecret: UUID().uuidString,
featureToggles: configFeatureToggle)

let contentScopeScript = ContentScopeUserScript(self.privacyManager,
Expand Down
1 change: 1 addition & 0 deletions Tests/BrowserServicesKitTests/GPC/GPCReferenceTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ final class GPCReferenceTests: XCTestCase {

let properties = ContentScopeProperties(gpcEnabled: gpcEnabled,
sessionKey: UUID().uuidString,
messageSecret: UUID().uuidString,
featureToggles: ContentScopeFeatureToggles.allTogglesOn)

let contentScopeScript = ContentScopeUserScript(privacyManager,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class SecureVaultManagerTests: XCTestCase {
}
""".data(using: .utf8)!
let privacyConfig = AutofillTestHelper.preparePrivacyConfig(embeddedConfig: embeddedConfig)
let properties = ContentScopeProperties(gpcEnabled: false, sessionKey: "1234", featureToggles: ContentScopeFeatureToggles.allTogglesOn)
let properties = ContentScopeProperties(gpcEnabled: false, sessionKey: "1234", messageSecret: "1234", featureToggles: ContentScopeFeatureToggles.allTogglesOn)
let sourceProvider = DefaultAutofillSourceProvider(privacyConfigurationManager: privacyConfig,
properties: properties,
isDebug: false)
Expand Down

0 comments on commit 7033b0d

Please sign in to comment.