/** * @file Checksum file fetching + parsing for download verification. * `parseChecksumFile` understands the three common text-file shapes: * * - BSD style: `SHA256 (filename) = hash` * - GNU style: `hash filename` with two spaces between them * - Simple: `hash filename` with a single space between them Comment lines * (`#…`) and blank lines are skipped. Each hex digest is converted to an * SRI integrity string (`sha256-=`) so callers always work in the * same format as `external-tools.json` and other integrity-string * consumers. `fetchChecksumFile` is the URL helper — fetches via * `httpRequest` and runs the body through `parseChecksumFile`. */ import type { ChecksumFile, FetchChecksumFileOptions } from './download-types.js'; /** * Fetch and parse a checksums file from a URL. * * Returns a map of filenames to SRI integrity strings (`sha256-=`). * Feed `httpDownload({ sha256 })` by converting back to hex via * `parseHash(x).hex`; pass the SRI string through verbatim to consumers * that accept SRI directly. * * @example * ;```ts * import { parseHash } from '@socketsecurity/lib/crypto/integrity' * * const sums = await fetchChecksumFile( * 'https://github.com/org/repo/releases/download/v1.0.0/checksums.txt', * ) * await httpDownload(url, '/tmp/tool.tar.gz', { * sha256: parseHash(sums['tool_linux.tar.gz']!).hex, * }) * ``` */ export declare function fetchChecksumFile(url: string, options?: FetchChecksumFileOptions | undefined): Promise; /** * Parse a checksums file text into a filename-to-integrity map. * * Supports standard checksums file formats: - BSD style: `SHA256 (filename) = * hash` - GNU style: `hash filename` with two spaces - Simple style: `hash * filename` with a single space. * * Lines starting with `#` are treated as comments and ignored. Empty lines are * ignored. Each 64-char hex digest is converted to an SRI integrity string so * the result is uniform regardless of source format. * * @example * ;```ts * const sums = parseChecksumFile( * 'e3b0c44... file.zip\nSHA256 (other.tar.gz) = abc123...\n', * ) * // sums['file.zip'] === 'sha256-47DEQpj8HBSa+/...' * ``` */ export declare function parseChecksumFile(text: string): ChecksumFile;