native-update 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CapacitorNativeUpdate.podspec +18 -0
- package/LICENSE +21 -0
- package/Readme.md +451 -0
- package/android/build.gradle +92 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +8 -0
- package/android/gradle.properties +17 -0
- package/android/proguard-rules.pro +29 -0
- package/android/settings.gradle +2 -0
- package/android/src/main/AndroidManifest.xml +34 -0
- package/android/src/main/java/com/aoneahsan/nativeupdate/AppReviewPlugin.kt +153 -0
- package/android/src/main/java/com/aoneahsan/nativeupdate/AppUpdatePlugin.kt +275 -0
- package/android/src/main/java/com/aoneahsan/nativeupdate/BackgroundNotificationManager.kt +390 -0
- package/android/src/main/java/com/aoneahsan/nativeupdate/BackgroundUpdateManager.kt +46 -0
- package/android/src/main/java/com/aoneahsan/nativeupdate/BackgroundUpdatePlugin.kt +333 -0
- package/android/src/main/java/com/aoneahsan/nativeupdate/BackgroundUpdateWorker.kt +251 -0
- package/android/src/main/java/com/aoneahsan/nativeupdate/CapacitorNativeUpdatePlugin.kt +265 -0
- package/android/src/main/java/com/aoneahsan/nativeupdate/LiveUpdatePlugin.kt +526 -0
- package/android/src/main/java/com/aoneahsan/nativeupdate/NotificationActionReceiver.kt +99 -0
- package/android/src/main/java/com/aoneahsan/nativeupdate/SecurityManager.kt +249 -0
- package/dist/esm/__tests__/bundle-manager.test.d.ts +1 -0
- package/dist/esm/__tests__/bundle-manager.test.js +123 -0
- package/dist/esm/__tests__/bundle-manager.test.js.map +1 -0
- package/dist/esm/__tests__/config.test.d.ts +1 -0
- package/dist/esm/__tests__/config.test.js +69 -0
- package/dist/esm/__tests__/config.test.js.map +1 -0
- package/dist/esm/__tests__/integration.test.d.ts +1 -0
- package/dist/esm/__tests__/integration.test.js +78 -0
- package/dist/esm/__tests__/integration.test.js.map +1 -0
- package/dist/esm/__tests__/security.test.d.ts +1 -0
- package/dist/esm/__tests__/security.test.js +54 -0
- package/dist/esm/__tests__/security.test.js.map +1 -0
- package/dist/esm/__tests__/version-manager.test.d.ts +1 -0
- package/dist/esm/__tests__/version-manager.test.js +45 -0
- package/dist/esm/__tests__/version-manager.test.js.map +1 -0
- package/dist/esm/app-review/app-review-manager.d.ts +24 -0
- package/dist/esm/app-review/app-review-manager.js +195 -0
- package/dist/esm/app-review/app-review-manager.js.map +1 -0
- package/dist/esm/app-review/index.d.ts +5 -0
- package/dist/esm/app-review/index.js +6 -0
- package/dist/esm/app-review/index.js.map +1 -0
- package/dist/esm/app-review/platform-review-handler.d.ts +20 -0
- package/dist/esm/app-review/platform-review-handler.js +138 -0
- package/dist/esm/app-review/platform-review-handler.js.map +1 -0
- package/dist/esm/app-review/review-conditions-checker.d.ts +22 -0
- package/dist/esm/app-review/review-conditions-checker.js +155 -0
- package/dist/esm/app-review/review-conditions-checker.js.map +1 -0
- package/dist/esm/app-review/review-rate-limiter.d.ts +23 -0
- package/dist/esm/app-review/review-rate-limiter.js +164 -0
- package/dist/esm/app-review/review-rate-limiter.js.map +1 -0
- package/dist/esm/app-review/types.d.ts +41 -0
- package/dist/esm/app-review/types.js +2 -0
- package/dist/esm/app-review/types.js.map +1 -0
- package/dist/esm/app-update/app-update-checker.d.ts +13 -0
- package/dist/esm/app-update/app-update-checker.js +104 -0
- package/dist/esm/app-update/app-update-checker.js.map +1 -0
- package/dist/esm/app-update/app-update-installer.d.ts +19 -0
- package/dist/esm/app-update/app-update-installer.js +123 -0
- package/dist/esm/app-update/app-update-installer.js.map +1 -0
- package/dist/esm/app-update/app-update-manager.d.ts +28 -0
- package/dist/esm/app-update/app-update-manager.js +199 -0
- package/dist/esm/app-update/app-update-manager.js.map +1 -0
- package/dist/esm/app-update/app-update-notifier.d.ts +14 -0
- package/dist/esm/app-update/app-update-notifier.js +100 -0
- package/dist/esm/app-update/app-update-notifier.js.map +1 -0
- package/dist/esm/app-update/index.d.ts +6 -0
- package/dist/esm/app-update/index.js +7 -0
- package/dist/esm/app-update/index.js.map +1 -0
- package/dist/esm/app-update/platform-app-update.d.ts +19 -0
- package/dist/esm/app-update/platform-app-update.js +129 -0
- package/dist/esm/app-update/platform-app-update.js.map +1 -0
- package/dist/esm/app-update/types.d.ts +58 -0
- package/dist/esm/app-update/types.js +12 -0
- package/dist/esm/app-update/types.js.map +1 -0
- package/dist/esm/background-update/background-scheduler.d.ts +17 -0
- package/dist/esm/background-update/background-scheduler.js +195 -0
- package/dist/esm/background-update/background-scheduler.js.map +1 -0
- package/dist/esm/background-update/index.d.ts +3 -0
- package/dist/esm/background-update/index.js +3 -0
- package/dist/esm/background-update/index.js.map +1 -0
- package/dist/esm/background-update/notification-manager.d.ts +29 -0
- package/dist/esm/background-update/notification-manager.js +89 -0
- package/dist/esm/background-update/notification-manager.js.map +1 -0
- package/dist/esm/core/analytics.d.ts +70 -0
- package/dist/esm/core/analytics.js +137 -0
- package/dist/esm/core/analytics.js.map +1 -0
- package/dist/esm/core/cache-manager.d.ts +72 -0
- package/dist/esm/core/cache-manager.js +275 -0
- package/dist/esm/core/cache-manager.js.map +1 -0
- package/dist/esm/core/config.d.ts +48 -0
- package/dist/esm/core/config.js +83 -0
- package/dist/esm/core/config.js.map +1 -0
- package/dist/esm/core/errors.d.ts +51 -0
- package/dist/esm/core/errors.js +80 -0
- package/dist/esm/core/errors.js.map +1 -0
- package/dist/esm/core/logger.d.ts +21 -0
- package/dist/esm/core/logger.js +109 -0
- package/dist/esm/core/logger.js.map +1 -0
- package/dist/esm/core/performance.d.ts +53 -0
- package/dist/esm/core/performance.js +140 -0
- package/dist/esm/core/performance.js.map +1 -0
- package/dist/esm/core/plugin-manager.d.ts +66 -0
- package/dist/esm/core/plugin-manager.js +148 -0
- package/dist/esm/core/plugin-manager.js.map +1 -0
- package/dist/esm/core/security.d.ts +93 -0
- package/dist/esm/core/security.js +315 -0
- package/dist/esm/core/security.js.map +1 -0
- package/dist/esm/definitions.d.ts +639 -0
- package/dist/esm/definitions.js +103 -0
- package/dist/esm/definitions.js.map +1 -0
- package/dist/esm/index.d.ts +12 -0
- package/dist/esm/index.js +16 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/live-update/bundle-manager.d.ts +94 -0
- package/dist/esm/live-update/bundle-manager.js +310 -0
- package/dist/esm/live-update/bundle-manager.js.map +1 -0
- package/dist/esm/live-update/certificate-pinning.d.ts +38 -0
- package/dist/esm/live-update/certificate-pinning.js +78 -0
- package/dist/esm/live-update/certificate-pinning.js.map +1 -0
- package/dist/esm/live-update/download-manager.d.ts +67 -0
- package/dist/esm/live-update/download-manager.js +319 -0
- package/dist/esm/live-update/download-manager.js.map +1 -0
- package/dist/esm/live-update/update-manager.d.ts +52 -0
- package/dist/esm/live-update/update-manager.js +294 -0
- package/dist/esm/live-update/update-manager.js.map +1 -0
- package/dist/esm/live-update/version-manager.d.ts +84 -0
- package/dist/esm/live-update/version-manager.js +335 -0
- package/dist/esm/live-update/version-manager.js.map +1 -0
- package/dist/esm/plugin.d.ts +6 -0
- package/dist/esm/plugin.js +283 -0
- package/dist/esm/plugin.js.map +1 -0
- package/dist/esm/security/crypto.d.ts +25 -0
- package/dist/esm/security/crypto.js +70 -0
- package/dist/esm/security/crypto.js.map +1 -0
- package/dist/esm/security/validator.d.ts +60 -0
- package/dist/esm/security/validator.js +143 -0
- package/dist/esm/security/validator.js.map +1 -0
- package/dist/esm/web.d.ts +74 -0
- package/dist/esm/web.js +595 -0
- package/dist/esm/web.js.map +1 -0
- package/dist/plugin.cjs.js +2 -0
- package/dist/plugin.cjs.js.map +1 -0
- package/dist/plugin.esm.js +2 -0
- package/dist/plugin.esm.js.map +1 -0
- package/dist/plugin.js +3 -0
- package/dist/plugin.js.map +1 -0
- package/docs/APP_REVIEW_GUIDE.md +768 -0
- package/docs/BUNDLE_SIGNING.md +264 -0
- package/docs/LIVE_UPDATES_GUIDE.md +650 -0
- package/docs/MIGRATION.md +192 -0
- package/docs/NATIVE_UPDATES_GUIDE.md +694 -0
- package/docs/QUICK_START.md +606 -0
- package/docs/README.md +111 -0
- package/docs/REMAINING_FEATURES.md +139 -0
- package/docs/api/app-review-api.md +259 -0
- package/docs/api/app-update-api.md +238 -0
- package/docs/api/events-api.md +451 -0
- package/docs/api/live-update-api.md +265 -0
- package/docs/background-updates.md +392 -0
- package/docs/examples/advanced-scenarios.md +410 -0
- package/docs/examples/basic-usage.md +185 -0
- package/docs/features/app-reviews.md +975 -0
- package/docs/features/app-updates.md +785 -0
- package/docs/features/live-updates.md +633 -0
- package/docs/getting-started/configuration.md +468 -0
- package/docs/getting-started/installation.md +209 -0
- package/docs/getting-started/quick-start.md +379 -0
- package/docs/guides/deployment-guide.md +333 -0
- package/docs/guides/migration-from-codepush.md +142 -0
- package/docs/guides/security-best-practices.md +1057 -0
- package/docs/guides/testing-guide.md +373 -0
- package/docs/production-readiness.md +478 -0
- package/docs/security/certificate-pinning.md +122 -0
- package/docs/server-requirements.md +147 -0
- package/ios/Plugin/AppReview/AppReviewPlugin.swift +158 -0
- package/ios/Plugin/AppUpdate/AppUpdatePlugin.swift +234 -0
- package/ios/Plugin/BackgroundUpdate/BackgroundNotificationManager.swift +329 -0
- package/ios/Plugin/BackgroundUpdate/BackgroundUpdatePlugin.swift +396 -0
- package/ios/Plugin/CapacitorNativeUpdatePlugin.m +45 -0
- package/ios/Plugin/CapacitorNativeUpdatePlugin.swift +190 -0
- package/ios/Plugin/Info.plist +43 -0
- package/ios/Plugin/LiveUpdate/LiveUpdatePlugin.swift +689 -0
- package/ios/Plugin/LiveUpdate/WebViewConfiguration.swift +45 -0
- package/ios/Plugin/Security/SecurityManager.swift +289 -0
- package/package.json +90 -0
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
# Bundle Signing Process
|
|
2
|
+
|
|
3
|
+
This guide explains how to implement cryptographic signing for update bundles to ensure integrity and authenticity.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
Bundle signing uses RSA-2048 with SHA-256 to create digital signatures that verify:
|
|
8
|
+
|
|
9
|
+
- **Integrity**: The bundle hasn't been modified
|
|
10
|
+
- **Authenticity**: The bundle comes from a trusted source
|
|
11
|
+
- **Non-repudiation**: The signature proves origin
|
|
12
|
+
|
|
13
|
+
## Key Generation
|
|
14
|
+
|
|
15
|
+
### 1. Generate RSA Key Pair
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
cd server-example
|
|
19
|
+
node bundle-signer.js generate-keys
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
This creates:
|
|
23
|
+
|
|
24
|
+
- `private.key` - Keep secure on your server
|
|
25
|
+
- `public.key` - Include in your app
|
|
26
|
+
- `public.key.b64` - Base64 version for app config
|
|
27
|
+
|
|
28
|
+
### 2. Secure Private Key
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
# Set restrictive permissions
|
|
32
|
+
chmod 600 private.key
|
|
33
|
+
|
|
34
|
+
# Store in secure location
|
|
35
|
+
mkdir -p /secure/keys
|
|
36
|
+
mv private.key /secure/keys/
|
|
37
|
+
|
|
38
|
+
# Set environment variable
|
|
39
|
+
export SIGNING_PRIVATE_KEY_PATH=/secure/keys/private.key
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Server-Side Signing
|
|
43
|
+
|
|
44
|
+
### 1. Automatic Signing
|
|
45
|
+
|
|
46
|
+
The update server automatically signs bundles on upload if `SIGNING_PRIVATE_KEY_PATH` is set:
|
|
47
|
+
|
|
48
|
+
```javascript
|
|
49
|
+
// server.js automatically signs on upload
|
|
50
|
+
const signature = signBundle(fileBuffer, privateKey);
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### 2. Manual Signing
|
|
54
|
+
|
|
55
|
+
Sign bundles manually:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
node bundle-signer.js sign bundle-1.0.0.zip /secure/keys/private.key
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
This creates `bundle-1.0.0.zip.sig` containing the base64 signature.
|
|
62
|
+
|
|
63
|
+
### 3. Signature Format
|
|
64
|
+
|
|
65
|
+
Signatures are:
|
|
66
|
+
|
|
67
|
+
- RSA-SHA256 algorithm
|
|
68
|
+
- Base64 encoded
|
|
69
|
+
- Stored as string in bundle metadata
|
|
70
|
+
|
|
71
|
+
## Client-Side Verification
|
|
72
|
+
|
|
73
|
+
### 1. Configure Public Key
|
|
74
|
+
|
|
75
|
+
#### Android
|
|
76
|
+
|
|
77
|
+
```kotlin
|
|
78
|
+
// capacitor.config.json
|
|
79
|
+
{
|
|
80
|
+
"plugins": {
|
|
81
|
+
"CapacitorNativeUpdate": {
|
|
82
|
+
"publicKey": "base64-encoded-public-key",
|
|
83
|
+
"enforceSignature": true
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
#### iOS
|
|
90
|
+
|
|
91
|
+
```swift
|
|
92
|
+
// Info.plist
|
|
93
|
+
<key>CapacitorNativeUpdatePublicKey</key>
|
|
94
|
+
<string>base64-encoded-public-key</string>
|
|
95
|
+
<key>CapacitorNativeUpdateEnforceSignature</key>
|
|
96
|
+
<true/>
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### 2. Verification Process
|
|
100
|
+
|
|
101
|
+
The plugin automatically verifies signatures:
|
|
102
|
+
|
|
103
|
+
```typescript
|
|
104
|
+
// Internal verification flow
|
|
105
|
+
async function verifyBundle(
|
|
106
|
+
bundle: ArrayBuffer,
|
|
107
|
+
signature: string
|
|
108
|
+
): Promise<boolean> {
|
|
109
|
+
const publicKey = await getPublicKey();
|
|
110
|
+
return crypto.subtle.verify(
|
|
111
|
+
'RSASSA-PKCS1-v1_5',
|
|
112
|
+
publicKey,
|
|
113
|
+
base64ToArrayBuffer(signature),
|
|
114
|
+
bundle
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### 3. Enforcement Modes
|
|
120
|
+
|
|
121
|
+
- **Strict Mode** (`enforceSignature: true`): Rejects unsigned/invalid bundles
|
|
122
|
+
- **Permissive Mode** (`enforceSignature: false`): Logs warnings but allows installation
|
|
123
|
+
|
|
124
|
+
## Security Best Practices
|
|
125
|
+
|
|
126
|
+
### 1. Key Management
|
|
127
|
+
|
|
128
|
+
**DO:**
|
|
129
|
+
|
|
130
|
+
- Generate keys on secure, offline machine
|
|
131
|
+
- Use hardware security modules (HSM) for production
|
|
132
|
+
- Rotate keys periodically (yearly recommended)
|
|
133
|
+
- Keep multiple key versions for rollback
|
|
134
|
+
|
|
135
|
+
**DON'T:**
|
|
136
|
+
|
|
137
|
+
- Store private keys in version control
|
|
138
|
+
- Share private keys across environments
|
|
139
|
+
- Use weak key sizes (< 2048 bits)
|
|
140
|
+
|
|
141
|
+
### 2. Signing Infrastructure
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
# Production setup example
|
|
145
|
+
├── signing-server/
|
|
146
|
+
│ ├── keys/
|
|
147
|
+
│ │ ├── private-v1.key # Current key
|
|
148
|
+
│ │ ├── private-v2.key # Next key (pre-generated)
|
|
149
|
+
│ │ └── archive/ # Old keys for verification
|
|
150
|
+
│ ├── sign-bundle.sh # Signing script
|
|
151
|
+
│ └── verify-bundle.sh # Verification script
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### 3. CI/CD Integration
|
|
155
|
+
|
|
156
|
+
#### GitHub Actions Example
|
|
157
|
+
|
|
158
|
+
```yaml
|
|
159
|
+
- name: Sign Bundle
|
|
160
|
+
env:
|
|
161
|
+
PRIVATE_KEY: ${{ secrets.BUNDLE_SIGNING_KEY }}
|
|
162
|
+
run: |
|
|
163
|
+
echo "$PRIVATE_KEY" > private.key
|
|
164
|
+
node bundle-signer.js sign dist/bundle.zip
|
|
165
|
+
rm private.key
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
#### Jenkins Example
|
|
169
|
+
|
|
170
|
+
```groovy
|
|
171
|
+
withCredentials([file(credentialsId: 'bundle-signing-key', variable: 'KEY_FILE')]) {
|
|
172
|
+
sh 'node bundle-signer.js sign dist/bundle.zip $KEY_FILE'
|
|
173
|
+
}
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
## Troubleshooting
|
|
177
|
+
|
|
178
|
+
### Common Issues
|
|
179
|
+
|
|
180
|
+
1. **"Invalid signature" error**
|
|
181
|
+
- Verify public key matches private key
|
|
182
|
+
- Check base64 encoding/decoding
|
|
183
|
+
- Ensure bundle wasn't modified after signing
|
|
184
|
+
|
|
185
|
+
2. **"Missing signature" error**
|
|
186
|
+
- Confirm server includes signature in response
|
|
187
|
+
- Check `enforceSignature` setting
|
|
188
|
+
- Verify signing process completed
|
|
189
|
+
|
|
190
|
+
3. **Performance issues**
|
|
191
|
+
- Use SHA-256 for checksum verification first
|
|
192
|
+
- Only verify signature on checksum match
|
|
193
|
+
- Cache verification results
|
|
194
|
+
|
|
195
|
+
### Verification Tools
|
|
196
|
+
|
|
197
|
+
Test signature verification:
|
|
198
|
+
|
|
199
|
+
```bash
|
|
200
|
+
# Verify manually
|
|
201
|
+
node bundle-signer.js verify bundle.zip bundle.zip.sig public.key
|
|
202
|
+
|
|
203
|
+
# Check signature format
|
|
204
|
+
cat bundle.zip.sig | base64 -d | xxd | head
|
|
205
|
+
|
|
206
|
+
# Compare checksums
|
|
207
|
+
shasum -a 256 bundle.zip
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
## Migration Guide
|
|
211
|
+
|
|
212
|
+
### From Unsigned Bundles
|
|
213
|
+
|
|
214
|
+
1. Generate keys and configure server
|
|
215
|
+
2. Deploy app update with public key
|
|
216
|
+
3. Enable permissive mode initially
|
|
217
|
+
4. Monitor adoption via analytics
|
|
218
|
+
5. Switch to strict mode after 90%+ adoption
|
|
219
|
+
|
|
220
|
+
### Key Rotation
|
|
221
|
+
|
|
222
|
+
1. Generate new key pair
|
|
223
|
+
2. Update server to sign with new key
|
|
224
|
+
3. Deploy app update with both keys
|
|
225
|
+
4. Monitor old key usage
|
|
226
|
+
5. Remove old key after full migration
|
|
227
|
+
|
|
228
|
+
## API Reference
|
|
229
|
+
|
|
230
|
+
### Server Endpoints
|
|
231
|
+
|
|
232
|
+
```http
|
|
233
|
+
GET /api/v1/check?version=1.0.0&channel=production
|
|
234
|
+
Response: {
|
|
235
|
+
"signature": "base64-signature",
|
|
236
|
+
"checksum": "sha256:hex-checksum"
|
|
237
|
+
}
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
### Plugin Methods
|
|
241
|
+
|
|
242
|
+
```typescript
|
|
243
|
+
// Manual verification (advanced use)
|
|
244
|
+
const isValid = await CapacitorNativeUpdate.verifySignature({
|
|
245
|
+
bundlePath: '/path/to/bundle.zip',
|
|
246
|
+
signature: 'base64-signature',
|
|
247
|
+
publicKey: 'base64-public-key', // Optional, uses config if not provided
|
|
248
|
+
});
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
## Compliance
|
|
252
|
+
|
|
253
|
+
Bundle signing helps meet security requirements for:
|
|
254
|
+
|
|
255
|
+
- **PCI DSS**: Integrity monitoring
|
|
256
|
+
- **HIPAA**: Data authenticity
|
|
257
|
+
- **SOC 2**: Change management
|
|
258
|
+
- **ISO 27001**: Cryptographic controls
|
|
259
|
+
|
|
260
|
+
## Additional Resources
|
|
261
|
+
|
|
262
|
+
- [NIST Guidelines on Digital Signatures](https://csrc.nist.gov/publications/detail/fips/186/5/final)
|
|
263
|
+
- [OWASP Mobile Security Testing Guide](https://owasp.org/www-project-mobile-security-testing-guide/)
|
|
264
|
+
- [RSA Cryptography Specifications](https://www.rfc-editor.org/rfc/rfc8017)
|