@holmdigital/engine 3.3.11 → 3.3.12

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.
@@ -260,7 +260,7 @@ function isInterstitialPage(pageTitle, hasMetaRefresh, bodyTextLength) {
260
260
  return false;
261
261
  }
262
262
  function getEngineVersion() {
263
- return "3.3.11";
263
+ return "3.3.12";
264
264
  }
265
265
  function getStandardsVersion() {
266
266
  try {
package/dist/cli/index.js CHANGED
@@ -1620,7 +1620,7 @@ function isInterstitialPage(pageTitle, hasMetaRefresh, bodyTextLength) {
1620
1620
  return false;
1621
1621
  }
1622
1622
  function getEngineVersion() {
1623
- return "3.3.11";
1623
+ return "3.3.12";
1624
1624
  }
1625
1625
  function getStandardsVersion() {
1626
1626
  try {
@@ -2289,6 +2289,12 @@ function formatDate(dateString) {
2289
2289
  minute: "2-digit"
2290
2290
  });
2291
2291
  }
2292
+ var RISK_BADGE_CLASS = {
2293
+ critical: "badge-critical",
2294
+ high: "badge-high",
2295
+ medium: "badge-medium",
2296
+ low: "badge-low"
2297
+ };
2292
2298
  function escapeHtml(value) {
2293
2299
  return String(value).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
2294
2300
  }
@@ -2382,11 +2388,11 @@ function generateReportHTML(result, sector = "public", audience = "developer", p
2382
2388
  ${needsReviewReports.map((report) => `
2383
2389
  <div class="violation-card">
2384
2390
  <div class="violation-header">
2385
- <div class="violation-title">${report.ruleId}</div>
2391
+ <div class="violation-title">${escapeHtml(report.ruleId)}</div>
2386
2392
  <div><span class="badge">needs review</span></div>
2387
2393
  </div>
2388
2394
  <div class="violation-meta">
2389
- WCAG ${report.wcagCriteria} \u2022 EN 301 549 ${report.en301549Criteria}
2395
+ WCAG ${escapeHtml(report.wcagCriteria)} \u2022 EN 301 549 ${escapeHtml(report.en301549Criteria)}
2390
2396
  </div>
2391
2397
  <div style="font-size: 0.95rem; color: #334155; line-height: 1.5;">
2392
2398
  ${escapeHtml(report.holmdigitalInsight.reasoning)}
@@ -2630,30 +2636,30 @@ function generateReportHTML(result, sector = "public", audience = "developer", p
2630
2636
  const bRisk = b.holmdigitalInsight.diggRisk.toLowerCase();
2631
2637
  return (severityOrder[aRisk] ?? 4) - (severityOrder[bRisk] ?? 4);
2632
2638
  }).map((report) => {
2633
- const riskClass = `badge-${report.holmdigitalInsight.diggRisk}`;
2639
+ const riskClass = RISK_BADGE_CLASS[report.holmdigitalInsight.diggRisk?.toLowerCase() ?? ""] ?? "";
2634
2640
  return `
2635
2641
  <div class="violation-card">
2636
2642
  <div class="violation-header">
2637
- <div class="violation-title">${report.ruleId}</div>
2643
+ <div class="violation-title">${escapeHtml(report.ruleId)}</div>
2638
2644
  <div>
2639
- <span class="badge ${riskClass}">${report.holmdigitalInsight.diggRisk}</span>
2645
+ <span class="badge ${riskClass}">${escapeHtml(report.holmdigitalInsight.diggRisk)}</span>
2640
2646
  ${sector === "public" && report.legalContext?.appliesTo?.includes("WAD") ? '<span class="badge badge-wad">WAD</span>' : ""}
2641
2647
  ${sector === "private" && report.legalContext?.appliesTo?.includes("EAA") ? '<span class="badge badge-eaa">EAA</span>' : ""}
2642
2648
  </div>
2643
2649
  </div>
2644
2650
  <div class="violation-meta">
2645
- WCAG ${report.wcagCriteria} \u2022 EN 301 549 ${report.en301549Criteria}
2646
- ${report.dosLagenReference ? `\u2022 ${report.dosLagenReference}` : ""}
2647
- ${report.legalContext?.eaaDeadline ? `<br/><strong>\u26A0\uFE0F EAA Deadline:</strong> ${report.legalContext.eaaDeadline}` : ""}
2651
+ WCAG ${escapeHtml(report.wcagCriteria)} \u2022 EN 301 549 ${escapeHtml(report.en301549Criteria)}
2652
+ ${report.dosLagenReference ? `\u2022 ${escapeHtml(report.dosLagenReference)}` : ""}
2653
+ ${report.legalContext?.eaaDeadline ? `<br/><strong>\u26A0\uFE0F EAA Deadline:</strong> ${escapeHtml(report.legalContext.eaaDeadline)}` : ""}
2648
2654
  </div>
2649
2655
  <div style="font-size: 0.95rem; color: #334155; line-height: 1.5;">
2650
2656
  ${escapeHtml(report.holmdigitalInsight.swedishInterpretation)}
2651
- ${report.holmdigitalInsight.priorityRationale ? `<br/><br/><strong>Priority Rationale:</strong> ${report.holmdigitalInsight.priorityRationale}` : ""}
2657
+ ${report.holmdigitalInsight.priorityRationale ? `<br/><br/><strong>Priority Rationale:</strong> ${escapeHtml(report.holmdigitalInsight.priorityRationale)}` : ""}
2652
2658
  </div>
2653
2659
  ${report.remediation.component ? `
2654
2660
  <div class="remediation-box">
2655
2661
  <div class="remediation-title">${t("report.prescriptive_fix")}</div>
2656
- <div class="remediation-text">${t("report.use")} <strong>${report.remediation.component}</strong>: ${escapeHtml(report.remediation.description)}</div>
2662
+ <div class="remediation-text">${t("report.use")} <strong>${escapeHtml(report.remediation.component)}</strong>: ${escapeHtml(report.remediation.description)}</div>
2657
2663
  </div>
2658
2664
  ` : ""}
2659
2665
  </div>
@@ -3509,6 +3515,28 @@ function parseHydrationWait(raw) {
3509
3515
  return ms;
3510
3516
  }
3511
3517
 
3518
+ // src/cli/url-guard.ts
3519
+ init_cjs_shims();
3520
+ var ALLOWED_SCAN_PROTOCOLS = ["http:", "https:"];
3521
+ var UnsupportedUrlError = class extends Error {
3522
+ };
3523
+ function assertScanUrl(raw) {
3524
+ let parsed;
3525
+ try {
3526
+ parsed = new URL(String(raw).trim());
3527
+ } catch {
3528
+ throw new UnsupportedUrlError(
3529
+ `Invalid URL '${raw}'. Expected an absolute address such as https://example.com.`
3530
+ );
3531
+ }
3532
+ if (!ALLOWED_SCAN_PROTOCOLS.includes(parsed.protocol)) {
3533
+ throw new UnsupportedUrlError(
3534
+ `Unsupported protocol '${parsed.protocol}' in '${raw}'. Only http:// and https:// can be scanned. A local file is not a website: serve it over http and scan that address instead.`
3535
+ );
3536
+ }
3537
+ return parsed;
3538
+ }
3539
+
3512
3540
  // src/cli/index.ts
3513
3541
  init_i18n();
3514
3542
  init_plain_language_support();
@@ -3632,14 +3660,6 @@ function renderNoScriptAdvisory(noScript) {
3632
3660
  }
3633
3661
  console.log(import_chalk2.default.gray(` ${t("cli.noscript_advisory")}`));
3634
3662
  }
3635
- function isValidUrl(urlString) {
3636
- try {
3637
- const url = new URL(urlString);
3638
- return url.protocol === "http:" || url.protocol === "https:";
3639
- } catch {
3640
- return false;
3641
- }
3642
- }
3643
3663
  var program = new import_commander.Command();
3644
3664
  program.name("hd-a11y-scan").description("HolmDigital Regulatory Scanner").version(getEngineVersion());
3645
3665
  program.argument("<url>", "URL to scan").option("--lang <code>", "Language code (en, sv)").option("--ci", "Run in CI/CD mode (exit code 1 on critical failures)").option("--generate-tests", "Generate Pseudo-Automation tests").option("--json", "Output as JSON").option("--junit <path>", "Generate JUnit XML report").option("--pdf <path>", "Generate PDF report to path").option("--statement <path>", "Generate accessibility statement HTML to path").option("--format <type>", "Output format for statement (html, md)", "html").option("--viewport <size>", 'Set viewport (e.g. "mobile", "desktop", "1024x768")').option("--threshold <level>", "Severity threshold (critical, high, medium, low)").option("--api-key <key>", "API key for HolmDigital Cloud").option("--cloud-url <url>", "Cloud API URL").option("--invalid-https-cert", "Allow scanning on pages with invalid https certificate").option("--email <email>", "Contact email for accessibility statement").option("--phone <number>", "Contact phone number for accessibility statement").option("--org <name>", "Organization name for accessibility statement").option("--response-time <time>", "Expected response time for accessibility statement").option("--country <code>", "Country code for accessibility statement enforcement body").option("--sector <type>", "Sector type: public (WAD) or private (EAA)", "public").option("--publish-date <date>", "Publish date for the website (YYYY-MM-DD)").option("--light", "Light scan: fast score-only mode (skips HTML validation and detailed legal mapping)").option("--audience <mode>", "Output audience: developer (default) or plain", "developer").option("--plain", "Alias for --audience plain (klarspr\xE5ksl\xE4ge for non-technical recipients)").option("--noscript-check", "Robustness probe: measure how much content is available without JavaScript. Advisory only, never affects the compliance score.").option("--wait-for-hydration <ms>", `Milliseconds to wait after network idle so client-rendered SPAs finish hydrating before axe runs (default 2500, 0 disables, max ${MAX_HYDRATION_WAIT_MS})`).action(async (url, cliOptions) => {
@@ -3692,7 +3712,14 @@ program.argument("<url>", "URL to scan").option("--lang <code>", "Language code
3692
3712
  plainFallbackFrom = options.lang;
3693
3713
  setLanguage("en");
3694
3714
  }
3695
- if (!isValidUrl(url)) {
3715
+ try {
3716
+ assertScanUrl(url);
3717
+ } catch (e) {
3718
+ if (e instanceof UnsupportedUrlError) {
3719
+ console.error(import_chalk2.default.red(`Error: ${e.message}`));
3720
+ process.exit(1);
3721
+ }
3722
+ throw e;
3696
3723
  }
3697
3724
  if (!options.json) {
3698
3725
  console.log(import_chalk2.default.blue.bold(t("cli.title")));
@@ -8,7 +8,7 @@ import {
8
8
  generateStatementContent,
9
9
  getEngineVersion,
10
10
  isBadgeWithheldByRobustness
11
- } from "../chunk-EWVIRZYF.mjs";
11
+ } from "../chunk-VBRRLFUH.mjs";
12
12
  import {
13
13
  groupReportsByRule,
14
14
  impactBreakdown,
@@ -63,6 +63,12 @@ function formatDate(dateString) {
63
63
  minute: "2-digit"
64
64
  });
65
65
  }
66
+ var RISK_BADGE_CLASS = {
67
+ critical: "badge-critical",
68
+ high: "badge-high",
69
+ medium: "badge-medium",
70
+ low: "badge-low"
71
+ };
66
72
  function escapeHtml(value) {
67
73
  return String(value).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
68
74
  }
@@ -156,11 +162,11 @@ function generateReportHTML(result, sector = "public", audience = "developer", p
156
162
  ${needsReviewReports.map((report) => `
157
163
  <div class="violation-card">
158
164
  <div class="violation-header">
159
- <div class="violation-title">${report.ruleId}</div>
165
+ <div class="violation-title">${escapeHtml(report.ruleId)}</div>
160
166
  <div><span class="badge">needs review</span></div>
161
167
  </div>
162
168
  <div class="violation-meta">
163
- WCAG ${report.wcagCriteria} \u2022 EN 301 549 ${report.en301549Criteria}
169
+ WCAG ${escapeHtml(report.wcagCriteria)} \u2022 EN 301 549 ${escapeHtml(report.en301549Criteria)}
164
170
  </div>
165
171
  <div style="font-size: 0.95rem; color: #334155; line-height: 1.5;">
166
172
  ${escapeHtml(report.holmdigitalInsight.reasoning)}
@@ -404,30 +410,30 @@ function generateReportHTML(result, sector = "public", audience = "developer", p
404
410
  const bRisk = b.holmdigitalInsight.diggRisk.toLowerCase();
405
411
  return (severityOrder[aRisk] ?? 4) - (severityOrder[bRisk] ?? 4);
406
412
  }).map((report) => {
407
- const riskClass = `badge-${report.holmdigitalInsight.diggRisk}`;
413
+ const riskClass = RISK_BADGE_CLASS[report.holmdigitalInsight.diggRisk?.toLowerCase() ?? ""] ?? "";
408
414
  return `
409
415
  <div class="violation-card">
410
416
  <div class="violation-header">
411
- <div class="violation-title">${report.ruleId}</div>
417
+ <div class="violation-title">${escapeHtml(report.ruleId)}</div>
412
418
  <div>
413
- <span class="badge ${riskClass}">${report.holmdigitalInsight.diggRisk}</span>
419
+ <span class="badge ${riskClass}">${escapeHtml(report.holmdigitalInsight.diggRisk)}</span>
414
420
  ${sector === "public" && report.legalContext?.appliesTo?.includes("WAD") ? '<span class="badge badge-wad">WAD</span>' : ""}
415
421
  ${sector === "private" && report.legalContext?.appliesTo?.includes("EAA") ? '<span class="badge badge-eaa">EAA</span>' : ""}
416
422
  </div>
417
423
  </div>
418
424
  <div class="violation-meta">
419
- WCAG ${report.wcagCriteria} \u2022 EN 301 549 ${report.en301549Criteria}
420
- ${report.dosLagenReference ? `\u2022 ${report.dosLagenReference}` : ""}
421
- ${report.legalContext?.eaaDeadline ? `<br/><strong>\u26A0\uFE0F EAA Deadline:</strong> ${report.legalContext.eaaDeadline}` : ""}
425
+ WCAG ${escapeHtml(report.wcagCriteria)} \u2022 EN 301 549 ${escapeHtml(report.en301549Criteria)}
426
+ ${report.dosLagenReference ? `\u2022 ${escapeHtml(report.dosLagenReference)}` : ""}
427
+ ${report.legalContext?.eaaDeadline ? `<br/><strong>\u26A0\uFE0F EAA Deadline:</strong> ${escapeHtml(report.legalContext.eaaDeadline)}` : ""}
422
428
  </div>
423
429
  <div style="font-size: 0.95rem; color: #334155; line-height: 1.5;">
424
430
  ${escapeHtml(report.holmdigitalInsight.swedishInterpretation)}
425
- ${report.holmdigitalInsight.priorityRationale ? `<br/><br/><strong>Priority Rationale:</strong> ${report.holmdigitalInsight.priorityRationale}` : ""}
431
+ ${report.holmdigitalInsight.priorityRationale ? `<br/><br/><strong>Priority Rationale:</strong> ${escapeHtml(report.holmdigitalInsight.priorityRationale)}` : ""}
426
432
  </div>
427
433
  ${report.remediation.component ? `
428
434
  <div class="remediation-box">
429
435
  <div class="remediation-title">${t("report.prescriptive_fix")}</div>
430
- <div class="remediation-text">${t("report.use")} <strong>${report.remediation.component}</strong>: ${escapeHtml(report.remediation.description)}</div>
436
+ <div class="remediation-text">${t("report.use")} <strong>${escapeHtml(report.remediation.component)}</strong>: ${escapeHtml(report.remediation.description)}</div>
431
437
  </div>
432
438
  ` : ""}
433
439
  </div>
@@ -906,6 +912,27 @@ function parseHydrationWait(raw) {
906
912
  return ms;
907
913
  }
908
914
 
915
+ // src/cli/url-guard.ts
916
+ var ALLOWED_SCAN_PROTOCOLS = ["http:", "https:"];
917
+ var UnsupportedUrlError = class extends Error {
918
+ };
919
+ function assertScanUrl(raw) {
920
+ let parsed;
921
+ try {
922
+ parsed = new URL(String(raw).trim());
923
+ } catch {
924
+ throw new UnsupportedUrlError(
925
+ `Invalid URL '${raw}'. Expected an absolute address such as https://example.com.`
926
+ );
927
+ }
928
+ if (!ALLOWED_SCAN_PROTOCOLS.includes(parsed.protocol)) {
929
+ throw new UnsupportedUrlError(
930
+ `Unsupported protocol '${parsed.protocol}' in '${raw}'. Only http:// and https:// can be scanned. A local file is not a website: serve it over http and scan that address instead.`
931
+ );
932
+ }
933
+ return parsed;
934
+ }
935
+
909
936
  // src/cli/cloud-client.ts
910
937
  function transformToCloudPayload(result) {
911
938
  const toCloudViolation = (report) => {
@@ -1021,14 +1048,6 @@ function renderNoScriptAdvisory(noScript) {
1021
1048
  }
1022
1049
  console.log(chalk.gray(` ${t("cli.noscript_advisory")}`));
1023
1050
  }
1024
- function isValidUrl(urlString) {
1025
- try {
1026
- const url = new URL(urlString);
1027
- return url.protocol === "http:" || url.protocol === "https:";
1028
- } catch {
1029
- return false;
1030
- }
1031
- }
1032
1051
  var program = new Command();
1033
1052
  program.name("hd-a11y-scan").description("HolmDigital Regulatory Scanner").version(getEngineVersion());
1034
1053
  program.argument("<url>", "URL to scan").option("--lang <code>", "Language code (en, sv)").option("--ci", "Run in CI/CD mode (exit code 1 on critical failures)").option("--generate-tests", "Generate Pseudo-Automation tests").option("--json", "Output as JSON").option("--junit <path>", "Generate JUnit XML report").option("--pdf <path>", "Generate PDF report to path").option("--statement <path>", "Generate accessibility statement HTML to path").option("--format <type>", "Output format for statement (html, md)", "html").option("--viewport <size>", 'Set viewport (e.g. "mobile", "desktop", "1024x768")').option("--threshold <level>", "Severity threshold (critical, high, medium, low)").option("--api-key <key>", "API key for HolmDigital Cloud").option("--cloud-url <url>", "Cloud API URL").option("--invalid-https-cert", "Allow scanning on pages with invalid https certificate").option("--email <email>", "Contact email for accessibility statement").option("--phone <number>", "Contact phone number for accessibility statement").option("--org <name>", "Organization name for accessibility statement").option("--response-time <time>", "Expected response time for accessibility statement").option("--country <code>", "Country code for accessibility statement enforcement body").option("--sector <type>", "Sector type: public (WAD) or private (EAA)", "public").option("--publish-date <date>", "Publish date for the website (YYYY-MM-DD)").option("--light", "Light scan: fast score-only mode (skips HTML validation and detailed legal mapping)").option("--audience <mode>", "Output audience: developer (default) or plain", "developer").option("--plain", "Alias for --audience plain (klarspr\xE5ksl\xE4ge for non-technical recipients)").option("--noscript-check", "Robustness probe: measure how much content is available without JavaScript. Advisory only, never affects the compliance score.").option("--wait-for-hydration <ms>", `Milliseconds to wait after network idle so client-rendered SPAs finish hydrating before axe runs (default 2500, 0 disables, max ${MAX_HYDRATION_WAIT_MS})`).action(async (url, cliOptions) => {
@@ -1081,7 +1100,14 @@ program.argument("<url>", "URL to scan").option("--lang <code>", "Language code
1081
1100
  plainFallbackFrom = options.lang;
1082
1101
  setLanguage("en");
1083
1102
  }
1084
- if (!isValidUrl(url)) {
1103
+ try {
1104
+ assertScanUrl(url);
1105
+ } catch (e) {
1106
+ if (e instanceof UnsupportedUrlError) {
1107
+ console.error(chalk.red(`Error: ${e.message}`));
1108
+ process.exit(1);
1109
+ }
1110
+ throw e;
1085
1111
  }
1086
1112
  if (!options.json) {
1087
1113
  console.log(chalk.blue.bold(t("cli.title")));
package/dist/index.js CHANGED
@@ -1228,7 +1228,7 @@ function isInterstitialPage(pageTitle, hasMetaRefresh, bodyTextLength) {
1228
1228
  return false;
1229
1229
  }
1230
1230
  function getEngineVersion() {
1231
- return "3.3.11";
1231
+ return "3.3.12";
1232
1232
  }
1233
1233
  function getStandardsVersion() {
1234
1234
  try {
package/dist/index.mjs CHANGED
@@ -17,7 +17,7 @@ import {
17
17
  resolveNationalLawReference,
18
18
  selectMappedRuleId,
19
19
  wcagTagToCriterion
20
- } from "./chunk-EWVIRZYF.mjs";
20
+ } from "./chunk-VBRRLFUH.mjs";
21
21
  import {
22
22
  getCurrentLang,
23
23
  setLanguage,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@holmdigital/engine",
3
- "version": "3.3.11",
3
+ "version": "3.3.12",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -86,7 +86,7 @@
86
86
  },
87
87
  "dependencies": {
88
88
  "@holmdigital/components": "^4.0.2",
89
- "@holmdigital/standards": "^4.1.1",
89
+ "@holmdigital/standards": "^4.2.1",
90
90
  "axe-core": "^4.13.0",
91
91
  "chalk": "^6.0.0",
92
92
  "commander": "^15.0.0",