testAnnouncementsAreCheckedBySignature
What a PDS lists isn't taken on its word: an announcement, or a review, whose record doesn't check against its
writer's signed repository (getRecord's proof signed by another key) isn't added, nor shown.
import { startFakeAtproto } from "#codebase/tcmts/cli/test/e2e/examples"; import { withChildren } from "#codebase/tcmts/cli/test/e2e/harness"; import { codebase, onFakeNetwork } from "#codebase/tcmts/cli/test/e2e/releases"; import { startServerInfo } from "#codebase/tcmts/cli/test/e2e/sync"; import assert from "node:assert/strict"; export const testAnnouncementsAreCheckedBySignature = () => withChildren(async (keep) => { const alice = { did: "did:plc:alice000000000000000000", handle: "alice.test", password: "a-pass", }; const maya = { did: "did:plc:maya0000000000000000000", handle: "maya.test", password: "m-pass", }; const net = await startFakeAtproto(keep, [alice, maya]); const { run, ok } = onFakeNetwork(keep, net); const geo = codebase("signed geo"); geo.save( `// tcm: namespace geo\nexport const manifest = { name: "geo" };\nexport const area = (side: number) => side * side;\n`, "add", ); const server = (await startServerInfo(keep, geo.dir, "tok", "--public")).url; await ok( geo.dir, "release", "geo@1.0.0", "--announce", "--as", "alice.test", "--source", server, ); const me = codebase("signed me"); me.save(`// tcm: namespace app\nexport const total = () => 1;\n`, "add"); await ok(me.dir, "lib", "add", "@alice.test/geo@1.0.0"); await ok( me.dir, "lib", "attest", "@alice.test/geo@1.0.0", "review", "-m", "Read it all.", "--as", "maya.test", ); await ok(me.dir, "lib", "trust", "--add", "@maya.test"); assert.match(await ok(me.dir, "lib"), /reviewed by @maya\.test: Read it all\./); // the PDS lists them as they were, but their proofs are signed by someone else's key const review = [...net.records.keys()].find((u) => u.startsWith(`at://${maya.did}/codes.tcm.review/`), )!; net.forge(review); net.forge(`at://${alice.did}/codes.tcm.release/geo:1.0.0`); assert.doesNotMatch(await ok(me.dir, "lib"), /reviewed by @maya\.test/); const refused = await run( me.dir, "lib", "add", "@alice.test/geo@1.0.0", "--at", "app.lib.geo2", ); assert.notEqual(refused.status, 0); assert.match( refused.out, /@alice\.test's announcement of geo@1\.0\.0 doesn't check against their signed repository/, ); })