native-update-capacitor 0.0.0-stage → 4.4.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.
Files changed (140) hide show
  1. package/AI-INTEGRATION-GUIDE.md +578 -0
  2. package/LICENSE +25 -0
  3. package/NativeUpdate.podspec +19 -0
  4. package/README.md +574 -2
  5. package/android/build.gradle +125 -0
  6. package/android/consumer-rules.pro +9 -0
  7. package/android/gradle/wrapper/gradle-wrapper.properties +8 -0
  8. package/android/gradle.properties +17 -0
  9. package/android/manifest-additions.xml +28 -0
  10. package/android/proguard-rules.pro +26 -0
  11. package/android/settings.gradle +2 -0
  12. package/android/src/main/AndroidManifest.xml +13 -0
  13. package/android/src/main/java/com/aoneahsan/nativeupdate/AppReviewPlugin.kt +159 -0
  14. package/android/src/main/java/com/aoneahsan/nativeupdate/AppUpdatePlugin.kt +314 -0
  15. package/android/src/main/java/com/aoneahsan/nativeupdate/BackgroundNotificationManager.kt +406 -0
  16. package/android/src/main/java/com/aoneahsan/nativeupdate/BackgroundUpdateManager.kt +48 -0
  17. package/android/src/main/java/com/aoneahsan/nativeupdate/BackgroundUpdatePlugin.kt +343 -0
  18. package/android/src/main/java/com/aoneahsan/nativeupdate/BackgroundUpdateWorker.kt +236 -0
  19. package/android/src/main/java/com/aoneahsan/nativeupdate/JsonOptional.kt +26 -0
  20. package/android/src/main/java/com/aoneahsan/nativeupdate/LiveUpdatePlugin.kt +1249 -0
  21. package/android/src/main/java/com/aoneahsan/nativeupdate/NativeUpdatePlugin.kt +404 -0
  22. package/android/src/main/java/com/aoneahsan/nativeupdate/NotificationActionReceiver.kt +107 -0
  23. package/android/src/main/java/com/aoneahsan/nativeupdate/SecurityManager.kt +240 -0
  24. package/android/variables.gradle +5 -0
  25. package/cli/commands/backend-create.js +623 -0
  26. package/cli/commands/bundle-create.js +145 -0
  27. package/cli/commands/bundle-sign.js +64 -0
  28. package/cli/commands/bundle-verify.js +58 -0
  29. package/cli/commands/flutter-patch.js +107 -0
  30. package/cli/commands/init.js +146 -0
  31. package/cli/commands/keys-generate.js +58 -0
  32. package/cli/commands/monitor.js +89 -0
  33. package/cli/commands/remote-shared.js +264 -0
  34. package/cli/commands/remote.js +634 -0
  35. package/cli/commands/server-start.js +96 -0
  36. package/cli/index.js +625 -0
  37. package/cli/package.json +21 -0
  38. package/dist/esm/app-review/app-review-manager.d.ts +24 -0
  39. package/dist/esm/app-review/app-review-manager.js +194 -0
  40. package/dist/esm/app-review/index.d.ts +5 -0
  41. package/dist/esm/app-review/index.js +5 -0
  42. package/dist/esm/app-review/platform-review-handler.d.ts +20 -0
  43. package/dist/esm/app-review/platform-review-handler.js +137 -0
  44. package/dist/esm/app-review/review-conditions-checker.d.ts +22 -0
  45. package/dist/esm/app-review/review-conditions-checker.js +154 -0
  46. package/dist/esm/app-review/review-rate-limiter.d.ts +23 -0
  47. package/dist/esm/app-review/review-rate-limiter.js +163 -0
  48. package/dist/esm/app-review/types.d.ts +41 -0
  49. package/dist/esm/app-review/types.js +1 -0
  50. package/dist/esm/app-update/app-update-checker.d.ts +58 -0
  51. package/dist/esm/app-update/app-update-checker.js +227 -0
  52. package/dist/esm/app-update/app-update-installer.d.ts +20 -0
  53. package/dist/esm/app-update/app-update-installer.js +134 -0
  54. package/dist/esm/app-update/app-update-manager.d.ts +28 -0
  55. package/dist/esm/app-update/app-update-manager.js +198 -0
  56. package/dist/esm/app-update/app-update-notifier.d.ts +14 -0
  57. package/dist/esm/app-update/app-update-notifier.js +99 -0
  58. package/dist/esm/app-update/index.d.ts +6 -0
  59. package/dist/esm/app-update/index.js +6 -0
  60. package/dist/esm/app-update/platform-app-update.d.ts +19 -0
  61. package/dist/esm/app-update/platform-app-update.js +138 -0
  62. package/dist/esm/app-update/types.d.ts +58 -0
  63. package/dist/esm/app-update/types.js +11 -0
  64. package/dist/esm/background-update/background-scheduler.d.ts +63 -0
  65. package/dist/esm/background-update/background-scheduler.js +332 -0
  66. package/dist/esm/background-update/index.d.ts +3 -0
  67. package/dist/esm/background-update/index.js +2 -0
  68. package/dist/esm/background-update/notification-manager.d.ts +29 -0
  69. package/dist/esm/background-update/notification-manager.js +88 -0
  70. package/dist/esm/config/support.d.ts +9 -0
  71. package/dist/esm/config/support.js +9 -0
  72. package/dist/esm/core/analytics.d.ts +83 -0
  73. package/dist/esm/core/analytics.js +151 -0
  74. package/dist/esm/core/cache-manager.d.ts +72 -0
  75. package/dist/esm/core/cache-manager.js +274 -0
  76. package/dist/esm/core/config.d.ts +69 -0
  77. package/dist/esm/core/config.js +107 -0
  78. package/dist/esm/core/errors.d.ts +56 -0
  79. package/dist/esm/core/errors.js +85 -0
  80. package/dist/esm/core/event-emitter.d.ts +30 -0
  81. package/dist/esm/core/event-emitter.js +80 -0
  82. package/dist/esm/core/logger.d.ts +21 -0
  83. package/dist/esm/core/logger.js +108 -0
  84. package/dist/esm/core/performance.d.ts +53 -0
  85. package/dist/esm/core/performance.js +153 -0
  86. package/dist/esm/core/plugin-manager.d.ts +88 -0
  87. package/dist/esm/core/plugin-manager.js +224 -0
  88. package/dist/esm/core/security.d.ts +123 -0
  89. package/dist/esm/core/security.js +361 -0
  90. package/dist/esm/core/update-check.d.ts +121 -0
  91. package/dist/esm/core/update-check.js +127 -0
  92. package/dist/esm/definitions.d.ts +872 -0
  93. package/dist/esm/definitions.js +104 -0
  94. package/dist/esm/index.d.ts +14 -0
  95. package/dist/esm/index.js +18 -0
  96. package/dist/esm/live-update/bundle-manager.d.ts +102 -0
  97. package/dist/esm/live-update/bundle-manager.js +344 -0
  98. package/dist/esm/live-update/certificate-pinning.d.ts +38 -0
  99. package/dist/esm/live-update/certificate-pinning.js +77 -0
  100. package/dist/esm/live-update/delta-processor.d.ts +84 -0
  101. package/dist/esm/live-update/delta-processor.js +257 -0
  102. package/dist/esm/live-update/download-manager.d.ts +106 -0
  103. package/dist/esm/live-update/download-manager.js +412 -0
  104. package/dist/esm/live-update/rollout-checker.d.ts +86 -0
  105. package/dist/esm/live-update/rollout-checker.js +304 -0
  106. package/dist/esm/live-update/update-manager.d.ts +63 -0
  107. package/dist/esm/live-update/update-manager.js +321 -0
  108. package/dist/esm/live-update/version-manager.d.ts +93 -0
  109. package/dist/esm/live-update/version-manager.js +390 -0
  110. package/dist/esm/plugin.d.ts +3 -0
  111. package/dist/esm/plugin.js +848 -0
  112. package/dist/esm/security/crypto.d.ts +88 -0
  113. package/dist/esm/security/crypto.js +228 -0
  114. package/dist/esm/security/validator.d.ts +60 -0
  115. package/dist/esm/security/validator.js +142 -0
  116. package/dist/esm/types/app-identity.d.ts +36 -0
  117. package/dist/esm/types/app-identity.js +1 -0
  118. package/dist/esm/types/rollout.d.ts +91 -0
  119. package/dist/esm/types/rollout.js +25 -0
  120. package/dist/esm/web.d.ts +130 -0
  121. package/dist/esm/web.js +981 -0
  122. package/dist/plugin.cjs +1 -0
  123. package/dist/plugin.esm.js +1 -0
  124. package/dist/plugin.js +2 -0
  125. package/docs/CHANGELOG.md +1016 -0
  126. package/docs/KNOWN_LIMITATIONS.md +240 -0
  127. package/docs/MIGRATION.md +391 -0
  128. package/docs/protocol/CLIENT-PROTOCOL.md +199 -0
  129. package/docs/server-requirements.md +211 -0
  130. package/ios/Plugin/AppReview/AppReviewPlugin.swift +158 -0
  131. package/ios/Plugin/AppUpdate/AppUpdatePlugin.swift +249 -0
  132. package/ios/Plugin/BackgroundUpdate/BackgroundNotificationManager.swift +333 -0
  133. package/ios/Plugin/BackgroundUpdate/BackgroundUpdatePlugin.swift +464 -0
  134. package/ios/Plugin/Info.plist +43 -0
  135. package/ios/Plugin/LiveUpdate/LiveUpdatePlugin.swift +1286 -0
  136. package/ios/Plugin/LiveUpdate/WebViewConfiguration.swift +45 -0
  137. package/ios/Plugin/NativeUpdatePlugin.m +53 -0
  138. package/ios/Plugin/NativeUpdatePlugin.swift +315 -0
  139. package/ios/Plugin/Security/SecurityManager.swift +289 -0
  140. package/package.json +133 -4
package/README.md CHANGED
@@ -1,3 +1,575 @@
1
- # Temporary Holding Version
1
+ > **`native-update-capacitor` is the same package as [`native-update`](https://www.npmjs.com/package/native-update)**,
2
+ > published under its framework name next to `native-update-react-native` and the Android and Flutter SDKs. Install
3
+ > one of the two, not both. Everything below applies unchanged; read `native-update` as `native-update-capacitor`
4
+ > in install commands and imports.
2
5
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
6
+ <div align="center">
7
+
8
+ <img src="https://nativeupdate-docs.aoneahsan.com/img/logo.svg" alt="Native Update logo" width="120" />
9
+
10
+ <h1>native-update</h1>
11
+
12
+ <p><strong>Over-the-air updates, app-store update flows, and in-app reviews for Capacitor apps.</strong></p>
13
+
14
+ [![npm version](https://img.shields.io/npm/v/native-update.svg)](https://www.npmjs.com/package/native-update)
15
+ [![downloads](https://img.shields.io/npm/dm/native-update.svg)](https://www.npmjs.com/package/native-update)
16
+ [![license](https://img.shields.io/npm/l/native-update.svg)](https://www.npmjs.com/package/native-update)
17
+ [![types](https://img.shields.io/npm/types/native-update.svg)](https://www.npmjs.com/package/native-update)
18
+ [![node](https://img.shields.io/node/v/native-update.svg)](https://nodejs.org)
19
+
20
+ [Docs](https://nativeupdate-docs.aoneahsan.com/) · [npm](https://www.npmjs.com/package/native-update) · [Dashboard](https://nativeupdate.aoneahsan.com) · [Changelog](https://nativeupdate-docs.aoneahsan.com/changelog) · [AI Guide](https://nativeupdate-docs.aoneahsan.com/ai-integration) · [Support](https://nativeupdate.aoneahsan.com/contact)
21
+
22
+ </div>
23
+
24
+ > [!IMPORTANT]
25
+ > Call `NativeUpdate.notifyAppReady()` on **every** successful boot. Activating a bundle marks it
26
+ > pending-verification, and the native layer rolls it back after two cold starts that never confirm. Miss
27
+ > this one call and every update you ship silently reverts.
28
+
29
+ Native Update ships web-layer fixes to a released Capacitor app without waiting for store review, and wraps
30
+ the platform APIs for store updates and review prompts behind one TypeScript surface. It talks to a
31
+ documented HTTP contract, so you can point it at the hosted Native Update service or write your own server. A bundled CLI creates, signs and deploys bundles, and the same operations
32
+ are available as an HTTP API for CI and coding agents.
33
+
34
+ | | |
35
+ |---|---|
36
+ | **Version** | `4.4.0` |
37
+ | **License** | Proprietary — free to use in your apps ([LICENSE](./LICENSE)) |
38
+ | **Node** | `>=24.16.0` (install + CLI toolchain) |
39
+ | **Platforms** | iOS 14+ · Android 8.0+ (API 26) · Web |
40
+ | **Package size** | 281 kB tarball · ~1.14 MB unpacked · 136 files |
41
+ | **Types** | Bundled `.d.ts` · ESM + CommonJS entry points |
42
+ | **Status** | Stable · actively maintained |
43
+
44
+ <a id="table-of-contents"></a>
45
+ ## 🧭 Table of Contents&nbsp;[#](#table-of-contents)
46
+
47
+ - [💡 Why native-update](#why-native-update)
48
+ - [✨ Features](#features)
49
+ - [📱 Platform Support](#platform-support)
50
+ - [📋 Requirements](#requirements)
51
+ - [📦 Installation](#installation)
52
+ - [🚀 Quick Start](#quick-start)
53
+ - [🛠️ Usage](#usage)
54
+ - [⚙️ Configuration](#configuration)
55
+ - [🔧 API Reference](#api-reference)
56
+ - [🧩 Types](#types)
57
+ - [💻 Command Line](#command-line)
58
+ - [🧪 Examples](#examples)
59
+ - [🎛️ Advanced Features](#advanced-features)
60
+ - [🚑 Recovery & Troubleshooting](#recovery-troubleshooting)
61
+ - [🚧 Limitations](#limitations)
62
+ - [❓ FAQ](#faq)
63
+ - [📚 Documentation](#documentation)
64
+ - [🔄 Changelog](#changelog)
65
+ - [🤝 Contributing](#contributing)
66
+ - [💬 Support](#support)
67
+ - [📄 License](#license)
68
+ - [👥 Team](#author)
69
+ - [🔗 Links](#links)
70
+ - [🏷️ Keywords](#keywords)
71
+
72
+ <a id="why-native-update"></a>
73
+ ## 💡 Why native-update&nbsp;[#](#why-native-update)
74
+
75
+ A Capacitor app's JavaScript, HTML and CSS live inside a native binary, so a one-line fix normally waits for
76
+ a store review. Over-the-air updating replaces that web layer at runtime. The three pieces a real deployment
77
+ needs — bundle delivery, a native update prompt when the binary itself must change, and a review request —
78
+ usually mean three separate integrations.
79
+
80
+ | | `native-update` | Typical alternative |
81
+ |---|---|---|
82
+ | Scope | OTA bundles, store-update flows and in-app reviews in one API | one concern per package |
83
+ | Backend | the hosted Native Update service, or your own server against a published HTTP contract | vendor-hosted only |
84
+ | Release automation | bundled CLI plus an HTTP management API for CI and agents | dashboard clicks, or a separate CLI |
85
+ | Bundle integrity | checksum plus optional signature, verified again at boot | varies |
86
+ | Cost model | free plugin; a Free plan, then Pro or Team on the hosted service | usage-priced service |
87
+
88
+ **Not the right tool when** your app is web-only (the OTA layer needs the native runtime), when you cannot
89
+ run or pay for any update server, or when your release process forbids shipping code outside a store review.
90
+ Apple and Google both permit OTA updates of interpreted code within their policies, but staying inside those
91
+ policies is your responsibility — see [Limitations](#limitations).
92
+
93
+ <a id="features"></a>
94
+ ## ✨ Features&nbsp;[#](#features)
95
+
96
+ - **Live (OTA) updates** — download and activate a new web bundle at runtime, with mandatory SHA-256 +
97
+ RSA-SHA256 verification before it is ever loaded.
98
+ - **Verified delta updates** — use a bounded `NUDELTA/1` patch from one of the last three compatible
99
+ builds when worthwhile, with automatic full-bundle fallback on any mismatch.
100
+ - **Automatic rollback** — a bundle that never confirms a healthy boot is reverted by the native layer, so a
101
+ bad release cannot brick installs.
102
+ - **Channels** — route development, staging and production installs to different bundles from one backend.
103
+ - **Staged rollouts** — release to a percentage of devices, then pause, resume or halt.
104
+ - **Native app updates** — detect a newer store build and run Google Play's immediate or flexible update
105
+ flow, or send the user to the App Store.
106
+ - **In-app reviews** — request the native review dialog without leaving the app, respecting platform limits.
107
+ - **Background updates** — schedule checks and notify the user when a bundle is ready.
108
+ - **Hosted service or your own server** — the hosted dashboard and API, or any server that implements the
109
+ documented HTTP contract.
110
+ - **Release tooling** — a CLI for creating, signing, verifying and deploying bundles, plus an HTTP
111
+ management API covering the same lifecycle for CI and coding agents.
112
+ - **TypeScript throughout** — declarations for every method, option, event and error code.
113
+
114
+ <a id="platform-support"></a>
115
+ ## 📱 Platform Support&nbsp;[#](#platform-support)
116
+
117
+ | Platform | Live updates | App updates | App reviews | Notes |
118
+ |---|---|---|---|---|
119
+ | Android | ✅ | ✅ | ✅ | Google Play Core immediate and flexible flows |
120
+ | iOS | ✅ | ✅ | ✅ | App Store version check; native review dialog |
121
+ | Web | ✅ | ⚠️ | ⚠️ | Bundle handling works; store-update and review calls resolve as no-ops so shared code need not branch |
122
+
123
+ Certificate pinning and accurate storage measurement are native-only — the web build reports both as
124
+ unavailable rather than pretending. See [Limitations](#limitations).
125
+
126
+ <a id="requirements"></a>
127
+ ## 📋 Requirements&nbsp;[#](#requirements)
128
+
129
+ | Requirement | Version | Why |
130
+ |---|---|---|
131
+ | Node | `>=24.16.0` | declared in `engines`; installers that enforce `engines` refuse an older runtime. Needed to install and to run the CLI — not by your app at runtime |
132
+ | `@capacitor/core` | `^8.0.1` | peer — the host app owns the Capacitor version |
133
+ | `@capacitor/filesystem` | `>=8.0.0` | peer — stores and extracts downloaded bundles |
134
+ | `@capacitor/preferences` | `>=8.0.0` | peer — records which bundle is active and whether it was confirmed |
135
+ | iOS | 14.0+ | minimum deployment target of the native plugin |
136
+ | Android | 8.0+ (API 26) | Capacitor 8.5 minimum; compile/target SDK 36 and Java 21 |
137
+ | An update server | — | the hosted Native Update service, or your own implementation of the HTTP contract |
138
+
139
+ <a id="installation"></a>
140
+ ## 📦 Installation&nbsp;[#](#installation)
141
+
142
+ ```bash
143
+ yarn add native-update @capacitor/filesystem @capacitor/preferences
144
+ npx cap sync
145
+ ```
146
+
147
+ `npx cap sync` is required. It copies the iOS and Android sources into your native projects; without it the
148
+ plugin loads on web and does nothing on device.
149
+
150
+ Then register an app in the [dashboard](https://nativeupdate.aoneahsan.com) to get an API key (`nu_app_…`),
151
+ or stand up your own server against the
152
+ [HTTP contract](https://nativeupdate-docs.aoneahsan.com/backend/api-contract). Keep the key in an environment
153
+ variable, and gate initialisation on it being non-empty so a missing key switches updates off instead of
154
+ crashing your app.
155
+
156
+ <a id="quick-start"></a>
157
+ ## 🚀 Quick Start&nbsp;[#](#quick-start)
158
+
159
+ ```ts
160
+ import { NativeUpdate } from 'native-update';
161
+ import { Filesystem } from '@capacitor/filesystem';
162
+ import { Preferences } from '@capacitor/preferences';
163
+
164
+ await NativeUpdate.initialize({
165
+ filesystem: Filesystem,
166
+ preferences: Preferences,
167
+ appId: 'com.example.app',
168
+ serverUrl: 'https://nativeupdatebe.aoneahsan.com/api',
169
+ apiKey: import.meta.env.VITE_NATIVE_UPDATE_API_KEY,
170
+ publicKey: import.meta.env.VITE_NATIVE_UPDATE_PUBLIC_KEY,
171
+ requireSignature: true,
172
+ channel: 'production',
173
+ });
174
+
175
+ // Confirms this boot is healthy. Without it the native layer reverts the
176
+ // bundle after two cold starts.
177
+ await NativeUpdate.notifyAppReady();
178
+
179
+ const result = await NativeUpdate.sync();
180
+ if (result.status === 'UPDATE_INSTALLED') {
181
+ await NativeUpdate.reload();
182
+ }
183
+ ```
184
+
185
+ <a id="usage"></a>
186
+ ## 🛠️ Usage&nbsp;[#](#usage)
187
+
188
+ ### Prompt before applying an update
189
+
190
+ `sync()` reports what it found; you decide whether to interrupt the user.
191
+
192
+ ```ts
193
+ const result = await NativeUpdate.sync();
194
+
195
+ if (result.status === 'UPDATE_INSTALLED') {
196
+ const proceed = result.mandatory || (await askTheUser(result.version));
197
+ if (proceed) {
198
+ await NativeUpdate.reload();
199
+ }
200
+ }
201
+ ```
202
+
203
+ ### Download manually, with progress
204
+
205
+ ```ts
206
+ const latest = await NativeUpdate.getLatest();
207
+
208
+ if (latest.available && latest.url && latest.version && latest.checksum) {
209
+ const listener = await NativeUpdate.addListener('downloadProgress', (progress) => {
210
+ setProgress(progress.percent);
211
+ });
212
+
213
+ const bundle = await NativeUpdate.download({
214
+ url: latest.url,
215
+ version: latest.version,
216
+ checksum: latest.checksum,
217
+ });
218
+
219
+ await listener.remove();
220
+ await NativeUpdate.set(bundle);
221
+ await NativeUpdate.reload();
222
+ }
223
+ ```
224
+
225
+ ### Handle a store update
226
+
227
+ ```ts
228
+ const info = await NativeUpdate.getAppUpdateInfo();
229
+
230
+ if (info.updateAvailable) {
231
+ if (info.immediateUpdateAllowed) {
232
+ await NativeUpdate.performImmediateUpdate();
233
+ } else if (info.flexibleUpdateAllowed) {
234
+ await NativeUpdate.startFlexibleUpdate();
235
+ } else {
236
+ await NativeUpdate.openAppStore();
237
+ }
238
+ }
239
+ ```
240
+
241
+ ### Request a review
242
+
243
+ ```ts
244
+ const { allowed } = await NativeUpdate.canRequestReview();
245
+
246
+ if (allowed) {
247
+ await NativeUpdate.requestReview();
248
+ }
249
+ ```
250
+
251
+ Ask after something went well for the user, never on launch. The platforms cap how often the dialog appears
252
+ and silently ignore extra requests.
253
+
254
+ ### When delivery is paused
255
+
256
+ ```ts
257
+ const result = await NativeUpdate.checkForUpdate();
258
+
259
+ if (result.held) {
260
+ // A newer release exists, but the hosted service is not serving it while the developer
261
+ // account is over its plan limits. Nothing is downloaded.
262
+ showBanner(result.heldMessage);
263
+ }
264
+ ```
265
+
266
+ `held` arrives only from the hosted service (from 4.2.0). Your users keep the bundle they have.
267
+
268
+ <a id="configuration"></a>
269
+ ## ⚙️ Configuration&nbsp;[#](#configuration)
270
+
271
+ Passed to `initialize()`. The complete set is in the
272
+ [configuration reference](https://nativeupdate-docs.aoneahsan.com/reference/sdk/core/config).
273
+
274
+ | Option | Type | Default | What it does |
275
+ |---|---|---|---|
276
+ | `filesystem` | `Filesystem` | — | the `@capacitor/filesystem` instance used to store bundles |
277
+ | `preferences` | `Preferences` | — | the `@capacitor/preferences` instance used to record bundle state |
278
+ | `appId` | `string` | — | identifies your app to the update server |
279
+ | `serverUrl` | `string` | — | base URL of the backend; the plugin appends `/v1/updates/check` |
280
+ | `apiKey` | `string` | — | sent as `X-API-Key`. Not persisted — pass it on every `initialize()` |
281
+ | `channel` | `string` | `'production'` | which release channel this install follows |
282
+ | `autoCheck` | `boolean` | `false` | check for updates without an explicit `sync()` |
283
+ | `autoUpdate` | `boolean` | `false` | apply what it finds without asking |
284
+ | `publicKey` | `string` | — | PEM RSA public key used to verify RSA-SHA256 signatures |
285
+ | `enableSignatureValidation` | `boolean` | `true` | reject a bundle whose signature does not verify |
286
+ | `requireSignature` | `boolean` | `true` | reject a bundle that carries no signature at all |
287
+ | `allowUnsignedDevelopmentUpdates` | `boolean` | `false` | explicit debug-only escape hatch; native release builds ignore it |
288
+ | `enableDeltaUpdates` | `boolean` | `true` | use verified NUDELTA/1 patches when the server offers one |
289
+ | `maxBundleSize` | `number` | `104857600` | refuse a download larger than this, in bytes |
290
+ | `maxUncompressedBundleSize` | `number` | `524288000` | native ZIP extraction cap for zip-bomb defense |
291
+ | `downloadTimeout` | `number` | `30000` | per-download timeout in milliseconds |
292
+ | `retryAttempts` | `number` | `3` | download retries before giving up |
293
+ | `retryDelay` | `number` | `1000` | milliseconds between retries |
294
+ | `checkInterval` | `number` | — | milliseconds between automatic checks when `autoCheck` is on |
295
+ | `allowedHosts` | `string[]` | — | restrict downloads to these hosts |
296
+ | `enableLogging` | `boolean` | `false` | verbose plugin logging |
297
+
298
+ <a id="api-reference"></a>
299
+ ## 🔧 API Reference&nbsp;[#](#api-reference)
300
+
301
+ An index. Signatures and behaviour are documented per method on the docs site.
302
+
303
+ | Area | Methods | Docs |
304
+ |---|---|---|
305
+ | Lifecycle | `initialize` · `isInitialized` · `configure` · `reset` · `cleanup` | [→](https://nativeupdate-docs.aoneahsan.com/reference/sdk/core/lifecycle) |
306
+ | Live update | `sync` · `getLatest` · `download` · `set` · `reload` · `current` · `list` · `delete` · `notifyAppReady` · `setChannel` · `validateUpdate` | [→](https://nativeupdate-docs.aoneahsan.com/reference/sdk/live-update/methods) |
307
+ | Download control | `checkForUpdate` · `downloadUpdate` · `applyUpdate` · `cancelDownload` · `cancelAllDownloads` · `isDownloading` · `getActiveDownloadCount` | [→](https://nativeupdate-docs.aoneahsan.com/reference/sdk/live-update/methods) |
308
+ | App update | `getAppUpdateInfo` · `performImmediateUpdate` · `startFlexibleUpdate` · `completeFlexibleUpdate` · `openAppStore` | [→](https://nativeupdate-docs.aoneahsan.com/reference/sdk/app-update/methods) |
309
+ | App review | `requestReview` · `canRequestReview` | [→](https://nativeupdate-docs.aoneahsan.com/reference/sdk/app-review/methods) |
310
+ | Background | `enableBackgroundUpdates` · `disableBackgroundUpdates` · `getBackgroundUpdateStatus` · `scheduleBackgroundCheck` · `triggerBackgroundCheck` · `setNotificationPreferences` · `getNotificationPermissions` · `requestNotificationPermissions` | [→](https://nativeupdate-docs.aoneahsan.com/reference/sdk/background-update/methods) |
311
+ | Security | `getSecurityInfo` · `getAppIdentity` | [→](https://nativeupdate-docs.aoneahsan.com/reference/sdk/security/overview) |
312
+ | Events | `addListener` · `removeAllListeners` | [→](https://nativeupdate-docs.aoneahsan.com/reference/sdk/live-update/events) |
313
+
314
+ `setUpdateUrl()` is deprecated and does nothing. Configuration is fixed at initialization so a compromised
315
+ WebView cannot repoint updates at another host; call `reset()` and then initialize again to switch servers.
316
+
317
+ <a id="types"></a>
318
+ ## 🧩 Types&nbsp;[#](#types)
319
+
320
+ ```ts
321
+ import type {
322
+ PluginInitConfig,
323
+ SyncResult,
324
+ BundleInfo,
325
+ LatestVersion,
326
+ DownloadOptions,
327
+ DownloadProgressEvent,
328
+ AppUpdateInfo,
329
+ ReviewResult,
330
+ CanRequestReviewResult,
331
+ } from 'native-update';
332
+
333
+ import { SyncStatus, BundleStatus, UpdateErrorCode } from 'native-update';
334
+
335
+ const result: SyncResult = {
336
+ status: SyncStatus.UPDATE_INSTALLED, // UP_TO_DATE | UPDATE_AVAILABLE | UPDATE_INSTALLED | ERROR
337
+ version: '1.2.0',
338
+ mandatory: false,
339
+ };
340
+ ```
341
+
342
+ Enums are real runtime values rather than type-only aliases, so they survive the build and can be compared at
343
+ runtime. The full type surface is exported from the package root.
344
+
345
+ <a id="command-line"></a>
346
+ ## 💻 Command Line&nbsp;[#](#command-line)
347
+
348
+ ```bash
349
+ npx native-update <command> [options]
350
+ ```
351
+
352
+ | Command | What it does |
353
+ |---|---|
354
+ | `init` | scaffold plugin configuration into an existing project |
355
+ | `bundle create <webDir>` | zip a build directory into a bundle and compute its checksum |
356
+ | `bundle sign <bundle>` | sign a bundle with a private key |
357
+ | `bundle verify <bundle>` | verify a bundle's signature against a public key |
358
+ | `keys generate` | generate a supported RSA signing key pair |
359
+ | `backend create <type>` | scaffold an `express`, `firebase` or `vercel` backend |
360
+ | `server start` | run a local update server for testing |
361
+ | `monitor` | watch deployments against a backend |
362
+ | `deploy <dirOrZip>` | upload a bundle to the hosted backend and publish it |
363
+ | `token info` | show what an access token is and which apps it can manage |
364
+ | `apps …` | create, show, update and delete apps; manage API keys, signing keys and keystore backups |
365
+ | `builds …` | list, promote, roll out, inspect and delete builds |
366
+ | `jobs status <jobId>` | poll a queued upload job |
367
+
368
+ ```bash
369
+ npx native-update keys generate --type rsa --size 4096
370
+ npx native-update bundle create ./dist --version 1.2.0 --channel production
371
+ ```
372
+
373
+ Deploying to the hosted backend needs an access token in `NATIVE_UPDATE_TOKEN` — never a flag, which lands in
374
+ shell history and CI logs.
375
+
376
+ ```bash
377
+ export NATIVE_UPDATE_TOKEN=nu_pat_…
378
+
379
+ # Zips ./dist, uploads it, and blocks until the release is live.
380
+ # Exits non-zero on failure, so a broken release fails the build.
381
+ npx native-update deploy ./dist --app com.example.app --version 1.2.0 --wait
382
+ ```
383
+
384
+ | Flag | Default | What it does |
385
+ |---|---|---|
386
+ | `--app <idOrNumericId>` | — | required; the app to deploy to |
387
+ | `--version <semver>` | `package.json` version | the bundle version, which must be higher than the current one |
388
+ | `--channel <name>` | `production` | release channel |
389
+ | `--rollout <percent>` | — | release to a percentage of devices |
390
+ | `--wait` | `false` | block until the queued upload finishes — **use this in CI** |
391
+
392
+ Full reference: [CLI docs](https://nativeupdate-docs.aoneahsan.com/reference/cli/overview).
393
+
394
+ <a id="examples"></a>
395
+ ## 🧪 Examples&nbsp;[#](#examples)
396
+
397
+ | Goal | Walkthrough |
398
+ |---|---|
399
+ | Ship a first OTA update end to end | [→](https://nativeupdate-docs.aoneahsan.com/tutorials/first-ota-update) |
400
+ | Stand up a backend, then wire the app to it | [→](https://nativeupdate-docs.aoneahsan.com/tutorials/backend-first-walkthrough) |
401
+ | Test bundles locally before publishing | [→](https://nativeupdate-docs.aoneahsan.com/how-to/test-bundles-locally) |
402
+ | Roll a bad bundle back | [→](https://nativeupdate-docs.aoneahsan.com/how-to/roll-back-bundle) |
403
+ | Deploy from GitHub Actions | [→](https://nativeupdate-docs.aoneahsan.com/how-to/ci-cd-github-actions) |
404
+ | Migrate from CodePush | [→](https://nativeupdate-docs.aoneahsan.com/how-to/migrate-from-codepush) |
405
+
406
+ <a id="advanced-features"></a>
407
+ ## 🎛️ Advanced Features&nbsp;[#](#advanced-features)
408
+
409
+ - **Public Management API** — apps, API keys, signing keys, keystore backups, uploads, promotion and
410
+ rollouts over HTTP, so CI or a coding agent can run an app's whole lifecycle.
411
+ [Overview](https://nativeupdate-docs.aoneahsan.com/public-api/overview) ·
412
+ [Endpoints](https://nativeupdate-docs.aoneahsan.com/public-api/endpoints)
413
+ - **Queued uploads** — an upload answers `202` with a job id, and the build stays invisible to devices until
414
+ processing finishes, so a half-uploaded build can never reach a user.
415
+ [Queued jobs](https://nativeupdate-docs.aoneahsan.com/public-api/async-jobs)
416
+ - **API key restrictions** — lock a key to your web origins, your Android package plus signing-certificate
417
+ fingerprints, or your iOS bundle id, so it can ship inside your app.
418
+ [How to](https://nativeupdate-docs.aoneahsan.com/how-to/restrict-api-keys)
419
+ - **Bundle signing** — sign bundles with your own key; the plugin verifies the signature before activation
420
+ and again at boot.
421
+ [Integrity and signing](https://nativeupdate-docs.aoneahsan.com/concepts/bundle-integrity-and-signing)
422
+ - **Certificate pinning** — pin the update host's certificate on iOS and Android.
423
+ [Reference](https://nativeupdate-docs.aoneahsan.com/reference/sdk/security/certificate-pinning)
424
+ - **Your own server** — implement the update contract in any language; the CLI scaffolds a starting point.
425
+ [Backend overview](https://nativeupdate-docs.aoneahsan.com/backend/overview)
426
+
427
+ <a id="recovery-troubleshooting"></a>
428
+ ## 🚑 Recovery & Troubleshooting&nbsp;[#](#recovery-troubleshooting)
429
+
430
+ | Symptom | Cause | Fix |
431
+ |---|---|---|
432
+ | `getDefaultProguardFile('proguard-android.txt') is no longer supported` while building your Android release | Fixed in 3.4.2 and later | Upgrade to the latest release and remove any local Yarn patch |
433
+ | `R8: Missing class com.google.android.gms.common.annotation.NoNullnessRewrite` in a release build with `minifyEnabled true` | Fixed in 4.2.1 and later: the plugin ships its R8 rules to your app | Upgrade to the latest release and remove any `-dontwarn` you added for it |
434
+ | Every update reverts a few minutes after it applies | `notifyAppReady()` is never called, so the native layer treats each boot as failed | Call `notifyAppReady()` once per successful boot, right after `initialize()` |
435
+ | `require('native-update')` returns `{}` | Fixed in 3.4.1. Earlier versions emitted the CommonJS artifact with a `.js` extension inside a `"type": "module"` package, so Node loaded it as ESM | Upgrade to `3.4.1` or later |
436
+ | Updates work on web, nothing happens on device | `npx cap sync` was not run after installing | Run `npx cap sync` and rebuild the native app |
437
+ | `initialize()` rejects, or downloads fail with an auth error | The API key is missing, wrong, or restricted to clients that do not include this one | Check the key and its restrictions in the dashboard |
438
+ | The server returns a bundle but it never installs | Checksum or signature verification failed, so the bundle was rejected before activation | Re-create and re-sign the bundle; confirm `publicKey` matches the signing key |
439
+ | A device never receives a release | The build is still processing, paused, or outside the rollout percentage | Check the build's status and rollout in the dashboard or with `builds status` |
440
+
441
+ More: [troubleshooting guide](https://nativeupdate-docs.aoneahsan.com/how-to/troubleshooting) ·
442
+ [error codes](https://nativeupdate-docs.aoneahsan.com/reference/sdk/security/error-codes).
443
+
444
+ <a id="limitations"></a>
445
+ ## 🚧 Limitations&nbsp;[#](#limitations)
446
+
447
+ - **OTA replaces the web layer only.** Anything that changes native code, permissions or the manifest still
448
+ needs a store release.
449
+ - **You supply the backend.** This package does not host your bundles. Use the hosted Native Update service, or
450
+ implement the HTTP contract on your own server.
451
+ - **Web is not a deployment target for the native flows.** Store-update and review calls resolve without
452
+ doing anything on web, and certificate pinning is unavailable there because browsers do not expose
453
+ certificate details to JavaScript. Storage capacity on web is a fixed default, not a measurement.
454
+ - **Mobile key restrictions are client-attested, not cryptographic attestation.** The plugin sends the
455
+ Android package and signing-certificate fingerprints, or the iOS bundle id, as headers — the same trust
456
+ model as a restricted Google Maps key. They stop casual key reuse; they are not proof of origin. Web
457
+ origin restrictions are stronger, because the browser sets `Origin` and page JavaScript cannot forge it.
458
+ Layer Play Integrity or App Attest yourself if you need hard attestation.
459
+ - **Apps built on versions older than 3.2.0 send no identity headers**, so an Android or iOS key
460
+ restriction blocks them until the app is rebuilt.
461
+ - **The iOS team id is not sent.** The dashboard accepts `team_id`, but the plugin does not send
462
+ `X-Ios-Team-Id`; set it only if your own fetch does.
463
+ - **`engines` requires Node `>=24.16.0`.** Installers that enforce `engines` refuse an older runtime. This
464
+ affects your build machine, not your users' devices.
465
+ - **Store policy is your responsibility.** Both platforms permit updating interpreted code within limits;
466
+ shipping something that changes what your app does is your call to defend.
467
+
468
+ <a id="faq"></a>
469
+ ## ❓ FAQ&nbsp;[#](#faq)
470
+
471
+ **Do I have to use the hosted backend?**
472
+ No. The [HTTP contract](https://nativeupdate-docs.aoneahsan.com/backend/api-contract) is published, and the
473
+ CLI can scaffold an Express, Firebase or Vercel server that implements it.
474
+
475
+ **Does `require()` work, or is this ESM-only?**
476
+ Both. The package publishes an ESM build and a real CommonJS build with matching type declarations. Versions
477
+ before 3.4.1 had a broken CommonJS entry point — upgrade if `require()` returned an empty object.
478
+
479
+ **Will an OTA update get my app rejected?**
480
+ Updating interpreted code is permitted by both stores within their policies. Changing what your app
481
+ fundamentally does, or using OTA to bypass review for native functionality, is not. Read the policies and
482
+ stay inside them.
483
+
484
+ **What happens if an update breaks the app?**
485
+ It is reverted. A newly activated bundle stays pending until `notifyAppReady()` confirms a healthy boot; two
486
+ cold starts without that confirmation trigger an automatic rollback to the previous bundle.
487
+
488
+ **Can I ship the API key inside my app?**
489
+ Yes, once you restrict it. An unrestricted key works from anywhere and belongs on a server. See
490
+ [restricting API keys](https://nativeupdate-docs.aoneahsan.com/how-to/restrict-api-keys), and note the
491
+ attestation limits in [Limitations](#limitations).
492
+
493
+ **Is the source public?**
494
+ No. The repository is private; the published package, its type declarations and the documentation site are
495
+ the public surface.
496
+
497
+ <a id="documentation"></a>
498
+ ## 📚 Documentation&nbsp;[#](#documentation)
499
+
500
+ | Document | Read it when |
501
+ |---|---|
502
+ | [Introduction](https://nativeupdate-docs.aoneahsan.com/intro) | deciding whether this fits your app |
503
+ | [Installation](https://nativeupdate-docs.aoneahsan.com/getting-started/installation) | setting the plugin up for the first time |
504
+ | [Quick start](https://nativeupdate-docs.aoneahsan.com/getting-started/quick-start) | you want a working update within the hour |
505
+ | [How OTA updates work](https://nativeupdate-docs.aoneahsan.com/concepts/how-ota-updates-work) | you need the mental model before designing a flow |
506
+ | [Security model](https://nativeupdate-docs.aoneahsan.com/concepts/security-model) | reviewing this for production |
507
+ | [SDK reference](https://nativeupdate-docs.aoneahsan.com/reference/sdk/core/config) | you need an exact signature or option |
508
+ | [CLI reference](https://nativeupdate-docs.aoneahsan.com/reference/cli/overview) | scripting releases |
509
+ | [Backend overview](https://nativeupdate-docs.aoneahsan.com/backend/overview) | choosing or building an update server |
510
+ | [Public Management API](https://nativeupdate-docs.aoneahsan.com/public-api/overview) | automating releases from CI |
511
+ | [Platform notes](https://nativeupdate-docs.aoneahsan.com/platforms/android) | something behaves differently on one platform |
512
+ | [AI integration guide](https://nativeupdate-docs.aoneahsan.com/ai-integration) | a coding agent is implementing against this |
513
+
514
+ Machine-readable sources for agents: the
515
+ [OpenAPI 3.1 spec](https://nativeupdate-docs.aoneahsan.com/openapi/public-api.json) and a raw-Markdown mirror
516
+ indexed at [`/raw/manifest.json`](https://nativeupdate-docs.aoneahsan.com/raw/manifest.json).
517
+
518
+ <a id="changelog"></a>
519
+ ## 🔄 Changelog&nbsp;[#](#changelog)
520
+
521
+ Latest release: **`4.4.0`**. The CLI builds and uploads Dart code patches for Flutter apps
522
+ (`bundle flutter-patch`, `deploy --payload-type dart_aot`), for the Flutter SDK 1.1.0. The Capacitor plugin's API is
523
+ unchanged.
524
+
525
+ Full history ships inside the package at `docs/CHANGELOG.md`, so it always matches the version you
526
+ installed. It is also published as the
527
+ [online changelog](https://nativeupdate-docs.aoneahsan.com/changelog).
528
+
529
+ <a id="contributing"></a>
530
+ ## 🤝 Contributing&nbsp;[#](#contributing)
531
+
532
+ The source repository is private, so there is no fork-and-pull-request path. Bug reports, reproductions and
533
+ feature proposals are genuinely wanted and are the most useful contribution you can make — send them through
534
+ the [contact page](https://nativeupdate.aoneahsan.com/contact). Include the package version, the platform,
535
+ and the smallest reproduction you can manage.
536
+
537
+ <a id="support"></a>
538
+ ## 💬 Support&nbsp;[#](#support)
539
+
540
+ Questions and bugs: [nativeupdate.aoneahsan.com/contact](https://nativeupdate.aoneahsan.com/contact).
541
+
542
+ If this package saves you time, you can support its maintenance at
543
+ [aoneahsan.com/payment](https://aoneahsan.com/payment?project-id=native-update&project-identifier=native-update).
544
+
545
+ <a id="license"></a>
546
+ ## 📄 License&nbsp;[#](#license)
547
+
548
+ Proprietary © Ahsan Mahmood, from 4.1.2. You may install and use the package in the apps you build, with
549
+ a Native Update account or your own contract server; you may not redistribute it on its own. Versions before
550
+ 4.1.2 were published under MIT. The full text ships in the package as `LICENSE`.
551
+
552
+ <a id="author"></a>
553
+ ## 👥 Team&nbsp;[#](#author)
554
+
555
+ Built and run by the Native Update team — [nativeupdate.aoneahsan.com](https://nativeupdate.aoneahsan.com) ·
556
+ [contact](https://nativeupdate.aoneahsan.com/contact)
557
+
558
+ <a id="links"></a>
559
+ ## 🔗 Links&nbsp;[#](#links)
560
+
561
+ | | |
562
+ |---|---|
563
+ | Documentation | https://nativeupdate-docs.aoneahsan.com |
564
+ | npm | https://www.npmjs.com/package/native-update |
565
+ | Dashboard and website | https://nativeupdate.aoneahsan.com |
566
+ | Changelog | https://nativeupdate-docs.aoneahsan.com/changelog |
567
+ | AI integration guide | https://nativeupdate-docs.aoneahsan.com/ai-integration |
568
+ | OpenAPI spec | https://nativeupdate-docs.aoneahsan.com/openapi/public-api.json |
569
+ | Report an issue | https://nativeupdate.aoneahsan.com/contact |
570
+ | Support the project | https://aoneahsan.com/payment?project-id=native-update&project-identifier=native-update |
571
+
572
+ <a id="keywords"></a>
573
+ ## 🏷️ Keywords&nbsp;[#](#keywords)
574
+
575
+ *capacitor · plugin · native · app-updates · native-updates · ota · live-updates · hot-reload · app-store · google-play · in-app-updates · app-reviews · ios · android · hybrid*