@capgo/capacitor-updater 8.43.8 → 8.43.10

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.
@@ -63,7 +63,7 @@ dependencies {
63
63
  implementation 'com.google.android.play:app-update:2.1.0'
64
64
  implementation 'com.google.android.play:app-update-ktx:2.1.0'
65
65
  testImplementation "junit:junit:$junitVersion"
66
- testImplementation 'org.mockito:mockito-core:5.21.0'
66
+ testImplementation 'org.mockito:mockito-core:5.22.0'
67
67
  testImplementation 'org.json:json:20250517'
68
68
  testImplementation 'org.robolectric:robolectric:4.16.1'
69
69
  androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
@@ -84,7 +84,7 @@ public class CapacitorUpdaterPlugin extends Plugin {
84
84
  private static final String[] BREAKING_EVENT_NAMES = { "breakingAvailable", "majorAvailable" };
85
85
  private static final String LAST_FAILED_BUNDLE_PREF_KEY = "CapacitorUpdater.lastFailedBundle";
86
86
 
87
- private final String pluginVersion = "8.43.8";
87
+ private final String pluginVersion = "8.43.10";
88
88
  private static final String DELAY_CONDITION_PREFERENCES = "";
89
89
 
90
90
  private SharedPreferences.Editor editor;
@@ -91,27 +91,36 @@ public class DownloadService extends Worker {
91
91
  .protocols(Arrays.asList(Protocol.HTTP_2, Protocol.HTTP_1_1))
92
92
  .addInterceptor((chain) -> {
93
93
  Request originalRequest = chain.request();
94
- String userAgent =
95
- "CapacitorUpdater/" +
96
- (currentPluginVersion != null ? currentPluginVersion : "unknown") +
97
- " (" +
98
- (currentAppId != null ? currentAppId : "unknown") +
99
- ") android/" +
100
- (currentVersionOs != null ? currentVersionOs : "unknown");
94
+ String userAgent = buildUserAgent(currentAppId, currentPluginVersion, currentVersionOs);
101
95
  Request requestWithUserAgent = originalRequest.newBuilder().header("User-Agent", userAgent).build();
102
96
  return chain.proceed(requestWithUserAgent);
103
97
  })
104
98
  .build();
105
99
  }
106
100
 
101
+ static String buildUserAgent(String appId, String pluginVersion, String versionOs) {
102
+ return (
103
+ "CapacitorUpdater/" +
104
+ sanitizeUserAgentValue(pluginVersion) +
105
+ " (" +
106
+ sanitizeUserAgentValue(appId) +
107
+ ") android/" +
108
+ sanitizeUserAgentValue(versionOs)
109
+ );
110
+ }
111
+
112
+ private static String sanitizeUserAgentValue(String value) {
113
+ return value == null || value.isEmpty() ? "unknown" : value;
114
+ }
115
+
107
116
  // Method to update User-Agent values
108
117
  public static void updateUserAgent(String appId, String pluginVersion, String versionOs) {
109
- currentAppId = appId != null ? appId : "unknown";
110
- currentPluginVersion = pluginVersion != null ? pluginVersion : "unknown";
111
- currentVersionOs = versionOs != null ? versionOs : "unknown";
112
- logger.debug(
113
- "Updated User-Agent: CapacitorUpdater/" + currentPluginVersion + " (" + currentAppId + ") android/" + currentVersionOs
114
- );
118
+ currentAppId = sanitizeUserAgentValue(appId);
119
+ currentPluginVersion = sanitizeUserAgentValue(pluginVersion);
120
+ currentVersionOs = sanitizeUserAgentValue(versionOs);
121
+ if (logger != null) {
122
+ logger.debug("Updated User-Agent: " + buildUserAgent(currentAppId, currentPluginVersion, currentVersionOs));
123
+ }
115
124
  }
116
125
 
117
126
  public DownloadService(@NonNull Context context, @NonNull WorkerParameters params) {
@@ -72,7 +72,7 @@ public class CapacitorUpdaterPlugin: CAPPlugin, CAPBridgedPlugin {
72
72
  CAPPluginMethod(name: "completeFlexibleUpdate", returnType: CAPPluginReturnPromise)
73
73
  ]
74
74
  public var implementation = CapgoUpdater()
75
- private let pluginVersion: String = "8.43.8"
75
+ private let pluginVersion: String = "8.43.10"
76
76
  static let updateUrlDefault = "https://plugin.capgo.app/updates"
77
77
  static let statsUrlDefault = "https://plugin.capgo.app/stats"
78
78
  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": "8.43.8",
3
+ "version": "8.43.10",
4
4
  "license": "MPL-2.0",
5
5
  "description": "Live update for capacitor apps",
6
6
  "main": "dist/plugin.cjs.js",