native-update
Version:
Foundation package for building a comprehensive update system for Capacitor apps. Provides architecture and interfaces but requires backend implementation.
147 lines (121 loc) • 3.28 kB
Markdown
# Backend Server Requirements
This document outlines the server infrastructure you need to build to use this plugin.
## ⚠️ No Server Included
This plugin does **not** include a backend server. You must build your own server that implements these requirements.
## Required API Endpoints
### 1. Version Check Endpoint
```
GET /api/v1/updates/check
```
**Query Parameters:**
- `appId`: Your application ID
- `currentVersion`: Current bundle version
- `platform`: ios | android | web
- `channel`: production | staging | development
**Response:**
```json
{
"updateAvailable": true,
"version": "1.2.3",
"minAppVersion": "2.0.0",
"releaseNotes": "Bug fixes and improvements",
"downloadUrl": "https://cdn.example.com/bundles/1.2.3.zip",
"signature": "base64-encoded-signature",
"checksum": "sha256-hash",
"size": 1234567,
"mandatory": false
}
```
### 2. Bundle Download Endpoint
```
GET /api/v1/bundles/{version}
```
**Requirements:**
- Serve bundle files with proper MIME types
- Support resume/partial downloads
- Include security headers
- CDN integration recommended
### 3. Update Confirmation Endpoint
```
POST /api/v1/updates/confirm
```
**Body:**
```json
{
"appId": "com.example.app",
"version": "1.2.3",
"platform": "ios",
"success": true,
"deviceId": "unique-device-id"
}
```
## Security Requirements
### Bundle Signing
- Generate RSA or ECDSA key pairs
- Sign bundles with private key
- Include public key in app
- Verify signatures before applying updates
### HTTPS Requirements
- All endpoints must use HTTPS
- Consider certificate pinning
- Implement rate limiting
- Add authentication tokens
## Storage Infrastructure
### Bundle Storage
- Store bundle files securely
- Implement versioning system
- Clean up old versions
- Monitor storage usage
### CDN Configuration
- Geographic distribution
- Caching strategies
- Bandwidth optimization
- Fallback mechanisms
## Example Server Structure
```
update-server/
├── src/
│ ├── api/
│ │ ├── updates.js
│ │ ├── bundles.js
│ │ └── analytics.js
│ ├── services/
│ │ ├── signing.js
│ │ ├── storage.js
│ │ └── version.js
│ ├── middleware/
│ │ ├── auth.js
│ │ ├── security.js
│ │ └── logging.js
│ └── config/
│ └── index.js
├── bundles/
│ └── [stored bundle files]
├── keys/
│ ├── private.pem
│ └── public.pem
└── package.json
```
## Minimum Implementation Checklist
- [ ] Version check API endpoint
- [ ] Bundle download endpoint
- [ ] Bundle signing implementation
- [ ] HTTPS configuration
- [ ] Basic authentication
- [ ] Error handling
- [ ] Logging system
- [ ] Health check endpoint
## Recommended Features
- [ ] Analytics tracking
- [ ] A/B testing support
- [ ] Rollback capabilities
- [ ] Multi-tenant support
- [ ] Admin dashboard
- [ ] Monitoring/alerting
- [ ] Automated testing
## Getting Help
Since no server is provided, you'll need to:
1. Build your own implementation
2. Use a third-party service
3. Hire developers familiar with update servers
Consider looking at open-source examples or commercial solutions for inspiration.