occ-cloudflare
v0.2.0
Published
OCC cryptographic proof signing for Cloudflare Workers tool calls
Readme
occ-cloudflare
Cryptographic proof signing for Cloudflare Workers. Every tool/binding call gets an Ed25519-signed proof pair returned alongside the result.
Unlike other OCC integrations, proofs are returned (not written to disk) since Cloudflare Workers have no filesystem. Store them wherever you like (KV, D1, R2, Durable Objects).
Install
npm install occ-cloudflareUsage
Wrap a tool
import { occWrapTool } from "occ-cloudflare";
const searchTool = {
execute: async (args: { query: string }) => {
return await doSearch(args.query);
},
};
const wrapped = occWrapTool(searchTool, "search");
const { result, proofs } = await wrapped.execute({ query: "OCC" });
// Store proofs in KV, D1, R2, etc.
await env.PROOF_LOG.put(`proof-${Date.now()}`, JSON.stringify(proofs));Wrap a binding
import { occWrapBinding } from "occ-cloudflare";
export default {
async fetch(request: Request, env: Env) {
const kv = occWrapBinding(env.MY_KV, "my-kv");
const { result, proofs } = await kv.get("some-key");
// result = the KV value
// proofs = pre/post Ed25519-signed proof entries
},
};Configuration
interface OCCCloudflareOptions {
measurement?: string; // Default: "occ-cloudflare:stub"
agentId?: string; // Default: "cloudflare-worker"
}How it works
occWrapTool()wraps a tool'sexecutewith pre/post proof signingoccWrapBinding()wraps all methods on a Cloudflare binding via Proxy- An ephemeral Ed25519 key pair is generated in-memory per Worker invocation
- Pre-execution proof: Ed25519 signature over SHA-256 of tool name + arguments
- Post-execution proof: signature over tool name + args + result
- Proofs are chained via
prevB64for tamper-evident ordering - No filesystem access — proofs are returned, not written to disk
Verify
Collect proof entries and write them to a .jsonl file, then:
npx occ-mcp-proxy verify proof.jsonl