@capgo/capacitor-updater 7.0.34 → 7.0.36

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.
package/README.md CHANGED
@@ -36,7 +36,7 @@ I maintain a more user-friendly and complete [documentation here](https://capgo.
36
36
 
37
37
  ## Migration to v7
38
38
 
39
- - `privateKey` is not available anymore, it was used for the old encryption method. to migrate foolow this guide : [https://capgo.app/docs/plugin/cloud-mode/getting-started/](https://capgo.app/docs/cli/migrations/encryption/)
39
+ - `privateKey` is not available anymore, it was used for the old encryption method. to migrate follow this guide : [https://capgo.app/docs/plugin/cloud-mode/getting-started/](https://capgo.app/docs/cli/migrations/encryption/)
40
40
  - To capacitor v7 : [https://capacitorjs.com/docs/updating/7-0](https://capacitorjs.com/docs/updating/7-0)
41
41
 
42
42
  ## Compatibility
@@ -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.34";
60
+ private final String PLUGIN_VERSION = "7.0.36";
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 self.decryptFileV2(filePath: tempDataPath, sessionKey: sessionKey, version: version)
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.34"
48
+ private let PLUGIN_VERSION: String = "7.0.36"
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": "7.0.34",
3
+ "version": "7.0.36",
4
4
  "license": "MPL-2.0",
5
5
  "description": "Live update for capacitor apps",
6
6
  "main": "dist/plugin.cjs.js",