@duckduckgo/autoconsent 1.0.6 → 2.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/.eslintrc.cjs +14 -0
- package/.vscode/settings.json +7 -0
- package/Jenkinsfile +68 -39
- package/api.md +104 -0
- package/dist/autoconsent.cjs.js +1 -1371
- package/dist/autoconsent.esm.js +1 -1363
- package/dist/autoconsent.playwright.js +1 -0
- package/dist/autoconsent.standalone.js +1 -0
- package/lib/cmps/all.ts +15 -10
- package/lib/cmps/base.ts +91 -91
- package/lib/cmps/consentmanager.ts +31 -19
- package/lib/cmps/consentomatic.ts +89 -0
- package/lib/cmps/cookiebot.ts +62 -53
- package/lib/cmps/evidon.ts +29 -18
- package/lib/cmps/onetrust.ts +37 -19
- package/lib/cmps/sourcepoint-frame.ts +102 -0
- package/lib/cmps/sourcepoint-top.ts +47 -0
- package/lib/cmps/trustarc-frame.ts +115 -0
- package/lib/cmps/trustarc-top.ts +91 -0
- package/lib/consentomatic/index.ts +233 -70
- package/lib/{web/consentomatic → consentomatic}/tools.ts +0 -0
- package/lib/eval-handler.ts +58 -0
- package/lib/index.ts +0 -2
- package/lib/messages.ts +100 -0
- package/lib/rule-executors.ts +108 -0
- package/lib/rules.ts +82 -0
- package/lib/types.ts +35 -0
- package/lib/utils.ts +64 -0
- package/lib/web.ts +283 -74
- package/package.json +17 -14
- package/playwright/content.ts +27 -0
- package/playwright/runner.ts +131 -0
- package/playwright/standalone.ts +36 -0
- package/playwright.config.ts +7 -0
- package/readme.md +57 -47
- package/rollup.config.js +23 -15
- package/rules/autoconsent/192.json +17 -0
- package/rules/autoconsent/ausopen.json +7 -0
- package/rules/autoconsent/aws-amazon.json +1 -1
- package/rules/autoconsent/baden-wuerttemberg-de.json +7 -3
- package/rules/autoconsent/bing.json +14 -0
- package/rules/autoconsent/bundesregierung-de.json +6 -2
- package/rules/autoconsent/cc-banner.json +0 -1
- package/rules/autoconsent/cookie-notice.json +0 -1
- package/rules/autoconsent/cookieconsent.json +5 -6
- package/rules/autoconsent/destatis-de.json +0 -1
- package/rules/autoconsent/dunelm.json +18 -0
- package/rules/autoconsent/etsy.json +3 -2
- package/rules/autoconsent/eu-cookie-compliance.json +0 -1
- package/rules/autoconsent/gov-uk.json +10 -0
- package/rules/autoconsent/hl-co-uk.json +8 -9
- package/rules/autoconsent/johnlewis.json +5 -2
- package/rules/autoconsent/marksandspencer.json +7 -0
- package/rules/autoconsent/notice-cookie.json +0 -1
- package/rules/autoconsent/osano.json +0 -1
- package/rules/autoconsent/{paypal-de.json → paypal.json} +6 -2
- package/rules/autoconsent/tealium.json +4 -5
- package/rules/autoconsent/uswitch.json +8 -0
- package/rules/autoconsent/waitrose.json +28 -0
- package/rules/autoconsent/wetransfer.json +7 -0
- package/rules/rules.json +314 -39
- package/tests/192.spec.ts +7 -0
- package/tests/arzt-auskunft.spec.ts +1 -1
- package/tests/asus.spec.ts +1 -1
- package/tests/ausopen.spec.ts +7 -0
- package/tests/aws.amazon.spec.ts +1 -1
- package/tests/baden-wuerttemberg.spec.ts +1 -1
- package/tests/borlabs.spec.ts +1 -1
- package/tests/bundesregierung.spec.ts +5 -2
- package/tests/ccbanner.spec.ts +1 -1
- package/tests/consentmanager.spec.ts +3 -3
- package/tests/cookiebot.spec.ts +8 -1
- package/tests/cookieconsent.spec.ts +1 -1
- package/tests/cookielawinfo.spec.ts +1 -1
- package/tests/cookienotice.spec.ts +1 -1
- package/tests/corona-in-zahlen.spec.ts +1 -1
- package/tests/deepl.spec.ts +1 -1
- package/tests/destatis.spec.ts +1 -1
- package/tests/didomi.spec.ts +6 -2
- package/tests/drupal.spec.ts +8 -0
- package/tests/dunelm.spec.ts +7 -0
- package/tests/etsy.spec.ts +1 -1
- package/tests/eu-cookie-compliance-banner.spec.ts +1 -1
- package/tests/evidon.spec.ts +1 -1
- package/tests/fundingchoices.spec.ts +2 -1
- package/tests/gov-uk.spec.ts +9 -0
- package/tests/hl-co-uk.spec.ts +1 -1
- package/tests/hubspot.spec.ts +1 -1
- package/tests/ionos.spec.ts +1 -1
- package/tests/johnlewis.spec.ts +2 -2
- package/tests/klaro.spec.ts +1 -1
- package/tests/marksandspencer.spec.ts +7 -0
- package/tests/mediamarkt.spec.ts +1 -1
- package/tests/metoffice-gov-uk.spec.ts +1 -1
- package/tests/microsoft.spec.ts +1 -1
- package/tests/moneysavingexpert.spec.ts +1 -1
- package/tests/motor-talk.spec.ts +1 -1
- package/tests/national-lottery.spec.ts +1 -1
- package/tests/netflix.spec.ts +1 -1
- package/tests/nhs.spec.ts +1 -1
- package/tests/notice-cookie.spec.ts +1 -1
- package/tests/obi.spec.ts +1 -1
- package/tests/oil.spec.ts +1 -1
- package/tests/onetrust.spec.ts +10 -1
- package/tests/osano.spec.ts +1 -1
- package/tests/otto.spec.ts +1 -1
- package/tests/paypal.spec.ts +8 -6
- package/tests/quantcast.spec.ts +4 -1
- package/tests/snigel.spec.ts +1 -1
- package/tests/sourcepoint.spec.ts +8 -8
- package/tests/springer.spec.ts +1 -1
- package/tests/steampowered.spec.ts +1 -1
- package/tests/tealium.spec.ts +1 -1
- package/tests/testcmp.spec.ts +1 -1
- package/tests/thalia.spec.ts +1 -1
- package/tests/thefreedictionary.spec.ts +1 -1
- package/tests/trustarc.spec.ts +25 -3
- package/tests/usercentrics-1.spec.ts +1 -1
- package/tests/uswitch.spec.ts +7 -0
- package/tests/vodafone.spec.ts +1 -1
- package/tests/waitrose.spec.ts +7 -0
- package/tests/wetransfer.spec.ts +7 -0
- package/tests/wordpressgdpr.spec.ts +1 -1
- package/tests/xing.spec.ts +1 -1
- package/tsconfig.json +2 -2
- package/.eslintrc +0 -12
- package/cosmetics/rules.json +0 -110
- package/dist/autoconsent.puppet.js +0 -1072
- package/lib/cmps/all.js +0 -19
- package/lib/cmps/base.js +0 -174
- package/lib/cmps/consentmanager.js +0 -31
- package/lib/cmps/cookiebot.js +0 -73
- package/lib/cmps/evidon.js +0 -26
- package/lib/cmps/onetrust.js +0 -32
- package/lib/cmps/sourcepoint.js +0 -82
- package/lib/cmps/sourcepoint.ts +0 -95
- package/lib/cmps/trustarc.js +0 -106
- package/lib/cmps/trustarc.ts +0 -147
- package/lib/config.js +0 -1
- package/lib/consentomatic/index.js +0 -52
- package/lib/detector.js +0 -33
- package/lib/detector.ts +0 -34
- package/lib/hider.js +0 -13
- package/lib/hider.ts +0 -16
- package/lib/index.js +0 -4
- package/lib/messages.d.ts +0 -61
- package/lib/node.js +0 -35
- package/lib/node.ts +0 -43
- package/lib/puppet/tab.js +0 -121
- package/lib/puppet/tab.ts +0 -146
- package/lib/rules.d.ts +0 -80
- package/lib/tabwrapper.js +0 -67
- package/lib/tabwrapper.ts +0 -74
- package/lib/types.d.ts +0 -61
- package/lib/web/consentomatic/index.js +0 -188
- package/lib/web/consentomatic/index.ts +0 -249
- package/lib/web/consentomatic/tools.js +0 -177
- package/lib/web/content-utils.js +0 -29
- package/lib/web/content-utils.ts +0 -31
- package/lib/web/content.js +0 -79
- package/lib/web/content.ts +0 -71
- package/lib/web/tab.js +0 -112
- package/lib/web/tab.ts +0 -178
- package/lib/web.js +0 -95
- package/tests/runner.ts +0 -61
package/.eslintrc.cjs
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
root: true,
|
|
3
|
+
parser: '@typescript-eslint/parser',
|
|
4
|
+
plugins: [
|
|
5
|
+
'@typescript-eslint',
|
|
6
|
+
],
|
|
7
|
+
extends: [
|
|
8
|
+
'eslint:recommended',
|
|
9
|
+
'plugin:@typescript-eslint/recommended',
|
|
10
|
+
],
|
|
11
|
+
rules: {
|
|
12
|
+
"@typescript-eslint/no-explicit-any": 0,
|
|
13
|
+
}
|
|
14
|
+
}
|
package/Jenkinsfile
CHANGED
|
@@ -1,50 +1,79 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
def runPlaywrightTests(resultDir) {
|
|
2
|
+
sh 'mkdir -p ./test-results'
|
|
3
|
+
sh """
|
|
4
|
+
PLAYWRIGHT_JUNIT_OUTPUT_NAME=results.xml npx playwright test --project webkit --reporter=junit || true
|
|
5
|
+
"""
|
|
6
|
+
junit 'results.xml'
|
|
7
|
+
sh """
|
|
8
|
+
mkdir -p ${resultDir}/results/${BRANCH_NAME}/${BUILD_NUMBER}/$REGION/
|
|
9
|
+
mkdir -p ./test-results
|
|
10
|
+
mv ./test-results/ ${resultDir}/results/${BRANCH_NAME}/${BUILD_NUMBER}/$REGION/
|
|
11
|
+
"""
|
|
12
|
+
}
|
|
11
13
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
def withEnvFile(envfile, Closure cb) {
|
|
15
|
+
def props = readProperties(file: envfile)
|
|
16
|
+
withEnv(props.collect{ entry -> "${entry.key}=${entry.value}" }) {
|
|
17
|
+
cb()
|
|
16
18
|
}
|
|
19
|
+
}
|
|
17
20
|
|
|
18
|
-
|
|
19
|
-
|
|
21
|
+
pipeline {
|
|
22
|
+
agent { label 'crawler-worker' }
|
|
23
|
+
parameters {
|
|
24
|
+
string(name: 'TEST_RESULT_ROOT', defaultValue: '/mnt/efs/users/smacbeth/autoconsent/ci', description: 'Where test results and configuration are stored')
|
|
20
25
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
26
|
+
environment {
|
|
27
|
+
NODENV_VERSION = "14.15.4"
|
|
28
|
+
NODENV_ROOT = "/opt/nodeenv"
|
|
29
|
+
PATH = "/opt/nodenv/shims:/opt/nodenv/bin:$PATH"
|
|
30
|
+
}
|
|
31
|
+
stages {
|
|
32
|
+
stage('Checkout') {
|
|
33
|
+
steps {
|
|
34
|
+
checkout scm
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
24
38
|
stage('Build') {
|
|
25
|
-
|
|
26
|
-
|
|
39
|
+
steps {
|
|
40
|
+
sh '''
|
|
41
|
+
npm ci
|
|
42
|
+
npx playwright install webkit
|
|
43
|
+
'''
|
|
44
|
+
}
|
|
27
45
|
}
|
|
28
|
-
|
|
29
|
-
stage('
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
46
|
+
|
|
47
|
+
stage('Test: DE') {
|
|
48
|
+
steps {
|
|
49
|
+
withEnvFile("${params.TEST_RESULT_ROOT}/de.env") {
|
|
50
|
+
runPlaywrightTests(params.TEST_RESULT_ROOT)
|
|
51
|
+
}
|
|
52
|
+
}
|
|
35
53
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
54
|
+
|
|
55
|
+
stage('Test: US') {
|
|
56
|
+
steps {
|
|
57
|
+
withEnvFile("${params.TEST_RESULT_ROOT}/us.env") {
|
|
58
|
+
runPlaywrightTests(params.TEST_RESULT_ROOT)
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
stage('Test: GB') {
|
|
64
|
+
steps {
|
|
65
|
+
withEnvFile("${params.TEST_RESULT_ROOT}/gb.env") {
|
|
66
|
+
runPlaywrightTests(params.TEST_RESULT_ROOT)
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
stage('Test: FR') {
|
|
72
|
+
steps {
|
|
73
|
+
withEnvFile("${params.TEST_RESULT_ROOT}/fr.env") {
|
|
74
|
+
runPlaywrightTests(params.TEST_RESULT_ROOT)
|
|
75
|
+
}
|
|
46
76
|
}
|
|
47
|
-
sh "aws s3 cp config.json s3://cdn.cliqz.com/autoconsent/${fileName} --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers --content-type application/json --cache-control \"max-age=3600\""
|
|
48
77
|
}
|
|
49
78
|
}
|
|
50
79
|
}
|
package/api.md
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# API
|
|
2
|
+
|
|
3
|
+
## Content script
|
|
4
|
+
Most of autoconsent logic is contained in a content script that should be injected into every page. However, the high-level orchestration is controlled externally by a background service worker (in case of a web extension), or a native browser integration. Autoconsent sends and receives messages to the background worker using provided callables which mimic postMessage API:
|
|
5
|
+
|
|
6
|
+
```typescript
|
|
7
|
+
const consent = new AutoConsent( // make sure not to leak anything to the page globals
|
|
8
|
+
chrome.runtime.sendMessage, // pass a function to send messages to the background worker
|
|
9
|
+
{ // optionally, pass a config object
|
|
10
|
+
enabled: true,
|
|
11
|
+
autoAction: 'optOut',
|
|
12
|
+
disabledCmps: [],
|
|
13
|
+
enablePrehide: true,
|
|
14
|
+
detectRetries: 20,
|
|
15
|
+
},
|
|
16
|
+
{ // optionally, pass JSON rules
|
|
17
|
+
autoconsent: [ ... ],
|
|
18
|
+
consentomatic: [ ... ],
|
|
19
|
+
}
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
// connect .receiveMessageCallback() to a platform-specific message receiver
|
|
23
|
+
chrome.runtime.onMessage.addListener((message: BackgroundMessage) => {
|
|
24
|
+
return Promise.resolve(
|
|
25
|
+
consent.receiveMessageCallback(message)
|
|
26
|
+
);
|
|
27
|
+
});
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Messaging API
|
|
31
|
+
|
|
32
|
+
For concrete message format, refer to [messages.ts](/lib/messages.ts).
|
|
33
|
+
|
|
34
|
+
The overall workflow is described below:
|
|
35
|
+
|
|
36
|
+
```mermaid
|
|
37
|
+
|
|
38
|
+
sequenceDiagram
|
|
39
|
+
participant BG as Browser (e.g. background service worker)
|
|
40
|
+
participant CS as Autoconsent content script in page (isolated) world
|
|
41
|
+
|
|
42
|
+
Note over BG: Fetch declarative JSON rules and user settings
|
|
43
|
+
Note over CS: Autoconsent class is instantiated.<br/>Optionally, initConfig is passed to constructor
|
|
44
|
+
|
|
45
|
+
CS -->>+ BG: (if initConfig is not passed already)<br/>init
|
|
46
|
+
BG -->>- CS: initResp<br/>(contains user settings and JSON rules)
|
|
47
|
+
|
|
48
|
+
activate CS
|
|
49
|
+
Note right of CS: Parse rules and initialize autoconsent code
|
|
50
|
+
Note right of CS: apply prehideSelectors
|
|
51
|
+
Note right of CS: wait for DOMContentLoaded
|
|
52
|
+
Note right of CS: detect a CMP presence (not necessarily visible)
|
|
53
|
+
|
|
54
|
+
CS ->> BG: cmpDetected
|
|
55
|
+
Note right of CS: detect a visible cookie popup
|
|
56
|
+
CS ->> BG: popupFound
|
|
57
|
+
deactivate CS
|
|
58
|
+
activate BG
|
|
59
|
+
alt if config.autoAction is NOT defined
|
|
60
|
+
Note left of BG: decide when to trigger opt-in / opt-out
|
|
61
|
+
BG -->> CS: optIn / optOut
|
|
62
|
+
else if config.autoAction IS defined
|
|
63
|
+
Note right of CS: <br/>proceed immediately
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
deactivate BG
|
|
67
|
+
|
|
68
|
+
Note right of CS: execute opt-in / opt-out rules
|
|
69
|
+
CS ->> BG: optOutResult / optInResult
|
|
70
|
+
|
|
71
|
+
opt if not intermediate ruleset
|
|
72
|
+
CS ->> BG: autoconsentDone
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
opt optional
|
|
76
|
+
BG -->>+ CS: (optional) selfTest
|
|
77
|
+
Note right of CS: execute self-test rules
|
|
78
|
+
CS -->>- BG: selfTestResult
|
|
79
|
+
end
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Asynchronous eval rules
|
|
83
|
+
|
|
84
|
+
Some rulesets rely on [eval rules](/readme.md#eval) executed in page main context. Since the content script lives in an isolated world, it passes those calls to the more powerful background worker.
|
|
85
|
+
|
|
86
|
+
**Warning**: eval rules are potentially dangerous and should be avoided when possible.
|
|
87
|
+
|
|
88
|
+
```mermaid
|
|
89
|
+
sequenceDiagram
|
|
90
|
+
participant P as Page main world
|
|
91
|
+
participant BG as Browser (e.g. background service worker)
|
|
92
|
+
participant CS as Autoconsent content script in page (isolated) world
|
|
93
|
+
|
|
94
|
+
Note over CS: Needs to evaluate <PAYLOAD> in the main world (e.g. interact with API)
|
|
95
|
+
|
|
96
|
+
CS ->> BG: { type: "eval", id: <UUID>, code: <PAYLOAD> }
|
|
97
|
+
activate BG
|
|
98
|
+
BG ->>+ P: evaluate <PAYLOAD> using platform-specific APIs<br/>e.g. chrome.scripting.executeScript()
|
|
99
|
+
P ->>- BG: evaluation <RESULT>
|
|
100
|
+
BG ->> CS: { type: "evalResp", id: <UUID>, result: <RESULT> }
|
|
101
|
+
deactivate BG
|
|
102
|
+
|
|
103
|
+
Note over CS: Continue rule execution (or fail with timeout)
|
|
104
|
+
```
|