Add map import and export with durable refresh progress

This commit is contained in:
2026-10-07 19:44:49 +05:00
parent dac8650ac1
commit 1307436e65
37 changed files with 2207 additions and 85 deletions

View File

@@ -0,0 +1,23 @@
import { createHmac, timingSafeEqual } from "node:crypto";
import {
archiveMetadataSchema,
type ArchiveMetadata,
} from "../shared/map-archive";
export function archiveSignature(value: ArchiveMetadata, key: string) {
const { signature: _signature, ...metadata } =
archiveMetadataSchema.strip().parse(value);
return createHmac("sha256", key)
.update("minegeo-map-share/v1\n")
.update(JSON.stringify(metadata))
.digest("hex");
}
export function verifyArchiveSignature(value: ArchiveMetadata, key: string) {
const expected = Buffer.from(archiveSignature(value, key), "hex");
const supplied = Buffer.from(value.signature, "hex");
if (
expected.length !== supplied.length ||
!timingSafeEqual(expected, supplied)
)
throw new Error("Map ZIP ownership verification failed");
}