@duckduckgo/autoconsent 15.1.0 → 16.0.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.
- package/.github/dependabot.yml +0 -3
- package/.github/workflows/release.yml +0 -4
- package/AGENTS.md +3 -3
- package/CHANGELOG.md +20 -0
- package/build.sh +0 -2
- package/dist/addon-firefox/background.bundle.js +8 -24
- package/dist/addon-firefox/compact-rules.json +1 -1
- package/dist/addon-firefox/content.bundle.js +176 -686
- package/dist/addon-firefox/manifest.json +1 -1
- package/dist/addon-firefox/popup.bundle.js +31 -27
- package/dist/addon-firefox/popup.html +21 -13
- package/dist/addon-firefox/rule-index.json +1 -1
- package/dist/addon-firefox/rules.json +1 -1
- package/dist/addon-mv3/background.bundle.js +8 -24
- package/dist/addon-mv3/compact-rules.json +1 -1
- package/dist/addon-mv3/content.bundle.js +176 -686
- package/dist/addon-mv3/manifest.json +1 -1
- package/dist/addon-mv3/popup.bundle.js +31 -27
- package/dist/addon-mv3/popup.html +21 -13
- package/dist/addon-mv3/rule-index.json +1 -1
- package/dist/addon-mv3/rules.json +1 -1
- package/dist/autoconsent.cjs.js +176 -685
- package/dist/autoconsent.esm.js +176 -685
- package/dist/autoconsent.playwright.js +177 -689
- package/dist/autoconsent.standalone.js +177 -690
- package/dist/types/cmps/base.d.ts +3 -3
- package/dist/types/heuristics.d.ts +2 -2
- package/dist/types/types.d.ts +10 -23
- package/dist/types/web.d.ts +0 -9
- package/docs/api.md +1 -8
- package/docs/puppeteer.md +1 -3
- package/docs/rule-syntax.md +0 -17
- package/eslint.config.mjs +1 -1
- package/lib/cmps/base.ts +5 -6
- package/lib/heuristics.ts +15 -15
- package/lib/types.ts +9 -21
- package/lib/utils.ts +2 -4
- package/lib/web.ts +3 -53
- package/package.json +4 -17
- package/playwright/content.ts +1 -2
- package/readme.md +3 -6
- package/rules/autoconsent/dreamlab-cmp.json +13 -0
- package/rules/build.ts +1 -24
- package/rules/compact-rules.json +1 -1
- package/rules/rule-index-builder.ts +2 -7
- package/rules/rule-index.json +1 -1
- package/rules/rules.json +1 -1
- package/standalone/content.ts +0 -2
- package/tests/dreamlab-cmp.spec.ts +3 -0
- package/tests/quantcast.spec.ts +0 -6
- package/tests-wtr/heuristics/get-actionable-popups.ts +13 -13
- package/tests-wtr/heuristics/heuristic-cmp.ts +32 -33
- package/tests-wtr/lifecycle/find-cmp.ts +5 -8
- package/tests-wtr/web/do-opt-in.test.ts +0 -1
- package/tests-wtr/web/do-opt-out.test.ts +0 -1
- package/tests-wtr/web/do-self-test.test.ts +0 -1
- package/tests-wtr/web/filter-cmps.test.ts +0 -1
- package/tests-wtr/web/receive-message-callback.test.ts +1 -2
- package/tests-wtr/web/update-state.test.ts +1 -3
- package/tsconfig.build.json +1 -1
- package/.github/workflows/update-filterlist.yml +0 -42
- package/dist/autoconsent.extra.cjs.js +0 -15717
- package/dist/autoconsent.extra.esm.js +0 -15649
- package/dist/types/cmps/consentomatic.d.ts +0 -34
- package/dist/types/consentomatic/index.d.ts +0 -2
- package/dist/types/consentomatic/tools.d.ts +0 -10
- package/dist/types/filterlist-engine.d.ts +0 -2
- package/dist/types/filterlist-utils.d.ts +0 -4
- package/dist/types/web-extra.d.ts +0 -11
- package/lib/cmps/consentomatic.ts +0 -97
- package/lib/consentomatic/index.ts +0 -252
- package/lib/consentomatic/tools.ts +0 -199
- package/lib/filterlist-engine.ts +0 -5
- package/lib/filterlist-utils.ts +0 -45
- package/lib/web-extra.ts +0 -116
- package/rules/consentomatic.json +0 -1
- package/rules/filterlist.txt +0 -18440
- package/rules/filterlists/overrides.txt +0 -4
- package/scripts/compile-filterlist.mjs +0 -63
- package/scripts/fetch-easylist.sh +0 -25
- package/scripts/rebuild-filterlist.mjs +0 -216
- package/tests/oil.spec.ts +0 -7
- package/tests/springer.spec.ts +0 -7
- package/tests/wordpressgdpr.spec.ts +0 -6
package/playwright/content.ts
CHANGED
|
@@ -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: []
|
|
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';
|
|
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
|
|
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
|
|
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, '
|
|
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)), () =>
|