Add PP Dashboard API and event subscription#36
Merged
Conversation
Polls Stellar RPC getEvents for provider_added, provider_removed, and contract_initialized events on the Channel Auth contract. - EventWatcher: self-scheduling poll loop, KV-persisted cursor for restart resilience, handler registration pattern - ChannelRegistry: tracks channel state (active/pending/inactive) from on-chain events - fetchChannelAuthEvents: parses RPC event responses into typed events - 16 unit tests with mock RPC responses
Operator authentication via Ed25519 signed challenge. Multisig-aware via Horizon signers lookup. Bounded challenge store (max 1000), configurable TTL from env, one-time nonce consumption. Dependencies injected for testability (provider key, Horizon URL, JWT generator). 9 unit tests including 64-byte invalid signature test.
- POST /dashboard/auth/challenge — nonce for Ed25519 signing - POST /dashboard/auth/verify — verify signature, issue JWT - GET /dashboard/channels — channel registry state - GET /dashboard/mempool — mempool stats and config - GET /dashboard/operations — bundle/tx counts via COUNT queries - GET /dashboard/treasury — OpEx balance from Horizon - GET /dashboard/audit-export — CSV export with SQL date filtering Auth endpoints use low rate limit (10/min). Data endpoints protected by JWT middleware. Error responses don't leak internal details.
- Start/stop EventWatcher in main.ts bootstrap/shutdown - Fix JWT expiry: getNumericDate(0)/getNumericDate(SESSION_TTL) - Hash nonce for JWT sessionId instead of raw material - Hard crash if SERVICE_AUTH_SECRET missing in production - Add countByStatus and findByStatusAndDateRange to repositories - Add composite index on (status, deleted_at, created_at)
The sessionId hashing broke the existing SEP-10 auth flow — bundle endpoints look up sessions by the raw challenge hash stored in KV, but the JWT now contained a hashed value that didn't match. Move the nonce hashing to dashboard-auth.ts only, since dashboard tokens don't use session lookups. The shared generate-jwt.ts passes challengeHash through unchanged to preserve SEP-10 compatibility.
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
Test plan
deno test --no-check --allow-all src/— 25 tests pass