DEPLOYMENT
Cloudflare Workers
Deploy PEAC receipt verification at the edge with Cloudflare Workers. Challenge requests with HTTP 402 and verify signed records before forwarding to your origin.
Edge Receipt Verification
Cloudflare Workers run at 300+ edge locations worldwide, making them ideal for verifying PEAC-Receipts with minimal latency. Gate your origin behind a Worker that challenges agents with HTTP 402 and verifies receipts before forwarding requests.
Ed25519 signature verification is stateless and runs at the edge without network calls. This pattern keeps your origin clean while enforcing payment and policy at the network edge.
Quickstart
- Install Originary Worker template:
npm create cloudflare@latest -- --template originary/worker - Configure your Originary API key and policy URL
- Deploy to Cloudflare:
wrangler deploy - Worker intercepts requests, challenges with 402, verifies receipts
- Valid receipts are forwarded to origin; invalid requests are rejected at edge
Code Example
export default {
async fetch(request, env) {
const receipt = request.headers.get('PEAC-Receipt')
if (!receipt) {
return new Response('Payment Required', {
status: 402,
headers: { 'WWW-Authenticate': 'PEAC' }
})
}
const valid = await verifyReceipt(receipt, env.ORIGINARY_KEY)
if (!valid) return new Response('Invalid Receipt', { status: 403 })
return fetch(request) // Forward to origin
}
}Deploy to the edge in minutes
Protect your origin with edge receipt verification using Cloudflare Workers.
Get Started