@pnpm/tarball-fetcher
Version:
Fetcher for packages hosted as tarballs
34 lines (33 loc) • 1.26 kB
TypeScript
import { type IncomingMessage } from 'http';
import { type FetchResult, type FetchOptions } from '@pnpm/fetcher-base';
import { type Cafs } from '@pnpm/cafs-types';
import { type FetchFromRegistry } from '@pnpm/fetching-types';
export interface HttpResponse {
body: string;
}
export type DownloadFunction = (url: string, opts: {
getAuthHeaderByURI: (registry: string) => string | undefined;
cafs: Cafs;
readManifest?: boolean;
registry?: string;
onStart?: (totalSize: number | null, attempt: number) => void;
onProgress?: (downloaded: number) => void;
integrity?: string;
filesIndexFile: string;
} & Pick<FetchOptions, 'pkg'>) => Promise<FetchResult>;
export interface NpmRegistryClient {
get: (url: string, getOpts: object, cb: (err: Error, data: object, raw: object, res: HttpResponse) => void) => void;
fetch: (url: string, opts: {
auth?: object;
}, cb: (err: Error, res: IncomingMessage) => void) => void;
}
export declare function createDownloader(fetchFromRegistry: FetchFromRegistry, gotOpts: {
retry?: {
retries?: number;
factor?: number;
minTimeout?: number;
maxTimeout?: number;
randomize?: boolean;
};
timeout?: number;
}): DownloadFunction;