@capgo/capacitor-updater 8.51.24 → 8.51.25

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.
@@ -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 = "8.51.24";
149
+ private final String pluginVersion = "8.51.25";
150
150
  private static final String DELAY_CONDITION_PREFERENCES = "";
151
151
 
152
152
  private SharedPreferences.Editor editor;
@@ -2663,6 +2663,7 @@ public class CapacitorUpdaterPlugin extends Plugin {
2663
2663
  CapacitorUpdaterPlugin.this.editor,
2664
2664
  DEFAULT_CHANNEL_PREF_KEY,
2665
2665
  configDefaultChannel,
2666
+ CapacitorUpdaterPlugin.this.allowSetDefaultChannel,
2666
2667
  (res) -> {
2667
2668
  JSObject jsRes = InternalUtils.mapToJSObject(res);
2668
2669
  if (jsRes.has("error")) {
@@ -2507,8 +2507,18 @@ public class CapgoUpdater {
2507
2507
  final SharedPreferences.Editor editor,
2508
2508
  final String defaultChannelKey,
2509
2509
  final String configDefaultChannel,
2510
+ final boolean allowSetDefaultChannel,
2510
2511
  final Callback callback
2511
2512
  ) {
2513
+ if (!allowSetDefaultChannel) {
2514
+ logger.error("unsetChannel is disabled by allowSetDefaultChannel config");
2515
+ final Map<String, Object> retError = new HashMap<>();
2516
+ retError.put("message", "unsetChannel is disabled by configuration");
2517
+ retError.put("error", "disabled_by_config");
2518
+ callback.callback(retError);
2519
+ return;
2520
+ }
2521
+
2512
2522
  // Clear persisted defaultChannel and revert to config value
2513
2523
  editor.remove(defaultChannelKey);
2514
2524
  editor.apply();
@@ -96,7 +96,7 @@ public class CapacitorUpdaterPlugin: CAPPlugin, CAPBridgedPlugin {
96
96
  deinit {
97
97
  implementation.shutdown()
98
98
  }
99
- private let pluginVersion: String = "8.51.24"
99
+ private let pluginVersion: String = "8.51.25"
100
100
  private let launchStartedAtMs = Int64(Date().timeIntervalSince1970 * 1000)
101
101
  static let updateUrlDefault = "https://plugin.capgo.app/updates"
102
102
  static let statsUrlDefault = "https://plugin.capgo.app/stats"
@@ -3025,11 +3025,16 @@ public class CapacitorUpdaterPlugin: CAPPlugin, CAPBridgedPlugin {
3025
3025
  self.saveCallForAsyncHandling(call)
3026
3026
  DispatchQueue.global(qos: .utility).async {
3027
3027
  let configDefaultChannel = self.getConfig().getString("defaultChannel", "")!
3028
- let res = self.implementation.unsetChannel(defaultChannelKey: self.defaultChannelDefaultsKey, configDefaultChannel: configDefaultChannel)
3028
+ let res = self.implementation.unsetChannel(
3029
+ defaultChannelKey: self.defaultChannelDefaultsKey,
3030
+ configDefaultChannel: configDefaultChannel,
3031
+ allowSetDefaultChannel: self.allowSetDefaultChannel
3032
+ )
3029
3033
  if res.error != "" {
3030
- self.rejectCall(call, message: res.error, code: "UNSETCHANNEL_FAILED", data: [
3031
- "message": res.error,
3032
- "error": res.error.contains("Channel URL") ? "missing_config" : "request_failed"
3034
+ let message = res.message.isEmpty ? res.error : res.message
3035
+ self.rejectCall(call, message: message, code: "UNSETCHANNEL_FAILED", data: [
3036
+ "message": message,
3037
+ "error": res.error
3033
3038
  ])
3034
3039
  } else {
3035
3040
  guard self.persistDefaultChannelStateFromDefaults() else {
@@ -3077,9 +3082,20 @@ public class CapacitorUpdaterPlugin: CAPPlugin, CAPBridgedPlugin {
3077
3082
  "message": res.error
3078
3083
  ])
3079
3084
  }
3080
- self.rejectCall(call, message: res.error, code: "SETCHANNEL_FAILED", data: [
3081
- "message": res.error,
3082
- "error": res.error.contains("Channel URL") ? "missing_config" : (res.error.contains("cannot_update_via_private_channel") || res.error.contains("channel_self_set_not_allowed")) ? "channel_private" : "request_failed"
3085
+ let message = res.message.isEmpty ? res.error : res.message
3086
+ let errorCode: String
3087
+ if res.error == "disabled_by_config" {
3088
+ errorCode = res.error
3089
+ } else if res.error.contains("cannot_update_via_private_channel") || res.error.contains("channel_self_set_not_allowed") {
3090
+ errorCode = "channel_private"
3091
+ } else if res.error.contains("Channel URL") {
3092
+ errorCode = "missing_config"
3093
+ } else {
3094
+ errorCode = "request_failed"
3095
+ }
3096
+ self.rejectCall(call, message: message, code: "SETCHANNEL_FAILED", data: [
3097
+ "message": message,
3098
+ "error": errorCode
3083
3099
  ])
3084
3100
  } else {
3085
3101
  guard self.persistDefaultChannelStateFromDefaults() else {
@@ -2937,9 +2937,16 @@ import UIKit
2937
2937
  self.setBundleStatus(id: bundle.getId(), status: BundleStatus.ERROR)
2938
2938
  }
2939
2939
 
2940
- func unsetChannel(defaultChannelKey: String, configDefaultChannel: String) -> SetChannel {
2940
+ func unsetChannel(defaultChannelKey: String, configDefaultChannel: String, allowSetDefaultChannel: Bool) -> SetChannel {
2941
2941
  let setChannel: SetChannel = SetChannel()
2942
2942
 
2943
+ if !allowSetDefaultChannel {
2944
+ logger.error("unsetChannel is disabled by allowSetDefaultChannel config")
2945
+ setChannel.message = "unsetChannel is disabled by configuration"
2946
+ setChannel.error = "disabled_by_config"
2947
+ return setChannel
2948
+ }
2949
+
2943
2950
  // Clear persisted defaultChannel and revert to config value
2944
2951
  UserDefaults.standard.removeObject(forKey: defaultChannelKey)
2945
2952
  UserDefaults.standard.synchronize()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/capacitor-updater",
3
- "version": "8.51.24",
3
+ "version": "8.51.25",
4
4
  "license": "MPL-2.0",
5
5
  "description": "Live update for capacitor apps",
6
6
  "main": "dist/plugin.cjs.js",