@capgo/capacitor-updater 9.0.1 → 9.0.2

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 (26) hide show
  1. package/README.md +106 -81
  2. package/android/build.gradle +1 -3
  3. package/android/src/main/java/ee/forgr/capacitor_updater/CapacitorUpdaterPlugin.java +513 -21
  4. package/android/src/main/java/ee/forgr/capacitor_updater/CapgoUpdater.java +675 -34
  5. package/android/src/main/java/ee/forgr/capacitor_updater/DownloadService.java +82 -10
  6. package/android/src/main/java/ee/forgr/capacitor_updater/DownloadWorkerManager.java +23 -0
  7. package/android/src/main/java/ee/forgr/capacitor_updater/HeadlessUpdateWorker.java +188 -4
  8. package/android/src/main/java/ee/forgr/capacitor_updater/Http3.java +81 -1
  9. package/android/src/main/java/ee/forgr/capacitor_updater/HttpEngineTransport.java +72 -21
  10. package/android/src/main/java/ee/forgr/capacitor_updater/ShakeMenu.java +5 -1
  11. package/dist/docs.json +13 -13
  12. package/dist/esm/definitions.d.ts +57 -23
  13. package/dist/esm/definitions.js.map +1 -1
  14. package/ios/Sources/CapacitorUpdaterPlugin/CapacitorUpdaterPlugin.swift +1278 -107
  15. package/ios/Sources/CapacitorUpdaterPlugin/CapgoSemanticVersion.swift +38 -0
  16. package/ios/Sources/CapacitorUpdaterPlugin/CapgoUpdater.swift +583 -56
  17. package/ios/Sources/CapacitorUpdaterPlugin/CryptoCipher.swift +8 -1
  18. package/ios/Sources/CapacitorUpdaterPlugin/ShakeMenu.swift +6 -1
  19. package/ios/Tests/CapacitorUpdaterPluginTests/CapacitorUpdaterPluginTests.swift +2705 -77
  20. package/ios/Tests/CapacitorUpdaterPluginTests/ChecksumRequiredTests.swift +9 -4
  21. package/ios/Tests/CapacitorUpdaterPluginTests/CliCryptoFixtureTests.swift +67 -2
  22. package/ios/Tests/CapacitorUpdaterPluginTests/HttpsOnlyBuiltinMinimumTests.swift +130 -5
  23. package/ios/Tests/CapacitorUpdaterPluginTests/NetworkTransportTests.swift +22 -8
  24. package/ios/Tests/CapacitorUpdaterPluginTests/SessionKeyRequiredTests.swift +4 -0
  25. package/ios/Tests/CapacitorUpdaterPluginTests/UpdateLifecycleTests.swift +19 -3
  26. package/package.json +2 -2
@@ -234,10 +234,17 @@ public struct CryptoCipher {
234
234
  return sessionKeyParts.count == 2 && !sessionKeyParts[0].isEmpty && !sessionKeyParts[1].isEmpty
235
235
  }
236
236
 
237
+ static func validateDecryptionKey(publicKey: String, sessionKey: String) throws {
238
+ guard !publicKey.isEmpty else {
239
+ return
240
+ }
241
+ _ = try prepareDecryptionKey(publicKey: publicKey, sessionKey: sessionKey)
242
+ }
243
+
237
244
  /// Decrypts `filePath` in place. `expectedCiphertextSha256` is `BundleChecksum.ciphertext`: the file is hashed
238
245
  /// and rejected before any AES work when it does not match.
239
246
  public static func decryptFile(
240
- filePath: URL, publicKey: String, sessionKey: String, version: String, expectedCiphertextSha256: String?
247
+ filePath: URL, publicKey: String, sessionKey: String, version _: String, expectedCiphertextSha256: String?
241
248
  ) throws {
242
249
  if publicKey.isEmpty || !isValidSessionKey(sessionKey) {
243
250
  logger.info("Encryption not set, no public key or session, ignored")
@@ -358,7 +358,12 @@ extension UIWindow {
358
358
  }
359
359
  if !next.isBuiltin() {
360
360
  plugin.logger.info("Resetting to: \(next.toString())")
361
- _ = updater.set(bundle: next)
361
+ // A pending bundle below the native version floor is rejected: never load it, fall back to builtin.
362
+ guard updater.set(bundle: next) else {
363
+ plugin.logger.warn("Cannot activate \(next.toString()), resetting to builtin")
364
+ resetBuiltin()
365
+ return
366
+ }
362
367
  guard let destHot = try? updater.getBundleDirectory(id: next.getId()) else {
363
368
  resetBuiltin()
364
369
  return