store-preflight
Catch App Store and Play rejections and EAS config drift in an Expo app before you build. MIT licence.
Run it in an Expo app before eas build or eas update. It catches the things that get an app rejected by App Store or Play review, and the EAS config drift that breaks builds and OTA updates. expo-doctor checks your dependency versions; this checks everything else.
Source: github.com/davidewins/store-preflight. Needs Node 20 or later.
Run it
npx github:davidewins/store-preflight # not on npm yet; runs straight from GitHub
npx store-preflight # current folder, production profile
npx store-preflight apps/mobile --profile preview
npx store-preflight --offline # skip the network checks (npm 10 install, EAS env, link domains)
npx store-preflight --json # machine-readable
npx store-preflight --strict # exit 1 on warnings too
npx store-preflight --skip ios.icon,auth.account-deletion # turn off checks by id (ids are in --json output)It evaluates your app config with expo config --type introspect, using the eas.json profile's env and no local .env files, the way an EAS build does. So it sees the real Info.plist and AndroidManifest that plugins generate, not just what's in app.json.
Exit code 1 if anything fails, 2 if the config can't be evaluated.
Checks
App Store
- Permission strings explain why. Empty strings, or Expo's stock "Allow $(PRODUCT_NAME) to access your camera", get rejected under Guideline 5.1.1.
ios.purpose-strings - Export compliance flag. Without
usesNonExemptEncryption, App Store Connect asks the question on every build.ios.encryption - No blanket ATS exception.
NSAllowsArbitraryLoadshas to be justified to review.ios.ats - Privacy manifest. Info only: points at
ios.privacyManifestswhen you get an ITMS-91053 email.ios.privacy-manifest - App icon. 1024x1024, and actually opaque (reads the pixels, not just the PNG type).
ios.icon - Sign in with Apple. Google / Facebook / OAuth login without it fails Guideline 4.8.
auth.apple-signin - Account deletion. Apps with sign-up must offer in-app account deletion (5.1.1(v)). Heuristic: greps your source.
auth.account-deletion
Play
- Permissions that need a Play declaration. Background location, photo/video access, all-files, SMS/call log, full-screen intents, and every Android 14 foreground service type (phone call, camera, microphone, media playback, location ...). Includes permissions that native libraries add at build time (it reads each dependency's
AndroidManifest.xml, whichexpo confignever shows), minusandroid.blockedPermissions. Skipped whenplatformshas no android.android.play-permissions
EAS builds and updates
- Build number bumps. Without
autoIncrement, the second upload with the same build number is rejected.version.build-number - OTA env matches the build.
eas updateignores eas.jsonenv, and local.envfiles leak into the bundle. Compares eas.json, EAS env (eas env:list) and local.env. Values are never printed.env.ota-drift - No unescaped
$in.env. Expo's .env loader expands$NAME, soab$cdsilently becomesablocally while EAS gets the real value.env.dollar - Lockfile installs with npm 10. EAS builders run npm 10. A lockfile written by npm 11 can pass locally and fail EAS's install step. Runs
npm@10 ci --dry-runin a temp copy.lock.npm10 - Skia +
useFrameworks. Skia doesn't compile underuse_frameworks!.build.skia-frameworks - CI generates router types. With
typedRoutes,.expo/types/router.d.tsis gitignored, so CI typechecks against the wrong types.ci.router-types - App links verify. Fetches
assetlinks.jsonandapple-app-site-associationfor your verified domains and checks your package / bundle ID is listed.links.verified-domains - No secrets in eas.json. eas.json is committed. Flags non-
EXPO_PUBLIC_keys named like secrets.secrets.eas-json .envnot committed.git ls-files.git.env-tracked
Not checked (yet)
- Whether the build number is higher than the last one uploaded (needs App Store Connect / Play API access)
- Android SHA-256 fingerprints in
assetlinks.jsonagainst your signing key (needs your credentials) - In-app purchase rules for digital goods (Guideline 3.1.1): too app-specific to guess at
Full source
Every file in the tool, ready to copy.
bin/store-preflight.mjsShowHide
#!/usr/bin/env node
// store-preflight: catch App Store / Play rejections and EAS config drift before you build.
//
// npx store-preflight [dir] [--profile production] [--offline] [--json] [--strict] [--skip id,id]
//
// Exit code 1 if any check fails (or warns, with --strict).
import { resolve } from "node:path";
import { checks } from "../src/checks.mjs";
import { loadContext } from "../src/context.mjs";
const args = process.argv.slice(2);
const flag = (name) => args.includes(name);
const opt = (name) => {
const i = args.indexOf(name);
return i === -1 ? undefined : args[i + 1];
};
const dir = resolve(args.find((a, i) => !a.startsWith("--") && !["--profile", "--skip"].includes(args[i - 1])) ?? ".");
const skipped = new Set(opt("--skip")?.split(",") ?? []);
const options = { profile: opt("--profile") ?? "production", offline: flag("--offline") };
let ctx;
try {
ctx = loadContext(dir, options);
} catch (e) {
console.error(e.message);
process.exit(2);
}
const results = [];
for (const c of checks) {
let r;
if (skipped.has(c.id)) {
results.push({ id: c.id, title: c.title, status: "skip", detail: "skipped with --skip" });
continue;
}
try {
r = await c.run(ctx);
} catch (e) {
r = { status: "fail", detail: `check crashed: ${e.message}` };
}
results.push({ id: c.id, title: c.title, ...r });
}
const failed = results.some((r) => r.status === "fail") || (flag("--strict") && results.some((r) => r.status === "warn"));
if (flag("--json")) {
console.log(JSON.stringify({ dir, profile: options.profile, results }, null, 2));
process.exit(failed ? 1 : 0);
}
const tty = process.stdout.isTTY;
const paint = (code, s) => (tty ? `\x1b[${code}m${s}\x1b[0m` : s);
const mark = { pass: paint(32, "PASS"), info: paint(36, "INFO"), warn: paint(33, "WARN"), fail: paint(31, "FAIL"), skip: paint(90, "SKIP") };
console.log(`store-preflight ${ctx.config.name} (${dir}), profile ${options.profile}\n`);
for (const r of results) {
console.log(`${mark[r.status]} ${r.title}${(r.status === "pass" || r.status === "skip") && r.detail ? paint(90, ` ${r.detail}`) : ""}`);
if (r.status === "skip") continue;
if (r.status !== "pass" && r.detail) console.log(r.detail.replace(/^/gm, " "));
if (r.fix && (r.status === "warn" || r.status === "fail" || r.status === "info")) console.log(paint(90, ` fix: ${r.fix}`));
}
const count = (s) => results.filter((r) => r.status === s).length;
console.log(`\n${count("fail")} fail, ${count("warn")} warn, ${count("info")} info, ${count("pass")} pass, ${count("skip")} skip`);
process.exit(failed ? 1 : 0);src/checks.mjsShowHide
import { spawnSync } from "node:child_process";
import { copyFileSync, existsSync, mkdtempSync, readFileSync, rmSync, statSync } from "node:fs";
import { tmpdir } from "node:os";
import { join, resolve } from "node:path";
import { readPng } from "./util.mjs";
// Each check: { id, title, run(ctx) } -> { status, detail?, fix? }
// status: pass | info | warn | fail | skip
const pass = (detail) => ({ status: "pass", detail });
const skip = (detail) => ({ status: "skip", detail });
const list = (xs) => xs.map((x) => ` - ${x}`).join("\n");
const plugin = (ctx, name) => {
for (const p of ctx.config.plugins ?? []) {
if (p === name) return {};
if (Array.isArray(p) && p[0] === name) return p[1] ?? {};
}
return null;
};
const grepSource = (ctx, re) => {
const hits = [];
for (const f of ctx.sourceFiles()) if (re.test(readFileSync(f, "utf8"))) hits.push(f.slice(ctx.dir.length + 1));
return hits;
};
// EAS-hosted env for one environment as { KEY: value }, or null if eas-cli can't read it.
// Sensitive values come back masked (*****); secret ones are not listed.
function loadEasEnv(dir, environment) {
const r = spawnSync("npx", ["-y", "eas-cli", "env:list", environment, "--format", "short"], {
cwd: dir,
encoding: "utf8",
stdio: ["ignore", "pipe", "pipe"],
timeout: 90000,
env: { ...process.env, EAS_NO_VCS: "1" },
});
if (r.status !== 0) return null;
const env = {};
for (const line of r.stdout.split("\n")) {
const m = line.match(/^([A-Z_][A-Z0-9_]*)=(.*)$/);
if (m) env[m[1]] = m[2];
}
return env;
}
const EXPO_DEFAULT_PURPOSE = /^Allow \$\(PRODUCT_NAME\) to /;
// Play Console asks for a declaration (or rejects) for these unless they are core to the app.
const PLAY_SENSITIVE = {
"android.permission.ACCESS_BACKGROUND_LOCATION": "background location declaration",
"android.permission.READ_MEDIA_IMAGES": "Photo and Video Permissions policy (use the photo picker unless core)",
"android.permission.READ_MEDIA_VIDEO": "Photo and Video Permissions policy (use the photo picker unless core)",
"android.permission.QUERY_ALL_PACKAGES": "package visibility declaration",
"android.permission.MANAGE_EXTERNAL_STORAGE": "All files access declaration",
"android.permission.READ_SMS": "SMS and Call Log policy",
"android.permission.READ_CALL_LOG": "SMS and Call Log policy",
"android.permission.USE_FULL_SCREEN_INTENT": "full-screen intent declaration (granted by default only to calling and alarm apps)",
// Android 14+: every foreground service type needs a Play Console declaration with a video.
"android.permission.FOREGROUND_SERVICE_PHONE_CALL": "foreground service declaration (phone call), with a video",
"android.permission.FOREGROUND_SERVICE_CAMERA": "foreground service declaration (camera), with a video",
"android.permission.FOREGROUND_SERVICE_MICROPHONE": "foreground service declaration (microphone), with a video",
"android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK": "foreground service declaration (media playback), with a video",
"android.permission.FOREGROUND_SERVICE_MEDIA_PROJECTION": "foreground service declaration (media projection), with a video",
"android.permission.FOREGROUND_SERVICE_LOCATION": "foreground service declaration (location), with a video",
"android.permission.FOREGROUND_SERVICE_DATA_SYNC": "foreground service declaration (data sync), with a video",
"android.permission.FOREGROUND_SERVICE_CONNECTED_DEVICE": "foreground service declaration (connected device), with a video",
"android.permission.FOREGROUND_SERVICE_SPECIAL_USE": "foreground service declaration (special use), with a video",
};
export const checks = [
{
id: "ios.purpose-strings",
title: "iOS permission strings explain why",
run(ctx) {
const entries = Object.entries(ctx.infoPlist).filter(([k]) => /^NS.*UsageDescription$/.test(k));
if (!entries.length) return pass("no permissions requested");
const empty = entries.filter(([, v]) => typeof v !== "string" || !v.trim()).map(([k]) => k);
const stock = entries.filter(([, v]) => EXPO_DEFAULT_PURPOSE.test(v)).map(([k, v]) => `${k}: "${v}"`);
if (empty.length) return { status: "fail", detail: `empty purpose strings:\n${list(empty)}`, fix: "Set every string in ios.infoPlist (or the plugin's permission option)." };
if (stock.length)
return {
status: "warn",
detail: `Expo's stock wording, which App Review often rejects under Guideline 5.1.1 for not saying why:\n${list(stock)}`,
fix: "Write a specific reason in ios.infoPlist, or remove the permission if the app never asks for it.",
};
return pass(`${entries.length} strings set`);
},
},
{
id: "ios.encryption",
title: "Export compliance flag set",
run(ctx) {
const v = ctx.infoPlist.ITSAppUsesNonExemptEncryption ?? ctx.config.ios?.config?.usesNonExemptEncryption;
if (v === undefined)
return { status: "warn", detail: "ITSAppUsesNonExemptEncryption is not set, so App Store Connect asks the export compliance question on every build.", fix: 'Set ios.config.usesNonExemptEncryption (false if you only use HTTPS / standard OS crypto).' };
return pass(`set to ${v}`);
},
},
{
id: "ios.ats",
title: "No blanket App Transport Security exception",
run(ctx) {
const ats = ctx.infoPlist.NSAppTransportSecurity ?? {};
if (ats.NSAllowsArbitraryLoads === true)
return { status: "warn", detail: "NSAllowsArbitraryLoads is true: plain HTTP is allowed everywhere. App Review can ask you to justify it.", fix: "Remove it, or replace it with NSExceptionDomains for the specific hosts that need HTTP." };
return pass();
},
},
{
id: "ios.privacy-manifest",
title: "Privacy manifest declared",
run(ctx) {
const pm = ctx.config.ios?.privacyManifests;
if (!pm) return { status: "info", detail: "No ios.privacyManifests in app config. Libraries that ship their own manifest are covered; your app code is not.", fix: "If App Store Connect emails ITMS-91053 about an API, declare it in ios.privacyManifests.NSPrivacyAccessedAPITypes." };
return pass(`${pm.NSPrivacyAccessedAPITypes?.length ?? 0} API types declared`);
},
},
{
id: "ios.icon",
title: "App icon is 1024x1024 and opaque",
run(ctx) {
let icon = ctx.config.ios?.icon ?? ctx.config.icon;
if (icon && typeof icon === "object") icon = icon.light ?? icon.any;
if (!icon) return { status: "fail", detail: "no icon set", fix: "Set icon (or ios.icon) to a 1024x1024 PNG." };
const path = resolve(ctx.dir, icon);
if (!existsSync(path)) return { status: "fail", detail: `icon not found: ${icon}` };
if (statSync(path).isDirectory() || !/\.png$/i.test(path)) return skip(`${icon} is not a PNG (Icon Composer or other format)`);
const png = readPng(path);
const problems = [];
if (png.width !== 1024 || png.height !== 1024) problems.push(`${png.width}x${png.height}, App Store needs 1024x1024`);
if (png.transparent === true) problems.push("has transparent pixels: the App Store icon can't be transparent, so those areas get filled in or the upload is rejected");
if (png.transparent === null) problems.push("has an alpha channel (could not measure whether any pixel is transparent)");
if (problems.length) return { status: "warn", detail: `${icon}:\n${list(problems)}`, fix: "Export the icon as a 1024x1024 PNG with a solid background." };
return pass(`${icon} 1024x1024${png.hasAlpha ? ", alpha channel but fully opaque" : ""}`);
},
},
{
id: "android.play-permissions",
title: "No Android permissions that need a Play declaration",
run(ctx) {
if (ctx.config.platforms && !ctx.config.platforms.includes("android")) return skip("app config platforms has no android");
const from = (p) => (ctx.androidPermissionFrom?.[p] && ctx.androidPermissionFrom[p] !== "app config" ? ` [added by ${ctx.androidPermissionFrom[p]}]` : "");
const hits = ctx.androidPermissions.filter((p) => PLAY_SENSITIVE[p]).map((p) => `${p.replace("android.permission.", "")}: ${PLAY_SENSITIVE[p]}${from(p)}`);
if (hits.length)
return { status: "warn", detail: `Play Console will ask about:\n${list(hits)}`, fix: "Add unused ones to android.blockedPermissions; fill in the Play Console declaration for the rest." };
return pass(`${ctx.androidPermissions.length} permissions, none sensitive`);
},
},
{
id: "auth.apple-signin",
title: "Sign in with Apple offered alongside other social logins",
run(ctx) {
const social = [];
if (ctx.deps["@react-native-google-signin/google-signin"]) social.push("Google (google-signin)");
if (ctx.deps["react-native-fbsdk-next"]) social.push("Facebook (fbsdk)");
const oauth = grepSource(ctx, /provider:\s*['"](google|facebook|github|twitter|discord)['"]/);
if (oauth.length) social.push(`OAuth provider in ${oauth.slice(0, 2).join(", ")}`);
if (!social.length) return skip("no third-party social login found");
const apple = ctx.deps["expo-apple-authentication"] || grepSource(ctx, /provider:\s*['"]apple['"]/).length;
if (apple) return pass(`social login (${social.join("; ")}) with Sign in with Apple`);
return { status: "warn", detail: `Social login found (${social.join("; ")}) but no Sign in with Apple. Guideline 4.8 requires an equivalent privacy-focused login option.`, fix: "Add expo-apple-authentication." };
},
},
{
id: "auth.account-deletion",
title: "In-app account deletion",
run(ctx) {
const auth = ["@supabase/supabase-js", "@react-native-firebase/auth", "firebase", "@clerk/clerk-expo", "@react-native-google-signin/google-signin", "expo-auth-session"].filter((d) => ctx.deps[d]);
if (!auth.length) return skip("no auth library found");
const hits = grepSource(ctx, /delete[\s_-]?(my[\s_-]?)?account|deleteAccount|delete_account|deleteUser|account[\s_-]?deletion/i);
if (hits.length) return pass(`found in ${hits.slice(0, 3).join(", ")}`);
return { status: "warn", detail: `Uses ${auth.join(", ")} but no account deletion code found. Guideline 5.1.1(v) requires apps with sign-up to let users delete their account in the app.`, fix: "Add a delete-account action (Settings > Account) that deletes the account, not just signs out." };
},
},
{
id: "version.build-number",
title: "Build number bumps on every store build",
run(ctx) {
const prof = ctx.eas?.build?.[ctx.options.profile];
if (!prof) return skip(`no "${ctx.options.profile}" profile in eas.json`);
const auto = prof.autoIncrement ?? (prof.extends ? ctx.eas.build[prof.extends]?.autoIncrement : undefined);
if (auto) return pass(`autoIncrement on, version source ${ctx.eas.cli?.appVersionSource ?? "local"}`);
return { status: "warn", detail: "autoIncrement is off: a second build with the same build number is rejected by App Store Connect and Play.", fix: `Set "cli": {"appVersionSource": "remote"} and build.${ctx.options.profile}.autoIncrement: true in eas.json.` };
},
},
{
id: "env.dollar",
title: "No unescaped $ in .env files",
run(ctx) {
const hits = [];
for (const f of ctx.envFiles) for (const r of f.rows) if (/(^|[^\\])\$[A-Za-z_{]/.test(r.value)) hits.push(`${f.name}:${r.line} ${r.key}`);
if (!ctx.envFiles.length) return skip("no .env files");
if (hits.length)
return { status: "fail", detail: `Expo's .env loader expands $NAME, so these values change silently in local builds (EAS env does not):\n${list(hits)}`, fix: "Escape as \\$ in the .env line, then restart Metro with --clear." };
return pass();
},
},
{
id: "env.ota-drift",
title: "OTA updates get the same env as builds",
// A build gets eas.json profile env over EAS env. `eas update` ignores eas.json env, uses EAS env,
// and local .env files leak into the bundle. Values are compared in memory and never printed.
run(ctx) {
if (!ctx.deps["expo-updates"]) return skip("expo-updates not installed");
const pub = (o) => Object.fromEntries(Object.entries(o).filter(([k]) => k.startsWith("EXPO_PUBLIC_")).map(([k, v]) => [k, String(v)]));
const easJson = pub(ctx.buildEnv);
const environment = ctx.eas?.build?.[ctx.options.profile]?.environment ?? (["preview", "development"].includes(ctx.options.profile) ? ctx.options.profile : "production");
const easEnv = ctx.options.offline ? null : loadEasEnv(ctx.dir, environment);
const build = { ...pub(easEnv ?? {}), ...easJson };
const update = pub(easEnv ?? {});
const MASKED = /^\*+$/;
const fails = [];
const warns = [];
if (easEnv) {
for (const [k, v] of Object.entries(easJson)) {
if (!(k in update)) fails.push(`${k}: set in eas.json build.${ctx.options.profile}.env but not in EAS env "${environment}", so updates ship without it`);
else if (!MASKED.test(update[k]) && update[k] !== v) fails.push(`${k}: eas.json and EAS env "${environment}" differ, so updates ship a different value than the build`);
}
}
for (const f of ctx.envFiles) {
for (const r of f.rows) {
if (!r.key.startsWith("EXPO_PUBLIC_")) continue;
if (!(r.key in build)) { if (easEnv) warns.push(`${r.key}: only in ${f.name}, the build doesn't have it`); }
else if (!MASKED.test(build[r.key]) && build[r.key] !== r.value) warns.push(`${r.key}: ${f.name} differs from the build value`);
}
}
const envNote = easEnv ? "" : `\nEAS env not checked (${ctx.options.offline ? "--offline" : "eas env:list failed: not logged in or project not linked"}).`;
if (fails.length)
return { status: "fail", detail: `${list(fails)}${warns.length ? `\nAn eas update run from this folder would also bake in local .env values:\n${list(warns)}` : ""}`, fix: `Add the missing values to EAS env "${environment}" (or drop them from eas.json).` };
if (warns.length)
return { status: "warn", detail: `An eas update run from this folder bakes in local .env values, so it would not match the build:\n${list(warns)}${envNote}`, fix: "Publish updates with the .env files moved aside (or from CI), with --environment set." };
if (!easEnv && Object.keys(easJson).length) return { status: "info", detail: envNote.trim() };
return pass(easEnv ? `${Object.keys(build).length} EXPO_PUBLIC_ vars, builds and updates agree` : undefined);
},
},
{
id: "secrets.eas-json",
title: "No secrets in eas.json env",
run(ctx) {
if (!ctx.eas) return skip("no eas.json");
// EXPO_PUBLIC_ values ship in the app anyway; anything else named like a secret shouldn't be in a committed file.
const secretish = /SECRET|TOKEN|PASSWORD|PASSWD|PRIVATE|CREDENTIAL|API_?KEY|ACCESS_?KEY|SERVICE_?ROLE|_DSN$/i;
const bad = [];
for (const [name, p] of Object.entries(ctx.eas.build ?? {})) for (const k of Object.keys(p.env ?? {})) if (!k.startsWith("EXPO_PUBLIC_") && secretish.test(k)) bad.push(`build.${name}.env.${k}`);
if (bad.length) return { status: "warn", detail: `eas.json is committed and these keys don't look public:\n${list(bad)}`, fix: "Move secrets to EAS env (eas env:create --visibility secret)." };
return pass();
},
},
{
id: "git.env-tracked",
title: ".env files not committed",
run(ctx) {
if (!ctx.tracked) return skip("not a git repo");
const hits = ctx.tracked.filter((f) => /(^|\/)\.env(\.[^/]+)?$/.test(f) && !/example|sample|template/i.test(f));
if (hits.length) return { status: "fail", detail: `tracked by git:\n${list(hits)}`, fix: "git rm --cached them, add .env* to .gitignore, and rotate anything secret in them." };
return pass();
},
},
{
id: "ci.router-types",
title: "CI generates expo-router types before typechecking",
run(ctx) {
if (!ctx.config.experiments?.typedRoutes) return skip("typedRoutes off");
const tsc = ctx.workflows.filter((w) => /\btsc\b|typecheck/.test(w.text));
if (!tsc.length) return skip("no CI typecheck found");
if (tsc.some((w) => /router\.d\.ts|expo start|expo customize/.test(w.text))) return pass();
return { status: "warn", detail: `${tsc.map((w) => w.name).join(", ")} typecheck without .expo/types/router.d.ts (gitignored), so tsc runs against looser router types and reports errors that don't exist locally.`, fix: "Start `npx expo start --offline` in the background until .expo/types/router.d.ts exists, then run tsc." };
},
},
{
id: "build.skia-frameworks",
title: "Skia not combined with useFrameworks",
run(ctx) {
if (!ctx.deps["@shopify/react-native-skia"]) return skip("Skia not installed");
const bp = plugin(ctx, "expo-build-properties");
if (bp?.ios?.useFrameworks) return { status: "fail", detail: `expo-build-properties ios.useFrameworks is "${bp.ios.useFrameworks}". Skia fails to compile under frameworks ('third_party/base64.h' file not found).`, fix: "Remove useFrameworks, then build once with --clear-cache." };
return pass();
},
},
{
id: "lock.npm10",
title: "Lockfile installs with the npm on EAS (npm 10)",
run(ctx) {
if (ctx.options.offline) return skip("--offline");
if (!existsSync(join(ctx.dir, "package-lock.json"))) return skip("no package-lock.json");
const tmp = mkdtempSync(join(tmpdir(), "store-preflight-"));
try {
copyFileSync(join(ctx.dir, "package.json"), join(tmp, "package.json"));
copyFileSync(join(ctx.dir, "package-lock.json"), join(tmp, "package-lock.json"));
if (existsSync(join(ctx.dir, ".npmrc"))) copyFileSync(join(ctx.dir, ".npmrc"), join(tmp, ".npmrc"));
const r = spawnSync("npx", ["-y", "npm@10.9.8", "ci", "--dry-run", "--ignore-scripts", "--include=dev", "--no-audit", "--no-fund"], { cwd: tmp, encoding: "utf8" });
if (r.status === 0) return pass("npm 10.9.8 ci --dry-run ok");
const lines = (r.stdout + r.stderr).split("\n").filter((l) => /Missing:|Invalid:|EUSAGE|ERESOLVE/.test(l)).slice(0, 8);
return { status: "fail", detail: `npm 10 ci fails, so the EAS "Install dependencies" step will too:\n${list(lines.length ? lines : ["(no detail, run it by hand)"])}`, fix: "npx -y npm@10.9.8 install --package-lock-only, then commit the lockfile." };
} finally {
rmSync(tmp, { recursive: true, force: true });
}
},
},
{
id: "links.verified-domains",
title: "App links and universal links verify",
async run(ctx) {
if (ctx.options.offline) return skip("--offline");
const pkg = ctx.config.android?.package;
const bundle = ctx.config.ios?.bundleIdentifier;
const androidHosts = new Set();
for (const f of ctx.config.android?.intentFilters ?? []) if (f.autoVerify) for (const d of [f.data ?? []].flat()) if (d.host) androidHosts.add(d.host);
const iosHosts = new Set((ctx.config.ios?.associatedDomains ?? []).filter((d) => d.startsWith("applinks:")).map((d) => d.slice(9).split("?")[0]));
if (!androidHosts.size && !iosHosts.size) return skip("no verified link domains");
const problems = [];
const get = async (url) => {
try {
const r = await fetch(url, { redirect: "manual", signal: AbortSignal.timeout(8000) });
if (r.status !== 200) return { error: `HTTP ${r.status}` };
return { json: await r.json() };
} catch (e) {
return { error: e.name === "SyntaxError" ? "not JSON" : e.message };
}
};
for (const h of androidHosts) {
const { json, error } = await get(`https://${h}/.well-known/assetlinks.json`);
if (error) problems.push(`${h} assetlinks.json: ${error}`);
else if (!json.some?.((s) => s.target?.package_name === pkg)) problems.push(`${h} assetlinks.json has no entry for ${pkg}`);
}
for (const h of iosHosts) {
const { json, error } = await get(`https://${h}/.well-known/apple-app-site-association`);
if (error) { problems.push(`${h} apple-app-site-association: ${error}`); continue; }
const ids = (json.applinks?.details ?? []).flatMap((d) => [d.appID, ...(d.appIDs ?? [])]).filter(Boolean);
if (!ids.some((id) => id.endsWith(`.${bundle}`))) problems.push(`${h} apple-app-site-association has no appID for ${bundle}`);
}
const hosts = [...androidHosts, ...iosHosts].length;
if (problems.length) return { status: "fail", detail: `links will open in the browser instead of the app:\n${list(problems)}`, fix: "Add the package / appID to the file on that domain. Android: the SHA-256 there must match the signing key (Play App Signing key once on Play)." };
return pass(`${hosts} domain(s) list this app (SHA-256 fingerprints not compared)`);
},
},
];src/context.mjsShowHide
import { spawnSync } from "node:child_process";
import { cpSync, existsSync, mkdtempSync, readdirSync, readFileSync, rmSync, symlinkSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { parseDotenv, parseJsonc } from "./util.mjs";
const read = (p) => (existsSync(p) ? readFileSync(p, "utf8") : null);
// eas.json build profile env, following "extends" chains. Child values win.
export function profileEnv(eas, name, seen = new Set()) {
const p = eas?.build?.[name];
if (!p || seen.has(name)) return {};
seen.add(name);
return { ...(p.extends ? profileEnv(eas, p.extends, seen) : {}), ...(p.env ?? {}) };
}
function git(dir, args) {
const r = spawnSync("git", args, { cwd: dir, encoding: "utf8" });
return r.status === 0 ? r.stdout : null;
}
// Everything the checks look at, gathered once. Checks never touch the disk themselves,
// except the few that need network or a subprocess (they get ctx.dir and ctx.options).
export function loadContext(dir, options = {}) {
const profile = options.profile ?? "production";
const pkg = JSON.parse(readFileSync(join(dir, "package.json"), "utf8"));
const deps = { ...pkg.dependencies, ...pkg.devDependencies };
const easText = read(join(dir, "eas.json"));
const eas = easText ? parseJsonc(easText) : null;
const buildEnv = profileEnv(eas, profile);
const tracked = git(dir, ["ls-files", "-z"])?.split("\0").filter(Boolean) ?? null;
// Evaluate the config the way an EAS build would: the profile's env, no local .env files.
// EAS only sees native folders that are committed. An uncommitted ios/ or android/ is a stale
// local prebuild whose Info.plist / manifest would leak into the result, so evaluate a copy without it.
const stale = ["ios", "android"].filter((d) => existsSync(join(dir, d)) && !tracked?.some((f) => f.startsWith(`${d}/`)));
const evalDir = stale.length ? copyWithout(dir, stale) : dir;
let r;
try {
r = spawnSync("npx", ["expo", "config", "--type", "introspect", "--json"], {
cwd: evalDir,
encoding: "utf8",
env: { ...process.env, ...buildEnv, EAS_BUILD_PROFILE: profile, EXPO_NO_DOTENV: "1" },
maxBuffer: 64 * 1024 * 1024,
});
} finally {
if (evalDir !== dir) rmSync(evalDir, { recursive: true, force: true });
}
if (r.status !== 0) throw new Error(`expo config failed in ${dir}:\n${r.stderr.trim().split("\n").slice(-5).join("\n")}`);
const config = JSON.parse(r.stdout);
const mods = config._internal?.modResults ?? {};
const infoPlist = mods.ios?.infoPlist ?? config.ios?.infoPlist ?? {};
// With no ios/ folder, introspection starts from a stand-in Info.plist that allows arbitrary loads.
// A real prebuild starts from Expo's template instead, which only allows local networking.
if (!tracked?.some((f) => f.startsWith("ios/")) && JSON.stringify(infoPlist.NSAppTransportSecurity) === INTROSPECT_ATS)
infoPlist.NSAppTransportSecurity = { NSAllowsArbitraryLoads: false, NSAllowsLocalNetworking: true };
// android.blockedPermissions stay in the manifest marked tools:node="remove"; they don't ship.
const usesPermission = mods.android?.manifest?.manifest?.["uses-permission"] ?? [];
const blocked = new Set(usesPermission.filter((p) => p.$?.["tools:node"] === "remove").map((p) => p.$?.["android:name"]));
const androidPermissionFrom = {};
for (const p of usesPermission) if (!blocked.has(p.$?.["android:name"])) androidPermissionFrom[p.$?.["android:name"]] = "app config";
// Native libraries add their own permissions when Gradle merges manifests at build time, so
// they never show in the introspected manifest. Read each autolinked dependency's manifest.
for (const dep of Object.keys(pkg.dependencies ?? {})) {
const xml = read(join(dir, "node_modules", dep, "android/src/main/AndroidManifest.xml"));
for (const [, name] of xml?.matchAll(/<uses-permission(?:-sdk-23)?\b[^>]*android:name="([^"]+)"/g) ?? [])
if (!blocked.has(name)) androidPermissionFrom[name] ??= dep;
}
const androidPermissions = Object.keys(androidPermissionFrom);
const envFiles = readdirSync(dir)
.filter((f) => /^\.env(\..+)?$/.test(f) && !/example|sample|template/i.test(f))
.map((name) => ({ name, rows: parseDotenv(readFileSync(join(dir, name), "utf8")) }));
const top = git(dir, ["rev-parse", "--show-toplevel"])?.trim();
const workflows = [];
for (const base of new Set([dir, top].filter(Boolean))) {
const wf = join(base, ".github/workflows");
if (!existsSync(wf)) continue;
for (const f of readdirSync(wf).filter((f) => /\.ya?ml$/.test(f))) {
workflows.push({ name: f, text: readFileSync(join(wf, f), "utf8") });
}
}
return {
dir,
options: { ...options, profile },
pkg,
deps,
eas,
buildEnv,
config,
infoPlist,
androidPermissions,
androidPermissionFrom,
envFiles,
tracked,
workflows,
sourceFiles: () => listSource(dir),
};
}
const INTROSPECT_ATS = JSON.stringify({ NSAllowsArbitraryLoads: true, NSExceptionDomains: { localhost: { NSExceptionAllowsInsecureHTTPLoads: true } } });
// A temp copy of the project without the given folders, sharing node_modules by symlink.
function copyWithout(dir, skip) {
const out = mkdtempSync(join(tmpdir(), "store-preflight-"));
const omit = new Set([...skip, "node_modules", ".git"]);
for (const e of readdirSync(dir)) if (!omit.has(e)) cpSync(join(dir, e), join(out, e), { recursive: true });
if (existsSync(join(dir, "node_modules"))) symlinkSync(join(dir, "node_modules"), join(out, "node_modules"));
return out;
}
// App source files (not node_modules, builds or native folders), for the few checks that grep code.
function listSource(dir) {
const out = [];
const skip = new Set(["node_modules", ".git", ".expo", "ios", "android", "dist", "build", "web-build", "coverage"]);
const walk = (d) => {
for (const e of readdirSync(d, { withFileTypes: true })) {
if (e.name.startsWith(".") && e.isDirectory()) continue;
if (skip.has(e.name)) continue;
const p = join(d, e.name);
if (e.isDirectory()) walk(p);
else if (/\.(tsx?|jsx?)$/.test(e.name) && !/\.(test|spec)\./.test(e.name)) out.push(p);
}
};
walk(dir);
return out;
}src/util.mjsShowHide
import { readFileSync } from "node:fs";
import { inflateSync } from "node:zlib";
// eas.json is JSONC: strip // and /* */ comments (outside strings) and trailing commas.
export function parseJsonc(text) {
let out = "";
let inStr = false;
for (let i = 0; i < text.length; i++) {
const c = text[i];
if (inStr) {
out += c;
if (c === "\\") out += text[++i] ?? "";
else if (c === '"') inStr = false;
} else if (c === '"') {
inStr = true;
out += c;
} else if (c === "/" && text[i + 1] === "/") {
while (i < text.length && text[i] !== "\n") i++;
out += "\n";
} else if (c === "/" && text[i + 1] === "*") {
i = text.indexOf("*/", i + 2);
if (i === -1) break;
i++;
} else {
out += c;
}
}
return JSON.parse(out.replace(/,(\s*[}\]])/g, "$1"));
}
// Minimal .env reader: returns [{ key, value, line }], value as written (quotes stripped).
export function parseDotenv(text) {
const rows = [];
text.split(/\r?\n/).forEach((raw, i) => {
const m = raw.match(/^\s*(?:export\s+)?([A-Za-z_][A-Za-z0-9_]*)\s*=\s*(.*)$/);
if (!m) return;
let value = m[2].trim();
const q = value[0];
if ((q === '"' || q === "'") && value.endsWith(q) && value.length > 1) value = value.slice(1, -1);
else value = value.replace(/\s+#.*$/, "");
rows.push({ key: m[1], value, line: i + 1, quote: q === "'" ? "single" : q === '"' ? "double" : null });
});
return rows;
}
// Reads a PNG: size, whether it has an alpha channel, and whether any pixel is actually transparent.
export function readPng(path) {
const buf = readFileSync(path);
if (buf.readUInt32BE(0) !== 0x89504e47) throw new Error("not a PNG");
const width = buf.readUInt32BE(16);
const height = buf.readUInt32BE(20);
const bitDepth = buf[24];
const colorType = buf[25];
const interlace = buf[28];
let hasTrns = false;
const idat = [];
for (let off = 8; off < buf.length; ) {
const len = buf.readUInt32BE(off);
const type = buf.toString("ascii", off + 4, off + 8);
if (type === "tRNS") hasTrns = true;
if (type === "IDAT") idat.push(buf.subarray(off + 8, off + 8 + len));
off += 12 + len;
}
const hasAlpha = colorType === 4 || colorType === 6 || hasTrns;
let transparent = hasAlpha ? null : false; // null = has alpha but not measured
if ((colorType === 6 || colorType === 4) && bitDepth === 8 && interlace === 0) {
transparent = anyTransparent(inflateSync(Buffer.concat(idat)), width, height, colorType === 6 ? 4 : 2);
}
return { width, height, hasAlpha, transparent };
}
function anyTransparent(data, width, height, bpp) {
const stride = width * bpp;
let prev = Buffer.alloc(stride);
for (let y = 0; y < height; y++) {
const filter = data[y * (stride + 1)];
const row = Buffer.from(data.subarray(y * (stride + 1) + 1, (y + 1) * (stride + 1)));
for (let x = 0; x < stride; x++) {
const a = x >= bpp ? row[x - bpp] : 0;
const b = prev[x];
const c = x >= bpp ? prev[x - bpp] : 0;
let add = 0;
if (filter === 1) add = a;
else if (filter === 2) add = b;
else if (filter === 3) add = (a + b) >> 1;
else if (filter === 4) {
const p = a + b - c;
const pa = Math.abs(p - a), pb = Math.abs(p - b), pc = Math.abs(p - c);
add = pa <= pb && pa <= pc ? a : pb <= pc ? b : c;
}
row[x] = (row[x] + add) & 0xff;
}
for (let x = bpp - 1; x < stride; x += bpp) if (row[x] < 255) return true;
prev = row;
}
return false;
}Licence
MIT.
Licence text
MIT License Copyright (c) 2026 David Ewins Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.