Files
reverse-engineering-anything/src/domain/webBundleAnalyzerState.ts
T
morluto 7b500d7833 fix(browser): report non-literal request URLs as unknown endpoints instead of dropping them (#11630)
* fix(browser): report non-literal request URLs as unknown endpoints instead of dropping them

* fix(browser): read XHR URLs from the proven request kind and bound view call sites
2026-11-16 09:12:44 +08:00

51 lines
1.7 KiB
TypeScript

import type { WebPageInspection } from "./browserObservationSchemas.js";
import type {
WebBundleAnalysis,
WebBundleCallSite,
} from "./webBundleAnalysis.js";
type BundleObservations = WebBundleAnalysis["observations"];
type BrowserScript = WebPageInspection["scripts"]["items"][number];
type IncludedSource = Extract<BrowserScript["source"], { included: true }>;
/** Captured script whose source bytes are available for inert analysis. */
export type IncludedScript = Omit<BrowserScript, "source"> & {
readonly source: IncludedSource;
};
/** Mutable facts shared by per-script inspection and bundle result assembly. */
export interface AnalysisAccumulator {
readonly edges: BundleObservations["chunks"]["edges"];
readonly routes: BundleObservations["routes"];
readonly endpoints: BundleObservations["endpoints"];
/** Browser requests whose URL argument is not a string literal. */
readonly unresolvedEndpoints: WebBundleCallSite[];
readonly webMcp: BundleObservations["webmcp_declarations"];
readonly inferences: WebBundleAnalysis["inferences"];
readonly seen: Set<string>;
visitedNodes: number;
parsedScripts: number;
readonly failedScripts: string[];
readonly recoveredScripts: string[];
readonly widenedScripts: string[];
}
export const createWebBundleAnalysisAccumulator = (): AnalysisAccumulator => ({
edges: [],
routes: [],
endpoints: [],
unresolvedEndpoints: [],
webMcp: [],
inferences: [],
seen: new Set(),
visitedNodes: 0,
parsedScripts: 0,
failedScripts: [],
recoveredScripts: [],
widenedScripts: [],
});
export const isIncludedScript = (
script: BrowserScript,
): script is IncludedScript => script.source.included;