fix(providers): admit credential endpoints and bound responses

Merged
TH
2h ago
+604-72

Summary

BrowserStack/TestMu requests that carry credentials go only to HTTPS or loopback-HTTP endpoints and never follow redirects. Every provider response body (WebDriver hub, Revyl, Limrun) is read through one bounded reader. The endpoint URL comes from user config or profile; the response bytes come from the provider.

Before / after

  • Before: credentials could be sent over cleartext public HTTP, a redirect could carry them to another host, and response.text() / arrayBuffer() / json() read unbounded provider bodies.
  • After: the credentialTransportRefusal rule (through admitCredentialDestination, including the AGENT_DEVICE_ALLOW_INSECURE_TRANSPORT override) is checked with the host env before each credentialed request. Credentialed requests use redirect: 'manual', and any 3xx gives provider_redirect_refused. Requests without credentials keep following redirects.
  • @agent-device/host-kit/response-body reads bodies with a 1 MiB budget. Successful screenshot and source answers, Revyl artifact answers, and provider catalog or app-list replies get 32 MiB. Overflow gives provider_response_too_large with the HTTP status. An oversized Revyl error body is dropped, so the status classifier still runs.
  • Limrun's file download keeps createByteLimitStream (2 GiB cap). Info.plist and release manifest reads pass a 256 KiB budget.
  • The host-kit readers load on demand, so the eager module closures stay within budget.

Out of scope: long-lived streaming bodies, such as the Limrun /xctest/run success stream.

Size

About 260 production lines versus 0.22.

Validation

Ran the provider package suites, packages/host-kit/src/response-body.test.ts, and scripts/__tests__/eager-closure-budgets.test.ts with vitest. All passed.