@helia/verified-fetch
Version:
A fetch-like API for obtaining verified & trustless IPFS content on the web
48 lines • 2.82 kB
TypeScript
import type { SupportedBodyTypes, ContentType } from '../index.js';
import type { RangeHeader } from './get-range-header.ts';
export interface ResponseOptions extends ResponseInit {
redirected?: boolean;
}
export declare function okResponse(url: string, body?: SupportedBodyTypes, init?: ResponseOptions): Response;
export declare function internalServerErrorResponse(url: string, body?: SupportedBodyTypes, init?: ResponseInit): Response;
/**
* A 504 Gateway Timeout for when a request made to an upstream server timed out
*/
export declare function gatewayTimeoutResponse(url: string, body?: SupportedBodyTypes, init?: ResponseInit): Response;
/**
* A 502 Bad Gateway is for when an invalid response was received from an
* upstream server.
*/
export declare function badGatewayResponse(url: string, body?: SupportedBodyTypes, init?: ResponseInit): Response;
export declare function notImplementedResponse(url: string, body?: SupportedBodyTypes, init?: ResponseInit): Response;
export declare function notAcceptableResponse(url: string | URL, requested: Array<Pick<ContentType, 'mediaType'>>, acceptable: Array<Pick<ContentType, 'mediaType'>>, init?: ResponseInit): Response;
export declare function notFoundResponse(url: string, body?: SupportedBodyTypes, init?: ResponseInit): Response;
export declare function badRequestResponse(url: string, errors: Error | Error[], init?: ResponseInit): Response;
export declare function movedPermanentlyResponse(url: string, location: string, init?: ResponseInit): Response;
export declare function notModifiedResponse(url: string, headers: Headers, init?: ResponseInit): Response;
export interface PartialContent {
/**
* Yield data from the content starting at `start` (or 0) inclusive and ending
* at `end` exclusive
*/
(offset: number, length: number): AsyncGenerator<Uint8Array>;
}
export declare function partialContentResponse(url: string, getSlice: PartialContent, range: RangeHeader, documentSize: number | bigint, init?: ResponseOptions): Response;
/**
* We likely need to catch errors handled by upstream helia libraries if
* range-request throws an error. Some examples:
*
* - The range is out of bounds
* - The range is invalid
* - The range is not supported for the given type
*/
export declare function notSatisfiableResponse(url: string, documentSize?: number | bigint | string, init?: ResponseInit): Response;
/**
* Error to indicate that request was formally correct, but Gateway is unable to
* return requested data under the additional (usually cache-related) conditions
* sent by the client.
*
* @see https://specs.ipfs.tech/http-gateways/path-gateway/#412-precondition-failed
*/
export declare function preconditionFailedResponse(url: string, init?: ResponseInit): Response;
//# sourceMappingURL=responses.d.ts.map