@duckduckgo/autoconsent 1.0.2
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/.eslintrc +12 -0
- package/Dockerfile +9 -0
- package/Jenkinsfile +50 -0
- package/LICENSE +373 -0
- package/cosmetics/rules.json +110 -0
- package/dist/autoconsent.cjs.js +1316 -0
- package/dist/autoconsent.esm.js +1308 -0
- package/dist/autoconsent.puppet.js +980 -0
- package/lib/cmps/all.js +17 -0
- package/lib/cmps/all.ts +21 -0
- package/lib/cmps/base.js +170 -0
- package/lib/cmps/base.ts +199 -0
- package/lib/cmps/consentmanager.js +31 -0
- package/lib/cmps/consentmanager.ts +39 -0
- package/lib/cmps/cookiebot.js +73 -0
- package/lib/cmps/cookiebot.ts +81 -0
- package/lib/cmps/evidon.js +26 -0
- package/lib/cmps/evidon.ts +32 -0
- package/lib/cmps/sourcepoint.js +82 -0
- package/lib/cmps/sourcepoint.ts +95 -0
- package/lib/cmps/trustarc.js +106 -0
- package/lib/cmps/trustarc.ts +147 -0
- package/lib/consentomatic/index.js +52 -0
- package/lib/consentomatic/index.ts +86 -0
- package/lib/detector.js +29 -0
- package/lib/detector.ts +30 -0
- package/lib/hider.js +13 -0
- package/lib/hider.ts +16 -0
- package/lib/index.js +4 -0
- package/lib/index.ts +6 -0
- package/lib/messages.d.ts +58 -0
- package/lib/node.js +30 -0
- package/lib/node.ts +38 -0
- package/lib/puppet/tab.js +114 -0
- package/lib/puppet/tab.ts +136 -0
- package/lib/rules.d.ts +80 -0
- package/lib/tabwrapper.js +61 -0
- package/lib/tabwrapper.ts +68 -0
- package/lib/types.d.ts +61 -0
- package/lib/web/consentomatic/index.js +188 -0
- package/lib/web/consentomatic/index.ts +249 -0
- package/lib/web/consentomatic/tools.js +177 -0
- package/lib/web/consentomatic/tools.ts +198 -0
- package/lib/web/content.js +91 -0
- package/lib/web/content.ts +83 -0
- package/lib/web/tab.js +106 -0
- package/lib/web/tab.ts +171 -0
- package/lib/web.js +90 -0
- package/lib/web.ts +109 -0
- package/package.json +41 -0
- package/playwright.config.ts +31 -0
- package/readme.md +151 -0
- package/rollup.config.js +54 -0
- package/rules/autoconsent/asus.json +7 -0
- package/rules/autoconsent/cc-banner.json +9 -0
- package/rules/autoconsent/cookie-law-info.json +14 -0
- package/rules/autoconsent/cookie-notice.json +9 -0
- package/rules/autoconsent/cookieconsent.json +9 -0
- package/rules/autoconsent/drupal.json +7 -0
- package/rules/autoconsent/eu-cookie-compliance.json +14 -0
- package/rules/autoconsent/fundingchoices.json +12 -0
- package/rules/autoconsent/hubspot.json +7 -0
- package/rules/autoconsent/klaro.json +10 -0
- package/rules/autoconsent/notice-cookie.json +9 -0
- package/rules/autoconsent/onetrust.json +24 -0
- package/rules/autoconsent/osano.json +11 -0
- package/rules/autoconsent/quantcast.json +14 -0
- package/rules/autoconsent/tealium.json +19 -0
- package/rules/autoconsent/testcmp.json +12 -0
- package/rules/build.js +63 -0
- package/rules/rules.json +3030 -0
- package/tests/asus.spec.ts +5 -0
- package/tests/ccbanner.spec.ts +11 -0
- package/tests/consentmanager.spec.ts +10 -0
- package/tests/cookiebot.spec.ts +9 -0
- package/tests/cookieconsent.spec.ts +8 -0
- package/tests/cookielawinfo.spec.ts +9 -0
- package/tests/cookienotice.spec.ts +6 -0
- package/tests/didomi.spec.ts +9 -0
- package/tests/eu-cookie-compliance-banner.spec.ts +7 -0
- package/tests/evidon.spec.ts +6 -0
- package/tests/fundingchoices.spec.ts +10 -0
- package/tests/hubspot.spec.ts +6 -0
- package/tests/klaro.spec.ts +5 -0
- package/tests/notice-cookie.spec.ts +7 -0
- package/tests/oil.spec.ts +10 -0
- package/tests/onetrust.spec.ts +15 -0
- package/tests/optanon.spec.ts +10 -0
- package/tests/osano.spec.ts +5 -0
- package/tests/quantcast.spec.ts +16 -0
- package/tests/runner.ts +61 -0
- package/tests/sourcepoint.spec.ts +17 -0
- package/tests/springer.spec.ts +11 -0
- package/tests/tealium.spec.ts +6 -0
- package/tests/testcmp.spec.ts +5 -0
- package/tests/trustarc.spec.ts +13 -0
- package/tests/wordpressgdpr.spec.ts +9 -0
- package/tsconfig.json +14 -0
- package/update_version.js +8 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import generateCMPTests from "./runner";
|
|
2
|
+
|
|
3
|
+
generateCMPTests('Onetrust', [
|
|
4
|
+
'https://mailchimp.com/',
|
|
5
|
+
'https://stackoverflow.com/',
|
|
6
|
+
'https://www.zdf.de/',
|
|
7
|
+
'https://www.cancer.org/',
|
|
8
|
+
]);
|
|
9
|
+
|
|
10
|
+
generateCMPTests('Onetrust', [
|
|
11
|
+
'https://arstechnica.com/',
|
|
12
|
+
'https://www.nvidia.com/',
|
|
13
|
+
], {
|
|
14
|
+
skipRegions: ['US', 'GB']
|
|
15
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import generateCMPTests from "./runner";
|
|
2
|
+
|
|
3
|
+
generateCMPTests('quantcast', [
|
|
4
|
+
'https://www.cyclingnews.com/',
|
|
5
|
+
'https://www.techradar.com/',
|
|
6
|
+
], {
|
|
7
|
+
skipRegions: ["US", "GB", "FR"]
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
generateCMPTests('com_quantcast2', [
|
|
11
|
+
'https://www.fandom.com/',
|
|
12
|
+
], {
|
|
13
|
+
testOptOut: false,
|
|
14
|
+
testSelfTest: false,
|
|
15
|
+
skipRegions: ["US"]
|
|
16
|
+
});
|
package/tests/runner.ts
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import fs from 'fs/promises';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { test, expect } from '@playwright/test';
|
|
4
|
+
import * as autoconsent from '../dist/autoconsent.puppet';
|
|
5
|
+
import * as extraRules from '../rules/rules.json';
|
|
6
|
+
|
|
7
|
+
const consentomatic = extraRules.consentomatic;
|
|
8
|
+
const rules = [
|
|
9
|
+
...autoconsent.rules,
|
|
10
|
+
...Object.keys(consentomatic).map(name => new autoconsent.ConsentOMaticCMP(`com_${name}`, consentomatic[name])),
|
|
11
|
+
...extraRules.autoconsent.map(spec => autoconsent.createAutoCMP(spec)),
|
|
12
|
+
];
|
|
13
|
+
const screenshotDir = `./screenshots`;
|
|
14
|
+
const testRegion = (process.env.REGION || 'NA').trim();
|
|
15
|
+
|
|
16
|
+
async function ensureScreenshotDir() {
|
|
17
|
+
try {
|
|
18
|
+
await fs.stat(screenshotDir);
|
|
19
|
+
} catch(e) {
|
|
20
|
+
await fs.mkdir(screenshotDir);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
type TestOptions = {
|
|
25
|
+
testOptOut: boolean;
|
|
26
|
+
testSelfTest: boolean;
|
|
27
|
+
skipRegions?: string[];
|
|
28
|
+
}
|
|
29
|
+
const defaultOptions: TestOptions = {
|
|
30
|
+
testOptOut: true,
|
|
31
|
+
testSelfTest: true,
|
|
32
|
+
skipRegions: [],
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function generateTest(url: string, expectedCmp: string, options: TestOptions = { testOptOut: true, testSelfTest: true }) {
|
|
36
|
+
test(`${url.split('://')[1]} .${testRegion}`, async ({ page }) => {
|
|
37
|
+
if (options.skipRegions && options.skipRegions.indexOf(testRegion) !== -1) {
|
|
38
|
+
test.skip();
|
|
39
|
+
}
|
|
40
|
+
await page.goto(url, { waitUntil: 'commit' });
|
|
41
|
+
|
|
42
|
+
const tab = autoconsent.attachToPage(page, url, rules, 20);
|
|
43
|
+
await tab.checked;
|
|
44
|
+
expect(tab.getCMPName()).toBe(expectedCmp);
|
|
45
|
+
expect(await tab.isPopupOpen(10, 100)).toBeTruthy();
|
|
46
|
+
if (options.testOptOut) {
|
|
47
|
+
expect(await tab.doOptOut()).toBeTruthy();
|
|
48
|
+
}
|
|
49
|
+
if (options.testSelfTest) {
|
|
50
|
+
expect(await tab.testOptOutWorked()).toBeTruthy();
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export default function generateCMPTests(cmp: string, sites: string[], options: Partial<TestOptions> = {}) {
|
|
56
|
+
test.describe(cmp, () => {
|
|
57
|
+
sites.forEach((url) => {
|
|
58
|
+
generateTest(url, cmp, Object.assign({}, defaultOptions, options));
|
|
59
|
+
});
|
|
60
|
+
})
|
|
61
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import generateCMPTests from "./runner";
|
|
2
|
+
|
|
3
|
+
generateCMPTests('Sourcepoint', [
|
|
4
|
+
'https://www.theguardian.com/',
|
|
5
|
+
'https://www.n-tv.de/',
|
|
6
|
+
'https://www.sueddeutsche.de/',
|
|
7
|
+
'https://news.sky.com/'
|
|
8
|
+
], {
|
|
9
|
+
testSelfTest: false,
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
generateCMPTests('Sourcepoint', [
|
|
13
|
+
'https://www.insider.com/',
|
|
14
|
+
], {
|
|
15
|
+
skipRegions: ["US", "GB"],
|
|
16
|
+
testSelfTest: false,
|
|
17
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import generateCMPTests from "./runner";
|
|
2
|
+
import { test } from '@playwright/test';
|
|
3
|
+
|
|
4
|
+
generateCMPTests('TrustArc', [
|
|
5
|
+
'https://www.garmin.com/de-DE/',
|
|
6
|
+
'https://www.wish.com/',
|
|
7
|
+
'https://www.forbes.com/',
|
|
8
|
+
'https://www.starbucks.com/',
|
|
9
|
+
], {
|
|
10
|
+
testOptOut: true,
|
|
11
|
+
testSelfTest: false,
|
|
12
|
+
skipRegions: ["US"]
|
|
13
|
+
});
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2020",
|
|
4
|
+
"typeRoots": ["node_modules/web-ext-types"],
|
|
5
|
+
"resolveJsonModule": true,
|
|
6
|
+
"moduleResolution": "node",
|
|
7
|
+
"noImplicitAny": true,
|
|
8
|
+
},
|
|
9
|
+
"exclude": [
|
|
10
|
+
"node_modules/*",
|
|
11
|
+
"playwright.config.ts",
|
|
12
|
+
"tests/*"
|
|
13
|
+
]
|
|
14
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
|
|
3
|
+
const manifestFile = './addon/manifest.json';
|
|
4
|
+
const day = new Date()
|
|
5
|
+
const version = `${day.getFullYear()}.${day.getMonth() + 1}.${day.getDate()}`
|
|
6
|
+
const manifest = require(manifestFile);
|
|
7
|
+
manifest.version = version;
|
|
8
|
+
fs.writeFileSync(manifestFile, JSON.stringify(manifest, null, 2));
|