/** * Expected response body formats. * * @enum {number} */ declare const enum ResponseType { BYTE = 0, VIEW = 1, TEXT = 2, JSON = 3 } /** * A context describing an outgoing HTTP request. * * @template T The platform-specific request options type (`RequestInit` in browsers, `https.RequestOptions` otherwise). */ interface RequestContext { /** * The target hostname. * * @type {string} */ host: string; /** * The target path. * * @type {string} */ path: string; /** * The expected response type. * * @type {ResponseType} * @readonly */ readonly type: ResponseType; /** * Platform-specific request options. * * @type {T} * @readonly */ readonly options: T; } /** * A custom transport function for making HTTPS requests. * * The response body must be decompressed before returning if the server sends a compressed response. * * @template T The platform-specific request options type. * @param {RequestContext} context The final request context after `onRequest` is invoked. * @returns {Uint8Array | Promise} The response body as a `Uint8Array`, or a `Promise` that resolves to one. * @see {@link RequestContext} */ type TransportFunction = (context: RequestContext) => Uint8Array | Promise; /** * A custom function for computing a SHA-256 hash. * * @param {string} text The input string to hash. * @returns {Uint8Array | Promise} The hash digest as a `Uint8Array`, or a `Promise` that resolves to one. */ type ComputeHashFunction = (text: string) => Uint8Array | Promise; /** * A hook function invoked before each HTTP request. * * @template T The platform-specific request options type. * @param {RequestContext} context The request context to inspect or modify. * @returns {RequestContext | void | Promise | void>} A modified context to use for the request, or `void` to use the original. * @see {@link RequestContext} */ type OnRequestFunction = (context: RequestContext) => RequestContext | void | Promise | void>; export { ResponseType }; export type { ComputeHashFunction, OnRequestFunction, RequestContext, TransportFunction };