@capgo/capacitor-updater 6.12.3 → 6.13.1

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.
@@ -60,7 +60,7 @@ public class CapacitorUpdaterPlugin extends Plugin {
60
60
  private static final String channelUrlDefault =
61
61
  "https://plugin.capgo.app/channel_self";
62
62
 
63
- private final String PLUGIN_VERSION = "6.12.3";
63
+ private final String PLUGIN_VERSION = "6.13.1";
64
64
  private static final String DELAY_CONDITION_PREFERENCES = "";
65
65
 
66
66
  private SharedPreferences.Editor editor;
@@ -385,6 +385,15 @@ typealias ZipArchiveHelper = SSZipArchive
385
385
  switch response.result {
386
386
  case .success(let data):
387
387
  do {
388
+ let statusCode = response.response?.statusCode ?? 200
389
+ if statusCode < 200 || statusCode >= 300 {
390
+ if let stringData = String(data: data, encoding: .utf8) {
391
+ throw NSError(domain: "StatusCodeError", code: 2, userInfo: [NSLocalizedDescriptionKey: "Failed to fetch. Status code (\(statusCode)) invalid. Data: \(stringData)"])
392
+ } else {
393
+ throw NSError(domain: "StatusCodeError", code: 2, userInfo: [NSLocalizedDescriptionKey: "Failed to fetch. Status code (\(statusCode)) invalid"])
394
+ }
395
+ }
396
+
388
397
  // Add decryption step if public key is set and sessionKey is provided
389
398
  var finalData = data
390
399
  if !self.publicKey.isEmpty && !sessionKey.isEmpty {
@@ -428,8 +437,7 @@ typealias ZipArchiveHelper = SSZipArchive
428
437
  print("\(CapacitorUpdater.TAG) downloadManifest \(id) \(fileName) error: \(error)")
429
438
  }
430
439
  case .failure(let error):
431
- downloadError = error
432
- print("\(CapacitorUpdater.TAG) downloadManifest \(id) \(fileName) download error: \(error)")
440
+ print("\(CapacitorUpdater.TAG) downloadManifest \(id) \(fileName) download error: \(error). Debug response: \(response.debugDescription).")
433
441
  }
434
442
  }
435
443
  }
@@ -504,6 +512,14 @@ typealias ZipArchiveHelper = SSZipArchive
504
512
  break
505
513
  } else if status == COMPRESSION_STATUS_ERROR {
506
514
  print("\(CapacitorUpdater.TAG) Error during Brotli decompression")
515
+ // Try to decode as text if mostly ASCII
516
+ if let text = String(data: data, encoding: .utf8) {
517
+ let asciiCount = text.unicodeScalars.filter { $0.isASCII }.count
518
+ let totalCount = text.unicodeScalars.count
519
+ if totalCount > 0 && Double(asciiCount) / Double(totalCount) >= 0.8 {
520
+ print("\(CapacitorUpdater.TAG) Compressed data as text: \(text)")
521
+ }
522
+ }
507
523
  return nil
508
524
  }
509
525
 
@@ -759,16 +775,16 @@ typealias ZipArchiveHelper = SSZipArchive
759
775
  print("\(CapacitorUpdater.TAG) Cannot delete \(id)")
760
776
  return false
761
777
  }
762
-
778
+
763
779
  // Check if this is the next bundle and prevent deletion if it is
764
780
  if let next = self.getNextBundle(),
765
- !next.isDeleted() &&
781
+ !next.isDeleted() &&
766
782
  !next.isErrorStatus() &&
767
783
  next.getId() == id {
768
784
  print("\(CapacitorUpdater.TAG) Cannot delete the next bundle \(id)")
769
785
  return false
770
786
  }
771
-
787
+
772
788
  let destPersist: URL = libraryDir.appendingPathComponent(bundleDirectory).appendingPathComponent(id)
773
789
  do {
774
790
  try FileManager.default.removeItem(atPath: destPersist.path)
@@ -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 = "6.12.3"
48
+ private let PLUGIN_VERSION: String = "6.13.1"
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"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/capacitor-updater",
3
- "version": "6.12.3",
3
+ "version": "6.13.1",
4
4
  "license": "MPL-2.0",
5
5
  "description": "Live update for capacitor apps",
6
6
  "main": "dist/plugin.cjs.js",