/** * @file Anonymous bearer-token acquisition for an OCI distribution-spec pull. * Two paths, unified behind `getRegistryToken`: probe `GET /v2/` for a * `WWW-Authenticate` 401 challenge and honor its realm/service/scope (works * for any spec-compliant registry, ghcr.io included), and fall back to the * conventional `GET https:///token?service=&scope= * repository::pull` form when a registry answers the probe with * a 200 advertising no challenge. A registry that needs no auth at all yields * an empty token, which the manifest/blob callers send as no `Authorization`. */ import type { AuthChallenge, OciHttpOptions } from './types.js'; /** * Build the conventional anonymous pull-token URL for a registry that follows * the `service=` convention (ghcr.io, Docker Hub-style hosts). */ export declare function buildAnonymousTokenUrl(registry: string, repository: string): string; /** * Build the token URL from a parsed challenge, forcing a pull scope for * `repository`. A challenge that already advertised a scope is overridden with * `repository::pull` so the token is minted for the intended repo. */ export declare function buildChallengeTokenUrl(challenge: AuthChallenge, repository: string): string; /** * Read the first value of a possibly-array HTTP header. */ export declare function firstHeaderValue(value: string | string[] | undefined): string | undefined; /** * Obtain an anonymous pull token for `repository` on `registry`. Probes * `GET /v2/`: a 401 with a parseable Bearer challenge drives the realm-based * token request; a 200 with no challenge means the registry serves anonymous * pulls directly, so the conventional `/token` endpoint is tried and an empty * token is returned when it declines. Fails loud when a registry demands auth * but advertises no usable challenge. */ export declare function getRegistryToken(registry: string, repository: string, options: OciHttpOptions): Promise; /** * Parse a `WWW-Authenticate: Bearer realm="...",service="...",scope="..."` * challenge into its realm/service/scope. Returns `undefined` for a non-Bearer * or realm-less header. */ export declare function parseWwwAuthenticate(header: string): AuthChallenge | undefined;