@slashgear/gdpr-cookie-scanner 3.6.0 → 3.8.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/.dockerignore +3 -0
- package/.gitattributes +1 -0
- package/.github/workflows/website.yml +80 -0
- package/CHANGELOG.md +52 -0
- package/CLAUDE.md +12 -1
- package/CONTRIBUTING.md +32 -4
- package/NEXT_STEPS.md +37 -3
- package/README.md +23 -0
- package/dist/analyzers/colour.d.ts +36 -0
- package/dist/analyzers/colour.d.ts.map +1 -0
- package/dist/analyzers/colour.js +75 -0
- package/dist/analyzers/colour.js.map +1 -0
- package/dist/analyzers/compliance.d.ts.map +1 -1
- package/dist/analyzers/compliance.js +24 -6
- package/dist/analyzers/compliance.js.map +1 -1
- package/dist/analyzers/tcf-decoder.d.ts +9 -0
- package/dist/analyzers/tcf-decoder.d.ts.map +1 -0
- package/dist/analyzers/tcf-decoder.js +123 -0
- package/dist/analyzers/tcf-decoder.js.map +1 -0
- package/dist/analyzers/wording.d.ts +1 -0
- package/dist/analyzers/wording.d.ts.map +1 -1
- package/dist/analyzers/wording.js +39 -0
- package/dist/analyzers/wording.js.map +1 -1
- package/dist/report/generator.d.ts +1 -0
- package/dist/report/generator.d.ts.map +1 -1
- package/dist/report/generator.js +71 -1
- package/dist/report/generator.js.map +1 -1
- package/dist/report/html.d.ts.map +1 -1
- package/dist/report/html.js +123 -0
- package/dist/report/html.js.map +1 -1
- package/dist/scanner/consent-modal.d.ts.map +1 -1
- package/dist/scanner/consent-modal.js +4 -2
- package/dist/scanner/consent-modal.js.map +1 -1
- package/dist/scanner/index.d.ts.map +1 -1
- package/dist/scanner/index.js +4 -0
- package/dist/scanner/index.js.map +1 -1
- package/dist/scanner/tcf.d.ts +9 -0
- package/dist/scanner/tcf.d.ts.map +1 -0
- package/dist/scanner/tcf.js +72 -0
- package/dist/scanner/tcf.js.map +1 -0
- package/dist/types.d.ts +26 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +7 -3
- package/pnpm-workspace.yaml +3 -0
- package/scripts/build-showcase.mjs +113 -0
- package/src/analyzers/colour.ts +89 -0
- package/src/analyzers/compliance.ts +35 -10
- package/src/analyzers/tcf-decoder.ts +130 -0
- package/src/analyzers/wording.ts +44 -0
- package/src/report/generator.ts +83 -1
- package/src/report/html.ts +146 -0
- package/src/scanner/consent-modal.ts +3 -1
- package/src/scanner/index.ts +5 -0
- package/src/scanner/tcf.ts +80 -0
- package/src/types.ts +29 -0
- package/tests/analyzers/colour.test.ts +187 -0
- package/tests/analyzers/compliance.test.ts +102 -0
- package/tests/analyzers/tcf-decoder.test.ts +292 -0
- package/tests/analyzers/wording.test.ts +38 -0
- package/tests/scanner/button-classification.test.ts +32 -0
- package/website/Dockerfile +55 -0
- package/website/node_modules/.bin/oxfmt +21 -0
- package/website/node_modules/.bin/oxlint +21 -0
- package/website/node_modules/.bin/tsc +21 -0
- package/website/node_modules/.bin/tsserver +21 -0
- package/website/node_modules/.bin/tsx +21 -0
- package/website/package.json +29 -0
- package/{docs → website/public}/index.html +88 -50
- package/website/public/reports/www.20minutes.fr/after-accept.png +3 -0
- package/website/public/reports/www.20minutes.fr/after-reject.png +3 -0
- package/website/public/reports/www.20minutes.fr/gdpr-report-20minutes.fr-2026-02-22.html +907 -0
- package/website/public/reports/www.20minutes.fr/modal-initial.png +3 -0
- package/website/public/reports/www.arte.tv/after-accept.png +3 -0
- package/website/public/reports/www.arte.tv/after-reject.png +3 -0
- package/website/public/reports/www.arte.tv/gdpr-report-arte.tv-2026-02-24.html +998 -0
- package/website/public/reports/www.arte.tv/modal-initial.png +3 -0
- package/website/public/reports/www.backmarket.fr/after-accept.png +3 -0
- package/website/public/reports/www.backmarket.fr/after-reject.png +3 -0
- package/website/public/reports/www.backmarket.fr/gdpr-report-backmarket.fr-2026-02-24.html +1530 -0
- package/website/public/reports/www.backmarket.fr/modal-initial.png +3 -0
- package/website/public/reports/www.deezer.com/after-accept.png +3 -0
- package/website/public/reports/www.deezer.com/after-reject.png +3 -0
- package/website/public/reports/www.deezer.com/gdpr-report-deezer.com-2026-02-22.html +1668 -0
- package/website/public/reports/www.deezer.com/modal-initial.png +3 -0
- package/website/public/reports/www.france.tv/after-accept.png +3 -0
- package/website/public/reports/www.france.tv/after-reject.png +3 -0
- package/website/public/reports/www.france.tv/gdpr-report-france.tv-2026-02-23.html +977 -0
- package/website/public/reports/www.france.tv/modal-initial.png +3 -0
- package/website/public/reports/www.m6.fr/after-accept.png +3 -0
- package/website/public/reports/www.m6.fr/after-reject.png +3 -0
- package/website/public/reports/www.m6.fr/gdpr-report-m6.fr-2026-02-28.html +1862 -0
- package/website/public/reports/www.m6.fr/modal-initial.png +3 -0
- package/website/public/reports/www.netflix.com/after-accept.png +3 -0
- package/website/public/reports/www.netflix.com/after-reject.png +3 -0
- package/website/public/reports/www.netflix.com/gdpr-report-netflix.com-2026-02-23.html +1051 -0
- package/website/public/reports/www.netflix.com/modal-initial.png +3 -0
- package/website/public/reports/www.radiofrance.fr/after-accept.png +3 -0
- package/website/public/reports/www.radiofrance.fr/after-reject.png +3 -0
- package/website/public/reports/www.radiofrance.fr/gdpr-report-radiofrance.fr-2026-02-24.html +1146 -0
- package/website/public/reports/www.radiofrance.fr/modal-initial.png +3 -0
- package/website/public/reports/www.tf1.fr/after-accept.png +3 -0
- package/website/public/reports/www.tf1.fr/after-reject.png +3 -0
- package/website/public/reports/www.tf1.fr/gdpr-report-tf1.fr-2026-02-23.html +1512 -0
- package/website/public/reports/www.tf1.fr/modal-initial.png +3 -0
- package/website/src/index.ts +15 -0
- package/website/src/security.ts +26 -0
- package/website/tsconfig.json +14 -0
- package/.github/workflows/pages.yml +0 -40
- package/docs/reports/github.com/after-accept.png +0 -0
- package/docs/reports/github.com/after-reject.png +0 -0
- package/docs/reports/github.com/gdpr-checklist-github.com-2026-02-22.md +0 -44
- package/docs/reports/github.com/gdpr-cookies-github.com-2026-02-22.md +0 -29
- package/docs/reports/github.com/gdpr-report-github.com-2026-02-22.md +0 -102
- package/docs/reports/github.com/gdpr-report-github.com-2026-02-22.pdf +0 -0
- package/docs/reports/gitlab.com/after-accept.png +0 -0
- package/docs/reports/gitlab.com/after-reject.png +0 -0
- package/docs/reports/gitlab.com/gdpr-checklist-gitlab.com-2026-02-22.md +0 -44
- package/docs/reports/gitlab.com/gdpr-cookies-gitlab.com-2026-02-22.md +0 -55
- package/docs/reports/gitlab.com/gdpr-report-gitlab.com-2026-02-22.md +0 -200
- package/docs/reports/gitlab.com/gdpr-report-gitlab.com-2026-02-22.pdf +0 -0
- package/docs/reports/gitlab.com/modal-initial.png +0 -0
- package/docs/reports/npmjs.com/after-accept.png +0 -0
- package/docs/reports/npmjs.com/after-reject.png +0 -0
- package/docs/reports/npmjs.com/gdpr-checklist-npmjs.com-2026-02-22.md +0 -44
- package/docs/reports/npmjs.com/gdpr-cookies-npmjs.com-2026-02-22.md +0 -25
- package/docs/reports/npmjs.com/gdpr-report-npmjs.com-2026-02-22.md +0 -88
- package/docs/reports/npmjs.com/gdpr-report-npmjs.com-2026-02-22.pdf +0 -0
- package/docs/reports/reddit.com/after-accept.png +0 -0
- package/docs/reports/reddit.com/after-reject.png +0 -0
- package/docs/reports/reddit.com/gdpr-checklist-reddit.com-2026-02-22.md +0 -44
- package/docs/reports/reddit.com/gdpr-cookies-reddit.com-2026-02-22.md +0 -33
- package/docs/reports/reddit.com/gdpr-report-reddit.com-2026-02-22.md +0 -148
- package/docs/reports/reddit.com/gdpr-report-reddit.com-2026-02-22.pdf +0 -0
- package/docs/reports/reddit.com/modal-initial.png +0 -0
- package/docs/reports/stackoverflow.com/after-accept.png +0 -0
- package/docs/reports/stackoverflow.com/after-reject.png +0 -0
- package/docs/reports/stackoverflow.com/gdpr-checklist-stackoverflow.com-2026-02-22.md +0 -44
- package/docs/reports/stackoverflow.com/gdpr-cookies-stackoverflow.com-2026-02-22.md +0 -67
- package/docs/reports/stackoverflow.com/gdpr-report-stackoverflow.com-2026-02-22.md +0 -206
- package/docs/reports/stackoverflow.com/gdpr-report-stackoverflow.com-2026-02-22.pdf +0 -0
- package/docs/reports/stackoverflow.com/modal-initial.png +0 -0
- package/docs/reports/www.afp.com/after-accept.png +0 -0
- package/docs/reports/www.afp.com/after-reject.png +0 -0
- package/docs/reports/www.afp.com/gdpr-checklist-afp.com-2026-02-22.md +0 -44
- package/docs/reports/www.afp.com/gdpr-cookies-afp.com-2026-02-22.md +0 -42
- package/docs/reports/www.afp.com/gdpr-report-afp.com-2026-02-22.md +0 -202
- package/docs/reports/www.afp.com/gdpr-report-afp.com-2026-02-22.pdf +0 -0
- package/docs/reports/www.afp.com/modal-initial.png +0 -0
- /package/{docs → website/public}/style.css +0 -0
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
|
2
|
+
import {
|
|
3
|
+
decodeTcfConsentString,
|
|
4
|
+
IAB_PURPOSES,
|
|
5
|
+
IAB_SPECIAL_FEATURES,
|
|
6
|
+
} from "../../src/analyzers/tcf-decoder.js";
|
|
7
|
+
|
|
8
|
+
// ── Fixture builder ───────────────────────────────────────────────────────────
|
|
9
|
+
//
|
|
10
|
+
// Encodes an array of [bitCount, value] pairs into a base64url string
|
|
11
|
+
// suitable for passing to decodeTcfConsentString().
|
|
12
|
+
// Uses modulo + Math.floor to avoid 32-bit overflow on large timestamps.
|
|
13
|
+
|
|
14
|
+
function makeTcfString(fields: Array<[bits: number, value: number]>): string {
|
|
15
|
+
const totalBits = fields.reduce((s, [b]) => s + b, 0);
|
|
16
|
+
const buf = Buffer.alloc(Math.ceil(totalBits / 8), 0);
|
|
17
|
+
let pos = 0;
|
|
18
|
+
for (const [bits, value] of fields) {
|
|
19
|
+
const arr: number[] = [];
|
|
20
|
+
let v = value;
|
|
21
|
+
for (let i = 0; i < bits; i++) {
|
|
22
|
+
arr.unshift(v % 2);
|
|
23
|
+
v = Math.floor(v / 2);
|
|
24
|
+
}
|
|
25
|
+
for (const bit of arr) {
|
|
26
|
+
if (bit) buf[Math.floor(pos / 8)] |= 1 << (7 - (pos % 8));
|
|
27
|
+
pos++;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return buf.toString("base64").replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** Encode a 2-char ISO language/country code into 12 bits (A=0). */
|
|
34
|
+
function langBits(code: string): number {
|
|
35
|
+
return ((code.charCodeAt(0) - 65) << 6) | (code.charCodeAt(1) - 65);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** Encode a list of purpose IDs (1-based) into a 24-bit bitfield. */
|
|
39
|
+
function purposeBits(ids: number[]): number {
|
|
40
|
+
return ids.reduce((acc, id) => acc | (1 << (24 - id)), 0);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** Encode a list of special feature IDs (1-based) into a 12-bit bitfield. */
|
|
44
|
+
function specialFeatureBits(ids: number[]): number {
|
|
45
|
+
return ids.reduce((acc, id) => acc | (1 << (12 - id)), 0);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// 2020-01-01T00:00:00.000Z in deciseconds
|
|
49
|
+
const EPOCH_2020_DS = 15778368000;
|
|
50
|
+
|
|
51
|
+
function makeTcfV2(
|
|
52
|
+
opts: {
|
|
53
|
+
cmpId?: number;
|
|
54
|
+
cmpVersion?: number;
|
|
55
|
+
consentLanguage?: string;
|
|
56
|
+
vendorListVersion?: number;
|
|
57
|
+
tcfPolicyVersion?: number;
|
|
58
|
+
isServiceSpecific?: boolean;
|
|
59
|
+
specialFeatures?: number[];
|
|
60
|
+
purposesConsent?: number[];
|
|
61
|
+
purposesLI?: number[];
|
|
62
|
+
publisherCC?: string;
|
|
63
|
+
} = {},
|
|
64
|
+
): string {
|
|
65
|
+
const {
|
|
66
|
+
cmpId = 28,
|
|
67
|
+
cmpVersion = 1,
|
|
68
|
+
consentLanguage = "EN",
|
|
69
|
+
vendorListVersion = 65,
|
|
70
|
+
tcfPolicyVersion = 2,
|
|
71
|
+
isServiceSpecific = false,
|
|
72
|
+
specialFeatures = [],
|
|
73
|
+
purposesConsent = [],
|
|
74
|
+
purposesLI = [],
|
|
75
|
+
publisherCC = "DE",
|
|
76
|
+
} = opts;
|
|
77
|
+
|
|
78
|
+
return makeTcfString([
|
|
79
|
+
[6, 2], // version = 2
|
|
80
|
+
[36, EPOCH_2020_DS], // created
|
|
81
|
+
[36, EPOCH_2020_DS], // lastUpdated
|
|
82
|
+
[12, cmpId],
|
|
83
|
+
[12, cmpVersion],
|
|
84
|
+
[6, 0], // consentScreen
|
|
85
|
+
[12, langBits(consentLanguage)],
|
|
86
|
+
[12, vendorListVersion],
|
|
87
|
+
[6, tcfPolicyVersion],
|
|
88
|
+
[1, isServiceSpecific ? 1 : 0],
|
|
89
|
+
[1, 0], // useNonStandardStacks
|
|
90
|
+
[12, specialFeatureBits(specialFeatures)],
|
|
91
|
+
[24, purposeBits(purposesConsent)],
|
|
92
|
+
[24, purposeBits(purposesLI)],
|
|
93
|
+
[1, 0], // purposeOneTreatment
|
|
94
|
+
[12, langBits(publisherCC)],
|
|
95
|
+
]);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function makeTcfV1(
|
|
99
|
+
opts: {
|
|
100
|
+
cmpId?: number;
|
|
101
|
+
cmpVersion?: number;
|
|
102
|
+
consentLanguage?: string;
|
|
103
|
+
vendorListVersion?: number;
|
|
104
|
+
purposesAllowed?: number[];
|
|
105
|
+
} = {},
|
|
106
|
+
): string {
|
|
107
|
+
const {
|
|
108
|
+
cmpId = 10,
|
|
109
|
+
cmpVersion = 1,
|
|
110
|
+
consentLanguage = "FR",
|
|
111
|
+
vendorListVersion = 12,
|
|
112
|
+
purposesAllowed = [],
|
|
113
|
+
} = opts;
|
|
114
|
+
|
|
115
|
+
return makeTcfString([
|
|
116
|
+
[6, 1], // version = 1
|
|
117
|
+
[36, EPOCH_2020_DS], // created
|
|
118
|
+
[36, EPOCH_2020_DS], // lastUpdated
|
|
119
|
+
[12, cmpId],
|
|
120
|
+
[12, cmpVersion],
|
|
121
|
+
[6, 0], // consentScreen
|
|
122
|
+
[12, langBits(consentLanguage)],
|
|
123
|
+
[12, vendorListVersion],
|
|
124
|
+
[24, purposeBits(purposesAllowed)],
|
|
125
|
+
]);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// ── TCF v2 ────────────────────────────────────────────────────────────────────
|
|
129
|
+
|
|
130
|
+
describe("decodeTcfConsentString — TCF v2", () => {
|
|
131
|
+
it("decodes version 2", () => {
|
|
132
|
+
expect(decodeTcfConsentString(makeTcfV2())?.version).toBe(2);
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
it("decodes CMP ID and version", () => {
|
|
136
|
+
const result = decodeTcfConsentString(makeTcfV2({ cmpId: 28, cmpVersion: 3 }));
|
|
137
|
+
expect(result?.cmpId).toBe(28);
|
|
138
|
+
expect(result?.cmpVersion).toBe(3);
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
it("decodes consent language", () => {
|
|
142
|
+
expect(decodeTcfConsentString(makeTcfV2({ consentLanguage: "FR" }))?.consentLanguage).toBe(
|
|
143
|
+
"FR",
|
|
144
|
+
);
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
it("decodes timestamps as Date objects", () => {
|
|
148
|
+
const result = decodeTcfConsentString(makeTcfV2());
|
|
149
|
+
expect(result?.created).toEqual(new Date(EPOCH_2020_DS * 100));
|
|
150
|
+
expect(result?.lastUpdated).toEqual(new Date(EPOCH_2020_DS * 100));
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
it("decodes purposesConsent", () => {
|
|
154
|
+
const result = decodeTcfConsentString(makeTcfV2({ purposesConsent: [1, 2, 7] }));
|
|
155
|
+
expect(result?.purposesConsent).toEqual([1, 2, 7]);
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
it("decodes purposesLegitimateInterest", () => {
|
|
159
|
+
const result = decodeTcfConsentString(makeTcfV2({ purposesLI: [2, 4, 9] }));
|
|
160
|
+
expect(result?.purposesLegitimateInterest).toEqual([2, 4, 9]);
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
it("decodes specialFeatureOptins", () => {
|
|
164
|
+
const result = decodeTcfConsentString(makeTcfV2({ specialFeatures: [1, 2] }));
|
|
165
|
+
expect(result?.specialFeatureOptins).toEqual([1, 2]);
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
it("returns empty arrays when nothing is set", () => {
|
|
169
|
+
const result = decodeTcfConsentString(
|
|
170
|
+
makeTcfV2({ purposesConsent: [], purposesLI: [], specialFeatures: [] }),
|
|
171
|
+
);
|
|
172
|
+
expect(result?.purposesConsent).toEqual([]);
|
|
173
|
+
expect(result?.purposesLegitimateInterest).toEqual([]);
|
|
174
|
+
expect(result?.specialFeatureOptins).toEqual([]);
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
it("decodes publisherCC", () => {
|
|
178
|
+
expect(decodeTcfConsentString(makeTcfV2({ publisherCC: "FR" }))?.publisherCC).toBe("FR");
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
it("decodes isServiceSpecific", () => {
|
|
182
|
+
expect(decodeTcfConsentString(makeTcfV2({ isServiceSpecific: true }))?.isServiceSpecific).toBe(
|
|
183
|
+
true,
|
|
184
|
+
);
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
it("decodes tcfPolicyVersion", () => {
|
|
188
|
+
expect(decodeTcfConsentString(makeTcfV2({ tcfPolicyVersion: 4 }))?.tcfPolicyVersion).toBe(4);
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
it("decodes vendorListVersion", () => {
|
|
192
|
+
expect(decodeTcfConsentString(makeTcfV2({ vendorListVersion: 130 }))?.vendorListVersion).toBe(
|
|
193
|
+
130,
|
|
194
|
+
);
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
it("preserves the raw string", () => {
|
|
198
|
+
const str = makeTcfV2();
|
|
199
|
+
expect(decodeTcfConsentString(str)?.raw).toBe(str);
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
it("ignores vendor segments after '~'", () => {
|
|
203
|
+
const str = makeTcfV2({ cmpId: 5 });
|
|
204
|
+
const result = decodeTcfConsentString(`${str}~someVendorSegment~anotherSegment`);
|
|
205
|
+
expect(result?.version).toBe(2);
|
|
206
|
+
expect(result?.cmpId).toBe(5);
|
|
207
|
+
});
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
// ── TCF v1 ────────────────────────────────────────────────────────────────────
|
|
211
|
+
|
|
212
|
+
describe("decodeTcfConsentString — TCF v1", () => {
|
|
213
|
+
it("decodes version 1", () => {
|
|
214
|
+
expect(decodeTcfConsentString(makeTcfV1())?.version).toBe(1);
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
it("decodes purposesAllowed as purposesConsent", () => {
|
|
218
|
+
const result = decodeTcfConsentString(makeTcfV1({ purposesAllowed: [1, 3, 5] }));
|
|
219
|
+
expect(result?.purposesConsent).toEqual([1, 3, 5]);
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
it("returns empty legitimateInterest and specialFeatures for v1", () => {
|
|
223
|
+
const result = decodeTcfConsentString(makeTcfV1());
|
|
224
|
+
expect(result?.purposesLegitimateInterest).toEqual([]);
|
|
225
|
+
expect(result?.specialFeatureOptins).toEqual([]);
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
it("decodes CMP ID", () => {
|
|
229
|
+
expect(decodeTcfConsentString(makeTcfV1({ cmpId: 42 }))?.cmpId).toBe(42);
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
it("decodes consent language", () => {
|
|
233
|
+
expect(decodeTcfConsentString(makeTcfV1({ consentLanguage: "DE" }))?.consentLanguage).toBe(
|
|
234
|
+
"DE",
|
|
235
|
+
);
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
it("decodes timestamps as Date objects", () => {
|
|
239
|
+
const result = decodeTcfConsentString(makeTcfV1());
|
|
240
|
+
expect(result?.created).toEqual(new Date(EPOCH_2020_DS * 100));
|
|
241
|
+
});
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
// ── Edge cases ────────────────────────────────────────────────────────────────
|
|
245
|
+
|
|
246
|
+
describe("decodeTcfConsentString — edge cases", () => {
|
|
247
|
+
it("returns null for an empty string", () => {
|
|
248
|
+
expect(decodeTcfConsentString("")).toBeNull();
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
it("returns null for a garbage base64 string", () => {
|
|
252
|
+
expect(decodeTcfConsentString("aaaa")).toBeNull();
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
it("returns null for an unsupported version (v3)", () => {
|
|
256
|
+
const str = makeTcfString([
|
|
257
|
+
[6, 3], // version = 3, unsupported
|
|
258
|
+
[36, 0],
|
|
259
|
+
[36, 0],
|
|
260
|
+
[12, 1],
|
|
261
|
+
[12, 1],
|
|
262
|
+
[6, 0],
|
|
263
|
+
[12, langBits("EN")],
|
|
264
|
+
[12, 1],
|
|
265
|
+
]);
|
|
266
|
+
expect(decodeTcfConsentString(str)).toBeNull();
|
|
267
|
+
});
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
// ── IAB constants ─────────────────────────────────────────────────────────────
|
|
271
|
+
|
|
272
|
+
describe("IAB_PURPOSES", () => {
|
|
273
|
+
it("contains all 11 standard purposes", () => {
|
|
274
|
+
for (let i = 1; i <= 11; i++) {
|
|
275
|
+
expect(IAB_PURPOSES[i], `purpose ${i}`).toBeDefined();
|
|
276
|
+
}
|
|
277
|
+
});
|
|
278
|
+
|
|
279
|
+
it("purpose 1 is about device storage", () => {
|
|
280
|
+
expect(IAB_PURPOSES[1]).toMatch(/store/i);
|
|
281
|
+
});
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
describe("IAB_SPECIAL_FEATURES", () => {
|
|
285
|
+
it("contains exactly 2 special features", () => {
|
|
286
|
+
expect(Object.keys(IAB_SPECIAL_FEATURES)).toHaveLength(2);
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
it("feature 1 is about geolocation", () => {
|
|
290
|
+
expect(IAB_SPECIAL_FEATURES[1]).toMatch(/geolocation/i);
|
|
291
|
+
});
|
|
292
|
+
});
|
|
@@ -84,6 +84,44 @@ describe("analyzeButtonWording", () => {
|
|
|
84
84
|
});
|
|
85
85
|
});
|
|
86
86
|
|
|
87
|
+
describe("indirect reject — refusal implied, not stated", () => {
|
|
88
|
+
it.each([
|
|
89
|
+
"Continuer sans accepter",
|
|
90
|
+
"Continue without accepting",
|
|
91
|
+
"Continue without consent",
|
|
92
|
+
"Proceed without accepting",
|
|
93
|
+
"Continuar sin aceptar",
|
|
94
|
+
"Continua senza accettare",
|
|
95
|
+
"Weiter ohne akzeptieren",
|
|
96
|
+
])('flags "%s" as indirect reject (warning)', (text) => {
|
|
97
|
+
const buttons = [makeButton("accept", "Accept all"), makeButton("reject", text)];
|
|
98
|
+
const result = analyzeButtonWording(buttons);
|
|
99
|
+
expect(result.hasIndirectRejectLabel).toBe(true);
|
|
100
|
+
const issue = result.issues.find(
|
|
101
|
+
(i) => i.type === "misleading-wording" && i.severity === "warning",
|
|
102
|
+
);
|
|
103
|
+
expect(issue).toBeDefined();
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
it("does NOT flag an explicit Reject button as indirect", () => {
|
|
107
|
+
const buttons = [makeButton("accept", "Accept all"), makeButton("reject", "Reject all")];
|
|
108
|
+
const result = analyzeButtonWording(buttons);
|
|
109
|
+
expect(result.hasIndirectRejectLabel).toBe(false);
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
it("does NOT flag 'Tout refuser' as indirect", () => {
|
|
113
|
+
const buttons = [makeButton("accept", "Tout accepter"), makeButton("reject", "Tout refuser")];
|
|
114
|
+
const result = analyzeButtonWording(buttons);
|
|
115
|
+
expect(result.hasIndirectRejectLabel).toBe(false);
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
it("returns hasIndirectRejectLabel: false when there is no reject button", () => {
|
|
119
|
+
const buttons = [makeButton("accept", "Accept all")];
|
|
120
|
+
const result = analyzeButtonWording(buttons);
|
|
121
|
+
expect(result.hasIndirectRejectLabel).toBe(false);
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
|
|
87
125
|
describe("fake reject — close/dismiss button disguised as reject", () => {
|
|
88
126
|
it.each(["×", "✕", "close", "Fermer", "dismiss", "skip"])(
|
|
89
127
|
'flags "%s" reject button as misleading (fake reject)',
|
|
@@ -191,6 +191,38 @@ describe("classifyButtonText — null (unknown language)", () => {
|
|
|
191
191
|
});
|
|
192
192
|
});
|
|
193
193
|
|
|
194
|
+
// ── "Continue without accepting" dark pattern ─────────────────────────────────
|
|
195
|
+
//
|
|
196
|
+
// Some sites hide their reject action behind a phrase that contains the word
|
|
197
|
+
// "accept" or an equivalent, making automated classifiers misread it as an
|
|
198
|
+
// accept button. These must be classified as "reject".
|
|
199
|
+
|
|
200
|
+
describe('classifyButtonText — "continue without accepting" dark pattern', () => {
|
|
201
|
+
it('FR: "Continuer sans accepter" → reject', () => {
|
|
202
|
+
expect(classifyButtonText("Continuer sans accepter", "fr")).toBe("reject");
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
it('EN: "Continue without accepting" → reject', () => {
|
|
206
|
+
expect(classifyButtonText("Continue without accepting", "en")).toBe("reject");
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
it('EN: "Continue without consent" → reject', () => {
|
|
210
|
+
expect(classifyButtonText("Continue without consent", "en")).toBe("reject");
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
it('ES: "Continuar sin aceptar" → reject', () => {
|
|
214
|
+
expect(classifyButtonText("Continuar sin aceptar", "es")).toBe("reject");
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
it('FR: "Accepter" alone → still accept (no regression)', () => {
|
|
218
|
+
expect(classifyButtonText("Accepter", "fr")).toBe("accept");
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
it('FR: "Tout accepter" → still accept (no regression)', () => {
|
|
222
|
+
expect(classifyButtonText("Tout accepter", "fr")).toBe("accept");
|
|
223
|
+
});
|
|
224
|
+
});
|
|
225
|
+
|
|
194
226
|
// ── BCP 47 subtag normalisation (sanity) ─────────────────────────────────────
|
|
195
227
|
|
|
196
228
|
describe("classifyButtonText — full BCP 47 tags should be pre-normalised", () => {
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# Build context: repo root (docker build -f website/Dockerfile .)
|
|
2
|
+
|
|
3
|
+
# ── Stage 1: build ────────────────────────────────────────────────────────────
|
|
4
|
+
FROM node:24-slim AS builder
|
|
5
|
+
WORKDIR /app
|
|
6
|
+
|
|
7
|
+
# Install compression tools (brotli, zstd, zopfli)
|
|
8
|
+
RUN apt-get update && apt-get install -y --no-install-recommends brotli zstd zopfli \
|
|
9
|
+
&& rm -rf /var/lib/apt/lists/*
|
|
10
|
+
|
|
11
|
+
RUN npm install -g pnpm@latest
|
|
12
|
+
|
|
13
|
+
# Copy workspace manifests for layer caching
|
|
14
|
+
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
|
|
15
|
+
COPY website/package.json ./website/
|
|
16
|
+
|
|
17
|
+
# Install website deps only (no playwright, no CLI deps)
|
|
18
|
+
RUN pnpm install --frozen-lockfile --filter @slashgear/gdpr-website
|
|
19
|
+
|
|
20
|
+
# Copy source and compile
|
|
21
|
+
COPY website/tsconfig.json ./website/
|
|
22
|
+
COPY website/src ./website/src
|
|
23
|
+
RUN pnpm --filter @slashgear/gdpr-website build
|
|
24
|
+
|
|
25
|
+
# Copy static assets and precompress them
|
|
26
|
+
COPY website/public ./website/public
|
|
27
|
+
RUN find /app/website/public -type f \( -name "*.html" -o -name "*.css" -o -name "*.js" -o -name "*.json" -o -name "*.svg" \) | \
|
|
28
|
+
while read f; do \
|
|
29
|
+
brotli --best -k "$f"; \
|
|
30
|
+
zstd --ultra -22 -k "$f"; \
|
|
31
|
+
zopfli --gzip "$f"; \
|
|
32
|
+
done
|
|
33
|
+
|
|
34
|
+
# ── Stage 2: runtime ──────────────────────────────────────────────────────────
|
|
35
|
+
FROM node:24-slim
|
|
36
|
+
WORKDIR /app
|
|
37
|
+
ENV NODE_ENV=production
|
|
38
|
+
|
|
39
|
+
RUN npm install -g pnpm@latest
|
|
40
|
+
|
|
41
|
+
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
|
|
42
|
+
COPY website/package.json ./website/
|
|
43
|
+
RUN pnpm install --prod --frozen-lockfile --filter @slashgear/gdpr-website
|
|
44
|
+
|
|
45
|
+
# Static assets with precompressed variants (.br, .zst, .gz)
|
|
46
|
+
COPY --from=builder /app/website/public ./website/public
|
|
47
|
+
|
|
48
|
+
# Compiled server
|
|
49
|
+
COPY --from=builder /app/website/dist ./website/dist
|
|
50
|
+
|
|
51
|
+
WORKDIR /app/website
|
|
52
|
+
ENV PORT=8080
|
|
53
|
+
EXPOSE 8080
|
|
54
|
+
|
|
55
|
+
CMD ["node", "dist/index.js"]
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
|
3
|
+
|
|
4
|
+
case `uname` in
|
|
5
|
+
*CYGWIN*|*MINGW*|*MSYS*)
|
|
6
|
+
if command -v cygpath > /dev/null 2>&1; then
|
|
7
|
+
basedir=`cygpath -w "$basedir"`
|
|
8
|
+
fi
|
|
9
|
+
;;
|
|
10
|
+
esac
|
|
11
|
+
|
|
12
|
+
if [ -z "$NODE_PATH" ]; then
|
|
13
|
+
export NODE_PATH="/home/runner/work/gdpr-cookie-scanner/gdpr-cookie-scanner/node_modules/.pnpm/oxfmt@0.34.0/node_modules/oxfmt/node_modules:/home/runner/work/gdpr-cookie-scanner/gdpr-cookie-scanner/node_modules/.pnpm/oxfmt@0.34.0/node_modules:/home/runner/work/gdpr-cookie-scanner/gdpr-cookie-scanner/node_modules/.pnpm/node_modules"
|
|
14
|
+
else
|
|
15
|
+
export NODE_PATH="/home/runner/work/gdpr-cookie-scanner/gdpr-cookie-scanner/node_modules/.pnpm/oxfmt@0.34.0/node_modules/oxfmt/node_modules:/home/runner/work/gdpr-cookie-scanner/gdpr-cookie-scanner/node_modules/.pnpm/oxfmt@0.34.0/node_modules:/home/runner/work/gdpr-cookie-scanner/gdpr-cookie-scanner/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
16
|
+
fi
|
|
17
|
+
if [ -x "$basedir/node" ]; then
|
|
18
|
+
exec "$basedir/node" "$basedir/../oxfmt/bin/oxfmt" "$@"
|
|
19
|
+
else
|
|
20
|
+
exec node "$basedir/../oxfmt/bin/oxfmt" "$@"
|
|
21
|
+
fi
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
|
3
|
+
|
|
4
|
+
case `uname` in
|
|
5
|
+
*CYGWIN*|*MINGW*|*MSYS*)
|
|
6
|
+
if command -v cygpath > /dev/null 2>&1; then
|
|
7
|
+
basedir=`cygpath -w "$basedir"`
|
|
8
|
+
fi
|
|
9
|
+
;;
|
|
10
|
+
esac
|
|
11
|
+
|
|
12
|
+
if [ -z "$NODE_PATH" ]; then
|
|
13
|
+
export NODE_PATH="/home/runner/work/gdpr-cookie-scanner/gdpr-cookie-scanner/node_modules/.pnpm/oxlint@1.49.0/node_modules/oxlint/node_modules:/home/runner/work/gdpr-cookie-scanner/gdpr-cookie-scanner/node_modules/.pnpm/oxlint@1.49.0/node_modules:/home/runner/work/gdpr-cookie-scanner/gdpr-cookie-scanner/node_modules/.pnpm/node_modules"
|
|
14
|
+
else
|
|
15
|
+
export NODE_PATH="/home/runner/work/gdpr-cookie-scanner/gdpr-cookie-scanner/node_modules/.pnpm/oxlint@1.49.0/node_modules/oxlint/node_modules:/home/runner/work/gdpr-cookie-scanner/gdpr-cookie-scanner/node_modules/.pnpm/oxlint@1.49.0/node_modules:/home/runner/work/gdpr-cookie-scanner/gdpr-cookie-scanner/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
16
|
+
fi
|
|
17
|
+
if [ -x "$basedir/node" ]; then
|
|
18
|
+
exec "$basedir/node" "$basedir/../oxlint/bin/oxlint" "$@"
|
|
19
|
+
else
|
|
20
|
+
exec node "$basedir/../oxlint/bin/oxlint" "$@"
|
|
21
|
+
fi
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
|
3
|
+
|
|
4
|
+
case `uname` in
|
|
5
|
+
*CYGWIN*|*MINGW*|*MSYS*)
|
|
6
|
+
if command -v cygpath > /dev/null 2>&1; then
|
|
7
|
+
basedir=`cygpath -w "$basedir"`
|
|
8
|
+
fi
|
|
9
|
+
;;
|
|
10
|
+
esac
|
|
11
|
+
|
|
12
|
+
if [ -z "$NODE_PATH" ]; then
|
|
13
|
+
export NODE_PATH="/home/runner/work/gdpr-cookie-scanner/gdpr-cookie-scanner/node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/node_modules:/home/runner/work/gdpr-cookie-scanner/gdpr-cookie-scanner/node_modules/.pnpm/typescript@5.9.3/node_modules:/home/runner/work/gdpr-cookie-scanner/gdpr-cookie-scanner/node_modules/.pnpm/node_modules"
|
|
14
|
+
else
|
|
15
|
+
export NODE_PATH="/home/runner/work/gdpr-cookie-scanner/gdpr-cookie-scanner/node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/node_modules:/home/runner/work/gdpr-cookie-scanner/gdpr-cookie-scanner/node_modules/.pnpm/typescript@5.9.3/node_modules:/home/runner/work/gdpr-cookie-scanner/gdpr-cookie-scanner/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
16
|
+
fi
|
|
17
|
+
if [ -x "$basedir/node" ]; then
|
|
18
|
+
exec "$basedir/node" "$basedir/../typescript/bin/tsc" "$@"
|
|
19
|
+
else
|
|
20
|
+
exec node "$basedir/../typescript/bin/tsc" "$@"
|
|
21
|
+
fi
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
|
3
|
+
|
|
4
|
+
case `uname` in
|
|
5
|
+
*CYGWIN*|*MINGW*|*MSYS*)
|
|
6
|
+
if command -v cygpath > /dev/null 2>&1; then
|
|
7
|
+
basedir=`cygpath -w "$basedir"`
|
|
8
|
+
fi
|
|
9
|
+
;;
|
|
10
|
+
esac
|
|
11
|
+
|
|
12
|
+
if [ -z "$NODE_PATH" ]; then
|
|
13
|
+
export NODE_PATH="/home/runner/work/gdpr-cookie-scanner/gdpr-cookie-scanner/node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/node_modules:/home/runner/work/gdpr-cookie-scanner/gdpr-cookie-scanner/node_modules/.pnpm/typescript@5.9.3/node_modules:/home/runner/work/gdpr-cookie-scanner/gdpr-cookie-scanner/node_modules/.pnpm/node_modules"
|
|
14
|
+
else
|
|
15
|
+
export NODE_PATH="/home/runner/work/gdpr-cookie-scanner/gdpr-cookie-scanner/node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/node_modules:/home/runner/work/gdpr-cookie-scanner/gdpr-cookie-scanner/node_modules/.pnpm/typescript@5.9.3/node_modules:/home/runner/work/gdpr-cookie-scanner/gdpr-cookie-scanner/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
16
|
+
fi
|
|
17
|
+
if [ -x "$basedir/node" ]; then
|
|
18
|
+
exec "$basedir/node" "$basedir/../typescript/bin/tsserver" "$@"
|
|
19
|
+
else
|
|
20
|
+
exec node "$basedir/../typescript/bin/tsserver" "$@"
|
|
21
|
+
fi
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
|
3
|
+
|
|
4
|
+
case `uname` in
|
|
5
|
+
*CYGWIN*|*MINGW*|*MSYS*)
|
|
6
|
+
if command -v cygpath > /dev/null 2>&1; then
|
|
7
|
+
basedir=`cygpath -w "$basedir"`
|
|
8
|
+
fi
|
|
9
|
+
;;
|
|
10
|
+
esac
|
|
11
|
+
|
|
12
|
+
if [ -z "$NODE_PATH" ]; then
|
|
13
|
+
export NODE_PATH="/home/runner/work/gdpr-cookie-scanner/gdpr-cookie-scanner/node_modules/.pnpm/tsx@4.21.0/node_modules/tsx/node_modules:/home/runner/work/gdpr-cookie-scanner/gdpr-cookie-scanner/node_modules/.pnpm/tsx@4.21.0/node_modules:/home/runner/work/gdpr-cookie-scanner/gdpr-cookie-scanner/node_modules/.pnpm/node_modules"
|
|
14
|
+
else
|
|
15
|
+
export NODE_PATH="/home/runner/work/gdpr-cookie-scanner/gdpr-cookie-scanner/node_modules/.pnpm/tsx@4.21.0/node_modules/tsx/node_modules:/home/runner/work/gdpr-cookie-scanner/gdpr-cookie-scanner/node_modules/.pnpm/tsx@4.21.0/node_modules:/home/runner/work/gdpr-cookie-scanner/gdpr-cookie-scanner/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
16
|
+
fi
|
|
17
|
+
if [ -x "$basedir/node" ]; then
|
|
18
|
+
exec "$basedir/node" "$basedir/../tsx/dist/cli.mjs" "$@"
|
|
19
|
+
else
|
|
20
|
+
exec node "$basedir/../tsx/dist/cli.mjs" "$@"
|
|
21
|
+
fi
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@slashgear/gdpr-website",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"description": "Web interface for gdpr-cookie-scanner",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "tsc",
|
|
9
|
+
"dev": "tsx src/index.ts",
|
|
10
|
+
"start": "node dist/index.js",
|
|
11
|
+
"typecheck": "tsc --noEmit",
|
|
12
|
+
"lint": "oxlint .",
|
|
13
|
+
"format": "oxfmt ."
|
|
14
|
+
},
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@hono/node-server": "^1.14.0",
|
|
17
|
+
"hono": "^4.7.0"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"@types/node": "^22.0.0",
|
|
21
|
+
"oxfmt": "^0.34.0",
|
|
22
|
+
"oxlint": "^1.48.0",
|
|
23
|
+
"tsx": "^4.19.0",
|
|
24
|
+
"typescript": "^5.5.0"
|
|
25
|
+
},
|
|
26
|
+
"engines": {
|
|
27
|
+
"node": ">=24.0.0"
|
|
28
|
+
}
|
|
29
|
+
}
|