@capgo/capacitor-updater 8.0.0 → 8.1.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 (64) hide show
  1. package/CapgoCapacitorUpdater.podspec +7 -5
  2. package/Package.swift +37 -0
  3. package/README.md +1461 -231
  4. package/android/build.gradle +29 -12
  5. package/android/proguard-rules.pro +45 -0
  6. package/android/src/main/AndroidManifest.xml +0 -1
  7. package/android/src/main/java/ee/forgr/capacitor_updater/BundleInfo.java +223 -195
  8. package/android/src/main/java/ee/forgr/capacitor_updater/BundleStatus.java +23 -23
  9. package/android/src/main/java/ee/forgr/capacitor_updater/Callback.java +13 -0
  10. package/android/src/main/java/ee/forgr/capacitor_updater/CapacitorUpdaterPlugin.java +2159 -1234
  11. package/android/src/main/java/ee/forgr/capacitor_updater/CapgoUpdater.java +1507 -0
  12. package/android/src/main/java/ee/forgr/capacitor_updater/CryptoCipher.java +330 -121
  13. package/android/src/main/java/ee/forgr/capacitor_updater/DataManager.java +28 -0
  14. package/android/src/main/java/ee/forgr/capacitor_updater/DelayCondition.java +43 -49
  15. package/android/src/main/java/ee/forgr/capacitor_updater/DelayUntilNext.java +4 -4
  16. package/android/src/main/java/ee/forgr/capacitor_updater/DelayUpdateUtils.java +260 -0
  17. package/android/src/main/java/ee/forgr/capacitor_updater/DeviceIdHelper.java +221 -0
  18. package/android/src/main/java/ee/forgr/capacitor_updater/DownloadService.java +808 -117
  19. package/android/src/main/java/ee/forgr/capacitor_updater/DownloadWorkerManager.java +156 -0
  20. package/android/src/main/java/ee/forgr/capacitor_updater/InternalUtils.java +32 -0
  21. package/android/src/main/java/ee/forgr/capacitor_updater/Logger.java +338 -0
  22. package/android/src/main/java/ee/forgr/capacitor_updater/ShakeDetector.java +72 -0
  23. package/android/src/main/java/ee/forgr/capacitor_updater/ShakeMenu.java +169 -0
  24. package/dist/docs.json +2187 -625
  25. package/dist/esm/definitions.d.ts +1286 -249
  26. package/dist/esm/definitions.js.map +1 -1
  27. package/dist/esm/history.d.ts +1 -0
  28. package/dist/esm/history.js +283 -0
  29. package/dist/esm/history.js.map +1 -0
  30. package/dist/esm/index.d.ts +3 -2
  31. package/dist/esm/index.js +5 -4
  32. package/dist/esm/index.js.map +1 -1
  33. package/dist/esm/web.d.ts +36 -41
  34. package/dist/esm/web.js +94 -35
  35. package/dist/esm/web.js.map +1 -1
  36. package/dist/plugin.cjs.js +376 -35
  37. package/dist/plugin.cjs.js.map +1 -1
  38. package/dist/plugin.js +376 -35
  39. package/dist/plugin.js.map +1 -1
  40. package/ios/Sources/CapacitorUpdaterPlugin/AES.swift +69 -0
  41. package/ios/Sources/CapacitorUpdaterPlugin/BigInt.swift +55 -0
  42. package/ios/{Plugin → Sources/CapacitorUpdaterPlugin}/BundleInfo.swift +37 -10
  43. package/ios/{Plugin → Sources/CapacitorUpdaterPlugin}/BundleStatus.swift +1 -1
  44. package/ios/Sources/CapacitorUpdaterPlugin/CapacitorUpdaterPlugin.swift +1605 -0
  45. package/ios/Sources/CapacitorUpdaterPlugin/CapgoUpdater.swift +1526 -0
  46. package/ios/Sources/CapacitorUpdaterPlugin/CryptoCipher.swift +267 -0
  47. package/ios/Sources/CapacitorUpdaterPlugin/DelayUpdateUtils.swift +220 -0
  48. package/ios/Sources/CapacitorUpdaterPlugin/DeviceIdHelper.swift +120 -0
  49. package/ios/Sources/CapacitorUpdaterPlugin/InternalUtils.swift +311 -0
  50. package/ios/Sources/CapacitorUpdaterPlugin/Logger.swift +310 -0
  51. package/ios/Sources/CapacitorUpdaterPlugin/RSA.swift +274 -0
  52. package/ios/Sources/CapacitorUpdaterPlugin/ShakeMenu.swift +112 -0
  53. package/ios/{Plugin → Sources/CapacitorUpdaterPlugin}/UserDefaultsExtension.swift +0 -2
  54. package/package.json +41 -35
  55. package/android/src/main/java/ee/forgr/capacitor_updater/CapacitorUpdater.java +0 -1130
  56. package/ios/Plugin/CapacitorUpdater.swift +0 -858
  57. package/ios/Plugin/CapacitorUpdaterPlugin.h +0 -10
  58. package/ios/Plugin/CapacitorUpdaterPlugin.m +0 -27
  59. package/ios/Plugin/CapacitorUpdaterPlugin.swift +0 -675
  60. package/ios/Plugin/CryptoCipher.swift +0 -240
  61. /package/{LICENCE → LICENSE} +0 -0
  62. /package/ios/{Plugin → Sources/CapacitorUpdaterPlugin}/DelayCondition.swift +0 -0
  63. /package/ios/{Plugin → Sources/CapacitorUpdaterPlugin}/DelayUntilNext.swift +0 -0
  64. /package/ios/{Plugin → Sources/CapacitorUpdaterPlugin}/Info.plist +0 -0
@@ -1,8 +1,8 @@
1
- import type { PluginListenerHandle } from "@capacitor/core";
2
- declare module "@capacitor/cli" {
1
+ import type { PluginListenerHandle } from '@capacitor/core';
2
+ declare module '@capacitor/cli' {
3
3
  interface PluginsConfig {
4
4
  /**
5
- * These configuration values are available:
5
+ * CapacitorUpdater can be configured with these options:
6
6
  */
7
7
  CapacitorUpdater?: {
8
8
  /**
@@ -14,6 +14,15 @@ declare module "@capacitor/cli" {
14
14
  * @example 1000 // (1 second)
15
15
  */
16
16
  appReadyTimeout?: number;
17
+ /**
18
+ * Configure the number of seconds the native plugin should wait before considering API timeout.
19
+ *
20
+ * Only available for Android and iOS.
21
+ *
22
+ * @default 20 // (20 second)
23
+ * @example 10 // (10 second)
24
+ */
25
+ responseTimeout?: number;
17
26
  /**
18
27
  * Configure whether the plugin should use automatically delete failed bundles.
19
28
  *
@@ -43,7 +52,7 @@ declare module "@capacitor/cli" {
43
52
  autoUpdate?: boolean;
44
53
  /**
45
54
  * Automatically delete previous downloaded bundles when a newer native app bundle is installed to the device.
46
- *
55
+ * Setting this to false can broke the auto update flow if the user download from the store a native app bundle that is older than the current downloaded bundle. Upload will be prevented by channel setting downgrade_under_native.
47
56
  * Only available for Android and iOS.
48
57
  *
49
58
  * @default true
@@ -55,27 +64,37 @@ declare module "@capacitor/cli" {
55
64
  *
56
65
  * Only available for Android and iOS.
57
66
  *
58
- * @default https://api.capgo.app/auto_update
67
+ * @default https://plugin.capgo.app/updates
59
68
  * @example https://example.com/api/auto_update
60
69
  */
61
70
  updateUrl?: string;
71
+ /**
72
+ * Configure the URL / endpoint for channel operations.
73
+ *
74
+ * Only available for Android and iOS.
75
+ *
76
+ * @default https://plugin.capgo.app/channel_self
77
+ * @example https://example.com/api/channel
78
+ */
79
+ channelUrl?: string;
62
80
  /**
63
81
  * Configure the URL / endpoint to which update statistics are sent.
64
82
  *
65
83
  * Only available for Android and iOS. Set to "" to disable stats reporting.
66
84
  *
67
- * @default https://api.capgo.app/stats
85
+ * @default https://plugin.capgo.app/stats
68
86
  * @example https://example.com/api/stats
69
87
  */
70
88
  statsUrl?: string;
71
89
  /**
72
- * Configure the private key for end to end live update encryption.
90
+ * Configure the public key for end to end live update encryption Version 2
73
91
  *
74
92
  * Only available for Android and iOS.
75
93
  *
76
94
  * @default undefined
95
+ * @since 6.2.0
77
96
  */
78
- privateKey?: string;
97
+ publicKey?: string;
79
98
  /**
80
99
  * Configure the current version of the app. This will be used for the first update request.
81
100
  * If not set, the plugin will get the version from the native code.
@@ -86,368 +105,1386 @@ declare module "@capacitor/cli" {
86
105
  * @since 4.17.48
87
106
  */
88
107
  version?: string;
108
+ /**
109
+ * Configure when the plugin should direct install updates. Only for autoUpdate mode.
110
+ * Works well for apps less than 10MB and with uploads done using --partial flag.
111
+ * Zip or apps more than 10MB will be relatively slow for users to update.
112
+ * - false: Never do direct updates (use default behavior: download at start, set when backgrounded)
113
+ * - atInstall: Direct update only when app is installed, updated from store, otherwise act as directUpdate = false
114
+ * - onLaunch: Direct update only on app installed, updated from store or after app kill, otherwise act as directUpdate = false
115
+ * - always: Direct update in all previous cases (app installed, updated from store, after app kill or app resume), never act as directUpdate = false
116
+ * - true: (deprecated) Same as "always" for backward compatibility
117
+ *
118
+ * Only available for Android and iOS.
119
+ *
120
+ * @default false
121
+ * @since 5.1.0
122
+ */
123
+ directUpdate?: boolean | 'atInstall' | 'always' | 'onLaunch';
124
+ /**
125
+ * Automatically handle splashscreen hiding when using directUpdate. When enabled, the plugin will automatically hide the splashscreen after updates are applied or when no update is needed.
126
+ * This removes the need to manually listen for appReady events and call SplashScreen.hide().
127
+ * Only works when directUpdate is set to "atInstall", "always", "onLaunch", or true.
128
+ * Requires the @capacitor/splash-screen plugin to be installed and configured with launchAutoHide: false.
129
+ * Requires autoUpdate and directUpdate to be enabled.
130
+ *
131
+ * Only available for Android and iOS.
132
+ *
133
+ * @default false
134
+ * @since 7.6.0
135
+ */
136
+ autoSplashscreen?: boolean;
137
+ /**
138
+ * Display a native loading indicator on top of the splashscreen while automatic direct updates are running.
139
+ * Only takes effect when {@link autoSplashscreen} is enabled.
140
+ * Requires the @capacitor/splash-screen plugin to be installed and configured with launchAutoHide: false.
141
+ *
142
+ * Only available for Android and iOS.
143
+ *
144
+ * @default false
145
+ * @since 7.19.0
146
+ */
147
+ autoSplashscreenLoader?: boolean;
148
+ /**
149
+ * Automatically hide the splashscreen after the specified number of milliseconds when using automatic direct updates.
150
+ * If the timeout elapses, the update continues to download in the background while the splashscreen is dismissed.
151
+ * Set to `0` (zero) to disable the timeout.
152
+ * When the timeout fires, the direct update flow is skipped and the downloaded bundle is installed on the next background/launch.
153
+ * Requires {@link autoSplashscreen} to be enabled.
154
+ *
155
+ * Only available for Android and iOS.
156
+ *
157
+ * @default 10000 // (10 seconds)
158
+ * @since 7.19.0
159
+ */
160
+ autoSplashscreenTimeout?: number;
161
+ /**
162
+ * Configure the delay period for period update check. the unit is in seconds.
163
+ *
164
+ * Only available for Android and iOS.
165
+ * Cannot be less than 600 seconds (10 minutes).
166
+ *
167
+ * @default 0 (disabled)
168
+ * @example 3600 (1 hour)
169
+ * @example 86400 (24 hours)
170
+ */
171
+ periodCheckDelay?: number;
172
+ /**
173
+ * Configure the CLI to use a local server for testing or self-hosted update server.
174
+ *
175
+ *
176
+ * @default undefined
177
+ * @since 4.17.48
178
+ */
179
+ localS3?: boolean;
180
+ /**
181
+ * Configure the CLI to use a local server for testing or self-hosted update server.
182
+ *
183
+ *
184
+ * @default undefined
185
+ * @since 4.17.48
186
+ */
187
+ localHost?: string;
188
+ /**
189
+ * Configure the CLI to use a local server for testing or self-hosted update server.
190
+ *
191
+ *
192
+ * @default undefined
193
+ * @since 4.17.48
194
+ */
195
+ localWebHost?: string;
196
+ /**
197
+ * Configure the CLI to use a local server for testing or self-hosted update server.
198
+ *
199
+ *
200
+ * @default undefined
201
+ * @since 4.17.48
202
+ */
203
+ localSupa?: string;
204
+ /**
205
+ * Configure the CLI to use a local server for testing.
206
+ *
207
+ *
208
+ * @default undefined
209
+ * @since 4.17.48
210
+ */
211
+ localSupaAnon?: string;
212
+ /**
213
+ * Configure the CLI to use a local api for testing.
214
+ *
215
+ *
216
+ * @default undefined
217
+ * @since 6.3.3
218
+ */
219
+ localApi?: string;
220
+ /**
221
+ * Configure the CLI to use a local file api for testing.
222
+ *
223
+ *
224
+ * @default undefined
225
+ * @since 6.3.3
226
+ */
227
+ localApiFiles?: string;
228
+ /**
229
+ * Allow the plugin to modify the updateUrl, statsUrl and channelUrl dynamically from the JavaScript side.
230
+ *
231
+ *
232
+ * @default false
233
+ * @since 5.4.0
234
+ */
235
+ allowModifyUrl?: boolean;
236
+ /**
237
+ * Allow the plugin to modify the appId dynamically from the JavaScript side.
238
+ *
239
+ *
240
+ * @default false
241
+ * @since 7.14.0
242
+ */
243
+ allowModifyAppId?: boolean;
244
+ /**
245
+ * Allow marking bundles as errored from JavaScript while using manual update flows.
246
+ * When enabled, {@link CapacitorUpdaterPlugin.setBundleError} can change a bundle status to `error`.
247
+ *
248
+ * @default false
249
+ * @since 7.20.0
250
+ */
251
+ allowManualBundleError?: boolean;
252
+ /**
253
+ * Persist the customId set through {@link CapacitorUpdaterPlugin.setCustomId} across app restarts.
254
+ *
255
+ * Only available for Android and iOS.
256
+ *
257
+ * @default false (will be true by default in a future major release v8.x.x)
258
+ * @since 7.17.3
259
+ */
260
+ persistCustomId?: boolean;
261
+ /**
262
+ * Persist the updateUrl, statsUrl and channelUrl set through {@link CapacitorUpdaterPlugin.setUpdateUrl},
263
+ * {@link CapacitorUpdaterPlugin.setStatsUrl} and {@link CapacitorUpdaterPlugin.setChannelUrl} across app restarts.
264
+ *
265
+ * Only available for Android and iOS.
266
+ *
267
+ * @default false
268
+ * @since 7.20.0
269
+ */
270
+ persistModifyUrl?: boolean;
271
+ /**
272
+ * Allow or disallow the {@link CapacitorUpdaterPlugin.setChannel} method to modify the defaultChannel.
273
+ * When set to `false`, calling `setChannel()` will return an error with code `disabled_by_config`.
274
+ *
275
+ * @default true
276
+ * @since 7.34.0
277
+ */
278
+ allowSetDefaultChannel?: boolean;
279
+ /**
280
+ * Set the default channel for the app in the config. Case sensitive.
281
+ * This will setting will override the default channel set in the cloud, but will still respect overrides made in the cloud.
282
+ * This requires the channel to allow devices to self dissociate/associate in the channel settings. https://capgo.app/docs/public-api/channels/#channel-configuration-options
283
+ *
284
+ *
285
+ * @default undefined
286
+ * @since 5.5.0
287
+ */
288
+ defaultChannel?: string;
289
+ /**
290
+ * Configure the app id for the app in the config.
291
+ *
292
+ * @default undefined
293
+ * @since 6.0.0
294
+ */
295
+ appId?: string;
296
+ /**
297
+ * Configure the plugin to keep the URL path after a reload.
298
+ * WARNING: When a reload is triggered, 'window.history' will be cleared.
299
+ *
300
+ * @default false
301
+ * @since 6.8.0
302
+ */
303
+ keepUrlPathAfterReload?: boolean;
304
+ /**
305
+ * Disable the JavaScript logging of the plugin. if true, the plugin will not log to the JavaScript console. only the native log will be done
306
+ *
307
+ * @default false
308
+ * @since 7.3.0
309
+ */
310
+ disableJSLogging?: boolean;
311
+ /**
312
+ * Enable shake gesture to show update menu for debugging/testing purposes
313
+ *
314
+ * @default false
315
+ * @since 7.5.0
316
+ */
317
+ shakeMenu?: boolean;
89
318
  };
90
319
  }
91
320
  }
92
- export interface noNeedEvent {
321
+ export interface CapacitorUpdaterPlugin {
93
322
  /**
94
- * Current status of download, between 0 and 100.
323
+ * Notify the native layer that JavaScript initialized successfully.
95
324
  *
96
- * @since 4.0.0
97
- */
98
- bundle: BundleInfo;
99
- }
100
- export interface updateAvailableEvent {
101
- /**
102
- * Current status of download, between 0 and 100.
325
+ * **CRITICAL: You must call this method on every app launch to prevent automatic rollback.**
103
326
  *
104
- * @since 4.0.0
105
- */
106
- bundle: BundleInfo;
107
- }
108
- export interface channelRes {
109
- /**
110
- * Current status of set channel
327
+ * This is a simple notification to confirm that your bundle's JavaScript loaded and executed.
328
+ * The native web server successfully served the bundle files and your JS runtime started.
329
+ * That's all it checks - nothing more complex.
111
330
  *
112
- * @since 4.7.0
113
- */
114
- status: string;
115
- error?: any;
116
- message?: any;
117
- }
118
- export interface getChannelRes {
119
- /**
120
- * Current status of get channel
331
+ * **What triggers rollback:**
332
+ * - NOT calling this method within the timeout (default: 10 seconds)
333
+ * - Complete JavaScript failure (bundle won't load at all)
121
334
  *
122
- * @since 4.8.0
123
- */
124
- channel?: string;
125
- error?: any;
126
- message?: any;
127
- status?: string;
128
- allowSet?: boolean;
129
- }
130
- export interface DownloadEvent {
131
- /**
132
- * Current status of download, between 0 and 100.
335
+ * **What does NOT trigger rollback:**
336
+ * - Runtime errors after initialization (API failures, crashes, etc.)
337
+ * - Network request failures
338
+ * - Application logic errors
133
339
  *
134
- * @since 4.0.0
135
- */
136
- percent: number;
137
- bundle: BundleInfo;
138
- }
139
- export interface MajorAvailableEvent {
140
- /**
141
- * Emit when a new major bundle is available.
340
+ * **IMPORTANT: Call this BEFORE any network requests.**
341
+ * Don't wait for APIs, data loading, or async operations. Call it as soon as your
342
+ * JavaScript bundle starts executing to confirm the bundle itself is valid.
142
343
  *
143
- * @since 4.0.0
144
- */
145
- version: string;
146
- }
147
- export interface DownloadFailedEvent {
148
- /**
149
- * Emit when a download fail.
344
+ * Best practices:
345
+ * - Call immediately in your app entry point (main.js, app component mount, etc.)
346
+ * - Don't put it after network calls or heavy initialization
347
+ * - Don't wrap it in try/catch with conditions
348
+ * - Adjust {@link PluginsConfig.CapacitorUpdater.appReadyTimeout} if you need more time
150
349
  *
151
- * @since 4.0.0
350
+ * @returns {Promise<AppReadyResult>} Always resolves successfully with current bundle info. This method never fails.
152
351
  */
153
- version: string;
154
- }
155
- export interface DownloadCompleteEvent {
352
+ notifyAppReady(): Promise<AppReadyResult>;
156
353
  /**
157
- * Emit when a new update is available.
354
+ * Set the update URL for the app dynamically at runtime.
158
355
  *
159
- * @since 4.0.0
160
- */
161
- bundle: BundleInfo;
162
- }
163
- export interface UpdateFailedEvent {
164
- /**
165
- * Emit when a update failed to install.
356
+ * This overrides the {@link PluginsConfig.CapacitorUpdater.updateUrl} config value.
357
+ * Requires {@link PluginsConfig.CapacitorUpdater.allowModifyUrl} to be set to `true`.
166
358
  *
167
- * @since 4.0.0
359
+ * Use {@link PluginsConfig.CapacitorUpdater.persistModifyUrl} to persist this value across app restarts.
360
+ * Otherwise, the URL will reset to the config value on next app launch.
361
+ *
362
+ * @param options Contains the URL to use for checking for updates.
363
+ * @returns {Promise<void>} Resolves when the URL is successfully updated.
364
+ * @throws {Error} If `allowModifyUrl` is false or if the operation fails.
365
+ * @since 5.4.0
168
366
  */
169
- bundle: BundleInfo;
170
- }
171
- export interface latestVersion {
367
+ setUpdateUrl(options: UpdateUrl): Promise<void>;
172
368
  /**
173
- * Res of getLatest method
369
+ * Set the statistics URL for the app dynamically at runtime.
174
370
  *
175
- * @since 4.0.0
371
+ * This overrides the {@link PluginsConfig.CapacitorUpdater.statsUrl} config value.
372
+ * Requires {@link PluginsConfig.CapacitorUpdater.allowModifyUrl} to be set to `true`.
373
+ *
374
+ * Pass an empty string to disable statistics gathering entirely.
375
+ * Use {@link PluginsConfig.CapacitorUpdater.persistModifyUrl} to persist this value across app restarts.
376
+ *
377
+ * @param options Contains the URL to use for sending statistics, or an empty string to disable.
378
+ * @returns {Promise<void>} Resolves when the URL is successfully updated.
379
+ * @throws {Error} If `allowModifyUrl` is false or if the operation fails.
380
+ * @since 5.4.0
176
381
  */
177
- version: string;
178
- major?: boolean;
179
- message?: string;
180
- sessionKey?: string;
181
- error?: string;
182
- old?: string;
183
- url?: string;
184
- }
185
- export interface BundleInfo {
186
- id: string;
187
- version: string;
188
- downloaded: string;
189
- checksum: string;
190
- status: BundleStatus;
191
- }
192
- export interface SetChannelOptions {
193
- channel: string;
194
- }
195
- export interface SetCustomIdOptions {
196
- customId: string;
197
- }
198
- export interface DelayCondition {
382
+ setStatsUrl(options: StatsUrl): Promise<void>;
199
383
  /**
200
- * Set up delay conditions in setMultiDelay
201
- * @param value is useless for @param kind "kill", optional for "background" (default value: "0") and required for "nativeVersion" and "date"
384
+ * Set the channel URL for the app dynamically at runtime.
385
+ *
386
+ * This overrides the {@link PluginsConfig.CapacitorUpdater.channelUrl} config value.
387
+ * Requires {@link PluginsConfig.CapacitorUpdater.allowModifyUrl} to be set to `true`.
388
+ *
389
+ * Use {@link PluginsConfig.CapacitorUpdater.persistModifyUrl} to persist this value across app restarts.
390
+ * Otherwise, the URL will reset to the config value on next app launch.
391
+ *
392
+ * @param options Contains the URL to use for channel operations.
393
+ * @returns {Promise<void>} Resolves when the URL is successfully updated.
394
+ * @throws {Error} If `allowModifyUrl` is false or if the operation fails.
395
+ * @since 5.4.0
202
396
  */
203
- kind: DelayUntilNext;
204
- value?: string;
205
- }
206
- export type BundleStatus = "success" | "error" | "pending" | "downloading";
207
- export type DelayUntilNext = "background" | "kill" | "nativeVersion" | "date";
208
- export type DownloadChangeListener = (state: DownloadEvent) => void;
209
- export type NoNeedListener = (state: noNeedEvent) => void;
210
- export type UpdateAvailabledListener = (state: updateAvailableEvent) => void;
211
- export type DownloadFailedListener = (state: DownloadFailedEvent) => void;
212
- export type DownloadCompleteListener = (state: DownloadCompleteEvent) => void;
213
- export type MajorAvailableListener = (state: MajorAvailableEvent) => void;
214
- export type UpdateFailedListener = (state: UpdateFailedEvent) => void;
215
- export type AppReloadedListener = (state: void) => void;
216
- export interface CapacitorUpdaterPlugin {
397
+ setChannelUrl(options: ChannelUrl): Promise<void>;
217
398
  /**
218
- * Notify Capacitor Updater that the current bundle is working (a rollback will occur of this method is not called on every app launch)
219
- * By default this method should be called in the first 10 sec after app launch, otherwise a rollback will occur.
220
- * Change this behaviour with {@link appReadyTimeout}
399
+ * Download a new bundle from the provided URL for later installation.
400
+ *
401
+ * The downloaded bundle is stored locally but not activated. To use it:
402
+ * - Call {@link next} to set it for installation on next app backgrounding/restart
403
+ * - Call {@link set} to activate it immediately (destroys current JavaScript context)
404
+ *
405
+ * The URL should point to a zip file containing either:
406
+ * - Your app files directly in the zip root, or
407
+ * - A single folder containing all your app files
408
+ *
409
+ * The bundle must include an `index.html` file at the root level.
221
410
  *
222
- * @returns {Promise<BundleInfo>} an Promise resolved directly
223
- * @throws An error if something went wrong
411
+ * For encrypted bundles, provide the `sessionKey` and `checksum` parameters.
412
+ * For multi-file partial updates, provide the `manifest` array.
413
+ *
414
+ * @example
415
+ * const bundle = await CapacitorUpdater.download({
416
+ * url: `https://example.com/versions/${version}/dist.zip`,
417
+ * version: version
418
+ * });
419
+ * // Bundle is downloaded but not active yet
420
+ * await CapacitorUpdater.next({ id: bundle.id }); // Will activate on next background
421
+ *
422
+ * @param options The {@link DownloadOptions} for downloading a new bundle zip.
423
+ * @returns {Promise<BundleInfo>} The {@link BundleInfo} for the downloaded bundle.
424
+ * @throws {Error} If the download fails or the bundle is invalid.
224
425
  */
225
- notifyAppReady(): Promise<BundleInfo>;
426
+ download(options: DownloadOptions): Promise<BundleInfo>;
226
427
  /**
227
- * Download a new bundle from the provided URL, it should be a zip file, with files inside or with a unique id inside with all your files
428
+ * Set the next bundle to be activated when the app backgrounds or restarts.
429
+ *
430
+ * This is the recommended way to apply updates as it doesn't interrupt the user's current session.
431
+ * The bundle will be activated when:
432
+ * - The app is backgrounded (user switches away), or
433
+ * - The app is killed and relaunched, or
434
+ * - {@link reload} is called manually
228
435
  *
436
+ * Unlike {@link set}, this method does NOT destroy the current JavaScript context immediately.
437
+ * Your app continues running normally until one of the above events occurs.
438
+ *
439
+ * Use {@link setMultiDelay} to add additional conditions before the update is applied.
440
+ *
441
+ * @param options Contains the ID of the bundle to set as next. Use {@link BundleInfo.id} from a downloaded bundle.
229
442
  * @returns {Promise<BundleInfo>} The {@link BundleInfo} for the specified bundle.
230
- * @param url The URL of the bundle zip file (e.g: dist.zip) to be downloaded. (This can be any URL. E.g: Amazon S3, a github tag, any other place you've hosted your bundle.)
231
- * @param version set the version code/name of this bundle/version
232
- * @example https://example.com/versions/{version}/dist.zip
443
+ * @throws {Error} When there is no index.html file inside the bundle folder or the bundle doesn't exist.
233
444
  */
234
- download(options: {
235
- url: string;
236
- version: string;
237
- sessionKey?: string;
238
- checksum?: string;
239
- }): Promise<BundleInfo>;
445
+ next(options: BundleId): Promise<BundleInfo>;
240
446
  /**
241
- * Set the next bundle to be used when the app is reloaded.
447
+ * Set the current bundle and immediately reloads the app.
448
+ *
449
+ * **IMPORTANT: This is a terminal operation that destroys the current JavaScript context.**
242
450
  *
243
- * @returns {Promise<BundleInfo>} The {@link BundleInfo} for the specified bundle id.
244
- * @param id The bundle id to set as current, next time the app is reloaded. See {@link BundleInfo.id}
245
- * @throws An error if there are is no index.html file inside the bundle folder.
451
+ * When you call this method:
452
+ * - The entire JavaScript context is immediately destroyed
453
+ * - The app reloads from a different folder with different files
454
+ * - NO code after this call will execute
455
+ * - NO promises will resolve
456
+ * - NO callbacks will fire
457
+ * - Event listeners registered after this call are unreliable and may never fire
458
+ *
459
+ * The reload happens automatically - you don't need to do anything else.
460
+ * If you need to preserve state like the current URL path, use the {@link PluginsConfig.CapacitorUpdater.keepUrlPathAfterReload} config option.
461
+ * For other state preservation needs, save your data before calling this method (e.g., to localStorage).
462
+ *
463
+ * **Do not** try to execute additional logic after calling `set()` - it won't work as expected.
464
+ *
465
+ * @param options A {@link BundleId} object containing the new bundle id to set as current.
466
+ * @returns {Promise<void>} A promise that will never resolve because the JavaScript context is destroyed.
467
+ * @throws {Error} When there is no index.html file inside the bundle folder.
246
468
  */
247
- next(options: {
248
- id: string;
249
- }): Promise<BundleInfo>;
469
+ set(options: BundleId): Promise<void>;
250
470
  /**
251
- * Set the current bundle and immediately reloads the app.
471
+ * Delete a bundle from local storage to free up disk space.
252
472
  *
253
- * @param id The bundle id to set as current. See {@link BundleInfo.id}
254
- * @returns {Promise<Void>} An empty promise.
255
- * @throws An error if there are is no index.html file inside the bundle folder.
473
+ * You cannot delete:
474
+ * - The currently active bundle
475
+ * - The `builtin` bundle (the version shipped with your app)
476
+ * - The bundle set as `next` (call {@link next} with a different bundle first)
477
+ *
478
+ * Use {@link list} to get all available bundle IDs.
479
+ *
480
+ * **Note:** The bundle ID is NOT the same as the version name.
481
+ * Use the `id` field from {@link BundleInfo}, not the `version` field.
482
+ *
483
+ * @param options A {@link BundleId} object containing the bundle ID to delete.
484
+ * @returns {Promise<void>} Resolves when the bundle is successfully deleted.
485
+ * @throws {Error} If the bundle is currently in use or doesn't exist.
256
486
  */
257
- set(options: {
258
- id: string;
259
- }): Promise<void>;
487
+ delete(options: BundleId): Promise<void>;
260
488
  /**
261
- * Delete bundle in storage
489
+ * Manually mark a bundle as failed/errored in manual update mode.
490
+ *
491
+ * This is useful when you detect that a bundle has critical issues and want to prevent
492
+ * it from being used again. The bundle status will be changed to `error` and the plugin
493
+ * will avoid using this bundle in the future.
262
494
  *
263
- * @returns {Promise<void>} an empty Promise when the bundle is deleted
264
- * @param id The bundle id to delete (note, this is the bundle id, NOT the version name)
265
- * @throws An error if the something went wrong
495
+ * **Requirements:**
496
+ * - {@link PluginsConfig.CapacitorUpdater.allowManualBundleError} must be set to `true`
497
+ * - Only works in manual update mode (when autoUpdate is disabled)
498
+ *
499
+ * Common use case: After downloading and testing a bundle, you discover it has critical
500
+ * bugs and want to mark it as failed so it won't be retried.
501
+ *
502
+ * @param options A {@link BundleId} object containing the bundle ID to mark as errored.
503
+ * @returns {Promise<BundleInfo>} The updated {@link BundleInfo} with status set to `error`.
504
+ * @throws {Error} When the bundle does not exist or `allowManualBundleError` is false.
505
+ * @since 7.20.0
266
506
  */
267
- delete(options: {
268
- id: string;
269
- }): Promise<void>;
507
+ setBundleError(options: BundleId): Promise<BundleInfo>;
270
508
  /**
271
- * Get all available bundles
509
+ * Get all locally downloaded bundles stored in your app.
510
+ *
511
+ * This returns all bundles that have been downloaded and are available locally, including:
512
+ * - The currently active bundle
513
+ * - The `builtin` bundle (shipped with your app)
514
+ * - Any downloaded bundles waiting to be activated
515
+ * - Failed bundles (with `error` status)
516
+ *
517
+ * Use this to:
518
+ * - Check available disk space by counting bundles
519
+ * - Delete old bundles with {@link delete}
520
+ * - Monitor bundle download status
272
521
  *
273
- * @returns {Promise<{bundles: BundleInfo[]}>} an Promise witht the bundles list
274
- * @throws An error if the something went wrong
522
+ * @param options The {@link ListOptions} for customizing the bundle list output.
523
+ * @returns {Promise<BundleListResult>} A promise containing the array of {@link BundleInfo} objects.
524
+ * @throws {Error} If the operation fails.
275
525
  */
276
- list(): Promise<{
277
- bundles: BundleInfo[];
278
- }>;
526
+ list(options?: ListOptions): Promise<BundleListResult>;
279
527
  /**
280
- * Set the `builtin` bundle (the one sent to Apple store / Google play store ) as current bundle
528
+ * Reset the app to a known good bundle.
281
529
  *
282
- * @returns {Promise<void>} an empty Promise
283
- * @param toLastSuccessful [false] if yes it reset to to the last successfully loaded bundle instead of `builtin`
284
- * @throws An error if the something went wrong
530
+ * This method helps recover from problematic updates by reverting to either:
531
+ * - The `builtin` bundle (the original version shipped with your app to App Store/Play Store)
532
+ * - The last successfully loaded bundle (most recent bundle that worked correctly)
533
+ *
534
+ * **IMPORTANT: This triggers an immediate app reload, destroying the current JavaScript context.**
535
+ * See {@link set} for details on the implications of this operation.
536
+ *
537
+ * Use cases:
538
+ * - Emergency recovery when an update causes critical issues
539
+ * - Testing rollback functionality
540
+ * - Providing users a "reset to factory" option
541
+ *
542
+ * @param options {@link ResetOptions} to control reset behavior. If `toLastSuccessful` is `false` (or omitted), resets to builtin. If `true`, resets to last successful bundle.
543
+ * @returns {Promise<void>} A promise that may never resolve because the app will be reloaded.
544
+ * @throws {Error} If the reset operation fails.
285
545
  */
286
- reset(options?: {
287
- toLastSuccessful?: boolean;
288
- }): Promise<void>;
546
+ reset(options?: ResetOptions): Promise<void>;
289
547
  /**
290
- * Get the current bundle, if none are set it returns `builtin`, currentNative is the original bundle installed on the device
548
+ * Get information about the currently active bundle.
549
+ *
550
+ * Returns:
551
+ * - `bundle`: The currently active bundle information
552
+ * - `native`: The version of the builtin bundle (the original app version from App/Play Store)
291
553
  *
292
- * @returns {Promise<{ bundle: BundleInfo, native: string }>} an Promise with the current bundle info
293
- * @throws An error if the something went wrong
554
+ * If no updates have been applied, `bundle.id` will be `"builtin"`, indicating the app
555
+ * is running the original version shipped with the native app.
556
+ *
557
+ * Use this to:
558
+ * - Display the current version to users
559
+ * - Check if an update is currently active
560
+ * - Compare against available updates
561
+ * - Log the active bundle for debugging
562
+ *
563
+ * @returns {Promise<CurrentBundleResult>} A promise with the current bundle and native version info.
564
+ * @throws {Error} If the operation fails.
294
565
  */
295
- current(): Promise<{
296
- bundle: BundleInfo;
297
- native: string;
298
- }>;
566
+ current(): Promise<CurrentBundleResult>;
299
567
  /**
300
- * Reload the view
568
+ * Manually reload the app to apply a pending update.
569
+ *
570
+ * This triggers the same reload behavior that happens automatically when the app backgrounds.
571
+ * If you've called {@link next} to queue an update, calling `reload()` will apply it immediately.
572
+ *
573
+ * **IMPORTANT: This destroys the current JavaScript context immediately.**
574
+ * See {@link set} for details on the implications of this operation.
301
575
  *
302
- * @returns {Promise<void>} an Promise resolved when the view is reloaded
303
- * @throws An error if the something went wrong
576
+ * Common use cases:
577
+ * - Applying an update immediately after download instead of waiting for backgrounding
578
+ * - Providing a "Restart now" button to users after an update is ready
579
+ * - Testing update flows during development
580
+ *
581
+ * If no update is pending (no call to {@link next}), this simply reloads the current bundle.
582
+ *
583
+ * @returns {Promise<void>} A promise that may never resolve because the app will be reloaded.
584
+ * @throws {Error} If the reload operation fails.
304
585
  */
305
586
  reload(): Promise<void>;
306
587
  /**
307
- * Set DelayCondition, skip updates until one of the conditions is met
588
+ * Configure conditions that must be met before a pending update is applied.
589
+ *
590
+ * After calling {@link next} to queue an update, use this method to control when it gets applied.
591
+ * The update will only be installed after ALL specified conditions are satisfied.
592
+ *
593
+ * Available condition types:
594
+ * - `background`: Wait for the app to be backgrounded. Optionally specify duration in milliseconds.
595
+ * - `kill`: Wait for the app to be killed and relaunched (**Note:** Current behavior triggers update immediately on kill, not on next background. This will be fixed in v8.)
596
+ * - `date`: Wait until a specific date/time (ISO 8601 format)
597
+ * - `nativeVersion`: Wait until the native app is updated to a specific version
308
598
  *
309
- * @returns {Promise<void>} an Promise resolved directly
310
- * @param options are the {@link DelayCondition} list to set
599
+ * Condition value formats:
600
+ * - `background`: Number in milliseconds (e.g., `"300000"` for 5 minutes), or omit for immediate
601
+ * - `kill`: No value needed
602
+ * - `date`: ISO 8601 date string (e.g., `"2025-12-31T23:59:59Z"`)
603
+ * - `nativeVersion`: Version string (e.g., `"2.0.0"`)
311
604
  *
312
605
  * @example
313
- * setMultiDelay({ delayConditions: [{ kind: 'kill' }, { kind: 'background', value: '300000' }] })
314
- * // installs the update after the user kills the app or after a background of 300000 ms (5 minutes)
606
+ * // Update after user kills app OR after 5 minutes in background
607
+ * await CapacitorUpdater.setMultiDelay({
608
+ * delayConditions: [
609
+ * { kind: 'kill' },
610
+ * { kind: 'background', value: '300000' }
611
+ * ]
612
+ * });
315
613
  *
316
614
  * @example
317
- * setMultiDelay({ delayConditions: [{ kind: 'date', value: '2022-09-14T06:14:11.920Z' }] })
318
- * // installs the update after the specific iso8601 date is expired
615
+ * // Update after a specific date
616
+ * await CapacitorUpdater.setMultiDelay({
617
+ * delayConditions: [{ kind: 'date', value: '2025-12-31T23:59:59Z' }]
618
+ * });
319
619
  *
320
620
  * @example
321
- * setMultiDelay({ delayConditions: [{ kind: 'background' }] })
322
- * // installs the update after the the first background (default behaviour without setting delay)
621
+ * // Default behavior: update on next background
622
+ * await CapacitorUpdater.setMultiDelay({
623
+ * delayConditions: [{ kind: 'background' }]
624
+ * });
323
625
  *
324
- * @throws An error if the something went wrong
626
+ * @param options Contains the {@link MultiDelayConditions} array of conditions.
627
+ * @returns {Promise<void>} Resolves when the delay conditions are set.
628
+ * @throws {Error} If the operation fails or conditions are invalid.
325
629
  * @since 4.3.0
326
630
  */
327
- setMultiDelay(options: {
328
- delayConditions: DelayCondition[];
329
- }): Promise<void>;
631
+ setMultiDelay(options: MultiDelayConditions): Promise<void>;
330
632
  /**
331
- * Cancel delay to updates as usual
633
+ * Cancel all delay conditions and apply the pending update immediately.
332
634
  *
333
- * @returns {Promise<void>} an Promise resolved directly
334
- * @throws An error if the something went wrong
635
+ * If you've set delay conditions with {@link setMultiDelay}, this method clears them
636
+ * and triggers the pending update to be applied on the next app background or restart.
637
+ *
638
+ * This is useful when:
639
+ * - User manually requests to update now (e.g., clicks "Update now" button)
640
+ * - Your app detects it's a good time to update (e.g., user finished critical task)
641
+ * - You want to override a time-based delay early
642
+ *
643
+ * @returns {Promise<void>} Resolves when the delay conditions are cleared.
644
+ * @throws {Error} If the operation fails.
335
645
  * @since 4.0.0
336
646
  */
337
647
  cancelDelay(): Promise<void>;
338
648
  /**
339
- * Get Latest bundle available from update Url
649
+ * Check the update server for the latest available bundle version.
340
650
  *
341
- * @returns {Promise<latestVersion>} an Promise resolved when url is loaded
342
- * @throws An error if the something went wrong
343
- * @since 4.0.0
344
- */
345
- getLatest(): Promise<latestVersion>;
346
- /**
347
- * Set Channel for this device
651
+ * This queries your configured update URL (or Capgo backend) to see if a newer bundle
652
+ * is available for download. It does NOT download the bundle automatically.
348
653
  *
349
- * @returns {Promise<channelRes>} an Promise resolved when channel is set
350
- * @param options is the {@link SetChannelOptions} channel to set
351
- * @throws An error if the something went wrong
352
- * @since 4.7.0
353
- */
354
- setChannel(options: SetChannelOptions): Promise<channelRes>;
355
- /**
356
- * get Channel for this device
654
+ * The response includes:
655
+ * - `version`: The latest available version identifier
656
+ * - `url`: Download URL for the bundle (if available)
657
+ * - `breaking`: Whether this update is marked as incompatible (requires native app update)
658
+ * - `message`: Optional message from the server
659
+ * - `manifest`: File list for partial updates (if using multi-file downloads)
357
660
  *
358
- * @returns {Promise<channelRes>} an Promise resolved with channel info
359
- * @throws An error if the something went wrong
661
+ * After receiving the latest version info, you can:
662
+ * 1. Compare it with your current version
663
+ * 2. Download it using {@link download}
664
+ * 3. Apply it using {@link next} or {@link set}
665
+ *
666
+ * **Important: Error handling for "no new version available"**
667
+ *
668
+ * When the device's current version matches the latest version on the server (i.e., the device is already
669
+ * up-to-date), the server returns a 200 response with `error: "no_new_version_available"` and
670
+ * `message: "No new version available"`. **This causes `getLatest()` to throw an error**, even though
671
+ * this is a normal, expected condition.
672
+ *
673
+ * You should catch this specific error to handle it gracefully:
674
+ *
675
+ * ```typescript
676
+ * try {
677
+ * const latest = await CapacitorUpdater.getLatest();
678
+ * // New version is available, proceed with download
679
+ * } catch (error) {
680
+ * if (error.message === 'No new version available') {
681
+ * // Device is already on the latest version - this is normal
682
+ * console.log('Already up to date');
683
+ * } else {
684
+ * // Actual error occurred
685
+ * console.error('Failed to check for updates:', error);
686
+ * }
687
+ * }
688
+ * ```
689
+ *
690
+ * In this scenario, the server:
691
+ * - Logs the request with a "No new version available" message
692
+ * - Sends a "noNew" stat action to track that the device checked for updates but was already current (done on the backend)
693
+ *
694
+ * @param options Optional {@link GetLatestOptions} to specify which channel to check.
695
+ * @returns {Promise<LatestVersion>} Information about the latest available bundle version.
696
+ * @throws {Error} Always throws when no new version is available (`error: "no_new_version_available"`), or when the request fails.
697
+ * @since 4.0.0
698
+ */
699
+ getLatest(options?: GetLatestOptions): Promise<LatestVersion>;
700
+ /**
701
+ * Assign this device to a specific update channel at runtime.
702
+ *
703
+ * Channels allow you to distribute different bundle versions to different groups of users
704
+ * (e.g., "production", "beta", "staging"). This method switches the device to a new channel.
705
+ *
706
+ * **Requirements:**
707
+ * - The target channel must allow self-assignment (configured in your Capgo dashboard or backend)
708
+ * - The backend may accept or reject the request based on channel settings
709
+ *
710
+ * **When to use:**
711
+ * - After the app is ready and the user has interacted (e.g., opted into beta program)
712
+ * - To implement in-app channel switching (beta toggle, tester access, etc.)
713
+ * - For user-driven channel changes
714
+ *
715
+ * **When NOT to use:**
716
+ * - At app boot/initialization - use {@link PluginsConfig.CapacitorUpdater.defaultChannel} config instead
717
+ * - Before user interaction
718
+ *
719
+ * **Important: Listen for the `channelPrivate` event**
720
+ *
721
+ * When a user attempts to set a channel that doesn't allow device self-assignment, the method will
722
+ * throw an error AND fire a {@link addListener}('channelPrivate') event. You should listen to this event
723
+ * to provide appropriate feedback to users:
724
+ *
725
+ * ```typescript
726
+ * CapacitorUpdater.addListener('channelPrivate', (data) => {
727
+ * console.warn(`Cannot access channel "${data.channel}": ${data.message}`);
728
+ * // Show user-friendly message
729
+ * });
730
+ * ```
731
+ *
732
+ * This sends a request to the Capgo backend linking your device ID to the specified channel.
733
+ *
734
+ * @param options The {@link SetChannelOptions} containing the channel name and optional auto-update trigger.
735
+ * @returns {Promise<ChannelRes>} Channel operation result with status and optional error/message.
736
+ * @throws {Error} If the channel doesn't exist or doesn't allow self-assignment.
737
+ * @since 4.7.0
738
+ */
739
+ setChannel(options: SetChannelOptions): Promise<ChannelRes>;
740
+ /**
741
+ * Remove the device's channel assignment and return to the default channel.
742
+ *
743
+ * This unlinks the device from any specifically assigned channel, causing it to fall back to:
744
+ * - The {@link PluginsConfig.CapacitorUpdater.defaultChannel} if configured, or
745
+ * - Your backend's default channel for this app
746
+ *
747
+ * Use this when:
748
+ * - Users opt out of beta/testing programs
749
+ * - You want to reset a device to standard update distribution
750
+ * - Testing channel switching behavior
751
+ *
752
+ * @param options {@link UnsetChannelOptions} containing optional auto-update trigger.
753
+ * @returns {Promise<void>} Resolves when the channel is successfully unset.
754
+ * @throws {Error} If the operation fails.
755
+ * @since 4.7.0
756
+ */
757
+ unsetChannel(options: UnsetChannelOptions): Promise<void>;
758
+ /**
759
+ * Get the current channel assigned to this device.
760
+ *
761
+ * Returns information about:
762
+ * - `channel`: The currently assigned channel name (if any)
763
+ * - `allowSet`: Whether the channel allows self-assignment
764
+ * - `status`: Operation status
765
+ * - `error`/`message`: Additional information (if applicable)
766
+ *
767
+ * Use this to:
768
+ * - Display current channel to users (e.g., "You're on the Beta channel")
769
+ * - Check if a device is on a specific channel before showing features
770
+ * - Verify channel assignment after calling {@link setChannel}
771
+ *
772
+ * @returns {Promise<GetChannelRes>} The current channel information.
773
+ * @throws {Error} If the operation fails.
360
774
  * @since 4.8.0
361
775
  */
362
- getChannel(): Promise<getChannelRes>;
776
+ getChannel(): Promise<GetChannelRes>;
363
777
  /**
364
- * Set Channel for this device
778
+ * Get a list of all channels available for this device to self-assign to.
365
779
  *
366
- * @returns {Promise<void>} an Promise resolved instantly
367
- * @param options is the {@link SetCustomIdOptions} customId to set
368
- * @throws An error if the something went wrong
780
+ * Only returns channels where `allow_self_set` is `true`. These are channels that
781
+ * users can switch to using {@link setChannel} without backend administrator intervention.
782
+ *
783
+ * Each channel includes:
784
+ * - `id`: Unique channel identifier
785
+ * - `name`: Human-readable channel name
786
+ * - `public`: Whether the channel is publicly visible
787
+ * - `allow_self_set`: Always `true` in results (filtered to only self-assignable channels)
788
+ *
789
+ * Use this to:
790
+ * - Build a channel selector UI for users (e.g., "Join Beta" button)
791
+ * - Show available testing/preview channels
792
+ * - Implement channel discovery features
793
+ *
794
+ * @returns {Promise<ListChannelsResult>} List of channels the device can self-assign to.
795
+ * @throws {Error} If the operation fails or the request to the backend fails.
796
+ * @since 7.5.0
797
+ */
798
+ listChannels(): Promise<ListChannelsResult>;
799
+ /**
800
+ * Set a custom identifier for this device.
801
+ *
802
+ * This allows you to identify devices by your own custom ID (user ID, account ID, etc.)
803
+ * instead of or in addition to the device's unique hardware ID. The custom ID is sent
804
+ * to your update server and can be used for:
805
+ * - Targeting specific users for updates
806
+ * - Analytics and user tracking
807
+ * - Debugging and support (correlating devices with users)
808
+ * - A/B testing or feature flagging
809
+ *
810
+ * **Persistence:**
811
+ * - When {@link PluginsConfig.CapacitorUpdater.persistCustomId} is `true`, the ID persists across app restarts
812
+ * - When `false`, the ID is only kept for the current session
813
+ *
814
+ * **Clearing the custom ID:**
815
+ * - Pass an empty string `""` to remove any stored custom ID
816
+ *
817
+ * @param options The {@link SetCustomIdOptions} containing the custom identifier string.
818
+ * @returns {Promise<void>} Resolves immediately (synchronous operation).
819
+ * @throws {Error} If the operation fails.
369
820
  * @since 4.9.0
370
821
  */
371
822
  setCustomId(options: SetCustomIdOptions): Promise<void>;
372
823
  /**
373
- * Listen for download event in the App, let you know when the download is started, loading and finished
824
+ * Get the builtin bundle version (the original version shipped with your native app).
825
+ *
826
+ * This returns the version of the bundle that was included when the app was installed
827
+ * from the App Store or Play Store. This is NOT the currently active bundle version -
828
+ * use {@link current} for that.
829
+ *
830
+ * Returns:
831
+ * - The {@link PluginsConfig.CapacitorUpdater.version} config value if set, or
832
+ * - The native app version from platform configs (package.json, Info.plist, build.gradle)
833
+ *
834
+ * Use this to:
835
+ * - Display the "factory" version to users
836
+ * - Compare against downloaded bundle versions
837
+ * - Determine if any updates have been applied
838
+ * - Debugging version mismatches
839
+ *
840
+ * @returns {Promise<BuiltinVersion>} The builtin bundle version string.
841
+ * @since 5.2.0
842
+ */
843
+ getBuiltinVersion(): Promise<BuiltinVersion>;
844
+ /**
845
+ * Get the unique, privacy-friendly identifier for this device.
846
+ *
847
+ * This ID is used to identify the device when communicating with update servers.
848
+ * It's automatically generated and stored securely by the plugin.
849
+ *
850
+ * **Privacy & Security characteristics:**
851
+ * - Generated as a UUID (not based on hardware identifiers)
852
+ * - Stored securely in platform-specific secure storage
853
+ * - Android: Android Keystore (persists across app reinstalls on API 23+)
854
+ * - iOS: Keychain with `kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly`
855
+ * - Not synced to cloud (iOS)
856
+ * - Follows Apple and Google privacy best practices
857
+ * - Users can clear it via system settings (Android) or keychain access (iOS)
858
+ *
859
+ * **Persistence:**
860
+ * The device ID persists across app reinstalls to maintain consistent device identity
861
+ * for update tracking and analytics.
862
+ *
863
+ * Use this to:
864
+ * - Debug update delivery issues (check what ID the server sees)
865
+ * - Implement device-specific features
866
+ * - Correlate server logs with specific devices
867
+ *
868
+ * @returns {Promise<DeviceId>} The unique device identifier string.
869
+ * @throws {Error} If the operation fails.
870
+ */
871
+ getDeviceId(): Promise<DeviceId>;
872
+ /**
873
+ * Get the version of the Capacitor Updater plugin installed in your app.
874
+ *
875
+ * This returns the version of the native plugin code (Android/iOS), which is sent
876
+ * to the update server with each request. This is NOT your app version or bundle version.
877
+ *
878
+ * Use this to:
879
+ * - Debug plugin-specific issues (when reporting bugs)
880
+ * - Verify plugin installation and version
881
+ * - Check compatibility with backend features
882
+ * - Display in debug/about screens
883
+ *
884
+ * @returns {Promise<PluginVersion>} The Capacitor Updater plugin version string.
885
+ * @throws {Error} If the operation fails.
886
+ */
887
+ getPluginVersion(): Promise<PluginVersion>;
888
+ /**
889
+ * Check if automatic updates are currently enabled.
890
+ *
891
+ * Returns `true` if {@link PluginsConfig.CapacitorUpdater.autoUpdate} is enabled,
892
+ * meaning the plugin will automatically check for, download, and apply updates.
893
+ *
894
+ * Returns `false` if in manual mode, where you control the update flow using
895
+ * {@link getLatest}, {@link download}, {@link next}, and {@link set}.
896
+ *
897
+ * Use this to:
898
+ * - Determine which update flow your app is using
899
+ * - Show/hide manual update UI based on mode
900
+ * - Debug update behavior
901
+ *
902
+ * @returns {Promise<AutoUpdateEnabled>} `true` if auto-update is enabled, `false` if in manual mode.
903
+ * @throws {Error} If the operation fails.
904
+ */
905
+ isAutoUpdateEnabled(): Promise<AutoUpdateEnabled>;
906
+ /**
907
+ * Remove all event listeners registered for this plugin.
908
+ *
909
+ * This unregisters all listeners added via {@link addListener} for all event types:
910
+ * - `download`
911
+ * - `noNeedUpdate`
912
+ * - `updateAvailable`
913
+ * - `downloadComplete`
914
+ * - `downloadFailed`
915
+ * - `breakingAvailable` / `majorAvailable`
916
+ * - `updateFailed`
917
+ * - `appReloaded`
918
+ * - `appReady`
919
+ *
920
+ * Use this during cleanup (e.g., when unmounting components or closing screens)
921
+ * to prevent memory leaks from lingering event listeners.
922
+ *
923
+ * @returns {Promise<void>} Resolves when all listeners are removed.
924
+ * @since 1.0.0
925
+ */
926
+ removeAllListeners(): Promise<void>;
927
+ /**
928
+ * Listen for bundle download event in the App. Fires once a download has started, during downloading and when finished.
929
+ * This will return you all download percent during the download
374
930
  *
375
931
  * @since 2.0.11
376
932
  */
377
- addListener(eventName: "download", listenerFunc: DownloadChangeListener): Promise<PluginListenerHandle> & PluginListenerHandle;
933
+ addListener(eventName: 'download', listenerFunc: (state: DownloadEvent) => void): Promise<PluginListenerHandle>;
378
934
  /**
379
- * Listen for no need to update event, usefull when you want force check every time the app is launched
935
+ * Listen for no need to update event, useful when you want force check every time the app is launched
380
936
  *
381
937
  * @since 4.0.0
382
938
  */
383
- addListener(eventName: "noNeedUpdate", listenerFunc: NoNeedListener): Promise<PluginListenerHandle> & PluginListenerHandle;
939
+ addListener(eventName: 'noNeedUpdate', listenerFunc: (state: NoNeedEvent) => void): Promise<PluginListenerHandle>;
384
940
  /**
385
- * Listen for availbale update event, usefull when you want to force check every time the app is launched
941
+ * Listen for available update event, useful when you want to force check every time the app is launched
386
942
  *
387
943
  * @since 4.0.0
388
944
  */
389
- addListener(eventName: "updateAvailable", listenerFunc: UpdateAvailabledListener): Promise<PluginListenerHandle> & PluginListenerHandle;
945
+ addListener(eventName: 'updateAvailable', listenerFunc: (state: UpdateAvailableEvent) => void): Promise<PluginListenerHandle>;
390
946
  /**
391
- * Listen for download event in the App, let you know when the download is started, loading and finished
947
+ * Listen for downloadComplete events.
392
948
  *
393
949
  * @since 4.0.0
394
950
  */
395
- addListener(eventName: "downloadComplete", listenerFunc: DownloadCompleteListener): Promise<PluginListenerHandle> & PluginListenerHandle;
951
+ addListener(eventName: 'downloadComplete', listenerFunc: (state: DownloadCompleteEvent) => void): Promise<PluginListenerHandle>;
952
+ /**
953
+ * Listen for breaking update events when the backend flags an update as incompatible with the current app.
954
+ * Emits the same payload as the legacy `majorAvailable` listener.
955
+ *
956
+ * @since 7.22.0
957
+ */
958
+ addListener(eventName: 'breakingAvailable', listenerFunc: (state: BreakingAvailableEvent) => void): Promise<PluginListenerHandle>;
396
959
  /**
397
960
  * Listen for Major update event in the App, let you know when major update is blocked by setting disableAutoUpdateBreaking
398
961
  *
962
+ * @deprecated Deprecated alias for {@link addListener} with `breakingAvailable`. Emits the same payload. will be removed in v8
399
963
  * @since 2.3.0
400
964
  */
401
- addListener(eventName: "majorAvailable", listenerFunc: MajorAvailableListener): Promise<PluginListenerHandle> & PluginListenerHandle;
965
+ addListener(eventName: 'majorAvailable', listenerFunc: (state: MajorAvailableEvent) => void): Promise<PluginListenerHandle>;
402
966
  /**
403
967
  * Listen for update fail event in the App, let you know when update has fail to install at next app start
404
968
  *
405
969
  * @since 2.3.0
406
970
  */
407
- addListener(eventName: "updateFailed", listenerFunc: UpdateFailedListener): Promise<PluginListenerHandle> & PluginListenerHandle;
971
+ addListener(eventName: 'updateFailed', listenerFunc: (state: UpdateFailedEvent) => void): Promise<PluginListenerHandle>;
408
972
  /**
409
- * Listen for download fail event in the App, let you know when download has fail finished
973
+ * Listen for download fail event in the App, let you know when a bundle download has failed
410
974
  *
411
975
  * @since 4.0.0
412
976
  */
413
- addListener(eventName: "downloadFailed", listenerFunc: DownloadFailedListener): Promise<PluginListenerHandle> & PluginListenerHandle;
977
+ addListener(eventName: 'downloadFailed', listenerFunc: (state: DownloadFailedEvent) => void): Promise<PluginListenerHandle>;
414
978
  /**
415
- * Listen for download fail event in the App, let you know when download has fail finished
979
+ * Listen for reload event in the App, let you know when reload has happened
416
980
  *
417
981
  * @since 4.3.0
418
982
  */
419
- addListener(eventName: "appReloaded", listenerFunc: AppReloadedListener): Promise<PluginListenerHandle> & PluginListenerHandle;
983
+ addListener(eventName: 'appReloaded', listenerFunc: () => void): Promise<PluginListenerHandle>;
420
984
  /**
421
- * Get unique ID used to identify device (sent to auto update server)
985
+ * Listen for app ready event in the App, let you know when app is ready to use, this event is retain till consumed.
422
986
  *
423
- * @returns {Promise<{ deviceId: string }>} an Promise with id for this device
424
- * @throws An error if the something went wrong
987
+ * @since 5.1.0
425
988
  */
426
- getDeviceId(): Promise<{
427
- deviceId: string;
428
- }>;
989
+ addListener(eventName: 'appReady', listenerFunc: (state: AppReadyEvent) => void): Promise<PluginListenerHandle>;
429
990
  /**
430
- * Get the native Capacitor Updater plugin version (sent to auto update server)
991
+ * Listen for channel private event, fired when attempting to set a channel that doesn't allow device self-assignment.
431
992
  *
432
- * @returns {Promise<{ id: string }>} an Promise with version for this device
433
- * @throws An error if the something went wrong
993
+ * This event is useful for:
994
+ * - Informing users they don't have permission to switch to a specific channel
995
+ * - Implementing custom error handling for channel restrictions
996
+ * - Logging unauthorized channel access attempts
997
+ *
998
+ * @since 7.34.0
434
999
  */
435
- getPluginVersion(): Promise<{
436
- version: string;
437
- }>;
1000
+ addListener(eventName: 'channelPrivate', listenerFunc: (state: ChannelPrivateEvent) => void): Promise<PluginListenerHandle>;
438
1001
  /**
439
- * Get the state of auto update config. This will return `false` in manual mode.
1002
+ * Check if the auto-update feature is available (not disabled by custom server configuration).
1003
+ *
1004
+ * Returns `false` when a custom `updateUrl` is configured, as this typically indicates
1005
+ * you're using a self-hosted update server that may not support all auto-update features.
440
1006
  *
441
- * @returns {Promise<{enabled: boolean}>} The status for auto update.
442
- * @throws An error if the something went wrong
1007
+ * Returns `true` when using the default Capgo backend or when the feature is available.
1008
+ *
1009
+ * This is different from {@link isAutoUpdateEnabled}:
1010
+ * - `isAutoUpdateEnabled()`: Checks if auto-update MODE is turned on/off
1011
+ * - `isAutoUpdateAvailable()`: Checks if auto-update is SUPPORTED with your current configuration
1012
+ *
1013
+ * @returns {Promise<AutoUpdateAvailable>} `false` when custom updateUrl is set, `true` otherwise.
1014
+ * @throws {Error} If the operation fails.
443
1015
  */
444
- isAutoUpdateEnabled(): Promise<{
445
- enabled: boolean;
446
- }>;
1016
+ isAutoUpdateAvailable(): Promise<AutoUpdateAvailable>;
447
1017
  /**
448
- * Remove all listeners for this plugin.
1018
+ * Get information about the bundle queued to be activated on next reload.
449
1019
  *
450
- * @since 1.0.0
1020
+ * Returns:
1021
+ * - {@link BundleInfo} object if a bundle has been queued via {@link next}
1022
+ * - `null` if no update is pending
1023
+ *
1024
+ * This is useful to:
1025
+ * - Check if an update is waiting to be applied
1026
+ * - Display "Update pending" status to users
1027
+ * - Show version info of the queued update
1028
+ * - Decide whether to show a "Restart to update" prompt
1029
+ *
1030
+ * The queued bundle will be activated when:
1031
+ * - The app is backgrounded (default behavior)
1032
+ * - The app is killed and restarted
1033
+ * - {@link reload} is called manually
1034
+ * - Delay conditions set by {@link setMultiDelay} are met
1035
+ *
1036
+ * @returns {Promise<BundleInfo | null>} The pending bundle info, or `null` if none is queued.
1037
+ * @throws {Error} If the operation fails.
1038
+ * @since 6.8.0
451
1039
  */
452
- removeAllListeners(): Promise<void>;
1040
+ getNextBundle(): Promise<BundleInfo | null>;
1041
+ /**
1042
+ * Retrieve information about the most recent bundle that failed to load.
1043
+ *
1044
+ * When a bundle fails to load (e.g., JavaScript errors prevent initialization, missing files),
1045
+ * the plugin automatically rolls back and stores information about the failure. This method
1046
+ * retrieves that failure information.
1047
+ *
1048
+ * **IMPORTANT: The stored value is cleared after being retrieved once.**
1049
+ * Calling this method multiple times will only return the failure info on the first call,
1050
+ * then `null` on subsequent calls until another failure occurs.
1051
+ *
1052
+ * Returns:
1053
+ * - {@link UpdateFailedEvent} with bundle info if a failure was recorded
1054
+ * - `null` if no failure has occurred or if it was already retrieved
1055
+ *
1056
+ * Use this to:
1057
+ * - Show users why an update failed
1058
+ * - Log failure information for debugging
1059
+ * - Implement custom error handling/reporting
1060
+ * - Display rollback notifications
1061
+ *
1062
+ * @returns {Promise<UpdateFailedEvent | null>} The failed update info (cleared after first retrieval), or `null`.
1063
+ * @throws {Error} If the operation fails.
1064
+ * @since 7.22.0
1065
+ */
1066
+ getFailedUpdate(): Promise<UpdateFailedEvent | null>;
1067
+ /**
1068
+ * Enable or disable the shake gesture menu for debugging and testing.
1069
+ *
1070
+ * When enabled, users can shake their device to open a debug menu that shows:
1071
+ * - Current bundle information
1072
+ * - Available bundles
1073
+ * - Options to switch bundles manually
1074
+ * - Update status
1075
+ *
1076
+ * This is useful during development and testing to:
1077
+ * - Quickly test different bundle versions
1078
+ * - Debug update flows
1079
+ * - Switch between production and test bundles
1080
+ * - Verify bundle installations
1081
+ *
1082
+ * **Important:** Disable this in production builds or only enable for internal testers.
1083
+ *
1084
+ * Can also be configured via {@link PluginsConfig.CapacitorUpdater.shakeMenu}.
1085
+ *
1086
+ * @param options {@link SetShakeMenuOptions} with `enabled: true` to enable or `enabled: false` to disable.
1087
+ * @returns {Promise<void>} Resolves when the setting is applied.
1088
+ * @throws {Error} If the operation fails.
1089
+ * @since 7.5.0
1090
+ */
1091
+ setShakeMenu(options: SetShakeMenuOptions): Promise<void>;
1092
+ /**
1093
+ * Check if the shake gesture debug menu is currently enabled.
1094
+ *
1095
+ * Returns the current state of the shake menu feature that can be toggled via
1096
+ * {@link setShakeMenu} or configured via {@link PluginsConfig.CapacitorUpdater.shakeMenu}.
1097
+ *
1098
+ * Use this to:
1099
+ * - Check if debug features are enabled
1100
+ * - Show/hide debug settings UI
1101
+ * - Verify configuration during testing
1102
+ *
1103
+ * @returns {Promise<ShakeMenuEnabled>} Object with `enabled: true` or `enabled: false`.
1104
+ * @throws {Error} If the operation fails.
1105
+ * @since 7.5.0
1106
+ */
1107
+ isShakeMenuEnabled(): Promise<ShakeMenuEnabled>;
1108
+ /**
1109
+ * Get the currently configured App ID used for update server communication.
1110
+ *
1111
+ * Returns the App ID that identifies this app to the update server. This can be:
1112
+ * - The value set via {@link setAppId}, or
1113
+ * - The {@link PluginsConfig.CapacitorUpdater.appId} config value, or
1114
+ * - The default app identifier from your native app configuration
1115
+ *
1116
+ * Use this to:
1117
+ * - Verify which App ID is being used for updates
1118
+ * - Debug update delivery issues
1119
+ * - Display app configuration in debug screens
1120
+ * - Confirm App ID after calling {@link setAppId}
1121
+ *
1122
+ * @returns {Promise<GetAppIdRes>} Object containing the current `appId` string.
1123
+ * @throws {Error} If the operation fails.
1124
+ * @since 7.14.0
1125
+ */
1126
+ getAppId(): Promise<GetAppIdRes>;
1127
+ /**
1128
+ * Dynamically change the App ID used for update server communication.
1129
+ *
1130
+ * This overrides the App ID used to identify your app to the update server, allowing you
1131
+ * to switch between different app configurations at runtime (e.g., production vs staging
1132
+ * app IDs, or multi-tenant configurations).
1133
+ *
1134
+ * **Requirements:**
1135
+ * - {@link PluginsConfig.CapacitorUpdater.allowModifyAppId} must be set to `true`
1136
+ *
1137
+ * **Important considerations:**
1138
+ * - Changing the App ID will affect which updates this device receives
1139
+ * - The new App ID must exist on your update server
1140
+ * - This is primarily for advanced use cases (multi-tenancy, environment switching)
1141
+ * - Most apps should use the config-based {@link PluginsConfig.CapacitorUpdater.appId} instead
1142
+ *
1143
+ * @param options {@link SetAppIdOptions} containing the new App ID string.
1144
+ * @returns {Promise<void>} Resolves when the App ID is successfully changed.
1145
+ * @throws {Error} If `allowModifyAppId` is false or the operation fails.
1146
+ * @since 7.14.0
1147
+ */
1148
+ setAppId(options: SetAppIdOptions): Promise<void>;
1149
+ }
1150
+ /**
1151
+ * pending: The bundle is pending to be **SET** as the next bundle.
1152
+ * downloading: The bundle is being downloaded.
1153
+ * success: The bundle has been downloaded and is ready to be **SET** as the next bundle.
1154
+ * error: The bundle has failed to download.
1155
+ */
1156
+ export type BundleStatus = 'success' | 'error' | 'pending' | 'downloading';
1157
+ export type DelayUntilNext = 'background' | 'kill' | 'nativeVersion' | 'date';
1158
+ export interface NoNeedEvent {
1159
+ /**
1160
+ * Current status of download, between 0 and 100.
1161
+ *
1162
+ * @since 4.0.0
1163
+ */
1164
+ bundle: BundleInfo;
1165
+ }
1166
+ export interface UpdateAvailableEvent {
1167
+ /**
1168
+ * Current status of download, between 0 and 100.
1169
+ *
1170
+ * @since 4.0.0
1171
+ */
1172
+ bundle: BundleInfo;
1173
+ }
1174
+ export interface ChannelRes {
1175
+ /**
1176
+ * Current status of set channel
1177
+ *
1178
+ * @since 4.7.0
1179
+ */
1180
+ status: string;
1181
+ error?: string;
1182
+ message?: string;
1183
+ }
1184
+ export interface GetChannelRes {
1185
+ /**
1186
+ * Current status of get channel
1187
+ *
1188
+ * @since 4.8.0
1189
+ */
1190
+ channel?: string;
1191
+ error?: string;
1192
+ message?: string;
1193
+ status?: string;
1194
+ allowSet?: boolean;
1195
+ }
1196
+ export interface ChannelInfo {
1197
+ /**
1198
+ * The channel ID
1199
+ *
1200
+ * @since 7.5.0
1201
+ */
1202
+ id: string;
1203
+ /**
1204
+ * The channel name
1205
+ *
1206
+ * @since 7.5.0
1207
+ */
1208
+ name: string;
1209
+ /**
1210
+ * Whether this is a public channel
1211
+ *
1212
+ * @since 7.5.0
1213
+ */
1214
+ public: boolean;
1215
+ /**
1216
+ * Whether devices can self-assign to this channel
1217
+ *
1218
+ * @since 7.5.0
1219
+ */
1220
+ allow_self_set: boolean;
1221
+ }
1222
+ export interface ListChannelsResult {
1223
+ /**
1224
+ * List of available channels
1225
+ *
1226
+ * @since 7.5.0
1227
+ */
1228
+ channels: ChannelInfo[];
1229
+ }
1230
+ export interface DownloadEvent {
1231
+ /**
1232
+ * Current status of download, between 0 and 100.
1233
+ *
1234
+ * @since 4.0.0
1235
+ */
1236
+ percent: number;
1237
+ bundle: BundleInfo;
1238
+ }
1239
+ export interface MajorAvailableEvent {
1240
+ /**
1241
+ * Emit when a breaking update is available.
1242
+ *
1243
+ * @deprecated Deprecated alias for {@link BreakingAvailableEvent}. Receives the same payload.
1244
+ * @since 4.0.0
1245
+ */
1246
+ version: string;
1247
+ }
1248
+ /**
1249
+ * Payload emitted by {@link CapacitorUpdaterPlugin.addListener} with `breakingAvailable`.
1250
+ *
1251
+ * @since 7.22.0
1252
+ */
1253
+ export type BreakingAvailableEvent = MajorAvailableEvent;
1254
+ export interface DownloadFailedEvent {
1255
+ /**
1256
+ * Emit when a download fail.
1257
+ *
1258
+ * @since 4.0.0
1259
+ */
1260
+ version: string;
1261
+ }
1262
+ export interface DownloadCompleteEvent {
1263
+ /**
1264
+ * Emit when a new update is available.
1265
+ *
1266
+ * @since 4.0.0
1267
+ */
1268
+ bundle: BundleInfo;
1269
+ }
1270
+ export interface UpdateFailedEvent {
1271
+ /**
1272
+ * Emit when a update failed to install.
1273
+ *
1274
+ * @since 4.0.0
1275
+ */
1276
+ bundle: BundleInfo;
1277
+ }
1278
+ export interface AppReadyEvent {
1279
+ /**
1280
+ * Emitted when the app is ready to use.
1281
+ *
1282
+ * @since 5.2.0
1283
+ */
1284
+ bundle: BundleInfo;
1285
+ status: string;
1286
+ }
1287
+ export interface ChannelPrivateEvent {
1288
+ /**
1289
+ * Emitted when attempting to set a channel that doesn't allow device self-assignment.
1290
+ *
1291
+ * @since 7.34.0
1292
+ */
1293
+ channel: string;
1294
+ message: string;
1295
+ }
1296
+ export interface ManifestEntry {
1297
+ file_name: string | null;
1298
+ file_hash: string | null;
1299
+ download_url: string | null;
1300
+ }
1301
+ export interface LatestVersion {
1302
+ /**
1303
+ * Result of getLatest method
1304
+ *
1305
+ * @since 4.0.0
1306
+ */
1307
+ version: string;
1308
+ /**
1309
+ * @since 6
1310
+ */
1311
+ checksum?: string;
1312
+ /**
1313
+ * Indicates whether the update was flagged as breaking by the backend.
1314
+ *
1315
+ * @since 7.22.0
1316
+ */
1317
+ breaking?: boolean;
1318
+ /**
1319
+ * @deprecated Use {@link LatestVersion.breaking} instead.
1320
+ */
1321
+ major?: boolean;
1322
+ /**
1323
+ * Optional message from the server.
1324
+ * When no new version is available, this will be "No new version available".
1325
+ */
1326
+ message?: string;
1327
+ sessionKey?: string;
1328
+ /**
1329
+ * Error code from the server, if any.
1330
+ * Common values:
1331
+ * - `"no_new_version_available"`: Device is already on the latest version (not a failure)
1332
+ * - Other error codes indicate actual failures in the update process
1333
+ */
1334
+ error?: string;
1335
+ /**
1336
+ * The previous/current version name (provided for reference).
1337
+ */
1338
+ old?: string;
1339
+ /**
1340
+ * Download URL for the bundle (when a new version is available).
1341
+ */
1342
+ url?: string;
1343
+ /**
1344
+ * File list for partial updates (when using multi-file downloads).
1345
+ * @since 6.1
1346
+ */
1347
+ manifest?: ManifestEntry[];
1348
+ /**
1349
+ * Optional link associated with this bundle version (e.g., release notes URL, changelog, GitHub release).
1350
+ * @since 7.35.0
1351
+ */
1352
+ link?: string;
1353
+ /**
1354
+ * Optional comment or description for this bundle version.
1355
+ * @since 7.35.0
1356
+ */
1357
+ comment?: string;
1358
+ }
1359
+ export interface BundleInfo {
1360
+ id: string;
1361
+ version: string;
1362
+ downloaded: string;
1363
+ checksum: string;
1364
+ status: BundleStatus;
1365
+ }
1366
+ export interface SetChannelOptions {
1367
+ channel: string;
1368
+ triggerAutoUpdate?: boolean;
1369
+ }
1370
+ export interface UnsetChannelOptions {
1371
+ triggerAutoUpdate?: boolean;
1372
+ }
1373
+ export interface SetCustomIdOptions {
1374
+ /**
1375
+ * Custom identifier to associate with the device. Use an empty string to clear any saved value.
1376
+ */
1377
+ customId: string;
1378
+ }
1379
+ export interface DelayCondition {
1380
+ /**
1381
+ * Set up delay conditions in setMultiDelay
1382
+ * @param value is useless for @param kind "kill", optional for "background" (default value: "0") and required for "nativeVersion" and "date"
1383
+ */
1384
+ kind: DelayUntilNext;
1385
+ value?: string;
1386
+ }
1387
+ export interface GetLatestOptions {
1388
+ /**
1389
+ * The channel to get the latest version for
1390
+ * The channel must allow 'self_assign' for this to work
1391
+ * @since 6.8.0
1392
+ * @default undefined
1393
+ */
1394
+ channel?: string;
1395
+ }
1396
+ export interface AppReadyResult {
1397
+ bundle: BundleInfo;
1398
+ }
1399
+ export interface UpdateUrl {
1400
+ url: string;
1401
+ }
1402
+ export interface StatsUrl {
1403
+ url: string;
1404
+ }
1405
+ export interface ChannelUrl {
1406
+ url: string;
1407
+ }
1408
+ /**
1409
+ * This URL and versions are used to download the bundle from the server, If you use backend all information will be given by the method getLatest.
1410
+ * If you don't use backend, you need to provide the URL and version of the bundle. Checksum and sessionKey are required if you encrypted the bundle with the CLI command encrypt, you should receive them as result of the command.
1411
+ */
1412
+ export interface DownloadOptions {
1413
+ /**
1414
+ * The URL of the bundle zip file (e.g: dist.zip) to be downloaded. (This can be any URL. E.g: Amazon S3, a GitHub tag, any other place you've hosted your bundle.)
1415
+ */
1416
+ url: string;
1417
+ /**
1418
+ * The version code/name of this bundle/version
1419
+ */
1420
+ version: string;
1421
+ /**
1422
+ * The session key for the update, when the bundle is encrypted with a session key
1423
+ * @since 4.0.0
1424
+ * @default undefined
1425
+ */
1426
+ sessionKey?: string;
1427
+ /**
1428
+ * The checksum for the update, it should be in sha256 and encrypted with private key if the bundle is encrypted
1429
+ * @since 4.0.0
1430
+ * @default undefined
1431
+ */
1432
+ checksum?: string;
1433
+ /**
1434
+ * The manifest for multi-file downloads
1435
+ * @since 6.1.0
1436
+ * @default undefined
1437
+ */
1438
+ manifest?: ManifestEntry[];
1439
+ }
1440
+ export interface BundleId {
1441
+ id: string;
1442
+ }
1443
+ export interface BundleListResult {
1444
+ bundles: BundleInfo[];
1445
+ }
1446
+ export interface ResetOptions {
1447
+ toLastSuccessful: boolean;
1448
+ }
1449
+ export interface ListOptions {
1450
+ /**
1451
+ * Whether to return the raw bundle list or the manifest. If true, the list will attempt to read the internal database instead of files on disk.
1452
+ * @since 6.14.0
1453
+ * @default false
1454
+ */
1455
+ raw?: boolean;
1456
+ }
1457
+ export interface CurrentBundleResult {
1458
+ bundle: BundleInfo;
1459
+ native: string;
1460
+ }
1461
+ export interface MultiDelayConditions {
1462
+ delayConditions: DelayCondition[];
1463
+ }
1464
+ export interface BuiltinVersion {
1465
+ version: string;
1466
+ }
1467
+ export interface DeviceId {
1468
+ deviceId: string;
1469
+ }
1470
+ export interface PluginVersion {
1471
+ version: string;
1472
+ }
1473
+ export interface AutoUpdateEnabled {
1474
+ enabled: boolean;
1475
+ }
1476
+ export interface AutoUpdateAvailable {
1477
+ available: boolean;
1478
+ }
1479
+ export interface SetShakeMenuOptions {
1480
+ enabled: boolean;
1481
+ }
1482
+ export interface ShakeMenuEnabled {
1483
+ enabled: boolean;
1484
+ }
1485
+ export interface GetAppIdRes {
1486
+ appId: string;
1487
+ }
1488
+ export interface SetAppIdOptions {
1489
+ appId: string;
453
1490
  }