@capgo/capacitor-updater 8.54.1 → 8.54.2

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
@@ -212,9 +212,11 @@ npm install @capgo/capacitor-updater@lts-v5
212
212
  npm install @capgo/capacitor-updater@lts-v4
213
213
  ```
214
214
 
215
- ### Android: keep web assets uncompressed
215
+ ### Android: builtin hash table and compressed assets
216
216
 
217
- On `npx cap copy`, the plugin writes `ota-builtin-hashes.json` next to your web assets so the native code can reuse builtin files without hashing them. On Android the size check uses `AssetManager.openFd()`, which cannot open compressed assets, so compressed files silently fall back to full hashing. To get the fast path, keep web asset extensions uncompressed in `android/app/build.gradle`:
217
+ On `npx cap copy`, the plugin writes `ota-builtin-hashes.json` next to your web assets so the native code can reuse builtin files without hashing them. On Android each sized row checks that the asset's uncompressed length still matches the manifest before trusting the stored SHA-256 (same integrity model as iOS file size checks). `AssetManager.openFd()` only works for uncompressed APK assets; when it fails, the plugin reads the uncompressed length via `AssetManager.open()` instead, so the fast path works for default aapt-compressed web bundles (`.js`, `.css`, `.html`, and similar) without `noCompress`.
218
+
219
+ Optional: listing extensions in `androidResources { noCompress += [...] }` avoids opening a stream for the length check on those files, but increases installed APK size. Without it, updates still verify every builtin file by checksum when the table cannot answer.
218
220
 
219
221
  ```groovy
220
222
  android {
@@ -224,8 +226,6 @@ android {
224
226
  }
225
227
  ```
226
228
 
227
- This only affects speed: without it, updates still verify every builtin file by checksum.
228
-
229
229
  ## Auto-update setup
230
230
 
231
231
  Create your account in [capgo.app](https://capgo.app) and get your [API key](https://console.capgo.app/dashboard/apikeys)
@@ -574,6 +574,21 @@ public class DownloadService extends Worker {
574
574
  static long builtinAssetLength(final AssetManager assets, final String assetPath) throws IOException {
575
575
  try (android.content.res.AssetFileDescriptor afd = assets.openFd(assetPath)) {
576
576
  return afd.getLength();
577
+ } catch (IOException openFdFailed) {
578
+ // Compressed APK assets cannot use openFd(); length is still the uncompressed byte count.
579
+ try (InputStream in = assets.open(assetPath)) {
580
+ final long fromAvailable = in.available();
581
+ if (fromAvailable > 0) {
582
+ return fromAvailable;
583
+ }
584
+ long total = 0;
585
+ final byte[] buffer = new byte[CryptoCipher.ioBufferBytes()];
586
+ int read;
587
+ while ((read = in.read(buffer)) != -1) {
588
+ total += read;
589
+ }
590
+ return total;
591
+ }
577
592
  }
578
593
  }
579
594
 
@@ -95,7 +95,7 @@ public class CapacitorUpdaterPlugin: CAPPlugin, CAPBridgedPlugin {
95
95
  deinit {
96
96
  implementation.shutdown()
97
97
  }
98
- private let pluginVersion: String = "8.54.1"
98
+ private let pluginVersion: String = "8.54.2"
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"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/capacitor-updater",
3
- "version": "8.54.1",
3
+ "version": "8.54.2",
4
4
  "license": "MPL-2.0",
5
5
  "description": "Live update for capacitor apps",
6
6
  "main": "dist/plugin.cjs.js",
@@ -6,7 +6,7 @@ import { resolveRealPath } from './resolve-real-path.mjs';
6
6
 
7
7
  export const BUILTIN_HASHES_FILE_NAME = 'ota-builtin-hashes.json';
8
8
 
9
- /** Android apps should list web asset extensions in aapt noCompress so sized rows can use openFd length checks. */
9
+ /** On Android, sized manifest rows compare against uncompressed asset length (openFd when stored uncompressed, otherwise InputStream). */
10
10
 
11
11
  export function sha256File(file) {
12
12
  const hash = createHash('sha256');