Refactor README and enhance ENS/receipt validation#16
Merged
Conversation
- src/ens.ts: fix resolveSignerFromENS signature — positional args (string, provider) are the canonical implementation; README was showing the wrong object-destructure calling convention. Added resolveSignerFromENSOptions overload for ergonomic usage so both calling styles work. - src/receipt.ts: add missing validation for payload.version in signReceipt; add input-length guard on signature base64 before calling verifyCanonical - src/compat.ts: guard against empty string signature (not just missing field) in verifyReceiptEd25519Sha256; add explicit type narrowing - README.md: remove every fabricated export reference (buildCommonsReceipt, buildCommercialReceipt, normalizeCommonsRequest, normalizeCommercialRequest, createSchemaClient, buildSchemaPath, createLayeredReceipt, hashReceiptCanonical, COMMONS_CONTRACT, COMMERCIAL_CONTRACT, COMMAND_LAYER_CURRENT_LINE, signReceiptEd25519, verifyReceiptSignature, toLegacyReceiptEnvelope, receipt-v1 subpath). Replace with accurate API surface matching src/index.ts exports. - package.json: remove stale AJV claim from description; confirm no unused deps - .env.example: add required file documenting RPC_URL and key env vars - test/receipt.test.ts: remove bare `as any` cast, add assertion on version field
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 significantly improves the documentation and adds stricter validation to core signing and ENS resolution functions. The README is rewritten to focus on the canonical implementation role of
runtime-core, with clearer examples and protocol documentation. Input validation is strengthened across receipt signing, ENS resolution, and legacy compat functions.Key Changes
Documentation & Examples
runtime-coreas the single canonical implementation of signing, verification, and canonicalization.env.exampleENS Resolution (
src/ens.ts)resolveSignerFromENS('name.eth', provider)(positional)resolveSignerFromENS({ ensName: 'name.eth', provider })(options)ResolveSignerFromENSOptionsinterface for options object formENS_KEY_SIGNERconstant from crypto module for convenienceReceipt Signing & Verification (
src/receipt.ts)signReceipt(): now validates all four required fields (verb, version, agent, timestamp) are non-empty stringsverifyReceipt()structure checks: validates signature is a non-empty stringisSignedLayeredReceipt(): now checks that signature string is non-empty (length > 0)Legacy Compat (
src/compat.ts)signReceiptEd25519Sha256(): validates privateKeyPem, signer_id, kidverifyReceiptEd25519Sha256(): validates publicKeyPemOrDersignatureorsignature_b64field with non-empty string checkTests (
test/ens.test.ts,test/receipt.test.ts)Notable Implementation Details
+concatenation for consistency with existing codebase stylehttps://claude.ai/code/session_01GQcff5HnFcrTbyuwuvsNEv