@duckduckgo/autoconsent 15.1.0 → 16.1.0

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.
Files changed (89) hide show
  1. package/.github/PULL_REQUEST_TEMPLATE.md +7 -0
  2. package/.github/dependabot.yml +0 -3
  3. package/.github/labeler.yml +36 -0
  4. package/.github/workflows/release-labels.yml +110 -0
  5. package/.github/workflows/release.yml +0 -4
  6. package/AGENTS.md +3 -3
  7. package/CHANGELOG.md +33 -0
  8. package/build.sh +0 -2
  9. package/dist/addon-firefox/background.bundle.js +8 -24
  10. package/dist/addon-firefox/compact-rules.json +1 -1
  11. package/dist/addon-firefox/content.bundle.js +176 -686
  12. package/dist/addon-firefox/manifest.json +1 -1
  13. package/dist/addon-firefox/popup.bundle.js +31 -27
  14. package/dist/addon-firefox/popup.html +21 -13
  15. package/dist/addon-firefox/rule-index.json +1 -1
  16. package/dist/addon-firefox/rules.json +1 -1
  17. package/dist/addon-mv3/background.bundle.js +8 -24
  18. package/dist/addon-mv3/compact-rules.json +1 -1
  19. package/dist/addon-mv3/content.bundle.js +176 -686
  20. package/dist/addon-mv3/manifest.json +1 -1
  21. package/dist/addon-mv3/popup.bundle.js +31 -27
  22. package/dist/addon-mv3/popup.html +21 -13
  23. package/dist/addon-mv3/rule-index.json +1 -1
  24. package/dist/addon-mv3/rules.json +1 -1
  25. package/dist/autoconsent.cjs.js +176 -685
  26. package/dist/autoconsent.esm.js +176 -685
  27. package/dist/autoconsent.playwright.js +177 -689
  28. package/dist/autoconsent.standalone.js +177 -690
  29. package/dist/types/cmps/base.d.ts +3 -3
  30. package/dist/types/heuristics.d.ts +2 -2
  31. package/dist/types/types.d.ts +10 -23
  32. package/dist/types/web.d.ts +0 -9
  33. package/docs/api.md +1 -8
  34. package/docs/puppeteer.md +1 -3
  35. package/docs/release-notes.md +65 -0
  36. package/docs/rule-syntax.md +0 -17
  37. package/eslint.config.mjs +1 -1
  38. package/lib/cmps/base.ts +5 -6
  39. package/lib/heuristics.ts +15 -15
  40. package/lib/types.ts +9 -21
  41. package/lib/utils.ts +2 -4
  42. package/lib/web.ts +3 -53
  43. package/package.json +112 -18
  44. package/playwright/content.ts +1 -2
  45. package/readme.md +3 -6
  46. package/rules/autoconsent/dreamlab-cmp.json +13 -0
  47. package/rules/build.ts +1 -24
  48. package/rules/compact-rules.json +1 -1
  49. package/rules/rule-index-builder.ts +2 -7
  50. package/rules/rule-index.json +1 -1
  51. package/rules/rules.json +1 -1
  52. package/scripts/check-pr-release-labels.ts +255 -0
  53. package/standalone/content.ts +0 -2
  54. package/tests/dreamlab-cmp.spec.ts +3 -0
  55. package/tests/quantcast.spec.ts +0 -6
  56. package/tests-wtr/heuristics/get-actionable-popups.ts +13 -13
  57. package/tests-wtr/heuristics/heuristic-cmp.ts +32 -33
  58. package/tests-wtr/lifecycle/find-cmp.ts +5 -8
  59. package/tests-wtr/web/do-opt-in.test.ts +0 -1
  60. package/tests-wtr/web/do-opt-out.test.ts +0 -1
  61. package/tests-wtr/web/do-self-test.test.ts +0 -1
  62. package/tests-wtr/web/filter-cmps.test.ts +0 -1
  63. package/tests-wtr/web/receive-message-callback.test.ts +1 -2
  64. package/tests-wtr/web/update-state.test.ts +1 -3
  65. package/tsconfig.build.json +1 -1
  66. package/.github/workflows/update-filterlist.yml +0 -42
  67. package/dist/autoconsent.extra.cjs.js +0 -15717
  68. package/dist/autoconsent.extra.esm.js +0 -15649
  69. package/dist/types/cmps/consentomatic.d.ts +0 -34
  70. package/dist/types/consentomatic/index.d.ts +0 -2
  71. package/dist/types/consentomatic/tools.d.ts +0 -10
  72. package/dist/types/filterlist-engine.d.ts +0 -2
  73. package/dist/types/filterlist-utils.d.ts +0 -4
  74. package/dist/types/web-extra.d.ts +0 -11
  75. package/lib/cmps/consentomatic.ts +0 -97
  76. package/lib/consentomatic/index.ts +0 -252
  77. package/lib/consentomatic/tools.ts +0 -199
  78. package/lib/filterlist-engine.ts +0 -5
  79. package/lib/filterlist-utils.ts +0 -45
  80. package/lib/web-extra.ts +0 -116
  81. package/rules/consentomatic.json +0 -1
  82. package/rules/filterlist.txt +0 -18440
  83. package/rules/filterlists/overrides.txt +0 -4
  84. package/scripts/compile-filterlist.mjs +0 -63
  85. package/scripts/fetch-easylist.sh +0 -25
  86. package/scripts/rebuild-filterlist.mjs +0 -216
  87. package/tests/oil.spec.ts +0 -7
  88. package/tests/springer.spec.ts +0 -7
  89. package/tests/wordpressgdpr.spec.ts +0 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@duckduckgo/autoconsent",
3
- "version": "15.1.0",
3
+ "version": "16.1.0",
4
4
  "description": "",
5
5
  "types": "./dist/types/web.d.ts",
6
6
  "exports": {
@@ -9,13 +9,7 @@
9
9
  "import": "./dist/autoconsent.esm.js",
10
10
  "require": "./dist/autoconsent.cjs.js"
11
11
  },
12
- "./extra": {
13
- "types": "./dist/types/web-extra.d.ts",
14
- "import": "./dist/autoconsent.extra.esm.js",
15
- "require": "./dist/autoconsent.extra.cjs.js"
16
- },
17
12
  "./rules/rules.json": "./rules/rules.json",
18
- "./rules/consentomatic.json": "./rules/consentomatic.json",
19
13
  "./rules/compact-rules.json": "./rules/compact-rules.json"
20
14
  },
21
15
  "directories": {
@@ -27,7 +21,7 @@
27
21
  "lint-fix": "eslint . --fix && prettier . --write && npm run rule-syntax-check",
28
22
  "bundle": "./build.sh",
29
23
  "rule-syntax-check": "node scripts/validate-json-rules.js",
30
- "watch": "npm run prepublish && chokidar \"lib\" \"addon\" \"rules/autoconsent\" \"rules/generated\" \"rules/filterlist.txt\" --ignore 'lib/filterlist-engine.ts' -c \"npm run prepublish\"",
24
+ "watch": "npm run prepublish && chokidar \"lib\" \"addon\" \"rules/autoconsent\" \"rules/generated\" -c \"npm run prepublish\"",
31
25
  "create-rule": "node rules/create-rule.mjs",
32
26
  "test": "playwright test",
33
27
  "test:webkit": "playwright test --project webkit",
@@ -35,24 +29,22 @@
35
29
  "test:chrome": "playwright test --project chrome",
36
30
  "test:lib": "web-test-runner",
37
31
  "test:sample": "playwright test tests/_sample-test.spec.ts --project webkit",
38
- "fetch-easylist": "scripts/fetch-easylist.sh",
39
- "rebuild-filterlist": "node scripts/rebuild-filterlist.mjs",
40
- "update-easylist": "npm run fetch-easylist && npm run rebuild-filterlist",
41
- "compile-filterlist": "node scripts/compile-filterlist.mjs",
42
32
  "build-rules": "ts-node rules/build.ts",
43
33
  "version": "node update_version.js && git add addon/manifest.*.json",
44
34
  "vendor-copy": "mkdir -p addon/vendor && cp node_modules/mocha/mocha.* addon/vendor/ && cp node_modules/chai/chai.js addon/vendor/",
45
- "prepublish": "npm run compile-filterlist && npm run build-rules && npm run bundle",
35
+ "prepublish": "npm run build-rules && npm run bundle",
46
36
  "launch:firefox": "web-ext run -s dist/addon-firefox",
47
37
  "release": "auto shipit",
48
38
  "get-text-for-xpath": "ts-node scripts/get-text-for-xpath.ts",
49
- "bundle-config-rules": "ts-node scripts/bundle-config-rules.ts"
39
+ "bundle-config-rules": "ts-node scripts/bundle-config-rules.ts",
40
+ "check-pr-release-labels": "ts-node scripts/check-pr-release-labels.ts"
50
41
  },
51
42
  "author": "Sam Macbeth",
52
43
  "license": "MPL-2.0",
53
44
  "devDependencies": {
54
45
  "@duckduckgo/eslint-config": "github:duckduckgo/eslint-config#v0.1.0",
55
46
  "@esm-bundle/chai": "^4.3.4-fix.0",
47
+ "@octokit/rest": "^22.0.1",
56
48
  "@playwright/test": "^1.17.1",
57
49
  "@types/chai": "^5.0.0",
58
50
  "@types/chrome": "^0.1.0",
@@ -68,7 +60,6 @@
68
60
  "bulma": "^1.0.2",
69
61
  "chai": "^6.0.1",
70
62
  "chokidar-cli": "^3.0.0",
71
- "csv-parse": "^6.0.0",
72
63
  "esbuild": "^0.28.0",
73
64
  "eslint": "^10.0.3",
74
65
  "globals": "^17.4.0",
@@ -87,13 +78,116 @@
87
78
  },
88
79
  "repository": "duckduckgo/autoconsent",
89
80
  "auto": {
81
+ "noDefaultLabels": true,
82
+ "labels": [
83
+ {
84
+ "name": "major",
85
+ "description": "Increment the major version when merged",
86
+ "releaseType": "major",
87
+ "color": "#C5000B"
88
+ },
89
+ {
90
+ "name": "minor",
91
+ "description": "Increment the minor version when merged",
92
+ "releaseType": "minor",
93
+ "color": "#F1A60E"
94
+ },
95
+ {
96
+ "name": "patch",
97
+ "description": "Increment the patch version when merged",
98
+ "releaseType": "patch",
99
+ "default": true,
100
+ "color": "#870048"
101
+ },
102
+ {
103
+ "name": "release",
104
+ "description": "Create a release when this PR is merged",
105
+ "releaseType": "release",
106
+ "color": "#007f70"
107
+ },
108
+ {
109
+ "name": "rules",
110
+ "changelogTitle": "Rules",
111
+ "description": "Autoconsent rule additions, updates, and generated rule changes",
112
+ "releaseType": "none",
113
+ "color": "#bfdadc"
114
+ },
115
+ {
116
+ "name": "bug",
117
+ "changelogTitle": "Bug Fixes",
118
+ "description": "Something isn't working",
119
+ "releaseType": "none",
120
+ "color": "#d73a4a"
121
+ },
122
+ {
123
+ "name": "enhancement",
124
+ "changelogTitle": "Enhancements",
125
+ "description": "New feature or request",
126
+ "releaseType": "none",
127
+ "color": "#a2eeef"
128
+ },
129
+ {
130
+ "name": "performance",
131
+ "changelogTitle": "Performance",
132
+ "description": "Improve performance of an existing feature",
133
+ "releaseType": "none",
134
+ "color": "#f4b2d8"
135
+ },
136
+ {
137
+ "name": "dependencies",
138
+ "changelogTitle": "Dependencies",
139
+ "description": "Update one or more dependencies version",
140
+ "releaseType": "none",
141
+ "color": "#8732bc"
142
+ },
143
+ {
144
+ "name": "ci",
145
+ "changelogTitle": "CI / Release Automation",
146
+ "description": "Automation scripts and release infrastructure",
147
+ "releaseType": "none",
148
+ "color": "#2612BF"
149
+ },
150
+ {
151
+ "name": "ai",
152
+ "changelogTitle": "AI / Agent Workflow",
153
+ "description": "Changes to agent workflows and skills",
154
+ "releaseType": "none",
155
+ "color": "#df4f06"
156
+ },
157
+ {
158
+ "name": "documentation",
159
+ "changelogTitle": "Documentation",
160
+ "description": "Changes only affect the documentation",
161
+ "releaseType": "none",
162
+ "color": "#cfd3d7"
163
+ },
164
+ {
165
+ "name": "tests",
166
+ "changelogTitle": "Test Infrastructure",
167
+ "description": "Changes to test harnesses, fixtures, or test infrastructure",
168
+ "releaseType": "none",
169
+ "color": "#ffd3cc"
170
+ },
171
+ {
172
+ "name": "internal",
173
+ "changelogTitle": "Internal",
174
+ "description": "Changes only affect internal implementation details",
175
+ "releaseType": "none",
176
+ "color": "#696969"
177
+ },
178
+ {
179
+ "name": "other",
180
+ "changelogTitle": "Other",
181
+ "description": "Changes that should appear in release notes but do not fit another category",
182
+ "releaseType": "none",
183
+ "color": "#ededed"
184
+ }
185
+ ],
90
186
  "plugins": [
91
187
  "npm"
92
188
  ]
93
189
  },
94
190
  "dependencies": {
95
- "@ghostery/adblocker": "^2.0.4",
96
- "@ghostery/adblocker-content": "^2.0.4",
97
- "tldts-experimental": "^7.0.4"
191
+ "tldts-experimental": "^7.4.3"
98
192
  }
99
193
  }
@@ -1,7 +1,6 @@
1
1
  import AutoConsent from '../lib/web';
2
2
  import { BackgroundMessage } from '../lib/messages';
3
3
  import { MessageSender, RuleBundle } from '../lib/types';
4
- import { consentomatic } from '../rules/consentomatic.json';
5
4
 
6
5
  declare global {
7
6
  interface Window {
@@ -11,7 +10,7 @@ declare global {
11
10
  }
12
11
 
13
12
  if (!window.autoconsentReceiveMessage) {
14
- const consent = new AutoConsent(window.autoconsentSendMessage, null, <RuleBundle>{ autoconsent: [], consentomatic });
13
+ const consent = new AutoConsent(window.autoconsentSendMessage, null, <RuleBundle>{ autoconsent: [] });
15
14
 
16
15
  window.autoconsentReceiveMessage = (message: BackgroundMessage) => {
17
16
  return Promise.resolve(consent.receiveMessageCallback(message));
package/readme.md CHANGED
@@ -11,14 +11,13 @@ Autoconsent is meant to be used in browser apps and extensions. [DuckDuckGo brow
11
11
  To integrate Autoconsent, you'll need to instantiate the main `AutoConsent` class in a content script (running in isolated page context), and implement some configuration hooks in a background script. See [this document](docs/api.md) for more details on internal APIs and data flows.
12
12
 
13
13
  ```javascript
14
- import AutoConsent from '@duckduckgo/autoconsent'; // or '@duckduckgo/autoconsent/extra' for the version with filterlists
14
+ import AutoConsent from '@duckduckgo/autoconsent';
15
15
  import { autoconsent } from '@duckduckgo/autoconsent/rules/rules.json';
16
- import { consentomatic } from '@duckduckgo/autoconsent/rules/consentomatic.json'
17
16
 
18
17
  const autoconsent = new AutoConsent(
19
18
  chrome.runtime.sendMessage, // provide a callback to send messages to the background script
20
19
  null, // optionally provide a config object here if you don't want to implement a background script
21
- { autoconsent, consentomatic },
20
+ { autoconsent },
22
21
  );
23
22
 
24
23
  // connect the message receiver callback to handle messages from the background script
@@ -76,13 +75,11 @@ that are installed on multiple sites. Each CMP ruleset defines:
76
75
  * Steps to specify an 'opt-in' or 'opt-out' consent for the CMP.
77
76
  * Optionally, a test if the consent was correctly applied.
78
77
 
79
- There are currently three ways of implementing a CMP:
78
+ There are currently two ways of implementing a CMP:
80
79
 
81
80
  1. As a [JSON ruleset](./rules/autoconsent/), intepreted by the `AutoConsent` class.
82
81
  1. As a class implementing the `AutoCMP` interface. This enables more complex logic than the linear AutoConsent
83
82
  rulesets allow.
84
- 3. As a [Consent-O-Matic](https://github.com/cavi-au/Consent-O-Matic) rule. The `ConsentOMaticCMP` class implements
85
- compability with rules written for the Consent-O-Matic extension.
86
83
 
87
84
  For more details on rule types, see [Rule Syntax Reference](docs/rule-syntax.md).
88
85
 
@@ -0,0 +1,13 @@
1
+ {
2
+ "name": "dreamlab-cmp",
3
+ "vendorUrl": "https://cmp.dreamlab.pl/",
4
+ "prehideSelectors": [".cmp-popup_popup"],
5
+ "detectCmp": [{ "exists": ".cmp-app_gdpr" }],
6
+ "detectPopup": [{ "visible": ".cmp-popup_popup" }],
7
+ "optIn": [{ "waitForThenClick": ".cmp-popup_popup .cmp-intro_acceptAll" }],
8
+ "optOut": [
9
+ { "waitForThenClick": ".cmp-popup_popup .cmp-intro_rejectAll" },
10
+ { "waitForThenClick": ".cmp-popup_popup .cmp-details_rejectAll" }
11
+ ],
12
+ "test": [{ "cookieContains": "lpubconsent=" }]
13
+ }
package/rules/build.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import fs from 'fs';
3
3
  import path from 'path';
4
- import https from 'https';
5
4
  import { encodeRules, deduplicateRules } from '../lib/encoding';
6
5
  import { AutoConsentCMPRule } from '../lib/rules';
7
6
  import { buildRuleIndex } from './rule-index-builder';
@@ -29,30 +28,9 @@ export async function buildAutoconsentRules(): Promise<AutoConsentCMPRule[]> {
29
28
  return deduplicateRules([...normalRules, ...generatedRules]);
30
29
  }
31
30
 
32
- export async function buildConsentOMaticRules() {
33
- // fetch ConsentOMatic rule set and merge with our custom rules
34
- const consentOMaticCommit = '7d7fd2bd6bf2b662350b0eaeca74db6eba155efe';
35
- const consentOMaticUrl = `https://raw.githubusercontent.com/cavi-au/Consent-O-Matic/${consentOMaticCommit}/Rules.json`;
36
- const consentOMaticInclude = ['oil', 'optanon', 'quantcast2', 'springer', 'wordpressgdpr'];
37
- const comRules: Record<string, object> = {};
38
- const allComRules: Record<string, object> = await new Promise((resolve) => {
39
- https.get(consentOMaticUrl, (res) => {
40
- res.setEncoding('utf-8');
41
- let content = '';
42
- res.on('data', (data) => (content += data));
43
- res.on('end', () => resolve(JSON.parse(content)));
44
- });
45
- });
46
- consentOMaticInclude.forEach((name) => {
47
- comRules[name] = allComRules[name];
48
- });
49
- return comRules;
50
- }
51
-
52
31
  (async () => {
53
32
  const stringify = (rules: object) => JSON.stringify(rules);
54
33
  const autoconsent = await buildAutoconsentRules();
55
- const consentomatic = await buildConsentOMaticRules();
56
34
 
57
35
  const compactRulesPath = path.join(rulesDir, 'compact-rules.json');
58
36
  let existingCompactRules = null;
@@ -61,8 +39,7 @@ export async function buildConsentOMaticRules() {
61
39
  }
62
40
 
63
41
  fs.writeFile(path.join(rulesDir, 'rules.json'), stringify({ autoconsent }), () => console.log('Written rules.json'));
64
- fs.writeFile(path.join(rulesDir, 'consentomatic.json'), stringify({ consentomatic }), () => console.log('Written consentomatic.json'));
65
- fs.writeFile(path.join(rulesDir, 'rule-index.json'), stringify(buildRuleIndex(autoconsent, consentomatic)), () =>
42
+ fs.writeFile(path.join(rulesDir, 'rule-index.json'), stringify(buildRuleIndex(autoconsent)), () =>
66
43
  console.log('Written rule-index.json'),
67
44
  );
68
45
  fs.writeFile(compactRulesPath, stringify(encodeRules(autoconsent, existingCompactRules)), () =>