@capgo/capacitor-updater 5.3.24 → 5.3.25
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.
|
@@ -56,7 +56,7 @@ public class CapacitorUpdaterPlugin extends Plugin {
|
|
|
56
56
|
private static final String channelUrlDefault =
|
|
57
57
|
"https://api.capgo.app/channel_self";
|
|
58
58
|
|
|
59
|
-
private final String PLUGIN_VERSION = "5.3.
|
|
59
|
+
private final String PLUGIN_VERSION = "5.3.25";
|
|
60
60
|
private static final String DELAY_CONDITION_PREFERENCES = "";
|
|
61
61
|
|
|
62
62
|
private SharedPreferences.Editor editor;
|
|
@@ -17,11 +17,6 @@ extension URL {
|
|
|
17
17
|
return FileManager().fileExists(atPath: self.path)
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
|
-
extension Date {
|
|
21
|
-
func adding(minutes: Int) -> Date {
|
|
22
|
-
return Calendar.current.date(byAdding: .minute, value: minutes, to: self)!
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
20
|
struct SetChannelDec: Decodable {
|
|
26
21
|
let status: String?
|
|
27
22
|
let error: String?
|
|
@@ -363,11 +358,24 @@ extension CustomError: LocalizedError {
|
|
|
363
358
|
print("cannot decode sessionKey", sessionKey)
|
|
364
359
|
throw CustomError.cannotDecode
|
|
365
360
|
}
|
|
366
|
-
|
|
367
|
-
let
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
361
|
+
|
|
362
|
+
guard let sessionKeyDataEncrypted = Data(base64Encoded: sessionKeyArray[1]) else {
|
|
363
|
+
throw NSError(domain: "Invalid session key data", code: 1, userInfo: nil)
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
guard let sessionKeyDataDecrypted = try? rsaPrivateKey.decrypt(data: sessionKeyDataEncrypted) else {
|
|
367
|
+
throw NSError(domain: "Failed to decrypt session key data", code: 2, userInfo: nil)
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
let aesPrivateKey = AES128Key(iv: ivData, aes128Key: sessionKeyDataDecrypted)
|
|
371
|
+
|
|
372
|
+
guard let encryptedData = try? Data(contentsOf: filePath) else {
|
|
373
|
+
throw NSError(domain: "Failed to read encrypted data", code: 3, userInfo: nil)
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
guard let decryptedData = try? aesPrivateKey.decrypt(data: encryptedData) else {
|
|
377
|
+
throw NSError(domain: "Failed to decrypt data", code: 4, userInfo: nil)
|
|
378
|
+
}
|
|
371
379
|
|
|
372
380
|
try decryptedData.write(to: filePath)
|
|
373
381
|
} catch {
|
|
@@ -15,7 +15,7 @@ import Version
|
|
|
15
15
|
@objc(CapacitorUpdaterPlugin)
|
|
16
16
|
public class CapacitorUpdaterPlugin: CAPPlugin {
|
|
17
17
|
public var implementation = CapacitorUpdater()
|
|
18
|
-
private let PLUGIN_VERSION: String = "5.3.
|
|
18
|
+
private let PLUGIN_VERSION: String = "5.3.25"
|
|
19
19
|
static let updateUrlDefault = "https://api.capgo.app/updates"
|
|
20
20
|
static let statsUrlDefault = "https://api.capgo.app/stats"
|
|
21
21
|
static let channelUrlDefault = "https://api.capgo.app/channel_self"
|
|
@@ -40,10 +40,15 @@ public class CapacitorUpdaterPlugin: CAPPlugin {
|
|
|
40
40
|
override public func load() {
|
|
41
41
|
self.semaphoreUp()
|
|
42
42
|
print("\(self.implementation.TAG) init for device \(self.implementation.deviceID)")
|
|
43
|
+
guard let versionName = getConfig().getString("version", Bundle.main.versionName) else {
|
|
44
|
+
print("\(self.implementation.TAG) Cannot get version name")
|
|
45
|
+
// crash the app
|
|
46
|
+
fatalError("Cannot get version name")
|
|
47
|
+
}
|
|
43
48
|
do {
|
|
44
|
-
currentVersionNative = try Version(
|
|
49
|
+
currentVersionNative = try Version(versionName)
|
|
45
50
|
} catch {
|
|
46
|
-
print("\(self.implementation.TAG) Cannot
|
|
51
|
+
print("\(self.implementation.TAG) Cannot parse versionName \(versionName)")
|
|
47
52
|
}
|
|
48
53
|
print("\(self.implementation.TAG) version native \(self.currentVersionNative.description)")
|
|
49
54
|
implementation.versionBuild = getConfig().getString("version", Bundle.main.versionName)!
|
|
@@ -581,13 +586,16 @@ public class CapacitorUpdaterPlugin: CAPPlugin {
|
|
|
581
586
|
|
|
582
587
|
func backgroundDownload() {
|
|
583
588
|
let messageUpdate = self.directUpdate ? "Update will occur now." : "Update will occur next time app moves to background."
|
|
589
|
+
guard let url = URL(string: self.updateUrl) else {
|
|
590
|
+
print("\(self.implementation.TAG) Error no url or wrong format")
|
|
591
|
+
return
|
|
592
|
+
}
|
|
584
593
|
DispatchQueue.global(qos: .background).async {
|
|
585
594
|
self.backgroundTaskID = UIApplication.shared.beginBackgroundTask(withName: "Finish Download Tasks") {
|
|
586
595
|
// End the task if time expires.
|
|
587
596
|
self.endBackGroundTask()
|
|
588
597
|
}
|
|
589
598
|
print("\(self.implementation.TAG) Check for update via \(self.updateUrl)")
|
|
590
|
-
let url = URL(string: self.updateUrl)!
|
|
591
599
|
let res = self.implementation.getLatest(url: url)
|
|
592
600
|
let current = self.implementation.getCurrentBundle()
|
|
593
601
|
|
|
@@ -706,7 +714,9 @@ public class CapacitorUpdaterPlugin: CAPPlugin {
|
|
|
706
714
|
}
|
|
707
715
|
|
|
708
716
|
@objc private func fromJsonArr(json: String) -> [NSObject] {
|
|
709
|
-
let jsonData = json.data(using: .utf8)
|
|
717
|
+
guard let jsonData = json.data(using: .utf8) else {
|
|
718
|
+
return []
|
|
719
|
+
}
|
|
710
720
|
let object = try? JSONSerialization.jsonObject(
|
|
711
721
|
with: jsonData,
|
|
712
722
|
options: .mutableContainers
|
|
@@ -734,8 +744,11 @@ public class CapacitorUpdaterPlugin: CAPPlugin {
|
|
|
734
744
|
if periodCheckDelay == 0 || !self._isAutoUpdateEnabled() {
|
|
735
745
|
return
|
|
736
746
|
}
|
|
747
|
+
guard let url = URL(string: self.updateUrl) else {
|
|
748
|
+
print("\(self.implementation.TAG) Error no url or wrong format")
|
|
749
|
+
return
|
|
750
|
+
}
|
|
737
751
|
let timer = Timer.scheduledTimer(withTimeInterval: TimeInterval(periodCheckDelay), repeats: true) { _ in
|
|
738
|
-
let url = URL(string: self.updateUrl)!
|
|
739
752
|
let res = self.implementation.getLatest(url: url)
|
|
740
753
|
let current = self.implementation.getCurrentBundle()
|
|
741
754
|
|
|
@@ -199,10 +199,16 @@ public struct RSAPrivateKey {
|
|
|
199
199
|
privKey = privKey.replacingOccurrences(of: "-----END RSA PRIVATE KEY-----", with: "")
|
|
200
200
|
privKey = privKey.replacingOccurrences(of: "\\n+", with: "", options: .regularExpression)
|
|
201
201
|
privKey = privKey.trimmingCharacters(in: .whitespacesAndNewlines)
|
|
202
|
-
|
|
203
|
-
|
|
202
|
+
do {
|
|
203
|
+
guard let rsaPrivateKeyData: Data = Data(base64Encoded: privKey) else {
|
|
204
|
+
throw CustomError.cannotDecode
|
|
205
|
+
}
|
|
206
|
+
guard let privateKey: SecKey = .loadPrivateFromData(rsaPrivateKeyData) else {
|
|
207
|
+
throw CustomError.cannotDecode
|
|
208
|
+
}
|
|
204
209
|
return RSAPrivateKey(privateKey: privateKey)
|
|
205
|
-
}
|
|
210
|
+
} catch {
|
|
211
|
+
print("Error load RSA: \(error)")
|
|
206
212
|
return nil
|
|
207
213
|
}
|
|
208
214
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capgo/capacitor-updater",
|
|
3
|
-
"version": "5.3.
|
|
3
|
+
"version": "5.3.25",
|
|
4
4
|
"packageManager": "pnpm@8.10.0",
|
|
5
5
|
"license": "MPL-2.0",
|
|
6
6
|
"description": "Live update for capacitor apps",
|
|
@@ -78,7 +78,6 @@
|
|
|
78
78
|
"@capacitor/core": "^5.0.0"
|
|
79
79
|
},
|
|
80
80
|
"prettier": "@ionic/prettier-config",
|
|
81
|
-
"swiftlint": "@ionic/swiftlint-config",
|
|
82
81
|
"eslintConfig": {
|
|
83
82
|
"extends": "@ionic/eslint-config/recommended"
|
|
84
83
|
},
|