@duckduckgo/autoconsent 14.97.0 → 15.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 (55) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/build.sh +3 -0
  3. package/dist/addon-firefox/background.bundle.js +10 -1
  4. package/dist/addon-firefox/compact-rules.json +1 -1
  5. package/dist/addon-firefox/content.bundle.js +157 -40
  6. package/dist/addon-firefox/manifest.json +1 -1
  7. package/dist/addon-firefox/popup.bundle.js +190 -14
  8. package/dist/addon-firefox/popup.html +93 -8
  9. package/dist/addon-firefox/rule-index.json +1 -0
  10. package/dist/addon-firefox/rules.json +1 -1
  11. package/dist/addon-mv3/background.bundle.js +10 -1
  12. package/dist/addon-mv3/compact-rules.json +1 -1
  13. package/dist/addon-mv3/content.bundle.js +157 -40
  14. package/dist/addon-mv3/manifest.json +1 -1
  15. package/dist/addon-mv3/popup.bundle.js +190 -14
  16. package/dist/addon-mv3/popup.html +93 -8
  17. package/dist/addon-mv3/rule-index.json +1 -0
  18. package/dist/addon-mv3/rules.json +1 -1
  19. package/dist/autoconsent.cjs.js +157 -40
  20. package/dist/autoconsent.esm.js +157 -40
  21. package/dist/autoconsent.extra.cjs.js +157 -40
  22. package/dist/autoconsent.extra.esm.js +157 -40
  23. package/dist/autoconsent.playwright.js +157 -40
  24. package/dist/autoconsent.standalone.js +4138 -0
  25. package/dist/types/cmps/base.d.ts +4 -2
  26. package/dist/types/cmps/trustarc-top.d.ts +1 -1
  27. package/dist/types/eval-handler.d.ts +3 -3
  28. package/dist/types/heuristic-patterns.d.ts +3 -0
  29. package/dist/types/heuristics.d.ts +4 -7
  30. package/dist/types/types.d.ts +18 -2
  31. package/lib/cmps/base.ts +20 -7
  32. package/lib/cmps/conversant.ts +7 -4
  33. package/lib/cmps/trustarc-top.ts +1 -1
  34. package/lib/cmps/uniconsent.ts +4 -4
  35. package/lib/eval-handler.ts +6 -3
  36. package/lib/heuristic-patterns.ts +68 -1
  37. package/lib/heuristics.ts +76 -27
  38. package/lib/types.ts +20 -2
  39. package/lib/utils.ts +13 -6
  40. package/lib/web.ts +3 -1
  41. package/package.json +1 -1
  42. package/rules/autoconsent/twitch.json +1 -1
  43. package/rules/build.ts +4 -0
  44. package/rules/compact-rules.json +1 -1
  45. package/rules/rule-index-builder.ts +63 -0
  46. package/rules/rule-index.json +1 -0
  47. package/rules/rules.json +1 -1
  48. package/standalone/content.ts +103 -0
  49. package/tests-wtr/heuristics/get-actionable-popups.html +16 -0
  50. package/tests-wtr/heuristics/get-actionable-popups.ts +85 -6
  51. package/tests-wtr/heuristics/heuristic-cmp.html +69 -0
  52. package/tests-wtr/heuristics/heuristic-cmp.ts +178 -0
  53. package/tests-wtr/heuristics/heuristics-utils.test.ts +96 -28
  54. package/tests-wtr/lifecycle/find-cmp.html +14 -0
  55. package/tests-wtr/lifecycle/find-cmp.ts +44 -2
@@ -19,6 +19,20 @@
19
19
  <button>Accept All</button>
20
20
  <button>Reject All</button>
21
21
  </div>
22
+ <div
23
+ id="heuristic-popup-acknowledge-only"
24
+ style="position: fixed; top: 0; left: 0; width: 300px; height: 200px; background: white; display: none"
25
+ >
26
+ <p>We use cookies to improve your experience.</p>
27
+ <button>OK</button>
28
+ </div>
29
+ <div
30
+ id="heuristic-popup-accept-only"
31
+ style="position: fixed; top: 0; left: 0; width: 300px; height: 200px; background: white; display: none"
32
+ >
33
+ <p>We use cookies to improve your experience.</p>
34
+ <button>Accept All</button>
35
+ </div>
22
36
  <div id="onetrust-pc-sdk" style="display: none">Cookie Preference Center</div>
23
37
  </body>
24
38
  </html>
@@ -1,6 +1,7 @@
1
1
  import { expect } from '@esm-bundle/chai';
2
2
  import Autoconsent from '../../lib/web';
3
3
  import Onetrust from '../../lib/cmps/onetrust';
4
+ import { PopupHandlingModes } from '../../lib/types';
4
5
 
5
6
  describe('Autoconsent.findCmp', () => {
6
7
  let autoconsent: Autoconsent;
@@ -145,7 +146,12 @@ describe('Autoconsent.findCmp', () => {
145
146
  });
146
147
 
147
148
  afterEach(() => {
148
- document.getElementById('heuristic-popup')?.remove();
149
+ const heuristicPopup = document.getElementById('heuristic-popup');
150
+ if (heuristicPopup) {
151
+ heuristicPopup.style.display = '';
152
+ }
153
+ document.getElementById('heuristic-popup-acknowledge-only')!.style.display = 'none';
154
+ document.getElementById('heuristic-popup-accept-only')!.style.display = 'none';
149
155
  });
150
156
 
151
157
  it('returns heuristic CMP when no declarative rules match', async () => {
@@ -161,7 +167,7 @@ describe('Autoconsent.findCmp', () => {
161
167
  const found = await autoconsent.findCmp(1);
162
168
 
163
169
  expect(found).to.have.length(1);
164
- expect(found[0].name).to.equal('HEURISTIC');
170
+ expect(found[0].name).to.equal('HEURISTIC-TIER0');
165
171
  });
166
172
 
167
173
  it('prefers declarative rules over heuristic CMP', async () => {
@@ -178,5 +184,41 @@ describe('Autoconsent.findCmp', () => {
178
184
  expect(found).to.have.length(1);
179
185
  expect(found[0].name).to.equal('test');
180
186
  });
187
+
188
+ it('returns HEURISTIC-TIER1 for acknowledge-only popup when mode is Tier1', async () => {
189
+ document.getElementById('heuristic-popup')!.style.display = 'none';
190
+ document.getElementById('heuristic-popup-acknowledge-only')!.style.display = 'block';
191
+
192
+ autoconsent = new Autoconsent((msg) => Promise.resolve(), {
193
+ enabled: false,
194
+ autoAction: null,
195
+ enableHeuristicAction: true,
196
+ heuristicMode: PopupHandlingModes.Tier1,
197
+ });
198
+ autoconsent.state.findCmpAttempts = 1;
199
+
200
+ const found = await autoconsent.findCmp(1);
201
+
202
+ expect(found).to.have.length(1);
203
+ expect(found[0].name).to.equal('HEURISTIC-TIER1');
204
+ });
205
+
206
+ it('returns HEURISTIC-TIER2 for accept-only popup when mode is Tier2', async () => {
207
+ document.getElementById('heuristic-popup')!.style.display = 'none';
208
+ document.getElementById('heuristic-popup-accept-only')!.style.display = 'block';
209
+
210
+ autoconsent = new Autoconsent((msg) => Promise.resolve(), {
211
+ enabled: false,
212
+ autoAction: null,
213
+ enableHeuristicAction: true,
214
+ heuristicMode: PopupHandlingModes.Tier2,
215
+ });
216
+ autoconsent.state.findCmpAttempts = 1;
217
+
218
+ const found = await autoconsent.findCmp(1);
219
+
220
+ expect(found).to.have.length(1);
221
+ expect(found[0].name).to.equal('HEURISTIC-TIER2');
222
+ });
181
223
  });
182
224
  });