expo-constants 58.0.3 → 58.0.4

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,12 @@
10
10
 
11
11
  ### 💡 Others
12
12
 
13
+ ## 58.0.4 — 2026-09-21
14
+
15
+ ### 🎉 New features
16
+
17
+ - Embed the project fingerprint (`app.fingerprint`) in debug builds, next to the embedded app config. ([#49905](https://github.com/expo/expo/pull/49905) by [@vonovak](https://github.com/vonovak))
18
+
13
19
  ## 58.0.3 — 2026-09-16
14
20
 
15
21
  ### 💡 Others
@@ -6,7 +6,7 @@ plugins {
6
6
  apply from: "../scripts/get-app-config-android.gradle"
7
7
 
8
8
  group = 'host.exp.exponent'
9
- version = '58.0.3'
9
+ version = '58.0.4'
10
10
 
11
11
  expoModule {
12
12
  // We can't prebuild the module because we need to apply `get-app-config-android.gradle` script.
@@ -17,6 +17,6 @@ android {
17
17
  namespace "expo.modules.constants"
18
18
  defaultConfig {
19
19
  versionCode 33
20
- versionName "58.0.3"
20
+ versionName "58.0.4"
21
21
  }
22
22
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-constants",
3
- "version": "58.0.3",
3
+ "version": "58.0.4",
4
4
  "description": "Provides system information that remains constant throughout the lifetime of your app.",
5
5
  "keywords": [
6
6
  "constants",
@@ -47,19 +47,20 @@
47
47
  ]
48
48
  },
49
49
  "dependencies": {
50
- "@expo/env": "~2.5.0"
50
+ "@expo/env": "~2.5.0",
51
+ "@expo/require-utils": "^58.0.1"
51
52
  },
52
53
  "devDependencies": {
53
54
  "@types/node": "^22.14.0",
54
55
  "expo-manifests": "58.0.0",
55
56
  "expo-module-scripts": "56.0.3",
56
- "expo-updates": "58.0.5"
57
+ "expo-updates": "58.0.6"
57
58
  },
58
59
  "peerDependencies": {
59
60
  "expo": "*",
60
61
  "react-native": "*"
61
62
  },
62
- "gitHead": "917a61b581baeb852aa4fe331da2c1395d824351",
63
+ "gitHead": "ebb1fd7569c9c9e172cb9abd73dfede027c1d674",
63
64
  "scripts": {
64
65
  "build": "expo-build src",
65
66
  "clean": "expo-module clean",
@@ -0,0 +1,110 @@
1
+ // @ts-check
2
+ /// <reference types="node" />
3
+
4
+ const { resolveFrom } = require('@expo/require-utils');
5
+ const fs = require('node:fs');
6
+ const path = require('node:path');
7
+
8
+ const { resolveProjectRoot } = require('./resolveProjectRoot');
9
+
10
+ const FINGERPRINT_FILE_NAME = 'app.fingerprint';
11
+
12
+ /**
13
+ * Write the project fingerprint to `app.fingerprint`, next to `app.config`.
14
+ *
15
+ * The options must match the reader's (`src/project/fingerprint.ts` in expo/expo-agent-cli).
16
+ * Never rejects: the fingerprint is optional metadata, so a failure is warned and the build goes on.
17
+ *
18
+ * @param {string} projectRoot
19
+ * @param {string} destinationDir
20
+ * @param {string | undefined} platform
21
+ * @param {boolean} enabled false for non-debug builds; the stale file is still removed
22
+ * @returns {Promise<string | null>} path of the written file, or null when skipped or failed
23
+ */
24
+ async function createFingerprintFileAsync(projectRoot, destinationDir, platform, enabled) {
25
+ try {
26
+ return await writeFingerprintFileAsync(projectRoot, destinationDir, platform, enabled);
27
+ } catch (error) {
28
+ warnFingerprintEmbedFailed(/** @type {Error} */ (error));
29
+ return null;
30
+ }
31
+ }
32
+
33
+ /** @type {typeof createFingerprintFileAsync} */
34
+ async function writeFingerprintFileAsync(projectRoot, destinationDir, platform, enabled) {
35
+ // No platform means the caller is not managing fingerprints — `@expo/cli`'s rebundle path asks
36
+ // for the app config alone — and clearing the file would strip it out of an app already built.
37
+ if (platform === undefined) {
38
+ return null;
39
+ }
40
+
41
+ // Cleared before the opt-out tests, not after: the iOS destination directory persists across
42
+ // builds, so a release build or an opted-out one has to remove what a debug build left.
43
+ const filePath = path.join(destinationDir, FINGERPRINT_FILE_NAME);
44
+ await fs.promises.rm(filePath, { force: true });
45
+
46
+ const skip =
47
+ !enabled || isFingerprintEmbeddingDisabled() || (platform !== 'ios' && platform !== 'android');
48
+ if (skip) {
49
+ return null;
50
+ }
51
+
52
+ // From the project root: a module-relative require could load another copy in a hoisted monorepo.
53
+ const fingerprintPath = resolveFrom(projectRoot, 'expo/fingerprint');
54
+ if (!fingerprintPath) {
55
+ return null;
56
+ }
57
+ const Fingerprint = require(fingerprintPath);
58
+
59
+ const fingerprint = await Fingerprint.createFingerprintAsync(projectRoot, {
60
+ platforms: [platform],
61
+ silent: true,
62
+ });
63
+ if (!fingerprint?.hash) {
64
+ return null;
65
+ }
66
+
67
+ const contents = { ...fingerprint, fingerprintVersion: readFingerprintVersion(fingerprintPath) };
68
+ await fs.promises.writeFile(filePath, JSON.stringify(contents));
69
+ return filePath;
70
+ }
71
+
72
+ /** @param {string} fingerprintPath */
73
+ function readFingerprintVersion(fingerprintPath) {
74
+ const packagePath = resolveFrom(path.dirname(fingerprintPath), '@expo/fingerprint/package.json');
75
+ if (!packagePath) {
76
+ return null;
77
+ }
78
+ try {
79
+ return require(packagePath).version ?? null;
80
+ } catch {
81
+ return null;
82
+ }
83
+ }
84
+
85
+ function isFingerprintEmbeddingDisabled() {
86
+ const value = process.env.EXPO_SKIP_FINGERPRINT_EMBED;
87
+ return value != null && !['0', 'false', ''].includes(value.toLowerCase());
88
+ }
89
+
90
+ /** @param {Error} error */
91
+ function warnFingerprintEmbedFailed(error) {
92
+ console.warn(
93
+ `Could not embed the project fingerprint (app.fingerprint): ${error.message}. ` +
94
+ `The build continues normally, but \`npx @expo/agent-cli status --explain\` cannot tell whether this build matches the project until a build with an embedded fingerprint succeeds.`
95
+ );
96
+ }
97
+
98
+ module.exports = {
99
+ createFingerprintFileAsync,
100
+ FINGERPRINT_FILE_NAME,
101
+ };
102
+
103
+ // Direct invocation from the Android build, whose task only exists for debuggable variants — hence
104
+ // the hardcoded `enabled`.
105
+ if (require.main === module) {
106
+ (async () => {
107
+ const projectRoot = resolveProjectRoot(process.argv[2] ?? process.cwd());
108
+ await createFingerprintFileAsync(projectRoot, process.argv[3], process.argv[4], true);
109
+ })();
110
+ }
@@ -37,13 +37,47 @@ afterEvaluate {
37
37
  // Switch to project root and generate the app config
38
38
  workingDir projectRoot
39
39
 
40
+ // The last argument turns the fingerprint embed off here: the task below owns it.
40
41
  if (Os.isFamily(Os.FAMILY_WINDOWS)) {
41
- commandLine("cmd", "/c", *nodeExecutableAndArgs, "$expoConstantsDir/scripts/getAppConfig.js", projectRoot, assetsDir)
42
+ commandLine("cmd", "/c", *nodeExecutableAndArgs, "$expoConstantsDir/scripts/getAppConfig.js", projectRoot, assetsDir, "android", "false")
42
43
  } else {
43
- commandLine(*nodeExecutableAndArgs, "$expoConstantsDir/scripts/getAppConfig.js", projectRoot, assetsDir)
44
+ commandLine(*nodeExecutableAndArgs, "$expoConstantsDir/scripts/getAppConfig.js", projectRoot, assetsDir, "android", "false")
44
45
  }
45
46
  }
46
47
 
47
48
  // Generate app.config at preBuild
48
49
  tasks.getByName('preBuild').dependsOn(currentCreateConfigTask)
50
+
51
+ def fingerprintAssetsDir = file("$buildDir/generated/assets/expo-constants-fingerprint")
52
+
53
+ // A second task because `createExpoConfig` publishes to `sourceSets.main` off the single
54
+ // `preBuild`, so its output reaches release too. The fingerprint must not.
55
+ def createFingerprintTask = tasks.register('createExpoFingerprint', Exec) {
56
+ description = 'expo-constants: Embed the project fingerprint (app.fingerprint) in debug builds.'
57
+
58
+ doFirst {
59
+ fingerprintAssetsDir.deleteDir()
60
+ fingerprintAssetsDir.mkdirs()
61
+ }
62
+
63
+ // The fingerprint hashes sources across the whole project, so always regenerate it
64
+ outputs.upToDateWhen { false }
65
+ outputs.dir fingerprintAssetsDir
66
+
67
+ workingDir projectRoot
68
+
69
+ if (Os.isFamily(Os.FAMILY_WINDOWS)) {
70
+ commandLine("cmd", "/c", *nodeExecutableAndArgs, "$expoConstantsDir/scripts/createFingerprintFile.js", projectRoot, fingerprintAssetsDir, "android")
71
+ } else {
72
+ commandLine(*nodeExecutableAndArgs, "$expoConstantsDir/scripts/createFingerprintFile.js", projectRoot, fingerprintAssetsDir, "android")
73
+ }
74
+ }
75
+
76
+ project.android.libraryVariants.all { variant ->
77
+ if (!variant.buildType.debuggable) {
78
+ return
79
+ }
80
+ variant.preBuildProvider.configure { it.dependsOn(createFingerprintTask) }
81
+ project.android.sourceSets.maybeCreate(variant.buildType.name).assets.srcDirs += fingerprintAssetsDir
82
+ }
49
83
  }
@@ -32,4 +32,8 @@ else
32
32
  exit 1
33
33
  fi
34
34
 
35
- "${EXPO_CONSTANTS_PACKAGE_DIR}/scripts/with-node.sh" "${EXPO_CONSTANTS_PACKAGE_DIR}/scripts/getAppConfig.js" "$PROJECT_ROOT" "$RESOURCE_DEST"
35
+ # Debug builds only, by the same configuration test expo-updates uses. The `|| echo` keeps a
36
+ # release build from tripping `set -e`.
37
+ EMBED_FINGERPRINT=$([[ "$CONFIGURATION" == *Debug* ]] && echo true || echo false)
38
+
39
+ "${EXPO_CONSTANTS_PACKAGE_DIR}/scripts/with-node.sh" "${EXPO_CONSTANTS_PACKAGE_DIR}/scripts/getAppConfig.js" "$PROJECT_ROOT" "$RESOURCE_DEST" "ios" "$EMBED_FINGERPRINT"
@@ -5,29 +5,29 @@ const { getConfig } = require('expo/config');
5
5
  const fs = require('node:fs');
6
6
  const path = require('node:path');
7
7
 
8
+ const { createFingerprintFileAsync } = require('./createFingerprintFile');
9
+ const { resolveProjectRoot } = require('./resolveProjectRoot');
10
+
8
11
  const cwd = process.cwd();
9
12
  const possibleProjectRoot = process.argv[2] ?? cwd;
10
13
  const destinationDir = process.argv[3] ?? cwd;
14
+ const platform = process.argv[4];
15
+ // The native build scripts pass 'true' for debug builds only.
16
+ const embedFingerprint = process.argv[5] === 'true';
17
+
18
+ (async () => {
19
+ const projectRoot = resolveProjectRoot(possibleProjectRoot);
20
+
21
+ require('@expo/env').load(projectRoot);
22
+ process.chdir(projectRoot);
23
+
24
+ const { exp } = getConfig(projectRoot, {
25
+ isPublicConfig: true,
26
+ skipSDKVersionRequirement: true,
27
+ });
28
+
29
+ fs.writeFileSync(path.join(destinationDir, 'app.config'), JSON.stringify(exp));
11
30
 
12
- // TODO: Verify we can remove projectRoot validation, now that we no longer
13
- // support React Native <= 62
14
- let projectRoot;
15
- if (fs.existsSync(path.join(possibleProjectRoot, 'package.json'))) {
16
- projectRoot = possibleProjectRoot;
17
- } else if (fs.existsSync(path.join(possibleProjectRoot, '..', 'package.json'))) {
18
- projectRoot = path.resolve(possibleProjectRoot, '..');
19
- } else {
20
- throw new Error(
21
- `Unable to locate project (no package.json found) at path: ${possibleProjectRoot}`
22
- );
23
- }
24
-
25
- require('@expo/env').load(projectRoot);
26
- process.chdir(projectRoot);
27
-
28
- const { exp } = getConfig(projectRoot, {
29
- isPublicConfig: true,
30
- skipSDKVersionRequirement: true,
31
- });
32
-
33
- fs.writeFileSync(path.join(destinationDir, 'app.config'), JSON.stringify(exp));
31
+ // Only the fingerprint is optional. A failure above this line must still fail the build.
32
+ await createFingerprintFileAsync(projectRoot, destinationDir, platform, embedFingerprint);
33
+ })();
@@ -0,0 +1,32 @@
1
+ // @ts-check
2
+ /// <reference types="node" />
3
+
4
+ const fs = require('node:fs');
5
+ const path = require('node:path');
6
+
7
+ // TODO: Verify we can remove projectRoot validation, now that we no longer
8
+ // support React Native <= 62
9
+ /**
10
+ * Resolve the app root from the app directory or from `<project>/android`, which is what gradle
11
+ * passes as `rootProject.projectDir`.
12
+ *
13
+ * @param {string} possibleProjectRoot
14
+ * @returns {string}
15
+ */
16
+ function resolveProjectRoot(possibleProjectRoot) {
17
+ const resolvedProjectRoot = path.resolve(possibleProjectRoot);
18
+ if (fs.existsSync(path.join(resolvedProjectRoot, 'package.json'))) {
19
+ return resolvedProjectRoot;
20
+ }
21
+
22
+ const parentProjectRoot = path.dirname(resolvedProjectRoot);
23
+ if (fs.existsSync(path.join(parentProjectRoot, 'package.json'))) {
24
+ return parentProjectRoot;
25
+ }
26
+
27
+ throw new Error(
28
+ `Unable to locate project (no package.json found) at path: ${possibleProjectRoot}`
29
+ );
30
+ }
31
+
32
+ module.exports = { resolveProjectRoot };