refactor(browser): clarify inspector capture identifiers

This commit is contained in:
morluto
2026-07-24 13:34:07 +00:00
parent fd25a7e15a
commit ca035a75eb
3 changed files with 17 additions and 12 deletions
+8 -5
View File
@@ -16,14 +16,17 @@ type ExclusionReason =
| "unsupported_location";
/** Empty durable-location exclusion counters. */
export const v8ExclusionCounts = (): Record<ExclusionReason, number> => ({
export const createInspectorExclusionCounts = (): Record<
ExclusionReason,
number
> => ({
outside_file_roots: 0,
outside_origins: 0,
unsupported_location: 0,
});
/** Stable safety and protocol limitations shared by target-list Evidence. */
export const v8TargetLimitations = (): string[] => [
export const describeInspectorTargetLimitations = (): string[] => [
"REA attaches to an already-running exact target and never launches, resumes, evaluates, pauses, or mutates it.",
"Only Runtime.enable and Debugger.enable are sent; source text, object values, EventEmitter activity, and Electron IPC are not inspected.",
"Target IDs and locations are authorized, but the Inspector protocol does not authenticate an operating-system process ID or Electron role.",
@@ -39,14 +42,14 @@ interface FinalizeCaptureInput {
}
/** Canonically authorize, deduplicate, and sort one bounded raw capture. */
export const finalizeV8InspectorCapture = async ({
export const finalizeInspectorCapture = async ({
input,
runtime,
target,
roots,
state,
}: FinalizeCaptureInput): Promise<JavaScriptRuntimeObservation> => {
const exclusions = v8ExclusionCounts();
const exclusions = createInspectorExclusionCounts();
const scripts = new Map<
string,
JavaScriptRuntimeObservation["scripts"]["items"][number]
@@ -119,7 +122,7 @@ export const finalizeV8InspectorCapture = async ({
"A bounded observation window cannot establish that an unobserved script or behavior never occurs.",
"The declared Node/Electron process role is not authenticated by the Inspector protocol.",
],
limitations: v8TargetLimitations(),
limitations: describeInspectorTargetLimitations(),
};
};
+6 -6
View File
@@ -31,9 +31,9 @@ import {
canonicalRuntimeRoots,
} from "./JavaScriptRuntimeScope.js";
import {
finalizeV8InspectorCapture,
v8ExclusionCounts,
v8TargetLimitations,
createInspectorExclusionCounts,
describeInspectorTargetLimitations,
finalizeInspectorCapture,
} from "./V8InspectorCaptureProjection.js";
import {
discoverV8Inspector,
@@ -93,7 +93,7 @@ export class V8InspectorProvider implements JavaScriptRuntimeObservationPort {
options.signal,
);
const allowed: AuthorizedV8InspectorTarget[] = [];
const excluded = v8ExclusionCounts();
const excluded = createInspectorExclusionCounts();
for (const target of discovery.targets) {
const decision = await authorizeRuntimeLocation(
target.url,
@@ -128,7 +128,7 @@ export class V8InspectorProvider implements JavaScriptRuntimeObservationPort {
has_more: nextOffset < allowed.length,
},
excluded: { ...excluded, unconnectable: 0 },
limitations: v8TargetLimitations(),
limitations: describeInspectorTargetLimitations(),
}),
);
} catch (cause: unknown) {
@@ -166,7 +166,7 @@ export class V8InspectorProvider implements JavaScriptRuntimeObservationPort {
} finally {
removeListener();
}
const result = await finalizeV8InspectorCapture({
const result = await finalizeInspectorCapture({
input,
runtime: discovery.runtime,
target,
+3 -1
View File
@@ -256,8 +256,10 @@ describe("browserScenarioSchema", () => {
});
it("rejects embedded URL credentials and query values", () => {
const credentialedUrl = new URL("https://app.example.test/");
credentialedUrl.username = String.fromCodePoint(120);
for (const url of [
"https://user@app.example.test/",
credentialedUrl.href,
"https://app.example.test/?token=raw",
]) {
const scenario = baseScenario();