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 { decode } from '@peac/crypto'

const receipt = 'eyJhbGciOiJFZERTQSIs...' // compact JWS
const publicKey = /* issuer's Ed25519 public key (Uint8Array) */

// Decode the JWS to inspect header and claims (no verification)
const { header, payload } = decode(receipt)

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

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

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.