Documentation Index
Fetch the complete documentation index at: https://docs.kynesys.xyz/llms.txt
Use this file to discover all available pages before exploring further.
Web2 Proxy (DAHR)
The DAHR — Data Agnostic HTTPS Relay — lets a client send an arbitrary HTTP(S) request through a Demos node instead of making it directly. The node forwards the request to the target, returns the response, and computes deterministic hashes over the response so the result can later be attested. The feature lives undersrc/features/web2/:
handleWeb2.ts— entry point; sanitizes the request and asks the factory for a DAHR instance.dahr/DAHR.ts— the relay session itself (owns a session ID and aProxy).dahr/DAHRFactory.ts— singleton that creates and tracks DAHR sessions, expiring them after 24 hours.proxy/Proxy.ts,proxy/ProxyFactory.ts— the per-session HTTP proxy server that actually forwards traffic.validator.ts— URL validation and SSRF protection.sanitizeWeb2Request.ts— strips/redacts sensitive headers for logging and storage.
RPC entry point
The proxy is reached through the JSON-RPC methodweb2ProxyRequest.
- Handler:
src/libs/network/routines/transactions/handleWeb2ProxyRequest.ts - Parser:
parseWeb2ProxyRequestinsrc/libs/utils/web2RequestUtils.ts
web2Request.raw.action (an EnumWeb2Actions value):
CREATE
Creates a DAHR session via
handleWeb2. Returns the serialized DAHR
({ sessionId, web2Request }) on success (HTTP-style result: 200), or an
error with result: 400.START_PROXY
Looks up the DAHR by
sessionId, validates/normalizes the target URL, then
forwards the request and returns the IWeb2Result.Unsupported action: <action>. The two action
values verified in source are EnumWeb2Actions.CREATE and
EnumWeb2Actions.START_PROXY.
Session model
- The client sends a
CREATErequest.DAHRFactory.instance.createDAHR()builds aDAHR, which generates a uniquesessionIdand constructs aProxybound to that ID. - The factory stores the session in an in-memory map keyed by
sessionId, trackinglastAccess. Sessions older than 24 hours are cleaned up (their proxy is stopped) on the nextcreateDAHRcall. - The client sends a
START_PROXYrequest carrying thesessionId. The node spins up a local proxy server (listening on an ephemeral port on0.0.0.0), forwards the request to the validated target, and returns the response. - Requests to the local proxy are authorized with an
x-dahr-session-idheader that must match the session ID (enforced whenrequireAuthForAllis on, which defaults to production mode).
Request and result shapes
IWeb2Request carries a raw object describing the request, plus result,
hash, and signature fields. The raw object includes:
action— anEnumWeb2Actionsvalue (CREATE/START_PROXY).url— the target URL (validated and normalized before use).method— the HTTP method (Web2Method).headers— optional request headers.
IWeb2Result is what Proxy.sendHTTPRequest resolves to:
| Field | Description |
|---|---|
status | Numeric HTTP status code from the target. |
statusText | HTTP status message. |
headers | Response headers from the target. |
data | Response body as a string. |
responseHash | SHA-256 over the exact UTF-8 bytes of the response body. |
responseHeadersHash | SHA-256 over the canonicalized response headers. |
requestHash | (optional) SHA-256 over the request body bytes, present only when a body was sent. |
responseHeadersHash lowercases keys, drops
volatile/hop-by-hop headers (date, set-cookie, connection,
content-length, etc.), and sorts by key, so the hash is deterministic across
intermediaries.
Security hardening
The proxy is built to resist SSRF and credential leakage:- URL validation (
validateAndNormalizeHttpUrl): onlyhttp/httpsschemes; rejects embedded credentials, missing hostnames,localhost, and loopback / private / link-local / reserved IP ranges (IPv4, IPv6, and IPv4-mapped IPv6); canonicalizes host, strips default ports, removes fragments. - DNS preflight (
Proxy): the resolved address is re-checked against the disallowed ranges at request time, in case DNS has changed since validation. - Header sanitization (
sanitizeWeb2Request.ts): sensitive headers such asauthorization,cookie,x-api-key, andx-auth-tokenare stripped before storage and redacted before logging. - TLS verification: certificate verification follows the node’s
PRODflag (enabled in production, disabled in development).
The source notes a
TODO that Web2 requests may eventually need to be signed
and may carry a fee. Treat that as not-yet-implemented.