@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.
Files changed (99) hide show
  1. package/.eslintrc +12 -0
  2. package/Dockerfile +9 -0
  3. package/Jenkinsfile +50 -0
  4. package/LICENSE +373 -0
  5. package/cosmetics/rules.json +110 -0
  6. package/dist/autoconsent.cjs.js +1316 -0
  7. package/dist/autoconsent.esm.js +1308 -0
  8. package/dist/autoconsent.puppet.js +980 -0
  9. package/lib/cmps/all.js +17 -0
  10. package/lib/cmps/all.ts +21 -0
  11. package/lib/cmps/base.js +170 -0
  12. package/lib/cmps/base.ts +199 -0
  13. package/lib/cmps/consentmanager.js +31 -0
  14. package/lib/cmps/consentmanager.ts +39 -0
  15. package/lib/cmps/cookiebot.js +73 -0
  16. package/lib/cmps/cookiebot.ts +81 -0
  17. package/lib/cmps/evidon.js +26 -0
  18. package/lib/cmps/evidon.ts +32 -0
  19. package/lib/cmps/sourcepoint.js +82 -0
  20. package/lib/cmps/sourcepoint.ts +95 -0
  21. package/lib/cmps/trustarc.js +106 -0
  22. package/lib/cmps/trustarc.ts +147 -0
  23. package/lib/consentomatic/index.js +52 -0
  24. package/lib/consentomatic/index.ts +86 -0
  25. package/lib/detector.js +29 -0
  26. package/lib/detector.ts +30 -0
  27. package/lib/hider.js +13 -0
  28. package/lib/hider.ts +16 -0
  29. package/lib/index.js +4 -0
  30. package/lib/index.ts +6 -0
  31. package/lib/messages.d.ts +58 -0
  32. package/lib/node.js +30 -0
  33. package/lib/node.ts +38 -0
  34. package/lib/puppet/tab.js +114 -0
  35. package/lib/puppet/tab.ts +136 -0
  36. package/lib/rules.d.ts +80 -0
  37. package/lib/tabwrapper.js +61 -0
  38. package/lib/tabwrapper.ts +68 -0
  39. package/lib/types.d.ts +61 -0
  40. package/lib/web/consentomatic/index.js +188 -0
  41. package/lib/web/consentomatic/index.ts +249 -0
  42. package/lib/web/consentomatic/tools.js +177 -0
  43. package/lib/web/consentomatic/tools.ts +198 -0
  44. package/lib/web/content.js +91 -0
  45. package/lib/web/content.ts +83 -0
  46. package/lib/web/tab.js +106 -0
  47. package/lib/web/tab.ts +171 -0
  48. package/lib/web.js +90 -0
  49. package/lib/web.ts +109 -0
  50. package/package.json +41 -0
  51. package/playwright.config.ts +31 -0
  52. package/readme.md +151 -0
  53. package/rollup.config.js +54 -0
  54. package/rules/autoconsent/asus.json +7 -0
  55. package/rules/autoconsent/cc-banner.json +9 -0
  56. package/rules/autoconsent/cookie-law-info.json +14 -0
  57. package/rules/autoconsent/cookie-notice.json +9 -0
  58. package/rules/autoconsent/cookieconsent.json +9 -0
  59. package/rules/autoconsent/drupal.json +7 -0
  60. package/rules/autoconsent/eu-cookie-compliance.json +14 -0
  61. package/rules/autoconsent/fundingchoices.json +12 -0
  62. package/rules/autoconsent/hubspot.json +7 -0
  63. package/rules/autoconsent/klaro.json +10 -0
  64. package/rules/autoconsent/notice-cookie.json +9 -0
  65. package/rules/autoconsent/onetrust.json +24 -0
  66. package/rules/autoconsent/osano.json +11 -0
  67. package/rules/autoconsent/quantcast.json +14 -0
  68. package/rules/autoconsent/tealium.json +19 -0
  69. package/rules/autoconsent/testcmp.json +12 -0
  70. package/rules/build.js +63 -0
  71. package/rules/rules.json +3030 -0
  72. package/tests/asus.spec.ts +5 -0
  73. package/tests/ccbanner.spec.ts +11 -0
  74. package/tests/consentmanager.spec.ts +10 -0
  75. package/tests/cookiebot.spec.ts +9 -0
  76. package/tests/cookieconsent.spec.ts +8 -0
  77. package/tests/cookielawinfo.spec.ts +9 -0
  78. package/tests/cookienotice.spec.ts +6 -0
  79. package/tests/didomi.spec.ts +9 -0
  80. package/tests/eu-cookie-compliance-banner.spec.ts +7 -0
  81. package/tests/evidon.spec.ts +6 -0
  82. package/tests/fundingchoices.spec.ts +10 -0
  83. package/tests/hubspot.spec.ts +6 -0
  84. package/tests/klaro.spec.ts +5 -0
  85. package/tests/notice-cookie.spec.ts +7 -0
  86. package/tests/oil.spec.ts +10 -0
  87. package/tests/onetrust.spec.ts +15 -0
  88. package/tests/optanon.spec.ts +10 -0
  89. package/tests/osano.spec.ts +5 -0
  90. package/tests/quantcast.spec.ts +16 -0
  91. package/tests/runner.ts +61 -0
  92. package/tests/sourcepoint.spec.ts +17 -0
  93. package/tests/springer.spec.ts +11 -0
  94. package/tests/tealium.spec.ts +6 -0
  95. package/tests/testcmp.spec.ts +5 -0
  96. package/tests/trustarc.spec.ts +13 -0
  97. package/tests/wordpressgdpr.spec.ts +9 -0
  98. package/tsconfig.json +14 -0
  99. package/update_version.js +8 -0
@@ -0,0 +1,5 @@
1
+ import generateCMPTests from "./runner";
2
+
3
+ generateCMPTests('asus', [
4
+ 'https://www.asus.com/',
5
+ ]);
@@ -0,0 +1,11 @@
1
+ import generateCMPTests from "./runner";
2
+
3
+ generateCMPTests('cc_banner', [
4
+ 'https://www.w3resource.com/',
5
+ 'https://bitcoin.org/en/',
6
+ ])
7
+ generateCMPTests('cc_banner', [
8
+ 'https://distrowatch.com/',
9
+ ], {
10
+ skipRegions: ['US', 'GB'],
11
+ });
@@ -0,0 +1,10 @@
1
+ import generateCMPTests from "./runner";
2
+
3
+ generateCMPTests('consentmanager.net',
4
+ [
5
+ 'https://sourceforge.net/',
6
+ 'https://www.dastelefonbuch.de/'
7
+ ]
8
+ , {
9
+ skipRegions: ["US", "GB"]
10
+ });
@@ -0,0 +1,9 @@
1
+ import generateCMPTests from "./runner";
2
+
3
+ generateCMPTests('Cybotcookiebot', [
4
+ 'https://www.zentrum-der-gesundheit.de/',
5
+ 'https://www.wohnen.de/',
6
+ 'https://www.history.de/',
7
+ 'https://www.zwilling.com/de/',
8
+ 'https://forums.cpanel.net/',
9
+ ]);
@@ -0,0 +1,8 @@
1
+ import generateCMPTests from "./runner";
2
+
3
+ generateCMPTests('cookieconsent', [
4
+ 'https://yrc.com/',
5
+ 'https://www.worldometers.info/'
6
+ ], {
7
+ skipRegions: ['GB']
8
+ });
@@ -0,0 +1,9 @@
1
+ import generateCMPTests from "./runner";
2
+
3
+ generateCMPTests('cookie-law-info', [
4
+ 'https://www.yubico.com/',
5
+ 'https://nytcrosswordanswers.org/',
6
+ 'https://www.drohnen.de/'
7
+ ], {
8
+ skipRegions: ['US', 'GB']
9
+ });
@@ -0,0 +1,6 @@
1
+ import generateCMPTests from "./runner";
2
+
3
+ generateCMPTests('cookie-notice', [
4
+ 'https://electricbikereview.com/',
5
+ 'https://osxdaily.com/',
6
+ ]);
@@ -0,0 +1,9 @@
1
+ import generateCMPTests from "./runner";
2
+
3
+ generateCMPTests('com_didomi.io', [
4
+ 'https://www.ghacks.net/'
5
+ ], {
6
+ testOptOut: false,
7
+ testSelfTest: false,
8
+ skipRegions: ["US"],
9
+ });
@@ -0,0 +1,7 @@
1
+ import generateCMPTests from "./runner";
2
+
3
+ generateCMPTests('eu-cookie-compliance-banner', [
4
+ 'https://dnd.wizards.com/',
5
+ 'https://www.bauwion.de/',
6
+ 'https://publichealth.jhu.edu/',
7
+ ]);
@@ -0,0 +1,6 @@
1
+ import generateCMPTests from "./runner";
2
+
3
+ generateCMPTests('Evidon', [
4
+ 'https://www.kia.com/us/en',
5
+ 'https://www.fujitsu.com/global/'
6
+ ]);
@@ -0,0 +1,10 @@
1
+ import generateCMPTests from "./runner";
2
+
3
+ generateCMPTests('funding-choices', [
4
+ 'https://www.schulferien.org/',
5
+ 'https://www.bbc.com/',
6
+ 'https://www.accuweather.com/',
7
+ 'https://hbr.org/',
8
+ ], {
9
+ skipRegions: ["US", "GB"]
10
+ });
@@ -0,0 +1,6 @@
1
+ import generateCMPTests from "./runner";
2
+
3
+ generateCMPTests('hubspot', [
4
+ 'https://blog.hubspot.com/',
5
+ 'https://www.hubspot.de/',
6
+ ]);
@@ -0,0 +1,5 @@
1
+ import generateCMPTests from "./runner";
2
+
3
+ generateCMPTests('klaro', [
4
+ 'https://heyklaro.com/'
5
+ ]);
@@ -0,0 +1,7 @@
1
+ import generateCMPTests from "./runner";
2
+
3
+ generateCMPTests('notice-cookie', [
4
+ 'https://forum.proxmox.com/',
5
+ 'https://usethinkscript.com/'
6
+ ], {
7
+ });
@@ -0,0 +1,10 @@
1
+ import generateCMPTests from "./runner";
2
+
3
+ generateCMPTests('com_oil', [
4
+ 'https://www.lastminute.com/',
5
+ 'https://www.nubert.de/',
6
+ ], {
7
+ skipRegions: ['GB'],
8
+ testOptOut: false,
9
+ testSelfTest: false,
10
+ });
@@ -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,10 @@
1
+ import generateCMPTests from "./runner";
2
+
3
+ generateCMPTests('com_optanon', [
4
+ 'https://www.myfonts.com/',
5
+ 'https://developer.atlassian.com/',
6
+ ], {
7
+ testOptOut: false,
8
+ testSelfTest: false,
9
+ skipRegions: ["US", "GB"]
10
+ });
@@ -0,0 +1,5 @@
1
+ import generateCMPTests from "./runner";
2
+
3
+ generateCMPTests('osano', [
4
+ 'https://www.weathertech.com/'
5
+ ]);
@@ -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
+ });
@@ -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,11 @@
1
+ import generateCMPTests from "./runner";
2
+
3
+ generateCMPTests('com_springer', [
4
+ 'https://www.beobachter.ch/',
5
+ 'https://www.blick.ch/',
6
+ 'https://www.onet.pl/',
7
+ ], {
8
+ skipRegions: ['GB'],
9
+ testOptOut: false,
10
+ testSelfTest: false,
11
+ });
@@ -0,0 +1,6 @@
1
+ import generateCMPTests from "./runner";
2
+
3
+ generateCMPTests('Tealium', [
4
+ 'https://www.bahn.de/',
5
+ 'https://www.lufthansa.com/de/en/homepage',
6
+ ]);
@@ -0,0 +1,5 @@
1
+ import generateCMPTests from "./runner";
2
+
3
+ generateCMPTests('Test page CMP', [
4
+ 'https://privacy-test-pages.glitch.me/features/autoconsent/'
5
+ ]);
@@ -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
+ });
@@ -0,0 +1,9 @@
1
+ import generateCMPTests from "./runner";
2
+
3
+ generateCMPTests('com_wordpressgdpr', [
4
+ 'https://www.expatica.com/',
5
+ 'https://www.yourpension.gov.uk/',
6
+ ], {
7
+ testOptOut: false,
8
+ testSelfTest: false,
9
+ });
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));