@duckduckgo/autoconsent 14.94.0 → 14.95.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,7 @@
1
1
  import fs from 'fs';
2
2
  import path from 'path';
3
- import { encodeRules } from '../lib/encoding';
3
+ import { applyEdits, modify, parse, type JSONPath } from 'jsonc-parser';
4
+ import { encodeRules, type IndexedCMPRuleset } from '../lib/encoding';
4
5
 
5
6
  if (process.argv.length !== 3) {
6
7
  console.log('Usage: npm run bundle-config-rules path/to/privacy-configuration');
@@ -15,19 +16,24 @@ const bundleLocations = [path.join(privacyConfigPath, 'features', 'autoconsent.j
15
16
  const autoconsentRules = JSON.parse(fs.readFileSync(path.join(__dirname, '../rules/rules.json'), 'utf-8')).autoconsent;
16
17
 
17
18
  for (const location of bundleLocations) {
18
- const config = JSON.parse(fs.readFileSync(location, 'utf-8'));
19
+ // privacy-configuration source files may contain comments (JSONC). Parse
20
+ // leniently and apply a targeted edit so comments and formatting survive.
21
+ const text = fs.readFileSync(location, 'utf-8');
22
+ const config = parse(text);
23
+ let rulePath: JSONPath;
24
+ let newCompactRuleList: IndexedCMPRuleset;
19
25
  if (location.endsWith('autoconsent.json')) {
20
26
  console.log(`Existing compact rule list: ${config.settings.compactRuleList.s.slice(0, 10)}`);
21
27
  // global config
22
- config.settings.compactRuleList = encodeRules(autoconsentRules, config.settings.compactRuleList);
28
+ newCompactRuleList = encodeRules(autoconsentRules, config.settings.compactRuleList);
29
+ rulePath = ['settings', 'compactRuleList'];
23
30
  } else {
24
31
  // platform override
25
- config.features.autoconsent.settings.compactRuleList = encodeRules(
26
- autoconsentRules,
27
- config.features.autoconsent.settings.compactRuleList,
28
- );
32
+ newCompactRuleList = encodeRules(autoconsentRules, config.features.autoconsent.settings.compactRuleList);
33
+ rulePath = ['features', 'autoconsent', 'settings', 'compactRuleList'];
29
34
  }
30
- // generate standard pretty-printed output
31
- const outputData = JSON.stringify(config, undefined, 4);
32
- fs.writeFileSync(location, outputData);
35
+ const edits = modify(text, rulePath, newCompactRuleList, {
36
+ formattingOptions: { tabSize: 4, insertSpaces: true },
37
+ });
38
+ fs.writeFileSync(location, applyEdits(text, edits));
33
39
  }
@@ -4,7 +4,6 @@ generateCMPTests(
4
4
  'didomi',
5
5
  [
6
6
  'https://nothing.tech/',
7
- 'https://www.planet.fr/',
8
7
  'http://www.allocine.fr/',
9
8
  'https://www.boursorama.com/',
10
9
  'https://www.theoriginalshotels.com/en/hotels/la-villa-vicha',
@@ -15,7 +14,7 @@ generateCMPTests(
15
14
  // Self-test is disabled because some sites (e.g. planet.fr) navigate away
16
15
  // after clicking the disagree button, which destroys the Didomi state.
17
16
  testSelfTest: false,
18
- skipRegions: ['US'],
17
+ onlyRegions: ['US', 'FR'],
19
18
  },
20
19
  );
21
20
 
@@ -0,0 +1,9 @@
1
+ import generateCMPTests from '../playwright/runner';
2
+
3
+ const urls = ['https://www.yachtclubgames.com/'];
4
+
5
+ generateCMPTests('yachtclubgames.com', urls);
6
+
7
+ generateCMPTests('yachtclubgames.com', urls, {
8
+ mobile: true,
9
+ });