Skip to content

Add the browser send proxy and web sender - #572

Merged
gschier merged 19 commits into
mainfrom
claude/affectionate-swirles-c0d950
Aug 18, 2026
Merged

Add the browser send proxy and web sender#572
gschier merged 19 commits into
mainfrom
claude/affectionate-swirles-c0d950

Conversation

@gschier

@gschier gschier commented Aug 17, 2026

Copy link
Copy Markdown
Member

Slice 2 of Yaak in the browser: sending. A tab renders the request; a small stateless proxy puts it on the network with the desktop's own engine and streams back everything the tab can't see on its own (all headers, redirect chain, timeline, body); the tab stores it in its wasm database.

  • crates-server/yaak-send-proxy: one binary over yaak-http's HttpTransaction (not crates/yaak, which would drag plugins along). POST /v1/http/send in, NDJSON frames out, nothing at rest. Refuses private/loopback/link-local/metadata ranges after DNS, on every redirect hop (new AddressFilter on the resolver, desktop passes None; plus a per-hop URL check for literal IPs), with size caps, timeout ceiling, per-IP rate limit, host allow/deny lists, optional token. --allow-private-networks for self-hosting. README covers running, self-hosting and the wire.
  • Web host: prepare_http_send in the wasm worker (env chain, inheritance, settings, cookie jar, rendering) → send.ts posts and writes back the response row, http_response_event rows, the body blob and the cookie jar. httpSending and timeline are now true.
  • render_http_request and path_placeholders moved into yaak-models so the wasm host renders with the same code; re-exported from yaak::render and yaak_http::path_placeholders, desktop and CLI callers unchanged. regexregex-lite there.

Sends today: any saved request with ${[ variable ]} templates and no auth. Auth plugins and template functions are refused with a message naming what's missing until the plugin Worker lands. WS/gRPC relays are later routes on the same binary, not built.

Verified in Chromium against a local proxy: 11/11 response headers, timeline with per-hop DNS and the redirect chain, POST body, Set-Cookie into the jar surviving reload, PNG body; 169.254.169.254, 127.0.0.1, localhost (→ ::1) and a redirect to 127.0.0.1 all refused. Desktop (--features wry) and CLI compile; touched-crate tests pass.

crates-server/yaak-send-proxy: a stateless executor over yaak-http's
HttpTransaction. It takes a rendered request, streams timeline events,
the response head, body chunks and the resulting cookies back as NDJSON,
and keeps nothing. Private/loopback/link-local/metadata ranges are refused
after DNS on every hop (an AddressFilter on the resolver plus a per-hop URL
check), with size caps, a timeout ceiling, a rate limit, host allow/deny
lists and an optional token.

The web host now sends through it: the wasm worker resolves and renders
the request (render_http_request moved into yaak-models so it builds for
wasm; re-exported from its old paths), the tab posts it, and stores what
comes back where the desktop stores it. Requests needing auth plugins or
template functions are refused with the reason until plugins run in the
browser.
@gschier

gschier commented Aug 17, 2026

Copy link
Copy Markdown
Member Author

@greptile-apps review please

@greptile-apps

greptile-apps Bot commented Aug 17, 2026

Copy link
Copy Markdown

Greptile Summary

The PR adds browser HTTP sending through a stateless Rust proxy and persists streamed responses, events, bodies, and cookie updates in the browser database. The cookie conflict fix remains incomplete when the response and user concurrently modify the same cookie.

  • Adds the guarded, rate-limited NDJSON HTTP send proxy.
  • Adds browser-side request preparation, streaming response persistence, and cookie reconciliation.
  • Moves shared request rendering and placeholder handling into yaak-models.

Confidence Score: 4/5

The PR should not merge until same-key cookie reconciliation stops overwriting user edits made during an in-flight send.

The reply claims the delta-based persistence makes an in-flight cookie edit survive, but apply_cookie_changes still replaces the current cookie whenever the response changes the same name, domain, and path, providing a concrete residual counterexample.

Files Needing Attention: crates/yaak-models/src/cookies.rs, crates/yaak-web/src/lib.rs

Important Files Changed

Filename Overview
crates/yaak-models/src/cookies.rs Introduces cookie-delta reconciliation, but same-key response updates overwrite concurrent user edits.
crates/yaak-web/src/lib.rs Adds browser request preparation and persistence handlers, including write-time cookie-jar reconciliation through the flawed delta helper.
packages/platform/src/web/send.ts Implements proxy streaming and browser response persistence while forwarding send-start and terminal cookie snapshots to WASM.
crates-server/yaak-send-proxy/src/guard.rs Enforces destination filtering for literal and resolved addresses, including outright refusal of the NAT64 local-use range.
crates-server/yaak-send-proxy/src/send.rs Executes guarded HTTP transactions and streams response metadata, events, body chunks, terminal statistics, and cookies.
crates/yaak-http/src/dns.rs Adds resolver-level address filtering used to enforce destination policy after DNS resolution.

Sequence Diagram

sequenceDiagram
  participant UI as Browser UI
  participant W as WASM Worker
  participant P as Send Proxy
  participant E as Endpoint
  participant DB as Browser Database
  UI->>W: Prepare rendered request and cookie snapshot
  W-->>UI: Prepared request
  UI->>P: POST /v1/http/send
  P->>E: Guarded HTTP request
  E-->>P: Headers, body, redirects, Set-Cookie
  P-->>UI: NDJSON events, response, body, terminal cookies
  UI->>W: Persist response and cookie delta
  W->>DB: Apply delta to current jar and store results
Loading

Reviews (4): Last reviewed commit: "Refuse the NAT64 local-use range outrigh..." | Re-trigger Greptile

Comment thread packages/platform/src/web/send.ts Outdated
Comment thread crates-server/yaak-send-proxy/src/guard.rs Outdated
@gschier

gschier commented Aug 17, 2026

Copy link
Copy Markdown
Member Author

@greptile-apps

@gschier

gschier commented Aug 17, 2026

Copy link
Copy Markdown
Member Author

@greptile-apps review again

Comment thread crates/yaak-web/src/lib.rs
Comment thread crates-server/yaak-send-proxy/src/guard.rs Outdated
Comment thread crates/yaak-models/src/cookies.rs
@gschier
gschier merged commit 6908391 into main Aug 18, 2026
6 checks passed
@gschier
gschier deleted the claude/affectionate-swirles-c0d950 branch August 18, 2026 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant