Skip to content

refactor: bridge architecture overhaul, connection pooling, and security hardening#57

Merged
Yashh56 merged 5 commits intoRelwave:developfrom
Yashh56:code-improvement
Apr 4, 2026
Merged

refactor: bridge architecture overhaul, connection pooling, and security hardening#57
Yashh56 merged 5 commits intoRelwave:developfrom
Yashh56:code-improvement

Conversation

@Yashh56
Copy link
Copy Markdown
Member

@Yashh56 Yashh56 commented Apr 4, 2026

Overview

This PR addresses several critical and major architectural setbacks in the Node.js bridge to vastly improve security, resource management, and codebase maintainability.

Key Changes

  • Security: Replaced machine-derived encryption keys with a secure, 32-byte randomized app secret (~/.relwave/relwave.key) and per-credential salts (AES-256-CBC).
  • Concurrency: Fixed broken Promise.race logic in parallelMap with a strict worker-based limit that guarantees input-order preservation.
  • Resource Management: Implemented connectionPool.ts (with a 10-minute idle eviction) and added a 30-minute background sweeper for orphaned sessions to prevent memory leaks.
  • Architecture: Introduced connectorRegistry.ts to map DB types to modules, eliminating over 1,000 lines of massive if/else dispatch chains across handlers.
  • Cleanup: Eradicated globalThis dependency for JSON-RPC registration, cleaned up index.ts, and injected proper Pino loggers.

⚠️ BREAKING CHANGE
Existing user database passwords encrypted with the legacy hostname-derived key are unrecoverable. Users will be prompted to re-enter their credentials on first connect.

Yashh56 added 5 commits April 4, 2026 21:58
- Replaced predictably-derived encryption key with a randomly generated 32-byte app secret stored securely in ~/.relwave/relwave.key
- Implemented per-credential salts for AES-256-CBC encryption in dbStore.ts
BREAKING CHANGE: Existing database passwords encrypted with the legacy hostname-derived key are unrecoverable and will require user re-entry.
…nagement

- Introduced connectionPool.ts to cache database configurations per dbId
- Updated DatabaseService to route through the connection pool, reducing disk IO
- Added a background sweeper to SessionManager that evicts orphaned, idle sessions older than 30 minutes to prevent memory leaks
- Fixed DatabaseService to strictly use the dbStoreInstance singleton
…ncurrency

- Fixed parallelMap concurrency limit and guaranteed input-order preservation
- Created connectorRegistry.ts mapping database types to connector modules
- Rewrote queryExecutor.ts and queryHandlers.ts to eliminate massive if/else dispatch chains
- Eradicated globalThis mutation from RPC handler registration
- Cleaned up bridge startup logic and simplified index.ts
- Removed dead rust scaffold code from src-tauri/src/lib.rs
- Moved TitleBar import to the top of main.tsx
- Renamed frontend theme storage key to relwave-ui-theme
@Yashh56 Yashh56 merged commit 69a383a into Relwave:develop Apr 4, 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