# Session cookie TLS proof

The scenario drives the real T3 HTTP endpoints in Chromium and reads its cookie jar. A local HTTPS reverse proxy terminates real TLS and forwards `X-Forwarded-Proto: https`; a second plain HTTP proxy forwards no TLS claim. Both use the same non-loopback IPv4 address, avoiding Chromium's localhost exceptions for Secure cookies. No auth response is mocked.

The screenshots are a diagnostic view of the observed server responses, request cookie names, browser cookie flags, and token equality checks. Credential values are redacted. Fresh one-time pairing tokens are minted through the real app; the synthetic project is created with the scenario fixture. A fresh browser context and fresh server database are used on each commit.

## Run

Use current main's scenario runner, dependencies installed with `vp i`, and place `session-cookie-tls.e2e.ts` in `scripts/scenarios/`. Install its browser with `node scripts/node_modules/playwright-core/cli.js install --only-shell chromium ffmpeg`.

Create a scratch directory and set `COOKIE_PROOF_SCRATCH` to its absolute path. Generate the throwaway local TLS certificate:

```sh
openssl req -x509 -newkey rsa:2048 -nodes -keyout "$COOKIE_PROOF_SCRATCH/key.pem" -out "$COOKIE_PROOF_SCRATCH/cert.pem" -days 2 -subj /CN=Cookie-proof
```

From the checkout root, run the attached `browser.mjs` in a separate terminal, with that same environment variable. It starts headless Chromium on CDP port 19333 with `--ignore-certificate-errors` for the throwaway certificate; normal Secure-cookie behavior remains enabled. In `scripts/e2e.config.ts`, add `connect: { cdpEndpoint: () => "http://127.0.0.1:19333" }` to the existing web engine options.

```sh
T3CODE_DEV_SEED=0 T3_SCENARIO_INHERIT_ENV='COOKIE_PROOF_SCRATCH,T3CODE_DEV_SEED' vp run scenarios:prove scripts/scenarios/session-cookie-tls.e2e.ts --base a68c367e4ff3d31a4a43493f6b22f83de1c6eb35 --head bff6a42a2fa5a3c475dfb61cbfd4de227c10052f --upload-command 'ghdrop upload'
```

Stop the browser with Ctrl-C afterwards. Proof data is written under `scripts/.e2e/prove/`.
