@capgo/capacitor-updater 7.2.20 → 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.
@@ -40,7 +40,7 @@ import org.json.JSONArray;
40
40
  import org.json.JSONException;
41
41
  import org.json.JSONObject;
42
42
 
43
- public class CapacitorUpdater {
43
+ public class CapgoUpdater {
44
44
 
45
45
  private static final String AB = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
46
46
  private static final SecureRandom rnd = new SecureRandom();
@@ -326,7 +326,7 @@ public class CapacitorUpdater {
326
326
 
327
327
  // If public key is present but no checksum provided, refuse installation
328
328
  if (!this.publicKey.isEmpty() && checksumDecrypted.isEmpty()) {
329
- Log.e(CapacitorUpdater.TAG, "Public key present but no checksum provided");
329
+ Log.e(CapgoUpdater.TAG, "Public key present but no checksum provided");
330
330
  this.sendStats("checksum_required");
331
331
  throw new IOException("Checksum required when public key is present: " + id);
332
332
  }
@@ -339,7 +339,7 @@ public class CapacitorUpdater {
339
339
  checksum = CryptoCipherV2.calcChecksum(downloaded);
340
340
  }
341
341
  if ((!checksumDecrypted.isEmpty() || !this.publicKey.isEmpty()) && !checksumDecrypted.equals(checksum)) {
342
- Log.e(CapacitorUpdater.TAG, "Error checksum '" + checksumDecrypted + "' '" + checksum + "' '");
342
+ Log.e(CapgoUpdater.TAG, "Error checksum '" + checksumDecrypted + "' '" + checksum + "' '");
343
343
  this.sendStats("checksum_fail");
344
344
  throw new IOException("Checksum failed: " + id);
345
345
  }
@@ -348,14 +348,14 @@ public class CapacitorUpdater {
348
348
  } catch (Exception e) {
349
349
  final Boolean res = this.delete(id);
350
350
  if (!res) {
351
- Log.i(CapacitorUpdater.TAG, "Double error, cannot cleanup: " + version);
351
+ Log.i(CapgoUpdater.TAG, "Double error, cannot cleanup: " + version);
352
352
  }
353
353
 
354
354
  final Map<String, Object> ret = new HashMap<>();
355
- ret.put("version", CapacitorUpdater.this.getCurrentBundle().getVersionName());
355
+ ret.put("version", CapgoUpdater.this.getCurrentBundle().getVersionName());
356
356
 
357
- CapacitorUpdater.this.notifyListeners("downloadFailed", ret);
358
- CapacitorUpdater.this.sendStats("download_fail");
357
+ CapgoUpdater.this.notifyListeners("downloadFailed", ret);
358
+ CapgoUpdater.this.sendStats("download_fail");
359
359
  return false;
360
360
  }
361
361
 
@@ -378,10 +378,10 @@ public class CapacitorUpdater {
378
378
 
379
379
  final Map<String, Object> ret = new HashMap<>();
380
380
  ret.put("bundle", next.toJSONMap());
381
- CapacitorUpdater.this.notifyListeners("updateAvailable", ret);
381
+ CapgoUpdater.this.notifyListeners("updateAvailable", ret);
382
382
  if (setNext) {
383
383
  if (this.directUpdate) {
384
- CapacitorUpdater.this.directUpdateFinish(next);
384
+ CapgoUpdater.this.directUpdateFinish(next);
385
385
  this.directUpdate = false;
386
386
  } else {
387
387
  this.setNextBundle(next.getId());
@@ -390,9 +390,9 @@ public class CapacitorUpdater {
390
390
  } catch (IOException e) {
391
391
  e.printStackTrace();
392
392
  final Map<String, Object> ret = new HashMap<>();
393
- ret.put("version", CapacitorUpdater.this.getCurrentBundle().getVersionName());
394
- CapacitorUpdater.this.notifyListeners("downloadFailed", ret);
395
- CapacitorUpdater.this.sendStats("download_fail");
393
+ ret.put("version", CapgoUpdater.this.getCurrentBundle().getVersionName());
394
+ CapgoUpdater.this.notifyListeners("downloadFailed", ret);
395
+ CapgoUpdater.this.sendStats("download_fail");
396
396
  return false;
397
397
  }
398
398
  return true;
@@ -546,7 +546,7 @@ public class CapacitorUpdater {
546
546
  return this.delete(id, true);
547
547
  } catch (IOException e) {
548
548
  e.printStackTrace();
549
- Log.i(CapacitorUpdater.TAG, "Failed to delete bundle (" + id + ")" + "\nError:\n" + e.toString());
549
+ Log.i(CapgoUpdater.TAG, "Failed to delete bundle (" + id + ")" + "\nError:\n" + e.toString());
550
550
  return false;
551
551
  }
552
552
  }
@@ -600,12 +600,12 @@ public class CapacitorUpdater {
600
600
  public void setSuccess(final BundleInfo bundle, Boolean autoDeletePrevious) {
601
601
  this.setBundleStatus(bundle.getId(), BundleStatus.SUCCESS);
602
602
  final BundleInfo fallback = this.getFallbackBundle();
603
- Log.d(CapacitorUpdater.TAG, "Fallback bundle is: " + fallback);
604
- Log.i(CapacitorUpdater.TAG, "Version successfully loaded: " + bundle.getVersionName());
603
+ Log.d(CapgoUpdater.TAG, "Fallback bundle is: " + fallback);
604
+ Log.i(CapgoUpdater.TAG, "Version successfully loaded: " + bundle.getVersionName());
605
605
  if (autoDeletePrevious && !fallback.isBuiltin()) {
606
606
  final Boolean res = this.delete(fallback.getId());
607
607
  if (res) {
608
- Log.i(CapacitorUpdater.TAG, "Deleted previous bundle: " + fallback.getVersionName());
608
+ Log.i(CapgoUpdater.TAG, "Deleted previous bundle: " + fallback.getVersionName());
609
609
  }
610
610
  }
611
611
  this.setFallbackBundle(bundle);
@@ -616,7 +616,7 @@ public class CapacitorUpdater {
616
616
  }
617
617
 
618
618
  public void reset(final boolean internal) {
619
- Log.d(CapacitorUpdater.TAG, "reset: " + internal);
619
+ Log.d(CapgoUpdater.TAG, "reset: " + internal);
620
620
  var currentBundleName = this.getCurrentBundle().getVersionName();
621
621
  this.setCurrentBundle(new File("public"));
622
622
  this.setFallbackBundle(null);
@@ -720,7 +720,7 @@ public class CapacitorUpdater {
720
720
  return;
721
721
  }
722
722
 
723
- Log.i(CapacitorUpdater.TAG, "Auto-update parameters: " + json);
723
+ Log.i(CapgoUpdater.TAG, "Auto-update parameters: " + json);
724
724
 
725
725
  makeJsonRequest(updateUrl, json, callback);
726
726
  }
@@ -135,11 +135,11 @@ public class CryptoCipherV2 {
135
135
 
136
136
  public static void decryptFile(final File file, final String publicKey, final String ivSessionKey) throws IOException {
137
137
  if (publicKey.isEmpty() || ivSessionKey == null || ivSessionKey.isEmpty() || ivSessionKey.split(":").length != 2) {
138
- Log.i(CapacitorUpdater.TAG, "Encryption not set, no public key or seesion, ignored");
138
+ Log.i(CapgoUpdater.TAG, "Encryption not set, no public key or seesion, ignored");
139
139
  return;
140
140
  }
141
141
  if (!publicKey.startsWith("-----BEGIN RSA PUBLIC KEY-----")) {
142
- Log.e(CapacitorUpdater.TAG, "The public key is not a valid RSA Public key");
142
+ Log.e(CapgoUpdater.TAG, "The public key is not a valid RSA Public key");
143
143
  return;
144
144
  }
145
145
 
@@ -168,7 +168,7 @@ public class CryptoCipherV2 {
168
168
  }
169
169
  }
170
170
  } catch (GeneralSecurityException e) {
171
- Log.i(CapacitorUpdater.TAG, "decryptFile fail");
171
+ Log.i(CapgoUpdater.TAG, "decryptFile fail");
172
172
  e.printStackTrace();
173
173
  throw new IOException("GeneralSecurityException");
174
174
  }
@@ -176,7 +176,7 @@ public class CryptoCipherV2 {
176
176
 
177
177
  public static String decryptChecksum(String checksum, String publicKey) throws IOException {
178
178
  if (publicKey.isEmpty()) {
179
- Log.e(CapacitorUpdater.TAG, "No encryption set (public key) ignored");
179
+ Log.e(CapgoUpdater.TAG, "No encryption set (public key) ignored");
180
180
  return checksum;
181
181
  }
182
182
  try {
@@ -187,7 +187,7 @@ public class CryptoCipherV2 {
187
187
  String result = Base64.encodeToString(decryptedChecksum, Base64.DEFAULT);
188
188
  return result.replaceAll("\\s", ""); // Remove all whitespace, including newlines
189
189
  } catch (GeneralSecurityException e) {
190
- Log.e(CapacitorUpdater.TAG, "decryptChecksum fail: " + e.getMessage());
190
+ Log.e(CapgoUpdater.TAG, "decryptChecksum fail: " + e.getMessage());
191
191
  throw new IOException("Decryption failed: " + e.getMessage());
192
192
  }
193
193
  }
@@ -198,7 +198,7 @@ public class CryptoCipherV2 {
198
198
  try {
199
199
  digest = MessageDigest.getInstance("SHA-256");
200
200
  } catch (java.security.NoSuchAlgorithmException e) {
201
- System.err.println(CapacitorUpdater.TAG + " SHA-256 algorithm not available");
201
+ System.err.println(CapgoUpdater.TAG + " SHA-256 algorithm not available");
202
202
  return "";
203
203
  }
204
204
 
@@ -217,7 +217,7 @@ public class CryptoCipherV2 {
217
217
  }
218
218
  return hexString.toString();
219
219
  } catch (IOException e) {
220
- System.err.println(CapacitorUpdater.TAG + " Cannot calc checksum v2: " + file.getPath() + " " + e.getMessage());
220
+ System.err.println(CapgoUpdater.TAG + " Cannot calc checksum v2: " + file.getPath() + " " + e.getMessage());
221
221
  return "";
222
222
  }
223
223
  }
@@ -55,7 +55,7 @@ public class DelayUpdateUtils {
55
55
  longValue = Long.parseLong(value);
56
56
  } catch (NumberFormatException e) {
57
57
  Log.e(
58
- CapacitorUpdater.TAG,
58
+ CapgoUpdater.TAG,
59
59
  "Background condition (value: " +
60
60
  value +
61
61
  ") had an invalid value at index " +
@@ -66,7 +66,7 @@ public class DelayUpdateUtils {
66
66
 
67
67
  if (delta > longValue) {
68
68
  Log.i(
69
- CapacitorUpdater.TAG,
69
+ CapgoUpdater.TAG,
70
70
  "Background condition (value: " +
71
71
  value +
72
72
  ") deleted at index " +
@@ -80,7 +80,7 @@ public class DelayUpdateUtils {
80
80
  } else {
81
81
  delayConditionListToKeep.add(condition);
82
82
  Log.i(
83
- CapacitorUpdater.TAG,
83
+ CapgoUpdater.TAG,
84
84
  "Background delay (value: " +
85
85
  value +
86
86
  ") condition kept at index " +
@@ -97,7 +97,7 @@ public class DelayUpdateUtils {
97
97
  } else {
98
98
  delayConditionListToKeep.add(condition);
99
99
  Log.i(
100
- CapacitorUpdater.TAG,
100
+ CapgoUpdater.TAG,
101
101
  "Kill delay (value: " + value + ") condition kept at index " + index + " (source: " + source.toString() + ")"
102
102
  );
103
103
  }
@@ -110,25 +110,22 @@ public class DelayUpdateUtils {
110
110
  assert date != null;
111
111
  if (new Date().compareTo(date) > 0) {
112
112
  Log.i(
113
- CapacitorUpdater.TAG,
113
+ CapgoUpdater.TAG,
114
114
  "Date delay (value: " + value + ") condition removed due to expired date at index " + index
115
115
  );
116
116
  } else {
117
117
  delayConditionListToKeep.add(condition);
118
- Log.i(CapacitorUpdater.TAG, "Date delay (value: " + value + ") condition kept at index " + index);
118
+ Log.i(CapgoUpdater.TAG, "Date delay (value: " + value + ") condition kept at index " + index);
119
119
  }
120
120
  } catch (final Exception e) {
121
121
  Log.e(
122
- CapacitorUpdater.TAG,
122
+ CapgoUpdater.TAG,
123
123
  "Date delay (value: " + value + ") condition removed due to parsing issue at index " + index,
124
124
  e
125
125
  );
126
126
  }
127
127
  } else {
128
- Log.d(
129
- CapacitorUpdater.TAG,
130
- "Date delay (value: " + value + ") condition removed due to empty value at index " + index
131
- );
128
+ Log.d(CapgoUpdater.TAG, "Date delay (value: " + value + ") condition removed due to empty value at index " + index);
132
129
  }
133
130
  break;
134
131
  case DelayUntilNext.nativeVersion:
@@ -137,23 +134,23 @@ public class DelayUpdateUtils {
137
134
  final Version versionLimit = new Version(value);
138
135
  if (this.currentVersionNative.isAtLeast(versionLimit)) {
139
136
  Log.i(
140
- CapacitorUpdater.TAG,
137
+ CapgoUpdater.TAG,
141
138
  "Native version delay (value: " + value + ") condition removed due to above limit at index " + index
142
139
  );
143
140
  } else {
144
141
  delayConditionListToKeep.add(condition);
145
- Log.i(CapacitorUpdater.TAG, "Native version delay (value: " + value + ") condition kept at index " + index);
142
+ Log.i(CapgoUpdater.TAG, "Native version delay (value: " + value + ") condition kept at index " + index);
146
143
  }
147
144
  } catch (final Exception e) {
148
145
  Log.e(
149
- CapacitorUpdater.TAG,
146
+ CapgoUpdater.TAG,
150
147
  "Native version delay (value: " + value + ") condition removed due to parsing issue at index " + index,
151
148
  e
152
149
  );
153
150
  }
154
151
  } else {
155
152
  Log.d(
156
- CapacitorUpdater.TAG,
153
+ CapgoUpdater.TAG,
157
154
  "Native version delay (value: " + value + ") condition removed due to empty value at index " + index
158
155
  );
159
156
  }
@@ -171,10 +168,10 @@ public class DelayUpdateUtils {
171
168
  try {
172
169
  this.editor.putString(DELAY_CONDITION_PREFERENCES, delayConditions);
173
170
  this.editor.commit();
174
- Log.i(CapacitorUpdater.TAG, "Delay update saved");
171
+ Log.i(CapgoUpdater.TAG, "Delay update saved");
175
172
  return true;
176
173
  } catch (final Exception e) {
177
- Log.e(CapacitorUpdater.TAG, "Failed to delay update, [Error calling '_setMultiDelay()']", e);
174
+ Log.e(CapgoUpdater.TAG, "Failed to delay update, [Error calling '_setMultiDelay()']", e);
178
175
  return false;
179
176
  }
180
177
  }
@@ -183,9 +180,9 @@ public class DelayUpdateUtils {
183
180
  try {
184
181
  this.editor.putLong(BACKGROUND_TIMESTAMP_KEY, backgroundTimestamp);
185
182
  this.editor.commit();
186
- Log.i(CapacitorUpdater.TAG, "Delay update saved");
183
+ Log.i(CapgoUpdater.TAG, "Delay update saved");
187
184
  } catch (final Exception e) {
188
- Log.e(CapacitorUpdater.TAG, "Failed to delay update, [Error calling '_setBackgroundTimestamp()']", e);
185
+ Log.e(CapgoUpdater.TAG, "Failed to delay update, [Error calling '_setBackgroundTimestamp()']", e);
189
186
  }
190
187
  }
191
188
 
@@ -193,9 +190,9 @@ public class DelayUpdateUtils {
193
190
  try {
194
191
  this.editor.remove(BACKGROUND_TIMESTAMP_KEY);
195
192
  this.editor.commit();
196
- Log.i(CapacitorUpdater.TAG, "Delay update saved");
193
+ Log.i(CapgoUpdater.TAG, "Delay update saved");
197
194
  } catch (final Exception e) {
198
- Log.e(CapacitorUpdater.TAG, "Failed to delay update, [Error calling '_unsetBackgroundTimestamp()']", e);
195
+ Log.e(CapgoUpdater.TAG, "Failed to delay update, [Error calling '_unsetBackgroundTimestamp()']", e);
199
196
  }
200
197
  }
201
198
 
@@ -203,7 +200,7 @@ public class DelayUpdateUtils {
203
200
  try {
204
201
  return this.prefs.getLong(BACKGROUND_TIMESTAMP_KEY, 0);
205
202
  } catch (final Exception e) {
206
- Log.e(CapacitorUpdater.TAG, "Failed to delay update, [Error calling '_getBackgroundTimestamp()']", e);
203
+ Log.e(CapgoUpdater.TAG, "Failed to delay update, [Error calling '_getBackgroundTimestamp()']", e);
207
204
  return 0;
208
205
  }
209
206
  }
@@ -212,10 +209,10 @@ public class DelayUpdateUtils {
212
209
  try {
213
210
  this.editor.remove(DELAY_CONDITION_PREFERENCES);
214
211
  this.editor.commit();
215
- Log.i(CapacitorUpdater.TAG, "All delays canceled from " + source);
212
+ Log.i(CapgoUpdater.TAG, "All delays canceled from " + source);
216
213
  return true;
217
214
  } catch (final Exception e) {
218
- Log.e(CapacitorUpdater.TAG, "Failed to cancel update delay", e);
215
+ Log.e(CapgoUpdater.TAG, "Failed to cancel update delay", e);
219
216
  return false;
220
217
  }
221
218
  }
@@ -409,7 +409,7 @@ public class DownloadService extends Worker {
409
409
  }
410
410
 
411
411
  if (!publicKey.isEmpty() && sessionKey != null && !sessionKey.isEmpty()) {
412
- Log.d(CapacitorUpdater.TAG + " DLSrv", "Decrypting file " + targetFile.getName());
412
+ Log.d(CapgoUpdater.TAG + " DLSrv", "Decrypting file " + targetFile.getName());
413
413
  CryptoCipherV2.decryptFile(compressedFile, publicKey, sessionKey);
414
414
  }
415
415
 
@@ -56,11 +56,11 @@ public struct AES128Key {
56
56
  result.length = Int(decryptedLength)
57
57
  return result as Data
58
58
  } else {
59
- print("\(CapacitorUpdater.TAG) AES decryption failed with status: \(status)")
59
+ print("\(CapgoUpdater.TAG) AES decryption failed with status: \(status)")
60
60
  return nil
61
61
  }
62
62
  } else {
63
- print("\(CapacitorUpdater.TAG) Failed to allocate memory for AES decryption")
63
+ print("\(CapgoUpdater.TAG) Failed to allocate memory for AES decryption")
64
64
  return nil
65
65
  }
66
66
  }