signaltrail / tree / src/worker.js ยท raw (this view has old GitHub links rewritten for the mirror; raw is byte-exact)
// Cloudflare Worker entry. Secret: SIGNALTRAIL_SIGNING_JWK.
import { handle } from './app.js';
import { importSigner } from './receipt.js';
import { MemoryStore } from './store.js';
import dataset from '../data/demo-posts.json';
import config from '../data/config.default.json';
import registry from '../data/registry.json';
export { ReceiptLedger } from './ledger-do.js';
class DOStore {
  constructor(ns) { this.stub = ns.get(ns.idFromName('main')); }
  head() { return this.stub.head(); }
  append(r) { return this.stub.append(JSON.stringify(r)); }
  list() { return this.stub.list(); }
  claimRun(ms) { return this.stub.claimRun(ms); }
  cacheGet(k) { return this.stub.cacheGet(k); }
  cachePut(k, v) { return this.stub.cachePut(k, v); }
}
let signerP; const mem = new MemoryStore();
export default {
  async fetch(request, env) {
    if (!env.SIGNALTRAIL_SIGNING_JWK) return new Response(JSON.stringify({ error: 'not_configured' }), { status: 503, headers: { 'content-type': 'application/json' } });
    signerP ||= importSigner(JSON.parse(env.SIGNALTRAIL_SIGNING_JWK));
    return handle(request, { fetch: (u, i) => fetch(u, i), signer: await signerP, store: env.LEDGER ? new DOStore(env.LEDGER) : mem, base: env.TOOLS_BASE, now: () => new Date(), issuer: { url: env.PUBLIC_URL }, dataset, config, registry, runThrottleMs: 30000 });
  },
};

agentgate-source: code mirror on Cloudflare Pages. All repos