Skip to content

feat: add signed meter metadata payloads#701

Merged
AnnabelJoe merged 2 commits into
AnnabelJoe:mainfrom
jessicanath:feat/547-signed-meter-metadata
Jul 3, 2026
Merged

feat: add signed meter metadata payloads#701
AnnabelJoe merged 2 commits into
AnnabelJoe:mainfrom
jessicanath:feat/547-signed-meter-metadata

Conversation

@jessicanath

Copy link
Copy Markdown
Contributor

Summary

Closes #547

Extends the meter reading payload to support optional device metadata (firmware version, hardware model, manufacturer, GPS coordinates), signed by the meter's Ed25519 key — so metadata is as tamper-evident as the reading itself.

Changes

  • lib/crypto.ts — adds MeterMetadata interface and computeMetadataHash() (SHA-256 of sorted-key canonical JSON)
  • api/readings/route.ts — accepts metadata + metadata_signature_hex; verifies Ed25519 sig before persisting; validates that sig is present when metadata is included
  • database.types.ts — adds metadata, metadata_hash, metadata_signature_hex columns to readings Row/Insert types
  • docs/migrations/003_meter_metadata.sqlALTER TABLE readings migration for the three new columns + index on metadata_hash
  • scripts/send-reading.mjs — adds --firmware, --model, --manufacturer flags; builds + signs metadata hash automatically

What was tested

  • TypeScript types compile cleanly
  • Metadata is optional — existing readings without it continue to work unchanged
  • Zod refine validator rejects a payload with metadata but no signature

jessicanath and others added 2 commits June 27, 2026 17:28
- Add MeterMetadata type and computeMetadataHash() to crypto lib
- Extend ReadingSchema to accept optional metadata + metadata_signature_hex
- Verify Ed25519 metadata signature in POST /api/readings
- Persist metadata, metadata_hash, metadata_signature_hex on readings row
- Add migration 003 for new readings columns
- Update send-reading.mjs to sign and send --firmware/--model/--manufacturer
@drips-wave

drips-wave Bot commented Jul 3, 2026

Copy link
Copy Markdown

@jessicanath Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@AnnabelJoe AnnabelJoe merged commit 6289698 into AnnabelJoe:main Jul 3, 2026
3 of 20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for signed meter metadata payloads

2 participants