@capgo/capacitor-updater 8.54.2 → 9.0.1
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/CapgoCapacitorUpdater.podspec +2 -2
- package/Package.swift +3 -4
- package/README.md +162 -417
- package/android/build.gradle +7 -7
- package/android/consumer-rules.pro +48 -0
- package/android/proguard-rules.pro +1 -23
- package/android/src/main/java/ee/forgr/capacitor_updater/CapacitorUpdaterPlugin.java +1420 -404
- package/android/src/main/java/ee/forgr/capacitor_updater/CapgoUpdater.java +1100 -308
- package/android/src/main/java/ee/forgr/capacitor_updater/CryptoCipher.java +102 -65
- package/android/src/main/java/ee/forgr/capacitor_updater/DownloadService.java +155 -18
- package/android/src/main/java/ee/forgr/capacitor_updater/DownloadWorkerManager.java +22 -2
- package/android/src/main/java/ee/forgr/capacitor_updater/HeadlessUpdateWorker.java +82 -21
- package/android/src/main/java/ee/forgr/capacitor_updater/Http3.java +356 -0
- package/android/src/main/java/ee/forgr/capacitor_updater/HttpEngineTransport.java +553 -0
- package/dist/docs.json +44 -566
- package/dist/esm/definitions.d.ts +97 -215
- package/dist/esm/definitions.js.map +1 -1
- package/ios/Sources/CapacitorUpdaterPlugin/CapacitorUpdaterPlugin.swift +197 -84
- package/ios/Sources/CapacitorUpdaterPlugin/CapgoUpdater.swift +402 -139
- package/ios/Sources/CapacitorUpdaterPlugin/CryptoCipher.swift +81 -55
- package/ios/Sources/CapacitorUpdaterPlugin/RedirectPolicyDelegate.swift +24 -0
- package/ios/Sources/CapacitorUpdaterPlugin/ShakeMenu.swift +2 -1
- package/ios/Sources/CapacitorUpdaterPlugin/WKWebView+CapgoObjcBridge.swift +20 -0
- package/ios/Tests/CapacitorUpdaterPluginTests/BuiltinHashesTests.swift +210 -0
- package/ios/Tests/CapacitorUpdaterPluginTests/BundleHardeningTests.swift +292 -0
- package/ios/Tests/CapacitorUpdaterPluginTests/CapacitorUpdaterPluginTests.swift +3905 -0
- package/ios/Tests/CapacitorUpdaterPluginTests/CapgoSemanticVersionTests.swift +64 -0
- package/ios/Tests/CapacitorUpdaterPluginTests/ChecksumRequiredTests.swift +151 -0
- package/ios/Tests/CapacitorUpdaterPluginTests/CliCryptoFixtureTests.swift +249 -0
- package/ios/Tests/CapacitorUpdaterPluginTests/HttpsOnlyBuiltinMinimumTests.swift +528 -0
- package/ios/Tests/CapacitorUpdaterPluginTests/InstallPerfTests.swift +174 -0
- package/ios/Tests/CapacitorUpdaterPluginTests/ListChannelsTests.swift +74 -0
- package/ios/Tests/CapacitorUpdaterPluginTests/LoggerSecurityTests.swift +149 -0
- package/ios/Tests/CapacitorUpdaterPluginTests/NativeContractTests.swift +160 -0
- package/ios/Tests/CapacitorUpdaterPluginTests/NetworkTransportTests.swift +1095 -0
- package/ios/Tests/CapacitorUpdaterPluginTests/PopulateDeltaCacheTests.swift +573 -0
- package/ios/Tests/CapacitorUpdaterPluginTests/RedirectPolicyTests.swift +63 -0
- package/ios/Tests/CapacitorUpdaterPluginTests/RsaContractTests.swift +281 -0
- package/ios/Tests/CapacitorUpdaterPluginTests/SessionKeyRequiredTests.swift +192 -0
- package/ios/Tests/CapacitorUpdaterPluginTests/TestZipWriter.swift +235 -0
- package/ios/Tests/CapacitorUpdaterPluginTests/UpdateLifecycleTests.swift +454 -0
- package/ios/Tests/CapacitorUpdaterPluginTests/WebKitOverlayGuardTests.swift +32 -0
- package/ios/Tests/CapacitorUpdaterPluginTests/ZipArchiveReaderTests.swift +302 -0
- package/ios/Tests/CapacitorUpdaterPluginTests/ZipBundleExtractionTests.swift +122 -0
- package/package.json +15 -13
|
@@ -145,28 +145,9 @@ declare module '@capacitor/cli' {
|
|
|
145
145
|
* @since 4.17.48
|
|
146
146
|
*/
|
|
147
147
|
version?: string;
|
|
148
|
-
/**
|
|
149
|
-
* Configure when the plugin should direct install updates. Only for autoUpdate mode.
|
|
150
|
-
* Instant apply (`atInstall`, `onLaunch`, `always`) should be uploaded with `--delta` so the update does not slow the user experience. A full zip, especially over 10MB, is relatively slow for users.
|
|
151
|
-
* These modes require `autoSplashscreen: true` and `@capacitor/splash-screen` installed with `launchAutoHide: false`.
|
|
152
|
-
* This flag makes the CLI upload delta in CI and ask for confirmation in local uploads.
|
|
153
|
-
* - false: Never do direct updates
|
|
154
|
-
* - atInstall: Same as `"atInstall"` for {@link autoUpdate}
|
|
155
|
-
* - onLaunch: Same as `"onLaunch"` for {@link autoUpdate}
|
|
156
|
-
* - always: Same as `"always"` for {@link autoUpdate}
|
|
157
|
-
* - true: (deprecated) Same as "always" for backward compatibility
|
|
158
|
-
*
|
|
159
|
-
* @deprecated Use {@link PluginsConfig.CapacitorUpdater.autoUpdate} string modes instead.
|
|
160
|
-
*
|
|
161
|
-
* Only available for Android and iOS.
|
|
162
|
-
*
|
|
163
|
-
* @default false
|
|
164
|
-
* @since 5.1.0
|
|
165
|
-
*/
|
|
166
|
-
directUpdate?: boolean | 'atInstall' | 'always' | 'onLaunch';
|
|
167
148
|
/**
|
|
168
149
|
* Automatically hide the splashscreen after instant apply updates finish, or when no update is needed.
|
|
169
|
-
* Required when using instant apply modes (`"atInstall"`, `"onLaunch"`, `"always"`)
|
|
150
|
+
* Required when using the instant apply {@link autoUpdate} modes (`"atInstall"`, `"onLaunch"`, `"always"`).
|
|
170
151
|
* `@capacitor/splash-screen` must be installed and configured with `launchAutoHide: false`.
|
|
171
152
|
* This removes the need to manually listen for appReady events and call SplashScreen.hide().
|
|
172
153
|
*
|
|
@@ -191,7 +172,9 @@ declare module '@capacitor/cli' {
|
|
|
191
172
|
* Automatically hide the splashscreen after the specified number of milliseconds when using automatic direct updates.
|
|
192
173
|
* If the timeout elapses, the update continues to download in the background while the splashscreen is dismissed.
|
|
193
174
|
* Set to `0` (zero) to disable the timeout.
|
|
194
|
-
*
|
|
175
|
+
* If installation has not started when the timeout fires, the downloaded bundle is installed on the next background/launch.
|
|
176
|
+
* If installation has already started, the splashscreen still hides at the deadline while the reload and app-ready checks finish.
|
|
177
|
+
* This can briefly expose the previous page while the new bundle loads.
|
|
195
178
|
* Requires {@link autoSplashscreen} to be enabled.
|
|
196
179
|
*
|
|
197
180
|
* Only available for Android and iOS.
|
|
@@ -309,6 +292,26 @@ declare module '@capacitor/cli' {
|
|
|
309
292
|
* @since 8.54.0
|
|
310
293
|
*/
|
|
311
294
|
httpsOnly?: boolean;
|
|
295
|
+
/**
|
|
296
|
+
* Let bundle and manifest downloads use HTTP/3 when the server advertises it.
|
|
297
|
+
*
|
|
298
|
+
* Android 14+ (and Android 12 or 13 with the S extension at level 7) sends https downloads through the
|
|
299
|
+
* platform `HttpEngine`, which keeps the server's HTTP/3 support across app launches and falls back to
|
|
300
|
+
* HTTP/2 (or HTTP/1.1 when the server lacks HTTP/2) on its own when QUIC is blocked. Older Android versions
|
|
301
|
+
* keep the current OkHttp client (HTTP/2 or HTTP/1.1). iOS marks download requests as HTTP/3 capable, and
|
|
302
|
+
* URLSession falls back to HTTP/2 or HTTP/1.1 when QUIC fails or the server does not support HTTP/3.
|
|
303
|
+
* Update checks, stats and channel calls are not affected.
|
|
304
|
+
*
|
|
305
|
+
* Set to `false` to stop preferring HTTP/3. Android then keeps downloads on the previous OkHttp client
|
|
306
|
+
* (HTTP/2 or HTTP/1.1). iOS no longer marks downloads as HTTP/3 capable, but URLSession can still pick
|
|
307
|
+
* HTTP/3 on its own if it already learned the server supports it, so `false` is not a hard HTTP/2 guarantee there.
|
|
308
|
+
*
|
|
309
|
+
* Only available for Android and iOS.
|
|
310
|
+
*
|
|
311
|
+
* @default true
|
|
312
|
+
* @since 8.55.0
|
|
313
|
+
*/
|
|
314
|
+
http3?: boolean;
|
|
312
315
|
/**
|
|
313
316
|
* Refuse to download or install a bundle whose version is lower than the native app version
|
|
314
317
|
* (`version` config override, else `CFBundleShortVersionString` / `versionName`). This is the on-device
|
|
@@ -316,14 +319,12 @@ declare module '@capacitor/cli' {
|
|
|
316
319
|
* replayed old update response rolling the app back below its store version. Only the numeric
|
|
317
320
|
* `major.minor.patch` part is compared (a `1.2.3-beta.1` bundle is accepted on native `1.2.3`), and
|
|
318
321
|
* versions that do not parse as semver skip the check. Rejections are reported as the
|
|
319
|
-
* `version_below_native` stat.
|
|
320
|
-
* (for example native `2.0.0` with bundle `1.4.7`).
|
|
321
|
-
*
|
|
322
|
-
* Future-major default candidate: `true`.
|
|
322
|
+
* `version_below_native` stat. Set it to `false` if you version web bundles independently of the native
|
|
323
|
+
* app (for example native `2.0.0` with bundle `1.4.7`).
|
|
323
324
|
*
|
|
324
325
|
* Only available for Android and iOS.
|
|
325
326
|
*
|
|
326
|
-
* @default false
|
|
327
|
+
* @default true (was `false` before 9.0.0)
|
|
327
328
|
* @since 8.54.0
|
|
328
329
|
*/
|
|
329
330
|
builtinMinimum?: boolean;
|
|
@@ -355,10 +356,12 @@ declare module '@capacitor/cli' {
|
|
|
355
356
|
allowPreview?: boolean;
|
|
356
357
|
/**
|
|
357
358
|
* Persist the customId set through {@link CapacitorUpdaterPlugin.setCustomId} across app restarts.
|
|
359
|
+
* Set it to `false` to keep the customId in memory only, so it resets on every app launch.
|
|
360
|
+
* Calling `setCustomId({ customId: '' })` clears the saved value even when persistence is disabled.
|
|
358
361
|
*
|
|
359
362
|
* Only available for Android and iOS.
|
|
360
363
|
*
|
|
361
|
-
* @default
|
|
364
|
+
* @default true (was `false` before 9.0.0)
|
|
362
365
|
* @since 7.17.3
|
|
363
366
|
*/
|
|
364
367
|
persistCustomId?: boolean;
|
|
@@ -477,7 +480,7 @@ declare module '@capacitor/cli' {
|
|
|
477
480
|
/**
|
|
478
481
|
* When enabled, show a native dialog prompting the user to install a newer native app from the App Store or Play Store.
|
|
479
482
|
* The prompt appears when a live update is blocked because the device native app is too old, including backend
|
|
480
|
-
* `disable_auto_update_*` responses, `store_update_required`, and `breakingAvailable`
|
|
483
|
+
* `disable_auto_update_*` responses, `store_update_required`, and `breakingAvailable` flows.
|
|
481
484
|
*
|
|
482
485
|
* Only available for Android and iOS. No-op on web.
|
|
483
486
|
*
|
|
@@ -920,6 +923,9 @@ export interface CapacitorUpdaterPlugin {
|
|
|
920
923
|
* - Testing update flows during development
|
|
921
924
|
*
|
|
922
925
|
* If no update is pending (no call to {@link next}), this simply reloads the current bundle.
|
|
926
|
+
* If `builtinMinimum` rejects a pending bundle below the native version, the promise rejects with
|
|
927
|
+
* code `VERSION_BELOW_NATIVE` and a message naming both versions. The current bundle and pending
|
|
928
|
+
* update remain unchanged, so you can reset to builtin or choose another bundle.
|
|
923
929
|
*
|
|
924
930
|
* @returns {Promise<void>} A promise that may never resolve because the app will be reloaded.
|
|
925
931
|
* @throws {Error} If the reload operation fails.
|
|
@@ -997,9 +1003,9 @@ export interface CapacitorUpdaterPlugin {
|
|
|
997
1003
|
* bundle without reimplementing the update protocol in JavaScript.
|
|
998
1004
|
*
|
|
999
1005
|
* The promise resolves after the native background work has been queued, not
|
|
1000
|
-
* after the update has been downloaded or installed. Listen to
|
|
1001
|
-
*
|
|
1002
|
-
* `noNeedUpdate` for the final result.
|
|
1006
|
+
* after the update has been downloaded or installed. Listen to `updaterEvent`
|
|
1007
|
+
* and its `updateAvailable`, `downloadComplete`, `downloadFailed`, and
|
|
1008
|
+
* `noNeedUpdate` types for the final result.
|
|
1003
1009
|
*
|
|
1004
1010
|
* Native support is available on iOS and Android. On Web, this method returns
|
|
1005
1011
|
* a result with `status: 'unavailable'`. Native platforms also return
|
|
@@ -1130,13 +1136,15 @@ export interface CapacitorUpdaterPlugin {
|
|
|
1130
1136
|
* **Important: Listen for the `channelPrivate` event**
|
|
1131
1137
|
*
|
|
1132
1138
|
* When a user attempts to set a channel that doesn't allow device self-assignment, the method will
|
|
1133
|
-
* throw an error AND
|
|
1139
|
+
* throw an error AND emit a `channelPrivate` {@link UpdaterEvent}. You should listen to this event
|
|
1134
1140
|
* to provide appropriate feedback to users:
|
|
1135
1141
|
*
|
|
1136
1142
|
* ```typescript
|
|
1137
|
-
* CapacitorUpdater.addListener('
|
|
1138
|
-
*
|
|
1139
|
-
*
|
|
1143
|
+
* CapacitorUpdater.addListener('updaterEvent', (event) => {
|
|
1144
|
+
* if (event.type === 'channelPrivate') {
|
|
1145
|
+
* console.warn(`Cannot access channel "${event.data.channel}": ${event.data.message}`);
|
|
1146
|
+
* // Show user-friendly message
|
|
1147
|
+
* }
|
|
1140
1148
|
* });
|
|
1141
1149
|
* ```
|
|
1142
1150
|
*
|
|
@@ -1182,8 +1190,9 @@ export interface CapacitorUpdaterPlugin {
|
|
|
1182
1190
|
* - Check if a device is on a specific channel before showing features
|
|
1183
1191
|
* - Verify channel assignment after calling {@link setChannel}
|
|
1184
1192
|
*
|
|
1185
|
-
* On native platforms, a successful response
|
|
1186
|
-
*
|
|
1193
|
+
* On native platforms, a successful response with a device channel override also refreshes the
|
|
1194
|
+
* default channel used by update checks. Responses with `status: 'default'` are reported only and
|
|
1195
|
+
* are not persisted. This refresh is persisted across app restarts.
|
|
1187
1196
|
*
|
|
1188
1197
|
* @returns {Promise<GetChannelRes>} The current channel information.
|
|
1189
1198
|
* @throws {Error} If the operation fails.
|
|
@@ -1224,11 +1233,11 @@ export interface CapacitorUpdaterPlugin {
|
|
|
1224
1233
|
* - A/B testing or feature flagging
|
|
1225
1234
|
*
|
|
1226
1235
|
* **Persistence:**
|
|
1227
|
-
* - When {@link PluginsConfig.CapacitorUpdater.persistCustomId} is `true
|
|
1236
|
+
* - When {@link PluginsConfig.CapacitorUpdater.persistCustomId} is `true` (the default), the ID persists across app restarts
|
|
1228
1237
|
* - When `false`, the ID is only kept for the current session
|
|
1229
1238
|
*
|
|
1230
1239
|
* **Clearing the custom ID:**
|
|
1231
|
-
* - Pass an empty string `""` to remove any stored custom ID
|
|
1240
|
+
* - Pass an empty string `""` to remove any stored custom ID, even when persistence is disabled
|
|
1232
1241
|
*
|
|
1233
1242
|
* @param options The {@link SetCustomIdOptions} containing the custom identifier string.
|
|
1234
1243
|
* @returns {Promise<void>} Resolves immediately (synchronous operation).
|
|
@@ -1324,18 +1333,8 @@ export interface CapacitorUpdaterPlugin {
|
|
|
1324
1333
|
/**
|
|
1325
1334
|
* Remove all event listeners registered for this plugin.
|
|
1326
1335
|
*
|
|
1327
|
-
* This unregisters
|
|
1328
|
-
*
|
|
1329
|
-
* - `download`
|
|
1330
|
-
* - `noNeedUpdate`
|
|
1331
|
-
* - `updateCheckResult`
|
|
1332
|
-
* - `updateAvailable`
|
|
1333
|
-
* - `downloadComplete`
|
|
1334
|
-
* - `downloadFailed`
|
|
1335
|
-
* - `breakingAvailable` / `majorAvailable`
|
|
1336
|
-
* - `updateFailed`
|
|
1337
|
-
* - `appReloaded`
|
|
1338
|
-
* - `appReady`
|
|
1336
|
+
* This unregisters every listener added via {@link addListener}, including all
|
|
1337
|
+
* `updaterEvent` listeners.
|
|
1339
1338
|
*
|
|
1340
1339
|
* Use this during cleanup (e.g., when unmounting components or closing screens)
|
|
1341
1340
|
* to prevent memory leaks from lingering event listeners.
|
|
@@ -1347,12 +1346,15 @@ export interface CapacitorUpdaterPlugin {
|
|
|
1347
1346
|
/**
|
|
1348
1347
|
* Listen for every updater event with a single listener.
|
|
1349
1348
|
*
|
|
1350
|
-
* Each call receives `{ type, data }`: `type` is the event name
|
|
1351
|
-
*
|
|
1352
|
-
*
|
|
1353
|
-
*
|
|
1349
|
+
* Each call receives `{ type, data }`: `type` is the event name and `data` is its payload
|
|
1350
|
+
* (see {@link UpdaterEvent} for every type and its payload).
|
|
1351
|
+
*
|
|
1352
|
+
* Since 9.0.0 this is the only listener the plugin emits. The per-event listeners
|
|
1353
|
+
* (`addListener('download', ...)`, `addListener('appReady', ...)`, ...) and the `majorAvailable`
|
|
1354
|
+
* alias were removed: switch on `event.type` instead.
|
|
1354
1355
|
*
|
|
1355
|
-
*
|
|
1356
|
+
* `set` and `appReady` are retained natively until a listener attaches, so they are still
|
|
1357
|
+
* delivered after a reload even when the listener is registered later in app startup.
|
|
1356
1358
|
*
|
|
1357
1359
|
* ```typescript
|
|
1358
1360
|
* CapacitorUpdater.addListener('updaterEvent', (event) => {
|
|
@@ -1363,6 +1365,9 @@ export interface CapacitorUpdaterPlugin {
|
|
|
1363
1365
|
* case 'downloadFailed':
|
|
1364
1366
|
* console.warn('download failed', event.data.version);
|
|
1365
1367
|
* break;
|
|
1368
|
+
* case 'channelPrivate':
|
|
1369
|
+
* console.warn(`Cannot access channel "${event.data.channel}": ${event.data.message}`);
|
|
1370
|
+
* break;
|
|
1366
1371
|
* }
|
|
1367
1372
|
* });
|
|
1368
1373
|
* ```
|
|
@@ -1370,145 +1375,6 @@ export interface CapacitorUpdaterPlugin {
|
|
|
1370
1375
|
* @since 8.53.0
|
|
1371
1376
|
*/
|
|
1372
1377
|
addListener(eventName: 'updaterEvent', listenerFunc: (event: UpdaterEvent) => void): Promise<PluginListenerHandle>;
|
|
1373
|
-
/**
|
|
1374
|
-
* Listen for bundle download event in the App. Fires once a download has started, during downloading and when finished.
|
|
1375
|
-
* This will return you all download percent during the download
|
|
1376
|
-
*
|
|
1377
|
-
* @deprecated Use `addListener('updaterEvent', ...)` and switch on `event.type`. This listener keeps working until v9.
|
|
1378
|
-
* @since 2.0.11
|
|
1379
|
-
*/
|
|
1380
|
-
addListener(eventName: 'download', listenerFunc: (state: DownloadEvent) => void): Promise<PluginListenerHandle>;
|
|
1381
|
-
/**
|
|
1382
|
-
* Listen for no need to update event, useful when you want force check every time the app is launched
|
|
1383
|
-
*
|
|
1384
|
-
* @deprecated Use `addListener('updaterEvent', ...)` and switch on `event.type`. This listener keeps working until v9.
|
|
1385
|
-
* @since 4.0.0
|
|
1386
|
-
*/
|
|
1387
|
-
addListener(eventName: 'noNeedUpdate', listenerFunc: (state: NoNeedEvent) => void): Promise<PluginListenerHandle>;
|
|
1388
|
-
/**
|
|
1389
|
-
* Listen for update check results before the updater decides whether to download.
|
|
1390
|
-
* The backend can classify the UpdateCheckResultEvent payload as `up_to_date`, `blocked`, or `failed`.
|
|
1391
|
-
*
|
|
1392
|
-
* This event is emitted alongside legacy events. For `up_to_date` and `blocked`, it is emitted before
|
|
1393
|
-
* `noNeedUpdate` and does not emit `downloadFailed`. For `failed`, it is emitted before the legacy
|
|
1394
|
-
* `downloadFailed` event; native code also sends an `update_check_error` stat (with error metadata)
|
|
1395
|
-
* instead of `download_fail`, because no bundle download was attempted.
|
|
1396
|
-
*
|
|
1397
|
-
* @deprecated Use `addListener('updaterEvent', ...)` and switch on `event.type`. This listener keeps working until v9.
|
|
1398
|
-
* @since 8.45.11
|
|
1399
|
-
*/
|
|
1400
|
-
addListener(eventName: 'updateCheckResult', listenerFunc: (state: UpdateCheckResultEvent) => void): Promise<PluginListenerHandle>;
|
|
1401
|
-
/**
|
|
1402
|
-
* Listen for available update event, useful when you want to force check every time the app is launched
|
|
1403
|
-
*
|
|
1404
|
-
* @deprecated Use `addListener('updaterEvent', ...)` and switch on `event.type`. This listener keeps working until v9.
|
|
1405
|
-
* @since 4.0.0
|
|
1406
|
-
*/
|
|
1407
|
-
addListener(eventName: 'updateAvailable', listenerFunc: (state: UpdateAvailableEvent) => void): Promise<PluginListenerHandle>;
|
|
1408
|
-
/**
|
|
1409
|
-
* Listen for downloadComplete events.
|
|
1410
|
-
*
|
|
1411
|
-
* @deprecated Use `addListener('updaterEvent', ...)` and switch on `event.type`. This listener keeps working until v9.
|
|
1412
|
-
* @since 4.0.0
|
|
1413
|
-
*/
|
|
1414
|
-
addListener(eventName: 'downloadComplete', listenerFunc: (state: DownloadCompleteEvent) => void): Promise<PluginListenerHandle>;
|
|
1415
|
-
/**
|
|
1416
|
-
* Listen for breaking update events when the backend flags an update as incompatible with the current app.
|
|
1417
|
-
* Emits the same payload as the legacy `majorAvailable` listener.
|
|
1418
|
-
*
|
|
1419
|
-
* @deprecated Use `addListener('updaterEvent', ...)` and switch on `event.type`. This listener keeps working until v9.
|
|
1420
|
-
* @since 7.22.0
|
|
1421
|
-
*/
|
|
1422
|
-
addListener(eventName: 'breakingAvailable', listenerFunc: (state: BreakingAvailableEvent) => void): Promise<PluginListenerHandle>;
|
|
1423
|
-
/**
|
|
1424
|
-
* Listen for Major update event in the App, let you know when major update is blocked by setting disableAutoUpdateBreaking
|
|
1425
|
-
*
|
|
1426
|
-
* @deprecated Deprecated alias for {@link addListener} with `breakingAvailable`. Emits the same payload. will be removed in v8
|
|
1427
|
-
* @since 2.3.0
|
|
1428
|
-
*/
|
|
1429
|
-
addListener(eventName: 'majorAvailable', listenerFunc: (state: MajorAvailableEvent) => void): Promise<PluginListenerHandle>;
|
|
1430
|
-
/**
|
|
1431
|
-
* Listen for update fail event in the App, let you know when update has fail to install at next app start
|
|
1432
|
-
*
|
|
1433
|
-
* @deprecated Use `addListener('updaterEvent', ...)` and switch on `event.type`. This listener keeps working until v9.
|
|
1434
|
-
* @since 2.3.0
|
|
1435
|
-
*/
|
|
1436
|
-
addListener(eventName: 'updateFailed', listenerFunc: (state: UpdateFailedEvent) => void): Promise<PluginListenerHandle>;
|
|
1437
|
-
/**
|
|
1438
|
-
* Listen for set event in the App, let you know when a bundle has been applied successfully.
|
|
1439
|
-
* This event is retained natively until JavaScript consumes it, so if the app reloads before your
|
|
1440
|
-
* listener is attached, the last pending `set` event is delivered once the listener subscribes.
|
|
1441
|
-
*
|
|
1442
|
-
* @deprecated Use `addListener('updaterEvent', ...)` and switch on `event.type`. This listener keeps working until v9.
|
|
1443
|
-
* @since 8.43.12
|
|
1444
|
-
*/
|
|
1445
|
-
addListener(eventName: 'set', listenerFunc: (state: SetEvent) => void): Promise<PluginListenerHandle>;
|
|
1446
|
-
/**
|
|
1447
|
-
* Listen for set next event in the App, let you know when a bundle is queued as the next bundle to install.
|
|
1448
|
-
*
|
|
1449
|
-
* @deprecated Use `addListener('updaterEvent', ...)` and switch on `event.type`. This listener keeps working until v9.
|
|
1450
|
-
* @since 6.14.0
|
|
1451
|
-
*/
|
|
1452
|
-
addListener(eventName: 'setNext', listenerFunc: (state: SetNextEvent) => void): Promise<PluginListenerHandle>;
|
|
1453
|
-
/**
|
|
1454
|
-
* Listen for download fail event in the App, let you know when a bundle download has failed
|
|
1455
|
-
*
|
|
1456
|
-
* @deprecated Use `addListener('updaterEvent', ...)` and switch on `event.type`. This listener keeps working until v9.
|
|
1457
|
-
* @since 4.0.0
|
|
1458
|
-
*/
|
|
1459
|
-
addListener(eventName: 'downloadFailed', listenerFunc: (state: DownloadFailedEvent) => void): Promise<PluginListenerHandle>;
|
|
1460
|
-
/**
|
|
1461
|
-
* Listen for reload event in the App, let you know when reload has happened
|
|
1462
|
-
*
|
|
1463
|
-
* @deprecated Use `addListener('updaterEvent', ...)` and switch on `event.type`. This listener keeps working until v9.
|
|
1464
|
-
* @since 4.3.0
|
|
1465
|
-
*/
|
|
1466
|
-
addListener(eventName: 'appReloaded', listenerFunc: () => void): Promise<PluginListenerHandle>;
|
|
1467
|
-
/**
|
|
1468
|
-
* Listen for app ready event in the App, let you know when app is ready to use.
|
|
1469
|
-
* This event is retained natively until JavaScript consumes it, so it can still be delivered after
|
|
1470
|
-
* a reload even if the listener is attached later in app startup.
|
|
1471
|
-
*
|
|
1472
|
-
* @deprecated Use `addListener('updaterEvent', ...)` and switch on `event.type`. This listener keeps working until v9.
|
|
1473
|
-
* @since 5.1.0
|
|
1474
|
-
*/
|
|
1475
|
-
addListener(eventName: 'appReady', listenerFunc: (state: AppReadyEvent) => void): Promise<PluginListenerHandle>;
|
|
1476
|
-
/**
|
|
1477
|
-
* Listen for channel private event, fired when attempting to set a channel that doesn't allow device self-assignment.
|
|
1478
|
-
*
|
|
1479
|
-
* This event is useful for:
|
|
1480
|
-
* - Informing users they don't have permission to switch to a specific channel
|
|
1481
|
-
* - Implementing custom error handling for channel restrictions
|
|
1482
|
-
* - Logging unauthorized channel access attempts
|
|
1483
|
-
*
|
|
1484
|
-
* @deprecated Use `addListener('updaterEvent', ...)` and switch on `event.type`. This listener keeps working until v9.
|
|
1485
|
-
* @since 7.34.0
|
|
1486
|
-
*/
|
|
1487
|
-
addListener(eventName: 'channelPrivate', listenerFunc: (state: ChannelPrivateEvent) => void): Promise<PluginListenerHandle>;
|
|
1488
|
-
/**
|
|
1489
|
-
* Listen for flexible update state changes on Android.
|
|
1490
|
-
*
|
|
1491
|
-
* This event fires during the flexible update download process, providing:
|
|
1492
|
-
* - Download progress (bytes downloaded / total bytes)
|
|
1493
|
-
* - Installation status changes
|
|
1494
|
-
*
|
|
1495
|
-
* **Install status values:**
|
|
1496
|
-
* - `UNKNOWN` (0): Unknown status
|
|
1497
|
-
* - `PENDING` (1): Download pending
|
|
1498
|
-
* - `DOWNLOADING` (2): Download in progress
|
|
1499
|
-
* - `INSTALLING` (3): Installing the update
|
|
1500
|
-
* - `INSTALLED` (4): Update installed (app restart needed)
|
|
1501
|
-
* - `FAILED` (5): Update failed
|
|
1502
|
-
* - `CANCELED` (6): Update was canceled
|
|
1503
|
-
* - `DOWNLOADED` (11): Download complete, ready to install
|
|
1504
|
-
*
|
|
1505
|
-
* When status is `DOWNLOADED`, you should prompt the user and call
|
|
1506
|
-
* {@link completeFlexibleUpdate} to finish the installation.
|
|
1507
|
-
*
|
|
1508
|
-
* @deprecated Use `addListener('updaterEvent', ...)` and switch on `event.type`. This listener keeps working until v9.
|
|
1509
|
-
* @since 8.0.0
|
|
1510
|
-
*/
|
|
1511
|
-
addListener(eventName: 'onFlexibleUpdateStateChange', listenerFunc: (state: FlexibleUpdateState) => void): Promise<PluginListenerHandle>;
|
|
1512
1378
|
/**
|
|
1513
1379
|
* Check if the auto-update feature is available (not disabled by custom server configuration).
|
|
1514
1380
|
*
|
|
@@ -1767,7 +1633,7 @@ export interface CapacitorUpdaterPlugin {
|
|
|
1767
1633
|
* 3. Notifies when download is complete
|
|
1768
1634
|
* 4. Requires calling {@link completeFlexibleUpdate} to install
|
|
1769
1635
|
*
|
|
1770
|
-
* Monitor the download progress
|
|
1636
|
+
* Monitor the download progress with the `onFlexibleUpdateStateChange` type of `updaterEvent`.
|
|
1771
1637
|
*
|
|
1772
1638
|
* **Requirements:**
|
|
1773
1639
|
* - Android only (throws error on iOS)
|
|
@@ -1776,7 +1642,7 @@ export interface CapacitorUpdaterPlugin {
|
|
|
1776
1642
|
*
|
|
1777
1643
|
* **Typical flow:**
|
|
1778
1644
|
* 1. Call `startFlexibleUpdate()` to begin download
|
|
1779
|
-
* 2. Listen to `onFlexibleUpdateStateChange` for progress
|
|
1645
|
+
* 2. Listen to `updaterEvent` and handle `onFlexibleUpdateStateChange` for progress
|
|
1780
1646
|
* 3. When status is `DOWNLOADED`, prompt user to restart
|
|
1781
1647
|
* 4. Call `completeFlexibleUpdate()` to install and restart
|
|
1782
1648
|
*
|
|
@@ -1938,21 +1804,19 @@ export interface DownloadEvent {
|
|
|
1938
1804
|
percent: number;
|
|
1939
1805
|
bundle: BundleInfo;
|
|
1940
1806
|
}
|
|
1941
|
-
|
|
1807
|
+
/**
|
|
1808
|
+
* Payload of the `breakingAvailable` {@link UpdaterEvent}.
|
|
1809
|
+
*
|
|
1810
|
+
* @since 7.22.0
|
|
1811
|
+
*/
|
|
1812
|
+
export interface BreakingAvailableEvent {
|
|
1942
1813
|
/**
|
|
1943
|
-
*
|
|
1814
|
+
* Version of the breaking update that the backend blocked for this native app.
|
|
1944
1815
|
*
|
|
1945
|
-
* @
|
|
1946
|
-
* @since 4.0.0
|
|
1816
|
+
* @since 7.22.0
|
|
1947
1817
|
*/
|
|
1948
1818
|
version: string;
|
|
1949
1819
|
}
|
|
1950
|
-
/**
|
|
1951
|
-
* Payload emitted by {@link CapacitorUpdaterPlugin.addListener} with `breakingAvailable`.
|
|
1952
|
-
*
|
|
1953
|
-
* @since 7.22.0
|
|
1954
|
-
*/
|
|
1955
|
-
export type BreakingAvailableEvent = MajorAvailableEvent;
|
|
1956
1820
|
export interface DownloadFailedEvent {
|
|
1957
1821
|
/**
|
|
1958
1822
|
* Emit when a download fail.
|
|
@@ -2015,10 +1879,28 @@ export interface ChannelPrivateEvent {
|
|
|
2015
1879
|
}
|
|
2016
1880
|
/**
|
|
2017
1881
|
* Payload of the single `updaterEvent` listener: every plugin event as `{ type, data }`.
|
|
2018
|
-
* `type`
|
|
2019
|
-
* so you can switch on `type` and get a typed `data`.
|
|
1882
|
+
* Switch on `type` to get a typed `data`.
|
|
2020
1883
|
*
|
|
2021
|
-
*
|
|
1884
|
+
* - `download`: download progress of a bundle, from start to finish (`percent` between 0 and 100).
|
|
1885
|
+
* - `noNeedUpdate`: the update check found nothing to install.
|
|
1886
|
+
* - `updateCheckResult`: classified result of an update check, before the updater decides whether to download.
|
|
1887
|
+
* In the background update pipeline, `up_to_date` and `blocked` are emitted before `noNeedUpdate` and no
|
|
1888
|
+
* `downloadFailed` follows. A `failed` result is emitted before `downloadFailed`, and native code sends an
|
|
1889
|
+
* `update_check_error` stat instead of `download_fail` because no bundle download was attempted.
|
|
1890
|
+
* Periodic checks (`periodCheckDelay`) may emit only `updateCheckResult`, without those follow-up events or stats.
|
|
1891
|
+
* - `updateAvailable`: a new bundle is downloaded and ready.
|
|
1892
|
+
* - `downloadComplete`: a bundle download finished.
|
|
1893
|
+
* - `downloadFailed`: a bundle download or update check failed.
|
|
1894
|
+
* - `breakingAvailable`: the backend blocked an update as incompatible with the current native app.
|
|
1895
|
+
* - `updateFailed`: a bundle failed to install at the next app start and was rolled back.
|
|
1896
|
+
* - `set`: a bundle was applied. Retained natively until a listener consumes it.
|
|
1897
|
+
* - `setNext`: a bundle was queued as the next bundle to install.
|
|
1898
|
+
* - `appReloaded`: the app reloaded.
|
|
1899
|
+
* - `appReady`: the app is ready to use. Retained natively until a listener consumes it.
|
|
1900
|
+
* - `channelPrivate`: `setChannel()` targeted a channel that does not allow device self-assignment.
|
|
1901
|
+
* - `onFlexibleUpdateStateChange`: Android flexible in-app update progress and install status.
|
|
1902
|
+
* When `installStatus` is `DOWNLOADED`, prompt the user and call
|
|
1903
|
+
* {@link CapacitorUpdaterPlugin.completeFlexibleUpdate}.
|
|
2022
1904
|
*
|
|
2023
1905
|
* @since 8.53.0
|
|
2024
1906
|
*/
|
|
@@ -2215,10 +2097,6 @@ export interface LatestVersion {
|
|
|
2215
2097
|
* @since 7.22.0
|
|
2216
2098
|
*/
|
|
2217
2099
|
breaking?: boolean;
|
|
2218
|
-
/**
|
|
2219
|
-
* @deprecated Use {@link LatestVersion.breaking} instead.
|
|
2220
|
-
*/
|
|
2221
|
-
major?: boolean;
|
|
2222
2100
|
/**
|
|
2223
2101
|
* Optional message from the server.
|
|
2224
2102
|
* When no new version is available, this will be "No new version available".
|
|
@@ -2535,7 +2413,11 @@ export interface DownloadOptions {
|
|
|
2535
2413
|
*/
|
|
2536
2414
|
sessionKey?: string;
|
|
2537
2415
|
/**
|
|
2538
|
-
* The checksum for the update, it should be in sha256 and encrypted with private key if the bundle is encrypted
|
|
2416
|
+
* The checksum for the update, it should be in sha256 and encrypted with private key if the bundle is encrypted.
|
|
2417
|
+
*
|
|
2418
|
+
* Since 9.0.0, the checksum of an encrypted bundle must sign both the SHA-256 of the bundle zip and the
|
|
2419
|
+
* SHA-256 of the encrypted bytes (the format `npx @capgo/cli@latest bundle encrypt` produces for updater 9).
|
|
2420
|
+
* The plugin checks the downloaded bytes against it before decrypting them.
|
|
2539
2421
|
* @since 4.0.0
|
|
2540
2422
|
* @default undefined
|
|
2541
2423
|
*/
|