replicator.ts

2.7 KB · TypeScript · Updated May 19, 2026

View folder
  1. 1import { verifyManifestSignature } from "./attestations";
  2. 2
  3. 3export interface ReplicaTarget {
  4. 4 peerId: string;
  5. 5 region: string;
  6. 6 contentId: string;
  7. 7}
  8. 8
  9. 9export async function publishReplica(target: ReplicaTarget) {
  10. 10 const verified = await verifyManifestSignature(target.contentId);
  11. 11
  12. 12 if (!verified) {
  13. 13 throw new Error("Replica manifest signature could not be verified");
  14. 14 }
  15. 15
  16. 16 return {
  17. 17 peerId: target.peerId,
  18. 18 region: target.region,
  19. 19 status: "queued",
  20. 20 receipt: `replica:${target.peerId}:${Date.now()}`,
  21. 21 };
  22. 22}