@capgo/capacitor-updater 6.51.19 → 6.51.23

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
@@ -46,7 +46,7 @@ Perfect for fixing bugs immediately, A/B testing features, and maintaining contr
46
46
  - 🔄 Auto Update: Automatically download and set the latest bundle for the app.
47
47
  - 🛟 Rollback: Reset the app to last working bundle if an incompatible bundle has been set.
48
48
  - 🔁 **Delta Updates**: Make instant updates by only downloading changed files.
49
- - 🔒 **Security**: Encrypt and sign each updates with best in class security standards.
49
+ - 🔒 Security: checksum on every update; encryption optional for high-security apps.
50
50
  - ⚔️ **Battle-Tested**: Used in more than 3000 projects.
51
51
  - 📊 View your deployment statistics
52
52
  - 🔋 Supports Android and iOS
@@ -146,7 +146,7 @@ public class CapacitorUpdaterPlugin extends Plugin {
146
146
  static final int APPLICATION_EXIT_REASON_USER_REQUESTED = 10;
147
147
  static final int APPLICATION_EXIT_REASON_DEPENDENCY_DIED = 12;
148
148
 
149
- private final String pluginVersion = "6.51.19";
149
+ private final String pluginVersion = "6.51.23";
150
150
  private static final String DELAY_CONDITION_PREFERENCES = "";
151
151
 
152
152
  private SharedPreferences.Editor editor;
@@ -2139,9 +2139,10 @@ public class CapacitorUpdaterPlugin extends Plugin {
2139
2139
  );
2140
2140
  }
2141
2141
  } else {
2142
- final boolean enabled = configuredMode != null
2143
- ? "true".equals(configuredMode)
2144
- : Boolean.TRUE.equals(this.getConfig().getBoolean("autoUpdate", true));
2142
+ final boolean enabled =
2143
+ configuredMode != null
2144
+ ? "true".equals(configuredMode)
2145
+ : Boolean.TRUE.equals(this.getConfig().getBoolean("autoUpdate", true));
2145
2146
  this.autoUpdateMode = enabled
2146
2147
  ? autoUpdateModeForLegacyDirectUpdateMode(this.resolveLegacyDirectUpdateModeFromConfig())
2147
2148
  : AUTO_UPDATE_MODE_OFF;
@@ -2841,6 +2842,16 @@ public class CapacitorUpdaterPlugin extends Plugin {
2841
2842
  final String checksum,
2842
2843
  final JSONArray manifest
2843
2844
  ) throws IOException {
2845
+ if (!this.implementation.publicKey.isEmpty() && !CryptoCipher.isValidSessionKey(sessionKey)) {
2846
+ logger.error("Public key present but no valid session key provided");
2847
+ this.implementation.sendStats("session_key_required");
2848
+ throw new IOException("Session key required when public key is present");
2849
+ }
2850
+ if (manifest == null && (checksum == null || checksum.isEmpty())) {
2851
+ logger.error("No checksum provided");
2852
+ this.implementation.sendStats("checksum_required");
2853
+ throw new IOException("Checksum required");
2854
+ }
2844
2855
  // Manual/preview downloads must wait too — launch orphan sweep can delete their temps.
2845
2856
  waitForCleanupIfNeeded();
2846
2857
  if (manifest != null) {
@@ -4013,33 +4024,30 @@ public class CapacitorUpdaterPlugin extends Plugin {
4013
4024
  this.editor.putBoolean(PREVIEW_SESSION_ALERT_PENDING_PREF_KEY, false);
4014
4025
  this.editor.apply();
4015
4026
 
4016
- new Handler(Looper.getMainLooper()).postDelayed(
4017
- () -> {
4018
- try {
4019
- if (!Boolean.TRUE.equals(this.previewSessionEnabled)) {
4020
- return;
4021
- }
4022
- if (getActivity() == null || getActivity().isFinishing()) {
4023
- this.previewSessionAlertPending = true;
4024
- this.editor.putBoolean(PREVIEW_SESSION_ALERT_PENDING_PREF_KEY, true);
4025
- this.editor.apply();
4026
- return;
4027
- }
4028
-
4029
- new AlertDialog.Builder(getActivity())
4030
- .setTitle("Preview started")
4031
- .setMessage("shake".equals(this.shakeMenuGesture) ? "Shake to open menu." : "Three-finger pinch to open menu.")
4032
- .setPositiveButton("Got it", (dialog, which) -> dialog.dismiss())
4033
- .show();
4034
- } catch (final Exception e) {
4027
+ new Handler(Looper.getMainLooper()).postDelayed(() -> {
4028
+ try {
4029
+ if (!Boolean.TRUE.equals(this.previewSessionEnabled)) {
4030
+ return;
4031
+ }
4032
+ if (getActivity() == null || getActivity().isFinishing()) {
4035
4033
  this.previewSessionAlertPending = true;
4036
4034
  this.editor.putBoolean(PREVIEW_SESSION_ALERT_PENDING_PREF_KEY, true);
4037
4035
  this.editor.apply();
4038
- logger.warn("Could not show preview session notice: " + e.getMessage());
4036
+ return;
4039
4037
  }
4040
- },
4041
- 600
4042
- );
4038
+
4039
+ new AlertDialog.Builder(getActivity())
4040
+ .setTitle("Preview started")
4041
+ .setMessage("shake".equals(this.shakeMenuGesture) ? "Shake to open menu." : "Three-finger pinch to open menu.")
4042
+ .setPositiveButton("Got it", (dialog, which) -> dialog.dismiss())
4043
+ .show();
4044
+ } catch (final Exception e) {
4045
+ this.previewSessionAlertPending = true;
4046
+ this.editor.putBoolean(PREVIEW_SESSION_ALERT_PENDING_PREF_KEY, true);
4047
+ this.editor.apply();
4048
+ logger.warn("Could not show preview session notice: " + e.getMessage());
4049
+ }
4050
+ }, 600);
4043
4051
  }
4044
4052
 
4045
4053
  @PluginMethod
@@ -4785,8 +4793,8 @@ public class CapacitorUpdaterPlugin extends Plugin {
4785
4793
  final String messageUpdate = initialDirectUpdateAllowed
4786
4794
  ? "Update will occur now."
4787
4795
  : this.shouldAutoSetNextBundle()
4788
- ? "Update will occur next time app moves to background."
4789
- : "Update will be downloaded and made available.";
4796
+ ? "Update will occur next time app moves to background."
4797
+ : "Update will be downloaded and made available.";
4790
4798
  Thread newTask = startNewThread(() -> {
4791
4799
  if (CapacitorUpdaterPlugin.this.shouldBlockAutoUpdateForPreviewSession()) {
4792
4800
  CapacitorUpdaterPlugin.this.clearBackgroundDownloadState();
@@ -4938,7 +4946,13 @@ public class CapacitorUpdaterPlugin extends Plugin {
4938
4946
  );
4939
4947
  return;
4940
4948
  }
4941
- if (latest.isDownloaded() && BundleStatus.DOWNLOADING != latest.getStatus()) {
4949
+ final String latestSessionKey = jsRes.has("sessionKey") ? jsRes.getString("sessionKey") : "";
4950
+ if (
4951
+ latest.isDownloaded() &&
4952
+ BundleStatus.DOWNLOADING != latest.getStatus() &&
4953
+ (CapacitorUpdaterPlugin.this.implementation.publicKey.isEmpty() ||
4954
+ CryptoCipher.isValidSessionKey(latestSessionKey))
4955
+ ) {
4942
4956
  logger.info("Latest bundle already exists and download is NOT required. " + messageUpdate);
4943
4957
  final boolean directUpdateAllowedNow = CapacitorUpdaterPlugin.this.isDirectUpdateCurrentlyAllowed(
4944
4958
  plannedDirectUpdate