Skip to content

Add receipt ID lookup and verification endpoints (POST /api/verify-id, GET /api/receipts/:id)#378

Merged
GsCommand merged 1 commit into
mainfrom
codex/add-receipt-verification-support
May 28, 2026
Merged

Add receipt ID lookup and verification endpoints (POST /api/verify-id, GET /api/receipts/:id)#378
GsCommand merged 1 commit into
mainfrom
codex/add-receipt-verification-support

Conversation

@GsCommand

Copy link
Copy Markdown
Contributor

Motivation

  • Provide a backend lookup so external tools and browser extensions can verify CommandLayer receipts by receipt_id without knowing where the JSON is stored.
  • Support genesis receipts stored on claim_requests (genesis_receipt_id / genesis_receipt_json) and optionally a receipts table in the future.
  • Keep verification on the existing verification path, avoid fabricating receipts or exposing DB errors/secrets, and avoid requiring a separate receipt ledger yet.

Description

  • Add lib/receipts/find-receipt-by-id.js which looks up receipts by ID first on claim_requests.genesis_receipt_id/genesis_receipt_json and then (optionally) receipts.receipt_id, with safe error handling that does not surface raw DB errors to clients.
  • Add POST /api/verify-id (api/verify-id.js) that validates receipt_id, uses findReceiptById, calls the existing verifyReceipt logic, and returns a compact extension-friendly result (VERIFIED / INVALID / RECEIPT_NOT_FOUND) without leaking storage internals.
  • Add optional raw lookup endpoint GET /api/receipts/:id (api/receipts/[id].js) that returns stored receipt JSON when present and RECEIPT_NOT_FOUND otherwise.
  • Add comprehensive tests (tests/api-verify-id.test.js) covering malformed requests, missing/unknown IDs, valid and tampered stored receipts, parity with /api/verify, local fallback behavior, DB error secrecy, and raw receipt retrieval.

Testing

  • Ran the new unit tests node --test tests/api-verify-id.test.js and all 8 tests in that file passed.
  • Ran the full test suite via npm test and all tests passed (122 tests total passed).
  • Ran link checks with npm run check:links and the link check succeeded for local assets.
  • Ran a search for erc8211.merkle.v1 as requested and found no matches.

Codex Task

@vercel

vercel Bot commented May 28, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
commandlayer-commandlayer-org Ready Ready Preview, Comment May 28, 2026 11:51pm
commandlayer-org Ready Ready Preview, Comment May 28, 2026 11:51pm
commandlayer-org111 Ready Ready Preview, Comment May 28, 2026 11:51pm

Request Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant