@capgo/capacitor-updater 7.0.32 → 7.0.34

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.
@@ -57,7 +57,7 @@ public class CapacitorUpdaterPlugin extends Plugin {
57
57
  private static final String statsUrlDefault = "https://plugin.capgo.app/stats";
58
58
  private static final String channelUrlDefault = "https://plugin.capgo.app/channel_self";
59
59
 
60
- private final String PLUGIN_VERSION = "7.0.32";
60
+ private final String PLUGIN_VERSION = "7.0.34";
61
61
  private static final String DELAY_CONDITION_PREFERENCES = "";
62
62
 
63
63
  private SharedPreferences.Editor editor;
@@ -263,7 +263,7 @@ public class DownloadService extends Worker {
263
263
  if (infoFile.exists() && tempFile.exists()) {
264
264
  try (BufferedReader reader = new BufferedReader(new FileReader(infoFile))) {
265
265
  String updateVersion = reader.readLine();
266
- if (!updateVersion.equals(version)) {
266
+ if (updateVersion != null && !updateVersion.equals(version)) {
267
267
  clearDownloadData(documentsDir);
268
268
  } else {
269
269
  downloadedBytes = tempFile.length();
@@ -353,27 +353,6 @@ import UIKit
353
353
  return actualHash == expectedHash
354
354
  }
355
355
 
356
- public func decryptChecksum(checksum: String, version: String) throws -> String {
357
- if self.publicKey.isEmpty {
358
- return checksum
359
- }
360
- do {
361
- let checksumBytes: Data = Data(base64Encoded: checksum)!
362
- guard let rsaPublicKey: RSAPublicKey = .load(rsaPublicKey: self.publicKey) else {
363
- print("cannot decode publicKey", self.publicKey)
364
- throw CustomError.cannotDecode
365
- }
366
- guard let decryptedChecksum = rsaPublicKey.decrypt(data: checksumBytes) else {
367
- throw NSError(domain: "Failed to decrypt session key data", code: 2, userInfo: nil)
368
- }
369
- return decryptedChecksum.base64EncodedString()
370
- } catch {
371
- print("\(CapacitorUpdater.TAG) Cannot decrypt checksum: \(checksum)", error)
372
- self.sendStats(action: "decrypt_fail", versionName: version)
373
- throw CustomError.cannotDecode
374
- }
375
- }
376
-
377
356
  public func downloadManifest(manifest: [ManifestEntry], version: String, sessionKey: String) throws -> BundleInfo {
378
357
  let id = self.randomString(length: 10)
379
358
  print("\(CapacitorUpdater.TAG) downloadManifest start \(id)")
@@ -45,7 +45,7 @@ public class CapacitorUpdaterPlugin: CAPPlugin, CAPBridgedPlugin {
45
45
  CAPPluginMethod(name: "getNextBundle", returnType: CAPPluginReturnPromise)
46
46
  ]
47
47
  public var implementation = CapacitorUpdater()
48
- private let PLUGIN_VERSION: String = "7.0.32"
48
+ private let PLUGIN_VERSION: String = "7.0.34"
49
49
  static let updateUrlDefault = "https://plugin.capgo.app/updates"
50
50
  static let statsUrlDefault = "https://plugin.capgo.app/stats"
51
51
  static let channelUrlDefault = "https://plugin.capgo.app/channel_self"
@@ -291,7 +291,7 @@ public class CapacitorUpdaterPlugin: CAPPlugin, CAPBridgedPlugin {
291
291
  DispatchQueue.global(qos: .background).async {
292
292
  do {
293
293
  let next = try self.implementation.download(url: url!, version: version, sessionKey: sessionKey)
294
- checksum = try self.implementation.decryptChecksum(checksum: checksum, version: version)
294
+ checksum = try CryptoCipherV2.decryptChecksum(checksum: checksum, publicKey: self.implementation.publicKey, version: version)
295
295
  if (checksum != "" || self.implementation.publicKey != "") && next.getChecksum() != checksum {
296
296
  print("\(CapacitorUpdater.TAG) Error checksum", next.getChecksum(), checksum)
297
297
  self.implementation.sendStats(action: "checksum_fail", versionName: next.getVersionName())
@@ -805,7 +805,7 @@ public class CapacitorUpdaterPlugin: CAPPlugin, CAPBridgedPlugin {
805
805
  self.endBackGroundTaskWithNotif(msg: "Latest version is in error state. Aborting update.", latestVersionName: latestVersionName, current: current)
806
806
  return
807
807
  }
808
- res.checksum = try self.implementation.decryptChecksum(checksum: res.checksum, version: latestVersionName)
808
+ res.checksum = try CryptoCipherV2.decryptChecksum(checksum: res.checksum, publicKey: self.implementation.publicKey, version: latestVersionName)
809
809
  if res.checksum != "" && next.getChecksum() != res.checksum && res.manifest == nil {
810
810
  print("\(CapacitorUpdater.TAG) Error checksum", next.getChecksum(), res.checksum)
811
811
  self.implementation.sendStats(action: "checksum_fail", versionName: next.getVersionName())
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/capacitor-updater",
3
- "version": "7.0.32",
3
+ "version": "7.0.34",
4
4
  "license": "MPL-2.0",
5
5
  "description": "Live update for capacitor apps",
6
6
  "main": "dist/plugin.cjs.js",