Skip to content

@btravstack/http-client


@btravstack/http-client ​

Classes ​

HttpCancelled ​

Defined in: packages/http-client/src/contracts.ts:64

The caller cancelled and the connection was destroyed.

Extends ​

  • TaggedErrorInstance<"HttpCancelled", { }>

Constructors ​

Constructor ​
ts
new HttpCancelled(args): HttpCancelled;

Defined in: node_modules/.pnpm/unthrown@5.12.1/node_modules/unthrown/dist/index.d.mts:2386

Parameters ​
ParameterType
argsvoid
Returns ​

HttpCancelled

Inherited from ​

TaggedError("HttpCancelled").constructor

Properties ​

PropertyModifierTypeInherited fromDefined in
_tagreadonly"HttpCancelled"TaggedError("HttpCancelled")._tagnode_modules/.pnpm/unthrown@5.12.1/node_modules/unthrown/dist/index.d.mts:2363
cause?publicunknownTaggedError("HttpCancelled").causenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2022.error.d.ts:24
messagepublicstringTaggedError("HttpCancelled").messagenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1075
namepublicstringTaggedError("HttpCancelled").namenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1074
stack?publicstringTaggedError("HttpCancelled").stacknode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1076

HttpClient ​

Defined in: packages/http-client/src/contracts.ts:100

One policy-bound outbound client per application graph.

Extends ​

Constructors ​

Constructor ​
ts
new HttpClient(): HttpClient;

Defined in: packages/di/dist/index.d.mts:15

Returns ​

HttpClient

Inherited from ​

Port("HttpClient")<HttpClientService>.constructor

Properties ​

PropertyModifierTypeInherited fromDefined in
[ID]readonly"HttpClient"Port("HttpClient").[ID]packages/di/dist/index.d.mts:11
[SERVICE]readonlyHttpClientServicePort("HttpClient").[SERVICE]packages/di/dist/index.d.mts:12
portIdstatic readonly"HttpClient"Port("HttpClient").portIdpackages/di/dist/index.d.mts:16

HttpDeadlineExceeded ​

Defined in: packages/http-client/src/contracts.ts:62

The whole-operation deadline expired and the connection was destroyed.

Extends ​

  • TaggedErrorInstance<"HttpDeadlineExceeded", { }>

Constructors ​

Constructor ​
ts
new HttpDeadlineExceeded(args): HttpDeadlineExceeded;

Defined in: node_modules/.pnpm/unthrown@5.12.1/node_modules/unthrown/dist/index.d.mts:2386

Parameters ​
ParameterType
argsvoid
Returns ​

HttpDeadlineExceeded

Inherited from ​

TaggedError("HttpDeadlineExceeded").constructor

Properties ​

PropertyModifierTypeInherited fromDefined in
_tagreadonly"HttpDeadlineExceeded"TaggedError("HttpDeadlineExceeded")._tagnode_modules/.pnpm/unthrown@5.12.1/node_modules/unthrown/dist/index.d.mts:2363
cause?publicunknownTaggedError("HttpDeadlineExceeded").causenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2022.error.d.ts:24
messagepublicstringTaggedError("HttpDeadlineExceeded").messagenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1075
namepublicstringTaggedError("HttpDeadlineExceeded").namenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1074
stack?publicstringTaggedError("HttpDeadlineExceeded").stacknode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1076

HttpDestinationForbidden ​

Defined in: packages/http-client/src/contracts.ts:50

At least one resolved address, or a literal address, was private or reserved without approval.

Extends ​

  • TaggedErrorInstance<"HttpDestinationForbidden", { }>

Constructors ​

Constructor ​
ts
new HttpDestinationForbidden(args): HttpDestinationForbidden;

Defined in: node_modules/.pnpm/unthrown@5.12.1/node_modules/unthrown/dist/index.d.mts:2386

Parameters ​
ParameterType
argsvoid
Returns ​

HttpDestinationForbidden

Inherited from ​

TaggedError("HttpDestinationForbidden").constructor

Properties ​

PropertyModifierTypeInherited fromDefined in
_tagreadonly"HttpDestinationForbidden"TaggedError("HttpDestinationForbidden")._tagnode_modules/.pnpm/unthrown@5.12.1/node_modules/unthrown/dist/index.d.mts:2363
cause?publicunknownTaggedError("HttpDestinationForbidden").causenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2022.error.d.ts:24
messagepublicstringTaggedError("HttpDestinationForbidden").messagenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1075
namepublicstringTaggedError("HttpDestinationForbidden").namenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1074
stack?publicstringTaggedError("HttpDestinationForbidden").stacknode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1076

HttpEncodingRefused ​

Defined in: packages/http-client/src/contracts.ts:56

The remote server ignored the identity-only encoding requirement.

Extends ​

  • TaggedErrorInstance<"HttpEncodingRefused", { }>

Constructors ​

Constructor ​
ts
new HttpEncodingRefused(args): HttpEncodingRefused;

Defined in: node_modules/.pnpm/unthrown@5.12.1/node_modules/unthrown/dist/index.d.mts:2386

Parameters ​
ParameterType
argsvoid
Returns ​

HttpEncodingRefused

Inherited from ​

TaggedError("HttpEncodingRefused").constructor

Properties ​

PropertyModifierTypeInherited fromDefined in
_tagreadonly"HttpEncodingRefused"TaggedError("HttpEncodingRefused")._tagnode_modules/.pnpm/unthrown@5.12.1/node_modules/unthrown/dist/index.d.mts:2363
cause?publicunknownTaggedError("HttpEncodingRefused").causenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2022.error.d.ts:24
messagepublicstringTaggedError("HttpEncodingRefused").messagenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1075
namepublicstringTaggedError("HttpEncodingRefused").namenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1074
stack?publicstringTaggedError("HttpEncodingRefused").stacknode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1076

HttpPolicyInvalid ​

Defined in: packages/http-client/src/contracts.ts:37

Invalid application policy; contains no input URLs.

Extends ​

  • TaggedErrorInstance<"HttpPolicyInvalid", { field: | "origins" | "maxResponseBytes" | "deadlineMs" | "tlsIdentities" | "privateOrigins"; }>

Constructors ​

Constructor ​
ts
new HttpPolicyInvalid(args): HttpPolicyInvalid;

Defined in: node_modules/.pnpm/unthrown@5.12.1/node_modules/unthrown/dist/index.d.mts:2386

Parameters ​
ParameterType
argsobject & object
Returns ​

HttpPolicyInvalid

Inherited from ​

TaggedError("HttpPolicyInvalid")<{ readonly field: | "origins" | "maxResponseBytes" | "deadlineMs" | "tlsIdentities" | "privateOrigins"; }>.constructor

Properties ​

PropertyModifierTypeInherited fromDefined in
_tagreadonly"HttpPolicyInvalid"TaggedError("HttpPolicyInvalid")._tagnode_modules/.pnpm/unthrown@5.12.1/node_modules/unthrown/dist/index.d.mts:2363
cause?publicunknownTaggedError("HttpPolicyInvalid").causenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2022.error.d.ts:24
fieldreadonly| "origins" | "maxResponseBytes" | "deadlineMs" | "tlsIdentities" | "privateOrigins"TaggedError("HttpPolicyInvalid").fieldpackages/http-client/src/contracts.ts:38
messagepublicstringTaggedError("HttpPolicyInvalid").messagenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1075
namepublicstringTaggedError("HttpPolicyInvalid").namenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1074
stack?publicstringTaggedError("HttpPolicyInvalid").stacknode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1076

HttpPolicyRejected ​

Defined in: packages/http-client/src/contracts.ts:46

The request was refused before transmission.

Extends ​

  • TaggedErrorInstance<"HttpPolicyRejected", { reason: "url" | "scheme" | "credentials" | "origin" | "headers" | "request"; }>

Constructors ​

Constructor ​
ts
new HttpPolicyRejected(args): HttpPolicyRejected;

Defined in: node_modules/.pnpm/unthrown@5.12.1/node_modules/unthrown/dist/index.d.mts:2386

Parameters ​
ParameterType
argsobject & object
Returns ​

HttpPolicyRejected

Inherited from ​

TaggedError("HttpPolicyRejected")<{ readonly reason: "url" | "scheme" | "credentials" | "origin" | "headers" | "request"; }>.constructor

Properties ​

PropertyModifierTypeInherited fromDefined in
_tagreadonly"HttpPolicyRejected"TaggedError("HttpPolicyRejected")._tagnode_modules/.pnpm/unthrown@5.12.1/node_modules/unthrown/dist/index.d.mts:2363
cause?publicunknownTaggedError("HttpPolicyRejected").causenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2022.error.d.ts:24
messagepublicstringTaggedError("HttpPolicyRejected").messagenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1075
namepublicstringTaggedError("HttpPolicyRejected").namenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1074
reasonreadonly"url" | "scheme" | "credentials" | "origin" | "headers" | "request"TaggedError("HttpPolicyRejected").reasonpackages/http-client/src/contracts.ts:47
stack?publicstringTaggedError("HttpPolicyRejected").stacknode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1076

HttpRedirectRefused ​

Defined in: packages/http-client/src/contracts.ts:52

A redirect response is never followed. Location is deliberately omitted.

Extends ​

  • TaggedErrorInstance<"HttpRedirectRefused", { status: number; }>

Constructors ​

Constructor ​
ts
new HttpRedirectRefused(args): HttpRedirectRefused;

Defined in: node_modules/.pnpm/unthrown@5.12.1/node_modules/unthrown/dist/index.d.mts:2386

Parameters ​
ParameterType
argsobject & object
Returns ​

HttpRedirectRefused

Inherited from ​

TaggedError("HttpRedirectRefused")<{ readonly status: number; }>.constructor

Properties ​

PropertyModifierTypeInherited fromDefined in
_tagreadonly"HttpRedirectRefused"TaggedError("HttpRedirectRefused")._tagnode_modules/.pnpm/unthrown@5.12.1/node_modules/unthrown/dist/index.d.mts:2363
cause?publicunknownTaggedError("HttpRedirectRefused").causenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2022.error.d.ts:24
messagepublicstringTaggedError("HttpRedirectRefused").messagenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1075
namepublicstringTaggedError("HttpRedirectRefused").namenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1074
stack?publicstringTaggedError("HttpRedirectRefused").stacknode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1076
statusreadonlynumberTaggedError("HttpRedirectRefused").statuspackages/http-client/src/contracts.ts:53

HttpResponseTooLarge ​

Defined in: packages/http-client/src/contracts.ts:58

Streaming bytes exceeded the application limit.

Extends ​

  • TaggedErrorInstance<"HttpResponseTooLarge", { limit: number; }>

Constructors ​

Constructor ​
ts
new HttpResponseTooLarge(args): HttpResponseTooLarge;

Defined in: node_modules/.pnpm/unthrown@5.12.1/node_modules/unthrown/dist/index.d.mts:2386

Parameters ​
ParameterType
argsobject & object
Returns ​

HttpResponseTooLarge

Inherited from ​

TaggedError("HttpResponseTooLarge")<{ readonly limit: number; }>.constructor

Properties ​

PropertyModifierTypeInherited fromDefined in
_tagreadonly"HttpResponseTooLarge"TaggedError("HttpResponseTooLarge")._tagnode_modules/.pnpm/unthrown@5.12.1/node_modules/unthrown/dist/index.d.mts:2363
cause?publicunknownTaggedError("HttpResponseTooLarge").causenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2022.error.d.ts:24
limitreadonlynumberTaggedError("HttpResponseTooLarge").limitpackages/http-client/src/contracts.ts:59
messagepublicstringTaggedError("HttpResponseTooLarge").messagenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1075
namepublicstringTaggedError("HttpResponseTooLarge").namenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1074
stack?publicstringTaggedError("HttpResponseTooLarge").stacknode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1076

HttpUnavailable ​

Defined in: packages/http-client/src/contracts.ts:66

DNS, TLS, connection or response framing failed. No raw cause or URL is retained.

Extends ​

  • TaggedErrorInstance<"HttpUnavailable", { }>

Constructors ​

Constructor ​
ts
new HttpUnavailable(args): HttpUnavailable;

Defined in: node_modules/.pnpm/unthrown@5.12.1/node_modules/unthrown/dist/index.d.mts:2386

Parameters ​
ParameterType
argsvoid
Returns ​

HttpUnavailable

Inherited from ​

TaggedError("HttpUnavailable").constructor

Properties ​

PropertyModifierTypeInherited fromDefined in
_tagreadonly"HttpUnavailable"TaggedError("HttpUnavailable")._tagnode_modules/.pnpm/unthrown@5.12.1/node_modules/unthrown/dist/index.d.mts:2363
cause?publicunknownTaggedError("HttpUnavailable").causenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2022.error.d.ts:24
messagepublicstringTaggedError("HttpUnavailable").messagenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1075
namepublicstringTaggedError("HttpUnavailable").namenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1074
stack?publicstringTaggedError("HttpUnavailable").stacknode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1076

Type Aliases ​

HttpClientService ​

ts
type HttpClientService = object;

Defined in: packages/http-client/src/contracts.ts:96

The outbound capability an application injects.

Properties ​

PropertyModifierTypeDefined in
requestreadonly(request) => AsyncResult<HttpResponse, HttpFailure>packages/http-client/src/contracts.ts:97

HttpFailure ​

ts
type HttpFailure = 
  | HttpPolicyRejected
  | HttpDestinationForbidden
  | HttpRedirectRefused
  | HttpEncodingRefused
  | HttpResponseTooLarge
  | HttpDeadlineExceeded
  | HttpCancelled
  | HttpUnavailable;

Defined in: packages/http-client/src/contracts.ts:68

All modeled failures of an outbound request.


HttpPolicy ​

ts
type HttpPolicy = object;

Defined in: packages/http-client/src/contracts.ts:24

Application-owned approvals. Tenant configuration must never supply or extend this policy.

Properties ​

PropertyModifierTypeDescriptionDefined in
deadlineMsreadonlynumberWhole-operation budget in milliseconds, including DNS, TLS, headers and body.packages/http-client/src/contracts.ts:34
maxResponseBytesreadonlynumberMaximum complete response body bytes. Only identity encoding is supported.packages/http-client/src/contracts.ts:32
originsreadonlyreadonly string[]Exact HTTPS origins, including non-default ports. Snapshotted when the client is built.packages/http-client/src/contracts.ts:26
privateOrigins?readonlyreadonly HttpPrivateOrigin[]Deployment-owned private CIDRs per approved origin; omitted origins remain public-only.packages/http-client/src/contracts.ts:30
tlsIdentities?readonlyreadonly HttpTlsBinding[]Exact-origin client identities. Sources are captured at construction; credentials may rotate.packages/http-client/src/contracts.ts:28

HttpPrivateOrigin ​

ts
type HttpPrivateOrigin = object;

Defined in: packages/http-client/src/contracts.ts:18

Private network approval for one exact HTTPS origin. Only RFC 1918 and IPv6 unique-local CIDRs are accepted.

Properties ​

PropertyModifierTypeDefined in
cidrsreadonlyreadonly string[]packages/http-client/src/contracts.ts:20
originreadonlystringpackages/http-client/src/contracts.ts:19

HttpRequest ​

ts
type HttpRequest = object;

Defined in: packages/http-client/src/contracts.ts:78

Deliberately narrow request; no agent, proxy, resolver, TLS or redirect overrides.

Properties ​

PropertyModifierTypeDefined in
body?readonlystring | Uint8Arraypackages/http-client/src/contracts.ts:82
headers?readonlyReadonly<Record<string, string>>packages/http-client/src/contracts.ts:81
method?readonly"GET" | "HEAD" | "POST" | "PUT" | "PATCH" | "DELETE" | "OPTIONS"packages/http-client/src/contracts.ts:80
signal?readonlyAbortSignalpackages/http-client/src/contracts.ts:83
urlreadonlystring | URLpackages/http-client/src/contracts.ts:79

HttpResponse ​

ts
type HttpResponse = object;

Defined in: packages/http-client/src/contracts.ts:90

A complete body within the policy limit; HTTP error statuses remain ordinary responses.

Properties ​

PropertyModifierTypeDefined in
bodyreadonlyUint8Arraypackages/http-client/src/contracts.ts:93
headersreadonlyReadonly<Record<string, string>>packages/http-client/src/contracts.ts:92
statusreadonlynumberpackages/http-client/src/contracts.ts:91

HttpTlsBinding ​

ts
type HttpTlsBinding = object;

Defined in: packages/http-client/src/contracts.ts:11

An identity bound to one approved origin. The trusted source is read for every connection.

Properties ​

PropertyModifierTypeDescriptionDefined in
credentialsreadonly() => HttpTlsIdentityRead an atomic credential snapshot from an application-owned secret cache; may throw on failure.packages/http-client/src/contracts.ts:14
originreadonlystring-packages/http-client/src/contracts.ts:12

HttpTlsIdentity ​

ts
type HttpTlsIdentity = object;

Defined in: packages/http-client/src/contracts.ts:5

PEM client identity supplied by the application's secret store.

Properties ​

PropertyModifierTypeDefined in
certreadonlystringpackages/http-client/src/contracts.ts:6
keyreadonlystringpackages/http-client/src/contracts.ts:7
passphrase?readonlystringpackages/http-client/src/contracts.ts:8

Functions ​

createHttpClient() ​

ts
function createHttpClient(input): Result<HttpClientService, HttpPolicyInvalid>;

Defined in: packages/http-client/src/client.ts:200

Build once at the application boundary. Origins and limits are copied, never read from the caller again.

Parameters ​

ParameterType
inputHttpPolicy

Returns ​

Result<HttpClientService, HttpPolicyInvalid>


httpClient() ​

ts
function httpClient<Id>(policy): Module<HttpClient, HttpPolicyInvalid, PortInstance<Id, HttpPolicy>>;

Defined in: packages/http-client/src/provider.ts:8

Provide an observed outbound capability from an application-owned policy port.

Type Parameters ​

Type Parameter
Id extends string

Parameters ​

ParameterType
policyPortClassOf<Id, HttpPolicy>

Returns ​

Module<HttpClient, HttpPolicyInvalid, PortInstance<Id, HttpPolicy>>


httpClientFetch() ​

ts
function httpClientFetch(client): (input, init?) => Promise<Response>;

Defined in: packages/http-client/src/fetch.ts:9

Adapt this boundary to the platform fetch protocol (including openid-client's customFetch). Unsupported Request objects, streaming bodies and fetch transport overrides are refused. This is the edge where Result failures reject for the upstream fetch consumer.

Parameters ​

ParameterType
clientHttpClientService

Returns ​

(input, init?) => Promise<Response>

Released under the MIT License.