fix(browser): redact transitional target titles

This commit is contained in:
N0zoM1z0
2026-07-22 22:09:12 +09:00
committed by N0zoM1z0
parent d25e98c3f9
commit f6095cb6ba
72 changed files with 198 additions and 140 deletions
+19 -5
View File
@@ -62,7 +62,11 @@ interface FakeOptions {
readonly webMcpChildLeavesScope?: boolean;
readonly electronFileUrl?: string;
readonly duplicateElectronInventory?: boolean;
readonly urlShapedAllowedTitle?: boolean;
readonly urlShapedAllowedTitle?:
| boolean
| "host-path"
| "root-relative"
| "prefixed";
}
/** Start a real HTTP/WebSocket fake at the same seams as a user-owned browser. */
@@ -226,10 +230,7 @@ const targets = (
{
id: "allowed-page",
type: "page",
title:
options.urlShapedAllowedTitle === true
? `http://127.0.0.1:${String(port)}/app?startup=title-secret#fragment`
: "Inspectable application",
title: allowedPageTitle(port, options.urlShapedAllowedTitle),
url: `http://127.0.0.1:${String(port)}/app?token=page-secret#fragment`,
attached: false,
...(options.omitTargetWebSocket === true
@@ -333,6 +334,19 @@ const targets = (
]),
];
const allowedPageTitle = (
port: number,
style: FakeOptions["urlShapedAllowedTitle"],
): string => {
const suffix = "/app?startup=title-secret#fragment";
const host = `127.0.0.1:${String(port)}`;
if (style === true) return `http://${host}${suffix}`;
if (style === "host-path") return `${host}${suffix}`;
if (style === "root-relative") return suffix;
if (style === "prefixed") return `Loading ${host}${suffix}`;
return "Inspectable application";
};
const parseCommand = (text: string): FakeCdpCommand => {
const value: unknown = JSON.parse(text);
if (typeof value !== "object" || value === null)