expo-updates 57.0.21 → 57.0.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/CHANGELOG.md CHANGED
@@ -10,6 +10,17 @@
10
10
 
11
11
  ### 💡 Others
12
12
 
13
+ ## 57.0.23 — 2026-09-18
14
+
15
+ ### 🐛 Bug fixes
16
+
17
+ - [iOS] Apply bundle diffs against the embedded bundle in the app binary when the launched update is the embedded one, instead of failing to resolve a patch base and downloading the full bundle. ([#50018](https://github.com/expo/expo/pull/50018) by [@alanjhughes](https://github.com/alanjhughes))
18
+ - [Android] Apply bundle diffs against the embedded bundle in the app binary when the launched update is the embedded one, instead of failing to resolve a patch base and downloading the full bundle. ([#50019](https://github.com/expo/expo/pull/50019) by [@alanjhughes](https://github.com/alanjhughes))
19
+
20
+ ## 57.0.22 — 2026-09-11
21
+
22
+ _This version does not introduce any user-facing changes._
23
+
13
24
  ## 57.0.21 — 2026-09-01
14
25
 
15
26
  _This version does not introduce any user-facing changes._
@@ -42,7 +42,7 @@ expoModule {
42
42
  }
43
43
 
44
44
  group = 'host.exp.exponent'
45
- version = '57.0.21'
45
+ version = '57.0.23'
46
46
 
47
47
  // Utility method to derive boolean values from the environment or from Java properties,
48
48
  // and return them as strings to be used in BuildConfig fields
@@ -94,7 +94,7 @@ android {
94
94
  namespace "expo.modules.updates"
95
95
  defaultConfig {
96
96
  versionCode 31
97
- versionName '57.0.21'
97
+ versionName '57.0.23'
98
98
  consumerProguardFiles("proguard-rules.pro")
99
99
  testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
100
100
 
@@ -22,6 +22,7 @@ import expo.modules.updates.manifest.ResponsePartHeaderData
22
22
  import expo.modules.updates.manifest.ResponsePartInfo
23
23
  import expo.modules.updates.manifest.UpdateFactory
24
24
  import expo.modules.updates.selectionpolicy.SelectionPolicies
25
+ import expo.modules.updates.utils.AndroidResourceAssetUtils
25
26
  import kotlinx.coroutines.suspendCancellableCoroutine
26
27
  import okhttp3.Cache
27
28
  import okhttp3.Headers
@@ -50,6 +51,7 @@ import kotlin.math.min
50
51
 
51
52
  private const val PATCH_TEMP_SUFFIX = ".patch"
52
53
  private const val PATCHED_TEMP_SUFFIX = ".patched"
54
+ private const val PATCH_BASE_TEMP_SUFFIX = ".base"
53
55
  private const val A_IM_HEADER = "A-IM"
54
56
  private const val IM_HEADER = "im"
55
57
  private const val EXPO_BASE_UPDATE_ID_RESPONSE_HEADER = "expo-base-update-id"
@@ -57,6 +59,8 @@ private const val EXPO_CURRENT_UPDATE_ID_HEADER = "Expo-Current-Update-ID"
57
59
  private const val EXPO_REQUESTED_UPDATE_ID_HEADER = "Expo-Requested-Update-ID"
58
60
  private const val EXPO_EMBEDDED_UPDATE_ID_HEADER = "Expo-Embedded-Update-ID"
59
61
 
62
+ internal typealias EmbeddedAssetExtractor = (AssetEntity, File) -> Unit
63
+
60
64
  /**
61
65
  * Utility class that holds all the logic for downloading data and files, such as update manifests
62
66
  * and assets, using an instance of [OkHttpClient].
@@ -106,7 +110,8 @@ class FileDownloader(
106
110
  progressListener: FileDownloadProgressListener? = null,
107
111
  allowPatch: Boolean,
108
112
  launchedUpdate: UpdateEntity? = null,
109
- requestedUpdate: UpdateEntity? = null
113
+ requestedUpdate: UpdateEntity? = null,
114
+ embeddedAssetExtractor: EmbeddedAssetExtractor? = null
110
115
  ): FileDownloadResult {
111
116
  try {
112
117
  val response = downloadData(request, progressListener)
@@ -175,7 +180,8 @@ class FileDownloader(
175
180
  updatesDirectory = updatesDirectory,
176
181
  launchedUpdate = launchedUpdate,
177
182
  requestedUpdate = requestedUpdate,
178
- expectedBase64URLEncodedSHA256Hash = expectedBase64URLEncodedSHA256Hash
183
+ expectedBase64URLEncodedSHA256Hash = expectedBase64URLEncodedSHA256Hash,
184
+ embeddedAssetExtractor = embeddedAssetExtractor
179
185
  )
180
186
  }.getOrElse {
181
187
  logger.warn(
@@ -293,36 +299,47 @@ class FileDownloader(
293
299
  updatesDirectory: File,
294
300
  launchedUpdate: UpdateEntity,
295
301
  requestedUpdate: UpdateEntity?,
296
- expectedBase64URLEncodedSHA256Hash: String?
302
+ expectedBase64URLEncodedSHA256Hash: String?,
303
+ embeddedAssetExtractor: EmbeddedAssetExtractor? = null
297
304
  ): ByteArray {
298
305
  val launchAssetContext = prepareAssetForDiff(
299
306
  asset = asset,
300
307
  responseBody = responseBody,
308
+ destination = destination,
301
309
  updatesDirectory = updatesDirectory,
302
- launchedUpdate = launchedUpdate
310
+ launchedUpdate = launchedUpdate,
311
+ embeddedAssetExtractor = embeddedAssetExtractor
303
312
  )
304
313
 
305
- return applyHermesDiff(
306
- baseFile = launchAssetContext.baseFile,
307
- diffBody = responseBody,
308
- destination = destination,
309
- expectedBase64URLEncodedSHA256Hash = expectedBase64URLEncodedSHA256Hash,
310
- asset = asset,
311
- requestedUpdateId = requestedUpdate?.id?.toString()
312
- )
314
+ try {
315
+ return applyHermesDiff(
316
+ baseFile = launchAssetContext.baseFile,
317
+ diffBody = responseBody,
318
+ destination = destination,
319
+ expectedBase64URLEncodedSHA256Hash = expectedBase64URLEncodedSHA256Hash,
320
+ asset = asset,
321
+ requestedUpdateId = requestedUpdate?.id?.toString()
322
+ )
323
+ } finally {
324
+ if (launchAssetContext.isTemporary) {
325
+ launchAssetContext.baseFile.delete()
326
+ }
327
+ }
313
328
  }
314
329
 
315
- internal data class LaunchAssetContext(val baseFile: File)
330
+ internal data class LaunchAssetContext(val baseFile: File, val isTemporary: Boolean = false)
316
331
 
317
332
  @VisibleForTesting
318
333
  internal fun prepareAssetForDiff(
319
334
  asset: AssetEntity,
320
335
  responseBody: ResponseBody,
336
+ destination: File,
321
337
  updatesDirectory: File,
322
- launchedUpdate: UpdateEntity
338
+ launchedUpdate: UpdateEntity,
339
+ embeddedAssetExtractor: EmbeddedAssetExtractor? = null
323
340
  ): LaunchAssetContext {
324
341
  return try {
325
- preparePatchBaseAsset(asset, updatesDirectory, launchedUpdate)
342
+ preparePatchBaseAsset(asset, destination, updatesDirectory, launchedUpdate, embeddedAssetExtractor)
326
343
  } catch (e: Exception) {
327
344
  responseBody.close()
328
345
  if (e is IOException) {
@@ -335,8 +352,10 @@ class FileDownloader(
335
352
 
336
353
  private fun preparePatchBaseAsset(
337
354
  asset: AssetEntity,
355
+ destination: File,
338
356
  updatesDirectory: File,
339
- launchedUpdate: UpdateEntity
357
+ launchedUpdate: UpdateEntity,
358
+ embeddedAssetExtractor: EmbeddedAssetExtractor? = null
340
359
  ): LaunchAssetContext {
341
360
  if (!asset.isLaunchAsset) {
342
361
  throw IOException("Received patch for non-launch asset ${asset.key}")
@@ -350,29 +369,60 @@ class FileDownloader(
350
369
  val launchAssetRelativePath = launchAssetEntity.relativePath
351
370
  ?: throw IOException("Launch asset for update $currentUpdateId is missing a relative path")
352
371
 
353
- val baseFile = File(updatesDirectory, launchAssetRelativePath)
372
+ // BSPatch needs a real path, so an asset inside the APK is extracted first.
373
+ val isEmbeddedLaunchAsset = AndroidResourceAssetUtils.isAndroidResourceAsset(launchAssetRelativePath)
374
+ val baseFile = if (isEmbeddedLaunchAsset) {
375
+ extractEmbeddedPatchBaseAsset(launchAssetEntity, destination, embeddedAssetExtractor)
376
+ } else {
377
+ File(updatesDirectory, launchAssetRelativePath)
378
+ }
354
379
  if (!baseFile.exists()) {
355
380
  throw IOException("Base asset $baseFile is missing; cannot apply patch")
356
381
  }
357
382
 
358
- val actualBaseHash = try {
359
- UpdatesUtils.toBase64Url(UpdatesUtils.sha256(baseFile))
360
- } catch (_: Exception) {
361
- null
383
+ val expectedBaseHash = launchAssetEntity.expectedHash
384
+ if (expectedBaseHash != null) {
385
+ val actualBaseHash = try {
386
+ UpdatesUtils.toBase64Url(UpdatesUtils.sha256(baseFile))
387
+ } catch (_: Exception) {
388
+ null
389
+ }
390
+ if (actualBaseHash != null && expectedBaseHash != actualBaseHash) {
391
+ logger.warn(
392
+ "Asset hash mismatch for update $currentUpdateId; expected=$expectedBaseHash actual=$actualBaseHash",
393
+ UpdatesErrorCode.AssetsFailedToLoad,
394
+ currentUpdateId.toString(),
395
+ asset.key
396
+ )
397
+ if (isEmbeddedLaunchAsset) {
398
+ baseFile.delete()
399
+ }
400
+ throw IOException("Asset hash mismatch for update $currentUpdateId; expected=$expectedBaseHash actual=$actualBaseHash")
401
+ }
362
402
  }
363
403
 
364
- val expectedBaseHash = launchAssetEntity.expectedHash
365
- if (expectedBaseHash != null && actualBaseHash != null && expectedBaseHash != actualBaseHash) {
366
- logger.warn(
367
- "Asset hash mismatch for update $currentUpdateId; expected=$expectedBaseHash actual=$actualBaseHash",
368
- UpdatesErrorCode.AssetsFailedToLoad,
369
- currentUpdateId.toString(),
370
- asset.key
371
- )
372
- throw IOException("Asset hash mismatch for update $currentUpdateId; expected=$expectedBaseHash actual=$actualBaseHash")
404
+ return LaunchAssetContext(baseFile, isTemporary = isEmbeddedLaunchAsset)
405
+ }
406
+
407
+ @Throws(IOException::class)
408
+ private fun extractEmbeddedPatchBaseAsset(
409
+ launchAssetEntity: AssetEntity,
410
+ destination: File,
411
+ embeddedAssetExtractor: EmbeddedAssetExtractor?
412
+ ): File {
413
+ if (embeddedAssetExtractor == null) {
414
+ throw IOException("The launch asset lives in the app binary and cannot be extracted without an extractor")
373
415
  }
374
416
 
375
- return LaunchAssetContext(baseFile)
417
+ val baseFile = File(destination.absolutePath + PATCH_BASE_TEMP_SUFFIX)
418
+ try {
419
+ baseFile.parentFile?.mkdirs()
420
+ embeddedAssetExtractor(launchAssetEntity, baseFile)
421
+ } catch (e: Exception) {
422
+ baseFile.delete()
423
+ throw e as? IOException ?: IOException("Failed to extract the embedded launch asset", e)
424
+ }
425
+ return baseFile
376
426
  }
377
427
 
378
428
  @VisibleForTesting
@@ -677,7 +727,8 @@ class FileDownloader(
677
727
  extraHeaders: JSONObject,
678
728
  launchedUpdate: UpdateEntity?,
679
729
  requestedUpdate: UpdateEntity?,
680
- assetLoadProgressListener: ((Double) -> Unit)? = null
730
+ assetLoadProgressListener: ((Double) -> Unit)? = null,
731
+ embeddedAssetExtractor: EmbeddedAssetExtractor? = null
681
732
  ): AssetDownloadResult {
682
733
  if (asset.url == null) {
683
734
  val message = "Failed to download asset ${asset.key}"
@@ -721,7 +772,8 @@ class FileDownloader(
721
772
  assetLoadProgressListener?.let { listener -> { listener.invoke(it) } },
722
773
  allowPatch = canApplyPatch,
723
774
  launchedUpdate = launchedUpdate,
724
- requestedUpdate = requestedUpdate
775
+ requestedUpdate = requestedUpdate,
776
+ embeddedAssetExtractor = embeddedAssetExtractor
725
777
  )
726
778
 
727
779
  asset.downloadTime = Date()
@@ -14,6 +14,7 @@ import kotlinx.coroutines.CoroutineScope
14
14
  import kotlinx.coroutines.Dispatchers
15
15
  import kotlinx.coroutines.SupervisorJob
16
16
  import java.io.File
17
+ import java.io.IOException
17
18
 
18
19
  data class ProcessSuccessLoaderResult(
19
20
  val availableUpdate: UpdateEntity?,
@@ -66,9 +67,28 @@ class RemoteLoader internal constructor(
66
67
  embeddedUpdate: UpdateEntity?
67
68
  ): FileDownloader.AssetDownloadResult {
68
69
  val extraHeaders = FileDownloader.getExtraHeadersForRemoteAssetRequest(launchedUpdate, embeddedUpdate, requestedUpdate)
69
- return mFileDownloader.downloadAsset(assetEntity, updatesDirectory, extraHeaders, launchedUpdate, requestedUpdate) { progress ->
70
- assetLoadProgressListener(assetEntity, progress)
71
- }
70
+ return mFileDownloader.downloadAsset(
71
+ asset = assetEntity,
72
+ destinationDirectory = updatesDirectory,
73
+ extraHeaders = extraHeaders,
74
+ launchedUpdate = launchedUpdate,
75
+ requestedUpdate = requestedUpdate,
76
+ embeddedAssetExtractor = { launchAsset, destination ->
77
+ // The stored path is not the APK asset name; resolve it through the embedded manifest by key.
78
+ val embeddedLaunchAsset = loaderFiles.readEmbeddedUpdate(context, configuration)
79
+ ?.assetEntityList
80
+ ?.find { it.key == launchAsset.key }
81
+ ?: throw IOException("No embedded asset matches launch asset ${launchAsset.key}")
82
+ val assetName = embeddedLaunchAsset.embeddedAssetFilename
83
+ ?: throw IOException("Embedded launch asset ${launchAsset.key} has no APK asset filename")
84
+ context.assets.open(assetName).use { input ->
85
+ destination.outputStream().use { output -> input.copyTo(output) }
86
+ }
87
+ },
88
+ assetLoadProgressListener = { progress ->
89
+ assetLoadProgressListener(assetEntity, progress)
90
+ }
91
+ )
72
92
  }
73
93
 
74
94
  companion object {
@@ -84,6 +84,12 @@ public final class FileDownloader {
84
84
  private let updatesDirectory: URL
85
85
  private let database: UpdatesDatabase
86
86
 
87
+ /// Overridable for testing, where the fixture is not in `updatesBundle`.
88
+ internal var embeddedLaunchAssetUrl: URL? = updatesBundle.url(
89
+ forResource: EmbeddedAppLoader.EXUpdatesBareEmbeddedBundleFilename,
90
+ withExtension: EmbeddedAppLoader.EXUpdatesBareEmbeddedBundleFileType
91
+ )
92
+
87
93
  public convenience init(
88
94
  config: UpdatesConfig,
89
95
  logger: UpdatesLogger,
@@ -558,8 +564,7 @@ public final class FileDownloader {
558
564
  throw DiffError.assetNotLaunch
559
565
  }
560
566
 
561
- let baseAsset = try resolveLaunchAsset(launchedUpdate: launchedUpdate)
562
- let baseFileUrl = try loadAndVerifyAsset(baseAsset)
567
+ let baseFileUrl = try resolveBaseFileUrl(launchedUpdate: launchedUpdate)
563
568
  let requestedUpdateId = requestedUpdate?.updateId.uuidString
564
569
 
565
570
  return try createPatchedAsset(
@@ -572,6 +577,19 @@ public final class FileDownloader {
572
577
  )
573
578
  }
574
579
 
580
+ private func resolveBaseFileUrl(launchedUpdate: Update) throws -> URL {
581
+ if launchedUpdate.status == UpdateStatus.StatusEmbedded {
582
+ // StatusEmbedded only launches for this binary's embedded update.
583
+ guard let embeddedLaunchAssetUrl else {
584
+ throw DiffError.embeddedBaseAssetMissing
585
+ }
586
+ return embeddedLaunchAssetUrl
587
+ }
588
+
589
+ let baseAsset = try resolveLaunchAsset(launchedUpdate: launchedUpdate)
590
+ return try loadAndVerifyAsset(baseAsset)
591
+ }
592
+
575
593
  private func resolveLaunchAsset(launchedUpdate: Update) throws -> UpdateAsset {
576
594
  let currentUpdateId = launchedUpdate.updateId
577
595
  var launchAsset: UpdateAsset?
@@ -1239,6 +1257,7 @@ extension FileDownloader {
1239
1257
  case missingHeader(String)
1240
1258
  case invalidHeader(String)
1241
1259
  case launchAssetNotFound
1260
+ case embeddedBaseAssetMissing
1242
1261
  case baseAssetMissing(path: String)
1243
1262
  case failedToReadBaseAsset(cause: Error)
1244
1263
  case failedToWritePatch(cause: Error, path: String)
@@ -1266,6 +1285,8 @@ extension FileDownloader.DiffError: CustomStringConvertible {
1266
1285
  return "Invalid \(header) header"
1267
1286
  case .launchAssetNotFound:
1268
1287
  return "Launch asset not found for current update"
1288
+ case .embeddedBaseAssetMissing:
1289
+ return "Embedded bundle not found in the app binary"
1269
1290
  case let .baseAssetMissing(path):
1270
1291
  return "Base asset is missing at path \(path)"
1271
1292
  case let .failedToReadBaseAsset(cause):
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-updates",
3
- "version": "57.0.21",
3
+ "version": "57.0.23",
4
4
  "description": "Fetches and manages remotely-hosted assets and updates to your app's JS bundle.",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -34,10 +34,10 @@
34
34
  "arg": "^4.1.0",
35
35
  "chalk": "^4.1.2",
36
36
  "debug": "^4.3.4",
37
- "expo-eas-client": "~57.0.3",
38
- "expo-manifests": "~57.0.1",
39
- "expo-structured-headers": "~57.0.0",
40
- "expo-updates-interface": "~57.0.1",
37
+ "expo-eas-client": "~57.0.4",
38
+ "expo-manifests": "~57.0.2",
39
+ "expo-structured-headers": "~57.0.1",
40
+ "expo-updates-interface": "~57.0.2",
41
41
  "getenv": "^2.0.0",
42
42
  "glob": "^13.0.0",
43
43
  "ignore": "^5.3.1",
@@ -60,10 +60,10 @@
60
60
  "picomatch": "^4.0.4",
61
61
  "ts-node": "^10.9.2",
62
62
  "xstate": "^4.37.2",
63
- "expo-dev-client": "57.0.18",
64
63
  "@expo/metro-config": "57.0.12",
65
64
  "expo-module-scripts": "56.0.3",
66
- "expo": "57.0.19"
65
+ "expo-dev-client": "57.0.19",
66
+ "expo": "57.0.24"
67
67
  },
68
68
  "peerDependencies": {
69
69
  "expo": "*",
@@ -82,7 +82,7 @@
82
82
  "./scripts/with-node.sh"
83
83
  ]
84
84
  },
85
- "gitHead": "730ffa946ce69c22d3be128d4bf48c4ea579261e",
85
+ "gitHead": "7687b07947a5c866adeb11abbceae72403ccb188",
86
86
  "scripts": {
87
87
  "build": "expo-module build",
88
88
  "clean": "expo-module clean",