@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,19 @@
1
+ {
2
+ "name": "Tealium",
3
+ "prehideSelectors": ["#__tealiumGDPRecModal,#__tealiumGDPRcpPrefs,#consent-layer"],
4
+ "isHidingRule": false,
5
+ "detectCmp": [{ "exists": "#__tealiumGDPRecModal" }, { "eval": "window.utag && typeof utag.gdpr === 'object'" }],
6
+ "detectPopup": [{ "visible": "#__tealiumGDPRecModal" }],
7
+ "optOut": [
8
+ { "hide": ["#__tealiumGDPRecModal", "#__tealiumGDPRcpPrefs", "#consent-layer"] },
9
+ { "click": "#cm-acceptNone,.js-accept-essential-cookies"}
10
+ ],
11
+ "optIn": [
12
+ { "hide": ["#__tealiumGDPRecModal"] },
13
+ { "eval": "utag.gdpr.setConsentValue(true)" }
14
+ ],
15
+ "test": [
16
+ { "eval": "utag.gdpr.getConsentState() !== 1" }
17
+ ]
18
+ }
19
+
@@ -0,0 +1,12 @@
1
+ {
2
+ "name": "Test page CMP",
3
+ "prehideSelectors": ["#reject-all"],
4
+ "detectCmp": [{ "exists": "#privacy-test-page-cmp-test" }],
5
+ "detectPopup": [{ "visible": "#privacy-test-page-cmp-test" }],
6
+ "optIn": [{ "click": "#accept-all" }],
7
+ "optOut": [
8
+ { "waitFor": "#reject-all" },
9
+ { "click": "#reject-all" }
10
+ ],
11
+ "test": [{ "eval": "window.results.results[0] === 'button_clicked'" }]
12
+ }
package/rules/build.js ADDED
@@ -0,0 +1,63 @@
1
+ #!/usr/bin/env node
2
+ const fs = require("fs");
3
+ const path = require("path");
4
+ const https = require("https");
5
+
6
+ const rules = {
7
+ autoconsent: [],
8
+ consentomatic: {}
9
+ };
10
+
11
+ async function readFileJSON(filePath) {
12
+ const data = await fs.promises.readFile(filePath, "utf-8")
13
+ return JSON.parse(data);
14
+ }
15
+
16
+ // merge rules from ./autoconsent into rules.autoconsent array
17
+ const autoconsentDir = path.join(__dirname, "autoconsent");
18
+ const files = fs.readdirSync(autoconsentDir);
19
+ const buildAutoconsent = Promise.all(
20
+ files.map(file => readFileJSON(path.join(autoconsentDir, file)))
21
+ ).then(r => (rules.autoconsent = r));
22
+
23
+ // fetch ConsentOMatic rule set and merge with our custom rules
24
+ const consentOMaticCommit = "7d7fd2bd6bf2b662350b0eaeca74db6eba155efe";
25
+ const consentOMaticUrl = `https://raw.githubusercontent.com/cavi-au/Consent-O-Matic/${consentOMaticCommit}/Rules.json`;
26
+ const consentOMaticDir = path.join(__dirname, "consentomatic");
27
+ const consentOMaticInclude = [
28
+ 'didomi.io', 'oil', 'optanon', 'quantcast2', 'springer', 'wordpressgdpr'
29
+ ]
30
+ const buildConsentOMatic = (async () => {
31
+ const comRules = {};
32
+ const allComRules = await new Promise(resolve => {
33
+ https.get(consentOMaticUrl, res => {
34
+ res.setEncoding("utf-8");
35
+ let content = "";
36
+ res.on("data", data => (content += data));
37
+ res.on("end", () => resolve(JSON.parse(content)));
38
+ });
39
+ });
40
+ consentOMaticInclude.forEach((name) => {
41
+ comRules[name] = allComRules[name];
42
+ })
43
+ try {
44
+ const extraRules = fs.readdirSync(consentOMaticDir);
45
+ await Promise.all(
46
+ extraRules.map(async file => {
47
+ const rule = await readFileJSON(path.join(consentOMaticDir, file));
48
+ // rule name is file name with JSON extension removed
49
+ comRules[file.substring(0, file.length - 5)] = rule;
50
+ })
51
+ );
52
+ } catch(e) {
53
+ }
54
+ rules.consentomatic = comRules;
55
+ })();
56
+
57
+ Promise.all([buildAutoconsent, buildConsentOMatic]).then(() => {
58
+ fs.writeFile(
59
+ path.join(__dirname, "rules.json"),
60
+ JSON.stringify(rules, undefined, " "),
61
+ () => console.log("Written rules.json")
62
+ );
63
+ });