summaryrefslogtreecommitdiff
path: root/cli/tsc/dts/lib.deno.ns.d.ts
diff options
context:
space:
mode:
authorAsher Gomez <ashersaupingomez@gmail.com>2024-09-12 10:46:48 +1000
committerGitHub <noreply@github.com>2024-09-12 10:46:48 +1000
commit8476bbff9af28408bc6a9b0a7b2303cb3803422e (patch)
tree7d06c3fb248c39b5924686213275b57df8d01fc7 /cli/tsc/dts/lib.deno.ns.d.ts
parent3a3837545ce6f585f718069cc05d96f765a05d3f (diff)
feat: stabilize `Deno.createHttpClient()` (#25569)
Closes #25518
Diffstat (limited to 'cli/tsc/dts/lib.deno.ns.d.ts')
-rw-r--r--cli/tsc/dts/lib.deno.ns.d.ts122
1 files changed, 122 insertions, 0 deletions
diff --git a/cli/tsc/dts/lib.deno.ns.d.ts b/cli/tsc/dts/lib.deno.ns.d.ts
index 2bc3b36a3..0d5e3eaa1 100644
--- a/cli/tsc/dts/lib.deno.ns.d.ts
+++ b/cli/tsc/dts/lib.deno.ns.d.ts
@@ -6087,4 +6087,126 @@ declare namespace Deno {
filename: string | URL,
symbols: S,
): DynamicLibrary<S>;
+
+ /**
+ * A custom `HttpClient` for use with {@linkcode fetch} function. This is
+ * designed to allow custom certificates or proxies to be used with `fetch()`.
+ *
+ * @example ```ts
+ * const caCert = await Deno.readTextFile("./ca.pem");
+ * const client = Deno.createHttpClient({ caCerts: [ caCert ] });
+ * const req = await fetch("https://myserver.com", { client });
+ * ```
+ *
+ * @category Fetch
+ */
+ export interface HttpClient extends Disposable {
+ /** Close the HTTP client. */
+ close(): void;
+ }
+
+ /**
+ * The options used when creating a {@linkcode Deno.HttpClient}.
+ *
+ * @category Fetch
+ */
+ export interface CreateHttpClientOptions {
+ /** A list of root certificates that will be used in addition to the
+ * default root certificates to verify the peer's certificate.
+ *
+ * Must be in PEM format. */
+ caCerts?: string[];
+ /** A HTTP proxy to use for new connections. */
+ proxy?: Proxy;
+ /** Sets the maximum number of idle connections per host allowed in the pool. */
+ poolMaxIdlePerHost?: number;
+ /** Set an optional timeout for idle sockets being kept-alive.
+ * Set to false to disable the timeout. */
+ poolIdleTimeout?: number | false;
+ /**
+ * Whether HTTP/1.1 is allowed or not.
+ *
+ * @default {true}
+ */
+ http1?: boolean;
+ /** Whether HTTP/2 is allowed or not.
+ *
+ * @default {true}
+ */
+ http2?: boolean;
+ /** Whether setting the host header is allowed or not.
+ *
+ * @default {false}
+ */
+ allowHost?: boolean;
+ }
+
+ /**
+ * The definition of a proxy when specifying
+ * {@linkcode Deno.CreateHttpClientOptions}.
+ *
+ * @category Fetch
+ */
+ export interface Proxy {
+ /** The string URL of the proxy server to use. */
+ url: string;
+ /** The basic auth credentials to be used against the proxy server. */
+ basicAuth?: BasicAuth;
+ }
+
+ /**
+ * Basic authentication credentials to be used with a {@linkcode Deno.Proxy}
+ * server when specifying {@linkcode Deno.CreateHttpClientOptions}.
+ *
+ * @category Fetch
+ */
+ export interface BasicAuth {
+ /** The username to be used against the proxy server. */
+ username: string;
+ /** The password to be used against the proxy server. */
+ password: string;
+ }
+
+ /** Create a custom HttpClient to use with {@linkcode fetch}. This is an
+ * extension of the web platform Fetch API which allows Deno to use custom
+ * TLS certificates and connect via a proxy while using `fetch()`.
+ *
+ * @example ```ts
+ * const caCert = await Deno.readTextFile("./ca.pem");
+ * const client = Deno.createHttpClient({ caCerts: [ caCert ] });
+ * const response = await fetch("https://myserver.com", { client });
+ * ```
+ *
+ * @example ```ts
+ * const client = Deno.createHttpClient({
+ * proxy: { url: "http://myproxy.com:8080" }
+ * });
+ * const response = await fetch("https://myserver.com", { client });
+ * ```
+ *
+ * @category Fetch
+ */
+ export function createHttpClient(
+ options: CreateHttpClientOptions,
+ ): HttpClient;
+
+ /**
+ * Create a custom HttpClient to use with {@linkcode fetch}. This is an
+ * extension of the web platform Fetch API which allows Deno to use custom
+ * TLS certificates and connect via a proxy while using `fetch()`.
+ *
+ * @example ```ts
+ * const caCert = await Deno.readTextFile("./ca.pem");
+ * // Load a client key and certificate that we'll use to connect
+ * const key = await Deno.readTextFile("./key.key");
+ * const cert = await Deno.readTextFile("./cert.crt");
+ * const client = Deno.createHttpClient({ caCerts: [ caCert ], key, cert });
+ * const response = await fetch("https://myserver.com", { client });
+ * ```
+ *
+ * @category Fetch
+ */
+ export function createHttpClient(
+ options: CreateHttpClientOptions & TlsCertifiedKeyPem,
+ ): HttpClient;
}