feat: implement OpenAPI deprecation warnings, request signing, and Redis key expiration monitoring - #345
Open
smokeylenz1-commits wants to merge 1 commit into
Conversation
…dis key expiration monitoring Resolves issues Pidoko257#245, Pidoko257#291, Pidoko257#292, and #943. Issue Pidoko257#245 - OpenAPI Deprecation Warnings: - Add DeprecationRegistry for centralized registration of deprecated endpoints - Add deprecationMiddleware for automatic RFC 8594/9110 header injection (Deprecation, Sunset, Link, Warning response headers) - Add deprecate() per-route middleware factory for one-off deprecations - Add enhanceOpenApiWithDeprecations() to annotate the generated OpenAPI spec with deprecated: true, x-sunset, x-deprecation-date, x-replacement fields - Add getDeprecationTimeline() helper for admin dashboards / changelogs Issue Pidoko257#291 - Request Signing for High-Value Transactions: - Add src/utils/requestSigning.ts with RSA-PSS signing and verification utilities (buildCanonicalMessage, signMessage, verifySignature, verifyRequest, buildSigningHeaders, generateKeyPair) - Add src/middleware/requestSigningMiddleware.ts with requireRequestSignature() middleware factory that enforces signature verification for transactions above the configurable threshold (default: 500 000 XAF via REQUEST_SIGNING_THRESHOLD) - Canonical message: METHOD\nPATH\nTIMESTAMP\nNONCE\nSHA-256(body) - Clock-skew tolerance configurable via REQUEST_SIGNING_TIMESTAMP_TOLERANCE Issue Pidoko257#292 - Redis Key Expiration Monitoring and Cleanup: - Add src/jobs/redisKeyExpirationJob.ts scheduled every 10 minutes (configurable via REDIS_EXPIRY_MONITOR_CRON) - Collects Redis INFO stats: used_memory, keyspace_hits/misses, evicted_keys, expired_keys; publishes to Prometheus gauges - Alerts when eviction rate exceeds REDIS_EVICTION_RATE_ALERT_THRESHOLD - Scans and deletes orphaned keys matching configurable prefixes - Dry-run mode via REDIS_CLEANUP_DRY_RUN=true - Register job in scheduler; fix missing travelRuleAuditReportJob import
|
@smokeylenz1-commits 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! 🚀 |
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
This PR resolves four issues by adding three production-ready features to the ProxyPay platform.
Closes #295
Closes #291
Closes #292
Closes #294
#245 — OpenAPI Deprecation Warnings for Old Endpoints
Files:
src/middleware/deprecation.ts,src/openapi/deprecationHandler.tsDeprecationRegistry— Central registry for declaring deprecated endpoints at startup. Supports string/regex path matching and per-method filtering.deprecationMiddleware— Global Express middleware that auto-stamps responses with RFC 8594 (Sunset) and RFC 9110 (Deprecation) headers whenever a request hits a registered deprecated path.deprecate()— Per-route middleware factory for one-off deprecations without touching the registry.enhanceOpenApiWithDeprecations()— Post-processes the Zod-generated OpenAPI document: setsdeprecated: true, addsx-sunset,x-deprecation-date,x-replacementextension fields, and appends migration guidance to operation descriptions.getDeprecationTimeline()— Returns a structured timeline of all deprecated endpoints for admin dashboards and automated changelog generation.Response headers set on deprecated endpoints:
#291 — Request Signing for High-Value Transactions
Files:
src/utils/requestSigning.ts,src/middleware/requestSigningMiddleware.tsAdds RSA-PSS cryptographic request signing for transactions above a configurable amount threshold.
Canonical message format (signed by the client, verified by the server):
Utilities (
src/utils/requestSigning.ts):buildCanonicalMessage()— Deterministic string constructionsignMessage()/verifySignature()— RSA-PSS sign/verify primitivesbuildSigningHeaders()— Client-side convenience: returnsX-Signature,X-Timestamp,X-NonceheadersverifyRequest()— Full server-side verification including clock-skew enforcementgenerateKeyPair()— RSA-2048 key pair generation for onboardingMiddleware (
src/middleware/requestSigningMiddleware.ts):requireRequestSignature(resolvePublicKey, opts)factory — applies signing enforcement on any routeREQUEST_SIGNING_THRESHOLD)REQUEST_SIGNING_TIMESTAMP_TOLERANCE)alwaysRequireoption for unconditional enforcement on high-security endpoints#292 — Redis Key Expiration Monitoring and Cleanup
Files:
src/jobs/redisKeyExpirationJob.ts,src/jobs/scheduler.tsScheduled job (every 10 minutes, configurable via
REDIS_EXPIRY_MONITOR_CRON) that:Collects Redis metrics via
INFO alland publishes to Prometheus:redis_memory_usage_bytesredis_keyspace_hits_total/redis_keyspace_misses_totalredis_evicted_keys_total/redis_expired_keys_totalEviction rate alerting — Computes eviction delta between runs and logs a warning + increments
redis_high_eviction_alert_totalwhen rate exceedsREDIS_EVICTION_RATE_ALERT_THRESHOLD(default: 100/s).Orphan key cleanup — Uses non-blocking
SCANto find keys matching configurable prefixes (REDIS_ORPHAN_KEY_PREFIXES, default:idempotency:,session:,otp:,lock:) with no TTL or TTL exceedingREDIS_ORPHAN_MAX_TTL_SECONDS(default: 86 400 s), then deletes them.REDIS_CLEANUP_DRY_RUN=trueredis_orphan_keys_deleted_totalcounterAlso fixes a pre-existing missing import:
runTravelRuleAuditReportJobwas referenced in the scheduler's JOBS array without a corresponding import statement.Configuration Reference
REQUEST_SIGNING_THRESHOLD500000REQUEST_SIGNING_TIMESTAMP_TOLERANCE300REDIS_EXPIRY_MONITOR_CRON*/10 * * * *REDIS_EVICTION_RATE_ALERT_THRESHOLD100REDIS_ORPHAN_KEY_PREFIXESidempotency:,session:,otp:,lock:REDIS_ORPHAN_MAX_TTL_SECONDS86400REDIS_CLEANUP_DRY_RUNfalse