mcp-web-validator 1.3.47 → 1.3.49
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 +91 -2
- package/dist/audit-history.d.ts +112 -0
- package/dist/audit-history.js +227 -0
- package/dist/audit-history.js.map +1 -0
- package/dist/index.js +66 -5
- package/dist/index.js.map +1 -1
- package/dist/language-subtags.d.ts +2 -0
- package/dist/language-subtags.js +9 -0
- package/dist/language-subtags.js.map +1 -1
- package/dist/network.d.ts +3 -1
- package/dist/network.js +127 -21
- package/dist/network.js.map +1 -1
- package/dist/presentation.d.ts +1 -0
- package/dist/presentation.js +76 -21
- package/dist/presentation.js.map +1 -1
- package/dist/report.d.ts +1 -0
- package/dist/report.js +60 -21
- package/dist/report.js.map +1 -1
- package/dist/screenshot-proxy.d.ts +3 -0
- package/dist/screenshot-proxy.js +67 -14
- package/dist/screenshot-proxy.js.map +1 -1
- package/dist/screenshot.d.ts +6 -0
- package/dist/screenshot.js +191 -16
- package/dist/screenshot.js.map +1 -1
- package/dist/seo-auditor.d.ts +5 -3
- package/dist/seo-auditor.js +417 -107
- package/dist/seo-auditor.js.map +1 -1
- package/dist/w3c-validator.js +46 -14
- package/dist/w3c-validator.js.map +1 -1
- package/package.json +4 -3
package/dist/report.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"report.js","sourceRoot":"","sources":["../src/report.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EACL,qBAAqB,GAGtB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,oBAAoB,EAAoD,MAAM,kBAAkB,CAAC;AAE1G,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,CAAU,CAAC;AAiElG,SAAS,UAAU,CAAC,KAAa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f,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,YAAY;QACZ,GAAG,CAAC,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC7E,CAAC;AACJ,CAAC","sourcesContent":["import * as path from \"node:path\";\nimport {\n getW3CMessageSeverity,\n type CSSMessage,\n type W3CMessage,\n} from \"./w3c-validator.js\";\nimport { isHttpRedirectStatus, type AuditCounts, type LinkStatus, type SEOIssue } from \"./seo-auditor.js\";\n\nexport const validationReportChecks = [\"input\", \"html\", \"css\", \"seo\", \"schema\", \"links\"] as const;\nexport type ValidationReportCheck = (typeof validationReportChecks)[number];\n\nexport interface ValidationReportSummary {\n overallScore: number | null;\n htmlScore: number | null;\n cssScore: number | null;\n seoScore: number | null;\n linkScore: number | null;\n htmlErrors: number;\n htmlWarnings: number;\n cssErrors: number;\n cssWarnings?: number;\n cssCompatibilityLimitations: number;\n seoErrors: number;\n seoWarnings: number;\n schemaErrors: number;\n linksChecked: number;\n brokenLinks: number;\n}\n\nexport interface ValidationReport {\n report: string;\n summary: ValidationReportSummary;\n htmlMessages: W3CMessage[];\n htmlTotalMessages: number;\n htmlTruncated: boolean;\n cssMessages: CSSMessage[];\n cssTotalMessages: number;\n cssTruncated: boolean;\n seoIssues: SEOIssue[];\n seoTotalIssues: number;\n seoTruncated: boolean;\n schemaIssues: SEOIssue[];\n schemaTotalIssues: number;\n schemaTruncated: boolean;\n links: LinkStatus[];\n failedChecks: ValidationReportCheck[];\n errors?: string[];\n}\n\nexport interface ValidationReportInput {\n htmlFilePath: string;\n cssAudited: boolean;\n htmlMessages: W3CMessage[];\n htmlTotalMessages?: number;\n htmlTruncated?: boolean;\n htmlCounts?: { error: number; warning: number; info: number };\n cssMessages: CSSMessage[];\n cssTotalMessages?: number;\n cssTruncated?: boolean;\n cssCounts?: { error: number; warning?: number; compatibilityLimitation: number };\n seoIssues: SEOIssue[];\n seoTotalIssues?: number;\n seoTruncated?: boolean;\n seoCounts?: AuditCounts;\n schemaIssues: SEOIssue[];\n schemaTotalIssues?: number;\n schemaTruncated?: boolean;\n schemaCounts?: AuditCounts;\n links: LinkStatus[];\n failedChecks?: ValidationReportCheck[];\n errors?: string[];\n}\n\nfunction clampScore(score: number): number {\n return Math.max(0, Math.min(100, score));\n}\n\nfunction scoreIndicator(score: number | null): string {\n if (score === null) return \"Unavailable\";\n if (score >= 90) return \"🟢\";\n if (score >= 50) return \"🟠\";\n return \"🔴\";\n}\n\nfunction markdownCell(value: unknown): string {\n return String(value ?? \"\")\n .replace(/&/g, \"&\")\n .replace(/</g, \"<\")\n .replace(/>/g, \">\")\n .replace(/\\\\/g, \"\\\\\\\\\")\n .replace(/([`*_[\\]|~])/g, \"\\\\$1\")\n .replace(/[\\r\\n]+/g, \" \")\n .trim();\n}\n\nfunction isRedirect(link: LinkStatus): boolean {\n return isHttpRedirectStatus(link.status);\n}\n\n/** Builds the human-readable report and its machine-readable equivalent. */\nexport function createValidationReport(input: ValidationReportInput): ValidationReport {\n const failedChecks = input.failedChecks ?? [];\n const checkFailed = (check: ValidationReportCheck): boolean => failedChecks.includes(check);\n const htmlErrors = input.htmlCounts?.error\n ?? input.htmlMessages.filter((message) => getW3CMessageSeverity(message) === \"error\").length;\n const htmlWarnings = input.htmlCounts?.warning\n ?? input.htmlMessages.filter((message) => getW3CMessageSeverity(message) === \"warning\").length;\n const htmlTotalMessages = input.htmlTotalMessages ?? input.htmlMessages.length;\n const htmlTruncated = input.htmlTruncated ?? htmlTotalMessages > input.htmlMessages.length;\n const cssTotalMessages = input.cssTotalMessages ?? input.cssMessages.length;\n const cssTruncated = input.cssTruncated ?? cssTotalMessages > input.cssMessages.length;\n const cssCompatibilityLimitations = input.cssCounts?.compatibilityLimitation\n ?? input.cssMessages.filter((message) => message.compatibility === \"known-validator-limitation\").length;\n const cssWarnings = input.cssCounts?.warning\n ?? input.cssMessages.filter((message) => message.type.toLowerCase() === \"warning\").length;\n const cssErrors = input.cssCounts?.error\n ?? input.cssMessages.length - cssWarnings - cssCompatibilityLimitations;\n const seoTotalIssues = input.seoTotalIssues ?? input.seoIssues.length;\n const seoTruncated = input.seoTruncated ?? seoTotalIssues > input.seoIssues.length;\n const schemaTotalIssues = input.schemaTotalIssues ?? input.schemaIssues.length;\n const schemaTruncated = input.schemaTruncated ?? schemaTotalIssues > input.schemaIssues.length;\n const seoErrors = input.seoCounts?.error ?? input.seoIssues.filter((issue) => issue.severity === \"error\").length;\n const seoWarnings = input.seoCounts?.warning ?? input.seoIssues.filter((issue) => issue.severity === \"warning\").length;\n const schemaErrors = input.schemaCounts?.error ?? input.schemaIssues.filter((issue) => issue.severity === \"error\").length;\n const brokenLinks = input.links.filter((link) => !link.ok).length;\n const redirectLinks = input.links.filter(isRedirect).length;\n\n const htmlScore = checkFailed(\"html\") ? null : clampScore(100 - htmlErrors * 15 - htmlWarnings * 2);\n const cssScore = checkFailed(\"css\") || !input.cssAudited || cssCompatibilityLimitations > 0\n ? null\n : clampScore(100 - cssErrors * 20);\n const seoScore = checkFailed(\"seo\") || checkFailed(\"schema\")\n ? null\n : clampScore(100 - seoErrors * 15 - seoWarnings * 4 - schemaErrors * 15);\n const linkScore = checkFailed(\"links\") || input.links.length === 0\n ? null\n : clampScore(100 - brokenLinks * 25);\n const auditedScores = [htmlScore, seoScore, cssScore, linkScore].filter(\n (score): score is number => score !== null,\n );\n const overallScore = failedChecks.length > 0 || cssCompatibilityLimitations > 0 || auditedScores.length === 0\n ? null\n : Math.round(auditedScores.reduce((total, score) => total + score, 0) / auditedScores.length);\n\n const summary: ValidationReportSummary = {\n overallScore,\n htmlScore,\n cssScore,\n seoScore,\n linkScore,\n htmlErrors,\n htmlWarnings,\n cssErrors,\n cssWarnings,\n cssCompatibilityLimitations,\n seoErrors,\n seoWarnings,\n schemaErrors,\n linksChecked: input.links.length,\n brokenLinks,\n };\n\n const report: string[] = [\n `# Web Validation & SEO Audit Report — ${overallScore === null ? \"Partial\" : `${scoreIndicator(overallScore)} **${overallScore}**/100`}`,\n `*Generated for: \\`${markdownCell(path.basename(input.htmlFilePath))}\\`*`,\n \"\",\n \"## Page health scores\",\n \"\",\n \"| Audit | Status | Score |\",\n \"| :--- | :---: | :---: |\",\n `| W3C HTML validation | ${htmlScore === null ? \"Unavailable\" : scoreIndicator(htmlScore)} | ${htmlScore === null ? \"N/A\" : `**${htmlScore}** / 100`} |`,\n `| CSS validation | ${cssScore === null ? (checkFailed(\"css\") ? \"Unavailable\" : cssCompatibilityLimitations > 0 ? \"Compatibility-limited\" : \"Not audited\") : scoreIndicator(cssScore)} | ${cssScore === null ? \"N/A\" : `**${cssScore}** / 100`} |`,\n `| SEO and accessibility | ${seoScore === null ? \"Unavailable\" : scoreIndicator(seoScore)} | ${seoScore === null ? \"N/A\" : `**${seoScore}** / 100`} |`,\n `| Link integrity | ${linkScore === null ? (checkFailed(\"links\") ? \"Unavailable\" : \"No links checked\") : scoreIndicator(linkScore)} | ${linkScore === null ? \"N/A\" : `**${linkScore}** / 100`} |`,\n \"\",\n \"## Summary\",\n \"\",\n `- HTML: ${htmlErrors} error(s), ${htmlWarnings} warning(s)` ,\n `- CSS: ${input.cssAudited ? `${cssErrors} error(s), ${cssWarnings} warning(s)${cssCompatibilityLimitations > 0 ? `, ${cssCompatibilityLimitations} known validator limitation(s)` : \"\"}` : \"not audited\"}`,\n `- SEO and accessibility: ${seoErrors} error(s), ${seoWarnings} warning(s)`,\n `- JSON-LD syntax: ${schemaErrors} error(s)`,\n `- Links: ${brokenLinks} broken or unreachable, ${redirectLinks} redirect${redirectLinks === 1 ? \"\" : \"s\"} to review of ${input.links.length} checked`,\n \"\",\n `## HTML diagnostics (${htmlTruncated ? `${input.htmlMessages.length} shown of ${htmlTotalMessages}` : htmlTotalMessages})`,\n ];\n\n if (failedChecks.length > 0) {\n report.splice(2, 0, \"\", \"## Partial validation report\", \"The following checks were unavailable: \" + failedChecks.join(\", \") + \". Remaining checks completed.\");\n }\n\n if (input.htmlMessages.length === 0) {\n report.push(\"No HTML validation diagnostics were returned.\");\n } else {\n if (htmlTruncated) {\n report.push(`The structured HTML diagnostics are capped; showing the first ${input.htmlMessages.length} of ${htmlTotalMessages}. Summary counts and scoring use all returned Nu diagnostics.`);\n }\n report.push(\"\", \"| Line | Column | Severity | Message | Extract |\", \"| :---: | :---: | :--- | :--- | :--- |\");\n for (const message of input.htmlMessages) {\n report.push(\n `| ${message.lastLine ?? \"N/A\"} | ${message.lastColumn ?? \"N/A\"} | ${markdownCell(getW3CMessageSeverity(message))} | ${markdownCell(message.message)} | ${markdownCell(message.extract ?? \"N/A\")} |`,\n );\n }\n }\n\n if (input.cssAudited) {\n report.push(\"\", `## CSS diagnostics (${cssTruncated ? `${input.cssMessages.length} shown of ${cssTotalMessages}` : cssTotalMessages})`);\n if (input.cssMessages.length === 0) {\n report.push(\"No CSS validation errors or warnings were returned.\");\n } else {\n if (cssTruncated) {\n report.push(`The structured CSS diagnostics are capped; showing the first ${input.cssMessages.length} of ${cssTotalMessages}. Summary counts and scoring use all returned Jigsaw diagnostics.`);\n }\n report.push(\"\", \"| Line | Severity | Context | Message |\", \"| :---: | :--- | :--- | :--- |\");\n for (const message of input.cssMessages) {\n report.push(\n `| ${message.line} | ${markdownCell(message.compatibility === \"known-validator-limitation\" ? \"known validator limitation\" : message.type)} | ${markdownCell(message.context ?? \"N/A\")} | ${markdownCell(message.message)} |`,\n );\n }\n if (cssCompatibilityLimitations > 0) {\n report.push(\n \"\",\n `${cssCompatibilityLimitations} known validator limitation(s) match Jigsaw's current parser gap for the standards-defined \\`@container\\` rule. The original Jigsaw diagnostic is preserved, but CSS and overall scores are withheld because this upstream limitation can report valid modern CSS as invalid.`,\n );\n }\n }\n }\n\n const combinedIssues = [...input.seoIssues, ...input.schemaIssues];\n const combinedTotalIssues = seoTotalIssues + schemaTotalIssues;\n const combinedTruncated = seoTruncated || schemaTruncated;\n report.push(\n \"\",\n `## SEO, accessibility, and JSON-LD findings (${combinedTruncated ? `${combinedIssues.length} shown of ${combinedTotalIssues}` : combinedTotalIssues})`,\n );\n if (combinedIssues.length === 0) {\n report.push(\"No SEO, accessibility, or JSON-LD syntax findings were returned.\");\n } else {\n if (seoTruncated) {\n report.push(`The structured SEO/accessibility findings are capped; showing the first ${input.seoIssues.length} of ${seoTotalIssues}. Summary counts and scoring use all findings.`);\n }\n if (schemaTruncated) {\n report.push(`The structured JSON-LD findings are capped; showing the first ${input.schemaIssues.length} of ${schemaTotalIssues}. Summary counts and scoring use all findings.`);\n }\n report.push(\"\", \"| Category | Severity | Message | Element |\", \"| :--- | :--- | :--- | :--- |\");\n for (const issue of combinedIssues) {\n report.push(\n `| ${markdownCell(issue.category)} | ${markdownCell(issue.severity)} | ${markdownCell(issue.message)} | ${markdownCell(issue.element ?? \"N/A\")} |`,\n );\n }\n }\n\n report.push(\"\", `## Link health (${input.links.length} checked)`);\n if (input.links.length === 0) {\n report.push(\"No public HTTP(S) links were checked.\");\n } else {\n report.push(\"\", \"| URL | Status | Reachable | Details |\", \"| :--- | :---: | :---: | :--- |\");\n for (const link of input.links) {\n report.push(\n `| ${markdownCell(link.url)} | ${markdownCell(link.status)} | ${link.ok ? \"Yes\" : \"No\"} | ${markdownCell(link.message ?? \"Accessible\")} |`,\n );\n }\n }\n\n return {\n report: report.join(\"\\n\"),\n summary,\n htmlMessages: input.htmlMessages,\n htmlTotalMessages,\n htmlTruncated,\n cssMessages: input.cssMessages,\n cssTotalMessages,\n cssTruncated,\n seoIssues: input.seoIssues,\n seoTotalIssues,\n seoTruncated,\n schemaIssues: input.schemaIssues,\n schemaTotalIssues,\n schemaTruncated,\n links: input.links,\n failedChecks,\n ...(input.errors && input.errors.length > 0 ? { errors: input.errors } : {}),\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"report.js","sourceRoot":"","sources":["../src/report.ts"],"names":[],"mappings":"AAAA,OAAO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QACd,YAAY;QACZ,YAAY,EAAE,KAAK,CAAC,YAAY;QAChC,iBAAiB;QACjB,eAAe;QACf,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,YAAY;QACZ,GAAG,CAAC,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC7E,CAAC;AACJ,CAAC","sourcesContent":["import * as path from \"node:path\";\nimport {\n getW3CMessageSeverity,\n type CSSMessage,\n type W3CMessage,\n} from \"./w3c-validator.js\";\nimport { isHttpRedirectStatus, isUnverifiedLinkStatus, type AuditCounts, type LinkStatus, type SEOIssue } from \"./seo-auditor.js\";\n\nexport const validationReportChecks = [\"input\", \"html\", \"css\", \"seo\", \"schema\", \"links\"] as const;\nexport type ValidationReportCheck = (typeof validationReportChecks)[number];\n\nexport interface ValidationReportSummary {\n overallScore: number | null;\n htmlScore: number | null;\n cssScore: number | null;\n seoScore: number | null;\n linkScore: number | null;\n htmlErrors: number;\n htmlWarnings: number;\n cssErrors: number;\n cssWarnings?: number;\n cssCompatibilityLimitations: number;\n seoErrors: number;\n seoWarnings: number;\n schemaErrors: number;\n linksChecked: number;\n brokenLinks: number;\n unverifiedLinks: number;\n}\n\nexport interface ValidationReport {\n report: string;\n summary: ValidationReportSummary;\n htmlMessages: W3CMessage[];\n htmlTotalMessages: number;\n htmlTruncated: boolean;\n cssMessages: CSSMessage[];\n cssTotalMessages: number;\n cssTruncated: boolean;\n seoIssues: SEOIssue[];\n seoTotalIssues: number;\n seoTruncated: boolean;\n schemaIssues: SEOIssue[];\n schemaTotalIssues: number;\n schemaTruncated: boolean;\n links: LinkStatus[];\n failedChecks: ValidationReportCheck[];\n errors?: string[];\n}\n\nexport interface ValidationReportInput {\n htmlFilePath: string;\n cssAudited: boolean;\n htmlMessages: W3CMessage[];\n htmlTotalMessages?: number;\n htmlTruncated?: boolean;\n htmlCounts?: { error: number; warning: number; info: number };\n cssMessages: CSSMessage[];\n cssTotalMessages?: number;\n cssTruncated?: boolean;\n cssCounts?: { error: number; warning?: number; compatibilityLimitation: number };\n seoIssues: SEOIssue[];\n seoTotalIssues?: number;\n seoTruncated?: boolean;\n seoCounts?: AuditCounts;\n schemaIssues: SEOIssue[];\n schemaTotalIssues?: number;\n schemaTruncated?: boolean;\n schemaCounts?: AuditCounts;\n links: LinkStatus[];\n failedChecks?: ValidationReportCheck[];\n errors?: string[];\n}\n\nfunction clampScore(score: number): number {\n return Math.max(0, Math.min(100, score));\n}\n\nfunction scoreIndicator(score: number | null): string {\n if (score === null) return \"Unavailable\";\n if (score >= 90) return \"🟢\";\n if (score >= 50) return \"🟠\";\n return \"🔴\";\n}\n\nfunction markdownCell(value: unknown): string {\n return String(value ?? \"\")\n .replace(/[\\u0000-\\u001f\\u007f-\\u009f\\u061c\\u200e\\u200f\\u202a-\\u202e\\u2066-\\u2069]+/g, \" \")\n .replace(/&/g, \"&\")\n .replace(/</g, \"<\")\n .replace(/>/g, \">\")\n .replace(/\\\\/g, \"\\\\\\\\\")\n .replace(/([`*_[\\]|~])/g, \"\\\\$1\")\n .trim();\n}\n\nfunction markdownCodeSpan(value: string): string {\n const content = value\n .replace(/[\\u0000-\\u001f\\u007f-\\u009f\\u061c\\u200e\\u200f\\u202a-\\u202e\\u2066-\\u2069]+/g, \" \")\n .trim();\n const longestBackticks = Math.max(0, ...Array.from(content.matchAll(/`+/g), (match) => match[0].length));\n const delimiter = \"`\".repeat(longestBackticks + 1);\n const padded = content.startsWith(\"`\") || content.endsWith(\"`\") ? ` ${content} ` : content;\n return `${delimiter}${padded}${delimiter}`;\n}\n\nfunction isRedirect(link: LinkStatus): boolean {\n return isHttpRedirectStatus(link.status);\n}\n\nfunction fallbackLinkMessage(link: LinkStatus): string {\n if (isUnverifiedLinkStatus(link.status)) return \"Destination availability not verified\";\n if (isRedirect(link)) return \"Redirect not followed\";\n return link.ok ? \"Accessible\" : \"HTTP response indicated failure\";\n}\n\n/** Builds the human-readable report and its machine-readable equivalent. */\nexport function createValidationReport(input: ValidationReportInput): ValidationReport {\n const failedChecks = input.failedChecks ?? [];\n const checkFailed = (check: ValidationReportCheck): boolean => failedChecks.includes(check);\n const htmlErrors = input.htmlCounts?.error\n ?? input.htmlMessages.filter((message) => getW3CMessageSeverity(message) === \"error\").length;\n const htmlWarnings = input.htmlCounts?.warning\n ?? input.htmlMessages.filter((message) => getW3CMessageSeverity(message) === \"warning\").length;\n const htmlTotalMessages = input.htmlTotalMessages ?? input.htmlMessages.length;\n const htmlTruncated = input.htmlTruncated ?? htmlTotalMessages > input.htmlMessages.length;\n const cssTotalMessages = input.cssTotalMessages ?? input.cssMessages.length;\n const cssTruncated = input.cssTruncated ?? cssTotalMessages > input.cssMessages.length;\n const cssCompatibilityLimitations = input.cssCounts?.compatibilityLimitation\n ?? input.cssMessages.filter((message) => message.compatibility === \"known-validator-limitation\").length;\n const cssWarnings = input.cssCounts?.warning\n ?? input.cssMessages.filter((message) => message.type.toLowerCase() === \"warning\").length;\n const cssErrors = input.cssCounts?.error\n ?? input.cssMessages.length - cssWarnings - cssCompatibilityLimitations;\n const seoTotalIssues = input.seoTotalIssues ?? input.seoIssues.length;\n const seoTruncated = input.seoTruncated ?? seoTotalIssues > input.seoIssues.length;\n const schemaTotalIssues = input.schemaTotalIssues ?? input.schemaIssues.length;\n const schemaTruncated = input.schemaTruncated ?? schemaTotalIssues > input.schemaIssues.length;\n // A capped diagnostic list cannot establish the severity distribution of omitted records.\n const htmlCountsIncomplete = htmlTruncated && input.htmlCounts === undefined;\n const cssCountsIncomplete = input.cssAudited && cssTruncated && input.cssCounts === undefined;\n const seoCountsIncomplete = seoTruncated && input.seoCounts === undefined;\n const schemaCountsIncomplete = schemaTruncated && input.schemaCounts === undefined;\n const incompleteCountChecks = [\n ...(htmlCountsIncomplete ? [\"HTML\"] : []),\n ...(cssCountsIncomplete ? [\"CSS\"] : []),\n ...(seoCountsIncomplete ? [\"SEO\"] : []),\n ...(schemaCountsIncomplete ? [\"JSON-LD\"] : []),\n ];\n const seoErrors = input.seoCounts?.error ?? input.seoIssues.filter((issue) => issue.severity === \"error\").length;\n const seoWarnings = input.seoCounts?.warning ?? input.seoIssues.filter((issue) => issue.severity === \"warning\").length;\n const schemaErrors = input.schemaCounts?.error ?? input.schemaIssues.filter((issue) => issue.severity === \"error\").length;\n const brokenLinks = input.links.filter((link) => !link.ok && !isUnverifiedLinkStatus(link.status)).length;\n const unverifiedLinks = input.links.filter((link) => !link.ok && isUnverifiedLinkStatus(link.status)).length;\n const redirectLinks = input.links.filter(isRedirect).length;\n const incompleteLinkTargets = unverifiedLinks > 0 || redirectLinks > 0;\n\n const htmlScore = checkFailed(\"html\") || htmlCountsIncomplete ? null : clampScore(100 - htmlErrors * 15 - htmlWarnings * 2);\n const cssScore = checkFailed(\"css\") || !input.cssAudited || cssCompatibilityLimitations > 0 || cssCountsIncomplete\n ? null\n : clampScore(100 - cssErrors * 20);\n const seoScore = checkFailed(\"seo\") || checkFailed(\"schema\") || seoCountsIncomplete || schemaCountsIncomplete\n ? null\n : clampScore(100 - seoErrors * 15 - seoWarnings * 4 - schemaErrors * 15);\n const linkScore = checkFailed(\"links\") || input.links.length === 0 || incompleteLinkTargets\n ? null\n : clampScore(100 - brokenLinks * 25);\n const auditedScores = [htmlScore, seoScore, cssScore, linkScore].filter(\n (score): score is number => score !== null,\n );\n const overallScore = failedChecks.length > 0 || cssCompatibilityLimitations > 0 || incompleteLinkTargets || incompleteCountChecks.length > 0 || auditedScores.length === 0\n ? null\n : Math.round(auditedScores.reduce((total, score) => total + score, 0) / auditedScores.length);\n\n const summary: ValidationReportSummary = {\n overallScore,\n htmlScore,\n cssScore,\n seoScore,\n linkScore,\n htmlErrors,\n htmlWarnings,\n cssErrors,\n cssWarnings,\n cssCompatibilityLimitations,\n seoErrors,\n seoWarnings,\n schemaErrors,\n linksChecked: input.links.length,\n brokenLinks,\n unverifiedLinks,\n };\n\n const report: string[] = [\n `# Web Validation & SEO Audit Report — ${overallScore === null ? \"Partial\" : `${scoreIndicator(overallScore)} **${overallScore}**/100`}`,\n `*Generated for: ${markdownCodeSpan(path.basename(input.htmlFilePath))}*`,\n \"\",\n \"## Page health scores\",\n \"\",\n \"| Audit | Status | Score |\",\n \"| :--- | :---: | :---: |\",\n `| W3C HTML validation | ${htmlScore === null ? \"Unavailable\" : scoreIndicator(htmlScore)} | ${htmlScore === null ? \"N/A\" : `**${htmlScore}** / 100`} |`,\n `| CSS validation | ${cssScore === null ? (checkFailed(\"css\") || cssCountsIncomplete ? \"Unavailable\" : cssCompatibilityLimitations > 0 ? \"Compatibility-limited\" : \"Not audited\") : scoreIndicator(cssScore)} | ${cssScore === null ? \"N/A\" : `**${cssScore}** / 100`} |`,\n `| SEO and accessibility | ${seoScore === null ? \"Unavailable\" : scoreIndicator(seoScore)} | ${seoScore === null ? \"N/A\" : `**${seoScore}** / 100`} |`,\n `| Link integrity | ${linkScore === null ? (checkFailed(\"links\") ? \"Unavailable\" : incompleteLinkTargets ? \"Incomplete\" : \"No links checked\") : scoreIndicator(linkScore)} | ${linkScore === null ? \"N/A\" : `**${linkScore}** / 100`} |`,\n \"\",\n \"## Summary\",\n \"\",\n `- HTML: ${htmlErrors} error(s), ${htmlWarnings} warning(s)${htmlCountsIncomplete ? \" (shown diagnostics only)\" : \"\"}` ,\n `- CSS: ${input.cssAudited ? `${cssErrors} error(s), ${cssWarnings} warning(s)${cssCompatibilityLimitations > 0 ? `, ${cssCompatibilityLimitations} known validator limitation(s)` : \"\"}${cssCountsIncomplete ? \" (shown diagnostics only)\" : \"\"}` : \"not audited\"}`,\n `- SEO and accessibility: ${seoErrors} error(s), ${seoWarnings} warning(s)${seoCountsIncomplete ? \" (shown findings only)\" : \"\"}`,\n `- JSON-LD syntax: ${schemaErrors} error(s)${schemaCountsIncomplete ? \" (shown findings only)\" : \"\"}`,\n `- Links: ${brokenLinks} confirmed HTTP failures, ${unverifiedLinks} unverified, ${redirectLinks} redirect${redirectLinks === 1 ? \"\" : \"s\"} to review of ${input.links.length} checked`,\n \"\",\n `## HTML diagnostics (${htmlTruncated ? `${input.htmlMessages.length} shown of ${htmlTotalMessages}` : htmlTotalMessages})`,\n ];\n\n if (failedChecks.length > 0) {\n report.splice(2, 0, \"\", \"## Partial validation report\", \"The following checks were unavailable: \" + failedChecks.join(\", \") + \". Remaining checks completed.\");\n }\n if (incompleteCountChecks.length > 0) {\n report.splice(2, 0, \"\", \"## Incomplete diagnostic counts\", `${incompleteCountChecks.join(\", \")} diagnostics were truncated without complete severity counts. Full severity counts are unavailable; summary counts reflect only shown findings, and affected audit and overall scores are withheld.`);\n }\n if (unverifiedLinks > 0) {\n report.splice(2, 0, \"\", \"## Incomplete link verification\", `${unverifiedLinks} link check(s) could not be verified because of a network or policy failure. Link and overall scores are withheld; an unverified check is not proof of a broken destination.`);\n }\n if (redirectLinks > 0) {\n report.splice(2, 0, \"\", \"## Unfollowed redirect destinations\", `${redirectLinks} redirect response(s) were observed, but the redirect destination was not checked. Link and overall scores are withheld because a redirect alone does not verify destination availability.`);\n }\n\n if (input.htmlMessages.length === 0) {\n report.push(\"No HTML validation diagnostics were returned.\");\n } else {\n if (htmlTruncated) {\n report.push(`The structured HTML diagnostics are capped; showing the first ${input.htmlMessages.length} of ${htmlTotalMessages}. ${htmlCountsIncomplete ? \"Full severity counts are unavailable, so the HTML score is withheld.\" : \"Summary counts and scoring use all returned Nu diagnostics.\"}`);\n }\n report.push(\"\", \"| Line | Column | Severity | Message | Extract |\", \"| :---: | :---: | :--- | :--- | :--- |\");\n for (const message of input.htmlMessages) {\n report.push(\n `| ${message.lastLine ?? \"N/A\"} | ${message.lastColumn ?? \"N/A\"} | ${markdownCell(getW3CMessageSeverity(message))} | ${markdownCell(message.message)} | ${markdownCell(message.extract ?? \"N/A\")} |`,\n );\n }\n }\n\n if (input.cssAudited) {\n report.push(\"\", `## CSS diagnostics (${cssTruncated ? `${input.cssMessages.length} shown of ${cssTotalMessages}` : cssTotalMessages})`);\n if (input.cssMessages.length === 0) {\n report.push(\"No CSS validation errors or warnings were returned.\");\n } else {\n if (cssTruncated) {\n report.push(`The structured CSS diagnostics are capped; showing the first ${input.cssMessages.length} of ${cssTotalMessages}. ${cssCountsIncomplete ? \"Full severity counts are unavailable, so the CSS score is withheld.\" : \"Summary counts and scoring use all returned Jigsaw diagnostics.\"}`);\n }\n report.push(\"\", \"| Line | Severity | Context | Message |\", \"| :---: | :--- | :--- | :--- |\");\n for (const message of input.cssMessages) {\n report.push(\n `| ${message.line} | ${markdownCell(message.compatibility === \"known-validator-limitation\" ? \"known validator limitation\" : message.type)} | ${markdownCell(message.context ?? \"N/A\")} | ${markdownCell(message.message)} |`,\n );\n }\n if (cssCompatibilityLimitations > 0) {\n report.push(\n \"\",\n `${cssCompatibilityLimitations} known validator limitation(s) match Jigsaw's current parser gap for the standards-defined \\`@container\\` rule. The original Jigsaw diagnostic is preserved, but CSS and overall scores are withheld because this upstream limitation can report valid modern CSS as invalid.`,\n );\n }\n }\n }\n\n const combinedIssues = [...input.seoIssues, ...input.schemaIssues];\n const combinedTotalIssues = seoTotalIssues + schemaTotalIssues;\n const combinedTruncated = seoTruncated || schemaTruncated;\n report.push(\n \"\",\n `## SEO, accessibility, and JSON-LD findings (${combinedTruncated ? `${combinedIssues.length} shown of ${combinedTotalIssues}` : combinedTotalIssues})`,\n );\n if (combinedIssues.length === 0) {\n report.push(\"No SEO, accessibility, or JSON-LD syntax findings were returned.\");\n } else {\n if (seoTruncated) {\n report.push(`The structured SEO/accessibility findings are capped; showing the first ${input.seoIssues.length} of ${seoTotalIssues}. ${seoCountsIncomplete ? \"Full severity counts are unavailable, so the SEO score is withheld.\" : \"Summary counts and scoring use all findings.\"}`);\n }\n if (schemaTruncated) {\n report.push(`The structured JSON-LD findings are capped; showing the first ${input.schemaIssues.length} of ${schemaTotalIssues}. ${schemaCountsIncomplete ? \"Full severity counts are unavailable, so the SEO score is withheld.\" : \"Summary counts and scoring use all findings.\"}`);\n }\n report.push(\"\", \"| Category | Severity | Message | Element |\", \"| :--- | :--- | :--- | :--- |\");\n for (const issue of combinedIssues) {\n report.push(\n `| ${markdownCell(issue.category)} | ${markdownCell(issue.severity)} | ${markdownCell(issue.message)} | ${markdownCell(issue.element ?? \"N/A\")} |`,\n );\n }\n }\n\n report.push(\"\", `## Link health (${input.links.length} checked)`);\n if (input.links.length === 0) {\n report.push(\"No public HTTP(S) links were checked.\");\n } else {\n report.push(\"\", \"| URL | Status | Reachable | Details |\", \"| :--- | :---: | :---: | :--- |\");\n for (const link of input.links) {\n report.push(\n `| ${markdownCell(link.url)} | ${markdownCell(link.status)} | ${isUnverifiedLinkStatus(link.status) ? \"Unverified\" : isRedirect(link) ? \"Redirect\" : link.ok ? \"Yes\" : \"No\"} | ${markdownCell(link.message ?? fallbackLinkMessage(link))} |`,\n );\n }\n }\n\n return {\n report: report.join(\"\\n\"),\n summary,\n htmlMessages: input.htmlMessages,\n htmlTotalMessages,\n htmlTruncated,\n cssMessages: input.cssMessages,\n cssTotalMessages,\n cssTruncated,\n seoIssues: input.seoIssues,\n seoTotalIssues,\n seoTruncated,\n schemaIssues: input.schemaIssues,\n schemaTotalIssues,\n schemaTruncated,\n links: input.links,\n failedChecks,\n ...(input.errors && input.errors.length > 0 ? { errors: input.errors } : {}),\n };\n}\n"]}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import * as http from "node:http";
|
|
1
2
|
export interface ScreenshotTransportProxy {
|
|
2
3
|
url: string;
|
|
3
4
|
close(): Promise<void>;
|
|
4
5
|
}
|
|
6
|
+
export declare function stripHopByHopHeaders(incoming: http.IncomingHttpHeaders): http.OutgoingHttpHeaders;
|
|
7
|
+
export declare function pipeScreenshotUpstreamResponse(upstreamResponse: http.IncomingMessage, response: http.ServerResponse): void;
|
|
5
8
|
export declare function startScreenshotTransportProxy(onBlocked: (message: string) => void): Promise<ScreenshotTransportProxy>;
|
package/dist/screenshot-proxy.js
CHANGED
|
@@ -4,6 +4,39 @@ import * as net from "node:net";
|
|
|
4
4
|
import { getErrorMessage, resolvePublicHttpUrl, } from "./network.js";
|
|
5
5
|
const PROXY_CONNECT_TIMEOUT_MS = 5_000;
|
|
6
6
|
const LOOPBACK_HOST = "127.0.0.1";
|
|
7
|
+
const HOP_BY_HOP_HEADERS = new Set([
|
|
8
|
+
"connection",
|
|
9
|
+
"keep-alive",
|
|
10
|
+
"proxy-authenticate",
|
|
11
|
+
"proxy-authorization",
|
|
12
|
+
"proxy-connection",
|
|
13
|
+
"te",
|
|
14
|
+
"trailer",
|
|
15
|
+
"transfer-encoding",
|
|
16
|
+
"upgrade",
|
|
17
|
+
]);
|
|
18
|
+
export function stripHopByHopHeaders(incoming) {
|
|
19
|
+
const connectionOptions = new Set();
|
|
20
|
+
for (const [name, value] of Object.entries(incoming)) {
|
|
21
|
+
if (name.toLowerCase() !== "connection" && name.toLowerCase() !== "proxy-connection")
|
|
22
|
+
continue;
|
|
23
|
+
for (const part of Array.isArray(value) ? value : value ? [value] : []) {
|
|
24
|
+
for (const option of part.split(",")) {
|
|
25
|
+
const normalized = option.trim().toLowerCase();
|
|
26
|
+
if (normalized)
|
|
27
|
+
connectionOptions.add(normalized);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
const filtered = {};
|
|
32
|
+
for (const [name, value] of Object.entries(incoming)) {
|
|
33
|
+
const normalized = name.toLowerCase();
|
|
34
|
+
if (!HOP_BY_HOP_HEADERS.has(normalized) && !connectionOptions.has(normalized)) {
|
|
35
|
+
filtered[name] = value;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return filtered;
|
|
39
|
+
}
|
|
7
40
|
function createPinnedLookup(addresses) {
|
|
8
41
|
const pinned = addresses.map((record) => ({ ...record }));
|
|
9
42
|
return (_hostname, options, callback) => {
|
|
@@ -65,12 +98,16 @@ async function connectPinnedTcp(addresses, port) {
|
|
|
65
98
|
throw lastError ?? new Error("No validated address was available for the screenshot proxy connection");
|
|
66
99
|
}
|
|
67
100
|
function sendProxyFailure(response) {
|
|
68
|
-
if (
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
101
|
+
if (response.destroyed)
|
|
102
|
+
return;
|
|
103
|
+
if (response.headersSent) {
|
|
104
|
+
response.destroy();
|
|
105
|
+
return;
|
|
73
106
|
}
|
|
107
|
+
response.writeHead(502, {
|
|
108
|
+
Connection: "close",
|
|
109
|
+
"Content-Length": "0",
|
|
110
|
+
});
|
|
74
111
|
response.end();
|
|
75
112
|
}
|
|
76
113
|
function sendTunnelFailure(socket) {
|
|
@@ -92,6 +129,27 @@ function proxyRequestUrl(request) {
|
|
|
92
129
|
}
|
|
93
130
|
return `http://${host}${requestUrl.startsWith("/") ? requestUrl : `/${requestUrl}`}`;
|
|
94
131
|
}
|
|
132
|
+
export function pipeScreenshotUpstreamResponse(upstreamResponse, response) {
|
|
133
|
+
// After headers are forwarded, a broken upstream body cannot become a 502.
|
|
134
|
+
// Tear down the downstream stream instead of delivering a truncated success.
|
|
135
|
+
const interrupt = () => {
|
|
136
|
+
if (!response.destroyed)
|
|
137
|
+
response.destroy();
|
|
138
|
+
};
|
|
139
|
+
upstreamResponse.once("error", interrupt);
|
|
140
|
+
upstreamResponse.once("aborted", interrupt);
|
|
141
|
+
// A socket can close with an incomplete HTTP body without emitting an error.
|
|
142
|
+
upstreamResponse.once("close", () => {
|
|
143
|
+
if (!upstreamResponse.complete)
|
|
144
|
+
interrupt();
|
|
145
|
+
});
|
|
146
|
+
response.once("close", () => {
|
|
147
|
+
if (!upstreamResponse.complete)
|
|
148
|
+
upstreamResponse.destroy();
|
|
149
|
+
});
|
|
150
|
+
response.writeHead(upstreamResponse.statusCode ?? 502, stripHopByHopHeaders(upstreamResponse.headers));
|
|
151
|
+
upstreamResponse.pipe(response);
|
|
152
|
+
}
|
|
95
153
|
async function forwardHttpRequest(request, response, onBlocked) {
|
|
96
154
|
let target;
|
|
97
155
|
try {
|
|
@@ -102,14 +160,8 @@ async function forwardHttpRequest(request, response, onBlocked) {
|
|
|
102
160
|
sendProxyFailure(response);
|
|
103
161
|
return;
|
|
104
162
|
}
|
|
105
|
-
const headers =
|
|
106
|
-
delete headers["proxy-authorization"];
|
|
107
|
-
delete headers["proxy-connection"];
|
|
163
|
+
const headers = stripHopByHopHeaders(request.headers);
|
|
108
164
|
headers.host = target.url.host;
|
|
109
|
-
const handleResponse = (upstreamResponse) => {
|
|
110
|
-
response.writeHead(upstreamResponse.statusCode ?? 502, upstreamResponse.headers);
|
|
111
|
-
upstreamResponse.pipe(response);
|
|
112
|
-
};
|
|
113
165
|
const requestOptions = {
|
|
114
166
|
hostname: target.url.hostname,
|
|
115
167
|
port: target.url.protocol === "https:" ? 443 : 80,
|
|
@@ -125,13 +177,14 @@ async function forwardHttpRequest(request, response, onBlocked) {
|
|
|
125
177
|
...requestOptions,
|
|
126
178
|
servername: target.url.hostname,
|
|
127
179
|
};
|
|
128
|
-
upstreamRequest = https.request(httpsOptions,
|
|
180
|
+
upstreamRequest = https.request(httpsOptions, (upstreamResponse) => pipeScreenshotUpstreamResponse(upstreamResponse, response));
|
|
129
181
|
}
|
|
130
182
|
else {
|
|
131
|
-
upstreamRequest = http.request(requestOptions,
|
|
183
|
+
upstreamRequest = http.request(requestOptions, (upstreamResponse) => pipeScreenshotUpstreamResponse(upstreamResponse, response));
|
|
132
184
|
}
|
|
133
185
|
upstreamRequest.once("error", () => sendProxyFailure(response));
|
|
134
186
|
request.once("aborted", () => upstreamRequest.destroy());
|
|
187
|
+
response.once("close", () => upstreamRequest.destroy());
|
|
135
188
|
request.pipe(upstreamRequest);
|
|
136
189
|
}
|
|
137
190
|
async function forwardConnect(request, clientSocket, head, onBlocked, trackUpstream) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"screenshot-proxy.js","sourceRoot":"","sources":["../src/screenshot-proxy.ts"],"names":[],"mappings":"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AAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAC9B,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,aAAa,EAAE,GAAG,EAAE;YACnC,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YAC7B,OAAO,EAAE,CAAC;QACZ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,CAAC;IACjC,IAAI,CAAC,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAC5C,MAAM,CAAC,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,kEAAkE,CAAC,CAAC;IACtF,CAAC;IAED,IAAI,MAAM,GAAG,KAAK,CAAC;IACnB,OAAO;QACL,GAAG,EAAE,UAAU,aAAa,IAAI,OAAO,CAAC,IAAI,EAAE;QAC9C,KAAK,CAAC,KAAK;YACT,IAAI,MAAM;gBAAE,OAAO;YACnB,MAAM,GAAG,IAAI,CAAC;YACd,MAAM,YAAY,GAAG,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE;gBACjD,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC;YAChC,CAAC,CAAC,CAAC;YACH,KAAK,MAAM,MAAM,IAAI,aAAa;gBAAE,MAAM,CAAC,OAAO,EAAE,CAAC;YACrD,KAAK,MAAM,MAAM,IAAI,eAAe;gBAAE,MAAM,CAAC,OAAO,EAAE,CAAC;YACvD,MAAM,YAAY,CAAC;QACrB,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import * as http from \"node:http\";\nimport * as https from \"node:https\";\nimport * as net from \"node:net\";\nimport {\n getErrorMessage,\n resolvePublicHttpUrl,\n type ResolvedPublicHttpUrl,\n} from \"./network.js\";\n\nconst PROXY_CONNECT_TIMEOUT_MS = 5_000;\nconst LOOPBACK_HOST = \"127.0.0.1\";\n\ntype ResolvedAddress = ResolvedPublicHttpUrl[\"addresses\"][number];\n\nexport interface ScreenshotTransportProxy {\n url: string;\n close(): Promise<void>;\n}\n\nfunction createPinnedLookup(addresses: readonly ResolvedAddress[]): net.LookupFunction {\n const pinned = addresses.map((record) => ({ ...record }));\n return (_hostname, options, callback): void => {\n const requestedFamily = options.family === 4 || options.family === 6 ? options.family : 0;\n const candidates = requestedFamily\n ? pinned.filter((record) => record.family === requestedFamily)\n : pinned;\n if (candidates.length === 0) {\n const error = new Error(\"No validated address is available for the requested IP family\") as NodeJS.ErrnoException;\n error.code = \"ENOTFOUND\";\n callback(error, []);\n return;\n }\n if (options.all) {\n callback(null, candidates);\n return;\n }\n const selected = candidates[0];\n callback(null, selected.address, selected.family);\n };\n}\n\nasync function connectPinnedTcp(\n addresses: readonly ResolvedAddress[],\n port: number,\n): Promise<net.Socket> {\n let lastError: unknown;\n for (const record of addresses) {\n try {\n return await new Promise<net.Socket>((resolve, reject) => {\n const socket = net.connect({\n host: record.address,\n port,\n family: record.family === 6 ? 6 : 4,\n });\n let settled = false;\n let timer: NodeJS.Timeout | undefined;\n const finish = (error?: unknown): void => {\n if (settled) return;\n settled = true;\n if (timer) clearTimeout(timer);\n socket.off(\"error\", onError);\n if (error) {\n socket.destroy();\n reject(error);\n } else {\n resolve(socket);\n }\n };\n const onError = (error: Error): void => finish(error);\n timer = setTimeout(\n () => finish(new Error(\"Pinned screenshot proxy connection timed out\")),\n PROXY_CONNECT_TIMEOUT_MS,\n );\n socket.once(\"error\", onError);\n socket.once(\"connect\", () => finish());\n });\n } catch (error) {\n lastError = error;\n }\n }\n throw lastError ?? new Error(\"No validated address was available for the screenshot proxy connection\");\n}\n\nfunction sendProxyFailure(response: http.ServerResponse): void {\n if (!response.headersSent) {\n response.writeHead(502, {\n Connection: \"close\",\n \"Content-Length\": \"0\",\n });\n }\n response.end();\n}\n\nfunction sendTunnelFailure(socket: net.Socket): void {\n if (socket.destroyed) return;\n socket.end(\n \"HTTP/1.1 502 Bad Gateway\\r\\nConnection: close\\r\\nContent-Length: 0\\r\\n\\r\\n\",\n );\n}\n\nfunction proxyRequestUrl(request: http.IncomingMessage): string {\n const requestUrl = request.url?.trim();\n if (!requestUrl) {\n throw new Error(\"Blocked empty screenshot proxy request URL\");\n }\n if (/^https?:\\/\\//i.test(requestUrl)) {\n return requestUrl;\n }\n const host = request.headers.host?.trim();\n if (!host) {\n throw new Error(\"Blocked screenshot proxy request without a Host header\");\n }\n return `http://${host}${requestUrl.startsWith(\"/\") ? requestUrl : `/${requestUrl}`}`;\n}\n\nasync function forwardHttpRequest(\n request: http.IncomingMessage,\n response: http.ServerResponse,\n onBlocked: (message: string) => void,\n): Promise<void> {\n let target: ResolvedPublicHttpUrl;\n try {\n target = await resolvePublicHttpUrl(proxyRequestUrl(request));\n } catch (error) {\n onBlocked(getErrorMessage(error));\n sendProxyFailure(response);\n return;\n }\n\n const headers: http.OutgoingHttpHeaders = { ...request.headers };\n delete headers[\"proxy-authorization\"];\n delete headers[\"proxy-connection\"];\n headers.host = target.url.host;\n\n const handleResponse = (upstreamResponse: http.IncomingMessage): void => {\n response.writeHead(upstreamResponse.statusCode ?? 502, upstreamResponse.headers);\n upstreamResponse.pipe(response);\n };\n const requestOptions: http.RequestOptions = {\n hostname: target.url.hostname,\n port: target.url.protocol === \"https:\" ? 443 : 80,\n method: request.method,\n path: `${target.url.pathname}${target.url.search}`,\n headers,\n lookup: createPinnedLookup(target.addresses),\n agent: false,\n };\n let upstreamRequest: http.ClientRequest;\n if (target.url.protocol === \"https:\") {\n const httpsOptions: https.RequestOptions = {\n ...requestOptions,\n servername: target.url.hostname,\n };\n upstreamRequest = https.request(httpsOptions, handleResponse);\n } else {\n upstreamRequest = http.request(requestOptions, handleResponse);\n }\n\n upstreamRequest.once(\"error\", () => sendProxyFailure(response));\n request.once(\"aborted\", () => upstreamRequest.destroy());\n request.pipe(upstreamRequest);\n}\n\nasync function forwardConnect(\n request: http.IncomingMessage,\n clientSocket: net.Socket,\n head: Buffer,\n onBlocked: (message: string) => void,\n trackUpstream: (socket: net.Socket) => void,\n): Promise<void> {\n const authority = request.url?.trim();\n if (!authority) {\n onBlocked(\"Blocked empty screenshot proxy tunnel target\");\n sendTunnelFailure(clientSocket);\n return;\n }\n\n let target: ResolvedPublicHttpUrl;\n try {\n target = await resolvePublicHttpUrl(`https://${authority}/`);\n } catch (error) {\n onBlocked(getErrorMessage(error));\n sendTunnelFailure(clientSocket);\n return;\n }\n\n let upstreamSocket: net.Socket;\n try {\n upstreamSocket = await connectPinnedTcp(target.addresses, 443);\n } catch {\n sendTunnelFailure(clientSocket);\n return;\n }\n trackUpstream(upstreamSocket);\n\n clientSocket.write(\"HTTP/1.1 200 Connection Established\\r\\n\\r\\n\");\n if (head.length > 0) upstreamSocket.write(head);\n\n clientSocket.once(\"error\", () => upstreamSocket.destroy());\n upstreamSocket.once(\"error\", () => clientSocket.destroy());\n clientSocket.once(\"close\", () => upstreamSocket.destroy());\n upstreamSocket.once(\"close\", () => clientSocket.destroy());\n clientSocket.pipe(upstreamSocket);\n upstreamSocket.pipe(clientSocket);\n}\n\nexport async function startScreenshotTransportProxy(\n onBlocked: (message: string) => void,\n): Promise<ScreenshotTransportProxy> {\n const clientSockets = new Set<net.Socket>();\n const upstreamSockets = new Set<net.Socket>();\n const server = http.createServer((request, response) => {\n void forwardHttpRequest(request, response, onBlocked).catch(() => {\n sendProxyFailure(response);\n });\n });\n\n server.on(\"connection\", (socket) => {\n clientSockets.add(socket);\n socket.once(\"close\", () => clientSockets.delete(socket));\n });\n server.on(\"connect\", (request, socket, head) => {\n void forwardConnect(\n request,\n socket as net.Socket,\n head,\n onBlocked,\n (upstreamSocket) => {\n upstreamSockets.add(upstreamSocket);\n upstreamSocket.once(\"close\", () => upstreamSockets.delete(upstreamSocket));\n },\n ).catch(() => sendTunnelFailure(socket as net.Socket));\n });\n server.on(\"clientError\", (_error, socket) => {\n if (!socket.destroyed) {\n socket.end(\"HTTP/1.1 400 Bad Request\\r\\nConnection: close\\r\\nContent-Length: 0\\r\\n\\r\\n\");\n }\n });\n\n await new Promise<void>((resolve, reject) => {\n const onError = (error: Error): void => reject(error);\n server.once(\"error\", onError);\n server.listen(0, LOOPBACK_HOST, () => {\n server.off(\"error\", onError);\n resolve();\n });\n });\n\n const address = server.address();\n if (!address || typeof address === \"string\") {\n server.close();\n throw new Error(\"Screenshot transport proxy did not expose a loopback TCP address\");\n }\n\n let closed = false;\n return {\n url: `http://${LOOPBACK_HOST}:${address.port}`,\n async close(): Promise<void> {\n if (closed) return;\n closed = true;\n const closePromise = new Promise<void>((resolve) => {\n server.close(() => resolve());\n });\n for (const socket of clientSockets) socket.destroy();\n for (const socket of upstreamSockets) socket.destroy();\n await closePromise;\n },\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"screenshot-proxy.js","sourceRoot":"","sources":["../src/screenshot-proxy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAChC,OAAO,EACL,eAAe,EACf,oBAAoB,GAErB,MAAM,cAAc,CAAC;AAEtB,MAAM,wBAAwB,GAAG,KAAK,CAAC;AACvC,MAAM,aAAa,GAAG,WAAW,CAAC;AASlC,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAAC;IACjC,YAAY;IACZ,YAAY;IACZ,oBAAoB;IACpB,qBAAqB;IACrB,kBAAkB;IAClB,IAAI;IACJ,SAAS;IACT,mBAAmB;IACnB,SAAS;CACV,CAAC,CAAC;AAEH,MAAM,UAAU,oBAAoB,CAAC,QAAkC;IACrE,MAAM,iBAAiB,GAAG,IAAI,GAAG,EAAU,CAAC;IAC5C,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;QACrD,IAAI,IAAI,CAAC,WAAW,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AAe;gBAAE,MAAM,CAAC,OAAO,EAAE,CAAC;YACvD,MAAM,YAAY,CAAC;QACrB,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import * as http from \"node:http\";\nimport * as https from \"node:https\";\nimport * as net from \"node:net\";\nimport {\n getErrorMessage,\n resolvePublicHttpUrl,\n type ResolvedPublicHttpUrl,\n} from \"./network.js\";\n\nconst PROXY_CONNECT_TIMEOUT_MS = 5_000;\nconst LOOPBACK_HOST = \"127.0.0.1\";\n\ntype ResolvedAddress = ResolvedPublicHttpUrl[\"addresses\"][number];\n\nexport interface ScreenshotTransportProxy {\n url: string;\n close(): Promise<void>;\n}\n\nconst HOP_BY_HOP_HEADERS = new Set([\n \"connection\",\n \"keep-alive\",\n \"proxy-authenticate\",\n \"proxy-authorization\",\n \"proxy-connection\",\n \"te\",\n \"trailer\",\n \"transfer-encoding\",\n \"upgrade\",\n]);\n\nexport function stripHopByHopHeaders(incoming: http.IncomingHttpHeaders): http.OutgoingHttpHeaders {\n const connectionOptions = new Set<string>();\n for (const [name, value] of Object.entries(incoming)) {\n if (name.toLowerCase() !== \"connection\" && name.toLowerCase() !== \"proxy-connection\") continue;\n for (const part of Array.isArray(value) ? value : value ? [value] : []) {\n for (const option of part.split(\",\")) {\n const normalized = option.trim().toLowerCase();\n if (normalized) connectionOptions.add(normalized);\n }\n }\n }\n\n const filtered: http.OutgoingHttpHeaders = {};\n for (const [name, value] of Object.entries(incoming)) {\n const normalized = name.toLowerCase();\n if (!HOP_BY_HOP_HEADERS.has(normalized) && !connectionOptions.has(normalized)) {\n filtered[name] = value;\n }\n }\n return filtered;\n}\n\nfunction createPinnedLookup(addresses: readonly ResolvedAddress[]): net.LookupFunction {\n const pinned = addresses.map((record) => ({ ...record }));\n return (_hostname, options, callback): void => {\n const requestedFamily = options.family === 4 || options.family === 6 ? options.family : 0;\n const candidates = requestedFamily\n ? pinned.filter((record) => record.family === requestedFamily)\n : pinned;\n if (candidates.length === 0) {\n const error = new Error(\"No validated address is available for the requested IP family\") as NodeJS.ErrnoException;\n error.code = \"ENOTFOUND\";\n callback(error, []);\n return;\n }\n if (options.all) {\n callback(null, candidates);\n return;\n }\n const selected = candidates[0];\n callback(null, selected.address, selected.family);\n };\n}\n\nasync function connectPinnedTcp(\n addresses: readonly ResolvedAddress[],\n port: number,\n): Promise<net.Socket> {\n let lastError: unknown;\n for (const record of addresses) {\n try {\n return await new Promise<net.Socket>((resolve, reject) => {\n const socket = net.connect({\n host: record.address,\n port,\n family: record.family === 6 ? 6 : 4,\n });\n let settled = false;\n let timer: NodeJS.Timeout | undefined;\n const finish = (error?: unknown): void => {\n if (settled) return;\n settled = true;\n if (timer) clearTimeout(timer);\n socket.off(\"error\", onError);\n if (error) {\n socket.destroy();\n reject(error);\n } else {\n resolve(socket);\n }\n };\n const onError = (error: Error): void => finish(error);\n timer = setTimeout(\n () => finish(new Error(\"Pinned screenshot proxy connection timed out\")),\n PROXY_CONNECT_TIMEOUT_MS,\n );\n socket.once(\"error\", onError);\n socket.once(\"connect\", () => finish());\n });\n } catch (error) {\n lastError = error;\n }\n }\n throw lastError ?? new Error(\"No validated address was available for the screenshot proxy connection\");\n}\n\nfunction sendProxyFailure(response: http.ServerResponse): void {\n if (response.destroyed) return;\n if (response.headersSent) {\n response.destroy();\n return;\n }\n response.writeHead(502, {\n Connection: \"close\",\n \"Content-Length\": \"0\",\n });\n response.end();\n}\n\nfunction sendTunnelFailure(socket: net.Socket): void {\n if (socket.destroyed) return;\n socket.end(\n \"HTTP/1.1 502 Bad Gateway\\r\\nConnection: close\\r\\nContent-Length: 0\\r\\n\\r\\n\",\n );\n}\n\nfunction proxyRequestUrl(request: http.IncomingMessage): string {\n const requestUrl = request.url?.trim();\n if (!requestUrl) {\n throw new Error(\"Blocked empty screenshot proxy request URL\");\n }\n if (/^https?:\\/\\//i.test(requestUrl)) {\n return requestUrl;\n }\n const host = request.headers.host?.trim();\n if (!host) {\n throw new Error(\"Blocked screenshot proxy request without a Host header\");\n }\n return `http://${host}${requestUrl.startsWith(\"/\") ? requestUrl : `/${requestUrl}`}`;\n}\n\nexport function pipeScreenshotUpstreamResponse(\n upstreamResponse: http.IncomingMessage,\n response: http.ServerResponse,\n): void {\n // After headers are forwarded, a broken upstream body cannot become a 502.\n // Tear down the downstream stream instead of delivering a truncated success.\n const interrupt = (): void => {\n if (!response.destroyed) response.destroy();\n };\n upstreamResponse.once(\"error\", interrupt);\n upstreamResponse.once(\"aborted\", interrupt);\n // A socket can close with an incomplete HTTP body without emitting an error.\n upstreamResponse.once(\"close\", () => {\n if (!upstreamResponse.complete) interrupt();\n });\n response.once(\"close\", () => {\n if (!upstreamResponse.complete) upstreamResponse.destroy();\n });\n response.writeHead(upstreamResponse.statusCode ?? 502, stripHopByHopHeaders(upstreamResponse.headers));\n upstreamResponse.pipe(response);\n}\n\nasync function forwardHttpRequest(\n request: http.IncomingMessage,\n response: http.ServerResponse,\n onBlocked: (message: string) => void,\n): Promise<void> {\n let target: ResolvedPublicHttpUrl;\n try {\n target = await resolvePublicHttpUrl(proxyRequestUrl(request));\n } catch (error) {\n onBlocked(getErrorMessage(error));\n sendProxyFailure(response);\n return;\n }\n\n const headers = stripHopByHopHeaders(request.headers);\n headers.host = target.url.host;\n\n const requestOptions: http.RequestOptions = {\n hostname: target.url.hostname,\n port: target.url.protocol === \"https:\" ? 443 : 80,\n method: request.method,\n path: `${target.url.pathname}${target.url.search}`,\n headers,\n lookup: createPinnedLookup(target.addresses),\n agent: false,\n };\n let upstreamRequest: http.ClientRequest;\n if (target.url.protocol === \"https:\") {\n const httpsOptions: https.RequestOptions = {\n ...requestOptions,\n servername: target.url.hostname,\n };\n upstreamRequest = https.request(httpsOptions, (upstreamResponse) => pipeScreenshotUpstreamResponse(upstreamResponse, response));\n } else {\n upstreamRequest = http.request(requestOptions, (upstreamResponse) => pipeScreenshotUpstreamResponse(upstreamResponse, response));\n }\n\n upstreamRequest.once(\"error\", () => sendProxyFailure(response));\n request.once(\"aborted\", () => upstreamRequest.destroy());\n response.once(\"close\", () => upstreamRequest.destroy());\n request.pipe(upstreamRequest);\n}\n\nasync function forwardConnect(\n request: http.IncomingMessage,\n clientSocket: net.Socket,\n head: Buffer,\n onBlocked: (message: string) => void,\n trackUpstream: (socket: net.Socket) => void,\n): Promise<void> {\n const authority = request.url?.trim();\n if (!authority) {\n onBlocked(\"Blocked empty screenshot proxy tunnel target\");\n sendTunnelFailure(clientSocket);\n return;\n }\n\n let target: ResolvedPublicHttpUrl;\n try {\n target = await resolvePublicHttpUrl(`https://${authority}/`);\n } catch (error) {\n onBlocked(getErrorMessage(error));\n sendTunnelFailure(clientSocket);\n return;\n }\n\n let upstreamSocket: net.Socket;\n try {\n upstreamSocket = await connectPinnedTcp(target.addresses, 443);\n } catch {\n sendTunnelFailure(clientSocket);\n return;\n }\n trackUpstream(upstreamSocket);\n\n clientSocket.write(\"HTTP/1.1 200 Connection Established\\r\\n\\r\\n\");\n if (head.length > 0) upstreamSocket.write(head);\n\n clientSocket.once(\"error\", () => upstreamSocket.destroy());\n upstreamSocket.once(\"error\", () => clientSocket.destroy());\n clientSocket.once(\"close\", () => upstreamSocket.destroy());\n upstreamSocket.once(\"close\", () => clientSocket.destroy());\n clientSocket.pipe(upstreamSocket);\n upstreamSocket.pipe(clientSocket);\n}\n\nexport async function startScreenshotTransportProxy(\n onBlocked: (message: string) => void,\n): Promise<ScreenshotTransportProxy> {\n const clientSockets = new Set<net.Socket>();\n const upstreamSockets = new Set<net.Socket>();\n const server = http.createServer((request, response) => {\n void forwardHttpRequest(request, response, onBlocked).catch(() => {\n sendProxyFailure(response);\n });\n });\n\n server.on(\"connection\", (socket) => {\n clientSockets.add(socket);\n socket.once(\"close\", () => clientSockets.delete(socket));\n });\n server.on(\"connect\", (request, socket, head) => {\n void forwardConnect(\n request,\n socket as net.Socket,\n head,\n onBlocked,\n (upstreamSocket) => {\n upstreamSockets.add(upstreamSocket);\n upstreamSocket.once(\"close\", () => upstreamSockets.delete(upstreamSocket));\n },\n ).catch(() => sendTunnelFailure(socket as net.Socket));\n });\n server.on(\"clientError\", (_error, socket) => {\n if (!socket.destroyed) {\n socket.end(\"HTTP/1.1 400 Bad Request\\r\\nConnection: close\\r\\nContent-Length: 0\\r\\n\\r\\n\");\n }\n });\n\n await new Promise<void>((resolve, reject) => {\n const onError = (error: Error): void => reject(error);\n server.once(\"error\", onError);\n server.listen(0, LOOPBACK_HOST, () => {\n server.off(\"error\", onError);\n resolve();\n });\n });\n\n const address = server.address();\n if (!address || typeof address === \"string\") {\n server.close();\n throw new Error(\"Screenshot transport proxy did not expose a loopback TCP address\");\n }\n\n let closed = false;\n return {\n url: `http://${LOOPBACK_HOST}:${address.port}`,\n async close(): Promise<void> {\n if (closed) return;\n closed = true;\n const closePromise = new Promise<void>((resolve) => {\n server.close(() => resolve());\n });\n for (const socket of clientSockets) socket.destroy();\n for (const socket of upstreamSockets) socket.destroy();\n await closePromise;\n },\n };\n}\n"]}
|
package/dist/screenshot.d.ts
CHANGED
|
@@ -10,6 +10,12 @@ export interface ScreenshotResult {
|
|
|
10
10
|
width: number;
|
|
11
11
|
height: number;
|
|
12
12
|
outputPath: string;
|
|
13
|
+
incompleteAssetCount?: number;
|
|
14
|
+
}
|
|
15
|
+
/** Carries paths already written when a later viewport cannot be captured. */
|
|
16
|
+
export declare class PartialScreenshotCaptureError extends Error {
|
|
17
|
+
readonly screenshots: ScreenshotResult[];
|
|
18
|
+
constructor(cause: unknown, screenshots: ScreenshotResult[]);
|
|
13
19
|
}
|
|
14
20
|
export declare const SCREENSHOT_HEADLESS_MODE: "shell";
|
|
15
21
|
export declare const SCREENSHOT_BROWSER_BUILD_ID = "156.0.8078.47";
|