export declare const DEFAULT_NPM_REGISTRY = "https://registry.npmjs.org"; export type NpmConfigOrigin = "env" | "user" | "global"; /** Which package manager will run the install this check is gating. */ export type Installer = "bun" | "npm"; /** Injection points so tests never read the real environment. */ export interface NpmRegistryEnvironment { /** Manager that will perform the install; decides Bun-vs-npm config priority. */ installer?: Installer; /** Resolves an executable on PATH; used to locate npm's effective prefix. */ whichExecutable?: (name: string) => string | undefined; /** Defaults to `$credentialEnv`, which excludes the caller's `cwd/.env`. */ lookupEnv?: (name: string) => string | undefined; homeDir?: string; platform?: NodeJS.Platform; readFile?: (filePath: string) => Promise; } export interface ResolvedNpmRegistry { registry: string; headers: Record; origin: NpmConfigOrigin | "default"; /** Where the value came from, e.g. `$npm_config_registry` or `~/.npmrc`. */ source: string; /** Config files that exist but could not be read. */ warnings: string[]; } export interface LatestPackageVersion { version: string; registry: string; /** Config problems that did not stop the lookup but changed its outcome. */ warnings: string[]; } export interface FetchResponseLike { ok: boolean; status: number; statusText: string; json: () => Promise; } export type FetchLike = (input: string, init?: { headers?: Record; signal?: AbortSignal; }) => Promise; export interface NpmRegistryLookupOptions extends NpmRegistryEnvironment { fetchImpl?: FetchLike; timeoutMs?: number; /** npm dist-tag to resolve; defaults to `latest`. Nightly channel lookups pass `nightly`. */ distTag?: string; } /** Thrown when a registry is configured but unusable, so it is never silently ignored. */ export declare class NpmRegistryConfigError extends Error { } /** * Parse an `.npmrc` into raw key/value pairs. Later duplicates win, as in npm. * * @internal Exported for tests; production code goes through `resolveNpmRegistry`. */ export declare function parseNpmrc(contents: string, lookupEnv?: (name: string) => string | undefined): Map; /** * Build the credential lookup keys npm calls "nerf darts": `//host/path/`, * walking up one path segment at a time until the bare host. * * @internal Exported for tests; production code goes through `resolveNpmRegistry`. */ export declare function credentialPrefixes(registry: string): string[]; /** Resolve the registry npm/bun would use for `packageName`, with credentials attached. */ export declare function resolveNpmRegistry(packageName: string, environment?: NpmRegistryEnvironment): Promise; /** * Registries can live under a path prefix, so join by string rather than `new URL`. * * @internal Exported for tests; production code goes through `fetchLatestPackageVersion`. */ export declare function buildRegistryPackageUrl(registry: string, packageName: string, spec?: string): string; /** Fetch the published version of `packageName` at `options.distTag` (default `latest`) from the configured registry. */ export declare function fetchLatestPackageVersion(packageName: string, options?: NpmRegistryLookupOptions): Promise;