@holmdigital/engine 3.3.13 → 4.0.1
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/README.md +13 -0
- package/dist/{chunk-W2H46SI5.mjs → chunk-M6ATPKNB.mjs} +5 -2
- package/dist/{chunk-UWT7ZJVZ.mjs → chunk-Y4NNYB3U.mjs} +238 -77
- package/dist/cli/index.js +291 -92
- package/dist/cli/index.mjs +54 -12
- package/dist/cli/templates/de.json +2 -2
- package/dist/cli/templates/en-au.json +1 -0
- package/dist/index.d.mts +15 -4
- package/dist/index.d.ts +15 -4
- package/dist/index.js +239 -83
- package/dist/index.mjs +1 -1
- package/dist/{plain-report-7MFB3JGF.mjs → plain-report-4MJZKEGX.mjs} +1 -1
- package/dist/templates/de.json +2 -2
- package/dist/templates/en-au.json +1 -0
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -67,6 +67,8 @@ npx hd-a11y-scan <url> [options]
|
|
|
67
67
|
| `--phone <number>` | Contact phone for the statement metadata |
|
|
68
68
|
| `--response-time <val>` | Response time for the statement metadata |
|
|
69
69
|
| `--publish-date <date>` | Publish date for the website (YYYY-MM-DD) |
|
|
70
|
+
| `--review-method <method>` | How the statement's assessment was made: `self-assessment` (default), `external-review` (requires `--reviewer`) or `no-review` |
|
|
71
|
+
| `--reviewer <name>` | Organisation that performed the external review, named in the statement |
|
|
70
72
|
| `--country <code>` | Country code for enforcement body (`SE`, `NO`, `DE`, `IT`, `PT`, `PL`, `AU`, etc.) |
|
|
71
73
|
| `--sector <type>` | Sector type: `public` (WAD) or `private` (EAA). Default: `public` |
|
|
72
74
|
| `--viewport <size>` | Set viewport size (`mobile`, `tablet`, `desktop`, or custom `1024x768`) |
|
|
@@ -74,6 +76,8 @@ npx hd-a11y-scan <url> [options]
|
|
|
74
76
|
| `--junit <path>` | Generate a JUnit XML report for CI dashboards |
|
|
75
77
|
| `--format <type>` | Output format for statement (`html`, `md`). Default: `html` |
|
|
76
78
|
| `--invalid-https-cert` | Allow scanning sites with invalid/self-signed HTTPS certificates ⚠️ |
|
|
79
|
+
| `--allow-private-hosts` | Allow private and internal addresses such as `localhost`, `10.x` and `192.168.x`. **Blocked by default**, for the page and every request it makes. Use it to scan your own local development server. |
|
|
80
|
+
| `--no-sandbox` | Disable Chromium's sandbox. **On by default.** Needed only when running as root or where user namespaces are restricted (some CI runners, containers without a user). Only for pages you trust. `PUPPETEER_ARGS="--no-sandbox"` does the same. |
|
|
77
81
|
| `--api-key <key>` | API Key for HolmDigital Cloud |
|
|
78
82
|
| `--cloud-url <url>` | Custom Cloud API Endpoint (default: cloud.holmdigital.se) |
|
|
79
83
|
| `--light` | Fast score-only mode — skips HTML validation and detailed legal mapping |
|
|
@@ -99,6 +103,15 @@ A `partial` verdict still earns the badge: core content is there and the page ca
|
|
|
99
103
|
|
|
100
104
|
> **⚠️ Security Note:** The `--invalid-https-cert` flag should only be used in trusted environments (local dev, staging). It disables certificate validation and is not recommended for production. *(Contributed by [@FerdiStro](https://github.com/FerdiStro))*
|
|
101
105
|
|
|
106
|
+
#### Security defaults (4.0.0)
|
|
107
|
+
|
|
108
|
+
Two defaults changed in 4.0.0, because the engine renders third-party pages with their scripts:
|
|
109
|
+
|
|
110
|
+
- **Private and internal addresses are blocked.** Scanning `http://localhost:3000` now fails with a message telling you to pass `--allow-private-hosts` (library: `allowPrivateHosts: true`). The check also covers redirects and every resource the page loads, so a public page cannot pull the scanner into your internal network.
|
|
111
|
+
- **Chromium's sandbox is on.** If Chrome cannot start its sandbox, which happens when running as root or on CI runners that restrict user namespaces, the error says so and tells you to add `--no-sandbox` (library: `sandbox: false`, or `PUPPETEER_ARGS="--no-sandbox"`).
|
|
112
|
+
|
|
113
|
+
In CI that scans a local build, you will typically need both: `npx hd-a11y-scan http://localhost:3000 --ci --allow-private-hosts --no-sandbox`.
|
|
114
|
+
|
|
102
115
|
**Example:**
|
|
103
116
|
```bash
|
|
104
117
|
# Fail only on critical issues in CI
|
|
@@ -56,11 +56,14 @@ function klarsprakLegalLine(dosLagenReference, opts) {
|
|
|
56
56
|
}
|
|
57
57
|
if (isNotYetLaw) {
|
|
58
58
|
const phrase2 = criterionPhrase(level, opts?.wcagCriteria ?? "", title);
|
|
59
|
-
|
|
59
|
+
if (opts?.sector === "private") {
|
|
60
|
+
return `\xC4nnu inte lagkrav enligt lagen (2023:254) om vissa produkters och tj\xE4nsters tillg\xE4nglighet. ${phrase2} tillkom i WCAG 2.2. Det ger presumtion enligt 9 \xA7 n\xE4r en harmoniserad standard som omfattar kriteriet har offentliggjorts i Europeiska unionens officiella tidning under direktiv (EU) 2019/882.`;
|
|
61
|
+
}
|
|
62
|
+
return `\xC4nnu inte lagkrav enligt DOS-lagen (2018:1937). ${phrase2} tillkom i WCAG 2.2. Det blir bindande n\xE4r MDFFS 2019:2 5 \xA7 \xE4ndras till en version av EN 301 549 som omfattar kriteriet.`;
|
|
60
63
|
}
|
|
61
64
|
const phrase = criterionPhrase(level, opts?.wcagCriteria ?? "", title);
|
|
62
65
|
if (opts?.sector === "private") {
|
|
63
|
-
return `Lagkrav
|
|
66
|
+
return `Lagkrav om tj\xE4nsten omfattas av lagen (2023:254) 4 \xA7 och inte tillhandah\xE5lls av ett mikrof\xF6retag (10 \xA7): webbplatser och appar ska vara uppfattningsbara, hanterbara, begripliga och robusta (6 \xA7 och f\xF6rordningen (2023:676) bilaga 2 punkt 3). Lagen n\xE4mner inte WCAG. ${phrase} \xE4r ett vedertaget s\xE4tt att visa detta, men ger presumtion enligt 9 \xA7 f\xF6rst n\xE4r en harmoniserad standard som omfattar kriteriet har offentliggjorts i Europeiska unionens officiella tidning.`;
|
|
64
67
|
}
|
|
65
68
|
const en = opts?.en301549Criteria && opts.en301549Criteria !== "N/A" && opts.en301549Criteria !== "Unknown" ? `, EN 301 549 ${opts.en301549Criteria}` : "";
|
|
66
69
|
return `Lagkrav: DOS-lagen (2018:1937), 10 \xA7. ${phrase}${en}.`;
|
|
@@ -136,6 +136,7 @@ function evaluateNoScriptCoverage(textLengthWithoutJs, textLengthWithJs, hasNoSc
|
|
|
136
136
|
async function probeWithoutJavaScript(browser, options) {
|
|
137
137
|
const page = await browser.newPage();
|
|
138
138
|
try {
|
|
139
|
+
if (options.preparePage) await options.preparePage(page);
|
|
139
140
|
if (options.userAgent) await page.setUserAgent(options.userAgent);
|
|
140
141
|
if (options.viewport) await page.setViewport(options.viewport);
|
|
141
142
|
await page.setJavaScriptEnabled(false);
|
|
@@ -201,6 +202,144 @@ var HtmlValidator = class {
|
|
|
201
202
|
}
|
|
202
203
|
};
|
|
203
204
|
|
|
205
|
+
// src/core/network-guard.ts
|
|
206
|
+
import { lookup } from "dns/promises";
|
|
207
|
+
import { isIP } from "net";
|
|
208
|
+
var PrivateHostError = class extends Error {
|
|
209
|
+
host;
|
|
210
|
+
reason;
|
|
211
|
+
constructor(url, host, reason) {
|
|
212
|
+
super(
|
|
213
|
+
`Refusing to scan '${url}': ${host} resolves to ${reason}. Private and internal addresses are blocked by default, so the engine cannot be used to reach internal services. To scan your own local development server, pass --allow-private-hosts (library: allowPrivateHosts: true).`
|
|
214
|
+
);
|
|
215
|
+
this.name = "PrivateHostError";
|
|
216
|
+
this.host = host;
|
|
217
|
+
this.reason = reason;
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
function blockedIPv4(ip) {
|
|
221
|
+
const p = ip.split(".").map(Number);
|
|
222
|
+
if (p.length !== 4 || p.some((n) => !Number.isInteger(n) || n < 0 || n > 255)) return "a malformed IPv4 address";
|
|
223
|
+
const [a, b] = p;
|
|
224
|
+
if (a === 0) return "this-network 0.0.0.0/8";
|
|
225
|
+
if (a === 10) return "private 10.0.0.0/8";
|
|
226
|
+
if (a === 127) return "loopback 127.0.0.0/8";
|
|
227
|
+
if (a === 169 && b === 254) {
|
|
228
|
+
return ip === "169.254.169.254" ? "the cloud metadata service 169.254.169.254" : "link-local 169.254.0.0/16";
|
|
229
|
+
}
|
|
230
|
+
if (a === 172 && b >= 16 && b <= 31) return "private 172.16.0.0/12";
|
|
231
|
+
if (a === 192 && b === 168) return "private 192.168.0.0/16";
|
|
232
|
+
if (a === 100 && b >= 64 && b <= 127) return "carrier-grade NAT 100.64.0.0/10";
|
|
233
|
+
if (a === 192 && b === 0) return "IETF protocol assignments 192.0.0.0/24";
|
|
234
|
+
if (a >= 224) return "multicast or reserved 224.0.0.0/4";
|
|
235
|
+
return null;
|
|
236
|
+
}
|
|
237
|
+
function blockedIPv6(ip) {
|
|
238
|
+
const lower = ip.toLowerCase();
|
|
239
|
+
const mapped = lower.match(/^::ffff:(\d+\.\d+\.\d+\.\d+)$/);
|
|
240
|
+
if (mapped) return blockedIPv4(mapped[1]);
|
|
241
|
+
if (lower === "::1") return "loopback ::1";
|
|
242
|
+
if (lower === "::") return "unspecified ::";
|
|
243
|
+
if (/^f[cd]/.test(lower)) return "unique local fc00::/7";
|
|
244
|
+
if (/^fe[89ab]/.test(lower)) return "link-local fe80::/10";
|
|
245
|
+
if (/^ff/.test(lower)) return "multicast ff00::/8";
|
|
246
|
+
return null;
|
|
247
|
+
}
|
|
248
|
+
var systemResolver = (hostname) => lookup(hostname, { all: true });
|
|
249
|
+
async function blockedHostReason(hostname, resolve = systemResolver) {
|
|
250
|
+
const host = hostname.replace(/^\[|\]$/g, "");
|
|
251
|
+
const literal = isIP(host);
|
|
252
|
+
if (literal === 4) return blockedIPv4(host);
|
|
253
|
+
if (literal === 6) return blockedIPv6(host);
|
|
254
|
+
let addresses;
|
|
255
|
+
try {
|
|
256
|
+
addresses = await resolve(host);
|
|
257
|
+
} catch {
|
|
258
|
+
return "an address that could not be resolved (blocked: the guard fails closed)";
|
|
259
|
+
}
|
|
260
|
+
if (addresses.length === 0) return "no address (blocked: the guard fails closed)";
|
|
261
|
+
for (const { address, family } of addresses) {
|
|
262
|
+
const reason = family === 6 ? blockedIPv6(address) : blockedIPv4(address);
|
|
263
|
+
if (reason) return reason;
|
|
264
|
+
}
|
|
265
|
+
return null;
|
|
266
|
+
}
|
|
267
|
+
async function assertPublicHost(url, resolve = systemResolver) {
|
|
268
|
+
const { hostname } = new URL(url);
|
|
269
|
+
const reason = await blockedHostReason(hostname, resolve);
|
|
270
|
+
if (reason) throw new PrivateHostError(url, hostname, reason);
|
|
271
|
+
}
|
|
272
|
+
var LOCAL_SCHEMES = /* @__PURE__ */ new Set(["data:", "blob:", "about:"]);
|
|
273
|
+
async function guardPage(page, resolve = systemResolver) {
|
|
274
|
+
const verdicts = /* @__PURE__ */ new Map();
|
|
275
|
+
const blocked = [];
|
|
276
|
+
const verdictFor = (hostname) => {
|
|
277
|
+
let verdict = verdicts.get(hostname);
|
|
278
|
+
if (!verdict) {
|
|
279
|
+
verdict = blockedHostReason(hostname, resolve);
|
|
280
|
+
verdicts.set(hostname, verdict);
|
|
281
|
+
}
|
|
282
|
+
return verdict;
|
|
283
|
+
};
|
|
284
|
+
await page.setRequestInterception(true);
|
|
285
|
+
page.on("request", (request) => {
|
|
286
|
+
void (async () => {
|
|
287
|
+
let reason;
|
|
288
|
+
let host = "";
|
|
289
|
+
try {
|
|
290
|
+
const target = new URL(request.url());
|
|
291
|
+
host = target.hostname;
|
|
292
|
+
if (LOCAL_SCHEMES.has(target.protocol)) {
|
|
293
|
+
reason = null;
|
|
294
|
+
} else if (target.protocol === "http:" || target.protocol === "https:") {
|
|
295
|
+
reason = await verdictFor(target.hostname);
|
|
296
|
+
} else {
|
|
297
|
+
reason = `the unsupported scheme ${target.protocol}`;
|
|
298
|
+
}
|
|
299
|
+
} catch {
|
|
300
|
+
reason = "an address the guard could not check";
|
|
301
|
+
}
|
|
302
|
+
try {
|
|
303
|
+
if (reason) {
|
|
304
|
+
blocked.push({ url: request.url(), host, reason });
|
|
305
|
+
await request.abort("blockedbyclient");
|
|
306
|
+
} else {
|
|
307
|
+
await request.continue();
|
|
308
|
+
}
|
|
309
|
+
} catch {
|
|
310
|
+
}
|
|
311
|
+
})();
|
|
312
|
+
});
|
|
313
|
+
return () => [...blocked];
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
// src/core/browser-launch.ts
|
|
317
|
+
function puppeteerArgsFromEnv(env = process.env) {
|
|
318
|
+
return (env.PUPPETEER_ARGS ?? "").split(/\s+/).filter(Boolean);
|
|
319
|
+
}
|
|
320
|
+
function sandboxRequested(policy, env = process.env) {
|
|
321
|
+
return policy.sandbox !== false && !puppeteerArgsFromEnv(env).includes("--no-sandbox");
|
|
322
|
+
}
|
|
323
|
+
function chromeLaunchArgs(policy, env = process.env) {
|
|
324
|
+
return [
|
|
325
|
+
...policy.sandbox === false ? ["--no-sandbox", "--disable-setuid-sandbox"] : [],
|
|
326
|
+
...policy.invalidHttpsCert ? ["--ignore-certificate-errors", "--allow-insecure-localhost"] : [],
|
|
327
|
+
...policy.extraArgs ?? [],
|
|
328
|
+
...puppeteerArgsFromEnv(env)
|
|
329
|
+
];
|
|
330
|
+
}
|
|
331
|
+
function explainLaunchFailure(error, policy, env = process.env) {
|
|
332
|
+
const original = error instanceof Error ? error : new Error(String(error));
|
|
333
|
+
if (!sandboxRequested(policy, env) || !/sandbox|user namespace|setuid|crbug\.com\/638180/i.test(original.message)) {
|
|
334
|
+
return original;
|
|
335
|
+
}
|
|
336
|
+
const chromeSaid = original.message.split("\n").find((line) => /sandbox|namespace|setuid/i.test(line))?.trim() ?? original.message.split("\n")[0];
|
|
337
|
+
return new Error(
|
|
338
|
+
`Chrome could not start its sandbox. The sandbox is on by default because the engine renders third-party pages. Chrome cannot use it when running as root (for example in a container without a USER) or where unprivileged user namespaces are restricted (for example on Ubuntu 24.04 CI runners). Either run as a regular user in an environment that allows the sandbox, or disable it explicitly with --no-sandbox (library: sandbox: false, or PUPPETEER_ARGS="--no-sandbox"). Only disable it for pages you trust.
|
|
339
|
+
Chrome said: ${chromeSaid}`
|
|
340
|
+
);
|
|
341
|
+
}
|
|
342
|
+
|
|
204
343
|
// src/core/regulatory-scanner.ts
|
|
205
344
|
import { readFileSync } from "fs";
|
|
206
345
|
function wcagTagToCriterion(tag) {
|
|
@@ -260,7 +399,7 @@ function isInterstitialPage(pageTitle, hasMetaRefresh, bodyTextLength) {
|
|
|
260
399
|
return false;
|
|
261
400
|
}
|
|
262
401
|
function getEngineVersion() {
|
|
263
|
-
return "
|
|
402
|
+
return "4.0.1";
|
|
264
403
|
}
|
|
265
404
|
function getStandardsVersion() {
|
|
266
405
|
try {
|
|
@@ -274,6 +413,7 @@ function getStandardsVersion() {
|
|
|
274
413
|
var SCAN_USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36";
|
|
275
414
|
var RegulatoryScanner = class {
|
|
276
415
|
browser = null;
|
|
416
|
+
blockedRequests = () => [];
|
|
277
417
|
options;
|
|
278
418
|
htmlValidator;
|
|
279
419
|
constructor(options) {
|
|
@@ -310,6 +450,9 @@ var RegulatoryScanner = class {
|
|
|
310
450
|
let interstitialSuspected;
|
|
311
451
|
let passedCount = 0;
|
|
312
452
|
try {
|
|
453
|
+
if (!this.options.allowPrivateHosts) {
|
|
454
|
+
await assertPublicHost(this.options.url);
|
|
455
|
+
}
|
|
313
456
|
await this.initBrowser();
|
|
314
457
|
const page = await this.getPage();
|
|
315
458
|
if (this.options.viewport) {
|
|
@@ -324,6 +467,10 @@ var RegulatoryScanner = class {
|
|
|
324
467
|
});
|
|
325
468
|
break;
|
|
326
469
|
} catch (e) {
|
|
470
|
+
const stopped = this.blockedRequests()[0];
|
|
471
|
+
if (stopped && e instanceof Error && e.message.includes("ERR_BLOCKED_BY_CLIENT")) {
|
|
472
|
+
throw new PrivateHostError(this.options.url, stopped.host, `${stopped.reason}, reached during navigation (for example through a redirect)`);
|
|
473
|
+
}
|
|
327
474
|
retries--;
|
|
328
475
|
if (retries === 0) throw e;
|
|
329
476
|
this.log(`Navigation failed, retrying... (${retries} attempts left)`);
|
|
@@ -403,6 +550,11 @@ var RegulatoryScanner = class {
|
|
|
403
550
|
}
|
|
404
551
|
const scanDuration = Date.now() - startTime;
|
|
405
552
|
const result = this.generateResultPackage(allReports, passedCount, scanDuration, pageTitle, pageLanguage, interstitialSuspected);
|
|
553
|
+
const blockedCount = this.blockedRequests().length;
|
|
554
|
+
if (blockedCount > 0) {
|
|
555
|
+
result.metadata.blockedPrivateRequests = blockedCount;
|
|
556
|
+
this.log(`Sp\xE4rrade ${blockedCount} f\xF6rfr\xE5gningar till privata eller interna adresser (Intern #53).`);
|
|
557
|
+
}
|
|
406
558
|
if (result.complianceStatus !== "INCONCLUSIVE") {
|
|
407
559
|
if (htmlValidation) {
|
|
408
560
|
result.htmlValidation = htmlValidation;
|
|
@@ -417,20 +569,27 @@ var RegulatoryScanner = class {
|
|
|
417
569
|
}
|
|
418
570
|
}
|
|
419
571
|
async initBrowser() {
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
572
|
+
const policy = {
|
|
573
|
+
sandbox: this.options.sandbox,
|
|
574
|
+
invalidHttpsCert: this.options.invalidHttpsCert,
|
|
575
|
+
extraArgs: ["--disable-blink-features=AutomationControlled"]
|
|
576
|
+
// Gömmer att det är en robot
|
|
577
|
+
};
|
|
578
|
+
try {
|
|
579
|
+
this.browser = await puppeteer.launch({
|
|
580
|
+
headless: this.options.headless,
|
|
581
|
+
args: chromeLaunchArgs(policy)
|
|
582
|
+
});
|
|
583
|
+
} catch (e) {
|
|
584
|
+
throw explainLaunchFailure(e, policy);
|
|
585
|
+
}
|
|
430
586
|
}
|
|
431
587
|
async getPage() {
|
|
432
588
|
if (!this.browser) throw new Error("Browser not initialized");
|
|
433
589
|
const page = await this.browser.newPage();
|
|
590
|
+
if (!this.options.allowPrivateHosts) {
|
|
591
|
+
this.blockedRequests = await guardPage(page);
|
|
592
|
+
}
|
|
434
593
|
await page.setUserAgent(SCAN_USER_AGENT);
|
|
435
594
|
return page;
|
|
436
595
|
}
|
|
@@ -457,7 +616,11 @@ var RegulatoryScanner = class {
|
|
|
457
616
|
// vi skulle mäta två olika sidor, inte JS-effekten.
|
|
458
617
|
url: this.options.url,
|
|
459
618
|
userAgent: SCAN_USER_AGENT,
|
|
460
|
-
viewport: this.options.viewport
|
|
619
|
+
viewport: this.options.viewport,
|
|
620
|
+
// Sondens sida får samma spärr som huvudsidan.
|
|
621
|
+
preparePage: this.options.allowPrivateHosts ? void 0 : async (probePage) => {
|
|
622
|
+
await guardPage(probePage);
|
|
623
|
+
}
|
|
461
624
|
});
|
|
462
625
|
return evaluateNoScriptCoverage(
|
|
463
626
|
measurement.textLength,
|
|
@@ -894,7 +1057,12 @@ function isBadgeWithheldByRobustness(noScript) {
|
|
|
894
1057
|
import React from "react";
|
|
895
1058
|
import { renderToStaticMarkup } from "react-dom/server";
|
|
896
1059
|
import { AccessibilityStatement } from "@holmdigital/components";
|
|
897
|
-
import {
|
|
1060
|
+
import {
|
|
1061
|
+
getEnforcementBody,
|
|
1062
|
+
getEnforcementStatementText,
|
|
1063
|
+
getNationalLaws,
|
|
1064
|
+
resolveNationalLawReference
|
|
1065
|
+
} from "@holmdigital/standards";
|
|
898
1066
|
import fs from "fs/promises";
|
|
899
1067
|
import path from "path";
|
|
900
1068
|
var EVALUATION_METHOD = {
|
|
@@ -954,49 +1122,35 @@ var RESPONSE_TIME_DEFAULT = {
|
|
|
954
1122
|
"en-ca": "2 days",
|
|
955
1123
|
"en-au": "2 days"
|
|
956
1124
|
};
|
|
957
|
-
var
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
function
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
if (country === "US") {
|
|
978
|
-
const usLaws = getNationalLaws("US").filter(inForce);
|
|
979
|
-
const adaLaw = usLaws.find((l) => l.euFramework === "ADA" && l.scope === sector);
|
|
980
|
-
if (adaLaw) {
|
|
981
|
-
if (sector === "public") {
|
|
982
|
-
const s508 = usLaws.find((l) => l.id === "us-508");
|
|
983
|
-
return s508 ? `${adaLaw.fullName} (${adaLaw.law}) & ${s508.fullName} (${s508.law})` : `${adaLaw.fullName} (${adaLaw.law})`;
|
|
984
|
-
}
|
|
985
|
-
const hhs504 = usLaws.find((l) => l.euFramework === "REHAB" && l.scope === "private");
|
|
986
|
-
return hhs504 ? `${adaLaw.fullName} (${adaLaw.law}) & ${hhs504.fullName} (${hhs504.law})` : `${adaLaw.fullName} (${adaLaw.law})`;
|
|
987
|
-
}
|
|
988
|
-
}
|
|
989
|
-
const law = getNationalLawForSector(country, sector);
|
|
990
|
-
if (law) {
|
|
991
|
-
const shortName = law.law.trim();
|
|
992
|
-
const longName = law.fullName.trim();
|
|
993
|
-
const redundant = longName === shortName || longName.startsWith(shortName);
|
|
994
|
-
return redundant ? longName : `${longName} (${shortName})`;
|
|
995
|
-
}
|
|
996
|
-
const langKey = lang.split("-")[0];
|
|
997
|
-
return NATIONAL_LAW_FALLBACK[langKey] ?? NATIONAL_LAW_FALLBACK.en;
|
|
1125
|
+
var REVIEWER_PLACEHOLDERS = [
|
|
1126
|
+
"{<extern akt\xF6r>}",
|
|
1127
|
+
"{<ekstern akt\xF8r>}",
|
|
1128
|
+
"{<ekstern aktor>}",
|
|
1129
|
+
"{<ulkoinen taho>}",
|
|
1130
|
+
"{<externe partij>}",
|
|
1131
|
+
"{<externer Dritter>}",
|
|
1132
|
+
"{<tiers externe>}",
|
|
1133
|
+
"{<tercero externo>}",
|
|
1134
|
+
"{<terza parte>}",
|
|
1135
|
+
"{<terceiro externo>}",
|
|
1136
|
+
"{<podmiot zewn\u0119trzny>}",
|
|
1137
|
+
"{<third party>}"
|
|
1138
|
+
];
|
|
1139
|
+
function resolveSwedishEnforcementContent(enforcementBody, nationalLaw) {
|
|
1140
|
+
return `${enforcementBody} har ansvaret f\xF6r tillsyn \xF6ver ${nationalLaw}. Du kan anm\xE4la till ${enforcementBody} om du tycker att v\xE5r digitala service har brister i tillg\xE4nglighet.
|
|
1141
|
+
|
|
1142
|
+
Du kan ocks\xE5 anm\xE4la till ${enforcementBody} om du tycker att v\xE5r bed\xF6mning av vad som \xE4r osk\xE4ligt betungande ska granskas, om du tycker att v\xE5r tillg\xE4nglighetsredog\xF6relse har brister eller om du tycker att vi inte har hanterat din beg\xE4ran om tillg\xE4ngligg\xF6rande korrekt.
|
|
1143
|
+
|
|
1144
|
+
Du kan anm\xE4la direkt till Digg via tj\xE4nsten f\xF6r anm\xE4lan om bristande tillg\xE4nglighet: https://www.digg.se/tdosanmalan`;
|
|
998
1145
|
}
|
|
999
1146
|
async function generateStatementContent(result, lang = "en", format = "html", metadata) {
|
|
1147
|
+
const reviewMethod = metadata?.reviewMethod;
|
|
1148
|
+
const reviewerName = typeof metadata?.reviewer?.name === "string" ? metadata.reviewer.name.trim() : "";
|
|
1149
|
+
if (reviewMethod === "external-review" && reviewerName === "") {
|
|
1150
|
+
throw new Error(
|
|
1151
|
+
"reviewMethod 'external-review' requires metadata.reviewer with a non-empty name: the organisation that performed the review, e.g. { reviewMethod: 'external-review', reviewer: { name: 'Example Audit AB' } }. The statement names it as the reviewer. Use 'self-assessment' (the default) if the statement is based on your own testing, such as this scan."
|
|
1152
|
+
);
|
|
1153
|
+
}
|
|
1000
1154
|
const templatePath = path.join(__dirname, "templates", `${lang}.json`);
|
|
1001
1155
|
let template;
|
|
1002
1156
|
try {
|
|
@@ -1007,12 +1161,7 @@ async function generateStatementContent(result, lang = "en", format = "html", me
|
|
|
1007
1161
|
`Accessibility statement template not found for locale "${lang}". Expected file at: ${templatePath}`
|
|
1008
1162
|
);
|
|
1009
1163
|
}
|
|
1010
|
-
|
|
1011
|
-
if (result.stats.critical > 0 || result.legalSummary && result.legalSummary.eaaDeadlineViolations > 0) {
|
|
1012
|
-
complianceLevel = "non-compliant";
|
|
1013
|
-
} else if (result.score < 100) {
|
|
1014
|
-
complianceLevel = "partial";
|
|
1015
|
-
}
|
|
1164
|
+
const complianceLevel = "partial";
|
|
1016
1165
|
const issuesMap = /* @__PURE__ */ new Map();
|
|
1017
1166
|
violationsOf(result.reports).forEach((report) => {
|
|
1018
1167
|
if (!issuesMap.has(report.ruleId)) {
|
|
@@ -1083,6 +1232,10 @@ async function generateStatementContent(result, lang = "en", format = "html", me
|
|
|
1083
1232
|
name: "HolmDigital Regulatory Engine",
|
|
1084
1233
|
url: "https://holmdigital.se"
|
|
1085
1234
|
},
|
|
1235
|
+
// Intern #95: HTML-utlåtandet renderas av komponenten, så metodvalet och
|
|
1236
|
+
// granskaren måste följa med dit. Annars gäller valet bara Markdown.
|
|
1237
|
+
reviewMethod,
|
|
1238
|
+
reviewer: metadata?.reviewer,
|
|
1086
1239
|
logoUrl,
|
|
1087
1240
|
// Placeholders make it obvious the consumer must supply real contact info.
|
|
1088
1241
|
// Previous fallback leaked HolmDigital's own contact details into customer statements.
|
|
@@ -1175,15 +1328,10 @@ async function generateStatementContent(result, lang = "en", format = "html", me
|
|
|
1175
1328
|
"{<m\xE9thode>}": props.evaluationMethod || "Automated Scan",
|
|
1176
1329
|
"{<m\xE9todo>}": props.evaluationMethod || "Automated Scan",
|
|
1177
1330
|
"{<method>}": props.evaluationMethod || "Automated Scan",
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
"{<externe partij>}": props.generatorTool?.name || "HolmDigital Engine",
|
|
1183
|
-
"{<externer Dritter>}": props.generatorTool?.name || "HolmDigital Engine",
|
|
1184
|
-
"{<tiers externe>}": props.generatorTool?.name || "HolmDigital Engine",
|
|
1185
|
-
"{<tercero externo>}": props.generatorTool?.name || "HolmDigital Engine",
|
|
1186
|
-
"{<third party>}": props.generatorTool?.name || "HolmDigital Engine",
|
|
1331
|
+
// Intern #95: granskarens plats fylls bara ur reviewer, aldrig ur
|
|
1332
|
+
// generatorTool. Den renderas bara när metodvalet är en uttalad
|
|
1333
|
+
// extern granskning, och då är namnet kontrollerat ovan.
|
|
1334
|
+
...Object.fromEntries(REVIEWER_PLACEHOLDERS.map((p) => [p, reviewerName])),
|
|
1187
1335
|
"{<enforcement_body>}": (() => {
|
|
1188
1336
|
if (country === "US") {
|
|
1189
1337
|
const adaLaw = getNationalLaws("US").find((l) => l.euFramework === "ADA" && l.scope === sector && l.inForce !== false);
|
|
@@ -1205,7 +1353,17 @@ async function generateStatementContent(result, lang = "en", format = "html", me
|
|
|
1205
1353
|
"{<braki>}": nonComplianceItems.length > 0 ? nonComplianceItems.map((item) => `* ${item}`).join("\n") : "Brak znanych problem\xF3w.",
|
|
1206
1354
|
"{<issues>}": nonComplianceItems.length > 0 ? nonComplianceItems.map((item) => `* ${item}`).join("\n") : "No known issues."
|
|
1207
1355
|
};
|
|
1208
|
-
const
|
|
1356
|
+
const choiceIndex = (kind, parts) => {
|
|
1357
|
+
if (kind === "method") {
|
|
1358
|
+
if (reviewMethod === "external-review") return 1;
|
|
1359
|
+
if (reviewMethod === "no-review") return parts > 2 ? 2 : 1;
|
|
1360
|
+
return 0;
|
|
1361
|
+
}
|
|
1362
|
+
if (complianceLevel === "partial") return 1;
|
|
1363
|
+
if (complianceLevel === "non-compliant") return parts > 2 ? 2 : 1;
|
|
1364
|
+
return 0;
|
|
1365
|
+
};
|
|
1366
|
+
const processText = (text, kind = "compliance") => {
|
|
1209
1367
|
let processed = text;
|
|
1210
1368
|
processed = processed.replace(/\[([\s\S]*?)\]/g, (_match, content2) => {
|
|
1211
1369
|
if (content2.includes("{<svarstid>}") || content2.includes("{<svartid>}") || content2.includes("{<response time>}")) {
|
|
@@ -1219,27 +1377,28 @@ async function generateStatementContent(result, lang = "en", format = "html", me
|
|
|
1219
1377
|
}
|
|
1220
1378
|
return content2;
|
|
1221
1379
|
});
|
|
1380
|
+
const values = [];
|
|
1222
1381
|
processed = processed.replace(/\{<[^>]+>\}/g, (match) => {
|
|
1223
|
-
|
|
1382
|
+
values.push(substitutions[match] !== void 0 ? substitutions[match] : match);
|
|
1383
|
+
return `\uE000${values.length - 1}\uE000`;
|
|
1224
1384
|
});
|
|
1225
1385
|
processed = processed.replace(/\{([^{}]*?)\}/g, (_match, content2) => {
|
|
1226
1386
|
const parts = content2.split("/");
|
|
1227
1387
|
if (parts.length >= 2) {
|
|
1228
|
-
|
|
1229
|
-
if (complianceLevel === "partial") idx = 1;
|
|
1230
|
-
if (complianceLevel === "non-compliant") idx = parts.length > 2 ? 2 : 1;
|
|
1231
|
-
return parts[idx].trim();
|
|
1388
|
+
return parts[choiceIndex(kind, parts.length)].trim();
|
|
1232
1389
|
}
|
|
1233
1390
|
return _match;
|
|
1234
1391
|
});
|
|
1235
|
-
return processed;
|
|
1392
|
+
return processed.replace(/\uE000(\d+)\uE000/g, (_m, i) => values[Number(i)]);
|
|
1236
1393
|
};
|
|
1237
1394
|
const title = processText(template.title);
|
|
1238
1395
|
const intro = processText(template.intro);
|
|
1239
1396
|
const enforcementBody = String(substitutions["{<enforcement_body>}"] ?? "").trim();
|
|
1240
1397
|
const sections = template.sections.map((s) => {
|
|
1241
1398
|
if (s.id === "enforcement" && enforcementBody === "") return null;
|
|
1242
|
-
|
|
1399
|
+
if (s.sectors && !s.sectors.includes(sector)) return null;
|
|
1400
|
+
const delad = s.id === "enforcement" ? getEnforcementStatementText(country, sector, lang) : null;
|
|
1401
|
+
const body = (delad ?? (s.id === "enforcement" && country === "SE" && lang === "sv" && sector === "public" ? resolveSwedishEnforcementContent(enforcementBody, substitutions["{<national_law>}"] ?? "") : processText(s.content, s.id === "testing" ? "method" : "compliance"))).trim();
|
|
1243
1402
|
if (body === "") return null;
|
|
1244
1403
|
return s.title ? `## ${s.title}
|
|
1245
1404
|
|
|
@@ -1269,6 +1428,8 @@ export {
|
|
|
1269
1428
|
NOSCRIPT_PARTIAL_THRESHOLD,
|
|
1270
1429
|
evaluateNoScriptCoverage,
|
|
1271
1430
|
probeWithoutJavaScript,
|
|
1431
|
+
chromeLaunchArgs,
|
|
1432
|
+
explainLaunchFailure,
|
|
1272
1433
|
wcagTagToCriterion,
|
|
1273
1434
|
criteriaFromTags,
|
|
1274
1435
|
en301549FromTags,
|