@capgo/capacitor-updater 7.0.34 → 7.0.35
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.
|
|
60
|
+
private final String PLUGIN_VERSION = "7.0.35";
|
|
61
61
|
private static final String DELAY_CONDITION_PREFERENCES = "";
|
|
62
62
|
|
|
63
63
|
private SharedPreferences.Editor editor;
|
|
@@ -140,50 +140,6 @@ import UIKit
|
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
142
|
|
|
143
|
-
private func decryptFileV2(filePath: URL, sessionKey: String, version: String) throws {
|
|
144
|
-
if self.publicKey.isEmpty || sessionKey.isEmpty || sessionKey.components(separatedBy: ":").count != 2 {
|
|
145
|
-
print("\(CapacitorUpdater.TAG) Cannot find public key or sessionKey")
|
|
146
|
-
return
|
|
147
|
-
}
|
|
148
|
-
do {
|
|
149
|
-
guard let rsaPublicKey: RSAPublicKey = .load(rsaPublicKey: self.publicKey) else {
|
|
150
|
-
print("cannot decode publicKey", self.publicKey)
|
|
151
|
-
throw CustomError.cannotDecode
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
let sessionKeyArray: [String] = sessionKey.components(separatedBy: ":")
|
|
155
|
-
guard let ivData: Data = Data(base64Encoded: sessionKeyArray[0]) else {
|
|
156
|
-
print("cannot decode sessionKey", sessionKey)
|
|
157
|
-
throw CustomError.cannotDecode
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
guard let sessionKeyDataEncrypted = Data(base64Encoded: sessionKeyArray[1]) else {
|
|
161
|
-
throw NSError(domain: "Invalid session key data", code: 1, userInfo: nil)
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
guard let sessionKeyDataDecrypted = rsaPublicKey.decrypt(data: sessionKeyDataEncrypted) else {
|
|
165
|
-
throw NSError(domain: "Failed to decrypt session key data", code: 2, userInfo: nil)
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
let aesPrivateKey = AES128Key(iv: ivData, aes128Key: sessionKeyDataDecrypted)
|
|
169
|
-
|
|
170
|
-
guard let encryptedData = try? Data(contentsOf: filePath) else {
|
|
171
|
-
throw NSError(domain: "Failed to read encrypted data", code: 3, userInfo: nil)
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
guard let decryptedData = aesPrivateKey.decrypt(data: encryptedData) else {
|
|
175
|
-
throw NSError(domain: "Failed to decrypt data", code: 4, userInfo: nil)
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
try decryptedData.write(to: filePath)
|
|
179
|
-
|
|
180
|
-
} catch {
|
|
181
|
-
print("\(CapacitorUpdater.TAG) Cannot decode: \(filePath.path)", error)
|
|
182
|
-
self.sendStats(action: "decrypt_fail", versionName: version)
|
|
183
|
-
throw CustomError.cannotDecode
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
|
|
187
143
|
private func unzipProgressHandler(entry: String, zipInfo: unz_file_info, entryNumber: Int, total: Int, destUnZip: URL, id: String, unzipError: inout NSError?) {
|
|
188
144
|
if entry.contains("\\") {
|
|
189
145
|
print("\(CapacitorUpdater.TAG) unzip: Windows path is not supported, please use unix path as required by zip RFC: \(entry)")
|
|
@@ -694,7 +650,7 @@ import UIKit
|
|
|
694
650
|
|
|
695
651
|
let finalPath = tempDataPath.deletingLastPathComponent().appendingPathComponent("\(id)")
|
|
696
652
|
do {
|
|
697
|
-
try
|
|
653
|
+
try CryptoCipherV2.decryptFile(filePath: tempDataPath, publicKey: self.publicKey, sessionKey: sessionKey, version: version)
|
|
698
654
|
try FileManager.default.moveItem(at: tempDataPath, to: finalPath)
|
|
699
655
|
} catch {
|
|
700
656
|
print("\(CapacitorUpdater.TAG) Failed decrypt file : \(error)")
|
|
@@ -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.
|
|
48
|
+
private let PLUGIN_VERSION: String = "7.0.35"
|
|
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"
|