@simmalugnt-se/payload-consent 0.6.9 → 0.6.10
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/CHANGELOG.md +16 -0
- package/README.md +11 -1
- package/dist/admin/ScanPanel.js +6 -4
- package/dist/advice.d.ts +24 -0
- package/dist/advice.js +37 -0
- package/dist/evaluate.d.ts +10 -0
- package/dist/evaluate.js +49 -3
- package/dist/notify.d.ts +10 -1
- package/dist/notify.js +29 -2
- package/dist/scans.js +1 -0
- package/dist/styles/admin.css +4 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.6.10
|
|
4
|
+
|
|
5
|
+
- A scan says what to do. Each finding that needs handling carries one instruction, in the Scan tab
|
|
6
|
+
and in the email, judged from what the scan measured: code or a frame from another site before
|
|
7
|
+
consent must wait, a font or stylesheet from another site belongs on the site's own domain, a plain
|
|
8
|
+
file needs its provider checked, and unexplained storage goes in a service. The email names each
|
|
9
|
+
finding and a page it was seen on. Needs `consent-scanner` at `dcefe83` or later; with an older one,
|
|
10
|
+
hosts get no instruction.
|
|
11
|
+
- A service in Necessary no longer makes code from another site count as in order: seen before any
|
|
12
|
+
choice, it needs action. So does a cookie in Necessary that the Open Cookie Database puts in
|
|
13
|
+
another category. A site may see new findings in its next scan.
|
|
14
|
+
- Add to service starts in Functionality for what must wait for consent, not in Necessary.
|
|
15
|
+
- Pages the scanner could not reach make the scan incomplete and are named.
|
|
16
|
+
- The README's Google Tag Manager example loads the tag after consent: passed as it stood, c15t loads
|
|
17
|
+
it at once.
|
|
18
|
+
|
|
3
19
|
## 0.6.9
|
|
4
20
|
|
|
5
21
|
- A scan visits every page it finds as a new visitor, up to 500 in all, and 30 pages in each other
|
package/README.md
CHANGED
|
@@ -172,6 +172,13 @@ every cookie, localStorage key and third-party host:
|
|
|
172
172
|
`_ga_*` rather than one property's `_ga_G123`), and the scan is judged again.
|
|
173
173
|
- **In order**: explained and seen only where allowed.
|
|
174
174
|
|
|
175
|
+
A finding that needs handling says what to do, judged from what the scan measured: code or a frame
|
|
176
|
+
from another site before any choice must wait for consent, even in a service marked Necessary; a
|
|
177
|
+
font or stylesheet from another site belongs on the site's own domain; a plain file with nothing
|
|
178
|
+
stored needs its provider checked; storage no service explains goes in one. The email lists the same,
|
|
179
|
+
with a page each was seen on. `docs/research/consent-rules.md` in the repository has the rule and its
|
|
180
|
+
sources.
|
|
181
|
+
|
|
175
182
|
Findings new since the previous scan are marked. A scan's raw results stay in `consent-scans`.
|
|
176
183
|
|
|
177
184
|
### Every month
|
|
@@ -264,7 +271,10 @@ The services picked in Admin load on their own. Other c15t integrations go in `s
|
|
|
264
271
|
'use client'
|
|
265
272
|
import { googleTagManager } from '@c15t/scripts/google-tag-manager'
|
|
266
273
|
|
|
267
|
-
<ConsentProvider
|
|
274
|
+
<ConsentProvider
|
|
275
|
+
config={consent}
|
|
276
|
+
scripts={[{ ...googleTagManager({ id: 'GTM-XXXXXXX' }), category: 'measurement', alwaysLoad: false }]}
|
|
277
|
+
>
|
|
268
278
|
```
|
|
269
279
|
|
|
270
280
|
Embedded content, such as a video or a map, waits behind a placeholder until the visitor allows
|
package/dist/admin/ScanPanel.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import { Button, Collapsible, Pill, SelectInput, ShimmerEffect, TextInput, useConfig, useFormFields, useLocale, useTranslation, } from "@payloadcms/ui";
|
|
4
4
|
import { useCallback, useEffect, useRef, useState, } from "react";
|
|
5
|
+
import { adviceText } from "../advice.js";
|
|
5
6
|
import { CATEGORIES } from "../defaults.js";
|
|
6
7
|
import { CONSENT_SCANS } from "../types.js";
|
|
7
8
|
import { describeProblem, estimateLeft, findingHeading, finishedPages, formatElapsed, markPace, pagePath, scanVerdict, } from "./scan-view.js";
|
|
@@ -85,7 +86,7 @@ const COPY = {
|
|
|
85
86
|
ok: "In order",
|
|
86
87
|
},
|
|
87
88
|
explain: {
|
|
88
|
-
action: "
|
|
89
|
+
action: "Loads before or without consent. Each one says what to do.",
|
|
89
90
|
unknown: "Add each to a service, new or existing, or remove it from the site.",
|
|
90
91
|
ok: "In a Cookie service, and seen only where its category is allowed.",
|
|
91
92
|
},
|
|
@@ -204,7 +205,7 @@ const COPY = {
|
|
|
204
205
|
ok: "I ordning",
|
|
205
206
|
},
|
|
206
207
|
explain: {
|
|
207
|
-
action: "
|
|
208
|
+
action: "Laddas före eller utan samtycke. Varje rad säger vad du ska göra.",
|
|
208
209
|
unknown: "Lägg till var och en i en tjänst, ny eller befintlig, eller ta bort den från webbplatsen.",
|
|
209
210
|
ok: "Finns i en Cookietjänst och syns bara där kategorin är tillåten.",
|
|
210
211
|
},
|
|
@@ -490,7 +491,8 @@ export function ScanPanel() {
|
|
|
490
491
|
function FindingRow({ api, copy, finding, language, locale, onAdded, }) {
|
|
491
492
|
const suggestion = finding.suggestion;
|
|
492
493
|
const [service, setService] = useState(suggestion?.platform ?? (finding.kind === "host" ? finding.name : ""));
|
|
493
|
-
|
|
494
|
+
// What must wait for consent starts in a category that does, not in Necessary.
|
|
495
|
+
const [category, setCategory] = useState(suggestion?.category ?? (finding.advice === "waitForConsent" ? "functionality" : "necessary"));
|
|
494
496
|
const [busy, setBusy] = useState(false);
|
|
495
497
|
const [error, setError] = useState();
|
|
496
498
|
async function add() {
|
|
@@ -545,7 +547,7 @@ function FindingRow({ api, copy, finding, language, locale, onAdded, }) {
|
|
|
545
547
|
const without = serviceCategory ? finding.withoutConsent : [];
|
|
546
548
|
const rest = finding.states.filter((id) => !without.includes(id));
|
|
547
549
|
const path = `consent-scan-${finding.key}`;
|
|
548
|
-
return (_jsxs("li", { className: "consent-scan__row", children: [_jsxs("div", { className: "consent-scan__row-head", children: [_jsx("h4", { className: "consent-scan__name", children: heading.from === "name" ? (_jsx("code", { children: heading.text })) : heading.from === "suggestion" ? (copy.looksLike(heading.text)) : (heading.text) }), (finding.beforeConsent && finding.status !== "ok") || finding.isNew ? (_jsxs("div", { className: "consent-scan__pills", children: [finding.beforeConsent && finding.status !== "ok" ? (_jsx(Pill, { pillStyle: "error", size: "small", children: copy.beforeConsent })) : null, finding.isNew ? (_jsx(Pill, { pillStyle: "light", size: "small", children: copy.isNew })) : null] })) : null] }), _jsx("p", { className: "consent-scan__seen", children: without.length ? (_jsxs(_Fragment, { children: [`${copy.seen[finding.kind]} ${whenLabel(copy, without, language)}`, _jsx("strong", { children: copy.notAllowed(serviceCategory) }), ".", rest.length ? ` ${copy.also(whenLabel(copy, rest, language))}` : null] })) : (`${copy.seen[finding.kind]} ${whenLabel(copy, finding.states, language)}.`) }), suggestion?.description && heading.from === "suggestion" ? (_jsx("p", { className: "consent-scan__note", children: suggestion.description })) : null, details.length ? (_jsx("p", { className: "consent-scan__details", children: details.map((detail, index) => (_jsx("span", { children: detail }, typeof detail === "string" ? detail : index))) })) : null, finding.status === "unknown" ? (_jsxs("div", { className: "consent-scan__classify", children: [_jsx(TextInput, { label: copy.service, onChange: (event) => setService(event.target.value), onKeyDown: (event) => {
|
|
550
|
+
return (_jsxs("li", { className: "consent-scan__row", children: [_jsxs("div", { className: "consent-scan__row-head", children: [_jsx("h4", { className: "consent-scan__name", children: heading.from === "name" ? (_jsx("code", { children: heading.text })) : heading.from === "suggestion" ? (copy.looksLike(heading.text)) : (heading.text) }), (finding.beforeConsent && finding.status !== "ok") || finding.isNew ? (_jsxs("div", { className: "consent-scan__pills", children: [finding.beforeConsent && finding.status !== "ok" ? (_jsx(Pill, { pillStyle: "error", size: "small", children: copy.beforeConsent })) : null, finding.isNew ? (_jsx(Pill, { pillStyle: "light", size: "small", children: copy.isNew })) : null] })) : null] }), _jsx("p", { className: "consent-scan__seen", children: without.length ? (_jsxs(_Fragment, { children: [`${copy.seen[finding.kind]} ${whenLabel(copy, without, language)}`, _jsx("strong", { children: copy.notAllowed(serviceCategory) }), ".", rest.length ? ` ${copy.also(whenLabel(copy, rest, language))}` : null] })) : (`${copy.seen[finding.kind]} ${whenLabel(copy, finding.states, language)}.`) }), finding.advice && finding.status !== "ok" ? (_jsx("p", { className: "consent-scan__advice", children: adviceText(finding.advice, language) })) : null, suggestion?.description && heading.from === "suggestion" ? (_jsx("p", { className: "consent-scan__note", children: suggestion.description })) : null, details.length ? (_jsx("p", { className: "consent-scan__details", children: details.map((detail, index) => (_jsx("span", { children: detail }, typeof detail === "string" ? detail : index))) })) : null, finding.status === "unknown" ? (_jsxs("div", { className: "consent-scan__classify", children: [_jsx(TextInput, { label: copy.service, onChange: (event) => setService(event.target.value), onKeyDown: (event) => {
|
|
549
551
|
// Enter adds the finding; it would otherwise submit the Cookies form around the tab.
|
|
550
552
|
if (event.key !== "Enter")
|
|
551
553
|
return;
|
package/dist/advice.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What to do about a finding, from what a scan measured. The rule behind it and its sources are in
|
|
3
|
+
* `docs/research/consent-rules.md` in the repository.
|
|
4
|
+
*/
|
|
5
|
+
export type Advice =
|
|
6
|
+
/** Third-party code, a frame, a tracking pixel, or a category seen where it is not allowed. */
|
|
7
|
+
"waitForConsent"
|
|
8
|
+
/** A font or stylesheet from another site gives that site the visitor's IP address. */
|
|
9
|
+
| "selfHost"
|
|
10
|
+
/** A plain file from another site, with nothing stored: fine if the provider only delivers it. */
|
|
11
|
+
| "checkProvider"
|
|
12
|
+
/** Storage no service explains. */
|
|
13
|
+
| "classifyStorage"
|
|
14
|
+
/** Registered as necessary, but the Open Cookie Database puts it in another category. */
|
|
15
|
+
| "reviewNecessary";
|
|
16
|
+
type Language = "en" | "sv";
|
|
17
|
+
export declare function adviceText(advice: Advice, language: Language): string;
|
|
18
|
+
/**
|
|
19
|
+
* What a host's requests before consent call for. No kinds at all means the scanner saw the host
|
|
20
|
+
* only inside a frame, so it is treated as code; `undefined` kinds come from an older scanner, which
|
|
21
|
+
* did not report them.
|
|
22
|
+
*/
|
|
23
|
+
export declare function hostAdvice(kinds: Record<string, number> | undefined, onTrackerList: boolean): Advice | undefined;
|
|
24
|
+
export {};
|
package/dist/advice.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
const TEXTS = {
|
|
2
|
+
en: {
|
|
3
|
+
waitForConsent: "Must wait for consent. Put it in the category that fits. If a c15t integration loads it, pick that integration on the service; if your code loads it, wrap it in ConsentFrame.",
|
|
4
|
+
selfHost: "Serve it from the site's own domain, for example fonts with next/font, so the visitor's IP address does not go to another site.",
|
|
5
|
+
checkProvider: "Only a file, and nothing is stored, so it can load before consent if the provider just delivers it for the site. Add the provider to a service and check its terms.",
|
|
6
|
+
classifyStorage: "Add it to a service. Unless the site cannot work without it for something the visitor asked for, it must wait for consent.",
|
|
7
|
+
reviewNecessary: "Registered as necessary, but the Open Cookie Database says otherwise. Move it to the category that fits and make it wait for consent, or remove the service from Necessary only if the site cannot work without it.",
|
|
8
|
+
},
|
|
9
|
+
sv: {
|
|
10
|
+
waitForConsent: "Måste vänta på samtycke. Lägg den i rätt kategori. Laddas den av en c15t-integration, välj integrationen i tjänsten. Laddas den av din kod, lägg den i ConsentFrame.",
|
|
11
|
+
selfHost: "Lägg filen på webbplatsens egen domän, till exempel typsnitt med next/font, så att besökarens IP-adress inte går till en annan webbplats.",
|
|
12
|
+
checkProvider: "Bara en fil, och inget lagras, så den får laddas före samtycke om leverantören enbart levererar den åt webbplatsen. Lägg leverantören i en tjänst och kontrollera dess villkor.",
|
|
13
|
+
classifyStorage: "Lägg den i en tjänst. Om inte webbplatsen behöver den för något besökaren har bett om måste den vänta på samtycke.",
|
|
14
|
+
reviewNecessary: "Står som nödvändig, men Open Cookie Database säger något annat. Flytta den till rätt kategori och låt den vänta på samtycke, eller behåll den bara om webbplatsen inte fungerar utan den.",
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
export function adviceText(advice, language) {
|
|
18
|
+
return TEXTS[language][advice];
|
|
19
|
+
}
|
|
20
|
+
/** Request kinds that only deliver a file: they run no code on the visitor's device. */
|
|
21
|
+
const PASSIVE = new Set(["image", "media", "manifest", "other"]);
|
|
22
|
+
const STYLING = new Set(["font", "stylesheet"]);
|
|
23
|
+
/**
|
|
24
|
+
* What a host's requests before consent call for. No kinds at all means the scanner saw the host
|
|
25
|
+
* only inside a frame, so it is treated as code; `undefined` kinds come from an older scanner, which
|
|
26
|
+
* did not report them.
|
|
27
|
+
*/
|
|
28
|
+
export function hostAdvice(kinds, onTrackerList) {
|
|
29
|
+
if (!kinds)
|
|
30
|
+
return undefined;
|
|
31
|
+
const seen = Object.keys(kinds);
|
|
32
|
+
if (!seen.length || onTrackerList)
|
|
33
|
+
return "waitForConsent";
|
|
34
|
+
if (seen.some((kind) => !PASSIVE.has(kind) && !STYLING.has(kind)))
|
|
35
|
+
return "waitForConsent";
|
|
36
|
+
return seen.some((kind) => STYLING.has(kind)) ? "selfHost" : "checkProvider";
|
|
37
|
+
}
|
package/dist/evaluate.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type Advice } from "./advice.ts";
|
|
1
2
|
import type { Category } from "./defaults.ts";
|
|
2
3
|
import type { ServiceDocument } from "./site-config.ts";
|
|
3
4
|
/** A consent state the scanner runs, and the categories the visitor allowed in it. */
|
|
@@ -44,6 +45,9 @@ export type ScanResultState = {
|
|
|
44
45
|
host: string;
|
|
45
46
|
firstParty: boolean;
|
|
46
47
|
requests: number;
|
|
48
|
+
/** Requests by Chromium's resource type; from a newer `consent-scanner`; older ones report none. */
|
|
49
|
+
kinds?: Record<string, number>;
|
|
50
|
+
pages?: string[];
|
|
47
51
|
}[];
|
|
48
52
|
beacons: {
|
|
49
53
|
host: string;
|
|
@@ -51,6 +55,8 @@ export type ScanResultState = {
|
|
|
51
55
|
lists: string[];
|
|
52
56
|
}[];
|
|
53
57
|
errors: string[];
|
|
58
|
+
/** Picked pages the scanner never reached. */
|
|
59
|
+
unvisited?: string[];
|
|
54
60
|
};
|
|
55
61
|
export type FindingKind = "cookie" | "localStorage" | "host";
|
|
56
62
|
/**
|
|
@@ -82,6 +88,10 @@ export type Finding = {
|
|
|
82
88
|
suggestion?: Suggestion;
|
|
83
89
|
/** For hosts: the tracker lists that flagged it (EasyPrivacy and others). */
|
|
84
90
|
trackerLists?: string[];
|
|
91
|
+
/** For hosts: requests by kind in the states with only necessary storage, to judge by. */
|
|
92
|
+
kinds?: Record<string, number>;
|
|
93
|
+
/** What to do about it. */
|
|
94
|
+
advice?: Advice;
|
|
85
95
|
};
|
|
86
96
|
export type ScanSummary = Record<FindingStatus, number> & {
|
|
87
97
|
new: number;
|
package/dist/evaluate.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { hostAdvice } from "./advice.js";
|
|
1
2
|
/**
|
|
2
3
|
* Why a finished scan may not show everything: a state the scanner did not return or that
|
|
3
4
|
* visited no pages, its errors, and sitemaps it could not read. Empty when the scan is complete.
|
|
@@ -12,6 +13,8 @@ export function scanProblems(args) {
|
|
|
12
13
|
problems.push(`${state.id}: no page could be visited`);
|
|
13
14
|
for (const error of result?.errors ?? [])
|
|
14
15
|
problems.push(`${state.id}: ${error}`);
|
|
16
|
+
if (result?.visited?.length && result.unvisited?.length)
|
|
17
|
+
problems.push(`${state.id}: ${result.unvisited.length} pages could not be visited: ${result.unvisited.slice(0, 3).join(", ")}`);
|
|
15
18
|
}
|
|
16
19
|
const sitemapErrors = args.pages?.sitemapErrors;
|
|
17
20
|
for (const entry of Array.isArray(sitemapErrors) ? sitemapErrors : []) {
|
|
@@ -89,9 +92,20 @@ export function evaluateScan({ states, results, services, previousKeys = [], })
|
|
|
89
92
|
suggestion: entry.suggestion,
|
|
90
93
|
});
|
|
91
94
|
const lists = new Map(state.beacons.map((beacon) => [beacon.host, beacon.lists]));
|
|
92
|
-
for (const host of state.hosts)
|
|
93
|
-
if (
|
|
94
|
-
|
|
95
|
+
for (const host of state.hosts) {
|
|
96
|
+
if (host.firstParty)
|
|
97
|
+
continue;
|
|
98
|
+
add("host", host.host, "", state.id, {
|
|
99
|
+
trackerLists: lists.get(host.host),
|
|
100
|
+
page: host.pages?.[0],
|
|
101
|
+
});
|
|
102
|
+
const finding = found.get(`host::${host.host}`);
|
|
103
|
+
if (finding && host.kinds && necessaryOnly.has(state.id)) {
|
|
104
|
+
finding.kinds ??= {};
|
|
105
|
+
for (const [kind, count] of Object.entries(host.kinds))
|
|
106
|
+
finding.kinds[kind] = (finding.kinds[kind] ?? 0) + count;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
95
109
|
}
|
|
96
110
|
for (const finding of found.values()) {
|
|
97
111
|
if (finding.kind !== "host" && OWN_STORAGE.test(finding.name)) {
|
|
@@ -109,6 +123,38 @@ export function evaluateScan({ states, results, services, previousKeys = [], })
|
|
|
109
123
|
finding.withoutConsent = finding.states.filter((stateId) => category !== "necessary" && !allowedIn.get(stateId)?.has(category));
|
|
110
124
|
finding.status = finding.withoutConsent.length ? "action" : "ok";
|
|
111
125
|
}
|
|
126
|
+
for (const finding of found.values()) {
|
|
127
|
+
if (finding.service === "c15t")
|
|
128
|
+
continue;
|
|
129
|
+
if (finding.kind === "host") {
|
|
130
|
+
if (!finding.beforeConsent) {
|
|
131
|
+
if (finding.status === "action")
|
|
132
|
+
finding.advice = "waitForConsent";
|
|
133
|
+
continue;
|
|
134
|
+
}
|
|
135
|
+
finding.advice = hostAdvice(finding.kinds, Boolean(finding.trackerLists?.length));
|
|
136
|
+
// A service marked necessary does not excuse code from another site before any choice.
|
|
137
|
+
if (finding.status !== "unknown" && finding.advice !== "checkProvider" && finding.advice)
|
|
138
|
+
finding.status = "action";
|
|
139
|
+
// A category seen where it is not allowed must wait, whatever kind of request it is.
|
|
140
|
+
if (finding.status === "action" && finding.withoutConsent.length)
|
|
141
|
+
finding.advice = "waitForConsent";
|
|
142
|
+
if (finding.status === "action")
|
|
143
|
+
finding.advice ??= "waitForConsent";
|
|
144
|
+
}
|
|
145
|
+
else if (finding.status === "action") {
|
|
146
|
+
finding.advice = "waitForConsent";
|
|
147
|
+
}
|
|
148
|
+
else if (finding.status === "unknown" && finding.beforeConsent) {
|
|
149
|
+
finding.advice = "classifyStorage";
|
|
150
|
+
}
|
|
151
|
+
else if (finding.category === "necessary" &&
|
|
152
|
+
finding.suggestion?.category &&
|
|
153
|
+
finding.suggestion.category !== "necessary") {
|
|
154
|
+
finding.status = "action";
|
|
155
|
+
finding.advice = "reviewNecessary";
|
|
156
|
+
}
|
|
157
|
+
}
|
|
112
158
|
const order = { action: 0, unknown: 1, ok: 2 };
|
|
113
159
|
const findings = [...found.values()].sort((a, b) => order[a.status] - order[b.status] ||
|
|
114
160
|
Number(b.beforeConsent) - Number(a.beforeConsent) ||
|
package/dist/notify.d.ts
CHANGED
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
import type { Payload } from "payload";
|
|
2
|
-
import type { ScanSummary } from "./evaluate.ts";
|
|
2
|
+
import type { Finding, ScanSummary } from "./evaluate.ts";
|
|
3
|
+
type Language = "en" | "sv";
|
|
3
4
|
export type ScanOutcome = {
|
|
4
5
|
url: string;
|
|
5
6
|
status: "done" | "failed";
|
|
6
7
|
error?: string | null;
|
|
7
8
|
summary?: ScanSummary | null;
|
|
9
|
+
/** What the scan found; the email lists what needs handling and how. */
|
|
10
|
+
findings?: Finding[] | null;
|
|
11
|
+
};
|
|
12
|
+
/** `name (page): what to do`, for each finding with advice that is not in order. */
|
|
13
|
+
export declare function listedActions(findings: Finding[] | null | undefined, language: Language): {
|
|
14
|
+
lines: string[];
|
|
15
|
+
more: number;
|
|
8
16
|
};
|
|
9
17
|
/**
|
|
10
18
|
* A scan worth an email: it failed, could not see everything, found something to handle, or found
|
|
@@ -16,3 +24,4 @@ export declare function needsNotice(outcome: ScanOutcome): boolean;
|
|
|
16
24
|
* email adapter, when it needs a look. Admin's default language picks the text.
|
|
17
25
|
*/
|
|
18
26
|
export declare function notifyScan(payload: Payload, outcome: ScanOutcome): Promise<void>;
|
|
27
|
+
export {};
|
package/dist/notify.js
CHANGED
|
@@ -1,4 +1,27 @@
|
|
|
1
|
+
import { adviceText } from "./advice.js";
|
|
1
2
|
import { CONSENT_GLOBAL } from "./types.js";
|
|
3
|
+
/** The most an email lists: the Scan tab has the rest. */
|
|
4
|
+
const MAX_LISTED = 10;
|
|
5
|
+
/** `name (page): what to do`, for each finding with advice that is not in order. */
|
|
6
|
+
export function listedActions(findings, language) {
|
|
7
|
+
const open = (findings ?? []).filter((finding) => finding.advice && finding.status !== "ok");
|
|
8
|
+
const page = (url) => {
|
|
9
|
+
if (!url)
|
|
10
|
+
return "";
|
|
11
|
+
try {
|
|
12
|
+
return ` (${new URL(url).pathname})`;
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
return "";
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
return {
|
|
19
|
+
lines: open
|
|
20
|
+
.slice(0, MAX_LISTED)
|
|
21
|
+
.map((finding) => `${finding.name}${page(finding.page)}: ${adviceText(finding.advice, language)}`),
|
|
22
|
+
more: Math.max(0, open.length - MAX_LISTED),
|
|
23
|
+
};
|
|
24
|
+
}
|
|
2
25
|
/**
|
|
3
26
|
* A scan worth an email: it failed, could not see everything, found something to handle, or found
|
|
4
27
|
* something new.
|
|
@@ -19,6 +42,7 @@ const COPY = {
|
|
|
19
42
|
done: (o) => `The cookie scan of ${o.url} found ${count(o.summary, "en")}.${problems(o).length
|
|
20
43
|
? ` It is incomplete, so it may have missed something: ${problems(o).slice(0, 3).join("; ")}.`
|
|
21
44
|
: ""}`,
|
|
45
|
+
more: (n) => `And ${n} more in the Scan tab.`,
|
|
22
46
|
open: "Open Cookies in Admin",
|
|
23
47
|
why: "You get this because you are chosen under Cookies → Scan.",
|
|
24
48
|
},
|
|
@@ -30,6 +54,7 @@ const COPY = {
|
|
|
30
54
|
done: (o) => `Cookieskanningen av ${o.url} hittade ${count(o.summary, "sv")}.${problems(o).length
|
|
31
55
|
? ` Den är ofullständig och kan ha missat något: ${problems(o).slice(0, 3).join("; ")}.`
|
|
32
56
|
: ""}`,
|
|
57
|
+
more: (n) => `Och ${n} till under fliken Skanning.`,
|
|
33
58
|
open: "Öppna Cookies i Admin",
|
|
34
59
|
why: "Du får det här för att du är vald under Cookies → Skanning.",
|
|
35
60
|
},
|
|
@@ -87,6 +112,8 @@ export async function notifyScan(payload, outcome) {
|
|
|
87
112
|
}
|
|
88
113
|
})();
|
|
89
114
|
const text = outcome.status === "failed" ? copy.failed(outcome) : copy.done(outcome);
|
|
115
|
+
const { lines, more } = listedActions(outcome.findings, language);
|
|
116
|
+
const andMore = more ? copy.more(more) : "";
|
|
90
117
|
// Admin is on the scanned site's origin when Payload has no serverURL.
|
|
91
118
|
const base = payload.config.serverURL || origin(outcome.url);
|
|
92
119
|
const link = `${base}${payload.config.routes.admin}/globals/${CONSENT_GLOBAL}`;
|
|
@@ -94,8 +121,8 @@ export async function notifyScan(payload, outcome) {
|
|
|
94
121
|
await payload.sendEmail({
|
|
95
122
|
to,
|
|
96
123
|
subject: copy.subject(outcome, host),
|
|
97
|
-
text: `${text}\n\n${copy.open}: ${link}\n\n${copy.why}`,
|
|
98
|
-
html: `<p>${escape(text)}</p
|
|
124
|
+
text: `${text}\n\n${lines.map((line) => `- ${line}`).join("\n")}${andMore ? `\n${andMore}` : ""}${lines.length ? "\n\n" : ""}${copy.open}: ${link}\n\n${copy.why}`,
|
|
125
|
+
html: `<p>${escape(text)}</p>${lines.length ? `<ul>${lines.map((line) => `<li>${escape(line)}</li>`).join("")}</ul>` : ""}${andMore ? `<p>${escape(andMore)}</p>` : ""}<p><a href="${escape(link)}">${copy.open}</a></p><p><small>${copy.why}</small></p>`,
|
|
99
126
|
});
|
|
100
127
|
}
|
|
101
128
|
catch (error) {
|
package/dist/scans.js
CHANGED
|
@@ -342,6 +342,7 @@ function endpoints(options) {
|
|
|
342
342
|
status: done ? "done" : "failed",
|
|
343
343
|
error: done ? null : (result.error ?? "The scan failed"),
|
|
344
344
|
summary: (summary ?? undefined),
|
|
345
|
+
findings: evaluated?.findings,
|
|
345
346
|
});
|
|
346
347
|
return Response.json({ ok: true });
|
|
347
348
|
},
|
package/dist/styles/admin.css
CHANGED