@webpieces/http-client-core
v0.4.741
Published
Isomorphic core of the webpieces HTTP client: the decorator-driven ProxyClient, error translation, and the Proxy trap shared by http-client-node and http-client-browser
Readme
@webpieces/http-client-core
The isomorphic engine behind the webpieces HTTP clients. You almost certainly want one of:
- @webpieces/http-client-node — server-side: inversify-wired, reads
RequestContext, mints OIDC / shared-secret delivery auth, resolves Cloud Run URLs from a service name. - @webpieces/http-client-browser — browser: DI-free (React or Angular), app-managed context store, no AsyncLocalStorage.
This package holds what they share: ProxyClient (contract decorators → HTTP request),
buildClientProxy (the typed Proxy trap), ClientTarget, and ClientErrorTranslator.
The one seam between the two environments is the abstract ProxyClient.outboundContextHeaders(destination):
RequestContextHeaders answers it on the server (via @webpieces/core-context), ContextMgr (in
@webpieces/core-util) in a browser. Keeping that a seam is what lets this package depend on
nothing but core-util, so no node-only import can reach a browser bundle.
destination is a DestinationTrust, derived here from the route's own AuthMode, and it decides
whether TRUSTED context keys (x-user-id, x-org-id, x-webpieces-roles) ride along: only an
endpoint that authenticates its caller (@AuthOidc / @AuthSharedSecret) receives them. Untrusted
keys always travel. See docs/architecture/context-propagation.md.
