eaa-kit 0.6.0 → 0.9.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.
Files changed (97) hide show
  1. package/README.md +52 -15
  2. package/dist/astro/index.d.ts +1 -1
  3. package/dist/astro/index.js +1 -1
  4. package/dist/audit/runners/worker.js +1 -1
  5. package/dist/audit-CJDCQaFY.js +2 -0
  6. package/dist/{audit-e_uixhPG.js → audit-J2jeLo-y.js} +170 -241
  7. package/dist/{baseline-BscHfFSW.js → baseline-477B1CZ_.js} +1 -1
  8. package/dist/baseline-D9ihb-wk.js +2 -0
  9. package/dist/{baseline-D2qWmUC6.js → baseline-DrFh7joZ.js} +15 -4
  10. package/dist/baseline-wyJsSIFQ.js +127 -0
  11. package/dist/cache-D4dOIuOi.js +219 -0
  12. package/dist/{checklist-BtgkxMEa.js → checklist-Gx2g3LFC.js} +6 -6
  13. package/dist/cli/index.js +103 -147
  14. package/dist/{collect-Cu1q9NTB.js → collect-BJYk7_pJ.js} +1 -1
  15. package/dist/{command-CZKp9Wi_.js → command-BGGMf4vn.js} +35 -8
  16. package/dist/countries-DRTBubeE.js +25 -0
  17. package/dist/countries-Dg0BdytB.js +156 -0
  18. package/dist/coverage-GvaMpV64.js +3 -0
  19. package/dist/{coverage-BD2_CYns.js → coverage-zdzgSKjz.js} +4 -286
  20. package/dist/{crawl-BHkJmUkA.js → crawl-DwdqiljK.js} +5 -3
  21. package/dist/criteria-CnPJKGeb.js +286 -0
  22. package/dist/{load-vZdV_fD1.js → define-Ctf2uOEh.js} +47 -95
  23. package/dist/eleventy/index.d.ts +1 -1
  24. package/dist/eleventy/index.js +1 -1
  25. package/dist/entry-CjqjrUBY.js +174 -0
  26. package/dist/{html-Bmh7X_sM.js → html-whingnfj.js} +9 -5
  27. package/dist/index.d.ts +61 -5
  28. package/dist/index.js +3 -2
  29. package/dist/init-CPbFVMuk.js +293 -0
  30. package/dist/jsdom-BUYuVJJm.js +3 -0
  31. package/dist/{jsdom-CQar6OQS.js → jsdom-CsW_xVcA.js} +11 -12
  32. package/dist/{json-HJDgJp09.js → json-CyLmvF5P.js} +1 -1
  33. package/dist/{json-PNg6BeXp.js → json-SGCgxSPT.js} +4 -3
  34. package/dist/load-CH-ltdlq.js +99 -0
  35. package/dist/load-D7lBeOsq.js +2 -0
  36. package/dist/nuxt/index.d.ts +1 -1
  37. package/dist/nuxt/index.js +1 -1
  38. package/dist/pages-DxY5Z0gl.js +300 -0
  39. package/dist/{playwright-C-miJP2b.js → playwright-ukCr_5o3.js} +1 -1
  40. package/dist/{pool-dkexq5xo.js → pool-B4tEUa2S.js} +6 -2
  41. package/dist/{project-MFrXcw1M.js → project-BLFdCbOq.js} +1 -1
  42. package/dist/{project-CzOnkLH6.js → project-v2PoRw70.js} +18 -1
  43. package/dist/{completeness-Dwq3CPB3.js → remediation-Bbs4KcX1.js} +72 -42
  44. package/dist/{render-CtsqR0k-.js → render-C6zYfaba.js} +69 -7
  45. package/dist/{result-DfUru6y_.js → result-B7_zVxAX.js} +1 -1
  46. package/dist/result-CRmjjoAA.js +2 -0
  47. package/dist/{review-CdMK2GpQ.js → review-Bz0fO9_I.js} +9 -1
  48. package/dist/{review-DIbOTmOM.js → review-a-2ghjQ5.js} +1 -1
  49. package/dist/{routes-CmdRUuOs.js → routes-CSctpS1P.js} +1 -1
  50. package/dist/{run-YiqyQA2b.d.ts → run-BK2blxMI.d.ts} +8 -0
  51. package/dist/{run-D7hdVXLA.js → run-DzVEOkiF.js} +6 -2
  52. package/dist/{sarif-BKvq_AUm.js → sarif-9BAgNiOa.js} +5 -3
  53. package/dist/site-BHMtf3q2.js +72 -0
  54. package/dist/start-DzOM0p6I.js +101 -0
  55. package/dist/statement/templates/at.de.md +14 -0
  56. package/dist/statement/templates/at.en.md +14 -0
  57. package/dist/statement/templates/be.de.md +148 -0
  58. package/dist/statement/templates/be.en.md +142 -0
  59. package/dist/statement/templates/be.fr.md +146 -0
  60. package/dist/statement/templates/be.nl.md +147 -0
  61. package/dist/statement/templates/ch.de.md +14 -0
  62. package/dist/statement/templates/ch.en.md +14 -0
  63. package/dist/statement/templates/cz.cs.md +137 -0
  64. package/dist/statement/templates/cz.en.md +139 -0
  65. package/dist/statement/templates/de.de.md +14 -0
  66. package/dist/statement/templates/de.en.md +14 -0
  67. package/dist/statement/templates/dk.da.md +141 -0
  68. package/dist/statement/templates/dk.en.md +141 -0
  69. package/dist/statement/templates/es.en.md +14 -0
  70. package/dist/statement/templates/es.es.md +15 -0
  71. package/dist/statement/templates/fi.en.md +139 -0
  72. package/dist/statement/templates/fi.fi.md +141 -0
  73. package/dist/statement/templates/fr.en.md +14 -0
  74. package/dist/statement/templates/fr.fr.md +15 -0
  75. package/dist/statement/templates/ie.en.md +144 -0
  76. package/dist/statement/templates/it.en.md +14 -0
  77. package/dist/statement/templates/it.it.md +15 -0
  78. package/dist/statement/templates/nl.en.md +14 -0
  79. package/dist/statement/templates/nl.nl.md +15 -0
  80. package/dist/statement/templates/pl.en.md +143 -0
  81. package/dist/statement/templates/pl.pl.md +144 -0
  82. package/dist/statement/templates/pt.en.md +142 -0
  83. package/dist/statement/templates/pt.pt.md +145 -0
  84. package/dist/statement/templates/se.en.md +139 -0
  85. package/dist/statement/templates/se.sv.md +142 -0
  86. package/dist/vite/index.d.ts +1 -1
  87. package/dist/vite/index.js +1 -1
  88. package/dist/watch-B2RoUbo0.js +122 -0
  89. package/dist/webpack/index.d.ts +1 -1
  90. package/dist/webpack/index.js +1 -1
  91. package/dist/{worksheet-eUjwYLxC.js → worksheet-B_kQ1pxq.js} +3 -2
  92. package/package.json +4 -3
  93. package/dist/audit-DK2StT1_.js +0 -2
  94. package/dist/coverage-7bQqWNfN.js +0 -2
  95. package/dist/init-BjKYttxc.js +0 -119
  96. package/dist/jsdom-DMvU2h-f.js +0 -3
  97. package/dist/load-Bc_xDGAh.js +0 -2
@@ -0,0 +1,286 @@
1
+ //#region src/audit/criteria.ts
2
+ /**
3
+ * WCAG 2.2 at Levels A and AA, which is what this tool audits against.
4
+ *
5
+ * 4.1.1 Parsing is deliberately absent: it was removed in WCAG 2.2 and counting
6
+ * it would inflate the denominator with a criterion nobody has to meet.
7
+ */
8
+ const WCAG22_AA_CRITERIA = [
9
+ {
10
+ number: "1.1.1",
11
+ title: "Non-text Content",
12
+ level: "A"
13
+ },
14
+ {
15
+ number: "1.2.1",
16
+ title: "Audio-only and Video-only (Prerecorded)",
17
+ level: "A"
18
+ },
19
+ {
20
+ number: "1.2.2",
21
+ title: "Captions (Prerecorded)",
22
+ level: "A"
23
+ },
24
+ {
25
+ number: "1.2.3",
26
+ title: "Audio Description or Media Alternative (Prerecorded)",
27
+ level: "A"
28
+ },
29
+ {
30
+ number: "1.2.4",
31
+ title: "Captions (Live)",
32
+ level: "AA"
33
+ },
34
+ {
35
+ number: "1.2.5",
36
+ title: "Audio Description (Prerecorded)",
37
+ level: "AA"
38
+ },
39
+ {
40
+ number: "1.3.1",
41
+ title: "Info and Relationships",
42
+ level: "A"
43
+ },
44
+ {
45
+ number: "1.3.2",
46
+ title: "Meaningful Sequence",
47
+ level: "A"
48
+ },
49
+ {
50
+ number: "1.3.3",
51
+ title: "Sensory Characteristics",
52
+ level: "A"
53
+ },
54
+ {
55
+ number: "1.3.4",
56
+ title: "Orientation",
57
+ level: "AA"
58
+ },
59
+ {
60
+ number: "1.3.5",
61
+ title: "Identify Input Purpose",
62
+ level: "AA"
63
+ },
64
+ {
65
+ number: "1.4.1",
66
+ title: "Use of Color",
67
+ level: "A"
68
+ },
69
+ {
70
+ number: "1.4.2",
71
+ title: "Audio Control",
72
+ level: "A"
73
+ },
74
+ {
75
+ number: "1.4.3",
76
+ title: "Contrast (Minimum)",
77
+ level: "AA"
78
+ },
79
+ {
80
+ number: "1.4.4",
81
+ title: "Resize Text",
82
+ level: "AA"
83
+ },
84
+ {
85
+ number: "1.4.5",
86
+ title: "Images of Text",
87
+ level: "AA"
88
+ },
89
+ {
90
+ number: "1.4.10",
91
+ title: "Reflow",
92
+ level: "AA"
93
+ },
94
+ {
95
+ number: "1.4.11",
96
+ title: "Non-text Contrast",
97
+ level: "AA"
98
+ },
99
+ {
100
+ number: "1.4.12",
101
+ title: "Text Spacing",
102
+ level: "AA"
103
+ },
104
+ {
105
+ number: "1.4.13",
106
+ title: "Content on Hover or Focus",
107
+ level: "AA"
108
+ },
109
+ {
110
+ number: "2.1.1",
111
+ title: "Keyboard",
112
+ level: "A"
113
+ },
114
+ {
115
+ number: "2.1.2",
116
+ title: "No Keyboard Trap",
117
+ level: "A"
118
+ },
119
+ {
120
+ number: "2.1.4",
121
+ title: "Character Key Shortcuts",
122
+ level: "A"
123
+ },
124
+ {
125
+ number: "2.2.1",
126
+ title: "Timing Adjustable",
127
+ level: "A"
128
+ },
129
+ {
130
+ number: "2.2.2",
131
+ title: "Pause, Stop, Hide",
132
+ level: "A"
133
+ },
134
+ {
135
+ number: "2.3.1",
136
+ title: "Three Flashes or Below Threshold",
137
+ level: "A"
138
+ },
139
+ {
140
+ number: "2.4.1",
141
+ title: "Bypass Blocks",
142
+ level: "A"
143
+ },
144
+ {
145
+ number: "2.4.2",
146
+ title: "Page Titled",
147
+ level: "A"
148
+ },
149
+ {
150
+ number: "2.4.3",
151
+ title: "Focus Order",
152
+ level: "A"
153
+ },
154
+ {
155
+ number: "2.4.4",
156
+ title: "Link Purpose (In Context)",
157
+ level: "A"
158
+ },
159
+ {
160
+ number: "2.4.5",
161
+ title: "Multiple Ways",
162
+ level: "AA"
163
+ },
164
+ {
165
+ number: "2.4.6",
166
+ title: "Headings and Labels",
167
+ level: "AA"
168
+ },
169
+ {
170
+ number: "2.4.7",
171
+ title: "Focus Visible",
172
+ level: "AA"
173
+ },
174
+ {
175
+ number: "2.4.11",
176
+ title: "Focus Not Obscured (Minimum)",
177
+ level: "AA"
178
+ },
179
+ {
180
+ number: "2.5.1",
181
+ title: "Pointer Gestures",
182
+ level: "A"
183
+ },
184
+ {
185
+ number: "2.5.2",
186
+ title: "Pointer Cancellation",
187
+ level: "A"
188
+ },
189
+ {
190
+ number: "2.5.3",
191
+ title: "Label in Name",
192
+ level: "A"
193
+ },
194
+ {
195
+ number: "2.5.4",
196
+ title: "Motion Actuation",
197
+ level: "A"
198
+ },
199
+ {
200
+ number: "2.5.7",
201
+ title: "Dragging Movements",
202
+ level: "AA"
203
+ },
204
+ {
205
+ number: "2.5.8",
206
+ title: "Target Size (Minimum)",
207
+ level: "AA"
208
+ },
209
+ {
210
+ number: "3.1.1",
211
+ title: "Language of Page",
212
+ level: "A"
213
+ },
214
+ {
215
+ number: "3.1.2",
216
+ title: "Language of Parts",
217
+ level: "AA"
218
+ },
219
+ {
220
+ number: "3.2.1",
221
+ title: "On Focus",
222
+ level: "A"
223
+ },
224
+ {
225
+ number: "3.2.2",
226
+ title: "On Input",
227
+ level: "A"
228
+ },
229
+ {
230
+ number: "3.2.3",
231
+ title: "Consistent Navigation",
232
+ level: "AA"
233
+ },
234
+ {
235
+ number: "3.2.4",
236
+ title: "Consistent Identification",
237
+ level: "AA"
238
+ },
239
+ {
240
+ number: "3.2.6",
241
+ title: "Consistent Help",
242
+ level: "A"
243
+ },
244
+ {
245
+ number: "3.3.1",
246
+ title: "Error Identification",
247
+ level: "A"
248
+ },
249
+ {
250
+ number: "3.3.2",
251
+ title: "Labels or Instructions",
252
+ level: "A"
253
+ },
254
+ {
255
+ number: "3.3.3",
256
+ title: "Error Suggestion",
257
+ level: "AA"
258
+ },
259
+ {
260
+ number: "3.3.4",
261
+ title: "Error Prevention (Legal, Financial, Data)",
262
+ level: "AA"
263
+ },
264
+ {
265
+ number: "3.3.7",
266
+ title: "Redundant Entry",
267
+ level: "A"
268
+ },
269
+ {
270
+ number: "3.3.8",
271
+ title: "Accessible Authentication (Minimum)",
272
+ level: "AA"
273
+ },
274
+ {
275
+ number: "4.1.2",
276
+ title: "Name, Role, Value",
277
+ level: "A"
278
+ },
279
+ {
280
+ number: "4.1.3",
281
+ title: "Status Messages",
282
+ level: "AA"
283
+ }
284
+ ];
285
+ //#endregion
286
+ export { WCAG22_AA_CRITERIA as t };
@@ -1,19 +1,26 @@
1
1
  import { n as IMPACT_LEVELS } from "./impact-luGCnN8F.js";
2
2
  import { _ as union, a as integer, d as optional, f as pipe, g as transform, h as string, i as enumeration, m as safeParse, n as boolean, o as isoDate, r as email, t as array, u as object, v as url, y as withDefault } from "./schema-DJSF4K05.js";
3
- import { r as isFile } from "./fs-BmPtmFke.js";
4
- import { readFile } from "node:fs/promises";
5
- import path from "node:path";
6
- import { pathToFileURL } from "node:url";
7
3
  //#region src/config/define.ts
8
- /** Countries with their own supervisory body and statute text. */
4
+ /**
5
+ * Countries with their own supervisory body and statute text. What is known
6
+ * about each one is in `countries.ts`.
7
+ */
9
8
  const COUNTRIES = [
10
9
  "AT",
11
- "DE",
10
+ "BE",
12
11
  "CH",
12
+ "CZ",
13
+ "DE",
14
+ "DK",
13
15
  "ES",
16
+ "FI",
14
17
  "FR",
18
+ "IE",
15
19
  "IT",
16
- "NL"
20
+ "NL",
21
+ "PL",
22
+ "PT",
23
+ "SE"
17
24
  ];
18
25
  /**
19
26
  * Languages a statement can be rendered in.
@@ -24,12 +31,18 @@ const COUNTRIES = [
24
31
  * ones a country has when asked for one it does not.
25
32
  */
26
33
  const STATEMENT_LOCALES = [
34
+ "cs",
35
+ "da",
27
36
  "de",
28
37
  "en",
29
38
  "es",
39
+ "fi",
30
40
  "fr",
31
41
  "it",
32
- "nl"
42
+ "nl",
43
+ "pl",
44
+ "pt",
45
+ "sv"
33
46
  ];
34
47
  /**
35
48
  * Wording follows the EU model statement: fully, partially, or not conformant
@@ -70,6 +83,20 @@ const knownIssueObject = object({
70
83
  */
71
84
  const knownIssueSchema = union([pipe(transform(string({ min: 1 }), (description) => ({ description })), knownIssueObject), knownIssueObject], "expected a description, or an object with one");
72
85
  /**
86
+ * What a crawl does when its entry URL redirects to another site.
87
+ *
88
+ * `ask` puts the question to whoever is at the terminal and, with nobody there,
89
+ * stops. `follow` goes on to the new address, and every report says so. `stop`
90
+ * never goes on, not even to the same site at another address. A redirect
91
+ * within the same host, give or take `www.` and http or https, is followed
92
+ * under `ask` and `follow` without a question, and is still reported.
93
+ */
94
+ const REDIRECT_MODES = [
95
+ "ask",
96
+ "follow",
97
+ "stop"
98
+ ];
99
+ /**
73
100
  * Defaults for `eaa-kit audit` and `eaa-kit baseline`, so a project says once
74
101
  * what every invocation would otherwise repeat.
75
102
  *
@@ -96,6 +123,8 @@ const auditSchema = object({
96
123
  ignoreRobots: optional(boolean()),
97
124
  /** Where the site lists its pages, when that is not /sitemap.xml. */
98
125
  sitemap: optional(string({ min: 1 })),
126
+ /** What to do when the entry URL redirects to another site. */
127
+ redirects: optional(enumeration(REDIRECT_MODES)),
99
128
  maxPages: optional(integer({ min: 1 })),
100
129
  /** 0 audits the entry page alone. */
101
130
  maxDepth: optional(integer({ min: 0 })),
@@ -131,7 +160,12 @@ const auditSchema = object({
131
160
  * find something to audit. Written in the positive because that is the state
132
161
  * being described, and because a config file has no flags to negate.
133
162
  */
134
- build: optional(boolean())
163
+ build: optional(boolean()),
164
+ /**
165
+ * False is `--no-cache`: audit every page, reusing nothing an earlier run
166
+ * measured. Written in the positive for the same reason `build` is.
167
+ */
168
+ cache: optional(boolean())
135
169
  });
136
170
  const configSchema = object({
137
171
  site: object({
@@ -198,10 +232,12 @@ function defineConfig(config) {
198
232
  }
199
233
  var ConfigError = class extends Error {
200
234
  issues;
235
+ next;
201
236
  name = "ConfigError";
202
- constructor(message, issues = []) {
237
+ constructor(message, issues = [], next) {
203
238
  super(message);
204
239
  this.issues = issues;
240
+ this.next = next;
205
241
  }
206
242
  };
207
243
  /** Validate an already-loaded config object. */
@@ -228,88 +264,4 @@ function parse(schema, value, source) {
228
264
  throw new ConfigError(`${source} is not valid`, issues);
229
265
  }
230
266
  //#endregion
231
- //#region src/config/load.ts
232
- /** Checked in this order, first match wins. */
233
- const CONFIG_FILENAMES = [
234
- "eaa.config.ts",
235
- "eaa.config.mts",
236
- "eaa.config.js",
237
- "eaa.config.mjs",
238
- "eaa.config.json"
239
- ];
240
- /**
241
- * Find and load `eaa.config.{ts,mts,js,mjs,json}`.
242
- *
243
- * TypeScript configs are imported directly: Node strips types natively from
244
- * 22.18 onwards, which is below this package's floor, so no bundler or loader
245
- * dependency is needed. The failure mode that remains is a project with no
246
- * package.json at all, where Node cannot tell ESM from CommonJS; the error says
247
- * so rather than surfacing "Unexpected token 'export'".
248
- */
249
- async function loadConfig(options = {}) {
250
- const cwd = path.resolve(options.cwd ?? process.cwd());
251
- const file = options.path ? path.resolve(cwd, options.path) : await findConfigFile(cwd);
252
- if (!file) throw new ConfigError(`No config file found in ${cwd} or its parent directories`, CONFIG_FILENAMES.map((name) => `looked for ${name}`));
253
- if (!await isFile(file)) throw new ConfigError(`Config file not found: ${file}`);
254
- return {
255
- config: parseConfig(await readConfigFile(file), path.basename(file)),
256
- path: file
257
- };
258
- }
259
- /**
260
- * Find the config file and read its `audit` block, for the commands that take
261
- * defaults from it.
262
- *
263
- * Returns undefined when there is no config file at all. That is not an error
264
- * here as it is for `statement`: `eaa-kit audit` has always run against a
265
- * project that has never heard of a config file, and it must keep doing so. An
266
- * explicit path that is not there is still an error, because somebody named it.
267
- */
268
- async function loadAuditConfig(options = {}) {
269
- const cwd = path.resolve(options.cwd ?? process.cwd());
270
- const file = options.path ? path.resolve(cwd, options.path) : await findConfigFile(cwd);
271
- if (!file) return void 0;
272
- if (!await isFile(file)) throw new ConfigError(`Config file not found: ${file}`);
273
- return {
274
- audit: parseAuditConfig(await readConfigFile(file), path.basename(file)),
275
- path: file
276
- };
277
- }
278
- function readConfigFile(file) {
279
- return file.endsWith(".json") ? importJson(file) : importModule(file);
280
- }
281
- /** Walks up from `cwd`, so the CLI works from a subdirectory of the project. */
282
- async function findConfigFile(cwd) {
283
- let directory = path.resolve(cwd);
284
- while (true) {
285
- for (const name of CONFIG_FILENAMES) {
286
- const candidate = path.join(directory, name);
287
- if (await isFile(candidate)) return candidate;
288
- }
289
- const parent = path.dirname(directory);
290
- if (parent === directory) return void 0;
291
- directory = parent;
292
- }
293
- }
294
- async function importJson(file) {
295
- const raw = await readFile(file, "utf8");
296
- try {
297
- return JSON.parse(raw);
298
- } catch (cause) {
299
- throw new ConfigError(`${path.basename(file)} is not valid JSON`, [cause instanceof Error ? cause.message : String(cause)]);
300
- }
301
- }
302
- async function importModule(file) {
303
- let module;
304
- try {
305
- module = await import(`${pathToFileURL(file).href}?t=${Date.now()}`);
306
- } catch (cause) {
307
- const message = cause instanceof Error ? cause.message : String(cause);
308
- const hint = message.includes("Unexpected token") ? "If the project has no package.json, Node cannot tell ESM from CommonJS. Add one with \"type\": \"module\", or use eaa.config.json." : message;
309
- throw new ConfigError(`Could not load ${path.basename(file)}`, [hint]);
310
- }
311
- if (module.default === void 0) throw new ConfigError(`${path.basename(file)} has no default export`, ["Expected: export default defineConfig({ … })"]);
312
- return module.default;
313
- }
314
- //#endregion
315
- export { ASSESSMENT_METHODS as a, ConfigError as c, configSchema as d, defineConfig as f, loadConfig as i, ISSUE_REASONS as l, findConfigFile as n, COMPLIANCE_STATUSES as o, parseConfig as p, loadAuditConfig as r, COUNTRIES as s, CONFIG_FILENAMES as t, STATEMENT_LOCALES as u };
267
+ export { ISSUE_REASONS as a, configSchema as c, parseConfig as d, ConfigError as i, defineConfig as l, COMPLIANCE_STATUSES as n, REDIRECT_MODES as o, COUNTRIES as r, STATEMENT_LOCALES as s, ASSESSMENT_METHODS as t, parseAuditConfig as u };
@@ -1,4 +1,4 @@
1
- import { n as IntegrationOptions, t as BuildAuditError } from "../run-YiqyQA2b.js";
1
+ import { n as IntegrationOptions, t as BuildAuditError } from "../run-BK2blxMI.js";
2
2
  //#region src/eleventy/index.d.ts
3
3
  /** What `eleventy.after` is given. Only two of its fields are read. */
4
4
  interface EleventyAfterEvent {
@@ -1,4 +1,4 @@
1
- import { n as auditBuild, r as stderrLogger, t as BuildAuditError } from "../run-D7hdVXLA.js";
1
+ import { n as auditBuild, r as stderrLogger, t as BuildAuditError } from "../run-DzVEOkiF.js";
2
2
  import path from "node:path";
3
3
  //#region src/eleventy/index.ts
4
4
  /**
@@ -0,0 +1,174 @@
1
+ //#region src/audit/entry.ts
2
+ /**
3
+ * What the entry URL of a crawl actually leads to, found before any page is
4
+ * crawled.
5
+ *
6
+ * Two things can put a run somewhere other than where it was sent, and both
7
+ * used to be discovered too late or not at all:
8
+ *
9
+ * - **A redirect to another site.** `https://www.gtainside.de` answers with a
10
+ * 301 to `https://www.gtainside.com`. The crawl refused every page as
11
+ * "redirected off", and the run ended with an error that did not say what to
12
+ * do about it. The run should stop and say where the site went, and it should
13
+ * only go on there when somebody agrees to.
14
+ * - **A sign-in wall.** A preview deployment or a staging CMS answers 401, or
15
+ * sends every request to a login form. The crawl then audited the login form
16
+ * and reported it as the site, which is the failure this tool is written
17
+ * against: a clean result for pages nobody looked at.
18
+ *
19
+ * So the entry is fetched first, one hop at a time, with redirects not
20
+ * followed automatically. That gives the whole chain, the status of each hop,
21
+ * and the page at the end of it. What to do with a redirect is the caller's
22
+ * decision. It depends on flags and on whether there is a terminal to ask at.
23
+ * This module only establishes the facts.
24
+ */
25
+ /** How many redirects to follow before calling it a loop. */
26
+ const MAX_HOPS = 10;
27
+ /** The origins that sign people in for other sites. Suffix-matched. */
28
+ const IDENTITY_PROVIDERS = [
29
+ "accounts.google.com",
30
+ "login.microsoftonline.com",
31
+ "login.live.com",
32
+ "login.windows.net",
33
+ "b2clogin.com",
34
+ "okta.com",
35
+ "oktapreview.com",
36
+ "auth0.com",
37
+ "onelogin.com",
38
+ "amazoncognito.com",
39
+ "appleid.apple.com",
40
+ "id.atlassian.com"
41
+ ];
42
+ /**
43
+ * Paths that are a sign-in page by name: `/login`, `/sign-in`, `/wp-login.php`,
44
+ * Keycloak's `/protocol/openid-connect/auth`, and a few other languages' words.
45
+ */
46
+ const SIGN_IN_PATH = /(?:^|\/)(?:log-?in|sign-?in|signin|sso|oauth2?|authorize|auth|anmelden|connexion|accedi|inloggen|logowanie|wp-login\.php|users\/sign_in|openid-connect\/auth)(?:[/.?]|$)/i;
47
+ function isIdentityProvider(url) {
48
+ const host = url.hostname.toLowerCase();
49
+ return IDENTITY_PROVIDERS.some((provider) => host === provider || host.endsWith(`.${provider}`));
50
+ }
51
+ function isSignInPath(url) {
52
+ return SIGN_IN_PATH.test(url.pathname);
53
+ }
54
+ /** A form somebody types a password into. The shape every sign-in page has. */
55
+ function hasPasswordField(html) {
56
+ return /<input\b[^>]*\btype\s*=\s*["']?password\b/i.test(html);
57
+ }
58
+ /**
59
+ * Whether two URLs are the same site in the sense a reader means it: the same
60
+ * host, give or take a leading `www.`, over http or https. A redirect between
61
+ * two of these is the site tidying its own address, not a different site.
62
+ */
63
+ function isSameSite(a, b) {
64
+ const host = (url) => url.hostname.toLowerCase().replace(/^www\./, "");
65
+ return host(a) === host(b) && a.port === b.port;
66
+ }
67
+ /** Follow the entry's redirects one at a time, and look at where they end. */
68
+ async function probeEntry(entry, options) {
69
+ const impl = options.fetchImpl ?? fetch;
70
+ const hops = [];
71
+ let current = new URL(entry.href);
72
+ for (let hop = 0; hop <= MAX_HOPS; hop += 1) {
73
+ let response;
74
+ const controller = new AbortController();
75
+ const timer = setTimeout(() => controller.abort(), options.timeoutMs);
76
+ try {
77
+ response = await impl(current.href, {
78
+ signal: controller.signal,
79
+ redirect: "manual",
80
+ headers: {
81
+ accept: "text/html,application/xhtml+xml",
82
+ "user-agent": "eaa-kit",
83
+ ...current.origin === entry.origin ? options.headers : {}
84
+ }
85
+ });
86
+ } catch (cause) {
87
+ clearTimeout(timer);
88
+ const reason = controller.signal.aborted ? `timed out after ${options.timeoutMs}ms` : cause instanceof Error ? cause.message : String(cause);
89
+ return {
90
+ hops,
91
+ final: current,
92
+ status: 0,
93
+ error: reason
94
+ };
95
+ }
96
+ clearTimeout(timer);
97
+ hops.push({
98
+ url: current.href,
99
+ status: response.status
100
+ });
101
+ const location = response.headers.get("location");
102
+ if (response.status >= 300 && response.status < 400 && location !== null) {
103
+ await discard(response);
104
+ current = new URL(location, current);
105
+ current.hash = "";
106
+ continue;
107
+ }
108
+ const result = {
109
+ hops,
110
+ final: current,
111
+ status: response.status
112
+ };
113
+ const signIn = await signInEvidence(entry, current, response, options.maxBodyBytes);
114
+ if (signIn !== void 0) result.signIn = signIn;
115
+ await discard(response);
116
+ return result;
117
+ }
118
+ return {
119
+ hops,
120
+ final: current,
121
+ status: 0,
122
+ error: `more than ${MAX_HOPS} redirects, which is a loop or close enough to one`
123
+ };
124
+ }
125
+ async function signInEvidence(entry, final, response, maxBodyBytes) {
126
+ if (response.status === 401) return "http-401";
127
+ if (response.status === 403) return "http-403";
128
+ if (final.href === entry.href) return void 0;
129
+ if (isIdentityProvider(final)) return "identity-provider";
130
+ if (isSignInPath(final)) return "sign-in-path";
131
+ if (!response.ok) return void 0;
132
+ const type = response.headers.get("content-type") ?? "";
133
+ if (!/\b(?:text\/html|application\/xhtml\+xml)\b/i.test(type)) return void 0;
134
+ return hasPasswordField(await readUpTo(response, maxBodyBytes)) ? "password-field" : void 0;
135
+ }
136
+ /**
137
+ * Let go of a body that was not read, so the connection is released. One that
138
+ * was read is locked to its reader and already finished with.
139
+ */
140
+ async function discard(response) {
141
+ if (response.body === null || response.body.locked) return;
142
+ await response.body.cancel();
143
+ }
144
+ /** A body, cut off at a limit rather than refused: this only looks for a form. */
145
+ async function readUpTo(response, limit) {
146
+ const reader = response.body?.getReader();
147
+ if (reader === void 0) return "";
148
+ const decoder = new TextDecoder();
149
+ let text = "";
150
+ let size = 0;
151
+ for (;;) {
152
+ const { done, value } = await reader.read();
153
+ if (done) break;
154
+ size += value.byteLength;
155
+ text += decoder.decode(value, { stream: true });
156
+ if (size >= limit) {
157
+ await reader.cancel();
158
+ break;
159
+ }
160
+ }
161
+ return text;
162
+ }
163
+ /** What each piece of evidence is, in words, for the message and the report. */
164
+ function describeSignIn(evidence, at) {
165
+ switch (evidence) {
166
+ case "http-401": return `${at} answered 401: it asks for credentials before it shows any page`;
167
+ case "http-403": return `${at} answered 403: it refuses requests that are not signed in`;
168
+ case "identity-provider": return `it sends visitors to sign in at ${new URL(at).origin}`;
169
+ case "sign-in-path": return `it sends visitors to a sign-in page at ${at}`;
170
+ case "password-field": return `it sends visitors to ${at}, a page with a password field on it`;
171
+ }
172
+ }
173
+ //#endregion
174
+ export { describeSignIn, hasPasswordField, isSameSite, probeEntry };
@@ -1,12 +1,12 @@
1
1
  import { a as impactLabel, r as byImpactThenRule } from "./impact-luGCnN8F.js";
2
2
  import { i as escapeText, n as count, r as escapeAttribute, s as standardsReference, t as collapse } from "./text-BF1LHMiV.js";
3
3
  import { t as TOOL_VERSION } from "./version-B3v4rNoG.js";
4
- import { c as runEngine } from "./result-DfUru6y_.js";
5
- import { l as reviewSentence } from "./review-CdMK2GpQ.js";
4
+ import { u as runEngine } from "./result-B7_zVxAX.js";
5
+ import { l as reviewSentence } from "./review-Bz0fO9_I.js";
6
+ import { a as isShared, c as missedParts, i as groupIssues, l as redirectPart, n as blindRules, o as issueTotals, r as coverageParts, s as discoveryLabel, t as remediationFor, u as reusedPart } from "./remediation-Bbs4KcX1.js";
6
7
  import { r as componentPath } from "./component-ChisoFyY.js";
7
- import { i as reviewSummary, n as buildCoverage, o as manualCheckFor, s as understandingUrl } from "./coverage-BD2_CYns.js";
8
- import { a as blindRules, c as isShared, i as remediationFor, l as issueTotals, n as missedParts, o as coverageParts, s as groupIssues, t as discoveryLabel } from "./completeness-Dwq3CPB3.js";
9
- import { n as buildSummary } from "./json-PNg6BeXp.js";
8
+ import { a as manualCheckFor, o as understandingUrl, r as reviewSummary, t as buildCoverage } from "./coverage-zdzgSKjz.js";
9
+ import { n as buildSummary } from "./json-SGCgxSPT.js";
10
10
  import axe from "axe-core";
11
11
  //#region src/audit/report/html.ts
12
12
  /**
@@ -103,6 +103,10 @@ function runDetails(audits, engine, generatedAt, options) {
103
103
  ];
104
104
  if (options.baseUrl) rows.splice(1, 0, ["Base URL", options.baseUrl]);
105
105
  if (options.completeness) rows.splice(2, 0, ["Pages found via", discoveryLabel(options.completeness.discovery)]);
106
+ const reused = options.completeness ? reusedPart(options.completeness) : void 0;
107
+ if (reused !== void 0) rows.push(["Reused", reused]);
108
+ const redirected = options.completeness ? redirectPart(options.completeness) : void 0;
109
+ if (redirected !== void 0) rows.splice(1, 0, ["Redirected", redirected]);
106
110
  return `<h2>The run</h2>\n<dl class="run">\n${rows.map(([term, value]) => ` <div><dt>${escapeText(term)}</dt><dd>${escapeText(value)}</dd></div>`).join("\n")}\n</dl>`;
107
111
  }
108
112
  /** Pages named individually before the rest are counted. */