Add the browser send proxy and web sender - #572
Conversation
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.
|
@greptile-apps review please |
Greptile SummaryThe 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.
Confidence Score: 4/5The 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 Files Needing Attention: crates/yaak-models/src/cookies.rs, crates/yaak-web/src/lib.rs
|
| 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
Reviews (4): Last reviewed commit: "Refuse the NAT64 local-use range outrigh..." | Re-trigger Greptile
|
@greptile-apps review again |
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 overyaak-http'sHttpTransaction(notcrates/yaak, which would drag plugins along).POST /v1/http/sendin, NDJSON frames out, nothing at rest. Refuses private/loopback/link-local/metadata ranges after DNS, on every redirect hop (newAddressFilteron the resolver, desktop passesNone; 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-networksfor self-hosting. README covers running, self-hosting and the wire.prepare_http_sendin the wasm worker (env chain, inheritance, settings, cookie jar, rendering) →send.tsposts and writes back the response row,http_response_eventrows, the body blob and the cookie jar.httpSendingandtimelineare now true.render_http_requestandpath_placeholdersmoved intoyaak-modelsso the wasm host renders with the same code; re-exported fromyaak::renderandyaak_http::path_placeholders, desktop and CLI callers unchanged.regex→regex-litethere.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 to127.0.0.1all refused. Desktop (--features wry) and CLI compile; touched-crate tests pass.