Implement legacy receipt verification & improve config/health surface#59
Merged
Merged
Conversation
- runtime/src/receipt-verification.js: implement missing exports (resolveSigner, resolveSignatureKey, verifyReceipt) used by four test files; stub-only file caused all legacy compatibility tests to throw TypeError at import - server.mjs: rename doClean return key from `cleaned` to `cleaned_content` to match test assertions in runtime-signing.test.mjs - server.mjs: remove dead variable `text` in doFetch error branch - server.mjs: hoist warmQueue/warmRunning declarations before handleVerb to eliminate temporal dead zone risk - server.mjs: lift `execution` declaration out of try block in handleVerb so catch block can reuse it without re-computing it - server.mjs: add verifier_ok field to /health response so scripts/smoke.mjs CI check does not abort on missing field - scripts/smoke.mjs: guard verifier_ok check correctly (field is now present) - SECURITY.md: remove false claim that RATE_LIMIT_MAX/RATE_LIMIT_WINDOW_MS are not implemented; they are actively read by server.mjs and passed to createRateLimiter - docs/CONFIGURATION.md: move RATE_LIMIT_MAX and RATE_LIMIT_WINDOW_MS out of the "not implemented" list and into a dedicated rate-limiting section - .env.example: align signer ID variable to canonical name RECEIPT_SIGNER_ID (was CL_RECEIPT_SIGNER_ID which is only an alias)
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
This PR restores legacy receipt verification helpers for backward-compatibility test coverage, improves the health endpoint surface, refactors error handling in
handleVerb, and updates configuration documentation to reflect current practices.Key Changes
Layer 3 (Execution Runtime) — receipt-verification.js
resolveSigner(),resolveSignatureKey(), andverifyReceipt()as legacy helpers for test_vectors schema@commandlayer/runtime-core(Layer 2)decodeBase64()anded25519RawToSpkiPem()for ed25519 key handlingLayer 3 (Execution Runtime) — server.mjs
verifier_okfield to/healthresponse (true when public key or ETH_RPC_URL is configured)executioncomputation outside try/catch inhandleVerb()so error path can reuse it without re-parsing consumed request bodycleaned→cleaned_contentand added fallback paths forbody.contentandbody.input.contentbody.contentinput pathhandleVerb()to avoid temporal dead zoneconst text = await resp.text()indoFetch()http://prefix)Configuration & Documentation
RECEIPT_SIGNER_IDas canonical) and encoding (RECEIPT_SIGNING_PRIVATE_KEY_PEM_B64for base64-encoded PKCS8)RATE_LIMIT_WINDOW_MSandRATE_LIMIT_MAXdefaults; moved these from "deprecated" to "active" section/healthand/healthzexclusions; notedRATE_LIMIT_ENABLEDis not a live toggleverifier_okto be absent (only fail if explicitlyfalse)Implementation Details
crypto.createVerify()with ed25519 algorithm and SPKI PEM format{ valid: false, error: string }for all failure pathshandleVerb()ensures the error catch block has access toexecutionwithout re-parsing the request body (which may have been consumed by the try block)Contract Impact
verifier_okfield (backward compatible; clients can ignore)runtime-corehttps://claude.ai/code/session_01GQcff5HnFcrTbyuwuvsNEv