Skip to content

feat(cli): nirium anchor - anchor a hash or small record to IPFS - #263

Merged
Eras256 merged 1 commit into
mainfrom
issue-133-anchor
Nov 7, 2026
Merged

Eras256 merged 1 commit into
mainfrom
issue-133-anchor

Conversation

@M0nsxx

@M0nsxx M0nsxx commented Nov 7, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds nirium anchor, a thin client for the Audit Trail node's POST /api/audit/log:

nirium anchor --file evidence.json
nirium anchor --hash <64-hex>
nirium anchor --record '{"order":"A-12"}'
  • --file computes the sha-256 locally and sends only the hash - the file content is never uploaded (IPFS can't delete anything once pinned).
  • --hash sends a sha-256 you already have.
  • --record anchors a small JSON object verbatim; capped at 8KB client-side, mirroring the server's own MAX_RECORD_BYTES.
  • Exactly one of the three is required.
  • --tx <hash> and --tag <label> are optional passthroughs.
  • Deliberately no --network flag: the agent box decides its own network (STELLAR_NETWORK), and the server already ignores/rejects a client-supplied one.

On success prints the CID, content hash, gateway URL, and a nirium verify <cid> suggestion.

Test plan

  • New test/anchor.test.js (17 cases) against a local HTTP server standing in for the agent - no real network, no real IPFS pin: each input mode, the mutual-exclusivity check, the 8KB limit, file-not-found, invalid hash/JSON, server 400/503, network-unreachable, and that --network is rejected as an unknown option.
  • Full suite green: npm test - 76/76.
  • node --check bin/nirium.js clean (this package ships a single flat file, no build step).

Closes #133

Adds `nirium anchor --file|--hash|--record` against the Audit Trail
node's POST /api/audit/log. --file computes sha-256 locally and sends
only the hash, never the file content. --record mirrors the server's
8KB limit client-side. No --network flag: the agent box decides its own
network, and the server already rejects a client-supplied one.

17 new tests against a local HTTP server standing in for the agent (no
real network, no real IPFS pin), full suite 76/76.

Closes #133

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

@Eras256 Eras256 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving — clean thin client for POST /api/audit/log, matches the issue spec exactly (hash/file/record modes, 8 KB limit, no --network flag). CI green (4/4), tests cover all three input modes.

@Eras256
Eras256 merged commit aa5b203 into main Nov 7, 2026
4 checks passed
Eras256 pushed a commit that referenced this pull request Nov 7, 2026
…k, report (#263, #268, #265, #266) (#269)

Bumps packages/cli 3.0.1 -> 3.1.0 (new public commands, not a patch) and
dates the Unreleased CHANGELOG section. All four changes are already
merged to main.

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
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.

CLI: nirium anchor, anchor a file or hash to the Audit Trail

2 participants