Add backward-compatibility shims for runtime receipt signing#14
Merged
Conversation
- src/compat.ts: CANONICAL_ID_SORTED_KEYS_V1, signReceiptEd25519Sha256, verifyReceiptEd25519Sha256 for runtime/server.mjs backward compat - src/index.ts: export compat shims - package.json: add prepare script so GitHub installs build dist/ - test/compat.test.ts: round-trip sign/verify, tamper detection, idempotency
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 introduces backward-compatibility adapters (
compat.ts) that translate between the runtime's envelope format (receipt withmetadata.proof) and the core v1.1.0 signing APIs. These shims enable the runtime/server.mjs to use the standardized Ed25519 signing protocol while maintaining compatibility with existing receipt structures.Key Changes
New
src/compat.tsmodule: Provides two main functions for runtime receipt handling:signReceiptEd25519Sha256(): Signs a runtime-style receipt and embeds the proof inmetadata.proofverifyReceiptEd25519Sha256(): Verifies a signed receipt, reconstructing the original payload by stripping the proof blockType definitions: Exports interfaces for
RuntimeReceipt,RuntimeProof, and related options/results typesExport constant:
CANONICAL_ID_SORTED_KEYS_V1for downstream useComprehensive test suite (
test/compat.test.ts): Validates signing, verification, tampering detection, idempotency, and legacysignature_b64field supportPackage exports: Added
./compatsubpath export inpackage.jsonfor modular importsBuild automation: Added
preparescript to ensure builds run before publishingImplementation Details
signatureandsignature_b64fields for backward compatibilityhttps://claude.ai/code/session_0112Taq5ne2BieC3hfqjjf3r