native-update 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (184) hide show
  1. package/CapacitorNativeUpdate.podspec +18 -0
  2. package/LICENSE +21 -0
  3. package/Readme.md +451 -0
  4. package/android/build.gradle +92 -0
  5. package/android/gradle/wrapper/gradle-wrapper.properties +8 -0
  6. package/android/gradle.properties +17 -0
  7. package/android/proguard-rules.pro +29 -0
  8. package/android/settings.gradle +2 -0
  9. package/android/src/main/AndroidManifest.xml +34 -0
  10. package/android/src/main/java/com/aoneahsan/nativeupdate/AppReviewPlugin.kt +153 -0
  11. package/android/src/main/java/com/aoneahsan/nativeupdate/AppUpdatePlugin.kt +275 -0
  12. package/android/src/main/java/com/aoneahsan/nativeupdate/BackgroundNotificationManager.kt +390 -0
  13. package/android/src/main/java/com/aoneahsan/nativeupdate/BackgroundUpdateManager.kt +46 -0
  14. package/android/src/main/java/com/aoneahsan/nativeupdate/BackgroundUpdatePlugin.kt +333 -0
  15. package/android/src/main/java/com/aoneahsan/nativeupdate/BackgroundUpdateWorker.kt +251 -0
  16. package/android/src/main/java/com/aoneahsan/nativeupdate/CapacitorNativeUpdatePlugin.kt +265 -0
  17. package/android/src/main/java/com/aoneahsan/nativeupdate/LiveUpdatePlugin.kt +526 -0
  18. package/android/src/main/java/com/aoneahsan/nativeupdate/NotificationActionReceiver.kt +99 -0
  19. package/android/src/main/java/com/aoneahsan/nativeupdate/SecurityManager.kt +249 -0
  20. package/dist/esm/__tests__/bundle-manager.test.d.ts +1 -0
  21. package/dist/esm/__tests__/bundle-manager.test.js +123 -0
  22. package/dist/esm/__tests__/bundle-manager.test.js.map +1 -0
  23. package/dist/esm/__tests__/config.test.d.ts +1 -0
  24. package/dist/esm/__tests__/config.test.js +69 -0
  25. package/dist/esm/__tests__/config.test.js.map +1 -0
  26. package/dist/esm/__tests__/integration.test.d.ts +1 -0
  27. package/dist/esm/__tests__/integration.test.js +78 -0
  28. package/dist/esm/__tests__/integration.test.js.map +1 -0
  29. package/dist/esm/__tests__/security.test.d.ts +1 -0
  30. package/dist/esm/__tests__/security.test.js +54 -0
  31. package/dist/esm/__tests__/security.test.js.map +1 -0
  32. package/dist/esm/__tests__/version-manager.test.d.ts +1 -0
  33. package/dist/esm/__tests__/version-manager.test.js +45 -0
  34. package/dist/esm/__tests__/version-manager.test.js.map +1 -0
  35. package/dist/esm/app-review/app-review-manager.d.ts +24 -0
  36. package/dist/esm/app-review/app-review-manager.js +195 -0
  37. package/dist/esm/app-review/app-review-manager.js.map +1 -0
  38. package/dist/esm/app-review/index.d.ts +5 -0
  39. package/dist/esm/app-review/index.js +6 -0
  40. package/dist/esm/app-review/index.js.map +1 -0
  41. package/dist/esm/app-review/platform-review-handler.d.ts +20 -0
  42. package/dist/esm/app-review/platform-review-handler.js +138 -0
  43. package/dist/esm/app-review/platform-review-handler.js.map +1 -0
  44. package/dist/esm/app-review/review-conditions-checker.d.ts +22 -0
  45. package/dist/esm/app-review/review-conditions-checker.js +155 -0
  46. package/dist/esm/app-review/review-conditions-checker.js.map +1 -0
  47. package/dist/esm/app-review/review-rate-limiter.d.ts +23 -0
  48. package/dist/esm/app-review/review-rate-limiter.js +164 -0
  49. package/dist/esm/app-review/review-rate-limiter.js.map +1 -0
  50. package/dist/esm/app-review/types.d.ts +41 -0
  51. package/dist/esm/app-review/types.js +2 -0
  52. package/dist/esm/app-review/types.js.map +1 -0
  53. package/dist/esm/app-update/app-update-checker.d.ts +13 -0
  54. package/dist/esm/app-update/app-update-checker.js +104 -0
  55. package/dist/esm/app-update/app-update-checker.js.map +1 -0
  56. package/dist/esm/app-update/app-update-installer.d.ts +19 -0
  57. package/dist/esm/app-update/app-update-installer.js +123 -0
  58. package/dist/esm/app-update/app-update-installer.js.map +1 -0
  59. package/dist/esm/app-update/app-update-manager.d.ts +28 -0
  60. package/dist/esm/app-update/app-update-manager.js +199 -0
  61. package/dist/esm/app-update/app-update-manager.js.map +1 -0
  62. package/dist/esm/app-update/app-update-notifier.d.ts +14 -0
  63. package/dist/esm/app-update/app-update-notifier.js +100 -0
  64. package/dist/esm/app-update/app-update-notifier.js.map +1 -0
  65. package/dist/esm/app-update/index.d.ts +6 -0
  66. package/dist/esm/app-update/index.js +7 -0
  67. package/dist/esm/app-update/index.js.map +1 -0
  68. package/dist/esm/app-update/platform-app-update.d.ts +19 -0
  69. package/dist/esm/app-update/platform-app-update.js +129 -0
  70. package/dist/esm/app-update/platform-app-update.js.map +1 -0
  71. package/dist/esm/app-update/types.d.ts +58 -0
  72. package/dist/esm/app-update/types.js +12 -0
  73. package/dist/esm/app-update/types.js.map +1 -0
  74. package/dist/esm/background-update/background-scheduler.d.ts +17 -0
  75. package/dist/esm/background-update/background-scheduler.js +195 -0
  76. package/dist/esm/background-update/background-scheduler.js.map +1 -0
  77. package/dist/esm/background-update/index.d.ts +3 -0
  78. package/dist/esm/background-update/index.js +3 -0
  79. package/dist/esm/background-update/index.js.map +1 -0
  80. package/dist/esm/background-update/notification-manager.d.ts +29 -0
  81. package/dist/esm/background-update/notification-manager.js +89 -0
  82. package/dist/esm/background-update/notification-manager.js.map +1 -0
  83. package/dist/esm/core/analytics.d.ts +70 -0
  84. package/dist/esm/core/analytics.js +137 -0
  85. package/dist/esm/core/analytics.js.map +1 -0
  86. package/dist/esm/core/cache-manager.d.ts +72 -0
  87. package/dist/esm/core/cache-manager.js +275 -0
  88. package/dist/esm/core/cache-manager.js.map +1 -0
  89. package/dist/esm/core/config.d.ts +48 -0
  90. package/dist/esm/core/config.js +83 -0
  91. package/dist/esm/core/config.js.map +1 -0
  92. package/dist/esm/core/errors.d.ts +51 -0
  93. package/dist/esm/core/errors.js +80 -0
  94. package/dist/esm/core/errors.js.map +1 -0
  95. package/dist/esm/core/logger.d.ts +21 -0
  96. package/dist/esm/core/logger.js +109 -0
  97. package/dist/esm/core/logger.js.map +1 -0
  98. package/dist/esm/core/performance.d.ts +53 -0
  99. package/dist/esm/core/performance.js +140 -0
  100. package/dist/esm/core/performance.js.map +1 -0
  101. package/dist/esm/core/plugin-manager.d.ts +66 -0
  102. package/dist/esm/core/plugin-manager.js +148 -0
  103. package/dist/esm/core/plugin-manager.js.map +1 -0
  104. package/dist/esm/core/security.d.ts +93 -0
  105. package/dist/esm/core/security.js +315 -0
  106. package/dist/esm/core/security.js.map +1 -0
  107. package/dist/esm/definitions.d.ts +639 -0
  108. package/dist/esm/definitions.js +103 -0
  109. package/dist/esm/definitions.js.map +1 -0
  110. package/dist/esm/index.d.ts +12 -0
  111. package/dist/esm/index.js +16 -0
  112. package/dist/esm/index.js.map +1 -0
  113. package/dist/esm/live-update/bundle-manager.d.ts +94 -0
  114. package/dist/esm/live-update/bundle-manager.js +310 -0
  115. package/dist/esm/live-update/bundle-manager.js.map +1 -0
  116. package/dist/esm/live-update/certificate-pinning.d.ts +38 -0
  117. package/dist/esm/live-update/certificate-pinning.js +78 -0
  118. package/dist/esm/live-update/certificate-pinning.js.map +1 -0
  119. package/dist/esm/live-update/download-manager.d.ts +67 -0
  120. package/dist/esm/live-update/download-manager.js +319 -0
  121. package/dist/esm/live-update/download-manager.js.map +1 -0
  122. package/dist/esm/live-update/update-manager.d.ts +52 -0
  123. package/dist/esm/live-update/update-manager.js +294 -0
  124. package/dist/esm/live-update/update-manager.js.map +1 -0
  125. package/dist/esm/live-update/version-manager.d.ts +84 -0
  126. package/dist/esm/live-update/version-manager.js +335 -0
  127. package/dist/esm/live-update/version-manager.js.map +1 -0
  128. package/dist/esm/plugin.d.ts +6 -0
  129. package/dist/esm/plugin.js +283 -0
  130. package/dist/esm/plugin.js.map +1 -0
  131. package/dist/esm/security/crypto.d.ts +25 -0
  132. package/dist/esm/security/crypto.js +70 -0
  133. package/dist/esm/security/crypto.js.map +1 -0
  134. package/dist/esm/security/validator.d.ts +60 -0
  135. package/dist/esm/security/validator.js +143 -0
  136. package/dist/esm/security/validator.js.map +1 -0
  137. package/dist/esm/web.d.ts +74 -0
  138. package/dist/esm/web.js +595 -0
  139. package/dist/esm/web.js.map +1 -0
  140. package/dist/plugin.cjs.js +2 -0
  141. package/dist/plugin.cjs.js.map +1 -0
  142. package/dist/plugin.esm.js +2 -0
  143. package/dist/plugin.esm.js.map +1 -0
  144. package/dist/plugin.js +3 -0
  145. package/dist/plugin.js.map +1 -0
  146. package/docs/APP_REVIEW_GUIDE.md +768 -0
  147. package/docs/BUNDLE_SIGNING.md +264 -0
  148. package/docs/LIVE_UPDATES_GUIDE.md +650 -0
  149. package/docs/MIGRATION.md +192 -0
  150. package/docs/NATIVE_UPDATES_GUIDE.md +694 -0
  151. package/docs/QUICK_START.md +606 -0
  152. package/docs/README.md +111 -0
  153. package/docs/REMAINING_FEATURES.md +139 -0
  154. package/docs/api/app-review-api.md +259 -0
  155. package/docs/api/app-update-api.md +238 -0
  156. package/docs/api/events-api.md +451 -0
  157. package/docs/api/live-update-api.md +265 -0
  158. package/docs/background-updates.md +392 -0
  159. package/docs/examples/advanced-scenarios.md +410 -0
  160. package/docs/examples/basic-usage.md +185 -0
  161. package/docs/features/app-reviews.md +975 -0
  162. package/docs/features/app-updates.md +785 -0
  163. package/docs/features/live-updates.md +633 -0
  164. package/docs/getting-started/configuration.md +468 -0
  165. package/docs/getting-started/installation.md +209 -0
  166. package/docs/getting-started/quick-start.md +379 -0
  167. package/docs/guides/deployment-guide.md +333 -0
  168. package/docs/guides/migration-from-codepush.md +142 -0
  169. package/docs/guides/security-best-practices.md +1057 -0
  170. package/docs/guides/testing-guide.md +373 -0
  171. package/docs/production-readiness.md +478 -0
  172. package/docs/security/certificate-pinning.md +122 -0
  173. package/docs/server-requirements.md +147 -0
  174. package/ios/Plugin/AppReview/AppReviewPlugin.swift +158 -0
  175. package/ios/Plugin/AppUpdate/AppUpdatePlugin.swift +234 -0
  176. package/ios/Plugin/BackgroundUpdate/BackgroundNotificationManager.swift +329 -0
  177. package/ios/Plugin/BackgroundUpdate/BackgroundUpdatePlugin.swift +396 -0
  178. package/ios/Plugin/CapacitorNativeUpdatePlugin.m +45 -0
  179. package/ios/Plugin/CapacitorNativeUpdatePlugin.swift +190 -0
  180. package/ios/Plugin/Info.plist +43 -0
  181. package/ios/Plugin/LiveUpdate/LiveUpdatePlugin.swift +689 -0
  182. package/ios/Plugin/LiveUpdate/WebViewConfiguration.swift +45 -0
  183. package/ios/Plugin/Security/SecurityManager.swift +289 -0
  184. package/package.json +90 -0
@@ -0,0 +1,639 @@
1
+ export interface NativeUpdatePlugin {
2
+ /**
3
+ * Configure the plugin with initial settings
4
+ */
5
+ configure(options: {
6
+ config: PluginInitConfig;
7
+ }): Promise<void>;
8
+ /**
9
+ * Get current security configuration
10
+ */
11
+ getSecurityInfo(): Promise<SecurityInfo>;
12
+ }
13
+ /**
14
+ * Live Update Plugin Interface
15
+ */
16
+ export interface LiveUpdatePlugin {
17
+ /**
18
+ * Sync with update server and apply updates if available
19
+ */
20
+ sync(options?: SyncOptions): Promise<SyncResult>;
21
+ /**
22
+ * Download a specific bundle version
23
+ */
24
+ download(options: DownloadOptions): Promise<BundleInfo>;
25
+ /**
26
+ * Set the active bundle
27
+ */
28
+ set(bundle: BundleInfo): Promise<void>;
29
+ /**
30
+ * Reload the app with current bundle
31
+ */
32
+ reload(): Promise<void>;
33
+ /**
34
+ * Reset to original bundle
35
+ */
36
+ reset(): Promise<void>;
37
+ /**
38
+ * Get current bundle info
39
+ */
40
+ current(): Promise<BundleInfo>;
41
+ /**
42
+ * List all downloaded bundles
43
+ */
44
+ list(): Promise<BundleInfo[]>;
45
+ /**
46
+ * Delete bundles
47
+ */
48
+ delete(options: DeleteOptions): Promise<void>;
49
+ /**
50
+ * Notify app is ready after update
51
+ */
52
+ notifyAppReady(): Promise<void>;
53
+ /**
54
+ * Check for latest version
55
+ */
56
+ getLatest(): Promise<LatestVersion>;
57
+ /**
58
+ * Switch update channel
59
+ */
60
+ setChannel(channel: string): Promise<void>;
61
+ /**
62
+ * Set update server URL
63
+ */
64
+ setUpdateUrl(url: string): Promise<void>;
65
+ /**
66
+ * Validate an update bundle
67
+ */
68
+ validateUpdate(options: ValidateOptions): Promise<ValidationResult>;
69
+ }
70
+ /**
71
+ * App Update Plugin Interface
72
+ */
73
+ export interface AppUpdatePlugin {
74
+ /**
75
+ * Get app update information
76
+ */
77
+ getAppUpdateInfo(): Promise<AppUpdateInfo>;
78
+ /**
79
+ * Perform immediate update
80
+ */
81
+ performImmediateUpdate(): Promise<void>;
82
+ /**
83
+ * Start flexible update
84
+ */
85
+ startFlexibleUpdate(): Promise<void>;
86
+ /**
87
+ * Complete flexible update
88
+ */
89
+ completeFlexibleUpdate(): Promise<void>;
90
+ /**
91
+ * Open app store page
92
+ */
93
+ openAppStore(options?: OpenAppStoreOptions): Promise<void>;
94
+ }
95
+ /**
96
+ * App Review Plugin Interface
97
+ */
98
+ export interface AppReviewPlugin {
99
+ /**
100
+ * Request in-app review
101
+ */
102
+ requestReview(): Promise<ReviewResult>;
103
+ /**
104
+ * Check if review can be requested
105
+ */
106
+ canRequestReview(): Promise<CanRequestReviewResult>;
107
+ }
108
+ /**
109
+ * Background Update Plugin Interface
110
+ */
111
+ export interface BackgroundUpdatePlugin {
112
+ /**
113
+ * Enable background update checking
114
+ */
115
+ enableBackgroundUpdates(config: BackgroundUpdateConfig): Promise<void>;
116
+ /**
117
+ * Disable background update checking
118
+ */
119
+ disableBackgroundUpdates(): Promise<void>;
120
+ /**
121
+ * Get current background update status
122
+ */
123
+ getBackgroundUpdateStatus(): Promise<BackgroundUpdateStatus>;
124
+ /**
125
+ * Schedule background update check with specific interval
126
+ */
127
+ scheduleBackgroundCheck(interval: number): Promise<void>;
128
+ /**
129
+ * Manually trigger background update check
130
+ */
131
+ triggerBackgroundCheck(): Promise<BackgroundCheckResult>;
132
+ /**
133
+ * Configure notification preferences
134
+ */
135
+ setNotificationPreferences(preferences: NotificationPreferences): Promise<void>;
136
+ /**
137
+ * Get notification permissions status
138
+ */
139
+ getNotificationPermissions(): Promise<NotificationPermissionStatus>;
140
+ /**
141
+ * Request notification permissions
142
+ */
143
+ requestNotificationPermissions(): Promise<boolean>;
144
+ }
145
+ /**
146
+ * Combined plugin interface
147
+ */
148
+ export interface NativeUpdateCombinedPlugin extends NativeUpdatePlugin, LiveUpdatePlugin, AppUpdatePlugin, AppReviewPlugin, BackgroundUpdatePlugin {
149
+ }
150
+ /**
151
+ * Configuration Types
152
+ */
153
+ export interface PluginConfig {
154
+ serverUrl?: string;
155
+ channel?: string;
156
+ autoCheck?: boolean;
157
+ autoUpdate?: boolean;
158
+ updateStrategy?: UpdateStrategy;
159
+ publicKey?: string;
160
+ requireSignature?: boolean;
161
+ checksumAlgorithm?: ChecksumAlgorithm;
162
+ checkInterval?: number;
163
+ security?: SecurityConfig;
164
+ }
165
+ export interface UpdateConfig {
166
+ liveUpdate?: LiveUpdateConfig;
167
+ appUpdate?: AppUpdateConfig;
168
+ appReview?: AppReviewConfig;
169
+ backgroundUpdate?: BackgroundUpdateConfig;
170
+ security?: SecurityConfig;
171
+ }
172
+ export interface LiveUpdateConfig {
173
+ appId: string;
174
+ serverUrl: string;
175
+ channel?: string;
176
+ autoUpdate?: boolean;
177
+ updateStrategy?: UpdateStrategy;
178
+ publicKey?: string;
179
+ requireSignature?: boolean;
180
+ checksumAlgorithm?: ChecksumAlgorithm;
181
+ checkInterval?: number;
182
+ allowEmulator?: boolean;
183
+ mandatoryInstallMode?: InstallMode;
184
+ optionalInstallMode?: InstallMode;
185
+ maxBundleSize?: number;
186
+ allowedHosts?: string[];
187
+ }
188
+ export interface AppUpdateConfig {
189
+ minimumVersion?: string;
190
+ updatePriority?: number;
191
+ storeUrl?: {
192
+ android?: string;
193
+ ios?: string;
194
+ };
195
+ checkOnAppStart?: boolean;
196
+ allowDowngrade?: boolean;
197
+ }
198
+ export interface AppReviewConfig {
199
+ minimumDaysSinceInstall?: number;
200
+ minimumDaysSinceLastPrompt?: number;
201
+ minimumLaunchCount?: number;
202
+ customTriggers?: string[];
203
+ debugMode?: boolean;
204
+ }
205
+ export interface BackgroundUpdateConfig {
206
+ enabled: boolean;
207
+ checkInterval: number;
208
+ updateTypes: BackgroundUpdateType[];
209
+ autoInstall?: boolean;
210
+ notificationPreferences?: NotificationPreferences;
211
+ respectBatteryOptimization?: boolean;
212
+ allowMeteredConnection?: boolean;
213
+ minimumBatteryLevel?: number;
214
+ requireWifi?: boolean;
215
+ maxRetries?: number;
216
+ retryDelay?: number;
217
+ taskIdentifier?: string;
218
+ }
219
+ export interface SecurityConfig {
220
+ enforceHttps?: boolean;
221
+ certificatePinning?: CertificatePinning;
222
+ validateInputs?: boolean;
223
+ secureStorage?: boolean;
224
+ logSecurityEvents?: boolean;
225
+ }
226
+ export interface CertificatePinning {
227
+ enabled: boolean;
228
+ pins: CertificatePin[];
229
+ }
230
+ export interface CertificatePin {
231
+ hostname: string;
232
+ sha256: string[];
233
+ }
234
+ /**
235
+ * Live Update Types
236
+ */
237
+ export interface SyncOptions {
238
+ channel?: string;
239
+ updateMode?: UpdateMode;
240
+ }
241
+ export interface SyncResult {
242
+ status: SyncStatus;
243
+ version?: string;
244
+ description?: string;
245
+ mandatory?: boolean;
246
+ error?: UpdateError;
247
+ }
248
+ export interface DownloadOptions {
249
+ url: string;
250
+ version: string;
251
+ checksum: string;
252
+ signature?: string;
253
+ maxRetries?: number;
254
+ timeout?: number;
255
+ }
256
+ export interface BundleInfo {
257
+ bundleId: string;
258
+ version: string;
259
+ path: string;
260
+ downloadTime: number;
261
+ size: number;
262
+ status: BundleStatus;
263
+ checksum: string;
264
+ signature?: string;
265
+ verified: boolean;
266
+ metadata?: Record<string, unknown>;
267
+ }
268
+ export interface DeleteOptions {
269
+ bundleId?: string;
270
+ keepVersions?: number;
271
+ olderThan?: number;
272
+ }
273
+ export interface UpdateOptions {
274
+ allowDowngrade?: boolean;
275
+ cleanupOldBundles?: boolean;
276
+ keepBundleCount?: number;
277
+ }
278
+ export interface LatestVersion {
279
+ available: boolean;
280
+ version?: string;
281
+ url?: string;
282
+ mandatory?: boolean;
283
+ notes?: string;
284
+ size?: number;
285
+ }
286
+ export interface ValidateOptions {
287
+ bundlePath: string;
288
+ checksum: string;
289
+ signature?: string;
290
+ maxSize?: number;
291
+ }
292
+ export interface ValidationResult {
293
+ isValid: boolean;
294
+ error?: string;
295
+ details?: {
296
+ checksumValid?: boolean;
297
+ signatureValid?: boolean;
298
+ sizeValid?: boolean;
299
+ versionValid?: boolean;
300
+ };
301
+ }
302
+ /**
303
+ * App Update Types
304
+ */
305
+ export interface AppUpdateInfo {
306
+ updateAvailable: boolean;
307
+ currentVersion: string;
308
+ availableVersion?: string;
309
+ updatePriority?: number;
310
+ immediateUpdateAllowed?: boolean;
311
+ flexibleUpdateAllowed?: boolean;
312
+ clientVersionStalenessDays?: number;
313
+ installStatus?: InstallStatus;
314
+ bytesDownloaded?: number;
315
+ totalBytesToDownload?: number;
316
+ }
317
+ export interface OpenAppStoreOptions {
318
+ appId?: string;
319
+ }
320
+ /**
321
+ * App Review Types
322
+ */
323
+ export interface ReviewResult {
324
+ displayed: boolean;
325
+ error?: string;
326
+ reason?: string;
327
+ }
328
+ export interface CanRequestReviewResult {
329
+ canRequest: boolean;
330
+ reason?: string;
331
+ }
332
+ /**
333
+ * Background Update Types
334
+ */
335
+ export interface BackgroundUpdateStatus {
336
+ enabled: boolean;
337
+ lastCheckTime?: number;
338
+ nextCheckTime?: number;
339
+ lastUpdateTime?: number;
340
+ currentTaskId?: string;
341
+ isRunning: boolean;
342
+ checkCount: number;
343
+ failureCount: number;
344
+ lastError?: UpdateError;
345
+ }
346
+ export interface BackgroundCheckResult {
347
+ success: boolean;
348
+ updatesFound: boolean;
349
+ appUpdate?: AppUpdateInfo;
350
+ liveUpdate?: LatestVersion;
351
+ notificationSent: boolean;
352
+ error?: UpdateError;
353
+ }
354
+ export interface NotificationPreferences {
355
+ title?: string;
356
+ description?: string;
357
+ iconName?: string;
358
+ soundEnabled?: boolean;
359
+ vibrationEnabled?: boolean;
360
+ showActions?: boolean;
361
+ actionLabels?: {
362
+ updateNow?: string;
363
+ updateLater?: string;
364
+ dismiss?: string;
365
+ };
366
+ channelId?: string;
367
+ channelName?: string;
368
+ priority?: NotificationPriority;
369
+ }
370
+ export interface NotificationPermissionStatus {
371
+ granted: boolean;
372
+ canRequest: boolean;
373
+ shouldShowRationale?: boolean;
374
+ }
375
+ /**
376
+ * Security Types
377
+ */
378
+ export interface SecurityInfo {
379
+ enforceHttps: boolean;
380
+ certificatePinning: CertificatePinning;
381
+ validateInputs: boolean;
382
+ secureStorage: boolean;
383
+ }
384
+ /**
385
+ * Error Types
386
+ */
387
+ export interface UpdateError {
388
+ code: UpdateErrorCode;
389
+ message: string;
390
+ details?: unknown;
391
+ }
392
+ /**
393
+ * Enums
394
+ */
395
+ export declare enum BackgroundUpdateType {
396
+ APP_UPDATE = "app_update",
397
+ LIVE_UPDATE = "live_update",
398
+ BOTH = "both"
399
+ }
400
+ export declare enum NotificationPriority {
401
+ MIN = "min",
402
+ LOW = "low",
403
+ DEFAULT = "default",
404
+ HIGH = "high",
405
+ MAX = "max"
406
+ }
407
+ export declare enum UpdateStrategy {
408
+ IMMEDIATE = "immediate",
409
+ BACKGROUND = "background",
410
+ MANUAL = "manual"
411
+ }
412
+ export declare enum UpdateMode {
413
+ IMMEDIATE = "immediate",
414
+ ON_NEXT_RESTART = "on_next_restart",
415
+ ON_NEXT_RESUME = "on_next_resume"
416
+ }
417
+ export declare enum InstallMode {
418
+ IMMEDIATE = "immediate",
419
+ ON_NEXT_RESTART = "on_next_restart",
420
+ ON_NEXT_RESUME = "on_next_resume"
421
+ }
422
+ export declare enum ChecksumAlgorithm {
423
+ SHA256 = "SHA-256",
424
+ SHA512 = "SHA-512"
425
+ }
426
+ export declare enum SyncStatus {
427
+ UP_TO_DATE = "UP_TO_DATE",
428
+ UPDATE_AVAILABLE = "UPDATE_AVAILABLE",
429
+ UPDATE_INSTALLED = "UPDATE_INSTALLED",
430
+ ERROR = "ERROR"
431
+ }
432
+ export declare enum BundleStatus {
433
+ PENDING = "PENDING",
434
+ DOWNLOADING = "DOWNLOADING",
435
+ READY = "READY",
436
+ ACTIVE = "ACTIVE",
437
+ FAILED = "FAILED"
438
+ }
439
+ export declare enum InstallStatus {
440
+ UNKNOWN = "UNKNOWN",
441
+ PENDING = "PENDING",
442
+ DOWNLOADING = "DOWNLOADING",
443
+ DOWNLOADED = "DOWNLOADED",
444
+ INSTALLING = "INSTALLING",
445
+ INSTALLED = "INSTALLED",
446
+ FAILED = "FAILED",
447
+ CANCELED = "CANCELED"
448
+ }
449
+ export declare enum UpdateErrorCode {
450
+ NETWORK_ERROR = "NETWORK_ERROR",
451
+ SERVER_ERROR = "SERVER_ERROR",
452
+ TIMEOUT_ERROR = "TIMEOUT_ERROR",
453
+ DOWNLOAD_ERROR = "DOWNLOAD_ERROR",
454
+ STORAGE_ERROR = "STORAGE_ERROR",
455
+ SIZE_LIMIT_EXCEEDED = "SIZE_LIMIT_EXCEEDED",
456
+ VERIFICATION_ERROR = "VERIFICATION_ERROR",
457
+ CHECKSUM_ERROR = "CHECKSUM_ERROR",
458
+ SIGNATURE_ERROR = "SIGNATURE_ERROR",
459
+ INSECURE_URL = "INSECURE_URL",
460
+ INVALID_CERTIFICATE = "INVALID_CERTIFICATE",
461
+ PATH_TRAVERSAL = "PATH_TRAVERSAL",
462
+ INSTALL_ERROR = "INSTALL_ERROR",
463
+ ROLLBACK_ERROR = "ROLLBACK_ERROR",
464
+ VERSION_MISMATCH = "VERSION_MISMATCH",
465
+ PERMISSION_DENIED = "PERMISSION_DENIED",
466
+ UPDATE_NOT_AVAILABLE = "UPDATE_NOT_AVAILABLE",
467
+ UPDATE_IN_PROGRESS = "UPDATE_IN_PROGRESS",
468
+ UPDATE_CANCELLED = "UPDATE_CANCELLED",
469
+ PLATFORM_NOT_SUPPORTED = "PLATFORM_NOT_SUPPORTED",
470
+ REVIEW_NOT_SUPPORTED = "REVIEW_NOT_SUPPORTED",
471
+ QUOTA_EXCEEDED = "QUOTA_EXCEEDED",
472
+ CONDITIONS_NOT_MET = "CONDITIONS_NOT_MET",
473
+ INVALID_CONFIG = "INVALID_CONFIG",
474
+ UNKNOWN_ERROR = "UNKNOWN_ERROR"
475
+ }
476
+ /**
477
+ * Event Types
478
+ */
479
+ export interface DownloadProgressEvent {
480
+ percent: number;
481
+ bytesDownloaded: number;
482
+ totalBytes: number;
483
+ bundleId: string;
484
+ }
485
+ export interface UpdateStateChangedEvent {
486
+ status: BundleStatus;
487
+ bundleId: string;
488
+ version: string;
489
+ }
490
+ export interface BackgroundUpdateProgressEvent {
491
+ type: BackgroundUpdateType;
492
+ status: 'checking' | 'downloading' | 'installing' | 'completed' | 'failed';
493
+ percent?: number;
494
+ error?: UpdateError;
495
+ }
496
+ export interface BackgroundUpdateNotificationEvent {
497
+ type: BackgroundUpdateType;
498
+ updateAvailable: boolean;
499
+ version?: string;
500
+ action?: 'shown' | 'tapped' | 'dismissed';
501
+ }
502
+ /**
503
+ * Plugin Events
504
+ */
505
+ export interface PluginListenerHandle {
506
+ remove: () => Promise<void>;
507
+ }
508
+ export interface NativeUpdateListeners {
509
+ /**
510
+ * Listen for download progress
511
+ */
512
+ addListener(eventName: 'downloadProgress', listenerFunc: (event: DownloadProgressEvent) => void): Promise<PluginListenerHandle>;
513
+ /**
514
+ * Listen for update state changes
515
+ */
516
+ addListener(eventName: 'updateStateChanged', listenerFunc: (event: UpdateStateChangedEvent) => void): Promise<PluginListenerHandle>;
517
+ /**
518
+ * Listen for background update progress
519
+ */
520
+ addListener(eventName: 'backgroundUpdateProgress', listenerFunc: (event: BackgroundUpdateProgressEvent) => void): Promise<PluginListenerHandle>;
521
+ /**
522
+ * Listen for background update notifications
523
+ */
524
+ addListener(eventName: 'backgroundUpdateNotification', listenerFunc: (event: BackgroundUpdateNotificationEvent) => void): Promise<PluginListenerHandle>;
525
+ /**
526
+ * Remove all listeners
527
+ */
528
+ removeAllListeners(): Promise<void>;
529
+ }
530
+ /**
531
+ * Plugin initialization configuration options
532
+ */
533
+ export interface PluginInitConfig {
534
+ /**
535
+ * Capacitor Filesystem instance (required)
536
+ */
537
+ filesystem?: typeof import('@capacitor/filesystem').Filesystem;
538
+ /**
539
+ * Capacitor Preferences instance (required)
540
+ */
541
+ preferences?: typeof import('@capacitor/preferences').Preferences;
542
+ /**
543
+ * Base URL for update server
544
+ */
545
+ baseUrl?: string;
546
+ /**
547
+ * List of allowed hosts for security
548
+ */
549
+ allowedHosts?: string[];
550
+ /**
551
+ * Maximum bundle size in bytes (default: 100MB)
552
+ */
553
+ maxBundleSize?: number;
554
+ /**
555
+ * Download timeout in milliseconds (default: 30000)
556
+ */
557
+ downloadTimeout?: number;
558
+ /**
559
+ * Number of retry attempts for failed downloads (default: 3)
560
+ */
561
+ retryAttempts?: number;
562
+ /**
563
+ * Delay between retry attempts in milliseconds (default: 1000)
564
+ */
565
+ retryDelay?: number;
566
+ /**
567
+ * Enable bundle signature validation (default: true)
568
+ */
569
+ enableSignatureValidation?: boolean;
570
+ /**
571
+ * Public key for signature validation
572
+ */
573
+ publicKey?: string;
574
+ /**
575
+ * Cache expiration time in milliseconds (default: 24 hours)
576
+ */
577
+ cacheExpiration?: number;
578
+ /**
579
+ * Enable debug logging (default: false)
580
+ */
581
+ enableLogging?: boolean;
582
+ /**
583
+ * Server URL for update checks
584
+ */
585
+ serverUrl?: string;
586
+ /**
587
+ * Update channel
588
+ */
589
+ channel?: string;
590
+ /**
591
+ * Enable automatic update checking
592
+ */
593
+ autoCheck?: boolean;
594
+ /**
595
+ * Enable automatic updates
596
+ */
597
+ autoUpdate?: boolean;
598
+ /**
599
+ * Update strategy
600
+ */
601
+ updateStrategy?: UpdateStrategy;
602
+ /**
603
+ * Require bundle signatures
604
+ */
605
+ requireSignature?: boolean;
606
+ /**
607
+ * Checksum algorithm to use
608
+ */
609
+ checksumAlgorithm?: ChecksumAlgorithm;
610
+ /**
611
+ * Update check interval in milliseconds
612
+ */
613
+ checkInterval?: number;
614
+ /**
615
+ * Security configuration
616
+ */
617
+ security?: SecurityConfig;
618
+ }
619
+ /**
620
+ * Main plugin interface with initialization
621
+ */
622
+ export interface CapacitorNativeUpdatePlugin extends NativeUpdateCombinedPlugin {
623
+ /**
624
+ * Initialize the plugin with configuration
625
+ */
626
+ initialize(config: PluginInitConfig): Promise<void>;
627
+ /**
628
+ * Check if plugin is initialized
629
+ */
630
+ isInitialized(): boolean;
631
+ /**
632
+ * Reset plugin state
633
+ */
634
+ reset(): Promise<void>;
635
+ /**
636
+ * Clean up resources
637
+ */
638
+ cleanup(): Promise<void>;
639
+ }