@capgo/capacitor-updater 7.2.19 → 7.2.21

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.
@@ -12,33 +12,33 @@ public struct CryptoCipherV2 {
12
12
 
13
13
  public static func decryptChecksum(checksum: String, publicKey: String) throws -> String {
14
14
  if publicKey.isEmpty {
15
- print("\(CapacitorUpdater.TAG) No encryption set (public key) ignored")
15
+ print("\(CapgoUpdater.TAG) No encryption set (public key) ignored")
16
16
  return checksum
17
17
  }
18
18
  do {
19
19
  guard let checksumBytes = Data(base64Encoded: checksum) else {
20
- print("\(CapacitorUpdater.TAG) Cannot decode checksum as base64: \(checksum)")
20
+ print("\(CapgoUpdater.TAG) Cannot decode checksum as base64: \(checksum)")
21
21
  throw CustomError.cannotDecode
22
22
  }
23
23
 
24
24
  if checksumBytes.isEmpty {
25
- print("\(CapacitorUpdater.TAG) Decoded checksum is empty")
25
+ print("\(CapgoUpdater.TAG) Decoded checksum is empty")
26
26
  throw CustomError.cannotDecode
27
27
  }
28
28
 
29
29
  guard let rsaPublicKey = RSAPublicKey.load(rsaPublicKey: publicKey) else {
30
- print("\(CapacitorUpdater.TAG) The public key is not a valid RSA Public key")
30
+ print("\(CapgoUpdater.TAG) The public key is not a valid RSA Public key")
31
31
  throw CustomError.cannotDecode
32
32
  }
33
33
 
34
34
  guard let decryptedChecksum = rsaPublicKey.decrypt(data: checksumBytes) else {
35
- print("\(CapacitorUpdater.TAG) decryptChecksum fail")
35
+ print("\(CapgoUpdater.TAG) decryptChecksum fail")
36
36
  throw NSError(domain: "Failed to decrypt session key data", code: 2, userInfo: nil)
37
37
  }
38
38
 
39
39
  return decryptedChecksum.base64EncodedString()
40
40
  } catch {
41
- print("\(CapacitorUpdater.TAG) decryptChecksum fail: \(error.localizedDescription)")
41
+ print("\(CapgoUpdater.TAG) decryptChecksum fail: \(error.localizedDescription)")
42
42
  throw CustomError.cannotDecode
43
43
  }
44
44
  }
@@ -51,7 +51,7 @@ public struct CryptoCipherV2 {
51
51
  do {
52
52
  fileHandle = try FileHandle(forReadingFrom: filePath)
53
53
  } catch {
54
- print("\(CapacitorUpdater.TAG) Cannot open file for checksum: \(filePath.path)", error)
54
+ print("\(CapgoUpdater.TAG) Cannot open file for checksum: \(filePath.path)", error)
55
55
  return ""
56
56
  }
57
57
 
@@ -59,7 +59,7 @@ public struct CryptoCipherV2 {
59
59
  do {
60
60
  try fileHandle.close()
61
61
  } catch {
62
- print("\(CapacitorUpdater.TAG) Error closing file: \(error)")
62
+ print("\(CapgoUpdater.TAG) Error closing file: \(error)")
63
63
  }
64
64
  }
65
65
 
@@ -72,7 +72,7 @@ public struct CryptoCipherV2 {
72
72
  fileData = fileHandle.readData(ofLength: bufferSize)
73
73
  }
74
74
  } catch {
75
- print("\(CapacitorUpdater.TAG) Error reading file: \(error)")
75
+ print("\(CapgoUpdater.TAG) Error reading file: \(error)")
76
76
  return false
77
77
  }
78
78
 
@@ -87,25 +87,25 @@ public struct CryptoCipherV2 {
87
87
  let digest = sha256.finalize()
88
88
  return digest.compactMap { String(format: "%02x", $0) }.joined()
89
89
  } catch {
90
- print("\(CapacitorUpdater.TAG) Cannot get checksum: \(filePath.path)", error)
90
+ print("\(CapgoUpdater.TAG) Cannot get checksum: \(filePath.path)", error)
91
91
  return ""
92
92
  }
93
93
  }
94
94
 
95
95
  public static func decryptFile(filePath: URL, publicKey: String, sessionKey: String, version: String) throws {
96
96
  if publicKey.isEmpty || sessionKey.isEmpty || sessionKey.components(separatedBy: ":").count != 2 {
97
- print("\(CapacitorUpdater.TAG) Encryption not set, no public key or seesion, ignored")
97
+ print("\(CapgoUpdater.TAG) Encryption not set, no public key or seesion, ignored")
98
98
  return
99
99
  }
100
100
 
101
101
  if !publicKey.hasPrefix("-----BEGIN RSA PUBLIC KEY-----") {
102
- print("\(CapacitorUpdater.TAG) The public key is not a valid RSA Public key")
102
+ print("\(CapgoUpdater.TAG) The public key is not a valid RSA Public key")
103
103
  return
104
104
  }
105
105
 
106
106
  do {
107
107
  guard let rsaPublicKey = RSAPublicKey.load(rsaPublicKey: publicKey) else {
108
- print("\(CapacitorUpdater.TAG) The public key is not a valid RSA Public key")
108
+ print("\(CapgoUpdater.TAG) The public key is not a valid RSA Public key")
109
109
  throw CustomError.cannotDecode
110
110
  }
111
111
 
@@ -114,27 +114,27 @@ public struct CryptoCipherV2 {
114
114
  let encryptedKeyBase64 = sessionKeyComponents[1]
115
115
 
116
116
  guard let ivData = Data(base64Encoded: ivBase64) else {
117
- print("\(CapacitorUpdater.TAG) Cannot decode sessionKey IV", ivBase64)
117
+ print("\(CapgoUpdater.TAG) Cannot decode sessionKey IV", ivBase64)
118
118
  throw CustomError.cannotDecode
119
119
  }
120
120
 
121
121
  if ivData.count != 16 {
122
- print("\(CapacitorUpdater.TAG) IV data has invalid length: \(ivData.count), expected 16")
122
+ print("\(CapgoUpdater.TAG) IV data has invalid length: \(ivData.count), expected 16")
123
123
  throw CustomError.cannotDecode
124
124
  }
125
125
 
126
126
  guard let sessionKeyDataEncrypted = Data(base64Encoded: encryptedKeyBase64) else {
127
- print("\(CapacitorUpdater.TAG) Cannot decode sessionKey data", encryptedKeyBase64)
127
+ print("\(CapgoUpdater.TAG) Cannot decode sessionKey data", encryptedKeyBase64)
128
128
  throw NSError(domain: "Invalid session key data", code: 1, userInfo: nil)
129
129
  }
130
130
 
131
131
  guard let sessionKeyDataDecrypted = rsaPublicKey.decrypt(data: sessionKeyDataEncrypted) else {
132
- print("\(CapacitorUpdater.TAG) Failed to decrypt session key data")
132
+ print("\(CapgoUpdater.TAG) Failed to decrypt session key data")
133
133
  throw NSError(domain: "Failed to decrypt session key data", code: 2, userInfo: nil)
134
134
  }
135
135
 
136
136
  if sessionKeyDataDecrypted.count != 16 {
137
- print("\(CapacitorUpdater.TAG) Decrypted session key has invalid length: \(sessionKeyDataDecrypted.count), expected 16")
137
+ print("\(CapgoUpdater.TAG) Decrypted session key has invalid length: \(sessionKeyDataDecrypted.count), expected 16")
138
138
  throw NSError(domain: "Invalid decrypted session key", code: 5, userInfo: nil)
139
139
  }
140
140
 
@@ -144,38 +144,38 @@ public struct CryptoCipherV2 {
144
144
  do {
145
145
  encryptedData = try Data(contentsOf: filePath)
146
146
  } catch {
147
- print("\(CapacitorUpdater.TAG) Failed to read encrypted data: \(error)")
147
+ print("\(CapgoUpdater.TAG) Failed to read encrypted data: \(error)")
148
148
  throw NSError(domain: "Failed to read encrypted data", code: 3, userInfo: nil)
149
149
  }
150
150
 
151
151
  if encryptedData.isEmpty {
152
- print("\(CapacitorUpdater.TAG) Encrypted file data is empty")
152
+ print("\(CapgoUpdater.TAG) Encrypted file data is empty")
153
153
  throw NSError(domain: "Empty encrypted data", code: 6, userInfo: nil)
154
154
  }
155
155
 
156
156
  guard let decryptedData = aesPrivateKey.decrypt(data: encryptedData) else {
157
- print("\(CapacitorUpdater.TAG) Failed to decrypt data")
157
+ print("\(CapgoUpdater.TAG) Failed to decrypt data")
158
158
  throw NSError(domain: "Failed to decrypt data", code: 4, userInfo: nil)
159
159
  }
160
160
 
161
161
  if decryptedData.isEmpty {
162
- print("\(CapacitorUpdater.TAG) Decrypted data is empty")
162
+ print("\(CapgoUpdater.TAG) Decrypted data is empty")
163
163
  throw NSError(domain: "Empty decrypted data", code: 7, userInfo: nil)
164
164
  }
165
165
 
166
166
  do {
167
167
  try decryptedData.write(to: filePath, options: .atomic)
168
168
  if !FileManager.default.fileExists(atPath: filePath.path) {
169
- print("\(CapacitorUpdater.TAG) File was not created after write")
169
+ print("\(CapgoUpdater.TAG) File was not created after write")
170
170
  throw NSError(domain: "File write failed", code: 8, userInfo: nil)
171
171
  }
172
172
  } catch {
173
- print("\(CapacitorUpdater.TAG) Error writing decrypted file: \(error)")
173
+ print("\(CapgoUpdater.TAG) Error writing decrypted file: \(error)")
174
174
  throw error
175
175
  }
176
176
 
177
177
  } catch {
178
- print("\(CapacitorUpdater.TAG) decryptFile fail")
178
+ print("\(CapgoUpdater.TAG) decryptFile fail")
179
179
  throw CustomError.cannotDecode
180
180
  }
181
181
  }
@@ -70,14 +70,14 @@ public class DelayUpdateUtils {
70
70
  }
71
71
 
72
72
  if delta > longValue {
73
- print("\(CapacitorUpdater.TAG) Background condition (value: \(value ?? "")) deleted at index \(index). Delta: \(delta), longValue: \(longValue)")
73
+ print("\(CapgoUpdater.TAG) Background condition (value: \(value ?? "")) deleted at index \(index). Delta: \(delta), longValue: \(longValue)")
74
74
  } else {
75
75
  delayConditionListToKeep.append(condition)
76
- print("\(CapacitorUpdater.TAG) Background delay (value: \(value ?? "")) condition kept at index \(index) (source: \(source.description))")
76
+ print("\(CapgoUpdater.TAG) Background delay (value: \(value ?? "")) condition kept at index \(index) (source: \(source.description))")
77
77
  }
78
78
  } else {
79
79
  delayConditionListToKeep.append(condition)
80
- print("\(CapacitorUpdater.TAG) Background delay (value: \(value ?? "")) condition kept at index \(index) (source: \(source.description))")
80
+ print("\(CapgoUpdater.TAG) Background delay (value: \(value ?? "")) condition kept at index \(index) (source: \(source.description))")
81
81
  }
82
82
 
83
83
  case "kill":
@@ -85,7 +85,7 @@ public class DelayUpdateUtils {
85
85
  self.installNext()
86
86
  } else {
87
87
  delayConditionListToKeep.append(condition)
88
- print("\(CapacitorUpdater.TAG) Kill delay (value: \(value ?? "")) condition kept at index \(index) (source: \(source.description))")
88
+ print("\(CapgoUpdater.TAG) Kill delay (value: \(value ?? "")) condition kept at index \(index) (source: \(source.description))")
89
89
  }
90
90
 
91
91
  case "date":
@@ -96,19 +96,19 @@ public class DelayUpdateUtils {
96
96
 
97
97
  if let date = dateFormatter.date(from: value) {
98
98
  if Date() > date {
99
- print("\(CapacitorUpdater.TAG) Date delay (value: \(value)) condition removed due to expired date at index \(index)")
99
+ print("\(CapgoUpdater.TAG) Date delay (value: \(value)) condition removed due to expired date at index \(index)")
100
100
  } else {
101
101
  delayConditionListToKeep.append(condition)
102
- print("\(CapacitorUpdater.TAG) Date delay (value: \(value)) condition kept at index \(index)")
102
+ print("\(CapgoUpdater.TAG) Date delay (value: \(value)) condition kept at index \(index)")
103
103
  }
104
104
  } else {
105
- print("\(CapacitorUpdater.TAG) Date delay (value: \(value)) condition removed due to parsing issue at index \(index)")
105
+ print("\(CapgoUpdater.TAG) Date delay (value: \(value)) condition removed due to parsing issue at index \(index)")
106
106
  }
107
107
  } catch {
108
- print("\(CapacitorUpdater.TAG) Date delay (value: \(value)) condition removed due to parsing issue at index \(index): \(error)")
108
+ print("\(CapgoUpdater.TAG) Date delay (value: \(value)) condition removed due to parsing issue at index \(index): \(error)")
109
109
  }
110
110
  } else {
111
- print("\(CapacitorUpdater.TAG) Date delay (value: \(value ?? "")) condition removed due to empty value at index \(index)")
111
+ print("\(CapgoUpdater.TAG) Date delay (value: \(value ?? "")) condition removed due to empty value at index \(index)")
112
112
  }
113
113
 
114
114
  case "nativeVersion":
@@ -116,20 +116,20 @@ public class DelayUpdateUtils {
116
116
  do {
117
117
  let versionLimit = try Version(value)
118
118
  if currentVersionNative >= versionLimit {
119
- print("\(CapacitorUpdater.TAG) Native version delay (value: \(value)) condition removed due to above limit at index \(index)")
119
+ print("\(CapgoUpdater.TAG) Native version delay (value: \(value)) condition removed due to above limit at index \(index)")
120
120
  } else {
121
121
  delayConditionListToKeep.append(condition)
122
- print("\(CapacitorUpdater.TAG) Native version delay (value: \(value)) condition kept at index \(index)")
122
+ print("\(CapgoUpdater.TAG) Native version delay (value: \(value)) condition kept at index \(index)")
123
123
  }
124
124
  } catch {
125
- print("\(CapacitorUpdater.TAG) Native version delay (value: \(value)) condition removed due to parsing issue at index \(index): \(error)")
125
+ print("\(CapgoUpdater.TAG) Native version delay (value: \(value)) condition removed due to parsing issue at index \(index): \(error)")
126
126
  }
127
127
  } else {
128
- print("\(CapacitorUpdater.TAG) Native version delay (value: \(value ?? "")) condition removed due to empty value at index \(index)")
128
+ print("\(CapgoUpdater.TAG) Native version delay (value: \(value ?? "")) condition removed due to empty value at index \(index)")
129
129
  }
130
130
 
131
131
  default:
132
- print("\(CapacitorUpdater.TAG) Unknown delay condition kind: \(kind) at index \(index)")
132
+ print("\(CapgoUpdater.TAG) Unknown delay condition kind: \(kind) at index \(index)")
133
133
  }
134
134
 
135
135
  index += 1
@@ -148,10 +148,10 @@ public class DelayUpdateUtils {
148
148
  do {
149
149
  UserDefaults.standard.set(delayConditions, forKey: DelayUpdateUtils.DELAY_CONDITION_PREFERENCES)
150
150
  UserDefaults.standard.synchronize()
151
- print("\(CapacitorUpdater.TAG) Delay update saved")
151
+ print("\(CapgoUpdater.TAG) Delay update saved")
152
152
  return true
153
153
  } catch {
154
- print("\(CapacitorUpdater.TAG) Failed to delay update, [Error calling 'setMultiDelay()']: \(error)")
154
+ print("\(CapgoUpdater.TAG) Failed to delay update, [Error calling 'setMultiDelay()']: \(error)")
155
155
  return false
156
156
  }
157
157
  }
@@ -160,9 +160,9 @@ public class DelayUpdateUtils {
160
160
  do {
161
161
  UserDefaults.standard.set(backgroundTimestamp, forKey: DelayUpdateUtils.BACKGROUND_TIMESTAMP_KEY)
162
162
  UserDefaults.standard.synchronize()
163
- print("\(CapacitorUpdater.TAG) Background timestamp saved")
163
+ print("\(CapgoUpdater.TAG) Background timestamp saved")
164
164
  } catch {
165
- print("\(CapacitorUpdater.TAG) Failed to save background timestamp, [Error calling 'setBackgroundTimestamp()']: \(error)")
165
+ print("\(CapgoUpdater.TAG) Failed to save background timestamp, [Error calling 'setBackgroundTimestamp()']: \(error)")
166
166
  }
167
167
  }
168
168
 
@@ -170,9 +170,9 @@ public class DelayUpdateUtils {
170
170
  do {
171
171
  UserDefaults.standard.removeObject(forKey: DelayUpdateUtils.BACKGROUND_TIMESTAMP_KEY)
172
172
  UserDefaults.standard.synchronize()
173
- print("\(CapacitorUpdater.TAG) Background timestamp removed")
173
+ print("\(CapgoUpdater.TAG) Background timestamp removed")
174
174
  } catch {
175
- print("\(CapacitorUpdater.TAG) Failed to remove background timestamp, [Error calling 'unsetBackgroundTimestamp()']: \(error)")
175
+ print("\(CapgoUpdater.TAG) Failed to remove background timestamp, [Error calling 'unsetBackgroundTimestamp()']: \(error)")
176
176
  }
177
177
  }
178
178
 
@@ -181,7 +181,7 @@ public class DelayUpdateUtils {
181
181
  let timestamp = UserDefaults.standard.object(forKey: DelayUpdateUtils.BACKGROUND_TIMESTAMP_KEY) as? Int64 ?? 0
182
182
  return timestamp
183
183
  } catch {
184
- print("\(CapacitorUpdater.TAG) Failed to get background timestamp, [Error calling 'getBackgroundTimestamp()']: \(error)")
184
+ print("\(CapgoUpdater.TAG) Failed to get background timestamp, [Error calling 'getBackgroundTimestamp()']: \(error)")
185
185
  return 0
186
186
  }
187
187
  }
@@ -190,10 +190,10 @@ public class DelayUpdateUtils {
190
190
  do {
191
191
  UserDefaults.standard.removeObject(forKey: DelayUpdateUtils.DELAY_CONDITION_PREFERENCES)
192
192
  UserDefaults.standard.synchronize()
193
- print("\(CapacitorUpdater.TAG) All delays canceled from \(source)")
193
+ print("\(CapgoUpdater.TAG) All delays canceled from \(source)")
194
194
  return true
195
195
  } catch {
196
- print("\(CapacitorUpdater.TAG) Failed to cancel update delay: \(error)")
196
+ print("\(CapgoUpdater.TAG) Failed to cancel update delay: \(error)")
197
197
  return false
198
198
  }
199
199
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/capacitor-updater",
3
- "version": "7.2.19",
3
+ "version": "7.2.21",
4
4
  "license": "MPL-2.0",
5
5
  "description": "Live update for capacitor apps",
6
6
  "main": "dist/plugin.cjs.js",