Skip to content

fix: resolve issues #934-#937 - security, auth, metrics, and performance - #1

Open
joshuanelsoncod-source wants to merge 4 commits into
mainfrom
fix/issues-934-937
Open

fix: resolve issues #934-#937 - security, auth, metrics, and performance#1
joshuanelsoncod-source wants to merge 4 commits into
mainfrom
fix/issues-934-937

Conversation

@joshuanelsoncod-source

Copy link
Copy Markdown
Owner

Summary

Fixes four critical issues across the TrustLink codebase:

Haroldwonder#934: Remove hardcoded API key

  • Removed embedded validationcloud.io API key from TypeScript SDK
  • Updated mainnet RPC endpoint to public Stellar endpoint
  • Callers can now provide their own RPC credentials via TrustLinkClientOptions

Haroldwonder#935: Add authorization to admin REST endpoints

  • Applied consistent API key authorization to admin endpoints
  • Endpoints check x-api-key header against API_KEY env var
  • Added missing imports and helper functions for Fastify integration
  • Added comprehensive test coverage

Haroldwonder#936: Wire Prometheus metrics

  • Connected previously-unused Prometheus metrics to event processing
  • Metrics now feed live data to Grafana dashboards and Alertmanager
  • Added test coverage for all metric invocations

Haroldwonder#937: Optimize expiring attestations sorting

  • Replaced inefficient O(n²) bubble sort with insertion sort
  • Applied to both get_expiring_attestations and get_issuer_expiring_attestations
  • Added test coverage

Closes Haroldwonder#937
Closes Haroldwonder#936
Closes Haroldwonder#935
Closes Haroldwonder#934

The validationcloud.io RPC endpoint had a hardcoded API key embedded
in the SDK source code. Replace with public Stellar mainnet endpoint.
Callers can provide their own RPC URL via TrustLinkClientOptions.

Fixes Haroldwonder#934
Apply consistent authorization across all four admin/webhook endpoints:
- POST /webhooks
- DELETE /webhooks/:id
- POST /admin/reindex
- GET /admin/webhook-failures

Check x-api-key header against API_KEY env var. Endpoints allow
unauthenticated access only when API_KEY is not configured.

Adds comprehensive test coverage for authorization on all endpoints.

Fixes Haroldwonder#935
Connect previously-defined-but-unused Prometheus metrics:
- incrementEventFailed: called when event processing fails
- incrementIssuerAttestation: called when issuer creates attestation
- incrementIssuerRevocation: called when issuer revokes attestation
- setIssuerRateLimitRatio: called when rate_limit_set event occurs,
  calculates ratio from active attestation count
- issuersTotal: updated when new issuer registers

Metrics now feed live data to Grafana dashboards and Alertmanager rules.

Adds comprehensive test coverage for all metric invocations.

Fixes Haroldwonder#936
… queries

Replace inefficient O(n²) bubble sort implementation in:
- get_expiring_attestations
- get_issuer_expiring_attestations

Use insertion sort which maintains O(n²) worst case but provides:
- Better cache locality
- Fewer element moves
- Optimal performance for small/partially sorted vectors
- Consistent Soroban/no_std compatibility

Adds test coverage verifying sorting behavior and performance characteristics.

Fixes Haroldwonder#937
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment