Skip to content

Commit c57ec9c

Browse files
test(desktop): seed fixture targets the Node inspector and rejects unisolated XDG paths
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent cb12fd5 commit c57ec9c

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

‎apps/desktop/scripts/seed-keyring-repro.mjs‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ const targetId = (
1717
const token = (await NodeFSP.readFile(tokenFile, "utf8")).trim().split("\n").at(-1);
1818
const home = NodePath.resolve(desktopHome);
1919
const targets = await (await fetch("http://127.0.0.1:9339/json/list")).json();
20-
const ws = new WebSocket(targets[0].webSocketDebuggerUrl);
20+
const mainTarget = targets.find((target) => target.type === "node" && target.webSocketDebuggerUrl);
21+
if (!mainTarget) throw new Error("No Node main-process inspector target on port 9339");
22+
const ws = new WebSocket(mainTarget.webSocketDebuggerUrl);
2123
await new Promise((accept, reject) => {
2224
ws.addEventListener("open", accept, { once: true });
2325
ws.addEventListener("error", reject, { once: true });
@@ -36,7 +38,12 @@ const expression = `(() => {
3638
const path = process.getBuiltinModule('path');
3739
const os = process.getBuiltinModule('os');
3840
const home = ${JSON.stringify(home)};
39-
if (path.resolve(process.env.T3CODE_HOME || '') !== home || home === path.join(os.homedir(), '.t3') || !process.env.XDG_CONFIG_HOME || !process.env.XDG_DATA_HOME) {
41+
// Desktop config trims XDG values and falls back to the real defaults when blank.
42+
const isolated = (name, fallback) => {
43+
const value = process.env[name] || '';
44+
return value === value.trim() && path.isAbsolute(value) && path.resolve(value) !== path.join(os.homedir(), fallback);
45+
};
46+
if (path.resolve(process.env.T3CODE_HOME || '') !== home || home === path.join(os.homedir(), '.t3') || !isolated('XDG_CONFIG_HOME', '.config') || !isolated('XDG_DATA_HOME', '.local/share')) {
4047
throw new Error('Requires matching isolated T3CODE_HOME and isolated XDG directories');
4148
}
4249
const E = process.getBuiltinModule('module').createRequire(process.cwd() + '/fixture.cjs')('electron');

0 commit comments

Comments
 (0)