Skip to content

Verify a Receipt

Verification is deterministic and offline once you have the issuer's public key. No network calls, no external services.

Install

pnpm add @peac/protocol @peac/crypto

Verify a receipt

import { verifyLocal } from '@peac/protocol'
import { decodeJWS } from '@peac/crypto'

const receipt = 'eyJhbGciOiJFZERTQSIs...' // compact JWS

// Decode the JWS to inspect claims
const { header, payload } = decodeJWS(receipt)

// Verify: deterministic and offline once you have the public key
const result = verifyLocal(receipt, {
  publicKey,          // issuer's Ed25519 public key (Uint8Array)
  expectedIss: 'https://api.example.com',
})

if (result.verified) {
  console.log('Record verified:', result.claims)
} else {
  console.log('Verification failed:', result.reason)
}

Public keys can be acquired from an issuer's /.well-known/peac-issuer.json endpoint or provided out of band. Key discovery requires a network call; verification itself does not.