Skip to main content
DEPLOYMENT

Cloudflare Workers

Deploy Originary receipt verification at the edge with Cloudflare Workers. Challenge requests with HTTP 402 and verify PEAC-Receipts in under 5ms globally.

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 fast enough to run at the edge, typically completing in under 5ms. This pattern keeps your origin clean while enforcing payment and policy at the network edge.

5-Minute Quickstart

  1. Install Originary Worker template: npm create cloudflare@latest -- --template originary/worker
  2. Configure your Originary API key and policy URL
  3. Deploy to Cloudflare: wrangler deploy
  4. Worker intercepts requests, challenges with 402, verifies receipts
  5. 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 for $1