Add receipt ID lookup and verification endpoints (POST /api/verify-id, GET /api/receipts/:id)#378
Merged
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
receipt_idwithout knowing where the JSON is stored.claim_requests(genesis_receipt_id/genesis_receipt_json) and optionally areceiptstable in the future.Description
lib/receipts/find-receipt-by-id.jswhich looks up receipts by ID first onclaim_requests.genesis_receipt_id/genesis_receipt_jsonand then (optionally)receipts.receipt_id, with safe error handling that does not surface raw DB errors to clients.POST /api/verify-id(api/verify-id.js) that validatesreceipt_id, usesfindReceiptById, calls the existingverifyReceiptlogic, and returns a compact extension-friendly result (VERIFIED / INVALID / RECEIPT_NOT_FOUND) without leaking storage internals.GET /api/receipts/:id(api/receipts/[id].js) that returns stored receipt JSON when present andRECEIPT_NOT_FOUNDotherwise.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
node --test tests/api-verify-id.test.jsand all 8 tests in that file passed.npm testand all tests passed (122 tests total passed).npm run check:linksand the link check succeeded for local assets.erc8211.merkle.v1as requested and found no matches.Codex Task