@capgo/cordova-updater 8.1.4 → 8.2.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/dist/esm/definitions.d.ts +116 -86
- package/dist/esm/definitions.js +2 -2
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/exec.js +11 -1
- package/dist/esm/exec.js.map +1 -1
- package/dist/esm/history.js +7 -7
- package/dist/esm/history.js.map +1 -1
- package/dist/plugin.cjs.js +13 -3
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +13 -3
- package/dist/plugin.js.map +1 -1
- package/package.json +5 -3
- package/plugin.xml +9 -9
- package/src/android/CordovaUpdaterPlugin.java +173 -5
- package/src/android/app/capgo/cordova/updater/CapgoUpdater.java +313 -55
- package/src/android/app/capgo/cordova/updater/CryptoCipher.java +51 -18
- package/src/android/app/capgo/cordova/updater/DelayUpdateUtils.java +0 -1
- package/src/android/app/capgo/cordova/updater/DownloadService.java +402 -89
- package/src/android/app/capgo/cordova/updater/Version.java +312 -0
- package/src/android/capgo-cordova-updater.gradle +0 -2
- package/src/android/test/app/capgo/cordova/updater/BackgroundDownloadSettlementTest.java +29 -0
- package/src/android/test/app/capgo/cordova/updater/CapacitorUpdaterUnitTest.java.skip +2 -12
- package/src/android/test/app/capgo/cordova/updater/DelayUpdateUtilsTest.java +0 -1
- package/src/android/test/app/capgo/cordova/updater/RsaContractTest.java +137 -0
- package/src/android/test/app/capgo/cordova/updater/SecurityHardeningTest.java +197 -0
- package/src/android/test/app/capgo/cordova/updater/SessionKeyRequiredTest.java +344 -0
- package/src/ios/CapgoSemanticVersion.swift +181 -0
- package/src/ios/CapgoUpdater.swift +427 -114
- package/src/ios/CordovaUpdaterPlugin.swift +171 -40
- package/src/ios/CryptoCipher.swift +41 -38
- package/src/ios/DelayUpdateUtils.swift +19 -45
- package/src/ios/Logger.swift +81 -5
- package/src/ios/RedirectPolicyDelegate.swift +53 -0
- package/src/ios/WebViewStatsReporter.swift +5 -0
- package/src/ios/ZipArchiveReader.swift +263 -0
- package/src/ios/ZipCentralDirectory.swift +283 -0
|
@@ -3,7 +3,7 @@ export interface PluginListenerHandle {
|
|
|
3
3
|
}
|
|
4
4
|
export interface CordovaUpdaterConfig {
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* Cordova updater can be configured with these options:
|
|
7
7
|
*/
|
|
8
8
|
options?: {
|
|
9
9
|
/**
|
|
@@ -16,7 +16,10 @@ export interface CordovaUpdaterConfig {
|
|
|
16
16
|
*/
|
|
17
17
|
appReadyTimeout?: number;
|
|
18
18
|
/**
|
|
19
|
-
* Configure the number of seconds the native plugin should wait before considering
|
|
19
|
+
* Configure the number of seconds the native plugin should wait before considering an HTTP timeout.
|
|
20
|
+
* Applies to update checks and file downloads. On Android these are idle connect/read/write
|
|
21
|
+
* timeouts and do not cap total download time; on iOS the request timeout also bounds the
|
|
22
|
+
* total download duration.
|
|
20
23
|
*
|
|
21
24
|
* Only available for Android and iOS.
|
|
22
25
|
*
|
|
@@ -43,21 +46,27 @@ export interface CordovaUpdaterConfig {
|
|
|
43
46
|
*/
|
|
44
47
|
autoDeletePrevious?: boolean;
|
|
45
48
|
/**
|
|
46
|
-
* Configure how the plugin
|
|
49
|
+
* Configure how the plugin checks for, downloads, and applies live updates.
|
|
50
|
+
*
|
|
51
|
+
* The plugin checks for updates when the app moves to the foreground. When
|
|
52
|
+
* {@link periodCheckDelay} is greater than 0, it also checks on a repeating timer
|
|
53
|
+
* while the app stays open.
|
|
47
54
|
*
|
|
48
55
|
* Boolean values keep their existing behavior:
|
|
49
56
|
* - `true`: Same as `"atBackground"`.
|
|
50
57
|
* - `false`: Same as `"off"`.
|
|
51
58
|
*
|
|
52
59
|
* String values merge the previous Auto Update and Direct Update configuration:
|
|
53
|
-
* - `"off"`: Disable
|
|
54
|
-
* - `"atBackground"`: Check and download
|
|
55
|
-
* - `"atInstall"`:
|
|
56
|
-
* - `"onLaunch"`:
|
|
57
|
-
* - `"always"`:
|
|
58
|
-
* - `"onlyDownload"`: Check and download
|
|
60
|
+
* - `"off"`: Disable automatic update checks.
|
|
61
|
+
* - `"atBackground"`: Check and download automatically on each foreground check, then apply the update the next time the app moves to background.
|
|
62
|
+
* - `"atInstall"`: Apply immediately only after a fresh install or native app store update; otherwise use `"atBackground"` behavior.
|
|
63
|
+
* - `"onLaunch"`: Apply immediately only when the app is brought to the foreground from a killed state (cold start). After that first check, fall back to `"atBackground"` behavior.
|
|
64
|
+
* - `"always"`: Check on every foreground transition and apply immediately whenever an update is available.
|
|
65
|
+
* - `"onlyDownload"`: Check and download automatically, emit `updateAvailable`, and never set the next bundle or apply an update automatically.
|
|
59
66
|
*
|
|
60
|
-
*
|
|
67
|
+
* Instant apply modes (`"atInstall"`, `"onLaunch"`, `"always"`) apply while the user is waiting.
|
|
68
|
+
* Upload with `npx @capgo/cli@latest bundle upload --delta` so only changed files download. A full zip upload slows the user experience.
|
|
69
|
+
* These modes require `autoSplashscreen: true` and `a splash screen plugin` installed with `launchAutoHide: false`.
|
|
61
70
|
*
|
|
62
71
|
* Only available for Android and iOS.
|
|
63
72
|
*
|
|
@@ -99,7 +108,8 @@ export interface CordovaUpdaterConfig {
|
|
|
99
108
|
* Native stats include update lifecycle events, app health signals such as crashes,
|
|
100
109
|
* Android ANRs, low-memory exits, iOS memory warnings, and WebView health signals
|
|
101
110
|
* such as JavaScript errors, unhandled promise rejections, resource load failures,
|
|
102
|
-
* WebView renderer exits,
|
|
111
|
+
* WebView renderer exits, unclean WebView restarts, app launch readiness timing,
|
|
112
|
+
* and WebView load milestones when available.
|
|
103
113
|
*
|
|
104
114
|
* @default https://plugin.capgo.app/stats
|
|
105
115
|
* @example https://example.com/api/stats
|
|
@@ -126,17 +136,17 @@ export interface CordovaUpdaterConfig {
|
|
|
126
136
|
version?: string;
|
|
127
137
|
/**
|
|
128
138
|
* Configure when the plugin should direct install updates. Only for autoUpdate mode.
|
|
129
|
-
*
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
* -
|
|
134
|
-
* -
|
|
135
|
-
* -
|
|
136
|
-
* - always: Direct update in all previous cases (app installed, updated from store, after app kill or app resume), never act as directUpdate = false
|
|
139
|
+
* 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.
|
|
140
|
+
* These modes require `autoSplashscreen: true` and `a splash screen plugin` installed with `launchAutoHide: false`.
|
|
141
|
+
* This flag makes the CLI upload delta in CI and ask for confirmation in local uploads.
|
|
142
|
+
* - false: Never do direct updates
|
|
143
|
+
* - atInstall: Same as `"atInstall"` for {@link autoUpdate}
|
|
144
|
+
* - onLaunch: Same as `"onLaunch"` for {@link autoUpdate}
|
|
145
|
+
* - always: Same as `"always"` for {@link autoUpdate}
|
|
137
146
|
* - true: (deprecated) Same as "always" for backward compatibility
|
|
138
147
|
*
|
|
139
|
-
*
|
|
148
|
+
* @deprecated Use {@link CordovaUpdaterConfig.options.autoUpdate} string modes instead.
|
|
149
|
+
*
|
|
140
150
|
* Only available for Android and iOS.
|
|
141
151
|
*
|
|
142
152
|
* @default false
|
|
@@ -144,11 +154,10 @@ export interface CordovaUpdaterConfig {
|
|
|
144
154
|
*/
|
|
145
155
|
directUpdate?: boolean | 'atInstall' | 'always' | 'onLaunch';
|
|
146
156
|
/**
|
|
147
|
-
* Automatically
|
|
157
|
+
* Automatically hide the splashscreen after instant apply updates finish, or when no update is needed.
|
|
158
|
+
* Required when using instant apply modes (`"atInstall"`, `"onLaunch"`, `"always"`), including the deprecated `directUpdate` values `"atInstall"`, `"onLaunch"`, `"always"`, and `true`.
|
|
159
|
+
* `a splash screen plugin` must be installed and configured with `launchAutoHide: false`.
|
|
148
160
|
* This removes the need to manually listen for appReady events and call SplashScreen.hide().
|
|
149
|
-
* **Required** when `autoUpdate` is set to `"atInstall"`, `"onLaunch"`, or `"always"` (legacy `directUpdate` instant modes included). Without this option and the splash-screen plugin below, instant apply can leave users on a blank screen or dismiss the splash before the update finishes.
|
|
150
|
-
* Requires the @capacitor/splash-screen plugin to be installed and configured with launchAutoHide: false.
|
|
151
|
-
* Requires Auto Update and instant apply behavior to be enabled.
|
|
152
161
|
*
|
|
153
162
|
* Only available for Android and iOS.
|
|
154
163
|
*
|
|
@@ -159,7 +168,7 @@ export interface CordovaUpdaterConfig {
|
|
|
159
168
|
/**
|
|
160
169
|
* Display a native loading indicator on top of the splashscreen while automatic direct updates are running.
|
|
161
170
|
* Only takes effect when {@link autoSplashscreen} is enabled.
|
|
162
|
-
* Requires
|
|
171
|
+
* Requires a splash screen plugin to be installed and configured with launchAutoHide: false.
|
|
163
172
|
*
|
|
164
173
|
* Only available for Android and iOS.
|
|
165
174
|
*
|
|
@@ -181,7 +190,8 @@ export interface CordovaUpdaterConfig {
|
|
|
181
190
|
*/
|
|
182
191
|
autoSplashscreenTimeout?: number;
|
|
183
192
|
/**
|
|
184
|
-
* Configure the
|
|
193
|
+
* Configure the interval in seconds for repeating update checks while the app stays open.
|
|
194
|
+
* Foreground checks still run when this is 0. Values below 600 are normalized to 600.
|
|
185
195
|
*
|
|
186
196
|
* Only available for Android and iOS.
|
|
187
197
|
* Cannot be less than 600 seconds (10 minutes).
|
|
@@ -255,6 +265,20 @@ export interface CordovaUpdaterConfig {
|
|
|
255
265
|
* @since 5.4.0
|
|
256
266
|
*/
|
|
257
267
|
allowModifyUrl?: boolean;
|
|
268
|
+
/**
|
|
269
|
+
* Allow the plugin to follow redirects from HTTPS to plain HTTP for its own network requests
|
|
270
|
+
* (update checks, stats, channel calls, and bundle/manifest downloads).
|
|
271
|
+
*
|
|
272
|
+
* Blocked by default so a redirect can never downgrade updater traffic to an unencrypted connection.
|
|
273
|
+
* Only enable this if your self-hosted update server or CDN must redirect to an HTTP URL.
|
|
274
|
+
* Direct HTTP URLs (for example `localApi` during development) are not affected.
|
|
275
|
+
*
|
|
276
|
+
* Only available for Android and iOS.
|
|
277
|
+
*
|
|
278
|
+
* @default false
|
|
279
|
+
* @since 8.52.0
|
|
280
|
+
*/
|
|
281
|
+
allowHttpsToHttpRedirect?: boolean;
|
|
258
282
|
/**
|
|
259
283
|
* Allow the plugin to modify the appId dynamically from the JavaScript side.
|
|
260
284
|
*
|
|
@@ -265,7 +289,7 @@ export interface CordovaUpdaterConfig {
|
|
|
265
289
|
allowModifyAppId?: boolean;
|
|
266
290
|
/**
|
|
267
291
|
* Allow marking bundles as errored from JavaScript while using manual update flows.
|
|
268
|
-
* When enabled, {@link
|
|
292
|
+
* When enabled, {@link CordovaUpdaterPlugin.setBundleError} can change a bundle status to `error`.
|
|
269
293
|
*
|
|
270
294
|
* @default false
|
|
271
295
|
* @since 7.20.0
|
|
@@ -282,7 +306,7 @@ export interface CordovaUpdaterConfig {
|
|
|
282
306
|
*/
|
|
283
307
|
allowPreview?: boolean;
|
|
284
308
|
/**
|
|
285
|
-
* Persist the customId set through {@link
|
|
309
|
+
* Persist the customId set through {@link CordovaUpdaterPlugin.setCustomId} across app restarts.
|
|
286
310
|
*
|
|
287
311
|
* Only available for Android and iOS.
|
|
288
312
|
*
|
|
@@ -291,8 +315,8 @@ export interface CordovaUpdaterConfig {
|
|
|
291
315
|
*/
|
|
292
316
|
persistCustomId?: boolean;
|
|
293
317
|
/**
|
|
294
|
-
* Persist the updateUrl, statsUrl and channelUrl set through {@link
|
|
295
|
-
* {@link
|
|
318
|
+
* Persist the updateUrl, statsUrl and channelUrl set through {@link CordovaUpdaterPlugin.setUpdateUrl},
|
|
319
|
+
* {@link CordovaUpdaterPlugin.setStatsUrl} and {@link CordovaUpdaterPlugin.setChannelUrl} across app restarts.
|
|
296
320
|
*
|
|
297
321
|
* Only available for Android and iOS.
|
|
298
322
|
*
|
|
@@ -301,7 +325,7 @@ export interface CordovaUpdaterConfig {
|
|
|
301
325
|
*/
|
|
302
326
|
persistModifyUrl?: boolean;
|
|
303
327
|
/**
|
|
304
|
-
* Allow or disallow the {@link
|
|
328
|
+
* Allow or disallow the {@link CordovaUpdaterPlugin.setChannel} method to modify the defaultChannel.
|
|
305
329
|
* When set to `false`, calling `setChannel()` will return an error with code `disabled_by_config`.
|
|
306
330
|
*
|
|
307
331
|
* @default true
|
|
@@ -309,8 +333,8 @@ export interface CordovaUpdaterConfig {
|
|
|
309
333
|
*/
|
|
310
334
|
allowSetDefaultChannel?: boolean;
|
|
311
335
|
/**
|
|
312
|
-
* Keep the default channel stored by {@link
|
|
313
|
-
* {@link
|
|
336
|
+
* Keep the default channel stored by {@link CordovaUpdaterPlugin.setChannel} or refreshed by
|
|
337
|
+
* {@link CordovaUpdaterPlugin.getChannel} when app data is restored into a new app install.
|
|
314
338
|
*
|
|
315
339
|
* `setChannel()` and a successful `getChannel()` still persist the selected channel across app
|
|
316
340
|
* restarts. When this option is `false`, native startup clears that persisted channel when it
|
|
@@ -373,7 +397,7 @@ export interface CordovaUpdaterConfig {
|
|
|
373
397
|
/**
|
|
374
398
|
* Enable the native preview menu gesture while a preview session is active.
|
|
375
399
|
* Outside preview sessions this preview menu is ignored, unless
|
|
376
|
-
* {@link
|
|
400
|
+
* {@link CordovaUpdaterConfig.options.allowShakeChannelSelector} is enabled.
|
|
377
401
|
*
|
|
378
402
|
* @default false
|
|
379
403
|
* @since 7.5.0
|
|
@@ -381,8 +405,8 @@ export interface CordovaUpdaterConfig {
|
|
|
381
405
|
shakeMenu?: boolean;
|
|
382
406
|
/**
|
|
383
407
|
* Choose which native gesture opens the preview/channel menu.
|
|
384
|
-
* This applies to both {@link
|
|
385
|
-
* and {@link
|
|
408
|
+
* This applies to both {@link CordovaUpdaterConfig.options.shakeMenu}
|
|
409
|
+
* and {@link CordovaUpdaterConfig.options.allowShakeChannelSelector}.
|
|
386
410
|
*
|
|
387
411
|
* Only available for Android and iOS.
|
|
388
412
|
*
|
|
@@ -392,9 +416,9 @@ export interface CordovaUpdaterConfig {
|
|
|
392
416
|
shakeMenuGesture?: ShakeMenuGesture;
|
|
393
417
|
/**
|
|
394
418
|
* Enable the native menu gesture to show a channel selector menu for switching between update channels.
|
|
395
|
-
* If {@link
|
|
419
|
+
* If {@link CordovaUpdaterConfig.options.shakeMenu} is also enabled while a preview session is active,
|
|
396
420
|
* the shake menu includes both preview actions and channel switching.
|
|
397
|
-
* The native gesture can be changed with {@link
|
|
421
|
+
* The native gesture can be changed with {@link CordovaUpdaterConfig.options.shakeMenuGesture}.
|
|
398
422
|
*
|
|
399
423
|
* Only available for Android and iOS.
|
|
400
424
|
*
|
|
@@ -404,7 +428,7 @@ export interface CordovaUpdaterConfig {
|
|
|
404
428
|
allowShakeChannelSelector?: boolean;
|
|
405
429
|
};
|
|
406
430
|
}
|
|
407
|
-
export interface
|
|
431
|
+
export interface CordovaUpdaterPlugin {
|
|
408
432
|
/**
|
|
409
433
|
* Notify the native layer that JavaScript initialized successfully.
|
|
410
434
|
*
|
|
@@ -431,7 +455,7 @@ export interface UpdaterPlugin {
|
|
|
431
455
|
* - Call immediately in your app entry point (main.js, app component mount, etc.)
|
|
432
456
|
* - Don't put it after network calls or heavy initialization
|
|
433
457
|
* - Don't wrap it in try/catch with conditions
|
|
434
|
-
* - Adjust {@link
|
|
458
|
+
* - Adjust {@link CordovaUpdaterConfig.options.appReadyTimeout} if you need more time
|
|
435
459
|
*
|
|
436
460
|
* @returns {Promise<AppReadyResult>} Always resolves successfully with current bundle info. This method never fails.
|
|
437
461
|
*/
|
|
@@ -439,10 +463,10 @@ export interface UpdaterPlugin {
|
|
|
439
463
|
/**
|
|
440
464
|
* Set the update URL for the app dynamically at runtime.
|
|
441
465
|
*
|
|
442
|
-
* This overrides the {@link
|
|
443
|
-
* Requires {@link
|
|
466
|
+
* This overrides the {@link CordovaUpdaterConfig.options.updateUrl} config value.
|
|
467
|
+
* Requires {@link CordovaUpdaterConfig.options.allowModifyUrl} to be set to `true`.
|
|
444
468
|
*
|
|
445
|
-
* Use {@link
|
|
469
|
+
* Use {@link CordovaUpdaterConfig.options.persistModifyUrl} to persist this value across app restarts.
|
|
446
470
|
* Otherwise, the URL will reset to the config value on next app launch.
|
|
447
471
|
*
|
|
448
472
|
* @param options Contains the URL to use for checking for updates.
|
|
@@ -454,11 +478,11 @@ export interface UpdaterPlugin {
|
|
|
454
478
|
/**
|
|
455
479
|
* Set the statistics URL for the app dynamically at runtime.
|
|
456
480
|
*
|
|
457
|
-
* This overrides the {@link
|
|
458
|
-
* Requires {@link
|
|
481
|
+
* This overrides the {@link CordovaUpdaterConfig.options.statsUrl} config value.
|
|
482
|
+
* Requires {@link CordovaUpdaterConfig.options.allowModifyUrl} to be set to `true`.
|
|
459
483
|
*
|
|
460
484
|
* Pass an empty string to disable statistics gathering entirely.
|
|
461
|
-
* Use {@link
|
|
485
|
+
* Use {@link CordovaUpdaterConfig.options.persistModifyUrl} to persist this value across app restarts.
|
|
462
486
|
*
|
|
463
487
|
* @param options Contains the URL to use for sending statistics, or an empty string to disable.
|
|
464
488
|
* @returns {Promise<void>} Resolves when the URL is successfully updated.
|
|
@@ -469,10 +493,10 @@ export interface UpdaterPlugin {
|
|
|
469
493
|
/**
|
|
470
494
|
* Set the channel URL for the app dynamically at runtime.
|
|
471
495
|
*
|
|
472
|
-
* This overrides the {@link
|
|
473
|
-
* Requires {@link
|
|
496
|
+
* This overrides the {@link CordovaUpdaterConfig.options.channelUrl} config value.
|
|
497
|
+
* Requires {@link CordovaUpdaterConfig.options.allowModifyUrl} to be set to `true`.
|
|
474
498
|
*
|
|
475
|
-
* Use {@link
|
|
499
|
+
* Use {@link CordovaUpdaterConfig.options.persistModifyUrl} to persist this value across app restarts.
|
|
476
500
|
* Otherwise, the URL will reset to the config value on next app launch.
|
|
477
501
|
*
|
|
478
502
|
* @param options Contains the URL to use for channel operations.
|
|
@@ -500,7 +524,9 @@ export interface UpdaterPlugin {
|
|
|
500
524
|
* **Android Background Runner note:** `@capacitor/background-runner` loads its
|
|
501
525
|
* configured runner script from native APK assets. Live updates cannot replace
|
|
502
526
|
* that runner script. Keep it stable across OTA updates and ship a native app
|
|
503
|
-
* update when the runner code changes.
|
|
527
|
+
* update when the runner code changes. When a bundle switch happens, Capacitor
|
|
528
|
+
* Updater cancels and reschedules configured Background Runner WorkManager jobs
|
|
529
|
+
* and syncs the bundled runner script into native `public/` storage when present.
|
|
504
530
|
*
|
|
505
531
|
* @example
|
|
506
532
|
* const bundle = await CapacitorUpdater.download({
|
|
@@ -548,7 +574,7 @@ export interface UpdaterPlugin {
|
|
|
548
574
|
* - Event listeners registered after this call are unreliable and may never fire
|
|
549
575
|
*
|
|
550
576
|
* The reload happens automatically - you don't need to do anything else.
|
|
551
|
-
* If you need to preserve state like the current URL path, use the {@link
|
|
577
|
+
* If you need to preserve state like the current URL path, use the {@link CordovaUpdaterConfig.options.keepUrlPathAfterReload} config option.
|
|
552
578
|
* For other state preservation needs, save your data before calling this method (e.g., to localStorage).
|
|
553
579
|
*
|
|
554
580
|
* **Do not** try to execute additional logic after calling `set()` - it won't work as expected.
|
|
@@ -564,7 +590,7 @@ export interface UpdaterPlugin {
|
|
|
564
590
|
* This stores the currently active bundle as the pending fallback, enables the
|
|
565
591
|
* native shake menu, and makes the next applied bundle show a native notice
|
|
566
592
|
* explaining that shaking the device can reload or leave the preview.
|
|
567
|
-
* Requires {@link
|
|
593
|
+
* Requires {@link CordovaUpdaterConfig.options.allowPreview} to be `true`.
|
|
568
594
|
* When `appId` is provided, the preview session temporarily uses that app id
|
|
569
595
|
* for update checks until the user leaves the preview. Native updater stats are
|
|
570
596
|
* skipped while the preview session is active.
|
|
@@ -680,7 +706,7 @@ export interface UpdaterPlugin {
|
|
|
680
706
|
* will avoid using this bundle in the future.
|
|
681
707
|
*
|
|
682
708
|
* **Requirements:**
|
|
683
|
-
* - {@link
|
|
709
|
+
* - {@link CordovaUpdaterConfig.options.allowManualBundleError} must be set to `true`
|
|
684
710
|
* - Only works in manual update mode (when autoUpdate is disabled)
|
|
685
711
|
*
|
|
686
712
|
* Common use case: After downloading and testing a bundle, you discover it has critical
|
|
@@ -957,9 +983,9 @@ export interface UpdaterPlugin {
|
|
|
957
983
|
* (e.g., "production", "beta", "staging"). This method switches the device to a new channel.
|
|
958
984
|
*
|
|
959
985
|
* **Device Override UI:** `setChannel()` validates the channel with the backend, then stores the
|
|
960
|
-
* selected channel locally on the device. It does not create or update
|
|
961
|
-
* so the device will not appear as overridden in the Capgo dashboard.
|
|
962
|
-
* from the dashboard or the Public API are shown in the Device Override UI.
|
|
986
|
+
* selected channel locally on the device for future app restarts. It does not create or update
|
|
987
|
+
* a backend Device Override, so the device will not appear as overridden in the Capgo dashboard.
|
|
988
|
+
* Only assignments created from the dashboard or the Public API are shown in the Device Override UI.
|
|
963
989
|
*
|
|
964
990
|
* **Requirements:**
|
|
965
991
|
* - The target channel must allow self-assignment (configured in your Capgo dashboard or backend)
|
|
@@ -971,7 +997,7 @@ export interface UpdaterPlugin {
|
|
|
971
997
|
* - For user-driven channel changes
|
|
972
998
|
*
|
|
973
999
|
* **When NOT to use:**
|
|
974
|
-
* - At app boot/initialization - use {@link
|
|
1000
|
+
* - At app boot/initialization - use {@link CordovaUpdaterConfig.options.defaultChannel} config instead
|
|
975
1001
|
* - Before user interaction
|
|
976
1002
|
*
|
|
977
1003
|
* **Important: Listen for the `channelPrivate` event**
|
|
@@ -988,7 +1014,7 @@ export interface UpdaterPlugin {
|
|
|
988
1014
|
* ```
|
|
989
1015
|
*
|
|
990
1016
|
* This sends a request to the Capgo backend to validate the specified channel, then stores the
|
|
991
|
-
* channel locally on the device.
|
|
1017
|
+
* channel locally on the device for future app restarts.
|
|
992
1018
|
*
|
|
993
1019
|
* @param options The {@link SetChannelOptions} containing the channel name and optional auto-update trigger.
|
|
994
1020
|
* @returns {Promise<ChannelRes>} Channel operation result with status and optional error/message.
|
|
@@ -1001,7 +1027,7 @@ export interface UpdaterPlugin {
|
|
|
1001
1027
|
*
|
|
1002
1028
|
* This clears only the channel stored locally by {@link setChannel}; it does not delete Dashboard or Public API Device Override records. After the local assignment is cleared, normal channel precedence applies:
|
|
1003
1029
|
* - An existing Dashboard or Public API Device Override, if one exists
|
|
1004
|
-
* - The {@link
|
|
1030
|
+
* - The {@link CordovaUpdaterConfig.options.defaultChannel} if configured, or
|
|
1005
1031
|
* - Your backend default channel for this app
|
|
1006
1032
|
*
|
|
1007
1033
|
* Use this when:
|
|
@@ -1029,8 +1055,8 @@ export interface UpdaterPlugin {
|
|
|
1029
1055
|
* - Check if a device is on a specific channel before showing features
|
|
1030
1056
|
* - Verify channel assignment after calling {@link setChannel}
|
|
1031
1057
|
*
|
|
1032
|
-
* On native platforms, a successful response also refreshes the
|
|
1033
|
-
*
|
|
1058
|
+
* On native platforms, a successful response also refreshes the default channel used by update checks.
|
|
1059
|
+
* This refresh is persisted across app restarts.
|
|
1034
1060
|
*
|
|
1035
1061
|
* @returns {Promise<GetChannelRes>} The current channel information.
|
|
1036
1062
|
* @throws {Error} If the operation fails.
|
|
@@ -1071,7 +1097,7 @@ export interface UpdaterPlugin {
|
|
|
1071
1097
|
* - A/B testing or feature flagging
|
|
1072
1098
|
*
|
|
1073
1099
|
* **Persistence:**
|
|
1074
|
-
* - When {@link
|
|
1100
|
+
* - When {@link CordovaUpdaterConfig.options.persistCustomId} is `true`, the ID persists across app restarts
|
|
1075
1101
|
* - When `false`, the ID is only kept for the current session
|
|
1076
1102
|
*
|
|
1077
1103
|
* **Clearing the custom ID:**
|
|
@@ -1091,7 +1117,7 @@ export interface UpdaterPlugin {
|
|
|
1091
1117
|
* use {@link current} for that.
|
|
1092
1118
|
*
|
|
1093
1119
|
* Returns:
|
|
1094
|
-
* - The {@link
|
|
1120
|
+
* - The {@link CordovaUpdaterConfig.options.version} config value if set, or
|
|
1095
1121
|
* - The native app version from platform configs (package.json, Info.plist, build.gradle)
|
|
1096
1122
|
*
|
|
1097
1123
|
* Use this to:
|
|
@@ -1153,7 +1179,7 @@ export interface UpdaterPlugin {
|
|
|
1153
1179
|
/**
|
|
1154
1180
|
* Check if automatic updates are currently enabled.
|
|
1155
1181
|
*
|
|
1156
|
-
* Returns `true` if {@link
|
|
1182
|
+
* Returns `true` if {@link CordovaUpdaterConfig.options.autoUpdate} is enabled,
|
|
1157
1183
|
* meaning the plugin will automatically check for, download, and apply updates.
|
|
1158
1184
|
*
|
|
1159
1185
|
* Returns `false` if in manual mode, where you control the update flow using
|
|
@@ -1386,15 +1412,15 @@ export interface UpdaterPlugin {
|
|
|
1386
1412
|
* During preview sessions, users can use the configured native gesture to:
|
|
1387
1413
|
* - Reload the current preview
|
|
1388
1414
|
* - Leave the test app and return to the fallback bundle
|
|
1389
|
-
* - Switch update channel, when {@link
|
|
1415
|
+
* - Switch update channel, when {@link CordovaUpdaterConfig.options.allowShakeChannelSelector} is also enabled
|
|
1390
1416
|
*
|
|
1391
1417
|
* Outside preview sessions, this preview menu is ignored. The channel selector can still be
|
|
1392
|
-
* shown outside preview sessions when {@link
|
|
1418
|
+
* shown outside preview sessions when {@link CordovaUpdaterConfig.options.allowShakeChannelSelector} is enabled.
|
|
1393
1419
|
*
|
|
1394
1420
|
* **Important:** Disable this in production builds or only enable for internal testers.
|
|
1395
1421
|
*
|
|
1396
|
-
* This can also be configured via {@link
|
|
1397
|
-
* The native gesture is configured via {@link
|
|
1422
|
+
* This can also be configured via {@link CordovaUpdaterConfig.options.shakeMenu}.
|
|
1423
|
+
* The native gesture is configured via {@link CordovaUpdaterConfig.options.shakeMenuGesture}.
|
|
1398
1424
|
*
|
|
1399
1425
|
* @param options {@link SetShakeMenuOptions} with `enabled: true` to enable or `enabled: false` to disable.
|
|
1400
1426
|
* @returns {Promise<void>} Resolves when the setting is applied.
|
|
@@ -1406,7 +1432,7 @@ export interface UpdaterPlugin {
|
|
|
1406
1432
|
* Check if the native preview menu gesture is currently enabled.
|
|
1407
1433
|
*
|
|
1408
1434
|
* Returns the current state of the shake menu feature that can be toggled via
|
|
1409
|
-
* {@link setShakeMenu} or configured via {@link
|
|
1435
|
+
* {@link setShakeMenu} or configured via {@link CordovaUpdaterConfig.options.shakeMenu}.
|
|
1410
1436
|
*
|
|
1411
1437
|
* Use this to:
|
|
1412
1438
|
* - Check if debug features are enabled
|
|
@@ -1425,8 +1451,8 @@ export interface UpdaterPlugin {
|
|
|
1425
1451
|
* If {@link setShakeMenu} is also enabled while a preview session is active, the shake menu includes
|
|
1426
1452
|
* both preview actions and channel switching.
|
|
1427
1453
|
*
|
|
1428
|
-
* This can also be configured via {@link
|
|
1429
|
-
* The native gesture is configured via {@link
|
|
1454
|
+
* This can also be configured via {@link CordovaUpdaterConfig.options.allowShakeChannelSelector}.
|
|
1455
|
+
* The native gesture is configured via {@link CordovaUpdaterConfig.options.shakeMenuGesture}.
|
|
1430
1456
|
*
|
|
1431
1457
|
* @param options {@link SetShakeChannelSelectorOptions} with `enabled: true` to enable or `enabled: false` to disable.
|
|
1432
1458
|
* @returns {Promise<void>} Resolves when the setting is applied.
|
|
@@ -1438,7 +1464,7 @@ export interface UpdaterPlugin {
|
|
|
1438
1464
|
* Check if the shake channel selector is currently enabled.
|
|
1439
1465
|
*
|
|
1440
1466
|
* Returns the current state of the shake channel selector feature that can be toggled via
|
|
1441
|
-
* {@link setShakeChannelSelector} or configured via {@link
|
|
1467
|
+
* {@link setShakeChannelSelector} or configured via {@link CordovaUpdaterConfig.options.allowShakeChannelSelector}.
|
|
1442
1468
|
*
|
|
1443
1469
|
* @returns {Promise<ShakeChannelSelectorEnabled>} Object with `enabled: true` or `enabled: false`.
|
|
1444
1470
|
* @throws {Error} If the operation fails.
|
|
@@ -1450,7 +1476,7 @@ export interface UpdaterPlugin {
|
|
|
1450
1476
|
*
|
|
1451
1477
|
* Returns the App ID that identifies this app to the update server. This can be:
|
|
1452
1478
|
* - The value set via {@link setAppId}, or
|
|
1453
|
-
* - The {@link
|
|
1479
|
+
* - The {@link CordovaUpdaterConfig.options.appId} config value, or
|
|
1454
1480
|
* - The default app identifier from your native app configuration
|
|
1455
1481
|
*
|
|
1456
1482
|
* Use this to:
|
|
@@ -1472,13 +1498,13 @@ export interface UpdaterPlugin {
|
|
|
1472
1498
|
* app IDs, or multi-tenant configurations).
|
|
1473
1499
|
*
|
|
1474
1500
|
* **Requirements:**
|
|
1475
|
-
* - {@link
|
|
1501
|
+
* - {@link CordovaUpdaterConfig.options.allowModifyAppId} must be set to `true`
|
|
1476
1502
|
*
|
|
1477
1503
|
* **Important considerations:**
|
|
1478
1504
|
* - Changing the App ID will affect which updates this device receives
|
|
1479
1505
|
* - The new App ID must exist on your update server
|
|
1480
1506
|
* - This is primarily for advanced use cases (multi-tenancy, environment switching)
|
|
1481
|
-
* - Most apps should use the config-based {@link
|
|
1507
|
+
* - Most apps should use the config-based {@link CordovaUpdaterConfig.options.appId} instead
|
|
1482
1508
|
*
|
|
1483
1509
|
* @param options {@link SetAppIdOptions} containing the new App ID string.
|
|
1484
1510
|
* @returns {Promise<void>} Resolves when the App ID is successfully changed.
|
|
@@ -1608,13 +1634,17 @@ export interface UpdaterPlugin {
|
|
|
1608
1634
|
*/
|
|
1609
1635
|
completeFlexibleUpdate(): Promise<void>;
|
|
1610
1636
|
}
|
|
1637
|
+
/** @deprecated Use {@link CordovaUpdaterPlugin}. */
|
|
1638
|
+
export type UpdaterPlugin = CordovaUpdaterPlugin;
|
|
1611
1639
|
/**
|
|
1612
1640
|
* pending: The bundle is pending to be **SET** as the next bundle.
|
|
1613
1641
|
* downloading: The bundle is being downloaded.
|
|
1614
1642
|
* success: The bundle has been downloaded and is ready to be **SET** as the next bundle.
|
|
1615
1643
|
* error: The bundle has failed to download.
|
|
1644
|
+
* deleted: The bundle was removed from disk and is no longer available.
|
|
1645
|
+
* deleting: The bundle is being removed from disk.
|
|
1616
1646
|
*/
|
|
1617
|
-
export type BundleStatus = 'success' | 'error' | 'pending' | 'downloading';
|
|
1647
|
+
export type BundleStatus = 'success' | 'error' | 'pending' | 'downloading' | 'deleted' | 'deleting';
|
|
1618
1648
|
export type DelayUntilNext = 'background' | 'kill' | 'nativeVersion' | 'date';
|
|
1619
1649
|
/**
|
|
1620
1650
|
* Classification for update-check responses that do not provide a downloadable bundle.
|
|
@@ -1753,7 +1783,7 @@ export interface MajorAvailableEvent {
|
|
|
1753
1783
|
version: string;
|
|
1754
1784
|
}
|
|
1755
1785
|
/**
|
|
1756
|
-
* Payload emitted by {@link
|
|
1786
|
+
* Payload emitted by {@link CordovaUpdaterPlugin.addListener} with `breakingAvailable`.
|
|
1757
1787
|
*
|
|
1758
1788
|
* @since 7.22.0
|
|
1759
1789
|
*/
|
|
@@ -2065,7 +2095,7 @@ export interface GetLatestOptions {
|
|
|
2065
2095
|
/**
|
|
2066
2096
|
* Temporarily use another app id for this update check while using a trusted preview container.
|
|
2067
2097
|
* This only changes the app id sent by this request; it does not persist a preview session.
|
|
2068
|
-
* Requires {@link
|
|
2098
|
+
* Requires {@link CordovaUpdaterConfig.options.allowPreview} to be `true`.
|
|
2069
2099
|
* @since 8.47.0
|
|
2070
2100
|
* @default undefined
|
|
2071
2101
|
*/
|
|
@@ -2087,7 +2117,7 @@ export interface StartPreviewSessionOptions {
|
|
|
2087
2117
|
/**
|
|
2088
2118
|
* App id to use while the preview session is active.
|
|
2089
2119
|
* The previous app id is restored when leaving the preview session.
|
|
2090
|
-
* Requires {@link
|
|
2120
|
+
* Requires {@link CordovaUpdaterConfig.options.allowPreview} to be `true`.
|
|
2091
2121
|
* @since 8.47.0
|
|
2092
2122
|
* @default undefined
|
|
2093
2123
|
*/
|
|
@@ -2096,7 +2126,7 @@ export interface StartPreviewSessionOptions {
|
|
|
2096
2126
|
* HTTP(S) URL returning a preview download payload.
|
|
2097
2127
|
* When provided, the native shake reload action fetches this payload again
|
|
2098
2128
|
* before reloading so channel previews can move to the latest bundle.
|
|
2099
|
-
* Requires {@link
|
|
2129
|
+
* Requires {@link CordovaUpdaterConfig.options.allowPreview} to be `true`.
|
|
2100
2130
|
* @since 8.48.0
|
|
2101
2131
|
* @default undefined
|
|
2102
2132
|
*/
|
|
@@ -2401,7 +2431,7 @@ export interface SetAppIdOptions {
|
|
|
2401
2431
|
appId: string;
|
|
2402
2432
|
}
|
|
2403
2433
|
/**
|
|
2404
|
-
* Options for {@link
|
|
2434
|
+
* Options for {@link CordovaUpdaterPlugin.getAppUpdateInfo}.
|
|
2405
2435
|
*
|
|
2406
2436
|
* @since 8.0.0
|
|
2407
2437
|
*/
|
|
@@ -2478,7 +2508,7 @@ export interface AppUpdateInfo {
|
|
|
2478
2508
|
/**
|
|
2479
2509
|
* Whether an immediate update is allowed (Android only).
|
|
2480
2510
|
*
|
|
2481
|
-
* If `true`, you can call {@link
|
|
2511
|
+
* If `true`, you can call {@link CordovaUpdaterPlugin.performImmediateUpdate}.
|
|
2482
2512
|
*
|
|
2483
2513
|
* @since 8.0.0
|
|
2484
2514
|
*/
|
|
@@ -2486,7 +2516,7 @@ export interface AppUpdateInfo {
|
|
|
2486
2516
|
/**
|
|
2487
2517
|
* Whether a flexible update is allowed (Android only).
|
|
2488
2518
|
*
|
|
2489
|
-
* If `true`, you can call {@link
|
|
2519
|
+
* If `true`, you can call {@link CordovaUpdaterPlugin.startFlexibleUpdate}.
|
|
2490
2520
|
*
|
|
2491
2521
|
* @since 8.0.0
|
|
2492
2522
|
*/
|
|
@@ -2514,7 +2544,7 @@ export interface AppUpdateInfo {
|
|
|
2514
2544
|
minimumOsVersion?: string;
|
|
2515
2545
|
}
|
|
2516
2546
|
/**
|
|
2517
|
-
* Options for {@link
|
|
2547
|
+
* Options for {@link CordovaUpdaterPlugin.openAppStore}.
|
|
2518
2548
|
*
|
|
2519
2549
|
* @since 8.0.0
|
|
2520
2550
|
*/
|
|
@@ -2645,7 +2675,7 @@ export declare enum FlexibleUpdateInstallStatus {
|
|
|
2645
2675
|
CANCELED = 6,
|
|
2646
2676
|
/**
|
|
2647
2677
|
* The update has been downloaded and is ready to install.
|
|
2648
|
-
* Call {@link
|
|
2678
|
+
* Call {@link CordovaUpdaterPlugin.completeFlexibleUpdate} to install.
|
|
2649
2679
|
*/
|
|
2650
2680
|
DOWNLOADED = 11
|
|
2651
2681
|
}
|
|
@@ -2678,7 +2708,7 @@ export declare enum AppUpdateResultCode {
|
|
|
2678
2708
|
NOT_ALLOWED = 4,
|
|
2679
2709
|
/**
|
|
2680
2710
|
* Required information is missing.
|
|
2681
|
-
* This can happen if {@link
|
|
2711
|
+
* This can happen if {@link CordovaUpdaterPlugin.getAppUpdateInfo} wasn't called first.
|
|
2682
2712
|
*/
|
|
2683
2713
|
INFO_MISSING = 5
|
|
2684
2714
|
}
|
package/dist/esm/definitions.js
CHANGED
|
@@ -68,7 +68,7 @@ export var FlexibleUpdateInstallStatus;
|
|
|
68
68
|
FlexibleUpdateInstallStatus[FlexibleUpdateInstallStatus["CANCELED"] = 6] = "CANCELED";
|
|
69
69
|
/**
|
|
70
70
|
* The update has been downloaded and is ready to install.
|
|
71
|
-
* Call {@link
|
|
71
|
+
* Call {@link CordovaUpdaterPlugin.completeFlexibleUpdate} to install.
|
|
72
72
|
*/
|
|
73
73
|
FlexibleUpdateInstallStatus[FlexibleUpdateInstallStatus["DOWNLOADED"] = 11] = "DOWNLOADED";
|
|
74
74
|
})(FlexibleUpdateInstallStatus || (FlexibleUpdateInstallStatus = {}));
|
|
@@ -102,7 +102,7 @@ export var AppUpdateResultCode;
|
|
|
102
102
|
AppUpdateResultCode[AppUpdateResultCode["NOT_ALLOWED"] = 4] = "NOT_ALLOWED";
|
|
103
103
|
/**
|
|
104
104
|
* Required information is missing.
|
|
105
|
-
* This can happen if {@link
|
|
105
|
+
* This can happen if {@link CordovaUpdaterPlugin.getAppUpdateInfo} wasn't called first.
|
|
106
106
|
*/
|
|
107
107
|
AppUpdateResultCode[AppUpdateResultCode["INFO_MISSING"] = 5] = "INFO_MISSING";
|
|
108
108
|
})(AppUpdateResultCode || (AppUpdateResultCode = {}));
|