import { createHash } from 'node:crypto' export default { async fetch(request) { const path = new URL(request.url).pathname if (request.method === 'GET' && path === '/manifest') { return Response.json({ title:'Dataset fingerprint', parents: ['milestones'], rule: 'Record a content fingerprint for milestones that mention a public dataset.' }) } if (request.method !== 'POST' || path !== '/deliver') return new Response(null, { status: 404 }) const { block } = await request.json() const content = typeof block.content === 'string' ? block.content : JSON.stringify(block.content) if (!/\bpublic dataset\b/i.test(content)) { return Response.json({ decision: 'stop', detail: 'No public dataset mentioned.' }) } const digest = createHash('sha256').update(content).digest('hex') return Response.json({ decision: 'record', detail: 'Content SHA-256 ' + digest }) } }