Back to Atlas map viewer
SOURCE / PINNED RELEASE

Made of little things.

Atlas map viewer

Release
1d2807e80b44…
Author-recorded commit
43810ed2b368…
License
LICENSE
Author’s source reference
nostr://npub182jczunncwe0jn6frpqwq3e0qjws7yqqnc3auccqv9nte2dnd63scjm4rf/wss%3A%2F%2Fgit.napplet.soy%2F/n-4757dbabc86

Archive hash verified: 8db6876d96c460ac…. The source-to-build association is the author’s claim; it has not been independently rebuilt.

packages/hashtree/src/published-map.ts
import type { MapOffer } from "../../format/src/catalog";
import type { AtlasReader } from "../../format/src/reader";

function canonical(value: unknown): string {
  if (value === undefined) return "null";
  if (Array.isArray(value)) return `[${value.map(canonical).join(",")}]`;
  if (value && typeof value === "object")
    return `{${Object.entries(value)
      .filter(([, v]) => v !== undefined)
      .sort(([a], [b]) => a.localeCompare(b))
      .map(([k, v]) => `${JSON.stringify(k)}:${canonical(v)}`)
      .join(",")}}`;
  return JSON.stringify(value);
}
/** Signed offers are hints until verified against the root-pinned archive.
 * Return its actual metadata; publishers cannot override routing or coverage. */
export function verifyPublishedMap(offer: MapOffer, reader: AtlasReader) {
  const actual = reader.index.manifest;
  if (
    actual.snapshot !== offer.manifest.snapshot ||
    reader.index.header.fileLength !== offer.bytes
  )
    throw new Error(
      "Published snapshot or file size differs from the pinned archive. Reopen discovery.",
    );
  for (const key of [
    "transport",
    "bounds",
    "selection",
    "capabilities",
    "composition",
  ] as const)
    if (canonical(actual[key]) !== canonical(offer.manifest[key]))
      throw new Error(`Published ${key} differs from the pinned archive.`);
  return actual;
}