Skip to content

Restore authoritative receipt consensus time for scoped keys - #92

Merged
thetangstr merged 1 commit into
mainfrom
kailortang-prog/public-block-time-fallback
Jul 23, 2026
Merged

Restore authoritative receipt consensus time for scoped keys#92
thetangstr merged 1 commit into
mainfrom
kailortang-prog/public-block-time-fallback

Conversation

@thetangstr

Copy link
Copy Markdown
Owner

Why

Logging-scoped credentials can anchor receipts but receive HTTP 401 from /api/time/block. The immutable public /searchAssetFromChain response already carries the authoritative block time, so receipts could remain confirmed while consensusTime stayed null forever.

What

  • keep the existing scoped block response unchanged when it succeeds
  • on scoped-route 401 only, read the same block through the keyless immutable endpoint
  • validate and normalize block height, proposer, and RFC 3339 block time before enrichment
  • fail closed on missing, malformed, or mismatched public block metadata
  • cover the complete pending-to-confirmed receipt path

The immutable on-chain verification path is unchanged, and the fallback never sends x-api-key.

Verification

  • RED: fallback tests failed with the original AuthError; permissive timestamp validation failed to reject "1"
  • GREEN: targeted getBlock / completeReceipt tests pass
  • npm run build
  • npm test
  • live read of block 1742929 through an intentionally invalid scoped key returned the expected public immutable block time
  • npm audit --audit-level=low still reports the repository baseline of 1 low, 3 moderate, and 2 high advisories; this PR changes no dependency or lockfile

No deploy is included in this PR.

When /api/time/block rejects a logging-only key, read the same immutable block keylessly, validate its metadata, and preserve strict failure semantics for malformed upstream data.

Constraint: Logging-scoped keys receive HTTP 401 from /api/time/block while /searchAssetFromChain is public.

Rejected: Falling back to mutable ledger timestamps | they are not authoritative block time

Confidence: high

Scope-risk: narrow

Directive: Keep this fallback keyless and limited to scoped-route authentication failures.

Tested: npm run build; npm test; targeted getBlock and completeReceipt tests; live block 1742929 read through the fallback

Not-tested: Cloud Run deployment; npm audit still reports 1 low, 3 moderate, and 2 high pre-existing advisories
@thetangstr thetangstr closed this Jul 23, 2026
@thetangstr thetangstr reopened this Jul 23, 2026
@thetangstr
thetangstr merged commit bef177b into main Jul 23, 2026
2 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.

1 participant