UNPKG

@lodestar/api

Version:

A Typescript REST client for the Ethereum Consensus API

43 lines 1.92 kB
export declare enum HttpHeader { ContentType = "content-type", Accept = "accept", Authorization = "authorization", /** * Used to indicate which response headers should be made available to * scripts running in the browser, in response to a cross-origin request. * https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Expose-Headers */ ExposeHeaders = "access-control-expose-headers" } export declare enum MediaType { json = "application/json", ssz = "application/octet-stream" } export declare const SUPPORTED_MEDIA_TYPES: MediaType[]; export declare function parseContentTypeHeader(contentType?: string): MediaType | null; export declare function parseAcceptHeader(accept?: string, supported?: MediaType[]): MediaType | null; export declare function setAuthorizationHeader(url: URL, headers: Headers, { bearerToken }: { bearerToken?: string; }): void; export declare function mergeHeaders(...headersList: (HeadersInit | undefined)[]): Headers; /** * Get header from request headers, by default an error will be thrown if the header * is not present. The header can be marked as optional in which case the return value * might be `undefined` but no error will be thrown if header is missing. */ export declare function fromHeaders<T extends Record<string, string | undefined>, R extends boolean = true>(headers: T, name: Extract<keyof T, string>, required?: R): R extends true ? string : string | undefined; /** * Extension of Headers object returned by Fetch API */ export declare class HeadersExtra extends Headers { /** * Get required header from response headers */ getRequired(name: string): string; /** * Get optional header from response headers. * Return default value if it does not exist */ getOrDefault(name: string, defaultValue: string): string; } //# sourceMappingURL=headers.d.ts.map