@capgo/capacitor-updater 8.53.1 → 8.54.0
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 +31 -15
- package/android/src/main/java/ee/forgr/capacitor_updater/CapacitorUpdaterPlugin.java +187 -16
- package/android/src/main/java/ee/forgr/capacitor_updater/CapgoUpdater.java +179 -18
- package/android/src/main/java/ee/forgr/capacitor_updater/CryptoCipher.java +82 -19
- package/android/src/main/java/ee/forgr/capacitor_updater/DownloadService.java +147 -29
- package/dist/docs.json +34 -2
- package/dist/esm/definitions.d.ts +46 -2
- package/dist/esm/definitions.js.map +1 -1
- package/ios/Sources/CapacitorUpdaterPlugin/CapacitorUpdaterPlugin.swift +44 -1
- package/ios/Sources/CapacitorUpdaterPlugin/CapgoUpdater.swift +278 -56
- package/ios/Sources/CapacitorUpdaterPlugin/CryptoCipher.swift +59 -33
- package/ios/Sources/CapacitorUpdaterPlugin/InternalUtils.swift +0 -19
- package/ios/Sources/CapacitorUpdaterPlugin/RedirectPolicyDelegate.swift +20 -0
- package/package.json +1 -1
|
@@ -95,7 +95,7 @@ public class CapacitorUpdaterPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
95
95
|
deinit {
|
|
96
96
|
implementation.shutdown()
|
|
97
97
|
}
|
|
98
|
-
private let pluginVersion: String = "8.
|
|
98
|
+
private let pluginVersion: String = "8.54.0"
|
|
99
99
|
private let launchStartedAtMs = Int64(Date().timeIntervalSince1970 * 1000)
|
|
100
100
|
static let updateUrlDefault = "https://plugin.capgo.app/updates"
|
|
101
101
|
static let statsUrlDefault = "https://plugin.capgo.app/stats"
|
|
@@ -315,6 +315,8 @@ public class CapacitorUpdaterPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
315
315
|
appReadyTimeout = max(1000, getConfig().getInt("appReadyTimeout", 10000)) // Minimum 1 second
|
|
316
316
|
implementation.timeout = Double(getConfig().getInt("responseTimeout", 20))
|
|
317
317
|
implementation.allowHttpsToHttpRedirect = getConfig().getBoolean("allowHttpsToHttpRedirect", false)
|
|
318
|
+
implementation.httpsOnly = getConfig().getBoolean("httpsOnly", true)
|
|
319
|
+
implementation.builtinMinimum = getConfig().getBoolean("builtinMinimum", false)
|
|
318
320
|
resetWhenUpdate = getConfig().getBoolean("resetWhenUpdate", true)
|
|
319
321
|
shakeMenuEnabled = getConfig().getBoolean("shakeMenu", false)
|
|
320
322
|
shakeChannelSelectorEnabled = getConfig().getBoolean("allowShakeChannelSelector", false)
|
|
@@ -381,6 +383,12 @@ public class CapacitorUpdaterPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
381
383
|
logger.info("Loaded persisted channelUrl")
|
|
382
384
|
}
|
|
383
385
|
}
|
|
386
|
+
if implementation.httpsOnly {
|
|
387
|
+
for (label, value) in [("updateUrl", updateUrl), ("statsUrl", implementation.statsUrl), ("channelUrl", implementation.channelUrl)]
|
|
388
|
+
where !value.isEmpty && !Self.isHttpsUrl(value) {
|
|
389
|
+
logger.error("httpsOnly is enabled and \(label) \(value) is not https; requests to it will fail")
|
|
390
|
+
}
|
|
391
|
+
}
|
|
384
392
|
implementation.restorePendingStats()
|
|
385
393
|
|
|
386
394
|
let nativeBuildVersionChanged = self.hasNativeBuildVersionChanged()
|
|
@@ -1341,6 +1349,20 @@ public class CapacitorUpdaterPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
1341
1349
|
}
|
|
1342
1350
|
}
|
|
1343
1351
|
|
|
1352
|
+
static func isHttpsUrl(_ value: String) -> Bool {
|
|
1353
|
+
return URL(string: value)?.scheme?.lowercased() == "https"
|
|
1354
|
+
}
|
|
1355
|
+
|
|
1356
|
+
/// Rejects the call when `httpsOnly` is set and the URL is not https. Returns true when the URL is allowed.
|
|
1357
|
+
private func allowUrlScheme(_ url: String, call: CAPPluginCall, method: String) -> Bool {
|
|
1358
|
+
if implementation.httpsOnly && !Self.isHttpsUrl(url) {
|
|
1359
|
+
logger.error("\(method): httpsOnly is enabled and \(url) is not https")
|
|
1360
|
+
call.reject("httpsOnly is enabled and \(url) is not https")
|
|
1361
|
+
return false
|
|
1362
|
+
}
|
|
1363
|
+
return true
|
|
1364
|
+
}
|
|
1365
|
+
|
|
1344
1366
|
@objc func setUpdateUrl(_ call: CAPPluginCall) {
|
|
1345
1367
|
if !getConfig().getBoolean("allowModifyUrl", false) {
|
|
1346
1368
|
logger.error("setUpdateUrl called without allowModifyUrl")
|
|
@@ -1352,6 +1374,9 @@ public class CapacitorUpdaterPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
1352
1374
|
call.reject("setUpdateUrl called without url")
|
|
1353
1375
|
return
|
|
1354
1376
|
}
|
|
1377
|
+
guard allowUrlScheme(url, call: call, method: "setUpdateUrl") else {
|
|
1378
|
+
return
|
|
1379
|
+
}
|
|
1355
1380
|
self.updateUrl = url
|
|
1356
1381
|
if persistModifyUrl {
|
|
1357
1382
|
UserDefaults.standard.set(url, forKey: updateUrlDefaultsKey)
|
|
@@ -1375,6 +1400,9 @@ public class CapacitorUpdaterPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
1375
1400
|
call.reject("setStatsUrl called without url")
|
|
1376
1401
|
return
|
|
1377
1402
|
}
|
|
1403
|
+
guard allowUrlScheme(url, call: call, method: "setStatsUrl") else {
|
|
1404
|
+
return
|
|
1405
|
+
}
|
|
1378
1406
|
self.implementation.statsUrl = url
|
|
1379
1407
|
if persistModifyUrl {
|
|
1380
1408
|
UserDefaults.standard.set(url, forKey: statsUrlDefaultsKey)
|
|
@@ -1394,6 +1422,9 @@ public class CapacitorUpdaterPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
1394
1422
|
call.reject("setChannelUrl called without url")
|
|
1395
1423
|
return
|
|
1396
1424
|
}
|
|
1425
|
+
guard allowUrlScheme(url, call: call, method: "setChannelUrl") else {
|
|
1426
|
+
return
|
|
1427
|
+
}
|
|
1397
1428
|
self.implementation.channelUrl = url
|
|
1398
1429
|
if persistModifyUrl {
|
|
1399
1430
|
UserDefaults.standard.set(url, forKey: channelUrlDefaultsKey)
|
|
@@ -4803,6 +4834,18 @@ public class CapacitorUpdaterPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
4803
4834
|
)
|
|
4804
4835
|
return
|
|
4805
4836
|
}
|
|
4837
|
+
// builtinMinimum also covers an already-downloaded bundle reused without a new download.
|
|
4838
|
+
do {
|
|
4839
|
+
try self.implementation.requireVersionNotBelowBuiltin(latestVersionName)
|
|
4840
|
+
} catch {
|
|
4841
|
+
self.endBackGroundTaskWithNotif(
|
|
4842
|
+
msg: error.localizedDescription,
|
|
4843
|
+
latestVersionName: latestVersionName,
|
|
4844
|
+
current: current,
|
|
4845
|
+
plannedDirectUpdate: plannedDirectUpdate
|
|
4846
|
+
)
|
|
4847
|
+
return
|
|
4848
|
+
}
|
|
4806
4849
|
var nextImpl = self.implementation.getBundleInfoByVersionName(version: latestVersionName)
|
|
4807
4850
|
let needsDownload = nextImpl.map(Self.shouldRetryDownloadForExistingBundle) ?? true
|
|
4808
4851
|
if needsDownload {
|