import type { Nuri } from "./port"; import { isNuri } from "./nuri"; /** * What a depositor puts in an index document's inbox: **a bare reference, and * nothing else**. * * Not an instruction — not "add this row", not even "I published this". The * curator resolves the reference and looks; what it finds is what decides. This * is the shape NextGraph already uses upstream: a `SocialQueryRequest` carries * `definition_commit_body_ref` — a REFERENCE — and the recipient's * `inbox_processor` composes its own SPARQL. Since anyone may deposit into any * index, a payload that carried an operation would be a licence to rewrite * someone else's document. * * It carries no index reference either. The deposit is addressed to the index * document's inbox, and upstream an inbox belongs to exactly one repo — the * address IS the identification. The polyfill says the same of its own inbox: * "Tagging deposits with their document would be an invention consumers would * have to unlearn at migration." * * And it carries no indexed data. Indexing is limited to PUBLIC objects * precisely so that the curator can open the object itself; a value copied into * the deposit would let a depositor put something in the index that the object * does not say. * * What is left is the NURI. That is the whole payload. */ export type IndexDeposit = Nuri; /** * Anyone may deposit anything into an index's inbox, so every payload is * untrusted input. Returns `null` for everything that is not a reference. */ export function decodeReference(payload: unknown): Nuri | null { return isNuri(payload) ? payload : null; }