@miracle352/statute 0.0.0-stage → 0.3.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/LICENSE +21 -0
- package/README.md +319 -2
- package/action.yml +356 -0
- package/bin/hook.js +81 -0
- package/bin/init.js +142 -0
- package/bin/mcp.js +166 -0
- package/bin/scope.js +78 -0
- package/bin/shots.js +52 -0
- package/bin/statute.js +362 -0
- package/examples/expect/newsletter_test.md +22 -0
- package/examples/expect/output-newsletter/.internal/execution.json +2053 -0
- package/examples/expect/output-newsletter/.internal/meta.json +39 -0
- package/examples/expect/output-newsletter/.internal/steps/1-d2368411/flows/0/actions.ndjson +2 -0
- package/examples/expect/output-newsletter/.internal/steps/2-a9e761f8/flows/0/actions.ndjson +6 -0
- package/examples/expect/output-newsletter/.internal/steps/3-63305a01/flows/0/actions.ndjson +2 -0
- package/examples/expect/output-newsletter/Result.md +21 -0
- package/examples/expect/search_test.md +20 -0
- package/laws/README.md +24 -0
- package/laws/accept_still_works_test.md +12 -0
- package/laws/cancel_as_easy_as_signup_test.md +15 -0
- package/laws/output-reject_means_reject/.internal/execution.json +1279 -0
- package/laws/output-reject_means_reject/.internal/meta.json +18 -0
- package/laws/output-reject_means_reject/.internal/steps/1-567cc234/flows/0/actions.ndjson +6 -0
- package/laws/output-reject_means_reject/.internal/steps/2-e3c06462/flows/0/actions.ndjson +1 -0
- package/laws/output-reject_means_reject/.internal/steps/3-3040a29b/flows/0/actions.ndjson +2 -0
- package/laws/output-reject_means_reject/Result.md +21 -0
- package/laws/price_shown_is_price_paid_test.md +12 -0
- package/laws/reject_means_reject_test.md +15 -0
- package/package.json +65 -4
- package/replays/cancel-demo-shop/evidence/cancel-1794754943192.evidence +0 -0
- package/replays/cancel-demo-shop/evidence/cancel-1794755110410.evidence +0 -0
- package/replays/cancel-demo-shop/loop.json +32 -0
- package/replays/demo-shop/evidence/consent-1794751413210.evidence +0 -0
- package/replays/demo-shop/evidence/consent-1794751523524.evidence +0 -0
- package/replays/demo-shop/evidence/consent-accept-1794751588395.evidence +0 -0
- package/replays/demo-shop/loop.json +40 -0
- package/replays/haxcms/evidence/consent-1794831086682.evidence +0 -0
- package/replays/haxcms/evidence/consent-1794831262757.evidence +0 -0
- package/replays/haxcms/evidence/consent-accept-1794831347132.evidence +0 -0
- package/replays/haxcms/loop.json +56 -0
- package/replays/in-the-wake-check/consent.json +67 -0
- package/replays/in-the-wake-check/consent.md +32 -0
- package/replays/kane-testmd-demo-shop/evidence/consent-1794935266000.evidence +0 -0
- package/replays/kane-testmd-demo-shop/loop.json +18 -0
- package/replays/lumen-pr-2/evidence/consent-1794929771799.evidence +0 -0
- package/replays/lumen-pr-2/evidence/consent-1794929845913.evidence +0 -0
- package/replays/lumen-pr-2/evidence/consent-accept-1794929886905.evidence +0 -0
- package/replays/lumen-pr-2/loop.json +57 -0
- package/replays/newsletter-expect/evidence/newsletter_test-round1-1795518837738.evidence +0 -0
- package/replays/newsletter-expect/evidence/newsletter_test-round2-1795519079029.evidence +0 -0
- package/replays/newsletter-expect/loop.json +99 -0
- package/replays/price-demo-shop/evidence/price-1794837093949.evidence +0 -0
- package/replays/price-demo-shop/evidence/price-1794837311639.evidence +0 -0
- package/replays/price-demo-shop/loop.json +43 -0
- package/rules/trackers.json +61 -0
- package/site/assets/fonts/OFL-archivo.txt +93 -0
- package/site/assets/fonts/OFL-geist.txt +93 -0
- package/site/assets/fonts/OFL-instrument-serif.txt +93 -0
- package/site/assets/fonts/archivo.woff2 +0 -0
- package/site/assets/fonts/geist.woff2 +0 -0
- package/site/assets/fonts/instrument-serif-italic.woff2 +0 -0
- package/site/assets/fonts/instrument-serif.woff2 +0 -0
- package/site/assets/fonts/inter.woff2 +0 -0
- package/site/assets/fonts/jetbrains-mono.woff2 +0 -0
- package/skill/statute/SKILL.md +57 -0
- package/src/agent.js +70 -0
- package/src/app.js +41 -0
- package/src/evidence.js +80 -0
- package/src/expect-cli.js +296 -0
- package/src/expect-view.js +79 -0
- package/src/expect.js +392 -0
- package/src/infer.js +32 -0
- package/src/kane.js +124 -0
- package/src/pack.js +128 -0
- package/src/packs/cancel.js +83 -0
- package/src/packs/consent-accept.js +57 -0
- package/src/packs/consent.js +237 -0
- package/src/packs/price.js +104 -0
- package/src/page.js +360 -0
- package/src/report.js +59 -0
- package/src/zip.js +38 -0
package/src/pack.js
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
// Reads a sealed Kane evidence pack into one structure the rules can query:
|
|
2
|
+
// the test file, its steps (sections), and per step the actions Kane took, the
|
|
3
|
+
// network requests (with bodies) and the console messages, all time-stamped.
|
|
4
|
+
const fs = require("fs");
|
|
5
|
+
const zip = require("./zip");
|
|
6
|
+
|
|
7
|
+
const text = (buf, e) => zip.read(buf, e).toString("utf8");
|
|
8
|
+
const ndjson = (s) => s.split("\n").filter((l) => l.trim()).map((l) => { try { return JSON.parse(l); } catch { return null; } }).filter(Boolean);
|
|
9
|
+
const t = (iso) => (iso ? Date.parse(iso) : null);
|
|
10
|
+
|
|
11
|
+
// "---\nmode: testing\nexpect:\n - a\n - b\n---" -> { mode: "testing", expect: ["a","b"] }
|
|
12
|
+
// Only what Statute needs: scalars and one level of "- item" lists.
|
|
13
|
+
function frontmatter(md) {
|
|
14
|
+
const m = String(md || "").match(/^?---\r?\n([\s\S]*?)\r?\n---/);
|
|
15
|
+
if (!m) return {};
|
|
16
|
+
const out = {};
|
|
17
|
+
let list = null;
|
|
18
|
+
for (const raw of m[1].split(/\r?\n/)) {
|
|
19
|
+
const item = raw.match(/^\s+-\s+(.*)$/);
|
|
20
|
+
if (item && list) { list.push(unquote(item[1])); continue; }
|
|
21
|
+
const kv = raw.match(/^([A-Za-z_][\w-]*):\s*(.*)$/);
|
|
22
|
+
if (!kv) continue;
|
|
23
|
+
if (kv[2] === "") { list = out[kv[1]] = []; continue; }
|
|
24
|
+
list = null;
|
|
25
|
+
out[kv[1]] = unquote(kv[2]);
|
|
26
|
+
}
|
|
27
|
+
return out;
|
|
28
|
+
}
|
|
29
|
+
function unquote(s) {
|
|
30
|
+
s = s.trim();
|
|
31
|
+
if (/^'.*'$/.test(s)) return s.slice(1, -1).replace(/''/g, "'");
|
|
32
|
+
if (/^".*"$/.test(s)) return s.slice(1, -1).replace(/\\"/g, '"');
|
|
33
|
+
return s;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// "## Refuse cookies" headings, in order. Kane writes one log set per heading.
|
|
37
|
+
function headings(md) {
|
|
38
|
+
const body = String(md || "").replace(/^?---\r?\n[\s\S]*?\r?\n---/, "");
|
|
39
|
+
return [...body.matchAll(/^##\s+(.+?)\s*$/gm)].map((m) => m[1]);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function read(packPath) {
|
|
43
|
+
return readBuffer(fs.readFileSync(packPath), packPath);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// The same, from the bytes of a pack (an upload, say).
|
|
47
|
+
function readBuffer(buf, packPath = null) {
|
|
48
|
+
const list = zip.entries(buf);
|
|
49
|
+
const md = list.find((e) => /(^|\/)test\.md$/.test(e.name));
|
|
50
|
+
const testMd = md ? text(buf, md) : null;
|
|
51
|
+
const titles = headings(testMd);
|
|
52
|
+
const sections = new Map();
|
|
53
|
+
const section = (i) => {
|
|
54
|
+
if (!sections.has(i)) sections.set(i, { index: i, title: titles[i] || (titles.length ? `step ${i + 1}` : "run"), actions: [], requests: [], console: [] });
|
|
55
|
+
return sections.get(i);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
for (const e of list) {
|
|
59
|
+
const m = e.name.match(/logs\/(?:(\d+)-)?(actions\.ndjson|network\.har|console\.ndjson)$/);
|
|
60
|
+
if (!m) continue;
|
|
61
|
+
const s = section(Number(m[1] || 0));
|
|
62
|
+
const raw = text(buf, e);
|
|
63
|
+
if (m[2] === "actions.ndjson") {
|
|
64
|
+
for (const a of ndjson(raw)) {
|
|
65
|
+
s.actions.push({
|
|
66
|
+
section: s.index, type: a.action_type, status: a.status, time: t(a.timestamp),
|
|
67
|
+
instruction: a.action_instruction || "", intent: a.intent || "",
|
|
68
|
+
params: a.action_params || {}, variable: a.output_variable || null,
|
|
69
|
+
value: a.output_value == null ? null : String(a.output_value),
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
} else if (m[2] === "network.har") {
|
|
73
|
+
let har;
|
|
74
|
+
try { har = JSON.parse(raw); } catch { continue; }
|
|
75
|
+
for (const h of (har.log && har.log.entries) || []) {
|
|
76
|
+
const req = h.request || {};
|
|
77
|
+
const res = h.response || {};
|
|
78
|
+
const sent = new Set((req.cookies || []).map((c) => c.name));
|
|
79
|
+
for (const x of req.headers || []) {
|
|
80
|
+
if (x.name.toLowerCase() === "cookie") for (const p of x.value.split(";")) { const n = p.split("=")[0].trim(); if (n) sent.add(n); }
|
|
81
|
+
}
|
|
82
|
+
s.requests.push({
|
|
83
|
+
section: s.index, time: t(h.startedDateTime), iso: h.startedDateTime, method: req.method, url: req.url,
|
|
84
|
+
status: res.status, body: (req.postData && req.postData.text) || "",
|
|
85
|
+
mime: (res.content && res.content.mimeType) || "",
|
|
86
|
+
setCookies: (res.headers || []).filter((x) => x.name.toLowerCase() === "set-cookie").map((x) => x.value.split("=")[0].trim()),
|
|
87
|
+
sentCookies: [...sent],
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
} else {
|
|
91
|
+
for (const c of ndjson(raw)) if (!c.marker) s.console.push({ section: s.index, level: c.level, text: c.text || "", url: c.url || "" });
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const ordered = [...sections.values()].sort((a, b) => a.index - b.index);
|
|
96
|
+
for (const s of ordered) { s.actions.sort((a, b) => (a.time || 0) - (b.time || 0)); s.requests.sort((a, b) => (a.time || 0) - (b.time || 0)); }
|
|
97
|
+
const result = list.find((e) => /(^|\/)result\.yaml$/.test(e.name));
|
|
98
|
+
const resultText = result ? text(buf, result) : "";
|
|
99
|
+
const status = (resultText.match(/^status:\s*(\S+)/m) || [])[1] || null;
|
|
100
|
+
const shareLink = (resultText.match(/sharable_link:\s*(\S+)/) || [])[1] || null;
|
|
101
|
+
|
|
102
|
+
return {
|
|
103
|
+
path: packPath,
|
|
104
|
+
testMd, frontmatter: frontmatter(testMd), expectations: expectations(testMd), titles,
|
|
105
|
+
sections: ordered,
|
|
106
|
+
actions: ordered.flatMap((s) => s.actions),
|
|
107
|
+
requests: ordered.flatMap((s) => s.requests),
|
|
108
|
+
console: ordered.flatMap((s) => s.console),
|
|
109
|
+
kaneStatus: status, shareLink,
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// Expectations live in an HTML comment in the test file, which Kane ignores:
|
|
114
|
+
// <!-- expect
|
|
115
|
+
// - no request to a tracker after "Refuse cookies"
|
|
116
|
+
// -->
|
|
117
|
+
function expectations(md) {
|
|
118
|
+
const out = [];
|
|
119
|
+
for (const m of String(md || "").matchAll(/<!--\s*expect\b([\s\S]*?)-->/gi)) {
|
|
120
|
+
for (const line of m[1].split(/\r?\n/)) {
|
|
121
|
+
const x = line.match(/^\s*[-*]\s+(.+?)\s*$/);
|
|
122
|
+
if (x) out.push(x[1]);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
return out;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
module.exports = { read, readBuffer, frontmatter, headings, expectations };
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
// Rule pack: cancelling is as easy as signing up.
|
|
2
|
+
// Kane subscribes like a customer, then tries to cancel online. This code
|
|
3
|
+
// (not an AI) counts both paths from Kane's action log and decides the verdict.
|
|
4
|
+
const { cleanLabel, actionText } = require("./consent");
|
|
5
|
+
|
|
6
|
+
const id = "cancel";
|
|
7
|
+
const title = "Cancel as easy as signup";
|
|
8
|
+
const rule =
|
|
9
|
+
"A subscription started online can be cancelled online, and cancelling takes no more steps " +
|
|
10
|
+
"than signing up did (one extra confirmation is allowed). No phone calls, no dead ends.";
|
|
11
|
+
const laws = [
|
|
12
|
+
{ ref: "California Bus. & Prof. Code §17602 (AB 2863, from 1 July 2025)", gist: "an online subscription must offer online cancellation, as easy as signing up" },
|
|
13
|
+
{ ref: "German Civil Code (BGB) §312k", gist: "consumer contracts sold online need a clearly labelled cancellation button" },
|
|
14
|
+
{ ref: "EU Directive 2023/2673, Art. 11a (from 19 June 2026)", gist: "withdrawing from an online contract must be possible online and no more burdensome than concluding it" },
|
|
15
|
+
];
|
|
16
|
+
|
|
17
|
+
const ALLOWED_EXTRA = 1; // a single "are you sure?" confirmation
|
|
18
|
+
|
|
19
|
+
function objective(url) {
|
|
20
|
+
return (
|
|
21
|
+
`Go to ${url}. If a cookie banner appears, click the button that rejects all cookies. ` +
|
|
22
|
+
`Subscribe to the monthly plan and start the subscription. ` +
|
|
23
|
+
`Then cancel that subscription online, the way a customer would, without phoning anyone. ` +
|
|
24
|
+
`Finally, verify that the page confirms the subscription is cancelled.`
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const INTERACTIVE = new Set(["click", "type", "fill", "select", "check", "uncheck", "press", "tap"]);
|
|
29
|
+
const COOKIE = /(cookie|consent|reject all|accept all)/i;
|
|
30
|
+
const CANCELISH = /(cancel|unsubscribe|end (my )?(plan|subscription)|withdraw|terminate|leave)/i;
|
|
31
|
+
const SIGNUP_DONE = /(start (the )?subscription|start (my )?(plan|trial)|confirm (the )?subscription|subscribe now|complete (the )?(subscription|purchase)|start subscription)/i;
|
|
32
|
+
const SUBSCRIBE = /(subscribe|start subscription|join|sign up|get started|start (my )?trial)/i;
|
|
33
|
+
|
|
34
|
+
function judge({ end, network }) {
|
|
35
|
+
const acts = (network.actions || []).filter((a) => a.status !== "failed");
|
|
36
|
+
const interactive = acts.filter((a) => INTERACTIVE.has(a.type) && !COOKIE.test(actionText(a)));
|
|
37
|
+
|
|
38
|
+
// The signup path ends at the last click that completes the subscription
|
|
39
|
+
// (falling back to the last "subscribe" click). Anything about cancelling
|
|
40
|
+
// never counts as signing up.
|
|
41
|
+
const isSignup = (re, a) => re.test(actionText(a)) && !CANCELISH.test(actionText(a));
|
|
42
|
+
let cut = -1;
|
|
43
|
+
interactive.forEach((a, i) => { if (isSignup(SIGNUP_DONE, a)) cut = i; });
|
|
44
|
+
if (cut < 0) interactive.forEach((a, i) => { if (isSignup(SUBSCRIBE, a)) cut = i; });
|
|
45
|
+
|
|
46
|
+
const signup = cut >= 0 ? interactive.slice(0, cut + 1) : [];
|
|
47
|
+
const cancel = cut >= 0 ? interactive.slice(cut + 1) : [];
|
|
48
|
+
const label = (a) => cleanLabel(a.instruction);
|
|
49
|
+
const passed = end ? end.status === "passed" : null;
|
|
50
|
+
const reason = end && end.status !== "passed" ? String(end.summary || "").split("\n")[0] : "";
|
|
51
|
+
const limit = signup.length + ALLOWED_EXTRA;
|
|
52
|
+
|
|
53
|
+
let verdict;
|
|
54
|
+
let why;
|
|
55
|
+
if (cut < 0) {
|
|
56
|
+
verdict = "inconclusive";
|
|
57
|
+
why = "Kane could not find a way to subscribe, so there is nothing to compare.";
|
|
58
|
+
} else if (passed === false) {
|
|
59
|
+
verdict = "violation";
|
|
60
|
+
why = `Subscribing took ${signup.length} click${signup.length === 1 ? "" : "s"}. Kane then tried ${cancel.length} step${cancel.length === 1 ? "" : "s"} to cancel and never reached a cancellation confirmation.${reason ? ` Kane: “${reason}”` : ""}`;
|
|
61
|
+
} else if (cancel.length > limit) {
|
|
62
|
+
verdict = "violation";
|
|
63
|
+
why = `Cancelling took ${cancel.length} clicks, against ${signup.length} to subscribe (limit: ${limit}, allowing one confirmation).`;
|
|
64
|
+
} else {
|
|
65
|
+
verdict = "pass";
|
|
66
|
+
why = `Subscribing took ${signup.length} click${signup.length === 1 ? "" : "s"} and cancelling took ${cancel.length}, ending on a cancellation confirmation.`;
|
|
67
|
+
}
|
|
68
|
+
return {
|
|
69
|
+
verdict, why,
|
|
70
|
+
signup: signup.map(label), cancel: cancel.map(label),
|
|
71
|
+
signupClicks: signup.length, cancelClicks: cancel.length, limit,
|
|
72
|
+
confirmed: passed === true, kaneReason: reason,
|
|
73
|
+
trackerRequests: [], trackerCookies: [],
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const fixHint =
|
|
78
|
+
"Give subscribers a clearly labelled cancel button where they manage the plan (the account page), " +
|
|
79
|
+
"cancel online in at most one confirmation step, and show a confirmation that the plan is cancelled. " +
|
|
80
|
+
"No phone-only cancellation, no mandatory survey, no chain of extra screens. A retention offer may " +
|
|
81
|
+
"be shown only if the cancel button stays on the same screen.";
|
|
82
|
+
|
|
83
|
+
module.exports = { id, title, rule, laws, objective, judge, fixHint };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// Companion check: after "Accept", the tags must still work.
|
|
2
|
+
// Stops a fix from "passing" the reject check by deleting analytics outright.
|
|
3
|
+
const { matchDomain, laws, cleanLabel, actionText } = require("./consent");
|
|
4
|
+
|
|
5
|
+
const id = "consent-accept";
|
|
6
|
+
const title = "Accept still works";
|
|
7
|
+
const rule = "When a visitor accepts cookies, the site's analytics and ads tags load as intended.";
|
|
8
|
+
|
|
9
|
+
function objective(url) {
|
|
10
|
+
if (/:4173\/|\/demo\/?$/.test(url)) return `Go to ${url}. In the cookie banner, click the button that accepts all cookies. Open the first product.`;
|
|
11
|
+
return `Go to ${url}. In the cookie or analytics consent banner, click the button that accepts or allows it. Then open one page from the site's navigation.`;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const ACCEPT_WORDS = /(accept|agree|allow all|allow cookies|got it)/i;
|
|
15
|
+
|
|
16
|
+
function judge({ events, network }) {
|
|
17
|
+
let accept = null;
|
|
18
|
+
for (const a of network.actions || []) {
|
|
19
|
+
if (a.type === "click" && a.status !== "failed" && ACCEPT_WORDS.test(actionText(a))) {
|
|
20
|
+
accept = { label: cleanLabel(a.instruction), time: a.time ? Date.parse(a.time) : null };
|
|
21
|
+
break;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
if (!accept) {
|
|
25
|
+
for (const e of events || []) {
|
|
26
|
+
const r = typeof e.remark === "string" ? e.remark : "";
|
|
27
|
+
if (e.status === "done" && /^click\b/i.test(r) && ACCEPT_WORDS.test(r)) { accept = { label: cleanLabel(r), time: null }; break; }
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
const after = [];
|
|
31
|
+
for (const r of network.requests) {
|
|
32
|
+
let u;
|
|
33
|
+
try { u = new URL(r.url); } catch { continue; }
|
|
34
|
+
const t = matchDomain(u);
|
|
35
|
+
if (!t) continue;
|
|
36
|
+
const at = r.time ? Date.parse(r.time) : null;
|
|
37
|
+
if (!accept || !accept.time || !at || at >= accept.time) after.push(t);
|
|
38
|
+
}
|
|
39
|
+
const trackers = [...new Set(after)];
|
|
40
|
+
let verdict;
|
|
41
|
+
let why;
|
|
42
|
+
if (!accept) {
|
|
43
|
+
verdict = "inconclusive";
|
|
44
|
+
why = "Kane did not find or click an accept button.";
|
|
45
|
+
} else if (trackers.length) {
|
|
46
|
+
verdict = "pass";
|
|
47
|
+
why = `After "Accept", the tags loaded as intended (${trackers.join(", ")}).`;
|
|
48
|
+
} else {
|
|
49
|
+
verdict = "violation";
|
|
50
|
+
why = 'After "Accept", no analytics or ads tag loaded. The fix seems to have switched tracking off entirely instead of respecting the choice.';
|
|
51
|
+
}
|
|
52
|
+
return { verdict, why, rejectClick: null, trackerRequests: [], trackerCookies: [], acceptClick: accept && accept.label, trackersAfterAccept: trackers };
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const fixHint = "Load the tags when the visitor clicks Accept, and on later page loads when the stored choice is accepted.";
|
|
56
|
+
|
|
57
|
+
module.exports = { id, title, rule, laws, objective, judge, fixHint };
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
// Rule pack: "Reject" means reject.
|
|
2
|
+
// Kane plays a visitor who refuses cookies and then shops normally. This code
|
|
3
|
+
// (not an AI) reads Kane's recorded traffic and action log and decides the verdict.
|
|
4
|
+
const trackers = require("../../rules/trackers.json");
|
|
5
|
+
|
|
6
|
+
const id = "consent";
|
|
7
|
+
const title = "Reject means reject";
|
|
8
|
+
const rule =
|
|
9
|
+
"When a visitor refuses cookies, no advertising or analytics tracker may load, " +
|
|
10
|
+
"before the choice or after it, and no visitor ID may be sent to a tracker.";
|
|
11
|
+
const laws = [
|
|
12
|
+
{ ref: "ePrivacy Directive 2002/58/EC, Art. 5(3)", gist: "storing or reading non-essential data on a device needs prior consent" },
|
|
13
|
+
{ ref: "GDPR (EU) 2016/679, Art. 4(11) and Art. 7", gist: "consent must be freely given and as easy to withdraw as to give" },
|
|
14
|
+
{ ref: "California Civil Code §1798.120 (CCPA/CPRA)", gist: "consumers may opt out of the sale or sharing of their personal information" },
|
|
15
|
+
];
|
|
16
|
+
|
|
17
|
+
const isShop = (url) => /:4173\/|\/demo\/?$/.test(url);
|
|
18
|
+
|
|
19
|
+
function objective(url) {
|
|
20
|
+
if (isShop(url)) return (
|
|
21
|
+
`Go to ${url}. In the cookie banner, click the button that rejects all cookies. ` +
|
|
22
|
+
`Open the first product. Click the add to cart button. Reload the page.`
|
|
23
|
+
);
|
|
24
|
+
return (
|
|
25
|
+
`Go to ${url}. Before doing anything else, deal with the cookie or analytics consent banner if one is shown: ` +
|
|
26
|
+
`click the button that rejects or declines it. If no banner is shown, do not look for one. ` +
|
|
27
|
+
`Then open one page from the site's navigation, then reload that page.`
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const REJECT_WORDS = /(reject|decline|refuse|deny|necessary only|only necessary|essential only)/i;
|
|
32
|
+
|
|
33
|
+
function matchDomain(u) {
|
|
34
|
+
const host = u.hostname.toLowerCase();
|
|
35
|
+
for (const r of trackers.domains) {
|
|
36
|
+
const [d, ...p] = r.split("/");
|
|
37
|
+
const pathPrefix = p.length ? "/" + p.join("/") : "";
|
|
38
|
+
if ((host === d || host.endsWith("." + d)) && u.pathname.startsWith(pathPrefix)) return r;
|
|
39
|
+
}
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Visitor identifiers that trackers send in the URL. Seeing one proves the
|
|
44
|
+
// visitor is being recognised, which is the whole point of the cookie.
|
|
45
|
+
const ID_PARAMS = [
|
|
46
|
+
{ param: "cid", name: "Google Analytics client ID (_ga cookie)", needs: "tid" },
|
|
47
|
+
{ param: "fbp", name: "Meta browser ID (_fbp cookie)" },
|
|
48
|
+
{ param: "_fbp", name: "Meta browser ID (_fbp cookie)" },
|
|
49
|
+
{ param: "fbc", name: "Meta click ID (_fbc cookie)" },
|
|
50
|
+
{ param: "gclid", name: "Google Ads click ID" },
|
|
51
|
+
{ param: "uid", name: "user ID" },
|
|
52
|
+
];
|
|
53
|
+
|
|
54
|
+
function visitorId(u) {
|
|
55
|
+
const q = u.searchParams;
|
|
56
|
+
for (const p of ID_PARAMS) {
|
|
57
|
+
const v = q.get(p.param);
|
|
58
|
+
if (!v) continue;
|
|
59
|
+
if (p.needs && !q.get(p.needs)) continue;
|
|
60
|
+
if (p.param === "cid" && /^G-/.test(v)) continue; // GTM uses cid for the tag ID
|
|
61
|
+
return { kind: p.name, value: v };
|
|
62
|
+
}
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Google Consent Mode: a hit sent with analytics storage denied is a cookieless
|
|
67
|
+
// ping, not tracking with a cookie. gcd letters at positions 2,4,6,8 are
|
|
68
|
+
// ad_storage, analytics_storage, ad_user_data, ad_personalization; p/q/m/u mean
|
|
69
|
+
// the final state is denied, l means Consent Mode is not in use.
|
|
70
|
+
const DENIED = new Set(["p", "q", "m", "u"]);
|
|
71
|
+
function consentModeDenied(u) {
|
|
72
|
+
const q = u.searchParams;
|
|
73
|
+
const gcd = q.get("gcd");
|
|
74
|
+
if (gcd && gcd.length > 4 && DENIED.has(gcd[4])) return true;
|
|
75
|
+
const gcs = q.get("gcs");
|
|
76
|
+
if (gcs && /^G1[01]0$/.test(gcs)) return true;
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const cookieRes = trackers.cookies.map((c) => new RegExp(c));
|
|
81
|
+
const isTrackerCookie = (name) => cookieRes.some((r) => r.test(name));
|
|
82
|
+
|
|
83
|
+
// "click: Clicking Reject all in the cookie banner" -> "Reject all in the cookie banner"
|
|
84
|
+
const cleanLabel = (s) => String(s || "").replace(/^click:\s*/i, "").replace(/^(clicking|clicked|click)\s+(on\s+)?(the\s+)?/i, "").trim().replace(/^"(.*)"$/, "$1");
|
|
85
|
+
// What Kane actually clicked: its own description plus the element's visible
|
|
86
|
+
// text. Kane's "intent" also carries the objective sentence it is working on,
|
|
87
|
+
// which can lag behind, so only the text="..." part of it is used.
|
|
88
|
+
function actionText(a) {
|
|
89
|
+
const m = String(a.intent || "").match(/text="([^"]*)"/);
|
|
90
|
+
return `${a.instruction || ""} ${m ? m[1] : ""}`.trim();
|
|
91
|
+
}
|
|
92
|
+
const plural = (n, word) => `${n} ${word}${n === 1 ? "" : "s"}`;
|
|
93
|
+
|
|
94
|
+
// When did Kane click "Reject"? Prefer the timestamped action log; fall back
|
|
95
|
+
// to the progress stream (no timestamp then).
|
|
96
|
+
function findReject(actions, events, fallbackTime) {
|
|
97
|
+
for (const a of actions || []) {
|
|
98
|
+
if (a.type === "click" && a.status !== "failed" && REJECT_WORDS.test(actionText(a))) {
|
|
99
|
+
return { label: cleanLabel(a.instruction), time: a.time ? Date.parse(a.time) : null };
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
for (const e of events || []) {
|
|
103
|
+
const r = typeof e.remark === "string" ? e.remark : "";
|
|
104
|
+
if (e.status === "done" && /^click\b/i.test(r) && REJECT_WORDS.test(r)) {
|
|
105
|
+
return { label: cleanLabel(r), time: fallbackTime || null };
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// Did Kane see a cookie banner? Kane logs its conditional check
|
|
112
|
+
// ("If-else checkpoint ...: condition 'A cookie banner appears.' matched").
|
|
113
|
+
function bannerSeen(actions) {
|
|
114
|
+
for (const a of actions || []) {
|
|
115
|
+
const t = `${a.instruction || ""}`;
|
|
116
|
+
if (!/(banner|cookie|consent)/i.test(t)) continue;
|
|
117
|
+
if (a.type === "if_else" || /checkpoint|condition/i.test(t)) {
|
|
118
|
+
if (/(not matched|did not match|unmatched|not met|false)/i.test(t)) return false;
|
|
119
|
+
if (/matched|met|true/i.test(t)) return true;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// strict: used for your own app. A site that loads trackers and gives no way to
|
|
126
|
+
// refuse them breaks the rule outright; for third-party sites the banner may simply
|
|
127
|
+
// not be shown to Kane's location, so those runs stay unjudged.
|
|
128
|
+
function judge({ events, network, strict = false }) {
|
|
129
|
+
const reject = findReject(network.actions, events, network.liveRejectAt);
|
|
130
|
+
const banner = bannerSeen(network.actions);
|
|
131
|
+
const hits = [];
|
|
132
|
+
for (const r of network.requests) {
|
|
133
|
+
let u;
|
|
134
|
+
try { u = new URL(r.url); } catch { continue; }
|
|
135
|
+
const tracker = matchDomain(u);
|
|
136
|
+
if (!tracker) continue;
|
|
137
|
+
const t = r.time ? Date.parse(r.time) : null;
|
|
138
|
+
const phase = reject && reject.time && t ? (t >= reject.time ? "after" : "before") : "unknown";
|
|
139
|
+
const page = u.searchParams.get("dl") || u.searchParams.get("dp") || null;
|
|
140
|
+
const denied = consentModeDenied(u);
|
|
141
|
+
// Google Tag Manager's own code (the container or gtag library) carries no
|
|
142
|
+
// measurement on its own; the hits it sends later do. Shown, not counted.
|
|
143
|
+
const loader = /(^|\.)googletagmanager\.com$/.test(u.hostname) && /^\/(gtm\.js|gtag\/js|gtag\/destination)$/.test(u.pathname);
|
|
144
|
+
hits.push({ tracker, url: u.origin + u.pathname, method: r.method, status: r.status, time: r.time, phase, page, id: denied ? null : visitorId(u), denied, loader });
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// Group identical endpoints per phase so the report stays readable.
|
|
148
|
+
const groups = new Map();
|
|
149
|
+
for (const h of hits) {
|
|
150
|
+
const key = `${h.phase}|${h.url}|${h.denied ? "d" : ""}${h.loader ? "l" : ""}`;
|
|
151
|
+
const g = groups.get(key) || { ...h, count: 0, pages: new Set(), ids: new Set() };
|
|
152
|
+
g.count++;
|
|
153
|
+
if (h.page) g.pages.add(h.page);
|
|
154
|
+
if (h.id) g.ids.add(`${h.id.kind}: ${h.id.value}`);
|
|
155
|
+
groups.set(key, g);
|
|
156
|
+
}
|
|
157
|
+
const trackerRequests = [...groups.values()].map((g) => ({
|
|
158
|
+
phase: g.phase, tracker: g.tracker, url: g.url, method: g.method, status: g.status,
|
|
159
|
+
count: g.count, firstTime: g.time, pages: [...g.pages], ids: [...g.ids], consentDenied: !!g.denied, loaderOnly: !!g.loader,
|
|
160
|
+
notCounted: !!(g.denied || g.loader),
|
|
161
|
+
}));
|
|
162
|
+
|
|
163
|
+
// If the site uses Consent Mode and its pings say "denied", the tag library
|
|
164
|
+
// loading is part of that design; count only hits that are not denied pings.
|
|
165
|
+
const usesDeniedMode = hits.some((h) => h.denied && h.phase !== "before");
|
|
166
|
+
const counts = (h) => !h.denied && !h.loader && !(usesDeniedMode && /googletagmanager\.com/.test(h.tracker));
|
|
167
|
+
const real = hits.filter(counts);
|
|
168
|
+
const cookieless = hits.filter((h) => h.denied && h.phase !== "before").length;
|
|
169
|
+
const after = real.filter((h) => h.phase === "after");
|
|
170
|
+
const idCounts = new Map();
|
|
171
|
+
for (const h of after) if (h.id) { const k = `${h.id.kind}: ${h.id.value}`; idCounts.set(k, (idCounts.get(k) || 0) + 1); }
|
|
172
|
+
const idsAfter = [...idCounts.keys()];
|
|
173
|
+
const repeated = [...idCounts.entries()].filter(([, n]) => n > 1);
|
|
174
|
+
|
|
175
|
+
const cookieNames = new Set();
|
|
176
|
+
for (const r of network.requests) {
|
|
177
|
+
for (const c of r.setCookies || []) cookieNames.add(c);
|
|
178
|
+
for (const c of r.sentCookies || []) cookieNames.add(c);
|
|
179
|
+
}
|
|
180
|
+
const trackerCookies = [...cookieNames].filter(isTrackerCookie);
|
|
181
|
+
|
|
182
|
+
let verdict;
|
|
183
|
+
let why;
|
|
184
|
+
if (!reject && banner === false && network.harFiles !== 0) {
|
|
185
|
+
// Many sites show a banner only to visitors in some countries, so a site
|
|
186
|
+
// that showed none to Kane's location is not judged on this run.
|
|
187
|
+
verdict = strict && real.length ? "violation" : "inconclusive";
|
|
188
|
+
why = strict && real.length
|
|
189
|
+
? `The page offered no way to refuse cookies, and ${plural(real.length, "tracker request")} went out before the visitor made any choice.`
|
|
190
|
+
: real.length
|
|
191
|
+
? `No cookie banner was shown to Kane's browser from its location, and ${plural(real.length, "tracker request")} went out. Sites often show banners only to visitors in the EU or UK, so this run can't judge the Reject button.`
|
|
192
|
+
: `No cookie banner was shown to Kane's browser from its location, and no tracker loaded.`;
|
|
193
|
+
} else if (!reject && strict && real.length) {
|
|
194
|
+
verdict = "violation";
|
|
195
|
+
why = `Kane found no way to refuse cookies, and ${plural(real.length, "tracker request")} went out before the visitor made any choice.`;
|
|
196
|
+
} else if (!reject) {
|
|
197
|
+
verdict = "inconclusive";
|
|
198
|
+
why = "Kane did not find or click a reject button, so this run cannot prove anything either way.";
|
|
199
|
+
} else if (network.harFiles === 0) {
|
|
200
|
+
verdict = "inconclusive";
|
|
201
|
+
why = "The evidence pack has no network recording.";
|
|
202
|
+
} else if (real.length || trackerCookies.length) {
|
|
203
|
+
verdict = "violation";
|
|
204
|
+
const parts = [];
|
|
205
|
+
const before = real.filter((h) => h.phase === "before").length;
|
|
206
|
+
if (after.length) parts.push(`${plural(after.length, "tracker request")} after the visitor clicked "Reject"`);
|
|
207
|
+
if (before) parts.push(`${plural(before, "tracker request")} before they had chosen anything`);
|
|
208
|
+
if (!after.length && !before && real.length) parts.push(plural(real.length, "tracker request"));
|
|
209
|
+
if (trackerCookies.length) parts.push(plural(trackerCookies.length, "tracker cookie"));
|
|
210
|
+
why = `Kane recorded ${parts.join(", and ")}.`;
|
|
211
|
+
if (repeated.length) why += ` After "Reject", the same visitor ID went out more than once (${repeated.map(([k, n]) => `${k}, ${n} times`).join("; ")}).`;
|
|
212
|
+
else if (idsAfter.length) why += ` After "Reject", Google Analytics received ${plural(idsAfter.length, "visitor ID")}.`;
|
|
213
|
+
if (cookieless) why += ` ${plural(cookieless, "further hit")} said consent was denied (Google Consent Mode) and were not counted.`;
|
|
214
|
+
} else {
|
|
215
|
+
verdict = "pass";
|
|
216
|
+
why = cookieless
|
|
217
|
+
? `Kane refused cookies. ${plural(cookieless, "Google hit")} still went out, but each said consent was denied (Google Consent Mode), with no visitor cookie. No other tracker loaded.`
|
|
218
|
+
: hits.some((h) => h.loader)
|
|
219
|
+
? `Kane refused cookies and recorded ${plural(network.requests.length, "request")}. Google Tag Manager's code loaded, but no measurement or ad hit went out and no visitor ID was sent.`
|
|
220
|
+
: `Kane refused cookies and recorded ${plural(network.requests.length, "request")}; none went to a known tracker and no visitor ID was sent.`;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
return {
|
|
224
|
+
verdict, why,
|
|
225
|
+
rejectClick: reject && { label: reject.label, time: reject.time ? new Date(reject.time).toISOString() : null },
|
|
226
|
+
trackerRequests, idsAfterReject: idsAfter, trackerCookies, bannerShown: banner, cookielessPings: cookieless,
|
|
227
|
+
totalRequests: network.requests.length,
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
const fixHint =
|
|
232
|
+
"Load each tracker listed above only after the visitor accepts. Before a choice, and after " +
|
|
233
|
+
"Reject, the tags must not load at all (hiding the banner is not enough). Check the stored " +
|
|
234
|
+
"choice on every page load, before any tag script is added. Keep the tags working after Accept. " +
|
|
235
|
+
"If the site has no way to refuse yet, add a small banner with Accept and Decline buttons.";
|
|
236
|
+
|
|
237
|
+
module.exports = { id, title, rule, laws, objective, judge, fixHint, matchDomain, visitorId, consentModeDenied, cleanLabel, actionText };
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
// Rule pack: the price shown is the price paid.
|
|
2
|
+
// Kane opens a product, reads the price shown for it, goes to checkout and reads
|
|
3
|
+
// the total, shipping and tax there. This code (not an AI) compares the numbers.
|
|
4
|
+
const id = "price";
|
|
5
|
+
const title = "The price shown is the price paid";
|
|
6
|
+
const rule =
|
|
7
|
+
"The first price a shopper sees for a product includes every mandatory fee. At checkout the " +
|
|
8
|
+
"total may add only taxes and shipping on top of it; a fee that only appears at the last step " +
|
|
9
|
+
"breaks the rule.";
|
|
10
|
+
const laws = [
|
|
11
|
+
{ ref: "California Civil Code §1770(a)(29) (SB 478, from 1 July 2024)", gist: "an advertised price must include all mandatory fees, other than government taxes and shipping" },
|
|
12
|
+
{ ref: "UK Digital Markets, Competition and Consumers Act 2024, s.230 (from 6 April 2025)", gist: "the headline price must include mandatory charges; drip pricing is banned" },
|
|
13
|
+
{ ref: "EU Consumer Rights Directive 2011/83/EU, Art. 6(1)(e)", gist: "the trader must give the total price of the goods, inclusive of taxes, before the contract" },
|
|
14
|
+
];
|
|
15
|
+
|
|
16
|
+
function objective(url) {
|
|
17
|
+
return (
|
|
18
|
+
`Go to ${url}. Reject all cookies if a banner appears. Open the first product and store the price shown for it in a variable named product_price. ` +
|
|
19
|
+
`Add it to the cart, go to checkout and stop on the page before payment. There, store the total to pay in checkout_total, ` +
|
|
20
|
+
`and copy every line listed between the product and the total, exactly as the page names it, with its amount, into checkout_lines ` +
|
|
21
|
+
`(for example "Delivery: 3.00; Packaging fee: 1.50"; write none if there are no such lines). Do not pay.`
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// "€1.234,50", "$1,234.50", "1 234,50 EUR", "49" -> number
|
|
26
|
+
function money(v) {
|
|
27
|
+
if (v == null) return null;
|
|
28
|
+
const m = String(v).replace(/ /g, " ").match(/-?\d[\d.,\s]*/);
|
|
29
|
+
if (!m) return null;
|
|
30
|
+
let s = m[0].replace(/\s/g, "");
|
|
31
|
+
const lastComma = s.lastIndexOf(","), lastDot = s.lastIndexOf(".");
|
|
32
|
+
if (lastComma > lastDot) s = s.replace(/\./g, "").replace(",", ".");
|
|
33
|
+
else s = s.replace(/,/g, "");
|
|
34
|
+
if (/^\d+\.\d{3}$/.test(s) && lastComma < 0 && lastDot >= 0 && !/[.,]\d{1,2}$/.test(m[0])) s = s.replace(".", "");
|
|
35
|
+
const n = Number(s);
|
|
36
|
+
return Number.isFinite(n) ? n : null;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function readVars(actions) {
|
|
40
|
+
const vars = {};
|
|
41
|
+
for (const a of actions || []) {
|
|
42
|
+
if (!a.outputVariable || a.outputValue == null || a.status === "failed") continue;
|
|
43
|
+
const k = String(a.outputVariable).toLowerCase().replace(/[^a-z_]/g, "");
|
|
44
|
+
vars[k] = { raw: String(a.outputValue), value: money(a.outputValue), time: a.time };
|
|
45
|
+
}
|
|
46
|
+
return vars;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const fmt = (n) => n.toFixed(2);
|
|
50
|
+
|
|
51
|
+
// Lines a shop may add on top of the shown price: shipping and taxes only.
|
|
52
|
+
// The decision uses the shop's own name for each line, not Kane's judgement.
|
|
53
|
+
const EXEMPT = /(shipping|delivery|postage|carriage|versand|livraison|envío|envio|spedizione|tax|vat|mwst|tva|iva|gst)/i;
|
|
54
|
+
|
|
55
|
+
function parseLines(raw) {
|
|
56
|
+
if (!raw || /^\s*(none|no|n\/a|-|0)\s*$/i.test(raw)) return [];
|
|
57
|
+
return String(raw).split(/[;\n]+/).map((part) => {
|
|
58
|
+
const m = part.match(/^\s*([^:=]+?)\s*[:=]\s*(.+)$/) || part.match(/^\s*(.*?[A-Za-z].*?)\s+([-–]?\s*[€$£]?\s*\d[\d.,]*\s*\S*)\s*$/);
|
|
59
|
+
if (!m) return null;
|
|
60
|
+
const amount = money(m[2]);
|
|
61
|
+
const label = m[1].replace(/[\s\u2013\u2014-]+$/, "").trim();
|
|
62
|
+
return amount == null ? null : { label, amount, exempt: EXEMPT.test(label) };
|
|
63
|
+
}).filter(Boolean);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function judge({ end, network }) {
|
|
67
|
+
const vars = readVars(network.actions);
|
|
68
|
+
const shown = vars.product_price && vars.product_price.value;
|
|
69
|
+
const total = vars.checkout_total && vars.checkout_total.value;
|
|
70
|
+
const lines = parseLines(vars.checkout_lines && vars.checkout_lines.raw);
|
|
71
|
+
const exempt = lines.filter((l) => l.exempt).reduce((a, l) => a + l.amount, 0);
|
|
72
|
+
const fees = lines.filter((l) => !l.exempt);
|
|
73
|
+
let verdict, why, extra = null;
|
|
74
|
+
if (shown == null || total == null) {
|
|
75
|
+
verdict = "inconclusive";
|
|
76
|
+
why = `Kane did not record both prices (product page: ${vars.product_price ? vars.product_price.raw : "none"}, checkout total: ${vars.checkout_total ? vars.checkout_total.raw : "none"}), so this run cannot prove anything either way.`;
|
|
77
|
+
} else {
|
|
78
|
+
extra = Math.round((total - shown - exempt) * 100) / 100;
|
|
79
|
+
const seen = `the product page showed ${vars.product_price.raw} and the checkout total was ${vars.checkout_total.raw}`;
|
|
80
|
+
const listed = lines.length ? ` The checkout listed ${lines.map((l) => `${l.label} ${fmt(l.amount)}`).join(", ")}.` : "";
|
|
81
|
+
if (extra > 0.009) {
|
|
82
|
+
verdict = "violation";
|
|
83
|
+
const named = fees.length ? ` (${fees.map((l) => l.label).join(", ")})` : "";
|
|
84
|
+
why = `Kane read the prices: ${seen}.${listed} Apart from shipping and tax, ${fmt(extra)} more than the shown price was added at checkout${named}.`;
|
|
85
|
+
} else {
|
|
86
|
+
verdict = "pass";
|
|
87
|
+
why = `Kane read the prices: ${seen}.${listed} Apart from shipping and tax, the shopper pays the price they were shown.`;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return {
|
|
91
|
+
verdict, why, shown, total, extra, lines,
|
|
92
|
+
shipping: lines.filter((l) => l.exempt && !/tax|vat|mwst|tva|iva|gst/i.test(l.label)).reduce((a, l) => a + l.amount, 0),
|
|
93
|
+
tax: lines.filter((l) => /tax|vat|mwst|tva|iva|gst/i.test(l.label)).reduce((a, l) => a + l.amount, 0),
|
|
94
|
+
readings: Object.fromEntries(Object.entries(vars).map(([k, v]) => [k, v.raw])),
|
|
95
|
+
trackerRequests: [], trackerCookies: [],
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const fixHint =
|
|
100
|
+
"Show the full price, including every mandatory fee, wherever the product price is first shown " +
|
|
101
|
+
"(product page and cart), or remove the fee. Taxes and shipping may still be listed separately at " +
|
|
102
|
+
"checkout. Do not hide the fee in small print.";
|
|
103
|
+
|
|
104
|
+
module.exports = { id, title, rule, laws, objective, judge, fixHint, money, parseLines };
|