// A fake archive.today on loopback (release 37 lane F): timemaps, copies // wrapped the way archive.today serves them, its redirects, a check page and // "too many requests". No test reaches the real archive.today. // // const at = await startFakeArchiveToday(); // at.fetch a fetch that sends https://archive.ph/… (any of its names) here // at.base the loopback origin // at.requests every request path, in order, with its time (`at`) // await at.close() // // Routes (every name — archive.ph, archive.today, archive.is, … — is one): // GET /timemap/ link format: rel="original", then one rel="memento" // (first/last marked) per copy of , oldest // first; 404 when it holds none // GET / the copy, wrapped (wrapLikeArchiveToday), with // Memento-Datetime and Link (rel="original", // rel="memento") headers; 404 for an unknown id // GET // 302 to the copy of nearest // GET /newest/ 302 to its newest copy; /oldest/ to its oldest // opts.challenge: ids (or "all") answered with a CAPTCHA page instead of the // copy (opts.challengeStatus, default 200 — archive.today also uses 429/503) // opts.busyTimes: the first N requests answer a plain 429 (Retry-After: 2) // opts.copies: the copies held (default COPIES) import http from "node:http"; import { readFileSync } from "node:fs"; // ─── Wrapping a page the way archive.today serves its copy ─── // // archive.today's snapshot (as known 2026-10-20; synthetic): its own header // bar (`#HEADER`: the "saved from" URL box, the capture's