@capgo/capacitor-updater 4.13.3 → 4.13.5

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.
@@ -54,7 +54,7 @@ public class CapacitorUpdater {
54
54
  private static final String bundleDirectory = "versions";
55
55
 
56
56
  public static final String TAG = "Capacitor-updater";
57
- public static final String pluginVersion = "4.13.3";
57
+ public static final String pluginVersion = "4.13.5";
58
58
 
59
59
  public SharedPreferences.Editor editor;
60
60
  public SharedPreferences prefs;
@@ -28,10 +28,10 @@ public class SetChannel: NSObject {
28
28
  }
29
29
  extension SetChannel {
30
30
  func toDict() -> [String: Any] {
31
- var dict = [String: Any]()
32
- let otherSelf = Mirror(reflecting: self)
33
- for child in otherSelf.children {
34
- if let key = child.label {
31
+ var dict: [String : Any] = [String: Any]()
32
+ let otherSelf: Mirror = Mirror(reflecting: self)
33
+ for child: Mirror.Child in otherSelf.children {
34
+ if let key: String = child.label {
35
35
  dict[key] = child.value
36
36
  }
37
37
  }
@@ -54,10 +54,10 @@ public class GetChannel: NSObject {
54
54
  }
55
55
  extension GetChannel {
56
56
  func toDict() -> [String: Any] {
57
- var dict = [String: Any]()
58
- let otherSelf = Mirror(reflecting: self)
59
- for child in otherSelf.children {
60
- if let key = child.label {
57
+ var dict: [String : Any] = [String: Any]()
58
+ let otherSelf: Mirror = Mirror(reflecting: self)
59
+ for child: Mirror.Child in otherSelf.children {
60
+ if let key: String = child.label {
61
61
  dict[key] = child.value
62
62
  }
63
63
  }
@@ -100,10 +100,10 @@ public class AppVersion: NSObject {
100
100
 
101
101
  extension AppVersion {
102
102
  func toDict() -> [String: Any] {
103
- var dict = [String: Any]()
104
- let otherSelf = Mirror(reflecting: self)
105
- for child in otherSelf.children {
106
- if let key = child.label {
103
+ var dict: [String : Any] = [String: Any]()
104
+ let otherSelf: Mirror = Mirror(reflecting: self)
105
+ for child: Mirror.Child in otherSelf.children {
106
+ if let key: String = child.label {
107
107
  dict[key] = child.value
108
108
  }
109
109
  }
@@ -132,7 +132,7 @@ extension ISO8601DateFormatter {
132
132
  }
133
133
  }
134
134
  extension Formatter {
135
- static let iso8601withFractionalSeconds = ISO8601DateFormatter([.withInternetDateTime, .withFractionalSeconds])
135
+ static let iso8601withFractionalSeconds: ISO8601DateFormatter = ISO8601DateFormatter([.withInternetDateTime, .withFractionalSeconds])
136
136
  }
137
137
  extension Date {
138
138
  var iso8601withFractionalSeconds: String { return Formatter.iso8601withFractionalSeconds.string(from: self) }
@@ -213,27 +213,27 @@ extension CustomError: LocalizedError {
213
213
 
214
214
  @objc public class CapacitorUpdater: NSObject {
215
215
 
216
- private let versionName = Bundle.main.versionName ?? ""
217
- private let versionCode = Bundle.main.versionCode ?? ""
216
+ private let versionName: String = Bundle.main.versionName ?? ""
217
+ private let versionCode: String = Bundle.main.versionCode ?? ""
218
218
  private let versionOs = UIDevice.current.systemVersion
219
- private let documentsDir = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first!
220
- private let libraryDir = FileManager.default.urls(for: .libraryDirectory, in: .userDomainMask).first!
221
- private let bundleDirectoryHot = "versions"
222
- private let DEFAULT_FOLDER = ""
223
- private let bundleDirectory = "NoCloud/ionic_built_snapshots"
224
- private let INFO_SUFFIX = "_info"
225
- private let FALLBACK_VERSION = "pastVersion"
226
- private let NEXT_VERSION = "nextVersion"
227
-
228
- public let TAG = "✨ Capacitor-updater:"
229
- public let CAP_SERVER_PATH = "serverBasePath"
230
- public var customId = ""
231
- public let pluginVersion = "4.13.3"
232
- public var statsUrl = ""
233
- public var channelUrl = ""
234
- public var appId = ""
219
+ private let documentsDir: URL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first!
220
+ private let libraryDir: URL = FileManager.default.urls(for: .libraryDirectory, in: .userDomainMask).first!
221
+ private let bundleDirectoryHot: String = "versions"
222
+ private let DEFAULT_FOLDER: String = ""
223
+ private let bundleDirectory: String = "NoCloud/ionic_built_snapshots"
224
+ private let INFO_SUFFIX: String = "_info"
225
+ private let FALLBACK_VERSION: String = "pastVersion"
226
+ private let NEXT_VERSION: String = "nextVersion"
227
+
228
+ public let TAG: String = "✨ Capacitor-updater:"
229
+ public let CAP_SERVER_PATH: String = "serverBasePath"
230
+ public var customId: String = ""
231
+ public let pluginVersion: String = "4.13.4"
232
+ public var statsUrl: String = ""
233
+ public var channelUrl: String = ""
234
+ public var appId: String = ""
235
235
  public var deviceID = UIDevice.current.identifierForVendor?.uuidString ?? ""
236
- public var privateKey = ""
236
+ public var privateKey: String = ""
237
237
 
238
238
  public var notifyDownload: (String, Int) -> Void = { _, _ in }
239
239
 
@@ -242,7 +242,7 @@ extension CustomError: LocalizedError {
242
242
  }
243
243
 
244
244
  private func randomString(length: Int) -> String {
245
- let letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
245
+ let letters: String = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
246
246
  return String((0..<length).map { _ in letters.randomElement()! })
247
247
  }
248
248
 
@@ -263,7 +263,7 @@ extension CustomError: LocalizedError {
263
263
  if isEmulator() {
264
264
  return false
265
265
  } else {
266
- guard let url = Bundle.main.appStoreReceiptURL else {
266
+ guard let url: URL = Bundle.main.appStoreReceiptURL else {
267
267
  return false
268
268
  }
269
269
  guard url.lastPathComponent == "sandboxReceipt" else {
@@ -305,9 +305,9 @@ extension CustomError: LocalizedError {
305
305
  }
306
306
 
307
307
  private func unflatFolder(source: URL, dest: URL) throws -> Bool {
308
- let index = source.appendingPathComponent("index.html")
308
+ let index: URL = source.appendingPathComponent("index.html")
309
309
  do {
310
- let files = try FileManager.default.contentsOfDirectory(atPath: source.path)
310
+ let files: [String] = try FileManager.default.contentsOfDirectory(atPath: source.path)
311
311
  if files.count == 1 && source.appendingPathComponent(files[0]).isDirectory && !FileManager.default.fileExists(atPath: index.path) {
312
312
  try FileManager.default.moveItem(at: source.appendingPathComponent(files[0]), to: dest)
313
313
  return true
@@ -323,8 +323,8 @@ extension CustomError: LocalizedError {
323
323
 
324
324
  private func getChecksum(filePath: URL) -> String {
325
325
  do {
326
- let fileData = try Data.init(contentsOf: filePath)
327
- let checksum = fileData.withUnsafeBytes { crc32(0, $0.bindMemory(to: Bytef.self).baseAddress, uInt(fileData.count)) }
326
+ let fileData: Data = try Data.init(contentsOf: filePath)
327
+ let checksum: uLong = fileData.withUnsafeBytes { crc32(0, $0.bindMemory(to: Bytef.self).baseAddress, uInt(fileData.count)) }
328
328
  return String(format: "%08X", checksum).lowercased()
329
329
  } catch {
330
330
  print("\(self.TAG) Cannot get checksum: \(filePath.path)", error)
@@ -343,12 +343,12 @@ extension CustomError: LocalizedError {
343
343
  return
344
344
  }
345
345
 
346
- let sessionKeyArray = sessionKey.components(separatedBy: ":")
347
- let ivData = Data(base64Encoded: sessionKeyArray[0])!
348
- let sessionKeyDataEncrypted = Data(base64Encoded: sessionKeyArray[1])!
346
+ let sessionKeyArray: [String] = sessionKey.components(separatedBy: ":")
347
+ let ivData: Data = Data(base64Encoded: sessionKeyArray[0])!
348
+ let sessionKeyDataEncrypted: Data = Data(base64Encoded: sessionKeyArray[1])!
349
349
  let sessionKeyDataDecrypted: Data = rsaPrivateKey.decrypt(data: sessionKeyDataEncrypted)!
350
350
  let aesPrivateKey: AES128Key = AES128Key(iv: ivData, aes128Key: sessionKeyDataDecrypted)
351
- let encryptedData = try Data(contentsOf: filePath)
351
+ let encryptedData: Data = try Data(contentsOf: filePath)
352
352
  let decryptedData: Data = aesPrivateKey.decrypt(data: encryptedData)!
353
353
 
354
354
  try decryptedData.write(to: filePath)
@@ -360,8 +360,8 @@ extension CustomError: LocalizedError {
360
360
 
361
361
  private func saveDownloaded(sourceZip: URL, id: String, base: URL) throws {
362
362
  try prepareFolder(source: base)
363
- let destHot = base.appendingPathComponent(id)
364
- let destUnZip = documentsDir.appendingPathComponent(randomString(length: 10))
363
+ let destHot: URL = base.appendingPathComponent(id)
364
+ let destUnZip: URL = documentsDir.appendingPathComponent(randomString(length: 10))
365
365
  if !SSZipArchive.unzipFile(atPath: sourceZip.path, toDestination: destUnZip.path) {
366
366
  throw CustomError.cannotUnzip
367
367
  }
@@ -389,8 +389,8 @@ extension CustomError: LocalizedError {
389
389
  }
390
390
 
391
391
  public func getLatest(url: URL) -> AppVersion {
392
- let semaphore = DispatchSemaphore(value: 0)
393
- let latest = AppVersion()
392
+ let semaphore: DispatchSemaphore = DispatchSemaphore(value: 0)
393
+ let latest: AppVersion = AppVersion()
394
394
  let parameters: InfoObject = self.createInfoObject()
395
395
  print("\(self.TAG) Auto-update parameters: \(parameters)")
396
396
  let request = AF.request(url, method: .post, parameters: parameters, encoder: JSONParameterEncoder.default)
@@ -437,13 +437,13 @@ extension CustomError: LocalizedError {
437
437
  }
438
438
 
439
439
  public func download(url: URL, version: String, sessionKey: String) throws -> BundleInfo {
440
- let semaphore = DispatchSemaphore(value: 0)
440
+ let semaphore: DispatchSemaphore = DispatchSemaphore(value: 0)
441
441
  let id: String = self.randomString(length: 10)
442
- var checksum = ""
442
+ var checksum: String = ""
443
443
  var mainError: NSError?
444
444
  let destination: DownloadRequest.Destination = { _, _ in
445
- let documentsURL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0]
446
- let fileURL = documentsURL.appendingPathComponent(self.randomString(length: 10))
445
+ let documentsURL: URL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0]
446
+ let fileURL: URL = documentsURL.appendingPathComponent(self.randomString(length: 10))
447
447
 
448
448
  return (fileURL, [.removePreviousFile, .createIntermediateDirectories])
449
449
  }
@@ -489,13 +489,13 @@ extension CustomError: LocalizedError {
489
489
  }
490
490
 
491
491
  public func list() -> [BundleInfo] {
492
- let dest = documentsDir.appendingPathComponent(bundleDirectoryHot)
492
+ let dest: URL = documentsDir.appendingPathComponent(bundleDirectoryHot)
493
493
  do {
494
- let files = try FileManager.default.contentsOfDirectory(atPath: dest.path)
494
+ let files: [String] = try FileManager.default.contentsOfDirectory(atPath: dest.path)
495
495
  var res: [BundleInfo] = []
496
496
  print("\(self.TAG) list File : \(dest.path)")
497
497
  if dest.exist {
498
- for id in files {
498
+ for id: String in files {
499
499
  res.append(self.getBundleInfo(id: id))
500
500
  }
501
501
  }
@@ -512,8 +512,8 @@ extension CustomError: LocalizedError {
512
512
  print("\(self.TAG) Cannot delete \(id)")
513
513
  return false
514
514
  }
515
- let destHot = documentsDir.appendingPathComponent(bundleDirectoryHot).appendingPathComponent(id)
516
- let destPersist = libraryDir.appendingPathComponent(bundleDirectory).appendingPathComponent(id)
515
+ let destHot: URL = documentsDir.appendingPathComponent(bundleDirectoryHot).appendingPathComponent(id)
516
+ let destPersist: URL = libraryDir.appendingPathComponent(bundleDirectory).appendingPathComponent(id)
517
517
  do {
518
518
  try FileManager.default.removeItem(atPath: destHot.path)
519
519
  } catch {
@@ -548,10 +548,10 @@ extension CustomError: LocalizedError {
548
548
  }
549
549
 
550
550
  private func bundleExists(id: String) -> Bool {
551
- let destHot = self.getPathHot(id: id)
552
- let destHotPersist = self.getPathPersist(id: id)
553
- let indexHot = destHot.appendingPathComponent("index.html")
554
- let indexPersist = destHotPersist.appendingPathComponent("index.html")
551
+ let destHot: URL = self.getPathHot(id: id)
552
+ let destHotPersist: URL = self.getPathPersist(id: id)
553
+ let indexHot: URL = destHot.appendingPathComponent("index.html")
554
+ let indexPersist: URL = destHotPersist.appendingPathComponent("index.html")
555
555
  let url: URL = self.getBundleDirectory(id: id)
556
556
  let bundleIndo: BundleInfo = self.getBundleInfo(id: id)
557
557
  if url.isDirectory && destHotPersist.isDirectory && indexHot.exist && indexPersist.exist && !bundleIndo.isDeleted() {
@@ -619,14 +619,14 @@ extension CustomError: LocalizedError {
619
619
  }
620
620
 
621
621
  func setChannel(channel: String) -> SetChannel {
622
- let setChannel = SetChannel()
622
+ let setChannel: SetChannel = SetChannel()
623
623
  if self.channelUrl == "" {
624
624
  print("\(self.TAG) Channel URL is not set")
625
625
  setChannel.message = "Channel URL is not set"
626
626
  setChannel.error = "missing_config"
627
627
  return setChannel
628
628
  }
629
- let semaphore = DispatchSemaphore(value: 0)
629
+ let semaphore: DispatchSemaphore = DispatchSemaphore(value: 0)
630
630
  var parameters: InfoObject = self.createInfoObject()
631
631
  parameters.channel = channel
632
632
 
@@ -656,14 +656,14 @@ extension CustomError: LocalizedError {
656
656
  }
657
657
 
658
658
  func getChannel() -> GetChannel {
659
- let getChannel = GetChannel()
659
+ let getChannel: GetChannel = GetChannel()
660
660
  if self.channelUrl == "" {
661
661
  print("\(self.TAG) Channel URL is not set")
662
662
  getChannel.message = "Channel URL is not set"
663
663
  getChannel.error = "missing_config"
664
664
  return getChannel
665
665
  }
666
- let semaphore = DispatchSemaphore(value: 0)
666
+ let semaphore: DispatchSemaphore = DispatchSemaphore(value: 0)
667
667
  let parameters: InfoObject = self.createInfoObject()
668
668
  let request = AF.request(self.channelUrl, method: .put, parameters: parameters, encoder: JSONParameterEncoder.default)
669
669
 
@@ -786,13 +786,13 @@ extension CustomError: LocalizedError {
786
786
  }
787
787
 
788
788
  public func getCurrentBundleId() -> String {
789
- guard let bundlePath = UserDefaults.standard.string(forKey: self.CAP_SERVER_PATH) else {
789
+ guard let bundlePath: String = UserDefaults.standard.string(forKey: self.CAP_SERVER_PATH) else {
790
790
  return BundleInfo.ID_BUILTIN
791
791
  }
792
792
  if bundlePath == "" {
793
793
  return BundleInfo.ID_BUILTIN
794
794
  }
795
- let bundleID = bundlePath.components(separatedBy: "/").last ?? bundlePath
795
+ let bundleID: String = bundlePath.components(separatedBy: "/").last ?? bundlePath
796
796
  return bundleID
797
797
  }
798
798
 
@@ -816,7 +816,7 @@ extension CustomError: LocalizedError {
816
816
  }
817
817
 
818
818
  public func setNextBundle(next: String?) -> Bool {
819
- guard let nextId = next else {
819
+ guard let nextId: String = next else {
820
820
  UserDefaults.standard.removeObject(forKey: self.NEXT_VERSION)
821
821
  UserDefaults.standard.synchronize()
822
822
  return false
@@ -9,21 +9,21 @@ import Version
9
9
  @objc(CapacitorUpdaterPlugin)
10
10
  public class CapacitorUpdaterPlugin: CAPPlugin {
11
11
  private var implementation = CapacitorUpdater()
12
- static let updateUrlDefault = "https://api.capgo.app/updates"
13
- static let statsUrlDefault = "https://api.capgo.app/stats"
14
- static let channelUrlDefault = "https://api.capgo.app/channel_self"
15
- let DELAY_CONDITION_PREFERENCES = ""
16
- private var updateUrl = ""
17
- private var statsUrl = ""
12
+ static let updateUrlDefault: String = "https://api.capgo.app/updates"
13
+ static let statsUrlDefault: String = "https://api.capgo.app/stats"
14
+ static let channelUrlDefault: String = "https://api.capgo.app/channel_self"
15
+ let DELAY_CONDITION_PREFERENCES: String = ""
16
+ private var updateUrl: String = ""
17
+ private var statsUrl: String = ""
18
18
  private var currentVersionNative: Version = "0.0.0"
19
- private var autoUpdate = false
20
- private var appReadyTimeout = 10000
19
+ private var autoUpdate: Bool = false
20
+ private var appReadyTimeout: Int = 10000
21
21
  private var appReadyCheck: DispatchWorkItem?
22
- private var resetWhenUpdate = true
23
- private var autoDeleteFailed = false
24
- private var autoDeletePrevious = false
22
+ private var resetWhenUpdate: Bool = true
23
+ private var autoDeleteFailed: Bool = false
24
+ private var autoDeletePrevious: Bool = false
25
25
  private var backgroundWork: DispatchWorkItem?
26
- private var taskRunning = false
26
+ private var taskRunning: Bool = false
27
27
 
28
28
  override public func load() {
29
29
  print("\(self.implementation.TAG) init for device \(self.implementation.deviceID)")
@@ -50,7 +50,7 @@ public class CapacitorUpdaterPlugin: CAPPlugin {
50
50
  if resetWhenUpdate {
51
51
  self.cleanupObsoleteVersions()
52
52
  }
53
- let nc = NotificationCenter.default
53
+ let nc: NotificationCenter = NotificationCenter.default
54
54
  nc.addObserver(self, selector: #selector(appMovedToBackground), name: UIApplication.didEnterBackgroundNotification, object: nil)
55
55
  nc.addObserver(self, selector: #selector(appMovedToForeground), name: UIApplication.willEnterForegroundNotification, object: nil)
56
56
  nc.addObserver(self, selector: #selector(appKilled), name: UIApplication.willTerminateNotification, object: nil)
@@ -347,7 +347,7 @@ public class CapacitorUpdaterPlugin: CAPPlugin {
347
347
  }
348
348
 
349
349
  private func _checkCancelDelay(killed: Bool) {
350
- let delayUpdatePreferences = UserDefaults.standard.string(forKey: DELAY_CONDITION_PREFERENCES) ?? "[]"
350
+ let delayUpdatePreferences: String = UserDefaults.standard.string(forKey: DELAY_CONDITION_PREFERENCES) ?? "[]"
351
351
  let delayConditionList: [DelayCondition] = fromJsonArr(json: delayUpdatePreferences).map { obj -> DelayCondition in
352
352
  let kind: String = obj.value(forKey: "kind") as! String
353
353
  let value: String? = obj.value(forKey: "value") as? String
@@ -473,7 +473,7 @@ public class CapacitorUpdaterPlugin: CAPPlugin {
473
473
  if self._isAutoUpdateEnabled() {
474
474
  DispatchQueue.global(qos: .background).async {
475
475
  print("\(self.implementation.TAG) Check for update via \(self.updateUrl)")
476
- let url = URL(string: self.updateUrl)!
476
+ let url: URL = URL(string: self.updateUrl)!
477
477
  let res = self.implementation.getLatest(url: url)
478
478
  let current = self.implementation.getCurrentBundle()
479
479
 
@@ -550,7 +550,7 @@ public class CapacitorUpdaterPlugin: CAPPlugin {
550
550
 
551
551
  @objc func appMovedToBackground() {
552
552
  print("\(self.implementation.TAG) Check for pending update")
553
- let delayUpdatePreferences = UserDefaults.standard.string(forKey: DELAY_CONDITION_PREFERENCES) ?? "[]"
553
+ let delayUpdatePreferences: String = UserDefaults.standard.string(forKey: DELAY_CONDITION_PREFERENCES) ?? "[]"
554
554
 
555
555
  let delayConditionList: [DelayCondition] = fromJsonArr(json: delayUpdatePreferences).map { obj -> DelayCondition in
556
556
  let kind: String = obj.value(forKey: "kind") as! String
@@ -587,7 +587,7 @@ public class CapacitorUpdaterPlugin: CAPPlugin {
587
587
  }
588
588
 
589
589
  private func installNext() {
590
- let delayUpdatePreferences = UserDefaults.standard.string(forKey: DELAY_CONDITION_PREFERENCES) ?? "[]"
590
+ let delayUpdatePreferences: String = UserDefaults.standard.string(forKey: DELAY_CONDITION_PREFERENCES) ?? "[]"
591
591
  let delayConditionList: [DelayCondition]? = fromJsonArr(json: delayUpdatePreferences).map { obj -> DelayCondition in
592
592
  let kind: String = obj.value(forKey: "kind") as! String
593
593
  let value: String? = obj.value(forKey: "value") as? String
@@ -612,15 +612,15 @@ public class CapacitorUpdaterPlugin: CAPPlugin {
612
612
  }
613
613
 
614
614
  @objc private func toJson(object: Any) -> String {
615
- guard let data = try? JSONSerialization.data(withJSONObject: object, options: []) else {
615
+ guard let data: Data = try? JSONSerialization.data(withJSONObject: object, options: []) else {
616
616
  return ""
617
617
  }
618
618
  return String(data: data, encoding: String.Encoding.utf8) ?? ""
619
619
  }
620
620
 
621
621
  @objc private func fromJsonArr(json: String) -> [NSObject] {
622
- let jsonData = json.data(using: .utf8)!
623
- let object = try? JSONSerialization.jsonObject(
622
+ let jsonData: Data = json.data(using: .utf8)!
623
+ let object: [NSObject]? = try? JSONSerialization.jsonObject(
624
624
  with: jsonData,
625
625
  options: .mutableContainers
626
626
  ) as? [NSObject]
@@ -60,20 +60,20 @@ public struct AES128Key {
60
60
  /// Returns the decrypted data.
61
61
  ///
62
62
  public func decrypt(data: Data) -> Data? {
63
- let encryptedData = (data as NSData).bytes.bindMemory(to: UInt8.self, capacity: data.count)
64
- let encryptedDataLength = data.count
63
+ let encryptedData: UnsafePointer<UInt8> = (data as NSData).bytes.bindMemory(to: UInt8.self, capacity: data.count)
64
+ let encryptedDataLength: Int = data.count
65
65
 
66
- if let result = NSMutableData(length: encryptedDataLength) {
67
- let keyData = (self.aes128Key as NSData).bytes.bindMemory(to: UInt8.self, capacity: self.aes128Key.count)
68
- let keyLength = size_t(self.aes128Key.count)
69
- let ivData = (iv as NSData).bytes.bindMemory(to: UInt8.self, capacity: self.iv.count)
66
+ if let result: NSMutableData = NSMutableData(length: encryptedDataLength) {
67
+ let keyData: UnsafePointer<UInt8> = (self.aes128Key as NSData).bytes.bindMemory(to: UInt8.self, capacity: self.aes128Key.count)
68
+ let keyLength: size_t = size_t(self.aes128Key.count)
69
+ let ivData: UnsafePointer<UInt8> = (iv as NSData).bytes.bindMemory(to: UInt8.self, capacity: self.iv.count)
70
70
 
71
- let decryptedData = UnsafeMutablePointer<UInt8>(result.mutableBytes.assumingMemoryBound(to: UInt8.self))
72
- let decryptedDataLength = size_t(result.length)
71
+ let decryptedData: UnsafeMutablePointer<UInt8> = UnsafeMutablePointer<UInt8>(result.mutableBytes.assumingMemoryBound(to: UInt8.self))
72
+ let decryptedDataLength: size_t = size_t(result.length)
73
73
 
74
74
  var decryptedLength: size_t = 0
75
75
 
76
- let status = CCCrypt(CCOperation(kCCDecrypt), CryptoCipherConstants.aesAlgorithm, CryptoCipherConstants.aesOptions, keyData, keyLength, ivData, encryptedData, encryptedDataLength, decryptedData, decryptedDataLength, &decryptedLength)
76
+ let status: CCCryptorStatus = CCCrypt(CCOperation(kCCDecrypt), CryptoCipherConstants.aesAlgorithm, CryptoCipherConstants.aesOptions, keyData, keyLength, ivData, encryptedData, encryptedDataLength, decryptedData, decryptedDataLength, &decryptedLength)
77
77
 
78
78
  if UInt32(status) == UInt32(kCCSuccess) {
79
79
  result.length = Int(decryptedLength)
@@ -215,12 +215,12 @@ public struct RSAPrivateKey {
215
215
  /// Allows you to load an RSA public key (i.e. one downloaded from the net).
216
216
  ///
217
217
  public static func load(rsaPrivateKey: String) -> RSAPrivateKey? {
218
- var privKey = rsaPrivateKey
218
+ var privKey: String = rsaPrivateKey
219
219
  privKey = privKey.replacingOccurrences(of: "-----BEGIN RSA PRIVATE KEY-----", with: "")
220
220
  privKey = privKey.replacingOccurrences(of: "-----END RSA PRIVATE KEY-----", with: "")
221
221
  privKey = privKey.replacingOccurrences(of: "\\n+", with: "", options: .regularExpression)
222
222
  privKey = privKey.trimmingCharacters(in: .whitespacesAndNewlines)
223
- let rsaPrivateKeyData = Data(base64Encoded: privKey)!
223
+ let rsaPrivateKeyData: Data = Data(base64Encoded: privKey)!
224
224
  if let privateKey: SecKey = .loadPrivateFromData(rsaPrivateKeyData) {
225
225
  return RSAPrivateKey(privateKey: privateKey)
226
226
  } else {
@@ -232,7 +232,7 @@ public struct RSAPrivateKey {
232
232
  fileprivate extension SecKey {
233
233
  func exportToData() -> Data? {
234
234
  var error: Unmanaged<CFError>?
235
- if let cfData = SecKeyCopyExternalRepresentation(self, &error) {
235
+ if let cfData: CFData = SecKeyCopyExternalRepresentation(self, &error) {
236
236
  if error != nil {
237
237
  return nil
238
238
  } else {
@@ -33,7 +33,7 @@ private func delayUntilNextValue(value: String) -> DelayUntilNext {
33
33
  }
34
34
 
35
35
  public required init(from decoder: Decoder) throws {
36
- let values = try decoder.container(keyedBy: CodingKeys.self)
36
+ let values: KeyedDecodingContainer<DelayCondition.CodingKeys> = try decoder.container(keyedBy: CodingKeys.self)
37
37
  kind = try values.decode(DelayUntilNext.self, forKey: .kind)
38
38
  value = try values.decode(String.self, forKey: .value)
39
39
  }
@@ -17,9 +17,9 @@ enum ObjectSavableError: String, LocalizedError {
17
17
 
18
18
  extension UserDefaults: ObjectSavable {
19
19
  func setObj<Object>(_ object: Object, forKey: String) throws where Object: Encodable {
20
- let encoder = JSONEncoder()
20
+ let encoder: JSONEncoder = JSONEncoder()
21
21
  do {
22
- let data = try encoder.encode(object)
22
+ let data: Data = try encoder.encode(object)
23
23
  set(data, forKey: forKey)
24
24
  } catch {
25
25
  throw ObjectSavableError.unableToEncode
@@ -28,11 +28,11 @@ extension UserDefaults: ObjectSavable {
28
28
 
29
29
  func getObj<Object>(forKey: String, castTo type: Object.Type) throws -> Object where Object: Decodable {
30
30
  // print("forKey", forKey)
31
- guard let data = data(forKey: forKey) else { throw ObjectSavableError.noValue }
31
+ guard let data: Data = data(forKey: forKey) else { throw ObjectSavableError.noValue }
32
32
  // print("data", data)
33
- let decoder = JSONDecoder()
33
+ let decoder: JSONDecoder = JSONDecoder()
34
34
  do {
35
- let object = try decoder.decode(type, from: data)
35
+ let object: Object = try decoder.decode(type, from: data)
36
36
  return object
37
37
  } catch {
38
38
  throw ObjectSavableError.unableToDecode
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/capacitor-updater",
3
- "version": "4.13.3",
3
+ "version": "4.13.5",
4
4
  "license": "LGPL-3.0-only",
5
5
  "description": "OTA update for capacitor apps",
6
6
  "main": "dist/plugin.cjs.js",