A monorepo containing OneKey's server infrastructure components, including end-to-end encryption server and cloud synchronization services.
This monorepo uses Yarn workspaces to manage multiple packages:
e2ee-server/
βββ packages/
β βββ transfer-server/ # E2EE real-time communication server
β βββ cloud-sync-server/ # Cloud synchronization component
βββ examples/
βββ mock-app/ # Mock application for testing
End-to-End Encryption Server - A high-performance, secure real-time communication server built with Socket.IO and TypeScript.
- Real-time bidirectional communication
- Room-based message routing
- End-to-end encryption support
- WebSocket with Socket.IO
- Production-ready with health checks
Cloud Sync Component - A Midway.js-based component for OneKey Prime synchronization functionality.
- Midway.js component architecture
- MongoDB and Kafka adapter support
- Dependency injection patterns
- Extensible sync service implementation
Mock Application - Testing and development application for integration testing.
- Midway.js application framework
- Integration test examples
- API endpoint testing
- Development environment setup
- Node.js >= 24
- Yarn package manager
- MongoDB (for cloud-sync-server)
- Kafka (optional, for cloud-sync-server)
# Clone the repository
git clone <repository-url>
cd e2ee-server
# Install all dependencies
yarn install
# Build all packages
yarn build
# Start transfer-server in development mode
yarn dev
# Start cloud-sync-server in watch mode
yarn dev:sync
# Start mock application
yarn dev:mock
# Build all packages
yarn build
# Start transfer-server
yarn start
# Start mock application
yarn start:mock
Command | Description |
---|---|
yarn install |
Install all dependencies for all packages |
yarn build |
Build all packages |
yarn build:sync |
Build cloud-sync-server only |
yarn build:mock |
Build mock-app only |
yarn dev |
Start transfer-server in development mode |
yarn dev:sync |
Start cloud-sync-server in watch mode |
yarn dev:mock |
Start mock-app in development mode |
yarn start |
Start transfer-server in production |
yarn start:mock |
Start mock-app in production |
yarn test |
Run tests for all packages |
yarn test:sync |
Run tests for cloud-sync-server |
yarn test:mock |
Run tests for mock-app |
yarn lint |
Run ESLint for all packages |
yarn lint:sync |
Run ESLint for cloud-sync-server |
yarn clean |
Clean build artifacts for all packages |
Each package has its own set of scripts. Navigate to the package directory or use yarn workspace commands:
# Run command for specific package
yarn workspace @onekeyhq/transfer-server <command>
yarn workspace @onekeyhq/cloud-sync-server <command>
yarn workspace @onekeyhq/mock-app <command>
Each package can be configured using environment variables. Create .env
files in package directories:
PORT=3868
CORS_ORIGINS=http://localhost:3000
MAX_USERS_PER_ROOM=2
ROOM_TIMEOUT=3600000
MAX_MESSAGE_SIZE=10485760
Configure through Midway.js configuration files in src/config/
.
e2ee-server/
βββ packages/
β βββ transfer-server/ # E2EE Server
β β βββ src/
β β β βββ server.ts # Main server entry
β β β βββ roomManager.ts # Room management
β β β βββ e2eeServerApi.ts # API interfaces
β β β βββ utils/ # Utility functions
β β βββ package.json
β β βββ tsconfig.json
β β
β βββ cloud-sync-server/ # Sync Component
β βββ src/
β β βββ configuration.ts # Midway configuration
β β βββ service/ # Service implementations
β β βββ dto/ # Data transfer objects
β β βββ adapter/ # External adapters
β βββ package.json
β βββ tsconfig.json
β
βββ examples/
β βββ mock-app/ # Mock Application
β βββ src/
β β βββ configuration.ts
β β βββ controller/
β β βββ service/
β βββ package.json
β
βββ package.json # Root package.json
βββ yarn.lock # Yarn lock file
βββ CLAUDE.md # AI assistant instructions
βββ README.md # This file
# Run all tests
yarn test
# Run tests for specific package
yarn test:sync # Cloud sync server tests
yarn test:mock # Mock app tests
# Run tests with coverage
yarn workspace @onekeyhq/cloud-sync-server test:cov
# Run tests in watch mode
yarn workspace @onekeyhq/cloud-sync-server test:watch
# Run linting for all packages
yarn lint
# Run linting for specific package
yarn lint:sync
# Auto-fix linting issues
yarn workspace @onekeyhq/cloud-sync-server lint:fix
# Build transfer-server image
docker build -f packages/transfer-server/Dockerfile -t onekey/transfer-server .
# Build cloud-sync-server image
docker build -f packages/cloud-sync-server/Dockerfile -t onekey/cloud-sync-server .
version: '3.8'
services:
transfer-server:
image: onekey/transfer-server
ports:
- "3868:3868"
environment:
- NODE_ENV=production
- PORT=3868
cloud-sync-server:
image: onekey/cloud-sync-server
ports:
- "7001:7001"
environment:
- NODE_ENV=production
depends_on:
- mongodb
- kafka
mongodb:
image: mongo:latest
ports:
- "27017:27017"
kafka:
image: confluentinc/cp-kafka:latest
ports:
- "9092:9092"
- Transfer Server:
http://localhost:3868/health
- Mock App:
http://localhost:7001/health
- Transfer Server:
http://localhost:3868/stats
- Create feature branch from
main
- Make changes and commit with conventional commits
- Run tests and linting
- Create pull request
- Merge after review
feat: Add new feature
fix: Fix bug
docs: Update documentation
style: Format code
refactor: Refactor code
test: Add tests
chore: Update dependencies
- Create new directory under
packages/
- Initialize package with
package.json
- Add to workspaces in root
package.json
- Run
yarn install
from root
- All sensitive configuration should use environment variables
- Never commit
.env
files - Use HTTPS in production
- Configure CORS appropriately
- Implement rate limiting
- Regular dependency updates
This project is part of the OneKey ecosystem.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'feat: Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
For issues and questions:
- Open an issue on GitHub
- Contact the OneKey development team