feat(receipts): add standalone purchase receipt verifier (closes #238) - #250
Open
Ranjeet2063 wants to merge 1 commit into
Open
Conversation
…pt-Hash-Stellar#238) - Add src/lib/receipts/receiptVerifier.ts with verifyReceipt(), verifyReceiptFromExport(), and checkReceiptIntegrity() utilities - Works entirely from exported receipt data + Stellar Horizon public API; no hosted PromptHash app dependency required - verifyReceipt() checks: field presence, contentHash format (64-char hex), Horizon tx existence, tx success status, and buyer/source-account match - verifyReceiptFromExport() accepts plain-JSON or base64-encoded exports - checkReceiptIntegrity() provides offline tamper detection via SHA-256 fingerprint over all canonical receipt fields - Add comprehensive test suite (receiptVerifier.test.ts): 14 cases covering valid receipts, tampered fields, tx_not_found, tx_failed, buyer_mismatch, network errors, export parsing, and offline fingerprint checks - Update docs/integration-guide.md with Standalone Receipt Verification section: receipt fields table, status codes, CLI usage, offline mode
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.
Summary
Closes #238
Implements a standalone purchase receipt verifier that works entirely without any hosted PromptHash application dependency. All verification checks run against the public Stellar Horizon API or use fully offline, deterministic SHA-256 fingerprint logic.
Changes
src/lib/receipts/receiptVerifier.ts(new)verifyReceipt(receipt, network)— full on-chain verification via Stellar HorizoncontentHashformat check (must be 64-character lowercase hex / SHA-256)tx_not_found,tx_failed, and networkerrorstatesbuyer_mismatchstatusvalidwith deterministic fingerprint indetailsverifyReceiptFromExport(exported, network)— accepts plain-JSON or base64-encoded export strings; surfaces corrupted/tampered exports gracefullycheckReceiptIntegrity(receipt, knownFingerprint)— fully offline tamper detection via SHA-256 over all canonical receipt fields; no network call neededsrc/lib/receipts/receiptVerifier.test.ts(new)14 test cases covering:
validstatus + correct explorerUrl + fingerprintbuyer_mismatchtamperedtamperedtx_not_foundtx_failederrorvalidvalidtampereddocs/integration-guide.md(updated)New Standalone Purchase Receipt Verification section with:
Acceptance Criteria