import { execDockerSshHostTargetCommand, execDockerSshHostTargetControlCommand, writeDockerSshHostTargetFile, type DockerSshHostTarget } from './docker-ssh-host-target' import { quotePosixShell } from '../../../src/shared/shell/launch/shell-argument-quoting' // Only the SSH container can resolve and reach this loopback origin; rendering its marker proves tunneled egress. export const SSH_REMOTE_ONLY_HOST = 'remote-only.internal' export const SSH_REMOTE_ONLY_PORT = 18_080 export const SSH_REMOTE_ONLY_ORIGIN = `http://${SSH_REMOTE_ONLY_HOST}:${SSH_REMOTE_ONLY_PORT}` export const SSH_REMOTE_ONLY_COOKIE_NAME = 'sta4150ssh' export const SSH_REMOTE_ONLY_COOKIE_VALUE = 'survivor' const SERVER_PATH = '/tmp/sta-4150-ssh-browser-fixture.js' const REQUEST_LOG_PATH = '/tmp/sta-4150-ssh-browser-requests.log' export type SshRemoteOnlyRequest = { path: string; cookie: string | null } const SERVER_SOURCE = [ 'const http = require("node:http")', 'const fs = require("node:fs")', `const log = ${JSON.stringify(REQUEST_LOG_PATH)}`, 'http', ' .createServer((request, response) => {', ' const url = new URL(request.url || "/", "http://fixture.invalid")', ' const cookie = request.headers.cookie || null', ' fs.appendFileSync(log, JSON.stringify({ path: url.pathname, cookie }) + "\\n")', ' const isLogin = url.pathname === "/login"', ' const marker = isLogin ? "login-marker" : "cookie:" + (cookie || "none")', ' const headers = {', ' "cache-control": "no-store",', ' "content-type": "text/html; charset=utf-8"', ' }', ' if (isLogin) {', ` headers["set-cookie"] = ${JSON.stringify( `${SSH_REMOTE_ONLY_COOKIE_NAME}=${SSH_REMOTE_ONLY_COOKIE_VALUE}; Max-Age=3600; Path=/; SameSite=Lax` )}`, ' }', ' response.writeHead(200, headers)', ' response.end(', ' "