https://github.com/onekeyhq/e2ee-server
https://github.com/onekeyhq/e2ee-server
Last synced: 7 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/onekeyhq/e2ee-server
- Owner: OneKeyHQ
- Created: 2025-07-17T03:50:43.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2025-08-14T03:00:41.000Z (8 months ago)
- Last Synced: 2025-08-14T03:26:24.505Z (8 months ago)
- Language: TypeScript
- Size: 160 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# OneKey Server Infrastructure
A monorepo containing OneKey's server infrastructure components, including end-to-end encryption server and cloud synchronization services.
## ๐ Architecture
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
```
## ๐ฆ Packages
### [@onekeyhq/transfer-server](./packages/transfer-server/)
**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
### [@onekeyhq/cloud-sync-server](./packages/cloud-sync-server/)
**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
### [@onekeyhq/mock-app](./examples/mock-app/)
**Mock Application** - Testing and development application for integration testing.
- Midway.js application framework
- Integration test examples
- API endpoint testing
- Development environment setup
## ๐ Quick Start
### Prerequisites
- Node.js >= 24
- Yarn package manager
- MongoDB (for cloud-sync-server)
- Kafka (optional, for cloud-sync-server)
### Installation
```bash
# Clone the repository
git clone
cd e2ee-server
# Install all dependencies
yarn install
# Build all packages
yarn build
```
### Development
```bash
# Start transfer-server in development mode
yarn dev
# Start cloud-sync-server in watch mode
yarn dev:sync
# Start mock application
yarn dev:mock
```
### Production
```bash
# Build all packages
yarn build
# Start transfer-server
yarn start
# Start mock application
yarn start:mock
```
## ๐ Available Scripts
### Root Level Commands
| 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 |
### Package-Specific Commands
Each package has its own set of scripts. Navigate to the package directory or use yarn workspace commands:
```bash
# Run command for specific package
yarn workspace @onekeyhq/transfer-server
yarn workspace @onekeyhq/cloud-sync-server
yarn workspace @onekeyhq/mock-app
```
## ๐ง Configuration
### Environment Variables
Each package can be configured using environment variables. Create `.env` files in package directories:
#### transfer-server
```env
PORT=3868
CORS_ORIGINS=http://localhost:3000
MAX_USERS_PER_ROOM=2
ROOM_TIMEOUT=3600000
MAX_MESSAGE_SIZE=10485760
```
#### cloud-sync-server
Configure through Midway.js configuration files in `src/config/`.
## ๐ Project Structure
```
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
```
## ๐งช Testing
```bash
# 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
```
## ๐ Code Quality
```bash
# 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
```
## ๐ณ Docker Support
### Building Docker Images
```bash
# 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 .
```
### Docker Compose
```yaml
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"
```
## ๐ Monitoring
### Health Checks
- Transfer Server: `http://localhost:3868/health`
- Mock App: `http://localhost:7001/health`
### Server Statistics
- Transfer Server: `http://localhost:3868/stats`
## ๐ Development Guidelines
### Git Workflow
1. Create feature branch from `main`
2. Make changes and commit with conventional commits
3. Run tests and linting
4. Create pull request
5. Merge after review
### Commit Convention
```
feat: Add new feature
fix: Fix bug
docs: Update documentation
style: Format code
refactor: Refactor code
test: Add tests
chore: Update dependencies
```
### Adding New Packages
1. Create new directory under `packages/`
2. Initialize package with `package.json`
3. Add to workspaces in root `package.json`
4. Run `yarn install` from root
## ๐ Security
- All sensitive configuration should use environment variables
- Never commit `.env` files
- Use HTTPS in production
- Configure CORS appropriately
- Implement rate limiting
- Regular dependency updates
## ๐ License
This project is part of the OneKey ecosystem.
## ๐ค Contributing
1. Fork the repository
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'feat: Add amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request
## ๐ Support
For issues and questions:
- Open an issue on GitHub
- Contact the OneKey development team
## ๐ Related Links
- [OneKey Website](https://onekey.so)
- [Documentation](./docs/)
- [API Reference](./docs/api/)
- [Migration Guide](./docs/migration.md)