mcp-web-validator 1.3.56 → 1.3.58
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 +25 -0
- package/README.md +19 -1
- package/SECURITY.md +10 -0
- package/dist/audit-history.js +2 -0
- package/dist/audit-history.js.map +1 -1
- package/dist/index.js +8 -2
- package/dist/index.js.map +1 -1
- package/dist/language-subtags.js +2 -0
- package/dist/language-subtags.js.map +1 -1
- package/dist/mcp-bounds.js.map +1 -1
- package/dist/modules/browser-ux/axe-review.js +2 -0
- package/dist/modules/browser-ux/axe-review.js.map +1 -1
- package/dist/modules/browser-ux/lighthouse-lab-probe.js +2 -0
- package/dist/modules/browser-ux/lighthouse-lab-probe.js.map +1 -1
- package/dist/modules/browser-ux/lighthouse-lab.js +2 -0
- package/dist/modules/browser-ux/lighthouse-lab.js.map +1 -1
- package/dist/modules/browser-ux/media-diagnostics.js +2 -0
- package/dist/modules/browser-ux/media-diagnostics.js.map +1 -1
- package/dist/modules/browser-ux/raw-rendered-diff.js +90 -40
- package/dist/modules/browser-ux/raw-rendered-diff.js.map +1 -1
- package/dist/modules/browser-ux/raw-rendered-probe.js +18 -0
- package/dist/modules/browser-ux/raw-rendered-probe.js.map +1 -1
- package/dist/modules/browser-ux/resource-failures-probe.js +2 -0
- package/dist/modules/browser-ux/resource-failures-probe.js.map +1 -1
- package/dist/modules/browser-ux/resource-failures.js +2 -0
- package/dist/modules/browser-ux/resource-failures.js.map +1 -1
- package/dist/modules/browser-ux/viewport-parity-probe.js +2 -0
- package/dist/modules/browser-ux/viewport-parity-probe.js.map +1 -1
- package/dist/modules/browser-ux/viewport-parity.js +2 -0
- package/dist/modules/browser-ux/viewport-parity.js.map +1 -1
- package/dist/modules/browser-ux/wcag-interactions.js +2 -0
- package/dist/modules/browser-ux/wcag-interactions.js.map +1 -1
- package/dist/modules/change-regression/availability-history-store.js +2 -0
- package/dist/modules/change-regression/availability-history-store.js.map +1 -1
- package/dist/modules/change-regression/crawler-log-correlation.js +2 -0
- package/dist/modules/change-regression/crawler-log-correlation.js.map +1 -1
- package/dist/modules/change-regression/google-common-crawler-ip.js +2 -0
- package/dist/modules/change-regression/google-common-crawler-ip.js.map +1 -1
- package/dist/modules/change-regression/historical-comparisons.js +2 -0
- package/dist/modules/change-regression/historical-comparisons.js.map +1 -1
- package/dist/modules/change-regression/production-change-comparison.js +2 -0
- package/dist/modules/change-regression/production-change-comparison.js.map +1 -1
- package/dist/modules/change-regression/regression-alerts.js.map +1 -1
- package/dist/modules/change-regression/strict-observation-time.js +2 -0
- package/dist/modules/change-regression/strict-observation-time.js.map +1 -1
- package/dist/modules/content-schema/citation-methodology-consistency.js +2 -0
- package/dist/modules/content-schema/citation-methodology-consistency.js.map +1 -1
- package/dist/modules/content-schema/competitor-intent-comparison.js.map +1 -1
- package/dist/modules/content-schema/empty-boilerplate-content.js +2 -0
- package/dist/modules/content-schema/empty-boilerplate-content.js.map +1 -1
- package/dist/modules/content-schema/extract-citation-methodology.js +2 -0
- package/dist/modules/content-schema/extract-citation-methodology.js.map +1 -1
- package/dist/modules/content-schema/extract-competitor-intent.js +2 -0
- package/dist/modules/content-schema/extract-competitor-intent.js.map +1 -1
- package/dist/modules/content-schema/extract-main-content.js +2 -0
- package/dist/modules/content-schema/extract-main-content.js.map +1 -1
- package/dist/modules/content-schema/extract-metadata-consistency.js +2 -0
- package/dist/modules/content-schema/extract-metadata-consistency.js.map +1 -1
- package/dist/modules/content-schema/extract-product-claims.js +4 -1
- package/dist/modules/content-schema/extract-product-claims.js.map +1 -1
- package/dist/modules/content-schema/extract-structured-data.js +2 -0
- package/dist/modules/content-schema/extract-structured-data.js.map +1 -1
- package/dist/modules/content-schema/metadata-consistency.js +2 -0
- package/dist/modules/content-schema/metadata-consistency.js.map +1 -1
- package/dist/modules/content-schema/product-claims.js.map +1 -1
- package/dist/modules/content-schema/same-language-duplicates.js.map +1 -1
- package/dist/modules/content-schema/structured-data-validation.js +2 -0
- package/dist/modules/content-schema/structured-data-validation.js.map +1 -1
- package/dist/modules/external-metrics/crux-field-probe.js +2 -0
- package/dist/modules/external-metrics/crux-field-probe.js.map +1 -1
- package/dist/modules/external-metrics/crux-field.js +2 -0
- package/dist/modules/external-metrics/crux-field.js.map +1 -1
- package/dist/modules/http-crawl/availability-observations.d.ts +0 -5
- package/dist/modules/http-crawl/availability-observations.js +8 -17
- package/dist/modules/http-crawl/availability-observations.js.map +1 -1
- package/dist/modules/http-crawl/availability-probe.js.map +1 -1
- package/dist/modules/http-crawl/crawler-access-probe.js +2 -0
- package/dist/modules/http-crawl/crawler-access-probe.js.map +1 -1
- package/dist/modules/http-crawl/crawler-access.js +2 -0
- package/dist/modules/http-crawl/crawler-access.js.map +1 -1
- package/dist/modules/http-crawl/http-delivery-probe.js +2 -0
- package/dist/modules/http-crawl/http-delivery-probe.js.map +1 -1
- package/dist/modules/http-crawl/http-delivery.js +4 -1
- package/dist/modules/http-crawl/http-delivery.js.map +1 -1
- package/dist/modules/http-crawl/https-security.js +2 -0
- package/dist/modules/http-crawl/https-security.js.map +1 -1
- package/dist/modules/http-crawl/non-html-directives.js +44 -14
- package/dist/modules/http-crawl/non-html-directives.js.map +1 -1
- package/dist/modules/http-crawl/redirect-canonical-chains.js +2 -0
- package/dist/modules/http-crawl/redirect-canonical-chains.js.map +1 -1
- package/dist/modules/http-crawl/redirect-canonical-probe.js +2 -0
- package/dist/modules/http-crawl/redirect-canonical-probe.js.map +1 -1
- package/dist/modules/http-crawl/sitemap-inventory-probe.js +2 -0
- package/dist/modules/http-crawl/sitemap-inventory-probe.js.map +1 -1
- package/dist/modules/http-crawl/sitemap-inventory.js +21 -2
- package/dist/modules/http-crawl/sitemap-inventory.js.map +1 -1
- package/dist/modules/http-crawl/url-variants.js +2 -0
- package/dist/modules/http-crawl/url-variants.js.map +1 -1
- package/dist/modules/site-architecture/extract-internal-links.js +38 -4
- package/dist/modules/site-architecture/extract-internal-links.js.map +1 -1
- package/dist/modules/site-architecture/extract-multilingual-page.js +2 -0
- package/dist/modules/site-architecture/extract-multilingual-page.js.map +1 -1
- package/dist/modules/site-architecture/internal-link-graph-probe.js +2 -0
- package/dist/modules/site-architecture/internal-link-graph-probe.js.map +1 -1
- package/dist/modules/site-architecture/internal-link-graph.js +2 -0
- package/dist/modules/site-architecture/internal-link-graph.js.map +1 -1
- package/dist/modules/site-architecture/internal-link-quality.js +2 -0
- package/dist/modules/site-architecture/internal-link-quality.js.map +1 -1
- package/dist/modules/site-architecture/multilingual-clusters.js +2 -0
- package/dist/modules/site-architecture/multilingual-clusters.js.map +1 -1
- package/dist/network-protocol.d.ts +3 -0
- package/dist/network-protocol.js +9 -0
- package/dist/network-protocol.js.map +1 -0
- package/dist/network.js +12 -0
- package/dist/network.js.map +1 -1
- package/dist/nu-ephemeral.d.ts +2 -0
- package/dist/nu-ephemeral.js +126 -0
- package/dist/nu-ephemeral.js.map +1 -0
- package/dist/presentation.js +3 -1
- package/dist/presentation.js.map +1 -1
- package/dist/report.js +4 -2
- package/dist/report.js.map +1 -1
- package/dist/screenshot-proxy.js +2 -0
- package/dist/screenshot-proxy.js.map +1 -1
- package/dist/screenshot.d.ts +1 -1
- package/dist/screenshot.js +3 -1
- package/dist/screenshot.js.map +1 -1
- package/dist/seo-auditor.js +20 -10
- package/dist/seo-auditor.js.map +1 -1
- package/dist/stylelint-validator.js +2 -0
- package/dist/stylelint-validator.js.map +1 -1
- package/dist/version.js +2 -0
- package/dist/version.js.map +1 -1
- package/dist/visual-diff.js +9 -1
- package/dist/visual-diff.js.map +1 -1
- package/dist/w3c-validator.js +20 -5
- package/dist/w3c-validator.js.map +1 -1
- package/docs/reliability-engines-20261123.md +156 -0
- package/package.json +8 -4
- package/scripts/deep-audit-optional.mjs +198 -0
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// Copyright (c) 2026 AKzar1el and Web Validator contributors
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
1
3
|
/**
|
|
2
4
|
* V07: deterministic, redacted comparison of HTTP source HTML and a browser
|
|
3
5
|
* rendered DOM snapshot. This analyzer is pure; Chromium is a separate local
|
|
@@ -34,11 +36,36 @@ const noindexPattern = /(?:^|[\s,;])(?:noindex|none)(?:$|[\s,;])/iu;
|
|
|
34
36
|
const hasRel = (raw, token) => (raw ?? "").toLowerCase().split(/\s+/u).includes(token);
|
|
35
37
|
const textWords = (raw) => (raw.normalize("NFKC").toLocaleLowerCase("en").match(/[\p{L}\p{N}]+/gu) ?? [])
|
|
36
38
|
.filter((word) => word.length >= 2 && word.length <= 60)
|
|
37
|
-
.slice(0, MAX_RENDER_WORDS);
|
|
39
|
+
.slice(0, MAX_RENDER_WORDS + 1);
|
|
40
|
+
const excludedMainDescendants = new Set([
|
|
41
|
+
"script", "style", "noscript", "template", "svg", "nav", "header", "footer", "aside",
|
|
42
|
+
]);
|
|
43
|
+
// Preserve textContent ordering and adjacency without cloning or recursively
|
|
44
|
+
// traversing arbitrarily deep caller-supplied HTML. Exclusions apply only to
|
|
45
|
+
// descendants, just as the previous clone().find(...).remove() did.
|
|
46
|
+
function snapshotText(root, excluded) {
|
|
47
|
+
if (!root)
|
|
48
|
+
return "";
|
|
49
|
+
const pending = [root];
|
|
50
|
+
const chunks = [];
|
|
51
|
+
while (pending.length > 0) {
|
|
52
|
+
const node = pending.pop();
|
|
53
|
+
if (node !== root && "name" in node && excluded?.has(node.name))
|
|
54
|
+
continue;
|
|
55
|
+
if (node.type === "text") {
|
|
56
|
+
chunks.push(node.data);
|
|
57
|
+
}
|
|
58
|
+
else if ("children" in node) {
|
|
59
|
+
for (let i = node.children.length - 1; i >= 0; i--)
|
|
60
|
+
pending.push(node.children[i]);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return chunks.join("");
|
|
64
|
+
}
|
|
38
65
|
function inspect(html, sourceUrl) {
|
|
39
66
|
const $ = load(html);
|
|
40
67
|
const head = $("head");
|
|
41
|
-
const title = head.find("title").first().
|
|
68
|
+
const title = snapshotText(head.find("title").first().get(0)).replace(/\s+/gu, " ").trim().slice(0, 600);
|
|
42
69
|
const description = head.find('meta[name="description" i]').first()
|
|
43
70
|
.attr("content")?.replace(/\s+/gu, " ").trim().slice(0, 1200) ?? "";
|
|
44
71
|
const metaNoindex = head.find("meta[name][content]").toArray().some((el) => {
|
|
@@ -46,6 +73,16 @@ function inspect(html, sourceUrl) {
|
|
|
46
73
|
return ["robots", "googlebot"].includes(name) &&
|
|
47
74
|
noindexPattern.test($(el).attr("content") ?? "");
|
|
48
75
|
});
|
|
76
|
+
const baseHref = head.find("base[href]").first().attr("href");
|
|
77
|
+
let canonicalBase = sourceUrl;
|
|
78
|
+
if (baseHref !== undefined) {
|
|
79
|
+
try {
|
|
80
|
+
canonicalBase = boundedUrl(new URL(baseHref, sourceUrl).href);
|
|
81
|
+
}
|
|
82
|
+
catch {
|
|
83
|
+
canonicalBase = undefined;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
49
86
|
const canonicals = head.find("link[rel][href]").toArray().filter((el) => hasRel($(el).attr("rel"), "canonical"));
|
|
50
87
|
const normalizedCanonicals = new Set();
|
|
51
88
|
let ambiguousCanonical = false;
|
|
@@ -55,8 +92,14 @@ function inspect(html, sourceUrl) {
|
|
|
55
92
|
ambiguousCanonical = true;
|
|
56
93
|
continue;
|
|
57
94
|
}
|
|
95
|
+
// An excluded document base makes relative identities uncertain, but
|
|
96
|
+
// does not affect a fully qualified HTTP(S) canonical declaration.
|
|
97
|
+
if (!canonicalBase && !/^https?:\/\//iu.test(href.trim())) {
|
|
98
|
+
ambiguousCanonical = true;
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
58
101
|
try {
|
|
59
|
-
const url = new URL(href,
|
|
102
|
+
const url = new URL(href, canonicalBase);
|
|
60
103
|
url.hash = "";
|
|
61
104
|
const safe = boundedUrl(url.href);
|
|
62
105
|
if (safe)
|
|
@@ -73,39 +116,40 @@ function inspect(html, sourceUrl) {
|
|
|
73
116
|
normalizedCanonicals.has(sourceUrl) ? "self" : "different";
|
|
74
117
|
// Evaluate only text visible in the source HTML structure, not CSS computed
|
|
75
118
|
// visibility or Google-selected content. Dynamic styles are out of scope.
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
119
|
+
const mainCandidates = $("main,[role='main'],article").toArray();
|
|
120
|
+
// Cheerio exposes inert template descendants through document-wide selectors.
|
|
121
|
+
const outsideTemplate = (el) => {
|
|
122
|
+
if (el.name === "template")
|
|
123
|
+
return false;
|
|
124
|
+
for (let ancestor = el.parent; ancestor; ancestor = ancestor.parent) {
|
|
125
|
+
if (ancestor.type === "tag" && ancestor.name === "template")
|
|
126
|
+
return false;
|
|
127
|
+
}
|
|
128
|
+
return true;
|
|
129
|
+
};
|
|
130
|
+
const main = mainCandidates.find(outsideTemplate);
|
|
131
|
+
const root = main ?? $("body").first().get(0);
|
|
132
|
+
const mainText = snapshotText(root, excludedMainDescendants);
|
|
133
|
+
const sampledWords = textWords(mainText);
|
|
134
|
+
const wordsTruncated = sampledWords.length > MAX_RENDER_WORDS || mainText.length > 100_000;
|
|
135
|
+
const words = sampledWords.slice(0, MAX_RENDER_WORDS);
|
|
80
136
|
const links = new Set();
|
|
81
137
|
const external = new Set();
|
|
82
138
|
let queryLinks = 0;
|
|
83
|
-
let
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
try {
|
|
89
|
-
const candidate = new URL(baseHref, sourceUrl);
|
|
90
|
-
const safe = boundedUrl(candidate.href);
|
|
91
|
-
if (safe && candidate.origin === new URL(sourceUrl).origin)
|
|
92
|
-
base = safe;
|
|
93
|
-
else
|
|
94
|
-
unsafeBase = true;
|
|
95
|
-
}
|
|
96
|
-
catch {
|
|
97
|
-
unsafeBase = true;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
139
|
+
let linksTruncated = false;
|
|
140
|
+
// Link comparison remains restricted to the source origin, even when a
|
|
141
|
+
// safe cross-origin base can resolve canonical identity for comparison.
|
|
142
|
+
const unsafeBase = !canonicalBase || new URL(canonicalBase).origin !== new URL(sourceUrl).origin;
|
|
143
|
+
const base = unsafeBase ? sourceUrl : canonicalBase;
|
|
100
144
|
const anchors = $("body a[href]").toArray();
|
|
101
145
|
if (anchors.length > MAX_RENDER_LINKS)
|
|
102
|
-
|
|
146
|
+
linksTruncated = true;
|
|
103
147
|
for (const el of anchors.slice(0, MAX_RENDER_LINKS)) {
|
|
104
148
|
const raw = ($(el).attr("href") ?? "").trim();
|
|
105
149
|
if (!raw || raw.length > 1024 || raw.startsWith("#"))
|
|
106
150
|
continue;
|
|
107
151
|
if (unsafeBase && !/^[a-z][a-z0-9+.-]*:/iu.test(raw) && !raw.startsWith("//")) {
|
|
108
|
-
|
|
152
|
+
linksTruncated = true;
|
|
109
153
|
continue;
|
|
110
154
|
}
|
|
111
155
|
try {
|
|
@@ -128,7 +172,10 @@ function inspect(html, sourceUrl) {
|
|
|
128
172
|
}
|
|
129
173
|
catch { /* No graph edge for unsafe or invalid URLs. */ }
|
|
130
174
|
}
|
|
131
|
-
|
|
175
|
+
// Template contents are inert until instantiated, even when Cheerio exposes
|
|
176
|
+
// their scripts through the document-wide selector.
|
|
177
|
+
const scripts = $("script").toArray().filter(outsideTemplate);
|
|
178
|
+
const scriptMediaType = (el) => (($(el).attr("type") ?? "").split(";", 1)[0] ?? "").trim().toLowerCase();
|
|
132
179
|
const snapshot = {
|
|
133
180
|
title_present: Boolean(title), title_characters: title.length,
|
|
134
181
|
description_present: Boolean(description), description_characters: description.length,
|
|
@@ -136,20 +183,20 @@ function inspect(html, sourceUrl) {
|
|
|
136
183
|
same_origin_link_targets: links.size, query_links_excluded: queryLinks,
|
|
137
184
|
external_link_targets: external.size,
|
|
138
185
|
canonicals: canonicalState, noindex_declared: metaNoindex,
|
|
139
|
-
jsonld_blocks: scripts.filter((el) => (
|
|
186
|
+
jsonld_blocks: scripts.filter((el) => scriptMediaType(el) === "application/ld+json").length,
|
|
140
187
|
external_script_tags: scripts.filter((el) => Boolean($(el).attr("src"))).length,
|
|
141
|
-
inline_script_tags: scripts.filter((el) => !$(el).attr("src") && !["application/ld+json", "application/json"].includes((
|
|
142
|
-
sample_truncated:
|
|
188
|
+
inline_script_tags: scripts.filter((el) => !$(el).attr("src") && !["application/ld+json", "application/json"].includes(scriptMediaType(el))).length,
|
|
189
|
+
sample_truncated: linksTruncated || wordsTruncated,
|
|
143
190
|
};
|
|
144
|
-
return { snapshot, title, firstH1: $("body h1").first().
|
|
191
|
+
return { snapshot, title, firstH1: snapshotText($("body h1").first().get(0)).trim().slice(0, 600),
|
|
145
192
|
canonicalState, canonicalSet: normalizedCanonicals,
|
|
146
|
-
links, words: new Set(words) };
|
|
193
|
+
links, words: new Set(words), linksTruncated, wordsTruncated };
|
|
147
194
|
}
|
|
148
195
|
const limitations = [
|
|
149
196
|
"This tool compares supplied source and rendered HTML snapshots; it does not verify Googlebot, Google Web Rendering Service, indexing, search results or historical production behavior.",
|
|
150
197
|
"Browser inline-script mode executes only local inline JavaScript in fresh, network-denied Chromium; external modules, frameworks, APIs, fonts, images and stylesheets do not load.",
|
|
151
198
|
"Static DOM comparisons do not prove visual visibility, interactivity, hydration success, accessibility, semantic equivalence or actual loaded resource availability.",
|
|
152
|
-
"All URL paths, titles, headings, text and script/console contents are omitted from output. Links with queries are excluded; only capped same-origin path-only links are compared.",
|
|
199
|
+
"All URL paths, titles, headings, text and script/console contents are omitted from output. Links with queries are excluded; only capped same-origin path-only links are compared. Numeric deltas describe samples when coverage is incomplete.",
|
|
153
200
|
];
|
|
154
201
|
export function emptyRawRenderedReview(scope = "caller_supplied_rendered_snapshot") {
|
|
155
202
|
const blank = {
|
|
@@ -219,20 +266,22 @@ export function analyzeRawRendered(input, evidence = {}) {
|
|
|
219
266
|
add("h1_removed", "warning", "A source H1 heading was absent after rendering.");
|
|
220
267
|
else if (report.raw.h1_count === 0 && report.rendered.h1_count > 0)
|
|
221
268
|
add("h1_added", "info", "The rendered DOM introduces an H1 absent in source HTML.");
|
|
222
|
-
|
|
269
|
+
// Absence requires complete coverage on the side where evidence is missing.
|
|
270
|
+
// A capped count on the other side remains a conservative lower bound.
|
|
271
|
+
if (!rendered.wordsTruncated && report.raw.main_words >= 20 &&
|
|
223
272
|
report.rendered.main_words < Math.floor(report.raw.main_words * 0.65)) {
|
|
224
273
|
add("main_text_dropped", "warning", "Rendered main content has substantially fewer words than the supplied source.");
|
|
225
274
|
}
|
|
226
|
-
else if (report.rendered.main_words >= 20 &&
|
|
275
|
+
else if (!raw.wordsTruncated && report.rendered.main_words >= 20 &&
|
|
227
276
|
report.raw.main_words < Math.floor(report.rendered.main_words * 0.65)) {
|
|
228
277
|
add("main_text_added", "info", "Main textual content is predominantly rendered rather than available in source.");
|
|
229
278
|
}
|
|
230
|
-
else if (report.main_words_removed > 15 && report.raw.main_words >= 20) {
|
|
279
|
+
else if (!rendered.wordsTruncated && report.main_words_removed > 15 && report.raw.main_words >= 20) {
|
|
231
280
|
add("main_text_changed", "info", "Some distinct source text tokens were absent in the rendered sample.");
|
|
232
281
|
}
|
|
233
|
-
if (report.link_targets_removed)
|
|
282
|
+
if (!rendered.linksTruncated && report.link_targets_removed)
|
|
234
283
|
add("links_removed", "warning", "One or more source same-origin links are absent in the rendered DOM.");
|
|
235
|
-
if (report.link_targets_added)
|
|
284
|
+
if (!raw.linksTruncated && report.link_targets_added)
|
|
236
285
|
add("links_added", "info", "One or more same-origin links appear only in the rendered DOM.");
|
|
237
286
|
if (!report.raw.noindex_declared && report.rendered.noindex_declared)
|
|
238
287
|
add("noindex_added", "warning", "The rendered head declares noindex absent in source; verify indexing intentions.");
|
|
@@ -250,8 +299,9 @@ export function analyzeRawRendered(input, evidence = {}) {
|
|
|
250
299
|
add("resources_blocked", "info", "Chromium attempted one or more external resource requests, all blocked.");
|
|
251
300
|
if (report.browser_executed && report.script_errors_observed)
|
|
252
301
|
add("script_errors_observed", "info", "One or more JavaScript runtime errors occurred; error text was discarded.");
|
|
253
|
-
if (report.raw.sample_truncated || report.rendered.sample_truncated)
|
|
254
|
-
add("snapshot_coverage_limited", "info", "Link or text
|
|
302
|
+
if (report.raw.sample_truncated || report.rendered.sample_truncated) {
|
|
303
|
+
add("snapshot_coverage_limited", "info", "Link or text coverage is incomplete; absence findings require complete coverage on the relevant side.");
|
|
304
|
+
}
|
|
255
305
|
records.sort((a, b) => (a.severity === b.severity ? 0 : a.severity === "warning" ? -1 : 1)
|
|
256
306
|
|| a.code.localeCompare(b.code));
|
|
257
307
|
report.total_findings = records.length;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"raw-rendered-diff.js","sourceRoot":"","sources":["../../../src/modules/browser-ux/raw-rendered-diff.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,OAAO,EAAE,eAAe,EAAE,MAAM,+CAA+C,CAAC;AAEhF,MAAM,CAAC,MAAM,qBAAqB,GAAG,OAAO,CAAC;AAC7C,MAAM,CAAC,MAAM,2BAA2B,GAAG,SAAS,CAAC;AACrD,MAAM,CAAC,MAAM,mBAAmB,GAAG,EAAE,CAAC;AACtC,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,CAAC;AACpC,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC;AACvC,MAAM,CAAC,MAAM,qBAAqB,GAAG,MAAM,CAAC;AAE5C,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,eAAe,EAAE,aAAa,EAAE,eAAe;IAC/C,qBAAqB,EAAE,mBAAmB;IAC1C,YAAY,EAAE,UAAU;IACxB,mBAAmB,EAAE,iBAAiB,EAAE,mBAAmB;IAC3D,eAAe,EAAE,aAAa;IAC9B,eAAe,EAAE,iBAAiB;IAClC,mBAAmB,EAAE,gBAAgB,EAAE,cAAc;IACrD,0BAA0B,EAAE,mBAAmB;IAC/C,wBAAwB,EAAE,2BAA2B;CAC7C,CAAC;AAkEX,MAAM,OAAO,GAAG,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B,IAAI,MAAM,CAAC,GAAG,CAAC,oBAAoB;QAAE,GAAG,CAAC,0BAA0B,EAC5F,MAAM,EAAE,gGAAgG,CAAC,CAAC;IAC5G,IAAI,MAAM,CAAC,gBAAgB,IAAI,MAAM,CAAC,0BAA0B;QAAE,GAAG,CAAC,mBAAmB,EACvF,MAAM,EAAE,yEAAyE,CAAC,CAAC;IACrF,IAAI,MAAM,CAAC,gBAAgB,IAAI,MAAM,CAAC,sBAAsB;QAAE,GAAG,CAAC,wBAAwB,EACxF,MAAM,EAAE,2EAA2E,CAAC,CAAC;IACvF,IAAI,MAAM,CAAC,GAAG,CAAC,gBAAgB,IAAI,MAAM,CAAC,QAAQ,CAAC,gBAAgB;QAAE,GAAG,CAAC,2BAA2B,EAClG,MAAM,EAAE,gFAAgF,CAAC,CAAC;IAC5F,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,QAAQ,KAAK,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;WACrF,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;IACnC,MAAM,CAAC,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC;IACvC,MAAM,CAAC,QAAQ,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,mBAAmB,CAAC,CAAC;IACxD,MAAM,CAAC,kBAAkB,GAAG,OAAO,CAAC,MAAM,GAAG,mBAAmB,CAAC;IACjE,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["/**\n * V07: deterministic, redacted comparison of HTTP source HTML and a browser\n * rendered DOM snapshot. This analyzer is pure; Chromium is a separate local\n * probe. Rendering is NOT equivalent to Google WRS or its index decision.\n */\nimport { load } from \"cheerio\";\nimport { safeLinkPageUrl } from \"../site-architecture/internal-link-quality.js\";\n\nexport const MAX_RENDER_HTML_BYTES = 524_288;\nexport const MAX_RENDER_TOTAL_HTML_BYTES = 1_048_576;\nexport const MAX_RENDER_FINDINGS = 18;\nexport const MAX_RENDER_LINKS = 200;\nexport const MAX_RENDER_WORDS = 10_000;\nexport const MAX_RENDER_BROWSER_MS = 15_000;\n\nexport const RENDER_FINDING_CODES = [\n \"title_removed\", \"title_added\", \"title_changed\",\n \"description_removed\", \"description_added\",\n \"h1_removed\", \"h1_added\",\n \"main_text_dropped\", \"main_text_added\", \"main_text_changed\",\n \"links_removed\", \"links_added\",\n \"noindex_added\", \"noindex_removed\",\n \"canonical_changed\", \"jsonld_removed\", \"jsonld_added\",\n \"external_scripts_blocked\", \"resources_blocked\",\n \"script_errors_observed\", \"snapshot_coverage_limited\",\n] as const;\nexport type RenderFindingCode = typeof RENDER_FINDING_CODES[number];\nexport type RenderScope =\n \"caller_supplied_rendered_snapshot\" | \"isolated_inline_script_chromium\" |\n \"isolated_public_html_inline_script_sample\";\n\nexport interface RawRenderedInput {\n page_url: string;\n raw_html: string;\n rendered_html: string;\n}\nexport interface RenderEvidence {\n scope?: RenderScope;\n browser_executed?: boolean;\n inline_scripts_attempted?: boolean;\n external_resources_blocked?: number;\n script_errors_observed?: number;\n}\nexport interface RenderSnapshot {\n title_present: boolean;\n title_characters: number;\n description_present: boolean;\n description_characters: number;\n h1_count: number;\n main_words: number;\n same_origin_link_targets: number;\n query_links_excluded: number;\n external_link_targets: number;\n canonicals: \"missing\" | \"self\" | \"different\" | \"ambiguous\";\n noindex_declared: boolean;\n jsonld_blocks: number;\n external_script_tags: number;\n inline_script_tags: number;\n sample_truncated: boolean;\n}\nexport interface RenderFinding {\n code: RenderFindingCode;\n severity: \"warning\" | \"info\";\n message: string;\n}\nexport interface RawRenderedReview {\n scope: RenderScope;\n browser_executed: boolean;\n inline_scripts_attempted: boolean;\n external_resources_blocked: number;\n script_errors_observed: number;\n raw: RenderSnapshot;\n rendered: RenderSnapshot;\n title_changed: boolean;\n h1_changed: boolean;\n canonical_changed: boolean;\n noindex_changed: boolean;\n shared_main_words: number;\n main_words_removed: number;\n main_words_added: number;\n link_targets_removed: number;\n link_targets_added: number;\n unchanged_link_targets: number;\n coverage_limited: true;\n limitations: string[];\n total_findings: number;\n findings: RenderFinding[];\n findings_truncated: boolean;\n error?: string;\n}\n\nconst encoder = new TextEncoder();\nconst bytes = (value: string): number => encoder.encode(value).byteLength;\nfunction boundedUrl(value: unknown): string | undefined {\n if (typeof value !== \"string\" || bytes(value) > 512 ||\n /[\\u0000-\\u001f\\u007f-\\u009f\\u202a-\\u202e\\u2066-\\u2069\\\\]/u.test(value)) return undefined;\n return safeLinkPageUrl(value);\n}\nconst noindexPattern = /(?:^|[\\s,;])(?:noindex|none)(?:$|[\\s,;])/iu;\nconst hasRel = (raw: string | undefined, token: string): boolean =>\n (raw ?? \"\").toLowerCase().split(/\\s+/u).includes(token);\nconst textWords = (raw: string): string[] =>\n (raw.normalize(\"NFKC\").toLocaleLowerCase(\"en\").match(/[\\p{L}\\p{N}]+/gu) ?? [])\n .filter((word) => word.length >= 2 && word.length <= 60)\n .slice(0, MAX_RENDER_WORDS);\n\nfunction inspect(html: string, sourceUrl: string) {\n const $ = load(html);\n const head = $(\"head\");\n const title = head.find(\"title\").first().text().replace(/\\s+/gu, \" \").trim().slice(0, 600);\n const description = head.find('meta[name=\"description\" i]').first()\n .attr(\"content\")?.replace(/\\s+/gu, \" \").trim().slice(0, 1200) ?? \"\";\n const metaNoindex = head.find(\"meta[name][content]\").toArray().some((el) => {\n const name = ($(el).attr(\"name\") ?? \"\").trim().toLowerCase();\n return [\"robots\", \"googlebot\"].includes(name) &&\n noindexPattern.test($(el).attr(\"content\") ?? \"\");\n });\n const canonicals = head.find(\"link[rel][href]\").toArray().filter((el) =>\n hasRel($(el).attr(\"rel\"), \"canonical\"));\n const normalizedCanonicals = new Set<string>();\n let ambiguousCanonical = false;\n for (const el of canonicals) {\n const href = $(el).attr(\"href\");\n if (!href) { ambiguousCanonical = true; continue; }\n try {\n const url = new URL(href, sourceUrl);\n url.hash = \"\";\n const safe = boundedUrl(url.href);\n if (safe) normalizedCanonicals.add(safe);\n else ambiguousCanonical = true;\n } catch { ambiguousCanonical = true; }\n }\n const canonicalState = canonicals.length === 0 ? \"missing\" :\n ambiguousCanonical || normalizedCanonicals.size !== 1 ? \"ambiguous\" :\n normalizedCanonicals.has(sourceUrl) ? \"self\" : \"different\";\n // Evaluate only text visible in the source HTML structure, not CSS computed\n // visibility or Google-selected content. Dynamic styles are out of scope.\n const main = $(\"main,[role='main'],article\").first();\n const root = main.length ? main.clone() : $(\"body\").first().clone();\n root.find(\"script,style,noscript,template,svg,nav,header,footer,aside\").remove();\n const words = textWords(root.text());\n const links = new Set<string>();\n const external = new Set<string>();\n let queryLinks = 0;\n let truncated = false;\n const baseHref = head.find(\"base[href]\").first().attr(\"href\");\n let base = sourceUrl;\n let unsafeBase = false;\n if (baseHref !== undefined) {\n try {\n const candidate = new URL(baseHref, sourceUrl);\n const safe = boundedUrl(candidate.href);\n if (safe && candidate.origin === new URL(sourceUrl).origin) base = safe;\n else unsafeBase = true;\n } catch { unsafeBase = true; }\n }\n const anchors = $(\"body a[href]\").toArray();\n if (anchors.length > MAX_RENDER_LINKS) truncated = true;\n for (const el of anchors.slice(0, MAX_RENDER_LINKS)) {\n const raw = ($(el).attr(\"href\") ?? \"\").trim();\n if (!raw || raw.length > 1024 || raw.startsWith(\"#\")) continue;\n if (unsafeBase && !/^[a-z][a-z0-9+.-]*:/iu.test(raw) && !raw.startsWith(\"//\")) {\n truncated = true;\n continue;\n }\n try {\n const url = new URL(raw, base);\n if (![\"https:\", \"http:\"].includes(url.protocol) ||\n url.username || url.password || url.port) continue;\n if (url.origin !== new URL(sourceUrl).origin) {\n external.add(url.origin);\n continue;\n }\n if (url.search || raw.includes(\"?\")) {\n queryLinks++;\n continue;\n }\n url.hash = \"\";\n const safe = boundedUrl(url.href);\n if (safe) links.add(safe);\n } catch { /* No graph edge for unsafe or invalid URLs. */ }\n }\n const scripts = $(\"script\").toArray();\n const snapshot: RenderSnapshot = {\n title_present: Boolean(title), title_characters: title.length,\n description_present: Boolean(description), description_characters: description.length,\n h1_count: $(\"body h1\").length, main_words: words.length,\n same_origin_link_targets: links.size, query_links_excluded: queryLinks,\n external_link_targets: external.size,\n canonicals: canonicalState, noindex_declared: metaNoindex,\n jsonld_blocks: scripts.filter((el) =>\n ($(el).attr(\"type\") ?? \"\").trim().toLowerCase() === \"application/ld+json\").length,\n external_script_tags: scripts.filter((el) =>\n Boolean($(el).attr(\"src\"))).length,\n inline_script_tags: scripts.filter((el) =>\n !$(el).attr(\"src\") && ![\"application/ld+json\", \"application/json\"].includes(\n ($(el).attr(\"type\") ?? \"\").trim().toLowerCase())).length,\n sample_truncated: truncated || root.text().length > 100_000,\n };\n return { snapshot, title, firstH1: $(\"body h1\").first().text().trim().slice(0, 600),\n canonicalState, canonicalSet: normalizedCanonicals,\n links, words: new Set(words) };\n}\nconst limitations = [\n \"This tool compares supplied source and rendered HTML snapshots; it does not verify Googlebot, Google Web Rendering Service, indexing, search results or historical production behavior.\",\n \"Browser inline-script mode executes only local inline JavaScript in fresh, network-denied Chromium; external modules, frameworks, APIs, fonts, images and stylesheets do not load.\",\n \"Static DOM comparisons do not prove visual visibility, interactivity, hydration success, accessibility, semantic equivalence or actual loaded resource availability.\",\n \"All URL paths, titles, headings, text and script/console contents are omitted from output. Links with queries are excluded; only capped same-origin path-only links are compared.\",\n];\nexport function emptyRawRenderedReview(\n scope: RenderScope = \"caller_supplied_rendered_snapshot\",\n): RawRenderedReview {\n const blank: RenderSnapshot = {\n title_present: false, title_characters: 0,\n description_present: false, description_characters: 0,\n h1_count: 0, main_words: 0, same_origin_link_targets: 0,\n query_links_excluded: 0, external_link_targets: 0,\n canonicals: \"missing\", noindex_declared: false,\n jsonld_blocks: 0, external_script_tags: 0,\n inline_script_tags: 0, sample_truncated: false,\n };\n return {\n scope, browser_executed: false, inline_scripts_attempted: false,\n external_resources_blocked: 0, script_errors_observed: 0,\n raw: { ...blank }, rendered: { ...blank },\n title_changed: false, h1_changed: false, canonical_changed: false,\n noindex_changed: false, shared_main_words: 0,\n main_words_removed: 0, main_words_added: 0,\n link_targets_removed: 0, link_targets_added: 0,\n unchanged_link_targets: 0, coverage_limited: true,\n limitations, total_findings: 0, findings: [], findings_truncated: false,\n };\n}\n\nexport function analyzeRawRendered(input: RawRenderedInput,\n evidence: RenderEvidence = {}): RawRenderedReview {\n const url = boundedUrl(input?.page_url);\n if (!url || typeof input.raw_html !== \"string\" || !input.raw_html.trim() ||\n typeof input.rendered_html !== \"string\" || !input.rendered_html.trim() ||\n bytes(input.raw_html) > MAX_RENDER_HTML_BYTES ||\n bytes(input.rendered_html) > MAX_RENDER_HTML_BYTES ||\n bytes(input.raw_html) + bytes(input.rendered_html) > MAX_RENDER_TOTAL_HTML_BYTES) {\n throw new Error(\"Provide a safe page URL and two bounded HTML snapshots.\");\n }\n const raw = inspect(input.raw_html, url);\n const rendered = inspect(input.rendered_html, url);\n const report = emptyRawRenderedReview(evidence.scope);\n report.browser_executed = evidence.browser_executed === true;\n report.inline_scripts_attempted = evidence.inline_scripts_attempted === true;\n report.external_resources_blocked = Math.min(1000,\n Math.max(0, evidence.external_resources_blocked ?? 0));\n report.script_errors_observed = Math.min(100,\n Math.max(0, evidence.script_errors_observed ?? 0));\n report.raw = raw.snapshot;\n report.rendered = rendered.snapshot;\n report.title_changed = raw.title !== rendered.title;\n report.h1_changed = raw.firstH1 !== rendered.firstH1;\n report.canonical_changed = raw.canonicalState !== rendered.canonicalState ||\n raw.canonicalSet.size !== rendered.canonicalSet.size ||\n [...raw.canonicalSet].some((value) => !rendered.canonicalSet.has(value));\n report.noindex_changed = raw.snapshot.noindex_declared !== rendered.snapshot.noindex_declared;\n report.shared_main_words = [...raw.words].filter((word) => rendered.words.has(word)).length;\n report.main_words_removed = [...raw.words].filter((word) => !rendered.words.has(word)).length;\n report.main_words_added = [...rendered.words].filter((word) => !raw.words.has(word)).length;\n report.link_targets_removed = [...raw.links].filter((target) => !rendered.links.has(target)).length;\n report.link_targets_added = [...rendered.links].filter((target) => !raw.links.has(target)).length;\n report.unchanged_link_targets = [...raw.links].filter((target) => rendered.links.has(target)).length;\n const records: RenderFinding[] = [];\n const add = (code: RenderFindingCode, severity: RenderFinding[\"severity\"], message: string) =>\n records.push({ code, severity, message });\n if (report.raw.title_present && !report.rendered.title_present) add(\"title_removed\",\n \"warning\", \"An observed source title is absent from the rendered DOM.\");\n else if (!report.raw.title_present && report.rendered.title_present) add(\"title_added\",\n \"info\", \"A title appears only after rendering; non-rendering crawlers may not see it.\");\n else if (report.title_changed) add(\"title_changed\", \"info\",\n \"The rendered title differs from the HTTP source title.\");\n if (report.raw.description_present && !report.rendered.description_present) add(\"description_removed\",\n \"warning\", \"A source meta description is absent from the rendered DOM.\");\n else if (!report.raw.description_present && report.rendered.description_present) add(\"description_added\",\n \"info\", \"The rendered DOM adds a meta description not present in source HTML.\");\n if (report.raw.h1_count > 0 && report.rendered.h1_count === 0) add(\"h1_removed\",\n \"warning\", \"A source H1 heading was absent after rendering.\");\n else if (report.raw.h1_count === 0 && report.rendered.h1_count > 0) add(\"h1_added\",\n \"info\", \"The rendered DOM introduces an H1 absent in source HTML.\");\n if (report.raw.main_words >= 20 &&\n report.rendered.main_words < Math.floor(report.raw.main_words * 0.65)) {\n add(\"main_text_dropped\", \"warning\",\n \"Rendered main content has substantially fewer words than the supplied source.\");\n } else if (report.rendered.main_words >= 20 &&\n report.raw.main_words < Math.floor(report.rendered.main_words * 0.65)) {\n add(\"main_text_added\", \"info\",\n \"Main textual content is predominantly rendered rather than available in source.\");\n } else if (report.main_words_removed > 15 && report.raw.main_words >= 20) {\n add(\"main_text_changed\", \"info\",\n \"Some distinct source text tokens were absent in the rendered sample.\");\n }\n if (report.link_targets_removed) add(\"links_removed\", \"warning\",\n \"One or more source same-origin links are absent in the rendered DOM.\");\n if (report.link_targets_added) add(\"links_added\", \"info\",\n \"One or more same-origin links appear only in the rendered DOM.\");\n if (!report.raw.noindex_declared && report.rendered.noindex_declared) add(\"noindex_added\",\n \"warning\", \"The rendered head declares noindex absent in source; verify indexing intentions.\");\n if (report.raw.noindex_declared && !report.rendered.noindex_declared) add(\"noindex_removed\",\n \"warning\", \"The source noindex declaration is missing after rendering; verify effective directives.\");\n if (report.canonical_changed) add(\"canonical_changed\", \"warning\",\n \"The observed canonical declaration changes during rendering.\");\n if (report.rendered.jsonld_blocks < report.raw.jsonld_blocks) add(\"jsonld_removed\",\n \"info\", \"Some source JSON-LD blocks are no longer present in the rendered DOM.\");\n if (report.rendered.jsonld_blocks > report.raw.jsonld_blocks) add(\"jsonld_added\",\n \"info\", \"Additional JSON-LD script blocks appear in the rendered DOM.\");\n if (report.browser_executed && report.raw.external_script_tags) add(\"external_scripts_blocked\",\n \"info\", \"External scripts were not loaded in the isolated offline browser; hydration may be incomplete.\");\n if (report.browser_executed && report.external_resources_blocked) add(\"resources_blocked\",\n \"info\", \"Chromium attempted one or more external resource requests, all blocked.\");\n if (report.browser_executed && report.script_errors_observed) add(\"script_errors_observed\",\n \"info\", \"One or more JavaScript runtime errors occurred; error text was discarded.\");\n if (report.raw.sample_truncated || report.rendered.sample_truncated) add(\"snapshot_coverage_limited\",\n \"info\", \"Link or text sampling reached a fixed cap; some DOM evidence was not compared.\");\n records.sort((a, b) => (a.severity === b.severity ? 0 : a.severity === \"warning\" ? -1 : 1)\n || a.code.localeCompare(b.code));\n report.total_findings = records.length;\n report.findings = records.slice(0, MAX_RENDER_FINDINGS);\n report.findings_truncated = records.length > MAX_RENDER_FINDINGS;\n return report;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"raw-rendered-diff.js","sourceRoot":"","sources":["../../../src/modules/browser-ux/raw-rendered-diff.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,+BAA+B;AAC/B;;;;GAIG;AACH,O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C,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;WACrF,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;IACnC,MAAM,CAAC,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC;IACvC,MAAM,CAAC,QAAQ,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,mBAAmB,CAAC,CAAC;IACxD,MAAM,CAAC,kBAAkB,GAAG,OAAO,CAAC,MAAM,GAAG,mBAAmB,CAAC;IACjE,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["// Copyright (c) 2026 AKzar1el and Web Validator contributors\n// SPDX-License-Identifier: MIT\n/**\n * V07: deterministic, redacted comparison of HTTP source HTML and a browser\n * rendered DOM snapshot. This analyzer is pure; Chromium is a separate local\n * probe. Rendering is NOT equivalent to Google WRS or its index decision.\n */\nimport { load } from \"cheerio\";\nimport type { AnyNode } from \"domhandler\";\nimport { safeLinkPageUrl } from \"../site-architecture/internal-link-quality.js\";\n\nexport const MAX_RENDER_HTML_BYTES = 524_288;\nexport const MAX_RENDER_TOTAL_HTML_BYTES = 1_048_576;\nexport const MAX_RENDER_FINDINGS = 18;\nexport const MAX_RENDER_LINKS = 200;\nexport const MAX_RENDER_WORDS = 10_000;\nexport const MAX_RENDER_BROWSER_MS = 15_000;\n\nexport const RENDER_FINDING_CODES = [\n \"title_removed\", \"title_added\", \"title_changed\",\n \"description_removed\", \"description_added\",\n \"h1_removed\", \"h1_added\",\n \"main_text_dropped\", \"main_text_added\", \"main_text_changed\",\n \"links_removed\", \"links_added\",\n \"noindex_added\", \"noindex_removed\",\n \"canonical_changed\", \"jsonld_removed\", \"jsonld_added\",\n \"external_scripts_blocked\", \"resources_blocked\",\n \"script_errors_observed\", \"snapshot_coverage_limited\",\n] as const;\nexport type RenderFindingCode = typeof RENDER_FINDING_CODES[number];\nexport type RenderScope =\n \"caller_supplied_rendered_snapshot\" | \"isolated_inline_script_chromium\" |\n \"isolated_public_html_inline_script_sample\";\n\nexport interface RawRenderedInput {\n page_url: string;\n raw_html: string;\n rendered_html: string;\n}\nexport interface RenderEvidence {\n scope?: RenderScope;\n browser_executed?: boolean;\n inline_scripts_attempted?: boolean;\n external_resources_blocked?: number;\n script_errors_observed?: number;\n}\nexport interface RenderSnapshot {\n title_present: boolean;\n title_characters: number;\n description_present: boolean;\n description_characters: number;\n h1_count: number;\n main_words: number;\n same_origin_link_targets: number;\n query_links_excluded: number;\n external_link_targets: number;\n canonicals: \"missing\" | \"self\" | \"different\" | \"ambiguous\";\n noindex_declared: boolean;\n jsonld_blocks: number;\n external_script_tags: number;\n inline_script_tags: number;\n sample_truncated: boolean;\n}\nexport interface RenderFinding {\n code: RenderFindingCode;\n severity: \"warning\" | \"info\";\n message: string;\n}\nexport interface RawRenderedReview {\n scope: RenderScope;\n browser_executed: boolean;\n inline_scripts_attempted: boolean;\n external_resources_blocked: number;\n script_errors_observed: number;\n raw: RenderSnapshot;\n rendered: RenderSnapshot;\n title_changed: boolean;\n h1_changed: boolean;\n canonical_changed: boolean;\n noindex_changed: boolean;\n shared_main_words: number;\n main_words_removed: number;\n main_words_added: number;\n link_targets_removed: number;\n link_targets_added: number;\n unchanged_link_targets: number;\n coverage_limited: true;\n limitations: string[];\n total_findings: number;\n findings: RenderFinding[];\n findings_truncated: boolean;\n error?: string;\n}\n\nconst encoder = new TextEncoder();\nconst bytes = (value: string): number => encoder.encode(value).byteLength;\nfunction boundedUrl(value: unknown): string | undefined {\n if (typeof value !== \"string\" || bytes(value) > 512 ||\n /[\\u0000-\\u001f\\u007f-\\u009f\\u202a-\\u202e\\u2066-\\u2069\\\\]/u.test(value)) return undefined;\n return safeLinkPageUrl(value);\n}\nconst noindexPattern = /(?:^|[\\s,;])(?:noindex|none)(?:$|[\\s,;])/iu;\nconst hasRel = (raw: string | undefined, token: string): boolean =>\n (raw ?? \"\").toLowerCase().split(/\\s+/u).includes(token);\nconst textWords = (raw: string): string[] =>\n (raw.normalize(\"NFKC\").toLocaleLowerCase(\"en\").match(/[\\p{L}\\p{N}]+/gu) ?? [])\n .filter((word) => word.length >= 2 && word.length <= 60)\n .slice(0, MAX_RENDER_WORDS + 1);\n\nconst excludedMainDescendants = new Set([\n \"script\", \"style\", \"noscript\", \"template\", \"svg\", \"nav\", \"header\", \"footer\", \"aside\",\n]);\n\n// Preserve textContent ordering and adjacency without cloning or recursively\n// traversing arbitrarily deep caller-supplied HTML. Exclusions apply only to\n// descendants, just as the previous clone().find(...).remove() did.\nfunction snapshotText(root: AnyNode | undefined, excluded?: ReadonlySet<string>): string {\n if (!root) return \"\";\n const pending: AnyNode[] = [root];\n const chunks: string[] = [];\n while (pending.length > 0) {\n const node = pending.pop()!;\n if (node !== root && \"name\" in node && excluded?.has(node.name)) continue;\n if (node.type === \"text\") {\n chunks.push(node.data);\n } else if (\"children\" in node) {\n for (let i = node.children.length - 1; i >= 0; i--) pending.push(node.children[i]!);\n }\n }\n return chunks.join(\"\");\n}\n\nfunction inspect(html: string, sourceUrl: string) {\n const $ = load(html);\n const head = $(\"head\");\n const title = snapshotText(head.find(\"title\").first().get(0)).replace(/\\s+/gu, \" \").trim().slice(0, 600);\n const description = head.find('meta[name=\"description\" i]').first()\n .attr(\"content\")?.replace(/\\s+/gu, \" \").trim().slice(0, 1200) ?? \"\";\n const metaNoindex = head.find(\"meta[name][content]\").toArray().some((el) => {\n const name = ($(el).attr(\"name\") ?? \"\").trim().toLowerCase();\n return [\"robots\", \"googlebot\"].includes(name) &&\n noindexPattern.test($(el).attr(\"content\") ?? \"\");\n });\n const baseHref = head.find(\"base[href]\").first().attr(\"href\");\n let canonicalBase: string | undefined = sourceUrl;\n if (baseHref !== undefined) {\n try { canonicalBase = boundedUrl(new URL(baseHref, sourceUrl).href); }\n catch { canonicalBase = undefined; }\n }\n const canonicals = head.find(\"link[rel][href]\").toArray().filter((el) =>\n hasRel($(el).attr(\"rel\"), \"canonical\"));\n const normalizedCanonicals = new Set<string>();\n let ambiguousCanonical = false;\n for (const el of canonicals) {\n const href = $(el).attr(\"href\");\n if (!href) { ambiguousCanonical = true; continue; }\n // An excluded document base makes relative identities uncertain, but\n // does not affect a fully qualified HTTP(S) canonical declaration.\n if (!canonicalBase && !/^https?:\\/\\//iu.test(href.trim())) {\n ambiguousCanonical = true;\n continue;\n }\n try {\n const url = new URL(href, canonicalBase);\n url.hash = \"\";\n const safe = boundedUrl(url.href);\n if (safe) normalizedCanonicals.add(safe);\n else ambiguousCanonical = true;\n } catch { ambiguousCanonical = true; }\n }\n const canonicalState = canonicals.length === 0 ? \"missing\" :\n ambiguousCanonical || normalizedCanonicals.size !== 1 ? \"ambiguous\" :\n normalizedCanonicals.has(sourceUrl) ? \"self\" : \"different\";\n // Evaluate only text visible in the source HTML structure, not CSS computed\n // visibility or Google-selected content. Dynamic styles are out of scope.\n const mainCandidates = $(\"main,[role='main'],article\").toArray();\n // Cheerio exposes inert template descendants through document-wide selectors.\n const outsideTemplate = (el: (typeof mainCandidates)[number]) => {\n if (el.name === \"template\") return false;\n for (let ancestor = el.parent; ancestor; ancestor = ancestor.parent) {\n if (ancestor.type === \"tag\" && ancestor.name === \"template\") return false;\n }\n return true;\n };\n const main = mainCandidates.find(outsideTemplate);\n const root = main ?? $(\"body\").first().get(0);\n const mainText = snapshotText(root, excludedMainDescendants);\n const sampledWords = textWords(mainText);\n const wordsTruncated = sampledWords.length > MAX_RENDER_WORDS || mainText.length > 100_000;\n const words = sampledWords.slice(0, MAX_RENDER_WORDS);\n const links = new Set<string>();\n const external = new Set<string>();\n let queryLinks = 0;\n let linksTruncated = false;\n // Link comparison remains restricted to the source origin, even when a\n // safe cross-origin base can resolve canonical identity for comparison.\n const unsafeBase = !canonicalBase || new URL(canonicalBase).origin !== new URL(sourceUrl).origin;\n const base = unsafeBase ? sourceUrl : canonicalBase!;\n const anchors = $(\"body a[href]\").toArray();\n if (anchors.length > MAX_RENDER_LINKS) linksTruncated = true;\n for (const el of anchors.slice(0, MAX_RENDER_LINKS)) {\n const raw = ($(el).attr(\"href\") ?? \"\").trim();\n if (!raw || raw.length > 1024 || raw.startsWith(\"#\")) continue;\n if (unsafeBase && !/^[a-z][a-z0-9+.-]*:/iu.test(raw) && !raw.startsWith(\"//\")) {\n linksTruncated = true;\n continue;\n }\n try {\n const url = new URL(raw, base);\n if (![\"https:\", \"http:\"].includes(url.protocol) ||\n url.username || url.password || url.port) continue;\n if (url.origin !== new URL(sourceUrl).origin) {\n external.add(url.origin);\n continue;\n }\n if (url.search || raw.includes(\"?\")) {\n queryLinks++;\n continue;\n }\n url.hash = \"\";\n const safe = boundedUrl(url.href);\n if (safe) links.add(safe);\n } catch { /* No graph edge for unsafe or invalid URLs. */ }\n }\n // Template contents are inert until instantiated, even when Cheerio exposes\n // their scripts through the document-wide selector.\n const scripts = $(\"script\").toArray().filter(outsideTemplate);\n const scriptMediaType = (el: (typeof scripts)[number]) =>\n (($(el).attr(\"type\") ?? \"\").split(\";\", 1)[0] ?? \"\").trim().toLowerCase();\n const snapshot: RenderSnapshot = {\n title_present: Boolean(title), title_characters: title.length,\n description_present: Boolean(description), description_characters: description.length,\n h1_count: $(\"body h1\").length, main_words: words.length,\n same_origin_link_targets: links.size, query_links_excluded: queryLinks,\n external_link_targets: external.size,\n canonicals: canonicalState, noindex_declared: metaNoindex,\n jsonld_blocks: scripts.filter((el) =>\n scriptMediaType(el) === \"application/ld+json\").length,\n external_script_tags: scripts.filter((el) =>\n Boolean($(el).attr(\"src\"))).length,\n inline_script_tags: scripts.filter((el) =>\n !$(el).attr(\"src\") && ![\"application/ld+json\", \"application/json\"].includes(\n scriptMediaType(el))).length,\n sample_truncated: linksTruncated || wordsTruncated,\n };\n return { snapshot, title, firstH1: snapshotText($(\"body h1\").first().get(0)).trim().slice(0, 600),\n canonicalState, canonicalSet: normalizedCanonicals,\n links, words: new Set(words), linksTruncated, wordsTruncated };\n}\nconst limitations = [\n \"This tool compares supplied source and rendered HTML snapshots; it does not verify Googlebot, Google Web Rendering Service, indexing, search results or historical production behavior.\",\n \"Browser inline-script mode executes only local inline JavaScript in fresh, network-denied Chromium; external modules, frameworks, APIs, fonts, images and stylesheets do not load.\",\n \"Static DOM comparisons do not prove visual visibility, interactivity, hydration success, accessibility, semantic equivalence or actual loaded resource availability.\",\n \"All URL paths, titles, headings, text and script/console contents are omitted from output. Links with queries are excluded; only capped same-origin path-only links are compared. Numeric deltas describe samples when coverage is incomplete.\",\n];\nexport function emptyRawRenderedReview(\n scope: RenderScope = \"caller_supplied_rendered_snapshot\",\n): RawRenderedReview {\n const blank: RenderSnapshot = {\n title_present: false, title_characters: 0,\n description_present: false, description_characters: 0,\n h1_count: 0, main_words: 0, same_origin_link_targets: 0,\n query_links_excluded: 0, external_link_targets: 0,\n canonicals: \"missing\", noindex_declared: false,\n jsonld_blocks: 0, external_script_tags: 0,\n inline_script_tags: 0, sample_truncated: false,\n };\n return {\n scope, browser_executed: false, inline_scripts_attempted: false,\n external_resources_blocked: 0, script_errors_observed: 0,\n raw: { ...blank }, rendered: { ...blank },\n title_changed: false, h1_changed: false, canonical_changed: false,\n noindex_changed: false, shared_main_words: 0,\n main_words_removed: 0, main_words_added: 0,\n link_targets_removed: 0, link_targets_added: 0,\n unchanged_link_targets: 0, coverage_limited: true,\n limitations, total_findings: 0, findings: [], findings_truncated: false,\n };\n}\n\nexport function analyzeRawRendered(input: RawRenderedInput,\n evidence: RenderEvidence = {}): RawRenderedReview {\n const url = boundedUrl(input?.page_url);\n if (!url || typeof input.raw_html !== \"string\" || !input.raw_html.trim() ||\n typeof input.rendered_html !== \"string\" || !input.rendered_html.trim() ||\n bytes(input.raw_html) > MAX_RENDER_HTML_BYTES ||\n bytes(input.rendered_html) > MAX_RENDER_HTML_BYTES ||\n bytes(input.raw_html) + bytes(input.rendered_html) > MAX_RENDER_TOTAL_HTML_BYTES) {\n throw new Error(\"Provide a safe page URL and two bounded HTML snapshots.\");\n }\n const raw = inspect(input.raw_html, url);\n const rendered = inspect(input.rendered_html, url);\n const report = emptyRawRenderedReview(evidence.scope);\n report.browser_executed = evidence.browser_executed === true;\n report.inline_scripts_attempted = evidence.inline_scripts_attempted === true;\n report.external_resources_blocked = Math.min(1000,\n Math.max(0, evidence.external_resources_blocked ?? 0));\n report.script_errors_observed = Math.min(100,\n Math.max(0, evidence.script_errors_observed ?? 0));\n report.raw = raw.snapshot;\n report.rendered = rendered.snapshot;\n report.title_changed = raw.title !== rendered.title;\n report.h1_changed = raw.firstH1 !== rendered.firstH1;\n report.canonical_changed = raw.canonicalState !== rendered.canonicalState ||\n raw.canonicalSet.size !== rendered.canonicalSet.size ||\n [...raw.canonicalSet].some((value) => !rendered.canonicalSet.has(value));\n report.noindex_changed = raw.snapshot.noindex_declared !== rendered.snapshot.noindex_declared;\n report.shared_main_words = [...raw.words].filter((word) => rendered.words.has(word)).length;\n report.main_words_removed = [...raw.words].filter((word) => !rendered.words.has(word)).length;\n report.main_words_added = [...rendered.words].filter((word) => !raw.words.has(word)).length;\n report.link_targets_removed = [...raw.links].filter((target) => !rendered.links.has(target)).length;\n report.link_targets_added = [...rendered.links].filter((target) => !raw.links.has(target)).length;\n report.unchanged_link_targets = [...raw.links].filter((target) => rendered.links.has(target)).length;\n const records: RenderFinding[] = [];\n const add = (code: RenderFindingCode, severity: RenderFinding[\"severity\"], message: string) =>\n records.push({ code, severity, message });\n if (report.raw.title_present && !report.rendered.title_present) add(\"title_removed\",\n \"warning\", \"An observed source title is absent from the rendered DOM.\");\n else if (!report.raw.title_present && report.rendered.title_present) add(\"title_added\",\n \"info\", \"A title appears only after rendering; non-rendering crawlers may not see it.\");\n else if (report.title_changed) add(\"title_changed\", \"info\",\n \"The rendered title differs from the HTTP source title.\");\n if (report.raw.description_present && !report.rendered.description_present) add(\"description_removed\",\n \"warning\", \"A source meta description is absent from the rendered DOM.\");\n else if (!report.raw.description_present && report.rendered.description_present) add(\"description_added\",\n \"info\", \"The rendered DOM adds a meta description not present in source HTML.\");\n if (report.raw.h1_count > 0 && report.rendered.h1_count === 0) add(\"h1_removed\",\n \"warning\", \"A source H1 heading was absent after rendering.\");\n else if (report.raw.h1_count === 0 && report.rendered.h1_count > 0) add(\"h1_added\",\n \"info\", \"The rendered DOM introduces an H1 absent in source HTML.\");\n // Absence requires complete coverage on the side where evidence is missing.\n // A capped count on the other side remains a conservative lower bound.\n if (!rendered.wordsTruncated && report.raw.main_words >= 20 &&\n report.rendered.main_words < Math.floor(report.raw.main_words * 0.65)) {\n add(\"main_text_dropped\", \"warning\",\n \"Rendered main content has substantially fewer words than the supplied source.\");\n } else if (!raw.wordsTruncated && report.rendered.main_words >= 20 &&\n report.raw.main_words < Math.floor(report.rendered.main_words * 0.65)) {\n add(\"main_text_added\", \"info\",\n \"Main textual content is predominantly rendered rather than available in source.\");\n } else if (!rendered.wordsTruncated && report.main_words_removed > 15 && report.raw.main_words >= 20) {\n add(\"main_text_changed\", \"info\",\n \"Some distinct source text tokens were absent in the rendered sample.\");\n }\n if (!rendered.linksTruncated && report.link_targets_removed) add(\"links_removed\", \"warning\",\n \"One or more source same-origin links are absent in the rendered DOM.\");\n if (!raw.linksTruncated && report.link_targets_added) add(\"links_added\", \"info\",\n \"One or more same-origin links appear only in the rendered DOM.\");\n if (!report.raw.noindex_declared && report.rendered.noindex_declared) add(\"noindex_added\",\n \"warning\", \"The rendered head declares noindex absent in source; verify indexing intentions.\");\n if (report.raw.noindex_declared && !report.rendered.noindex_declared) add(\"noindex_removed\",\n \"warning\", \"The source noindex declaration is missing after rendering; verify effective directives.\");\n if (report.canonical_changed) add(\"canonical_changed\", \"warning\",\n \"The observed canonical declaration changes during rendering.\");\n if (report.rendered.jsonld_blocks < report.raw.jsonld_blocks) add(\"jsonld_removed\",\n \"info\", \"Some source JSON-LD blocks are no longer present in the rendered DOM.\");\n if (report.rendered.jsonld_blocks > report.raw.jsonld_blocks) add(\"jsonld_added\",\n \"info\", \"Additional JSON-LD script blocks appear in the rendered DOM.\");\n if (report.browser_executed && report.raw.external_script_tags) add(\"external_scripts_blocked\",\n \"info\", \"External scripts were not loaded in the isolated offline browser; hydration may be incomplete.\");\n if (report.browser_executed && report.external_resources_blocked) add(\"resources_blocked\",\n \"info\", \"Chromium attempted one or more external resource requests, all blocked.\");\n if (report.browser_executed && report.script_errors_observed) add(\"script_errors_observed\",\n \"info\", \"One or more JavaScript runtime errors occurred; error text was discarded.\");\n if (report.raw.sample_truncated || report.rendered.sample_truncated) {\n add(\"snapshot_coverage_limited\", \"info\",\n \"Link or text coverage is incomplete; absence findings require complete coverage on the relevant side.\");\n }\n records.sort((a, b) => (a.severity === b.severity ? 0 : a.severity === \"warning\" ? -1 : 1)\n || a.code.localeCompare(b.code));\n report.total_findings = records.length;\n report.findings = records.slice(0, MAX_RENDER_FINDINGS);\n report.findings_truncated = records.length > MAX_RENDER_FINDINGS;\n return report;\n}\n"]}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// Copyright (c) 2026 AKzar1el and Web Validator contributors
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
1
3
|
/**
|
|
2
4
|
* Local-only V07 Chromium evidence. Supplied or publicly fetched HTML is
|
|
3
5
|
* loaded into a fresh offline browser, executing inline JS ONLY. No page URL
|
|
@@ -12,6 +14,8 @@ import { safeHttpResourceUrl } from "../http-crawl/non-html-directives.js";
|
|
|
12
14
|
import { analyzeRawRendered, MAX_RENDER_HTML_BYTES, MAX_RENDER_BROWSER_MS, } from "./raw-rendered-diff.js";
|
|
13
15
|
const DENY_ALL_PROXY = "http://127.0.0.1:9";
|
|
14
16
|
const SERVICE_UA = "DigestSEO-Web-Validator/1.3";
|
|
17
|
+
// parse5's serializer is recursive; the byte cap alone does not bound its stack.
|
|
18
|
+
const MAX_RENDER_DOM_DEPTH = 512;
|
|
15
19
|
const bytes = (s) => new TextEncoder().encode(s).byteLength;
|
|
16
20
|
const guard = (value) => {
|
|
17
21
|
const safe = safeHttpResourceUrl(value);
|
|
@@ -25,6 +29,19 @@ async function cancel(response) {
|
|
|
25
29
|
}
|
|
26
30
|
catch { /* Already exhausted. */ }
|
|
27
31
|
}
|
|
32
|
+
function assertSerializableDepth(root) {
|
|
33
|
+
const pending = [{ node: root, depth: 0 }];
|
|
34
|
+
while (pending.length > 0) {
|
|
35
|
+
const { node, depth } = pending.pop();
|
|
36
|
+
if (depth > MAX_RENDER_DOM_DEPTH) {
|
|
37
|
+
throw new Error("Normalized source HTML exceeds the render DOM depth cap.");
|
|
38
|
+
}
|
|
39
|
+
if ("children" in node) {
|
|
40
|
+
for (const child of node.children)
|
|
41
|
+
pending.push({ node: child, depth: depth + 1 });
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
28
45
|
/**
|
|
29
46
|
* Render supplied static HTML with scripts allowed, but external script/src,
|
|
30
47
|
* embedded frames, meta refresh and all network requests blocked. A real
|
|
@@ -40,6 +57,7 @@ export async function renderInlineHtml(rawHtml, pageUrl, runtime = defaultScreen
|
|
|
40
57
|
// Inline JavaScript is the only executable source allowed into Chromium.
|
|
41
58
|
$("script[src],iframe,frame,frameset,object,embed,portal").remove();
|
|
42
59
|
$('meta[http-equiv="refresh" i]').remove();
|
|
60
|
+
assertSerializableDepth($.root()[0]);
|
|
43
61
|
const sanitized = $.html();
|
|
44
62
|
if (bytes(sanitized) > MAX_RENDER_HTML_BYTES) {
|
|
45
63
|
throw new Error("Normalized source HTML exceeds the render byte cap.");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"raw-rendered-probe.js","sourceRoot":"","sources":["../../../src/modules/browser-ux/raw-rendered-probe.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,OAAO,EACL,+BAA+B,GAChC,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,eAAe,EAAE,gBAAgB,EAAE,oBAAoB,GACxD,MAAM,kBAA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1F,CAAC;QACD,MAAM,OAAO,GAAG,wCAAwC;aACrD,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QACzD,OAAO,GAAG,MAAM,gBAAgB,CAAC,QAAQ,EAAE,qBAAqB,EAAE,OAAO,EAAE,CAAC,OAAO,CAAC,CAAC;IACvF,CAAC;YAAS,CAAC;QAAC,MAAM,MAAM,CAAC,QAAQ,CAAC,CAAC;IAAC,CAAC;IACrC,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC;AAC/C,CAAC;AAED;mEACmE;AACnE,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,GAAW,EACX,OAAO,GAA6B,+BAA+B;IAEnE,MAAM,MAAM,GAAG,MAAM,sBAAsB,CAAC,GAAG,CAAC,CAAC;IACjD,OAAO,gBAAgB,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,OAAO,EAC/D,2CAA2C,CAAC,CAAC;AACjD,CAAC","sourcesContent":["/**\n * Local-only V07 Chromium evidence. Supplied or publicly fetched HTML is\n * loaded into a fresh offline browser, executing inline JS ONLY. No page URL\n * navigation, third-party or first-party subresources, cookies, credentials,\n * local files, screenshots or persistent browser profile.\n */\nimport { load } from \"cheerio\";\nimport {\n defaultScreenshotBrowserRuntime, type ScreenshotBrowserRuntime,\n} from \"../../screenshot.js\";\nimport {\n fetchPublicHttp, readResponseText, resolvePublicHttpUrl,\n} from \"../../network.js\";\nimport {\n isAllowedForFetcher, MAX_CRAWLER_ROBOTS_BYTES,\n} from \"../http-crawl/crawler-access.js\";\nimport { safeHttpResourceUrl } from \"../http-crawl/non-html-directives.js\";\nimport {\n analyzeRawRendered, MAX_RENDER_HTML_BYTES, MAX_RENDER_BROWSER_MS,\n type RawRenderedReview, type RenderScope,\n} from \"./raw-rendered-diff.js\";\n\nconst DENY_ALL_PROXY = \"http://127.0.0.1:9\";\nconst SERVICE_UA = \"DigestSEO-Web-Validator/1.3\";\nconst bytes = (s: string) => new TextEncoder().encode(s).byteLength;\nconst guard = (value: string) => {\n const safe = safeHttpResourceUrl(value);\n if (!safe) throw new Error(\"Supply one safe public query-free HTTP(S) page URL.\");\n return safe;\n};\nasync function cancel(response: Response) {\n try { await response.body?.cancel(); } catch { /* Already exhausted. */ }\n}\n\n/**\n * Render supplied static HTML with scripts allowed, but external script/src,\n * embedded frames, meta refresh and all network requests blocked. A real\n * Google WRS render requires external assets and is NOT simulated here.\n */\nexport async function renderInlineHtml(\n rawHtml: string, pageUrl: string,\n runtime: ScreenshotBrowserRuntime = defaultScreenshotBrowserRuntime,\n scope: RenderScope = \"isolated_inline_script_chromium\",\n): Promise<RawRenderedReview> {\n guard(pageUrl);\n if (typeof rawHtml !== \"string\" || !rawHtml.trim() ||\n bytes(rawHtml) > MAX_RENDER_HTML_BYTES) {\n throw new Error(\"Raw HTML exceeds the bounded render input limit.\");\n }\n const $ = load(rawHtml);\n // Inline JavaScript is the only executable source allowed into Chromium.\n $(\"script[src],iframe,frame,frameset,object,embed,portal\").remove();\n $('meta[http-equiv=\"refresh\" i]').remove();\n const sanitized = $.html();\n if (bytes(sanitized) > MAX_RENDER_HTML_BYTES) {\n throw new Error(\"Normalized source HTML exceeds the render byte cap.\");\n }\n let browser: Awaited<ReturnType<ScreenshotBrowserRuntime[\"launch\"]>> | undefined;\n let deadline: ReturnType<typeof setTimeout> | undefined;\n let pendingError: unknown;\n try {\n browser = await runtime.launch(DENY_ALL_PROXY);\n deadline = setTimeout(() => {\n void browser?.close().catch(() => {});\n }, MAX_RENDER_BROWSER_MS);\n deadline.unref?.();\n const page = await browser.newPage();\n page.setDefaultTimeout(5_000);\n page.setDefaultNavigationTimeout(8_000);\n await page.setViewport({ width: 960, height: 720, deviceScaleFactor: 1 });\n await page.setJavaScriptEnabled(true);\n // Block *all* requests, including localhost and first-party script assets.\n await page.setOfflineMode(true);\n let blocked = 0, scriptErrors = 0;\n page.on(\"pageerror\", () => { scriptErrors++; });\n await page.setRequestInterception(true);\n page.on(\"request\", (request) => {\n blocked++;\n void request.abort(\"blockedbyclient\").catch(() => {});\n });\n page.on(\"dialog\", (dialog) => { void dialog.dismiss().catch(() => {}); });\n await page.setContent(sanitized, { waitUntil: \"domcontentloaded\", timeout: 8_000 });\n // Give a bounded microtask/short-timer opportunity without waiting for\n // network idle. Browser work is capped by the separate close deadline.\n await new Promise((resolve) => setTimeout(resolve, 250));\n const renderedHtml = await page.content();\n if (bytes(renderedHtml) > MAX_RENDER_HTML_BYTES) {\n throw new Error(\"The rendered DOM exceeded the bounded snapshot size.\");\n }\n return analyzeRawRendered({\n page_url: pageUrl, raw_html: rawHtml, rendered_html: renderedHtml,\n }, {\n scope, browser_executed: true, inline_scripts_attempted: true,\n external_resources_blocked: blocked, script_errors_observed: scriptErrors,\n });\n } catch (cause) {\n pendingError = cause;\n throw cause;\n } finally {\n if (deadline) clearTimeout(deadline);\n try { if (browser) await browser.close(); }\n catch (cause) { if (!pendingError) throw cause; }\n }\n}\n\n/** Shared V07/V09 guarded single-public-HTML source fetch.\n * Exactly one robots.txt and one page GET; never follows redirects. */\nexport async function fetchGuardedPublicHtml(url: string): Promise<{\n page_url: string; raw_html: string;\n}> {\n const safe = guard(url);\n await resolvePublicHttpUrl(safe);\n const origin = new URL(safe).origin;\n let robotsTxt: string | undefined;\n let robotsStatus: number | undefined;\n try {\n const { response } = await fetchPublicHttp(origin + \"/robots.txt\", {\n method: \"GET\", maxRedirects: 0, timeoutMs: 12_000,\n headers: { accept: \"text/plain\", \"user-agent\": SERVICE_UA },\n });\n robotsStatus = response.status;\n try {\n const type = response.headers.get(\"content-type\")\n ?.split(\";\", 1)[0].trim().toLowerCase();\n if (response.status === 200 && (!type || type === \"text/plain\")) {\n robotsTxt = await readResponseText(response, MAX_CRAWLER_ROBOTS_BYTES);\n }\n } finally { await cancel(response); }\n } catch { /* Unknown robots permission is not assumed allowed. */ }\n\n const allowed = robotsTxt !== undefined\n ? isAllowedForFetcher(robotsTxt, safe)\n : robotsStatus === 404 || robotsStatus === 410 ? true : undefined;\n if (allowed !== true) {\n throw new Error(\"The public page is robots-disallowed or crawl permission is unknown.\");\n }\n const { response } = await fetchPublicHttp(safe, {\n method: \"GET\", maxRedirects: 0, timeoutMs: 12_000,\n headers: { accept: \"text/html,application/xhtml+xml\", \"user-agent\": SERVICE_UA },\n });\n let rawHtml: string;\n try {\n const mime = response.headers.get(\"content-type\")\n ?.split(\";\", 1)[0].trim().toLowerCase();\n if (response.status !== 200 ||\n (mime !== \"text/html\" && mime !== \"application/xhtml+xml\") ||\n response.headers.get(\"cf-mitigated\") === \"challenge\") {\n throw new Error(\"The public HTTP sample is not a complete ordinary HTML 200 response.\");\n }\n const charset = /(?:^|;)\\s*charset\\s*=\\s*\"?([^;\\s\"]+)/iu\n .exec(response.headers.get(\"content-type\") ?? \"\")?.[1];\n rawHtml = await readResponseText(response, MAX_RENDER_HTML_BYTES, charset, !charset);\n } finally { await cancel(response); }\n return { page_url: safe, raw_html: rawHtml };\n}\n\n/** Fetch one authorized public HTML response, robots-gated, then render\n * a resource-denied inline-script DOM sample in local Chromium. */\nexport async function reviewPublicInlineDom(\n url: string,\n runtime: ScreenshotBrowserRuntime = defaultScreenshotBrowserRuntime,\n): Promise<RawRenderedReview> {\n const source = await fetchGuardedPublicHtml(url);\n return renderInlineHtml(source.raw_html, source.page_url, runtime,\n \"isolated_public_html_inline_script_sample\");\n}\n"]}
|
|
1
|
+
{"version":3,"file":"raw-rendered-probe.js","sourceRoot":"","sources":["../../../src/modules/browser-ux/raw-rendered-probe.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,+BAA+B;AAC/B;;;;;GAKG;AACH,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAE/B,OAAO,EACL,+BAA+B,GAChC,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,eAAe,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C,KAAK,UAAU,qBAAqB,CACzC,GAAW,EACX,OAAO,GAA6B,+BAA+B;IAEnE,MAAM,MAAM,GAAG,MAAM,sBAAsB,CAAC,GAAG,CAAC,CAAC;IACjD,OAAO,gBAAgB,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,OAAO,EAC/D,2CAA2C,CAAC,CAAC;AACjD,CAAC","sourcesContent":["// Copyright (c) 2026 AKzar1el and Web Validator contributors\n// SPDX-License-Identifier: MIT\n/**\n * Local-only V07 Chromium evidence. Supplied or publicly fetched HTML is\n * loaded into a fresh offline browser, executing inline JS ONLY. No page URL\n * navigation, third-party or first-party subresources, cookies, credentials,\n * local files, screenshots or persistent browser profile.\n */\nimport { load } from \"cheerio\";\nimport type { AnyNode } from \"domhandler\";\nimport {\n defaultScreenshotBrowserRuntime, type ScreenshotBrowserRuntime,\n} from \"../../screenshot.js\";\nimport {\n fetchPublicHttp, readResponseText, resolvePublicHttpUrl,\n} from \"../../network.js\";\nimport {\n isAllowedForFetcher, MAX_CRAWLER_ROBOTS_BYTES,\n} from \"../http-crawl/crawler-access.js\";\nimport { safeHttpResourceUrl } from \"../http-crawl/non-html-directives.js\";\nimport {\n analyzeRawRendered, MAX_RENDER_HTML_BYTES, MAX_RENDER_BROWSER_MS,\n type RawRenderedReview, type RenderScope,\n} from \"./raw-rendered-diff.js\";\n\nconst DENY_ALL_PROXY = \"http://127.0.0.1:9\";\nconst SERVICE_UA = \"DigestSEO-Web-Validator/1.3\";\n// parse5's serializer is recursive; the byte cap alone does not bound its stack.\nconst MAX_RENDER_DOM_DEPTH = 512;\nconst bytes = (s: string) => new TextEncoder().encode(s).byteLength;\nconst guard = (value: string) => {\n const safe = safeHttpResourceUrl(value);\n if (!safe) throw new Error(\"Supply one safe public query-free HTTP(S) page URL.\");\n return safe;\n};\nasync function cancel(response: Response) {\n try { await response.body?.cancel(); } catch { /* Already exhausted. */ }\n}\n\nfunction assertSerializableDepth(root: AnyNode): void {\n const pending = [{ node: root, depth: 0 }];\n while (pending.length > 0) {\n const { node, depth } = pending.pop()!;\n if (depth > MAX_RENDER_DOM_DEPTH) {\n throw new Error(\"Normalized source HTML exceeds the render DOM depth cap.\");\n }\n if (\"children\" in node) {\n for (const child of node.children) pending.push({ node: child, depth: depth + 1 });\n }\n }\n}\n\n/**\n * Render supplied static HTML with scripts allowed, but external script/src,\n * embedded frames, meta refresh and all network requests blocked. A real\n * Google WRS render requires external assets and is NOT simulated here.\n */\nexport async function renderInlineHtml(\n rawHtml: string, pageUrl: string,\n runtime: ScreenshotBrowserRuntime = defaultScreenshotBrowserRuntime,\n scope: RenderScope = \"isolated_inline_script_chromium\",\n): Promise<RawRenderedReview> {\n guard(pageUrl);\n if (typeof rawHtml !== \"string\" || !rawHtml.trim() ||\n bytes(rawHtml) > MAX_RENDER_HTML_BYTES) {\n throw new Error(\"Raw HTML exceeds the bounded render input limit.\");\n }\n const $ = load(rawHtml);\n // Inline JavaScript is the only executable source allowed into Chromium.\n $(\"script[src],iframe,frame,frameset,object,embed,portal\").remove();\n $('meta[http-equiv=\"refresh\" i]').remove();\n assertSerializableDepth($.root()[0]!);\n const sanitized = $.html();\n if (bytes(sanitized) > MAX_RENDER_HTML_BYTES) {\n throw new Error(\"Normalized source HTML exceeds the render byte cap.\");\n }\n let browser: Awaited<ReturnType<ScreenshotBrowserRuntime[\"launch\"]>> | undefined;\n let deadline: ReturnType<typeof setTimeout> | undefined;\n let pendingError: unknown;\n try {\n browser = await runtime.launch(DENY_ALL_PROXY);\n deadline = setTimeout(() => {\n void browser?.close().catch(() => {});\n }, MAX_RENDER_BROWSER_MS);\n deadline.unref?.();\n const page = await browser.newPage();\n page.setDefaultTimeout(5_000);\n page.setDefaultNavigationTimeout(8_000);\n await page.setViewport({ width: 960, height: 720, deviceScaleFactor: 1 });\n await page.setJavaScriptEnabled(true);\n // Block *all* requests, including localhost and first-party script assets.\n await page.setOfflineMode(true);\n let blocked = 0, scriptErrors = 0;\n page.on(\"pageerror\", () => { scriptErrors++; });\n await page.setRequestInterception(true);\n page.on(\"request\", (request) => {\n blocked++;\n void request.abort(\"blockedbyclient\").catch(() => {});\n });\n page.on(\"dialog\", (dialog) => { void dialog.dismiss().catch(() => {}); });\n await page.setContent(sanitized, { waitUntil: \"domcontentloaded\", timeout: 8_000 });\n // Give a bounded microtask/short-timer opportunity without waiting for\n // network idle. Browser work is capped by the separate close deadline.\n await new Promise((resolve) => setTimeout(resolve, 250));\n const renderedHtml = await page.content();\n if (bytes(renderedHtml) > MAX_RENDER_HTML_BYTES) {\n throw new Error(\"The rendered DOM exceeded the bounded snapshot size.\");\n }\n return analyzeRawRendered({\n page_url: pageUrl, raw_html: rawHtml, rendered_html: renderedHtml,\n }, {\n scope, browser_executed: true, inline_scripts_attempted: true,\n external_resources_blocked: blocked, script_errors_observed: scriptErrors,\n });\n } catch (cause) {\n pendingError = cause;\n throw cause;\n } finally {\n if (deadline) clearTimeout(deadline);\n try { if (browser) await browser.close(); }\n catch (cause) { if (!pendingError) throw cause; }\n }\n}\n\n/** Shared V07/V09 guarded single-public-HTML source fetch.\n * Exactly one robots.txt and one page GET; never follows redirects. */\nexport async function fetchGuardedPublicHtml(url: string): Promise<{\n page_url: string; raw_html: string;\n}> {\n const safe = guard(url);\n await resolvePublicHttpUrl(safe);\n const origin = new URL(safe).origin;\n let robotsTxt: string | undefined;\n let robotsStatus: number | undefined;\n try {\n const { response } = await fetchPublicHttp(origin + \"/robots.txt\", {\n method: \"GET\", maxRedirects: 0, timeoutMs: 12_000,\n headers: { accept: \"text/plain\", \"user-agent\": SERVICE_UA },\n });\n robotsStatus = response.status;\n try {\n const type = response.headers.get(\"content-type\")\n ?.split(\";\", 1)[0].trim().toLowerCase();\n if (response.status === 200 && (!type || type === \"text/plain\")) {\n robotsTxt = await readResponseText(response, MAX_CRAWLER_ROBOTS_BYTES);\n }\n } finally { await cancel(response); }\n } catch { /* Unknown robots permission is not assumed allowed. */ }\n\n const allowed = robotsTxt !== undefined\n ? isAllowedForFetcher(robotsTxt, safe)\n : robotsStatus === 404 || robotsStatus === 410 ? true : undefined;\n if (allowed !== true) {\n throw new Error(\"The public page is robots-disallowed or crawl permission is unknown.\");\n }\n const { response } = await fetchPublicHttp(safe, {\n method: \"GET\", maxRedirects: 0, timeoutMs: 12_000,\n headers: { accept: \"text/html,application/xhtml+xml\", \"user-agent\": SERVICE_UA },\n });\n let rawHtml: string;\n try {\n const mime = response.headers.get(\"content-type\")\n ?.split(\";\", 1)[0].trim().toLowerCase();\n if (response.status !== 200 ||\n (mime !== \"text/html\" && mime !== \"application/xhtml+xml\") ||\n response.headers.get(\"cf-mitigated\") === \"challenge\") {\n throw new Error(\"The public HTTP sample is not a complete ordinary HTML 200 response.\");\n }\n const charset = /(?:^|;)\\s*charset\\s*=\\s*\"?([^;\\s\"]+)/iu\n .exec(response.headers.get(\"content-type\") ?? \"\")?.[1];\n rawHtml = await readResponseText(response, MAX_RENDER_HTML_BYTES, charset, !charset);\n } finally { await cancel(response); }\n return { page_url: safe, raw_html: rawHtml };\n}\n\n/** Fetch one authorized public HTML response, robots-gated, then render\n * a resource-denied inline-script DOM sample in local Chromium. */\nexport async function reviewPublicInlineDom(\n url: string,\n runtime: ScreenshotBrowserRuntime = defaultScreenshotBrowserRuntime,\n): Promise<RawRenderedReview> {\n const source = await fetchGuardedPublicHtml(url);\n return renderInlineHtml(source.raw_html, source.page_url, runtime,\n \"isolated_public_html_inline_script_sample\");\n}\n"]}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// Copyright (c) 2026 AKzar1el and Web Validator contributors
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
1
3
|
import { assertPublicHttpUrl, fetchPublicHttp, readResponseText, resolvePublicHttpUrl, } from "../../network.js";
|
|
2
4
|
import { defaultScreenshotBrowserRuntime, } from "../../screenshot.js";
|
|
3
5
|
import { startScreenshotTransportProxy } from "../../screenshot-proxy.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version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AAC,IAAI,CAAC,YAAY,IAAI,CAAC,cAAc;gBAAE,cAAc,GAAG,KAAK,CAAC;QAAC,CAAC;QAC/E,IAAI,cAAc;YAAE,MAAM,cAAc,CAAC;IAC3C,CAAC;AACH,CAAC","sourcesContent":["import {\n assertPublicHttpUrl, fetchPublicHttp, readResponseText, resolvePublicHttpUrl,\n} from \"../../network.js\";\nimport {\n defaultScreenshotBrowserRuntime, type ScreenshotBrowserRuntime,\n} from \"../../screenshot.js\";\nimport { startScreenshotTransportProxy } from \"../../screenshot-proxy.js\";\nimport { safeHttpResourceUrl } from \"../http-crawl/non-html-directives.js\";\nimport {\n isAllowedForFetcher, MAX_CRAWLER_ROBOTS_BYTES,\n} from \"../http-crawl/crawler-access.js\";\nimport {\n analyzeResourceFailures, MAX_RESOURCE_BROWSER_MS, MAX_RESOURCE_OBSERVATIONS,\n RESOURCE_TYPES, type ResourceType, type ResourceFailureReason,\n type ResourceObservation, type ResourceFailureReview,\n} from \"./resource-failures.js\";\n\n/** Normalize browser failures to redacted reason groups; no error strings leak. */\nexport function classifyResourceNetworkFailure(\n raw: string | undefined,\n): ResourceFailureReason {\n const value = (raw ?? \"\").toUpperCase();\n if (/NAME_NOT_RESOLVED|DNS|NAME_RESOLUTION/iu.test(value)) return \"dns\";\n if (/TIMED_OUT|TIMEOUT/iu.test(value)) return \"timeout\";\n if (/CERT_|SSL_|TLS_/iu.test(value)) return \"tls\";\n if (/CONNECTION_|NETWORK_CHANGED|INTERNET_DISCONNECTED/iu.test(value)) return \"connection\";\n if (/ABORTED|CANCELLED/iu.test(value)) return \"canceled\";\n return \"other\";\n}\nexport function browserResourceType(value: string | undefined): ResourceType {\n return RESOURCE_TYPES.includes(value as ResourceType) ? value as ResourceType : \"other\";\n}\n/** Browser-side page scripts may issue mutations; never permit those methods. */\nexport function isReadOnlyBrowserResourceMethod(method: string): boolean {\n return method === \"GET\" || method === \"HEAD\";\n}\nasync function cancel(response: Response) {\n try { await response.body?.cancel(); } catch { /* Already consumed. */ }\n}\n\nexport interface ResourceBrowserOptions {\n includeThirdParty?: boolean;\n}\nexport async function inspectPublicResourceLoading(\n inputUrl: string,\n options: ResourceBrowserOptions = {},\n runtime: ScreenshotBrowserRuntime = defaultScreenshotBrowserRuntime,\n): Promise<ResourceFailureReview> {\n const url = safeHttpResourceUrl(inputUrl);\n if (!url) throw new Error(\"Use a safe, query-free public HTTP(S) page URL.\");\n if (options.includeThirdParty !== undefined &&\n typeof options.includeThirdParty !== \"boolean\") {\n throw new Error(\"The third-party request option must be Boolean.\");\n }\n const site = await resolvePublicHttpUrl(url);\n const origin = site.url.origin;\n let robots: string | undefined;\n let robotsStatus: number | undefined;\n try {\n const { response } = await fetchPublicHttp(origin + \"/robots.txt\", {\n method: \"GET\", maxRedirects: 0, timeoutMs: 12_000,\n headers: { accept: \"text/plain\", \"user-agent\": \"DigestSEO-Web-Validator/1.3\" },\n });\n robotsStatus = response.status;\n try {\n const mime = response.headers.get(\"content-type\")\n ?.split(\";\", 1)[0].trim().toLowerCase();\n if (response.status === 200 && (!mime || mime === \"text/plain\")) {\n robots = await readResponseText(response, MAX_CRAWLER_ROBOTS_BYTES);\n }\n } finally { await cancel(response); }\n } catch { /* Unverified robots access fails closed. */ }\n const allowed = robots !== undefined\n ? isAllowedForFetcher(robots, url)\n : robotsStatus === 404 || robotsStatus === 410 ? true : undefined;\n if (allowed !== true) throw new Error(\"Robots access is disallowed or unverified.\");\n\n let proxyPolicyBlocks = 0;\n const proxy = await startScreenshotTransportProxy(() => { proxyPolicyBlocks++; });\n let browser: Awaited<ReturnType<ScreenshotBrowserRuntime[\"launch\"]>> | undefined;\n let deadline: ReturnType<typeof setTimeout> | undefined;\n let pendingError: unknown;\n const observations: ResourceObservation[] = [];\n const mapped = new WeakMap<object, { index: number; started: number }>();\n const responseStatuses = new WeakMap<object, number>();\n let additionalBudgetBlocked = 0;\n let navigationCompleted = false;\n const permittedOrigins = new Set<string>([origin]);\n\n try {\n browser = await runtime.launch(proxy.url);\n deadline = setTimeout(() => {\n void browser?.close().catch(() => {});\n }, MAX_RESOURCE_BROWSER_MS);\n deadline.unref?.();\n const page = await browser.newPage();\n page.setDefaultTimeout(5_000);\n page.setDefaultNavigationTimeout(12_000);\n await page.setViewport({ width: 1200, height: 850, deviceScaleFactor: 1 });\n await page.setRequestInterception(true);\n\n page.on(\"request\", (request) => {\n if (request.isInterceptResolutionHandled()) return;\n const type = browserResourceType(request.resourceType());\n let target: URL | undefined;\n try { target = new URL(request.url()); }\n catch { /* Invalid URL is blocked and counted without echo. */ }\n const external = target && target.origin !== origin;\n if (observations.length >= MAX_RESOURCE_OBSERVATIONS) {\n additionalBudgetBlocked = Math.min(1_000_000, additionalBudgetBlocked + 1);\n void request.abort(\"blockedbyclient\").catch(() => {});\n return;\n }\n const row: ResourceObservation = {\n resource_type: type,\n origin: !target ? \"unknown\" : external ? \"third_party\" : \"same_origin\",\n outcome: \"pending\",\n };\n const index = observations.push(row) - 1;\n mapped.set(request, { index, started: Date.now() });\n const deny = () => {\n row.outcome = \"tool_blocked\";\n void request.abort(\"blockedbyclient\").catch(() => {});\n };\n if (!target || ![\"https:\", \"http:\"].includes(target.protocol) ||\n target.username || target.password || target.port ||\n !isReadOnlyBrowserResourceMethod(request.method()) ||\n (type === \"document\" && target.href !== url) ||\n type === \"media\" || (external && options.includeThirdParty !== true)) {\n deny();\n return;\n }\n if (external && target && !permittedOrigins.has(target.origin)) {\n if (permittedOrigins.size >= 4) { deny(); return; }\n permittedOrigins.add(target.origin);\n }\n // The screenshot proxy also performs DNS-pinned public-address checks.\n // Validate before continuing each browser request, preventing local/SSRF\n // fetches while retaining the HTTPS proxy's safe network behavior.\n void assertPublicHttpUrl(target.href).then(() => {\n if (!request.isInterceptResolutionHandled()) {\n return request.continue();\n }\n }).catch(() => deny());\n });\n page.on(\"response\", (response) => {\n const req = response.request();\n const info = mapped.get(req);\n if (!info) return;\n const row = observations[info.index];\n if (row.outcome !== \"pending\") return;\n // Receiving response headers does not prove a complete body download.\n // Puppeteer's requestfinished event establishes a completed HTTP fetch.\n responseStatuses.set(req, response.status());\n });\n page.on(\"requestfinished\", (request) => {\n const info = mapped.get(request);\n if (!info) return;\n const row = observations[info.index];\n const status = responseStatuses.get(request);\n if (row.outcome === \"pending\" && status !== undefined) {\n row.outcome = \"http\";\n row.status_code = status;\n row.duration_ms = Math.max(0, Date.now() - info.started);\n }\n });\n page.on(\"requestfailed\", (request) => {\n const info = mapped.get(request);\n if (!info) return;\n const row = observations[info.index];\n if (row.outcome === \"tool_blocked\") return;\n row.outcome = \"transport_failed\";\n row.status_code = undefined;\n row.duration_ms = Math.max(0, Date.now() - info.started);\n row.failure_reason = classifyResourceNetworkFailure(\n request.failure()?.errorText);\n });\n\n try {\n const main = await page.goto(url, {\n waitUntil: \"domcontentloaded\",\n timeout: 12_000,\n });\n navigationCompleted = Boolean(main);\n } catch {\n // Keep observed HTTP responses/transport failures rather than\n // fabricating a success, timeout status or page content.\n }\n await new Promise((resolve) => setTimeout(resolve, 900));\n if (observations.length === 0) {\n throw new Error(\"The browser emitted no observable requests.\");\n }\n const result = analyzeResourceFailures({\n observations, additional_budget_blocked: additionalBudgetBlocked,\n navigation_completed: navigationCompleted,\n }, \"guarded_public_browser_resources\");\n // Proxy blocks are a tool/network safeguard, not proof that a resource\n // from the site returned an HTTP error. Do not propagate private targets.\n if (proxyPolicyBlocks) {\n result.error = \"Some URLs were rejected by the guarded public HTTP proxy; affected browser requests require independent verification.\";\n }\n return result;\n } catch (cause) {\n pendingError = cause;\n throw cause;\n } finally {\n if (deadline) clearTimeout(deadline);\n let cleanupFailure: unknown;\n try {\n if (browser) await browser.close();\n } catch (cause) {\n if (!pendingError) cleanupFailure = cause;\n }\n try { await proxy.close(); }\n catch (cause) { if (!pendingError && !cleanupFailure) cleanupFailure = cause; }\n if (cleanupFailure) throw cleanupFailure;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"resource-failures-probe.js","sourceRoot":"","sources":["../../../src/modules/browser-ux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,IAAI,CAAC,cAAc;gBAAE,cAAc,GAAG,KAAK,CAAC;QAAC,CAAC;QAC/E,IAAI,cAAc;YAAE,MAAM,cAAc,CAAC;IAC3C,CAAC;AACH,CAAC","sourcesContent":["// Copyright (c) 2026 AKzar1el and Web Validator contributors\n// SPDX-License-Identifier: MIT\nimport {\n assertPublicHttpUrl, fetchPublicHttp, readResponseText, resolvePublicHttpUrl,\n} from \"../../network.js\";\nimport {\n defaultScreenshotBrowserRuntime, type ScreenshotBrowserRuntime,\n} from \"../../screenshot.js\";\nimport { startScreenshotTransportProxy } from \"../../screenshot-proxy.js\";\nimport { safeHttpResourceUrl } from \"../http-crawl/non-html-directives.js\";\nimport {\n isAllowedForFetcher, MAX_CRAWLER_ROBOTS_BYTES,\n} from \"../http-crawl/crawler-access.js\";\nimport {\n analyzeResourceFailures, MAX_RESOURCE_BROWSER_MS, MAX_RESOURCE_OBSERVATIONS,\n RESOURCE_TYPES, type ResourceType, type ResourceFailureReason,\n type ResourceObservation, type ResourceFailureReview,\n} from \"./resource-failures.js\";\n\n/** Normalize browser failures to redacted reason groups; no error strings leak. */\nexport function classifyResourceNetworkFailure(\n raw: string | undefined,\n): ResourceFailureReason {\n const value = (raw ?? \"\").toUpperCase();\n if (/NAME_NOT_RESOLVED|DNS|NAME_RESOLUTION/iu.test(value)) return \"dns\";\n if (/TIMED_OUT|TIMEOUT/iu.test(value)) return \"timeout\";\n if (/CERT_|SSL_|TLS_/iu.test(value)) return \"tls\";\n if (/CONNECTION_|NETWORK_CHANGED|INTERNET_DISCONNECTED/iu.test(value)) return \"connection\";\n if (/ABORTED|CANCELLED/iu.test(value)) return \"canceled\";\n return \"other\";\n}\nexport function browserResourceType(value: string | undefined): ResourceType {\n return RESOURCE_TYPES.includes(value as ResourceType) ? value as ResourceType : \"other\";\n}\n/** Browser-side page scripts may issue mutations; never permit those methods. */\nexport function isReadOnlyBrowserResourceMethod(method: string): boolean {\n return method === \"GET\" || method === \"HEAD\";\n}\nasync function cancel(response: Response) {\n try { await response.body?.cancel(); } catch { /* Already consumed. */ }\n}\n\nexport interface ResourceBrowserOptions {\n includeThirdParty?: boolean;\n}\nexport async function inspectPublicResourceLoading(\n inputUrl: string,\n options: ResourceBrowserOptions = {},\n runtime: ScreenshotBrowserRuntime = defaultScreenshotBrowserRuntime,\n): Promise<ResourceFailureReview> {\n const url = safeHttpResourceUrl(inputUrl);\n if (!url) throw new Error(\"Use a safe, query-free public HTTP(S) page URL.\");\n if (options.includeThirdParty !== undefined &&\n typeof options.includeThirdParty !== \"boolean\") {\n throw new Error(\"The third-party request option must be Boolean.\");\n }\n const site = await resolvePublicHttpUrl(url);\n const origin = site.url.origin;\n let robots: string | undefined;\n let robotsStatus: number | undefined;\n try {\n const { response } = await fetchPublicHttp(origin + \"/robots.txt\", {\n method: \"GET\", maxRedirects: 0, timeoutMs: 12_000,\n headers: { accept: \"text/plain\", \"user-agent\": \"DigestSEO-Web-Validator/1.3\" },\n });\n robotsStatus = response.status;\n try {\n const mime = response.headers.get(\"content-type\")\n ?.split(\";\", 1)[0].trim().toLowerCase();\n if (response.status === 200 && (!mime || mime === \"text/plain\")) {\n robots = await readResponseText(response, MAX_CRAWLER_ROBOTS_BYTES);\n }\n } finally { await cancel(response); }\n } catch { /* Unverified robots access fails closed. */ }\n const allowed = robots !== undefined\n ? isAllowedForFetcher(robots, url)\n : robotsStatus === 404 || robotsStatus === 410 ? true : undefined;\n if (allowed !== true) throw new Error(\"Robots access is disallowed or unverified.\");\n\n let proxyPolicyBlocks = 0;\n const proxy = await startScreenshotTransportProxy(() => { proxyPolicyBlocks++; });\n let browser: Awaited<ReturnType<ScreenshotBrowserRuntime[\"launch\"]>> | undefined;\n let deadline: ReturnType<typeof setTimeout> | undefined;\n let pendingError: unknown;\n const observations: ResourceObservation[] = [];\n const mapped = new WeakMap<object, { index: number; started: number }>();\n const responseStatuses = new WeakMap<object, number>();\n let additionalBudgetBlocked = 0;\n let navigationCompleted = false;\n const permittedOrigins = new Set<string>([origin]);\n\n try {\n browser = await runtime.launch(proxy.url);\n deadline = setTimeout(() => {\n void browser?.close().catch(() => {});\n }, MAX_RESOURCE_BROWSER_MS);\n deadline.unref?.();\n const page = await browser.newPage();\n page.setDefaultTimeout(5_000);\n page.setDefaultNavigationTimeout(12_000);\n await page.setViewport({ width: 1200, height: 850, deviceScaleFactor: 1 });\n await page.setRequestInterception(true);\n\n page.on(\"request\", (request) => {\n if (request.isInterceptResolutionHandled()) return;\n const type = browserResourceType(request.resourceType());\n let target: URL | undefined;\n try { target = new URL(request.url()); }\n catch { /* Invalid URL is blocked and counted without echo. */ }\n const external = target && target.origin !== origin;\n if (observations.length >= MAX_RESOURCE_OBSERVATIONS) {\n additionalBudgetBlocked = Math.min(1_000_000, additionalBudgetBlocked + 1);\n void request.abort(\"blockedbyclient\").catch(() => {});\n return;\n }\n const row: ResourceObservation = {\n resource_type: type,\n origin: !target ? \"unknown\" : external ? \"third_party\" : \"same_origin\",\n outcome: \"pending\",\n };\n const index = observations.push(row) - 1;\n mapped.set(request, { index, started: Date.now() });\n const deny = () => {\n row.outcome = \"tool_blocked\";\n void request.abort(\"blockedbyclient\").catch(() => {});\n };\n if (!target || ![\"https:\", \"http:\"].includes(target.protocol) ||\n target.username || target.password || target.port ||\n !isReadOnlyBrowserResourceMethod(request.method()) ||\n (type === \"document\" && target.href !== url) ||\n type === \"media\" || (external && options.includeThirdParty !== true)) {\n deny();\n return;\n }\n if (external && target && !permittedOrigins.has(target.origin)) {\n if (permittedOrigins.size >= 4) { deny(); return; }\n permittedOrigins.add(target.origin);\n }\n // The screenshot proxy also performs DNS-pinned public-address checks.\n // Validate before continuing each browser request, preventing local/SSRF\n // fetches while retaining the HTTPS proxy's safe network behavior.\n void assertPublicHttpUrl(target.href).then(() => {\n if (!request.isInterceptResolutionHandled()) {\n return request.continue();\n }\n }).catch(() => deny());\n });\n page.on(\"response\", (response) => {\n const req = response.request();\n const info = mapped.get(req);\n if (!info) return;\n const row = observations[info.index];\n if (row.outcome !== \"pending\") return;\n // Receiving response headers does not prove a complete body download.\n // Puppeteer's requestfinished event establishes a completed HTTP fetch.\n responseStatuses.set(req, response.status());\n });\n page.on(\"requestfinished\", (request) => {\n const info = mapped.get(request);\n if (!info) return;\n const row = observations[info.index];\n const status = responseStatuses.get(request);\n if (row.outcome === \"pending\" && status !== undefined) {\n row.outcome = \"http\";\n row.status_code = status;\n row.duration_ms = Math.max(0, Date.now() - info.started);\n }\n });\n page.on(\"requestfailed\", (request) => {\n const info = mapped.get(request);\n if (!info) return;\n const row = observations[info.index];\n if (row.outcome === \"tool_blocked\") return;\n row.outcome = \"transport_failed\";\n row.status_code = undefined;\n row.duration_ms = Math.max(0, Date.now() - info.started);\n row.failure_reason = classifyResourceNetworkFailure(\n request.failure()?.errorText);\n });\n\n try {\n const main = await page.goto(url, {\n waitUntil: \"domcontentloaded\",\n timeout: 12_000,\n });\n navigationCompleted = Boolean(main);\n } catch {\n // Keep observed HTTP responses/transport failures rather than\n // fabricating a success, timeout status or page content.\n }\n await new Promise((resolve) => setTimeout(resolve, 900));\n if (observations.length === 0) {\n throw new Error(\"The browser emitted no observable requests.\");\n }\n const result = analyzeResourceFailures({\n observations, additional_budget_blocked: additionalBudgetBlocked,\n navigation_completed: navigationCompleted,\n }, \"guarded_public_browser_resources\");\n // Proxy blocks are a tool/network safeguard, not proof that a resource\n // from the site returned an HTTP error. Do not propagate private targets.\n if (proxyPolicyBlocks) {\n result.error = \"Some URLs were rejected by the guarded public HTTP proxy; affected browser requests require independent verification.\";\n }\n return result;\n } catch (cause) {\n pendingError = cause;\n throw cause;\n } finally {\n if (deadline) clearTimeout(deadline);\n let cleanupFailure: unknown;\n try {\n if (browser) await browser.close();\n } catch (cause) {\n if (!pendingError) cleanupFailure = cause;\n }\n try { await proxy.close(); }\n catch (cause) { if (!pendingError && !cleanupFailure) cleanupFailure = cause; }\n if (cleanupFailure) throw cleanupFailure;\n }\n}\n"]}
|