physical.sha256Filefunctionno test imports itfunction sha256File(file: string): Promise<string>A file's SHA-256 in hexadecimal, read in chunks.
The boot files and the installer image on the boot machine: each is fetched once, checked against its pinned SHA-256 and kept; a file that does not match is removed and nothing is served from it. The fetch is a function that is given, so that a test serves made-up files; the check is of the bytes, read in chunks (an installer image is several GB).
import { sha256File } from "./assets.ts";
// await sha256File("/var/lib/netboot/linux")physical.sha256Filefunctionno test imports itfunction sha256File(file: string): Promise<string>A file's SHA-256 in hexadecimal, read in chunks.
physical.Assetstypeno test imports ittype Assets = { readonly files: Readonly<Record<string, string>>; readonly iso?: string };The files the server holds: the boot files by name, and the installer image.
physical.Fetchtypeno test imports ittype Fetch = (url: string) => Promise<Response>;Gets the bytes at an address.
physical.ensureAssetsfunctionno test imports itfunction ensureAssets(dir: string, pins: BootPins, fetcher?: Fetch, say?: (m: string) => void): Promise<Result<Assets, string>>Every boot file and the installer image, fetched where they are not held and checked against their pins.
physical.assetStatusfunctionno test imports itfunction assetStatus(dir: string, pins: BootPins): Promise<{ readonly ready: readonly string[]; readonly missing: readonly string[]; }>What of the assets is held and matches its pin, without fetching: the names that are ready and the ones that are not.
sha256Filefunctionfunction sha256File(file: string): Promise<string>A file's SHA-256 in hexadecimal, read in chunks.
Assetstypeno test imports ittype Assets = { readonly files: Readonly<Record<string, string>>; readonly iso?: string };The files the server holds: the boot files by name, and the installer image.
Fetchtypeno test imports ittype Fetch = (url: string) => Promise<Response>;Gets the bytes at an address.
ensureAssetsfunctionfunction ensureAssets(dir: string, pins: BootPins, fetcher?: Fetch, say?: (m: string) => void): Promise<Result<Assets, string>>Every boot file and the installer image, fetched where they are not held and checked against their pins.
assetStatusfunctionfunction assetStatus(dir: string, pins: BootPins): Promise<{ readonly ready: readonly string[]; readonly missing: readonly string[]; }>What of the assets is held and matches its pin, without fetching: the names that are ready and the ones that are not.