@expo/cli 55.0.30 → 55.0.32

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.
Files changed (68) hide show
  1. package/build/bin/cli +1 -1
  2. package/build/src/api/rest/client.js +27 -12
  3. package/build/src/api/rest/client.js.map +1 -1
  4. package/build/src/api/user/UserSettings.js +4 -2
  5. package/build/src/api/user/UserSettings.js.map +1 -1
  6. package/build/src/events/index.js +1 -1
  7. package/build/src/export/embed/exportEmbedAsync.js +3 -3
  8. package/build/src/export/embed/exportEmbedAsync.js.map +1 -1
  9. package/build/src/export/embed/exportServer.js +1 -1
  10. package/build/src/export/embed/exportServer.js.map +1 -1
  11. package/build/src/export/exportApp.js +1 -1
  12. package/build/src/export/exportApp.js.map +1 -1
  13. package/build/src/export/publicFolder.js +19 -1
  14. package/build/src/export/publicFolder.js.map +1 -1
  15. package/build/src/prebuild/resolveTemplate.js +10 -5
  16. package/build/src/prebuild/resolveTemplate.js.map +1 -1
  17. package/build/src/run/android/resolveLaunchProps.js +4 -1
  18. package/build/src/run/android/resolveLaunchProps.js.map +1 -1
  19. package/build/src/start/platforms/android/adb.js +16 -15
  20. package/build/src/start/platforms/android/adb.js.map +1 -1
  21. package/build/src/start/server/DevToolsPlugin.js +26 -1
  22. package/build/src/start/server/DevToolsPlugin.js.map +1 -1
  23. package/build/src/start/server/DevToolsPluginCliExtensionExecutor.js +57 -22
  24. package/build/src/start/server/DevToolsPluginCliExtensionExecutor.js.map +1 -1
  25. package/build/src/start/server/DevToolsPluginCliExtensionResults.js +29 -0
  26. package/build/src/start/server/DevToolsPluginCliExtensionResults.js.map +1 -1
  27. package/build/src/start/server/MCPDevToolsPluginCLIExtensions.js +15 -5
  28. package/build/src/start/server/MCPDevToolsPluginCLIExtensions.js.map +1 -1
  29. package/build/src/start/server/createMCPDevToolsExtensionSchema.js +13 -1
  30. package/build/src/start/server/createMCPDevToolsExtensionSchema.js.map +1 -1
  31. package/build/src/start/server/getStaticRenderFunctions.js +2 -1
  32. package/build/src/start/server/getStaticRenderFunctions.js.map +1 -1
  33. package/build/src/start/server/metro/createServerComponentsMiddleware.js +5 -12
  34. package/build/src/start/server/metro/createServerComponentsMiddleware.js.map +1 -1
  35. package/build/src/start/server/metro/debugging/createDebugMiddleware.js +6 -5
  36. package/build/src/start/server/metro/debugging/createDebugMiddleware.js.map +1 -1
  37. package/build/src/start/server/metro/debugging/messageHandlers/NetworkResponse.js +17 -1
  38. package/build/src/start/server/metro/debugging/messageHandlers/NetworkResponse.js.map +1 -1
  39. package/build/src/start/server/metro/dev-server/createMessageSocket.js +13 -2
  40. package/build/src/start/server/metro/dev-server/createMessageSocket.js.map +1 -1
  41. package/build/src/start/server/metro/dev-server/createMetroMiddleware.js +9 -2
  42. package/build/src/start/server/metro/dev-server/createMetroMiddleware.js.map +1 -1
  43. package/build/src/start/server/metro/instantiateMetro.js +8 -5
  44. package/build/src/start/server/metro/instantiateMetro.js.map +1 -1
  45. package/build/src/start/server/metro/metroErrorInterface.js +5 -2
  46. package/build/src/start/server/metro/metroErrorInterface.js.map +1 -1
  47. package/build/src/start/server/metro/router.js +10 -1
  48. package/build/src/start/server/metro/router.js.map +1 -1
  49. package/build/src/start/server/middleware/InterstitialPageMiddleware.js +7 -4
  50. package/build/src/start/server/middleware/InterstitialPageMiddleware.js.map +1 -1
  51. package/build/src/start/server/middleware/ServeStaticMiddleware.js +2 -9
  52. package/build/src/start/server/middleware/ServeStaticMiddleware.js.map +1 -1
  53. package/build/src/start/server/middleware/inspector/createJsInspectorMiddleware.js +14 -24
  54. package/build/src/start/server/middleware/inspector/createJsInspectorMiddleware.js.map +1 -1
  55. package/build/src/start/server/webTemplate.js +3 -5
  56. package/build/src/start/server/webTemplate.js.map +1 -1
  57. package/build/src/utils/codesigning.js +6 -0
  58. package/build/src/utils/codesigning.js.map +1 -1
  59. package/build/src/utils/net.js +13 -0
  60. package/build/src/utils/net.js.map +1 -1
  61. package/build/src/utils/tar.js +2 -2
  62. package/build/src/utils/tar.js.map +1 -1
  63. package/build/src/utils/telemetry/clients/FetchClient.js +1 -1
  64. package/build/src/utils/telemetry/utils/context.js +1 -1
  65. package/build/src/utils/url.js +0 -12
  66. package/build/src/utils/url.js.map +1 -1
  67. package/package.json +9 -9
  68. package/static/loading-page/index.html +10 -2
@@ -15,20 +15,6 @@ function _chalk() {
15
15
  };
16
16
  return data;
17
17
  }
18
- function _net() {
19
- const data = /*#__PURE__*/ _interop_require_default(require("net"));
20
- _net = function() {
21
- return data;
22
- };
23
- return data;
24
- }
25
- function _tls() {
26
- const data = require("tls");
27
- _tls = function() {
28
- return data;
29
- };
30
- return data;
31
- }
32
18
  function _url() {
33
19
  const data = require("url");
34
20
  _url = function() {
@@ -37,20 +23,26 @@ function _url() {
37
23
  return data;
38
24
  }
39
25
  const _JsInspector = require("./JsInspector");
26
+ const _net = require("../../../../utils/net");
40
27
  function _interop_require_default(obj) {
41
28
  return obj && obj.__esModule ? obj : {
42
29
  default: obj
43
30
  };
44
31
  }
45
- function createJsInspectorMiddleware() {
32
+ function createJsInspectorMiddleware({ serverBaseUrl }) {
46
33
  return async function(req, res, next) {
47
- const { origin, searchParams } = new (_url()).URL(req.url ?? '/', getServerBase(req));
34
+ if (!(0, _net.isMatchingOrigin)(req, serverBaseUrl)) {
35
+ res.writeHead(403).end();
36
+ return;
37
+ }
38
+ // `req.url` may be absolute-form (HTTP/1.1) — only take search params from it.
39
+ const { searchParams } = new (_url()).URL(req.url ?? '/', serverBaseUrl);
48
40
  const appId = searchParams.get('appId') || searchParams.get('applicationId');
49
41
  if (!appId) {
50
42
  res.writeHead(400).end('Missing application identifier ("?appId=...")');
51
43
  return;
52
44
  }
53
- const app = await (0, _JsInspector.queryInspectorAppAsync)(origin, appId);
45
+ const app = await (0, _JsInspector.queryInspectorAppAsync)(serverBaseUrl, appId);
54
46
  if (!app) {
55
47
  res.writeHead(404).end('Unable to find inspector target from @react-native/dev-middleware');
56
48
  console.warn(_chalk().default.yellow('No compatible apps connected. JavaScript Debugging can only be used with the Hermes engine.'));
@@ -65,8 +57,12 @@ function createJsInspectorMiddleware() {
65
57
  });
66
58
  res.end(data);
67
59
  } else if (req.method === 'POST' || req.method === 'PUT') {
60
+ if ((0, _net.shouldThrottleRemoteDevCall)()) {
61
+ res.writeHead(429).end();
62
+ return;
63
+ }
68
64
  try {
69
- await (0, _JsInspector.openJsInspector)(origin, app);
65
+ await (0, _JsInspector.openJsInspector)(serverBaseUrl, app);
70
66
  } catch (error) {
71
67
  // abort(Error: Command failed: osascript -e POSIX path of (path to application "google chrome")
72
68
  // 15:50: execution error: Google Chrome got an error: Application isn’t running. (-600)
@@ -81,11 +77,5 @@ function createJsInspectorMiddleware() {
81
77
  }
82
78
  };
83
79
  }
84
- function getServerBase(req) {
85
- const scheme = req.socket instanceof _tls().TLSSocket && req.socket.encrypted === true ? 'https' : 'http';
86
- const { localAddress, localPort } = req.socket;
87
- const address = localAddress && _net().default.isIPv6(localAddress) ? `[${localAddress}]` : localAddress;
88
- return `${scheme}:${address}:${localPort}`;
89
- }
90
80
 
91
81
  //# sourceMappingURL=createJsInspectorMiddleware.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../src/start/server/middleware/inspector/createJsInspectorMiddleware.ts"],"sourcesContent":["import chalk from 'chalk';\nimport type { NextHandleFunction } from 'connect';\nimport type { IncomingMessage, ServerResponse } from 'http';\nimport net from 'net';\nimport { TLSSocket } from 'tls';\nimport { URL } from 'url';\n\nimport { openJsInspector, queryInspectorAppAsync } from './JsInspector';\n\n/**\n * Create a middleware that handles new requests to open the debugger from the dev menu.\n * @todo(cedric): delete this middleware once we fully swap over to the new React Native JS Inspector.\n */\nexport function createJsInspectorMiddleware(): NextHandleFunction {\n return async function (req: IncomingMessage, res: ServerResponse, next: (err?: Error) => void) {\n const { origin, searchParams } = new URL(req.url ?? '/', getServerBase(req));\n const appId = searchParams.get('appId') || searchParams.get('applicationId');\n if (!appId) {\n res.writeHead(400).end('Missing application identifier (\"?appId=...\")');\n return;\n }\n\n const app = await queryInspectorAppAsync(origin, appId);\n if (!app) {\n res.writeHead(404).end('Unable to find inspector target from @react-native/dev-middleware');\n console.warn(\n chalk.yellow(\n 'No compatible apps connected. JavaScript Debugging can only be used with the Hermes engine.'\n )\n );\n return;\n }\n\n if (req.method === 'GET') {\n const data = JSON.stringify(app);\n res.writeHead(200, {\n 'Content-Type': 'application/json; charset=UTF-8',\n 'Cache-Control': 'no-cache',\n 'Content-Length': data.length.toString(),\n });\n res.end(data);\n } else if (req.method === 'POST' || req.method === 'PUT') {\n try {\n await openJsInspector(origin, app);\n } catch (error: any) {\n // abort(Error: Command failed: osascript -e POSIX path of (path to application \"google chrome\")\n // 15:50: execution error: Google Chrome got an error: Application isn’t running. (-600)\n\n console.error(\n chalk.red('Error launching JS inspector: ' + (error?.message ?? 'Unknown error occurred'))\n );\n res.writeHead(500);\n res.end();\n return;\n }\n res.end();\n } else {\n res.writeHead(405);\n }\n };\n}\n\nfunction getServerBase(req: IncomingMessage): string {\n const scheme =\n req.socket instanceof TLSSocket && req.socket.encrypted === true ? 'https' : 'http';\n const { localAddress, localPort } = req.socket;\n const address = localAddress && net.isIPv6(localAddress) ? `[${localAddress}]` : localAddress;\n return `${scheme}:${address}:${localPort}`;\n}\n"],"names":["createJsInspectorMiddleware","req","res","next","origin","searchParams","URL","url","getServerBase","appId","get","writeHead","end","app","queryInspectorAppAsync","console","warn","chalk","yellow","method","data","JSON","stringify","length","toString","openJsInspector","error","red","message","scheme","socket","TLSSocket","encrypted","localAddress","localPort","address","net","isIPv6"],"mappings":";;;;+BAagBA;;;eAAAA;;;;gEAbE;;;;;;;gEAGF;;;;;;;yBACU;;;;;;;yBACN;;;;;;6BAEoC;;;;;;AAMjD,SAASA;IACd,OAAO,eAAgBC,GAAoB,EAAEC,GAAmB,EAAEC,IAA2B;QAC3F,MAAM,EAAEC,MAAM,EAAEC,YAAY,EAAE,GAAG,IAAIC,CAAAA,MAAE,KAAC,CAAC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AAMK,UAAUF,gBAAgBG,cAAG,CAACC,MAAM,CAACJ,gBAAgB,CAAC,CAAC,EAAEA,aAAa,CAAC,CAAC,GAAGA;IACjF,OAAO,GAAGJ,OAAO,CAAC,EAAEM,QAAQ,CAAC,EAAED,WAAW;AAC5C"}
1
+ {"version":3,"sources":["../../../../../../src/start/server/middleware/inspector/createJsInspectorMiddleware.ts"],"sourcesContent":["import chalk from 'chalk';\nimport type { NextHandleFunction } from 'connect';\nimport type { IncomingMessage, ServerResponse } from 'http';\nimport { URL } from 'url';\n\nimport { openJsInspector, queryInspectorAppAsync } from './JsInspector';\nimport { isMatchingOrigin, shouldThrottleRemoteDevCall } from '../../../../utils/net';\n\ninterface JsInspectorMiddlewareOptions {\n serverBaseUrl: string;\n}\n\n/**\n * Create a middleware that handles new requests to open the debugger from the dev menu.\n * @todo(cedric): delete this middleware once we fully swap over to the new React Native JS Inspector.\n */\nexport function createJsInspectorMiddleware({\n serverBaseUrl,\n}: JsInspectorMiddlewareOptions): NextHandleFunction {\n return async function (req: IncomingMessage, res: ServerResponse, next: (err?: Error) => void) {\n if (!isMatchingOrigin(req, serverBaseUrl)) {\n res.writeHead(403).end();\n return;\n }\n\n // `req.url` may be absolute-form (HTTP/1.1) — only take search params from it.\n const { searchParams } = new URL(req.url ?? '/', serverBaseUrl);\n const appId = searchParams.get('appId') || searchParams.get('applicationId');\n if (!appId) {\n res.writeHead(400).end('Missing application identifier (\"?appId=...\")');\n return;\n }\n\n const app = await queryInspectorAppAsync(serverBaseUrl, appId);\n if (!app) {\n res.writeHead(404).end('Unable to find inspector target from @react-native/dev-middleware');\n console.warn(\n chalk.yellow(\n 'No compatible apps connected. JavaScript Debugging can only be used with the Hermes engine.'\n )\n );\n return;\n }\n\n if (req.method === 'GET') {\n const data = JSON.stringify(app);\n res.writeHead(200, {\n 'Content-Type': 'application/json; charset=UTF-8',\n 'Cache-Control': 'no-cache',\n 'Content-Length': data.length.toString(),\n });\n res.end(data);\n } else if (req.method === 'POST' || req.method === 'PUT') {\n if (shouldThrottleRemoteDevCall()) {\n res.writeHead(429).end();\n return;\n }\n try {\n await openJsInspector(serverBaseUrl, app);\n } catch (error: any) {\n // abort(Error: Command failed: osascript -e POSIX path of (path to application \"google chrome\")\n // 15:50: execution error: Google Chrome got an error: Application isn’t running. (-600)\n\n console.error(\n chalk.red('Error launching JS inspector: ' + (error?.message ?? 'Unknown error occurred'))\n );\n res.writeHead(500);\n res.end();\n return;\n }\n res.end();\n } else {\n res.writeHead(405);\n }\n };\n}\n"],"names":["createJsInspectorMiddleware","serverBaseUrl","req","res","next","isMatchingOrigin","writeHead","end","searchParams","URL","url","appId","get","app","queryInspectorAppAsync","console","warn","chalk","yellow","method","data","JSON","stringify","length","toString","shouldThrottleRemoteDevCall","openJsInspector","error","red","message"],"mappings":";;;;+BAgBgBA;;;eAAAA;;;;gEAhBE;;;;;;;yBAGE;;;;;;6BAEoC;qBACM;;;;;;AAUvD,SAASA,4BAA4B,EAC1CC,aAAa,EACgB;IAC7B,OAAO,eAAgBC,GAAoB,EAAEC,GAAmB,EAAEC,IAA2B;QAC3F,IAAI,CAACC,IAAAA,qBAAgB,EAACH,KAAKD,gBAAgB;YACzCE,IAAIG,SAAS,CAAC,KAAKC,GAAG;YACtB;QACF;QAEA,+EAA+E;QAC/E,MAAM,EAAEC,YAAY,EAAE,GAAG,IAAIC,CAAAA,MAAE,KAAC,CAACP,IAAIQ,GAAG,IAAI,KAAKT;QACjD,MAAMU,QAAQH,aAAaI,GAAG,CAAC,YAAYJ,aAAaI,GAAG,CAAC;QAC5D,IAAI,CAACD,OAAO;YACVR,IAAIG,SAAS,CAAC,KAAKC,GAAG,CAAC;YACvB;QACF;QAEA,MAAMM,MAAM,MAAMC,IAAAA,mCAAsB,EAACb,eAAeU;QACxD,IAAI,CAACE,KAAK;YACRV,IAAIG,SAAS,CAAC,KAAKC,GAAG,CAAC;YACvBQ,QAAQC,IAAI,CACVC,gBAAK,CAACC,MAAM,CACV;YAGJ;QACF;QAEA,IAAIhB,IAAIiB,MAAM,KAAK,OAAO;YACxB,MAAMC,OAAOC,KAAKC,SAAS,CAACT;YAC5BV,IAAIG,SAAS,CAAC,KAAK;gBACjB,gBAAgB;gBAChB,iBAAiB;gBACjB,kBAAkBc,KAAKG,MAAM,CAACC,QAAQ;YACxC;YACArB,IAAII,GAAG,CAACa;QACV,OAAO,IAAIlB,IAAIiB,MAAM,KAAK,UAAUjB,IAAIiB,MAAM,KAAK,OAAO;YACxD,IAAIM,IAAAA,gCAA2B,KAAI;gBACjCtB,IAAIG,SAAS,CAAC,KAAKC,GAAG;gBACtB;YACF;YACA,IAAI;gBACF,MAAMmB,IAAAA,4BAAe,EAACzB,eAAeY;YACvC,EAAE,OAAOc,OAAY;gBACnB,gGAAgG;gBAChG,wFAAwF;gBAExFZ,QAAQY,KAAK,CACXV,gBAAK,CAACW,GAAG,CAAC,mCAAoCD,CAAAA,CAAAA,yBAAAA,MAAOE,OAAO,KAAI,wBAAuB;gBAEzF1B,IAAIG,SAAS,CAAC;gBACdH,IAAII,GAAG;gBACP;YACF;YACAJ,IAAII,GAAG;QACT,OAAO;YACLJ,IAAIG,SAAS,CAAC;QAChB;IACF;AACF"}
@@ -39,7 +39,7 @@ function _path() {
39
39
  }
40
40
  const _templates = require("../../customize/templates");
41
41
  const _html = require("../../export/html");
42
- const _env = require("../../utils/env");
42
+ const _publicFolder = require("../../export/publicFolder");
43
43
  function _interop_require_default(obj) {
44
44
  return obj && obj.__esModule ? obj : {
45
45
  default: obj
@@ -58,8 +58,8 @@ async function createTemplateHtmlFromExpoConfigAsync(projectRoot, { scripts, css
58
58
  themeColor: (_exp_web2 = exp.web) == null ? void 0 : _exp_web2.themeColor
59
59
  });
60
60
  }
61
- function getFileFromLocalPublicFolder(projectRoot, { publicFolder, filePath }) {
62
- const localFilePath = _path().default.resolve(projectRoot, publicFolder, filePath);
61
+ function getFileFromLocalPublicFolder(projectRoot, { filePath }) {
62
+ const localFilePath = _path().default.resolve((0, _publicFolder.getPublicFolderPath)(projectRoot), filePath);
63
63
  if (!_fs().default.existsSync(localFilePath)) {
64
64
  return null;
65
65
  }
@@ -67,8 +67,6 @@ function getFileFromLocalPublicFolder(projectRoot, { publicFolder, filePath }) {
67
67
  }
68
68
  /** Attempt to read the `index.html` from the local project before falling back on the template `index.html`. */ async function getTemplateIndexHtmlAsync(projectRoot) {
69
69
  let filePath = getFileFromLocalPublicFolder(projectRoot, {
70
- // TODO: Maybe use the app.json override.
71
- publicFolder: _env.env.EXPO_PUBLIC_FOLDER,
72
70
  filePath: 'index.html'
73
71
  });
74
72
  if (!filePath) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/start/server/webTemplate.ts"],"sourcesContent":["import { ExpoConfig, getConfig, getNameFromConfig } from '@expo/config';\nimport fs from 'fs';\nimport path from 'path';\n\nimport { TEMPLATES } from '../../customize/templates';\nimport { appendLinkToHtml, appendScriptsToHtml } from '../../export/html';\nimport { env } from '../../utils/env';\n\n/**\n * Create a static HTML for SPA styled websites.\n * This method attempts to reuse the same patterns as `@expo/webpack-config`.\n */\nexport async function createTemplateHtmlFromExpoConfigAsync(\n projectRoot: string,\n {\n scripts,\n cssLinks,\n exp = getConfig(projectRoot, { skipSDKVersionRequirement: true }).exp,\n }: {\n scripts: string[];\n cssLinks?: string[];\n exp?: ExpoConfig;\n }\n) {\n return createTemplateHtmlAsync(projectRoot, {\n langIsoCode: exp.web?.lang ?? 'en',\n scripts,\n cssLinks,\n title: getNameFromConfig(exp).webName ?? 'Expo App',\n description: exp.web?.description,\n themeColor: exp.web?.themeColor,\n });\n}\n\nfunction getFileFromLocalPublicFolder(\n projectRoot: string,\n { publicFolder, filePath }: { publicFolder: string; filePath: string }\n): string | null {\n const localFilePath = path.resolve(projectRoot, publicFolder, filePath);\n if (!fs.existsSync(localFilePath)) {\n return null;\n }\n return localFilePath;\n}\n\n/** Attempt to read the `index.html` from the local project before falling back on the template `index.html`. */\nasync function getTemplateIndexHtmlAsync(projectRoot: string): Promise<string> {\n let filePath = getFileFromLocalPublicFolder(projectRoot, {\n // TODO: Maybe use the app.json override.\n publicFolder: env.EXPO_PUBLIC_FOLDER,\n filePath: 'index.html',\n });\n if (!filePath) {\n filePath = TEMPLATES.find((value) => value.id === 'index.html')!.file(projectRoot);\n }\n return fs.promises.readFile(filePath, 'utf8');\n}\n\n/** Return an `index.html` string with template values added. */\nexport async function createTemplateHtmlAsync(\n projectRoot: string,\n {\n scripts,\n cssLinks,\n description,\n langIsoCode,\n title,\n themeColor,\n }: {\n scripts: string[];\n cssLinks?: string[];\n description?: string;\n langIsoCode: string;\n title: string;\n themeColor?: string;\n }\n): Promise<string> {\n // Resolve the best possible index.html template file.\n let contents = await getTemplateIndexHtmlAsync(projectRoot);\n\n contents = contents.replace('%LANG_ISO_CODE%', langIsoCode);\n contents = contents.replace('%WEB_TITLE%', title);\n\n contents = appendScriptsToHtml(contents, scripts);\n\n if (cssLinks) {\n contents = appendLinkToHtml(\n contents,\n cssLinks\n .map((href) => [\n // NOTE: We probably don't have to preload the CSS files for SPA-styled websites.\n {\n as: 'style',\n rel: 'preload',\n href,\n },\n {\n rel: 'stylesheet',\n href,\n },\n ])\n .flat()\n );\n }\n\n if (themeColor) {\n contents = addMeta(contents, `name=\"theme-color\" content=\"${themeColor}\"`);\n }\n\n if (description) {\n contents = addMeta(contents, `name=\"description\" content=\"${description}\"`);\n }\n\n return contents;\n}\n\n/** Add a `<meta />` tag to the `<head />` element. */\nfunction addMeta(contents: string, meta: string): string {\n return contents.replace('</head>', `<meta ${meta}>\\n</head>`);\n}\n"],"names":["createTemplateHtmlAsync","createTemplateHtmlFromExpoConfigAsync","projectRoot","scripts","cssLinks","exp","getConfig","skipSDKVersionRequirement","langIsoCode","web","lang","title","getNameFromConfig","webName","description","themeColor","getFileFromLocalPublicFolder","publicFolder","filePath","localFilePath","path","resolve","fs","existsSync","getTemplateIndexHtmlAsync","env","EXPO_PUBLIC_FOLDER","TEMPLATES","find","value","id","file","promises","readFile","contents","replace","appendScriptsToHtml","appendLinkToHtml","map","href","as","rel","flat","addMeta","meta"],"mappings":";;;;;;;;;;;IA2DsBA,uBAAuB;eAAvBA;;IA/CAC,qCAAqC;eAArCA;;;;yBAZmC;;;;;;;gEAC1C;;;;;;;gEACE;;;;;;2BAES;sBAC4B;qBAClC;;;;;;AAMb,eAAeA,sCACpBC,WAAmB,EACnB,EACEC,OAAO,EACPC,QAAQ,EACRC,MAAMC,IAAAA,mBAAS,EAACJ,aAAa;IAAEK,2BAA2B;AAAK,GAAGF,GAAG,EAKtE;QAGcA,UAIAA,WACDA;IANd,OAAOL,wBAAwBE,aAAa;QAC1CM,aAAaH,EAAAA,WAAAA,IAAII,GAAG,qBAAPJ,SAASK,IAAI,KAAI;QAC9BP;QACAC;QACAO,OAAOC,IAAAA,2BAAiB,EAACP,KAAKQ,OAAO,IAAI;QACzCC,WAAW,GAAET,YAAAA,IAAII,GAAG,qBAAPJ,UAASS,WAAW;QACjCC,UAAU,GAAEV,YAAAA,IAAII,GAAG,qBAAPJ,UAASU,UAAU;IACjC;AACF;AAEA,SAASC,6BACPd,WAAmB,EACnB,EAAEe,YAAY,EAAEC,QAAQ,EAA8C;IAEtE,MAAMC,gBAAgBC,eAAI,CAACC,OAAO,CAACnB,aAAae,cAAcC;IAC9D,IAAI,CAACI,aAAE,CAACC,UAAU,CAACJ,gBAAgB;QACjC,OAAO;IACT;IACA,OAAOA;AACT;AAEA,8GAA8G,GAC9G,eAAeK,0BAA0BtB,WAAmB;IAC1D,IAAIgB,WAAWF,6BAA6Bd,aAAa;QACvD,yCAAyC;QACzCe,cAAcQ,QAAG,CAACC,kBAAkB;QACpCR,UAAU;IACZ;IACA,IAAI,CAACA,UAAU;QACbA,WAAWS,oBAAS,CAACC,IAAI,CAAC,CAACC,QAAUA,MAAMC,EAAE,KAAK,cAAeC,IAAI,CAAC7B;IACxE;IACA,OAAOoB,aAAE,CAACU,QAAQ,CAACC,QAAQ,CAACf,UAAU;AACxC;AAGO,eAAelB,wBACpBE,WAAmB,EACnB,EACEC,OAAO,EACPC,QAAQ,EACRU,WAAW,EACXN,WAAW,EACXG,KAAK,EACLI,UAAU,EAQX;IAED,sDAAsD;IACtD,IAAImB,WAAW,MAAMV,0BAA0BtB;IAE/CgC,WAAWA,SAASC,OAAO,CAAC,mBAAmB3B;IAC/C0B,WAAWA,SAASC,OAAO,CAAC,eAAexB;IAE3CuB,WAAWE,IAAAA,yBAAmB,EAACF,UAAU/B;IAEzC,IAAIC,UAAU;QACZ8B,WAAWG,IAAAA,sBAAgB,EACzBH,UACA9B,SACGkC,GAAG,CAAC,CAACC,OAAS;gBACb,iFAAiF;gBACjF;oBACEC,IAAI;oBACJC,KAAK;oBACLF;gBACF;gBACA;oBACEE,KAAK;oBACLF;gBACF;aACD,EACAG,IAAI;IAEX;IAEA,IAAI3B,YAAY;QACdmB,WAAWS,QAAQT,UAAU,CAAC,4BAA4B,EAAEnB,WAAW,CAAC,CAAC;IAC3E;IAEA,IAAID,aAAa;QACfoB,WAAWS,QAAQT,UAAU,CAAC,4BAA4B,EAAEpB,YAAY,CAAC,CAAC;IAC5E;IAEA,OAAOoB;AACT;AAEA,oDAAoD,GACpD,SAASS,QAAQT,QAAgB,EAAEU,IAAY;IAC7C,OAAOV,SAASC,OAAO,CAAC,WAAW,CAAC,MAAM,EAAES,KAAK,UAAU,CAAC;AAC9D"}
1
+ {"version":3,"sources":["../../../../src/start/server/webTemplate.ts"],"sourcesContent":["import { ExpoConfig, getConfig, getNameFromConfig } from '@expo/config';\nimport fs from 'fs';\nimport path from 'path';\n\nimport { TEMPLATES } from '../../customize/templates';\nimport { appendLinkToHtml, appendScriptsToHtml } from '../../export/html';\nimport { getPublicFolderPath } from '../../export/publicFolder';\n\n/**\n * Create a static HTML for SPA styled websites.\n * This method attempts to reuse the same patterns as `@expo/webpack-config`.\n */\nexport async function createTemplateHtmlFromExpoConfigAsync(\n projectRoot: string,\n {\n scripts,\n cssLinks,\n exp = getConfig(projectRoot, { skipSDKVersionRequirement: true }).exp,\n }: {\n scripts: string[];\n cssLinks?: string[];\n exp?: ExpoConfig;\n }\n) {\n return createTemplateHtmlAsync(projectRoot, {\n langIsoCode: exp.web?.lang ?? 'en',\n scripts,\n cssLinks,\n title: getNameFromConfig(exp).webName ?? 'Expo App',\n description: exp.web?.description,\n themeColor: exp.web?.themeColor,\n });\n}\n\nfunction getFileFromLocalPublicFolder(\n projectRoot: string,\n { filePath }: { filePath: string }\n): string | null {\n const localFilePath = path.resolve(getPublicFolderPath(projectRoot), filePath);\n if (!fs.existsSync(localFilePath)) {\n return null;\n }\n return localFilePath;\n}\n\n/** Attempt to read the `index.html` from the local project before falling back on the template `index.html`. */\nasync function getTemplateIndexHtmlAsync(projectRoot: string): Promise<string> {\n let filePath = getFileFromLocalPublicFolder(projectRoot, {\n filePath: 'index.html',\n });\n if (!filePath) {\n filePath = TEMPLATES.find((value) => value.id === 'index.html')!.file(projectRoot);\n }\n return fs.promises.readFile(filePath, 'utf8');\n}\n\n/** Return an `index.html` string with template values added. */\nexport async function createTemplateHtmlAsync(\n projectRoot: string,\n {\n scripts,\n cssLinks,\n description,\n langIsoCode,\n title,\n themeColor,\n }: {\n scripts: string[];\n cssLinks?: string[];\n description?: string;\n langIsoCode: string;\n title: string;\n themeColor?: string;\n }\n): Promise<string> {\n // Resolve the best possible index.html template file.\n let contents = await getTemplateIndexHtmlAsync(projectRoot);\n\n contents = contents.replace('%LANG_ISO_CODE%', langIsoCode);\n contents = contents.replace('%WEB_TITLE%', title);\n\n contents = appendScriptsToHtml(contents, scripts);\n\n if (cssLinks) {\n contents = appendLinkToHtml(\n contents,\n cssLinks\n .map((href) => [\n // NOTE: We probably don't have to preload the CSS files for SPA-styled websites.\n {\n as: 'style',\n rel: 'preload',\n href,\n },\n {\n rel: 'stylesheet',\n href,\n },\n ])\n .flat()\n );\n }\n\n if (themeColor) {\n contents = addMeta(contents, `name=\"theme-color\" content=\"${themeColor}\"`);\n }\n\n if (description) {\n contents = addMeta(contents, `name=\"description\" content=\"${description}\"`);\n }\n\n return contents;\n}\n\n/** Add a `<meta />` tag to the `<head />` element. */\nfunction addMeta(contents: string, meta: string): string {\n return contents.replace('</head>', `<meta ${meta}>\\n</head>`);\n}\n"],"names":["createTemplateHtmlAsync","createTemplateHtmlFromExpoConfigAsync","projectRoot","scripts","cssLinks","exp","getConfig","skipSDKVersionRequirement","langIsoCode","web","lang","title","getNameFromConfig","webName","description","themeColor","getFileFromLocalPublicFolder","filePath","localFilePath","path","resolve","getPublicFolderPath","fs","existsSync","getTemplateIndexHtmlAsync","TEMPLATES","find","value","id","file","promises","readFile","contents","replace","appendScriptsToHtml","appendLinkToHtml","map","href","as","rel","flat","addMeta","meta"],"mappings":";;;;;;;;;;;IAyDsBA,uBAAuB;eAAvBA;;IA7CAC,qCAAqC;eAArCA;;;;yBAZmC;;;;;;;gEAC1C;;;;;;;gEACE;;;;;;2BAES;sBAC4B;8BAClB;;;;;;AAM7B,eAAeA,sCACpBC,WAAmB,EACnB,EACEC,OAAO,EACPC,QAAQ,EACRC,MAAMC,IAAAA,mBAAS,EAACJ,aAAa;IAAEK,2BAA2B;AAAK,GAAGF,GAAG,EAKtE;QAGcA,UAIAA,WACDA;IANd,OAAOL,wBAAwBE,aAAa;QAC1CM,aAAaH,EAAAA,WAAAA,IAAII,GAAG,qBAAPJ,SAASK,IAAI,KAAI;QAC9BP;QACAC;QACAO,OAAOC,IAAAA,2BAAiB,EAACP,KAAKQ,OAAO,IAAI;QACzCC,WAAW,GAAET,YAAAA,IAAII,GAAG,qBAAPJ,UAASS,WAAW;QACjCC,UAAU,GAAEV,YAAAA,IAAII,GAAG,qBAAPJ,UAASU,UAAU;IACjC;AACF;AAEA,SAASC,6BACPd,WAAmB,EACnB,EAAEe,QAAQ,EAAwB;IAElC,MAAMC,gBAAgBC,eAAI,CAACC,OAAO,CAACC,IAAAA,iCAAmB,EAACnB,cAAce;IACrE,IAAI,CAACK,aAAE,CAACC,UAAU,CAACL,gB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IGNING_SETTINGS_FILE_NAME = 'development-code-signing-se
118
118
  function getDevelopmentCodeSigningDirectory() {
119
119
  return _path().default.join((0, _UserSettings.getExpoHomeDirectory)(), 'codesigning');
120
120
  }
121
+ function assertBasenameValue(input) {
122
+ if (!input || input === '.' || input === '..' || input !== _path().default.basename(input)) {
123
+ throw new _errors.CommandError('Invalid EAS project ID for development code signing cache');
124
+ }
125
+ }
121
126
  function getProjectDevelopmentCodeSigningInfoFile(defaults) {
122
127
  function getFile(easProjectId) {
128
+ assertBasenameValue(easProjectId);
123
129
  const filePath = _path().default.join(getDevelopmentCodeSigningDirectory(), easProjectId, DEVELOPMENT_CODE_SIGNING_SETTINGS_FILE_NAME);
124
130
  return new (_jsonfile()).default(filePath);
125
131
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/utils/codesigning.ts"],"sourcesContent":["import {\n convertCertificatePEMToCertificate,\n convertKeyPairToPEM,\n convertCSRToCSRPEM,\n generateKeyPair,\n generateCSR,\n convertPrivateKeyPEMToPrivateKey,\n validateSelfSignedCertificate,\n signBufferRSASHA256AndVerify,\n} from '@expo/code-signing-certificates';\nimport { ExpoConfig } from '@expo/config';\nimport JsonFile, { JSONObject } from '@expo/json-file';\nimport { promises as fs } from 'fs';\nimport { pki as PKI } from 'node-forge';\nimport path from 'path';\nimport { Dictionary, parseDictionary } from 'structured-headers';\n\nimport { env } from './env';\nimport { CommandError } from './errors';\nimport { getExpoGoIntermediateCertificateAsync } from '../api/getExpoGoIntermediateCertificate';\nimport { getProjectDevelopmentCertificateAsync } from '../api/getProjectDevelopmentCertificate';\nimport { UnexpectedServerError, UnexpectedServerData } from '../api/graphql/client';\nimport { AppQuery, type App } from '../api/graphql/queries/AppQuery';\nimport { getExpoHomeDirectory } from '../api/user/UserSettings';\nimport { tryGetUserAsync } from '../api/user/actions';\nimport { Actor } from '../api/user/user';\nimport * as Log from '../log';\nimport { learnMore } from '../utils/link';\n\nconst debug = require('debug')('expo:codesigning') as typeof console.log;\n\nexport type CodeSigningInfo = {\n keyId: string;\n privateKey: string;\n certificateForPrivateKey: string;\n /**\n * Chain of certificates to serve in the manifest multipart body \"certificate_chain\" part.\n * The leaf certificate must be the 0th element of the array, followed by any intermediate certificates\n * necessary to evaluate the chain of trust ending in the implicitly trusted root certificate embedded in\n * the client.\n *\n * An empty array indicates that there is no need to serve the certificate chain in the multipart response.\n */\n certificateChainForResponse: string[];\n /**\n * Scope key cached for the project when certificate is development Expo Go code signing.\n * For project-specific code signing (keyId == the project's generated keyId) this is undefined.\n */\n scopeKey: string | null;\n};\n\ntype StoredDevelopmentExpoRootCodeSigningInfo = {\n easProjectId: string | null;\n scopeKey: string | null;\n privateKey: string | null;\n certificateChain: string[] | null;\n};\nconst DEVELOPMENT_CODE_SIGNING_SETTINGS_FILE_NAME = 'development-code-signing-settings-2.json';\n\nexport function getDevelopmentCodeSigningDirectory(): string {\n return path.join(getExpoHomeDirectory(), 'codesigning');\n}\n\nfunction getProjectDevelopmentCodeSigningInfoFile<T extends JSONObject>(defaults: T) {\n function getFile(easProjectId: string): JsonFile<T> {\n const filePath = path.join(\n getDevelopmentCodeSigningDirectory(),\n easProjectId,\n DEVELOPMENT_CODE_SIGNING_SETTINGS_FILE_NAME\n );\n return new JsonFile<T>(filePath);\n }\n\n async function readAsync(easProjectId: string): Promise<T> {\n let projectSettings;\n try {\n projectSettings = await getFile(easProjectId).readAsync();\n } catch {\n projectSettings = await getFile(easProjectId).writeAsync(defaults, { ensureDir: true });\n }\n // Set defaults for any missing fields\n return { ...defaults, ...projectSettings };\n }\n\n async function setAsync(easProjectId: string, json: Partial<T>): Promise<T> {\n try {\n return await getFile(easProjectId).mergeAsync(json, {\n cantReadFileDefault: defaults,\n });\n } catch {\n return await getFile(easProjectId).writeAsync(\n {\n ...defaults,\n ...json,\n },\n { ensureDir: true }\n );\n }\n }\n\n return {\n getFile,\n readAsync,\n setAsync,\n };\n}\n\nexport const DevelopmentCodeSigningInfoFile =\n getProjectDevelopmentCodeSigningInfoFile<StoredDevelopmentExpoRootCodeSigningInfo>({\n easProjectId: null,\n scopeKey: null,\n privateKey: null,\n certificateChain: null,\n });\n\n/**\n * Get info necessary to generate a response `expo-signature` header given a project and incoming request `expo-expect-signature` header.\n * This only knows how to serve two code signing keyids:\n * - `expo-root` indicates that it should use a development certificate in the `expo-root` chain. See {@link getExpoRootDevelopmentCodeSigningInfoAsync}\n * - <developer's expo-updates keyid> indicates that it should sign with the configured certificate. See {@link getProjectCodeSigningCertificateAsync}\n */\nexport async function getCodeSigningInfoAsync(\n exp: ExpoConfig,\n expectSignatureHeader: string | null,\n privateKeyPath: string | undefined\n): Promise<CodeSigningInfo | null> {\n if (!expectSignatureHeader) {\n return null;\n }\n\n let parsedExpectSignature: Dictionary;\n try {\n parsedExpectSignature = parseDictionary(expectSignatureHeader);\n } catch {\n throw new CommandError('Invalid value for expo-expect-signature header');\n }\n\n const expectedKeyIdOuter = parsedExpectSignature.get('keyid');\n if (!expectedKeyIdOuter) {\n throw new CommandError('keyid not present in expo-expect-signature header');\n }\n\n const expectedKeyId = expectedKeyIdOuter[0];\n if (typeof expectedKeyId !== 'string') {\n throw new CommandError(\n `Invalid value for keyid in expo-expect-signature header: ${expectedKeyId}`\n );\n }\n\n let expectedAlg: string | null = null;\n const expectedAlgOuter = parsedExpectSignature.get('alg');\n if (expectedAlgOuter) {\n const expectedAlgTemp = expectedAlgOuter[0];\n if (typeof expectedAlgTemp !== 'string') {\n throw new CommandError('Invalid value for alg in expo-expect-signature header');\n }\n expectedAlg = expectedAlgTemp;\n }\n\n if (expectedKeyId === 'expo-root') {\n return await getExpoRootDevelopmentCodeSigningInfoAsync(exp);\n } else if (expectedKeyId === 'expo-go') {\n throw new CommandError(\n 'Invalid certificate requested: cannot sign with embedded keyid=expo-go key'\n );\n } else {\n return await getProjectCodeSigningCertificateAsync(\n exp,\n privateKeyPath,\n expectedKeyId,\n expectedAlg\n );\n }\n}\n\n/**\n * Get a development code signing certificate for the expo-root -> expo-go -> (development certificate) certificate chain.\n * This requires the user be logged in and online, otherwise try to use the cached development certificate.\n */\nasync function getExpoRootDevelopmentCodeSigningInfoAsync(\n exp: ExpoConfig\n): Promise<CodeSigningInfo | null> {\n const easProjectId = exp.extra?.eas?.projectId;\n // can't check for scope key validity since scope key is derived on the server from projectId and we may be offline.\n // we rely upon the client certificate check to validate the scope key\n if (!easProjectId) {\n debug(\n `WARN: Expo Application Services (EAS) is not configured for your project. Configuring EAS enables a more secure development experience amongst many other benefits. ${learnMore(\n 'https://docs.expo.dev/eas/'\n )}`\n );\n return null;\n }\n\n const developmentCodeSigningInfoFromFile =\n await DevelopmentCodeSigningInfoFile.readAsync(easProjectId);\n const validatedCodeSigningInfo = validateStoredDevelopmentExpoRootCertificateCodeSigningInfo(\n developmentCodeSigningInfoFromFile,\n easProjectId\n );\n\n // 1. If online, ensure logged in, generate key pair and CSR, fetch and cache certificate chain for projectId\n // (overwriting existing dev cert in case projectId changed or it has expired)\n if (!env.EXPO_OFFLINE) {\n try {\n const newCodeSigningInfo =\n await fetchAndCacheNewDevelopmentCodeSigningInfoAsync(easProjectId);\n\n if (newCodeSigningInfo) {\n return newCodeSigningInfo;\n // fall back to cached certificate if we couldn't fetch a new one\n } else if (validatedCodeSigningInfo) {\n Log.warn(\n 'Could not fetch new Expo development certificate, falling back to cached certificate'\n );\n return validatedCodeSigningInfo;\n } else {\n return null;\n }\n } catch (e: any) {\n if (validatedCodeSigningInfo) {\n Log.warn(\n 'There was an error fetching the Expo development certificate, falling back to cached certificate'\n );\n return validatedCodeSigningInfo;\n } else {\n // need to return null here and say a message\n throw e;\n }\n }\n }\n\n // 2. check for cached cert/private key matching projectId and scopeKey of project, if found and valid return private key and cert chain including expo-go cert\n if (validatedCodeSigningInfo) {\n return validatedCodeSigningInfo;\n }\n\n // 3. if offline, return null\n Log.warn('Offline and no cached development certificate found, unable to sign manifest');\n return null;\n}\n\n/**\n * Get the certificate configured for expo-updates for this project.\n */\nasync function getProjectCodeSigningCertificateAsync(\n exp: ExpoConfig,\n privateKeyPath: string | undefined,\n expectedKeyId: string,\n expectedAlg: string | null\n): Promise<CodeSigningInfo | null> {\n const codeSigningCertificatePath = exp.updates?.codeSigningCertificate;\n if (!codeSigningCertificatePath) {\n return null;\n }\n\n if (!privateKeyPath) {\n throw new CommandError(\n 'Must specify --private-key-path argument to sign development manifest for requested code signing key'\n );\n }\n\n const codeSigningMetadata = exp.updates?.codeSigningMetadata;\n if (!codeSigningMetadata) {\n throw new CommandError(\n 'Must specify \"codeSigningMetadata\" under the \"updates\" field of your app config file to use EAS code signing'\n );\n }\n\n const { alg, keyid } = codeSigningMetadata;\n if (!alg || !keyid) {\n throw new CommandError(\n 'Must specify \"keyid\" and \"alg\" in the \"codeSigningMetadata\" field under the \"updates\" field of your app config file to use EAS code signing'\n );\n }\n\n if (expectedKeyId !== keyid) {\n throw new CommandError(`keyid mismatch: client=${expectedKeyId}, project=${keyid}`);\n }\n\n if (expectedAlg && expectedAlg !== alg) {\n throw new CommandError(`\"alg\" field mismatch (client=${expectedAlg}, project=${alg})`);\n }\n\n const { privateKeyPEM, certificatePEM } =\n await getProjectPrivateKeyAndCertificateFromFilePathsAsync({\n codeSigningCertificatePath,\n privateKeyPath,\n });\n\n return {\n keyId: keyid,\n privateKey: privateKeyPEM,\n certificateForPrivateKey: certificatePEM,\n certificateChainForResponse: [],\n scopeKey: null,\n };\n}\n\nasync function readFileWithErrorAsync(path: string, errorMessage: string): Promise<string> {\n try {\n return await fs.readFile(path, 'utf8');\n } catch {\n throw new CommandError(errorMessage);\n }\n}\n\nasync function getProjectPrivateKeyAndCertificateFromFilePathsAsync({\n codeSigningCertificatePath,\n privateKeyPath,\n}: {\n codeSigningCertificatePath: string;\n privateKeyPath: string;\n}): Promise<{ privateKeyPEM: string; certificatePEM: string }> {\n const [codeSigningCertificatePEM, privateKeyPEM] = await Promise.all([\n readFileWithErrorAsync(\n codeSigningCertificatePath,\n `Code signing certificate cannot be read from path: ${codeSigningCertificatePath}`\n ),\n readFileWithErrorAsync(\n privateKeyPath,\n `Code signing private key cannot be read from path: ${privateKeyPath}`\n ),\n ]);\n\n const privateKey = convertPrivateKeyPEMToPrivateKey(privateKeyPEM);\n const certificate = convertCertificatePEMToCertificate(codeSigningCertificatePEM);\n validateSelfSignedCertificate(certificate, {\n publicKey: certificate.publicKey as PKI.rsa.PublicKey,\n privateKey,\n });\n\n return { privateKeyPEM, certificatePEM: codeSigningCertificatePEM };\n}\n\n/**\n * Validate that the cached code signing info is still valid for the current project and\n * that it hasn't expired. If invalid, return null.\n */\nfunction validateStoredDevelopmentExpoRootCertificateCodeSigningInfo(\n codeSigningInfo: StoredDevelopmentExpoRootCodeSigningInfo,\n easProjectId: string\n): CodeSigningInfo | null {\n if (codeSigningInfo.easProjectId !== easProjectId) {\n return null;\n }\n\n const {\n privateKey: privateKeyPEM,\n certificateChain: certificatePEMs,\n scopeKey,\n } = codeSigningInfo;\n if (!privateKeyPEM || !certificatePEMs) {\n return null;\n }\n\n const certificateChain = certificatePEMs.map((certificatePEM) =>\n convertCertificatePEMToCertificate(certificatePEM)\n );\n\n // TODO(wschurman): maybe move to @expo/code-signing-certificates\n\n // ensure all intermediate certificates are valid\n for (const certificate of certificateChain) {\n const now = new Date();\n if (certificate.validity.notBefore > now || certificate.validity.notAfter < now) {\n return null;\n }\n }\n\n // TODO(wschurman): maybe do more validation, like validation of projectID and scopeKey within eas certificate extension\n\n return {\n keyId: 'expo-go',\n certificateChainForResponse: certificatePEMs,\n certificateForPrivateKey: certificatePEMs[0],\n privateKey: privateKeyPEM,\n scopeKey,\n };\n}\n\nfunction actorCanGetProjectDevelopmentCertificate(actor: Actor, app: App) {\n const owningAccountId = app.ownerAccount.id;\n\n const owningAccountIsActorPrimaryAccount =\n actor.__typename === 'User' || actor.__typename === 'SSOUser'\n ? actor.primaryAccount.id === owningAccountId\n : false;\n const userHasPublishPermissionForOwningAccount = !!actor.accounts\n .find((account) => account.id === owningAccountId)\n ?.users?.find((userPermission) => userPermission.actor.id === actor.id)\n ?.permissions?.includes('PUBLISH');\n return owningAccountIsActorPrimaryAccount || userHasPublishPermissionForOwningAccount;\n}\n\nasync function fetchAndCacheNewDevelopmentCodeSigningInfoAsync(\n easProjectId: string\n): Promise<CodeSigningInfo | null> {\n const actor = await tryGetUserAsync();\n\n if (!actor) {\n return null;\n }\n\n let app: App;\n try {\n app = await AppQuery.byIdAsync(easProjectId);\n } catch (e) {\n if (e instanceof UnexpectedServerError || e instanceof UnexpectedServerData) {\n return null;\n }\n throw e;\n }\n if (!actorCanGetProjectDevelopmentCertificate(actor, app)) {\n return null;\n }\n\n const keyPair = generateKeyPair();\n const keyPairPEM = convertKeyPairToPEM(keyPair);\n const csr = generateCSR(keyPair, `Development Certificate for ${easProjectId}`);\n const csrPEM = convertCSRToCSRPEM(csr);\n const [developmentSigningCertificate, expoGoIntermediateCertificate] = await Promise.all([\n getProjectDevelopmentCertificateAsync(easProjectId, csrPEM),\n getExpoGoIntermediateCertificateAsync(easProjectId),\n ]);\n\n await DevelopmentCodeSigningInfoFile.setAsync(easProjectId, {\n easProjectId,\n scopeKey: app.scopeKey,\n privateKey: keyPairPEM.privateKeyPEM,\n certificateChain: [developmentSigningCertificate, expoGoIntermediateCertificate],\n });\n\n return {\n keyId: 'expo-go',\n certificateChainForResponse: [developmentSigningCertificate, expoGoIntermediateCertificate],\n certificateForPrivateKey: developmentSigningCertificate,\n privateKey: keyPairPEM.privateKeyPEM,\n scopeKey: app.scopeKey,\n };\n}\n/**\n * Generate the `expo-signature` header for a manifest and code signing info.\n */\nexport function signManifestString(\n stringifiedManifest: string,\n codeSigningInfo: CodeSigningInfo\n): string {\n const privateKey = convertPrivateKeyPEMToPrivateKey(codeSigningInfo.privateKey);\n const certificate = convertCertificatePEMToCertificate(codeSigningInfo.certificateForPrivateKey);\n return signBufferRSASHA256AndVerify(\n privateKey,\n certificate,\n Buffer.from(stringifiedManifest, 'utf8')\n );\n}\n"],"names":["DevelopmentCodeSigningInfoFile","getCodeSigningInfoAsync","getDevelopmentCodeSigningDirectory","signManifestString","debug","require","DEVELOPMENT_CODE_SIGNING_SETTINGS_FILE_NAME","path","join","getExpoHomeDirectory","getProjectDevelopmentCodeSigningInfoFile","defaults","getFile","easProjectId","filePath","JsonFile","readAsync","projectSettings","writeAsync","ensureDir","setAsync","json","mergeAsync","cantReadFileDefault","scopeKey","privateKey","certificateChain","exp","expectSignatureHeader","privateKeyPath","parsedExpectSignature","parseDictionary","CommandError","expectedKeyIdOuter","get","expectedKeyId","expectedAlg","expectedAlgOuter","expectedAlgTemp","getExpoRootDevelopmentCodeSigningInfoAsync","getProjectCodeSigningCertificateAsync","extra","eas","projectId","learnMore","developmentCodeSigningInfoFromFile","validatedCodeSigningInfo","validateStoredDevelopmentExpoRootCertificateCodeSigningInfo","env","EXPO_OFFLINE","newCodeSigningInfo","fetchAndCacheNewDevelopmentCodeSigningInfoAsync","Log","warn","e","codeSigningCertificatePath","updates","codeSigningCertificate","codeSigningMetadata","alg","keyid","privateKeyPEM","certificatePEM","getProjectPrivateKeyAndCertificateFromFilePathsAsync","keyId","certificateForPrivateKey","certificateChainForResponse","readFileWithErrorAsync","errorMessage","fs","readFile","codeSigningCertificatePEM","Promise","all","convertPrivateKeyPEMToPrivateKey","certificate","convertCertificatePEMToCertificate","validateSelfSignedCertificate","publicKey","codeSigningInfo","certificatePEMs","map","now","Date","validity","notBefore","notAfter","actorCanGetProjectDevelopmentCertificate","actor","app","owningAccountId","ownerAccount","id","owningAccountIsActorPrimaryAccount","__typename","primaryAccount","userHasPublishPermissionForOwningAccount","accounts","find","account","users","userPermission","permissions","includes","tryGetUserAsync","AppQuery","byIdAsync","UnexpectedServerError","UnexpectedServerData","keyPair","generateKeyPair","keyPairPEM","convertKeyPairToPEM","csr","generateCSR","csrPEM","convertCSRToCSRPEM","developmentSigningCertificate","expoGoIntermediateCertificate","getProjectDevelopmentCertificateAsync","getExpoGoIntermediateCertificateAsync","stringifiedManifest","signBufferRSASHA256AndVerify","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FA,MAAM,MAAMgB,kBAAQ,CAACC,SAAS,CAAC7F;IACjC,EAAE,OAAOyC,GAAG;QACV,IAAIA,aAAaqD,6BAAqB,IAAIrD,aAAasD,4BAAoB,EAAE;YAC3E,OAAO;QACT;QACA,MAAMtD;IACR;IACA,IAAI,CAACiC,yCAAyCC,OAAOC,MAAM;QACzD,OAAO;IACT;IAEA,MAAMoB,UAAUC,IAAAA,0CAAe;IAC/B,MAAMC,aAAaC,IAAAA,8CAAmB,EAACH;IACvC,MAAMI,MAAMC,IAAAA,sCAAW,EAACL,SAAS,CAAC,4BAA4B,EAAEhG,cAAc;IAC9E,MAAMsG,SAASC,IAAAA,6CAAkB,EAACH;IAClC,MAAM,CAACI,+BAA+BC,8BAA8B,GAAG,MAAM9C,QAAQC,GAAG,CAAC;QACvF8C,IAAAA,uEAAqC,EAAC1G,cAAcsG;QACpDK,IAAAA,uEAAqC,EAAC3G;KACvC;IAED,MAAMb,+BAA+BoB,QAAQ,CAACP,cAAc;QAC1DA;QACAW,UAAUiE,IAAIjE,QAAQ;QACtBC,YAAYsF,WAAWlD,aAAa;QACpCnC,kBAAkB;YAAC2F;YAA+BC;SAA8B;IAClF;IAEA,OAAO;QACLtD,OAAO;QACPE,6BAA6B;YAACmD;YAA+BC;SAA8B;QAC3FrD,0BAA0BoD;QAC1B5F,YAAYsF,WAAWlD,aAAa;QACpCrC,UAAUiE,IAAIjE,QAAQ;IACxB;AACF;AAIO,SAASrB,mBACdsH,mBAA2B,EAC3B1C,eAAgC;IAEhC,MAAMtD,aAAaiD,IAAAA,2DAAgC,EAACK,gBAAgBtD,UAAU;IAC9E,MAAMkD,cAAcC,IAAAA,6DAAkC,EAACG,gBAAgBd,wBAAwB;IAC/F,OAAOyD,IAAAA,uDAA4B,EACjCjG,YACAkD,aACAgD,OAAOC,IAAI,CAACH,qBAAqB;AAErC"}
1
+ {"version":3,"sources":["../../../src/utils/codesigning.ts"],"sourcesContent":["import {\n convertCertificatePEMToCertificate,\n convertKeyPairToPEM,\n convertCSRToCSRPEM,\n generateKeyPair,\n generateCSR,\n convertPrivateKeyPEMToPrivateKey,\n validateSelfSignedCertificate,\n signBufferRSASHA256AndVerify,\n} from '@expo/code-signing-certificates';\nimport { ExpoConfig } from '@expo/config';\nimport JsonFile, { JSONObject } from '@expo/json-file';\nimport { promises as fs } from 'fs';\nimport { pki as PKI } from 'node-forge';\nimport path from 'path';\nimport { Dictionary, parseDictionary } from 'structured-headers';\n\nimport { env } from './env';\nimport { CommandError } from './errors';\nimport { getExpoGoIntermediateCertificateAsync } from '../api/getExpoGoIntermediateCertificate';\nimport { getProjectDevelopmentCertificateAsync } from '../api/getProjectDevelopmentCertificate';\nimport { UnexpectedServerError, UnexpectedServerData } from '../api/graphql/client';\nimport { AppQuery, type App } from '../api/graphql/queries/AppQuery';\nimport { getExpoHomeDirectory } from '../api/user/UserSettings';\nimport { tryGetUserAsync } from '../api/user/actions';\nimport { Actor } from '../api/user/user';\nimport * as Log from '../log';\nimport { learnMore } from '../utils/link';\n\nconst debug = require('debug')('expo:codesigning') as typeof console.log;\n\nexport type CodeSigningInfo = {\n keyId: string;\n privateKey: string;\n certificateForPrivateKey: string;\n /**\n * Chain of certificates to serve in the manifest multipart body \"certificate_chain\" part.\n * The leaf certificate must be the 0th element of the array, followed by any intermediate certificates\n * necessary to evaluate the chain of trust ending in the implicitly trusted root certificate embedded in\n * the client.\n *\n * An empty array indicates that there is no need to serve the certificate chain in the multipart response.\n */\n certificateChainForResponse: string[];\n /**\n * Scope key cached for the project when certificate is development Expo Go code signing.\n * For project-specific code signing (keyId == the project's generated keyId) this is undefined.\n */\n scopeKey: string | null;\n};\n\ntype StoredDevelopmentExpoRootCodeSigningInfo = {\n easProjectId: string | null;\n scopeKey: string | null;\n privateKey: string | null;\n certificateChain: string[] | null;\n};\nconst DEVELOPMENT_CODE_SIGNING_SETTINGS_FILE_NAME = 'development-code-signing-settings-2.json';\n\nexport function getDevelopmentCodeSigningDirectory(): string {\n return path.join(getExpoHomeDirectory(), 'codesigning');\n}\n\nfunction assertBasenameValue(input: string): void {\n if (!input || input === '.' || input === '..' || input !== path.basename(input)) {\n throw new CommandError('Invalid EAS project ID for development code signing cache');\n }\n}\n\nfunction getProjectDevelopmentCodeSigningInfoFile<T extends JSONObject>(defaults: T) {\n function getFile(easProjectId: string): JsonFile<T> {\n assertBasenameValue(easProjectId);\n const filePath = path.join(\n getDevelopmentCodeSigningDirectory(),\n easProjectId,\n DEVELOPMENT_CODE_SIGNING_SETTINGS_FILE_NAME\n );\n return new JsonFile<T>(filePath);\n }\n\n async function readAsync(easProjectId: string): Promise<T> {\n let projectSettings;\n try {\n projectSettings = await getFile(easProjectId).readAsync();\n } catch {\n projectSettings = await getFile(easProjectId).writeAsync(defaults, { ensureDir: true });\n }\n // Set defaults for any missing fields\n return { ...defaults, ...projectSettings };\n }\n\n async function setAsync(easProjectId: string, json: Partial<T>): Promise<T> {\n try {\n return await getFile(easProjectId).mergeAsync(json, {\n cantReadFileDefault: defaults,\n });\n } catch {\n return await getFile(easProjectId).writeAsync(\n {\n ...defaults,\n ...json,\n },\n { ensureDir: true }\n );\n }\n }\n\n return {\n getFile,\n readAsync,\n setAsync,\n };\n}\n\nexport const DevelopmentCodeSigningInfoFile =\n getProjectDevelopmentCodeSigningInfoFile<StoredDevelopmentExpoRootCodeSigningInfo>({\n easProjectId: null,\n scopeKey: null,\n privateKey: null,\n certificateChain: null,\n });\n\n/**\n * Get info necessary to generate a response `expo-signature` header given a project and incoming request `expo-expect-signature` header.\n * This only knows how to serve two code signing keyids:\n * - `expo-root` indicates that it should use a development certificate in the `expo-root` chain. See {@link getExpoRootDevelopmentCodeSigningInfoAsync}\n * - <developer's expo-updates keyid> indicates that it should sign with the configured certificate. See {@link getProjectCodeSigningCertificateAsync}\n */\nexport async function getCodeSigningInfoAsync(\n exp: ExpoConfig,\n expectSignatureHeader: string | null,\n privateKeyPath: string | undefined\n): Promise<CodeSigningInfo | null> {\n if (!expectSignatureHeader) {\n return null;\n }\n\n let parsedExpectSignature: Dictionary;\n try {\n parsedExpectSignature = parseDictionary(expectSignatureHeader);\n } catch {\n throw new CommandError('Invalid value for expo-expect-signature header');\n }\n\n const expectedKeyIdOuter = parsedExpectSignature.get('keyid');\n if (!expectedKeyIdOuter) {\n throw new CommandError('keyid not present in expo-expect-signature header');\n }\n\n const expectedKeyId = expectedKeyIdOuter[0];\n if (typeof expectedKeyId !== 'string') {\n throw new CommandError(\n `Invalid value for keyid in expo-expect-signature header: ${expectedKeyId}`\n );\n }\n\n let expectedAlg: string | null = null;\n const expectedAlgOuter = parsedExpectSignature.get('alg');\n if (expectedAlgOuter) {\n const expectedAlgTemp = expectedAlgOuter[0];\n if (typeof expectedAlgTemp !== 'string') {\n throw new CommandError('Invalid value for alg in expo-expect-signature header');\n }\n expectedAlg = expectedAlgTemp;\n }\n\n if (expectedKeyId === 'expo-root') {\n return await getExpoRootDevelopmentCodeSigningInfoAsync(exp);\n } else if (expectedKeyId === 'expo-go') {\n throw new CommandError(\n 'Invalid certificate requested: cannot sign with embedded keyid=expo-go key'\n );\n } else {\n return await getProjectCodeSigningCertificateAsync(\n exp,\n privateKeyPath,\n expectedKeyId,\n expectedAlg\n );\n }\n}\n\n/**\n * Get a development code signing certificate for the expo-root -> expo-go -> (development certificate) certificate chain.\n * This requires the user be logged in and online, otherwise try to use the cached development certificate.\n */\nasync function getExpoRootDevelopmentCodeSigningInfoAsync(\n exp: ExpoConfig\n): Promise<CodeSigningInfo | null> {\n const easProjectId = exp.extra?.eas?.projectId;\n // can't check for scope key validity since scope key is derived on the server from projectId and we may be offline.\n // we rely upon the client certificate check to validate the scope key\n if (!easProjectId) {\n debug(\n `WARN: Expo Application Services (EAS) is not configured for your project. Configuring EAS enables a more secure development experience amongst many other benefits. ${learnMore(\n 'https://docs.expo.dev/eas/'\n )}`\n );\n return null;\n }\n\n const developmentCodeSigningInfoFromFile =\n await DevelopmentCodeSigningInfoFile.readAsync(easProjectId);\n const validatedCodeSigningInfo = validateStoredDevelopmentExpoRootCertificateCodeSigningInfo(\n developmentCodeSigningInfoFromFile,\n easProjectId\n );\n\n // 1. If online, ensure logged in, generate key pair and CSR, fetch and cache certificate chain for projectId\n // (overwriting existing dev cert in case projectId changed or it has expired)\n if (!env.EXPO_OFFLINE) {\n try {\n const newCodeSigningInfo =\n await fetchAndCacheNewDevelopmentCodeSigningInfoAsync(easProjectId);\n\n if (newCodeSigningInfo) {\n return newCodeSigningInfo;\n // fall back to cached certificate if we couldn't fetch a new one\n } else if (validatedCodeSigningInfo) {\n Log.warn(\n 'Could not fetch new Expo development certificate, falling back to cached certificate'\n );\n return validatedCodeSigningInfo;\n } else {\n return null;\n }\n } catch (e: any) {\n if (validatedCodeSigningInfo) {\n Log.warn(\n 'There was an error fetching the Expo development certificate, falling back to cached certificate'\n );\n return validatedCodeSigningInfo;\n } else {\n // need to return null here and say a message\n throw e;\n }\n }\n }\n\n // 2. check for cached cert/private key matching projectId and scopeKey of project, if found and valid return private key and cert chain including expo-go cert\n if (validatedCodeSigningInfo) {\n return validatedCodeSigningInfo;\n }\n\n // 3. if offline, return null\n Log.warn('Offline and no cached development certificate found, unable to sign manifest');\n return null;\n}\n\n/**\n * Get the certificate configured for expo-updates for this project.\n */\nasync function getProjectCodeSigningCertificateAsync(\n exp: ExpoConfig,\n privateKeyPath: string | undefined,\n expectedKeyId: string,\n expectedAlg: string | null\n): Promise<CodeSigningInfo | null> {\n const codeSigningCertificatePath = exp.updates?.codeSigningCertificate;\n if (!codeSigningCertificatePath) {\n return null;\n }\n\n if (!privateKeyPath) {\n throw new CommandError(\n 'Must specify --private-key-path argument to sign development manifest for requested code signing key'\n );\n }\n\n const codeSigningMetadata = exp.updates?.codeSigningMetadata;\n if (!codeSigningMetadata) {\n throw new CommandError(\n 'Must specify \"codeSigningMetadata\" under the \"updates\" field of your app config file to use EAS code signing'\n );\n }\n\n const { alg, keyid } = codeSigningMetadata;\n if (!alg || !keyid) {\n throw new CommandError(\n 'Must specify \"keyid\" and \"alg\" in the \"codeSigningMetadata\" field under the \"updates\" field of your app config file to use EAS code signing'\n );\n }\n\n if (expectedKeyId !== keyid) {\n throw new CommandError(`keyid mismatch: client=${expectedKeyId}, project=${keyid}`);\n }\n\n if (expectedAlg && expectedAlg !== alg) {\n throw new CommandError(`\"alg\" field mismatch (client=${expectedAlg}, project=${alg})`);\n }\n\n const { privateKeyPEM, certificatePEM } =\n await getProjectPrivateKeyAndCertificateFromFilePathsAsync({\n codeSigningCertificatePath,\n privateKeyPath,\n });\n\n return {\n keyId: keyid,\n privateKey: privateKeyPEM,\n certificateForPrivateKey: certificatePEM,\n certificateChainForResponse: [],\n scopeKey: null,\n };\n}\n\nasync function readFileWithErrorAsync(path: string, errorMessage: string): Promise<string> {\n try {\n return await fs.readFile(path, 'utf8');\n } catch {\n throw new CommandError(errorMessage);\n }\n}\n\nasync function getProjectPrivateKeyAndCertificateFromFilePathsAsync({\n codeSigningCertificatePath,\n privateKeyPath,\n}: {\n codeSigningCertificatePath: string;\n privateKeyPath: string;\n}): Promise<{ privateKeyPEM: string; certificatePEM: string }> {\n const [codeSigningCertificatePEM, privateKeyPEM] = await Promise.all([\n readFileWithErrorAsync(\n codeSigningCertificatePath,\n `Code signing certificate cannot be read from path: ${codeSigningCertificatePath}`\n ),\n readFileWithErrorAsync(\n privateKeyPath,\n `Code signing private key cannot be read from path: ${privateKeyPath}`\n ),\n ]);\n\n const privateKey = convertPrivateKeyPEMToPrivateKey(privateKeyPEM);\n const certificate = convertCertificatePEMToCertificate(codeSigningCertificatePEM);\n validateSelfSignedCertificate(certificate, {\n publicKey: certificate.publicKey as PKI.rsa.PublicKey,\n privateKey,\n });\n\n return { privateKeyPEM, certificatePEM: codeSigningCertificatePEM };\n}\n\n/**\n * Validate that the cached code signing info is still valid for the current project and\n * that it hasn't expired. If invalid, return null.\n */\nfunction validateStoredDevelopmentExpoRootCertificateCodeSigningInfo(\n codeSigningInfo: StoredDevelopmentExpoRootCodeSigningInfo,\n easProjectId: string\n): CodeSigningInfo | null {\n if (codeSigningInfo.easProjectId !== easProjectId) {\n return null;\n }\n\n const {\n privateKey: privateKeyPEM,\n certificateChain: certificatePEMs,\n scopeKey,\n } = codeSigningInfo;\n if (!privateKeyPEM || !certificatePEMs) {\n return null;\n }\n\n const certificateChain = certificatePEMs.map((certificatePEM) =>\n convertCertificatePEMToCertificate(certificatePEM)\n );\n\n // TODO(wschurman): maybe move to @expo/code-signing-certificates\n\n // ensure all intermediate certificates are valid\n for (const certificate of certificateChain) {\n const now = new Date();\n if (certificate.validity.notBefore > now || certificate.validity.notAfter < now) {\n return null;\n }\n }\n\n // TODO(wschurman): maybe do more validation, like validation of projectID and scopeKey within eas certificate extension\n\n return {\n keyId: 'expo-go',\n certificateChainForResponse: certificatePEMs,\n certificateForPrivateKey: certificatePEMs[0],\n privateKey: privateKeyPEM,\n scopeKey,\n };\n}\n\nfunction actorCanGetProjectDevelopmentCertificate(actor: Actor, app: App) {\n const owningAccountId = app.ownerAccount.id;\n\n const owningAccountIsActorPrimaryAccount =\n actor.__typename === 'User' || actor.__typename === 'SSOUser'\n ? actor.primaryAccount.id === owningAccountId\n : false;\n const userHasPublishPermissionForOwningAccount = !!actor.accounts\n .find((account) => account.id === owningAccountId)\n ?.users?.find((userPermission) => userPermission.actor.id === actor.id)\n ?.permissions?.includes('PUBLISH');\n return owningAccountIsActorPrimaryAccount || userHasPublishPermissionForOwningAccount;\n}\n\nasync function fetchAndCacheNewDevelopmentCodeSigningInfoAsync(\n easProjectId: string\n): Promise<CodeSigningInfo | null> {\n const actor = await tryGetUserAsync();\n\n if (!actor) {\n return null;\n }\n\n let app: App;\n try {\n app = await AppQuery.byIdAsync(easProjectId);\n } catch (e) {\n if (e instanceof UnexpectedServerError || e instanceof UnexpectedServerData) {\n return null;\n }\n throw e;\n }\n if (!actorCanGetProjectDevelopmentCertificate(actor, app)) {\n return null;\n }\n\n const keyPair = generateKeyPair();\n const keyPairPEM = convertKeyPairToPEM(keyPair);\n const csr = generateCSR(keyPair, `Development Certificate for ${easProjectId}`);\n const csrPEM = convertCSRToCSRPEM(csr);\n const [developmentSigningCertificate, expoGoIntermediateCertificate] = await Promise.all([\n getProjectDevelopmentCertificateAsync(easProjectId, csrPEM),\n getExpoGoIntermediateCertificateAsync(easProjectId),\n ]);\n\n await DevelopmentCodeSigningInfoFile.setAsync(easProjectId, {\n easProjectId,\n scopeKey: app.scopeKey,\n privateKey: keyPairPEM.privateKeyPEM,\n certificateChain: [developmentSigningCertificate, expoGoIntermediateCertificate],\n });\n\n return {\n keyId: 'expo-go',\n certificateChainForResponse: [developmentSigningCertificate, expoGoIntermediateCertificate],\n certificateForPrivateKey: developmentSigningCertificate,\n privateKey: keyPairPEM.privateKeyPEM,\n scopeKey: app.scopeKey,\n };\n}\n/**\n * Generate the `expo-signature` header for a manifest and code signing info.\n */\nexport function signManifestString(\n stringifiedManifest: string,\n codeSigningInfo: CodeSigningInfo\n): string {\n const privateKey = convertPrivateKeyPEMToPrivateKey(codeSigningInfo.privateKey);\n const certificate = convertCertificatePEMToCertificate(codeSigningInfo.certificateForPrivateKey);\n return signBufferRSASHA256AndVerify(\n privateKey,\n certificate,\n Buffer.from(stringifiedManifest, 'utf8')\n );\n}\n"],"names":["DevelopmentCodeSigningInfoFile","getCodeSigningInfoAsync","getDevelopmentCodeSigningDirectory","signManifestString","debug","require","DEVELOPMENT_CODE_SIGNING_SETTINGS_FILE_NAME","path","join","getExpoHomeDirectory","assertBasenameValue","input","basename","CommandError","getProjectDevelopmentCodeSigningInfoFile","defaults","getFile","easProjectId","filePath","JsonFile","readAsync","projectSettings","writeAsync","ensureDir","setAsync","json","mergeAsync","cantReadFileDefault","scopeKey","privateKey","certificateChain","exp","expectSignatureHeader","privateKeyPath","parsedExpectSignature","parseDictionary","expectedKeyIdOuter","get","expectedKeyId","expectedAlg","expectedAlgOuter","expectedAlgTemp","getExpoRootDevelopmentCodeSigningInfoAsync","getProjectCodeSigningCertificateAsync","extra","eas","projectId","learnMore","developmentCodeSigningInfoFromFile","validatedCodeSigningInfo","validateStoredDevelopmentExpoRootCertificateCodeSigningInfo","env","EXPO_OFFLINE","newCodeSigningInfo","fetchAndCacheNewDevelopmentCodeSigningInfoAsync","Log","warn","e","codeSigningCertificatePath","updates","codeSigningCertificate","codeSigningMetadata","alg","keyid","privateKeyPEM","certificatePEM","getProjectPrivateKeyAndCertificateFromFilePathsAsync","keyId","certificateForPrivateKey","certificateChainForResponse","readFileWithErrorAsync","errorMessage","fs","readFile","codeSigningCertificatePEM","Promise","all","convertPrivateKeyPEMToPrivateKey","certificate","convertCertificatePEMToCertificate","validateSelfSignedCertificate","publicKey","codeSigningInfo","certificatePEMs","map","now","Date","validity","notBefore","notAfter","actorCanGetProjectDevelopmentCertificate","actor","app","owningAccountId","ownerAccount","id","owningAccountIsActorPrimaryAccount","__typename","primaryAccount","userHasPublishPermissionForOwningAccount","accounts","find","account","users","userPermission","permissions","includes","tryGetUserAsync","AppQuery","byIdAsync","UnexpectedServerError","UnexpectedServerData","keyPair","generateKeyPair","keyPairPEM","convertKeyPairToPEM","csr","generateCSR","csrPEM","convertCSRToCSRPEM","developmentSigningCertificate","expoGoIntermediateCertificate","getProjectDevelopmentCertificateAsync","getExpoGoIntermediateCertificateAsync","stringifiedManifest","signBufferRSASHA256AndVerify","Buffer","from"],"mappings":";;;;;;;;;;;IAkHaA,8BAA8B;eAA9BA;;IAcSC,uBAAuB;eAAvBA;;IArENC,kCAAkC;eAAlCA;;IAwYAC,kBAAkB;eAAlBA;;;;yBA1bT;;;;;;;gEAE8B;;;;;;;yBACN;;;;;;;gEAEd;;;;;;;yBAC2B;;;;;;qBAExB;wBACS;kDACyB;kDACA;wBACM;0BACzB;8BACE;yBACL;6DAEX;sBACK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE1B,MAAMC,QAAQC,QAAQ,SAAS;AA4B/B,MAAMC,8CAA8C;AAE7C,SAASJ;IACd,OAAOK,eAAI,CA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AAMoB,UAAUC,IAAAA,0CAAe;IAC/B,MAAMC,aAAaC,IAAAA,8CAAmB,EAACH;IACvC,MAAMI,MAAMC,IAAAA,sCAAW,EAACL,SAAS,CAAC,4BAA4B,EAAE/F,cAAc;IAC9E,MAAMqG,SAASC,IAAAA,6CAAkB,EAACH;IAClC,MAAM,CAACI,+BAA+BC,8BAA8B,GAAG,MAAM9C,QAAQC,GAAG,CAAC;QACvF8C,IAAAA,uEAAqC,EAACzG,cAAcqG;QACpDK,IAAAA,uEAAqC,EAAC1G;KACvC;IAED,MAAMjB,+BAA+BwB,QAAQ,CAACP,cAAc;QAC1DA;QACAW,UAAUgE,IAAIhE,QAAQ;QACtBC,YAAYqF,WAAWlD,aAAa;QACpClC,kBAAkB;YAAC0F;YAA+BC;SAA8B;IAClF;IAEA,OAAO;QACLtD,OAAO;QACPE,6BAA6B;YAACmD;YAA+BC;SAA8B;QAC3FrD,0BAA0BoD;QAC1B3F,YAAYqF,WAAWlD,aAAa;QACpCpC,UAAUgE,IAAIhE,QAAQ;IACxB;AACF;AAIO,SAASzB,mBACdyH,mBAA2B,EAC3B1C,eAAgC;IAEhC,MAAMrD,aAAagD,IAAAA,2DAAgC,EAACK,gBAAgBrD,UAAU;IAC9E,MAAMiD,cAAcC,IAAAA,6DAAkC,EAACG,gBAAgBd,wBAAwB;IAC/F,OAAOyD,IAAAA,uDAA4B,EACjChG,YACAiD,aACAgD,OAAOC,IAAI,CAACH,qBAAqB;AAErC"}
@@ -14,6 +14,9 @@ _export(exports, {
14
14
  },
15
15
  isMatchingOrigin: function() {
16
16
  return isMatchingOrigin;
17
+ },
18
+ shouldThrottleRemoteDevCall: function() {
19
+ return shouldThrottleRemoteDevCall;
17
20
  }
18
21
  });
19
22
  const ipv6To4Prefix = '::ffff:';
@@ -39,5 +42,15 @@ const isMatchingOrigin = (request, serverBaseUrl)=>{
39
42
  const expectedHost = new URL(serverBaseUrl).host;
40
43
  return actualHost === expectedHost;
41
44
  };
45
+ const DEV_CALL_THROTTLE_MS = 2000;
46
+ let lastRemoteDevCallAt = 0;
47
+ const shouldThrottleRemoteDevCall = ()=>{
48
+ const now = Date.now();
49
+ if (now - lastRemoteDevCallAt < DEV_CALL_THROTTLE_MS) {
50
+ return true;
51
+ }
52
+ lastRemoteDevCallAt = now;
53
+ return false;
54
+ };
42
55
 
43
56
  //# sourceMappingURL=net.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/utils/net.ts"],"sourcesContent":["import type { IncomingHttpHeaders } from 'node:http';\nimport type { Socket } from 'node:net';\n\nconst ipv6To4Prefix = '::ffff:';\n\nexport const isLocalSocket = (socket: Socket): boolean => {\n let { localAddress, remoteAddress, remoteFamily } = socket;\n\n const isLoopbackRequest = localAddress && localAddress === remoteAddress;\n if (isLoopbackRequest) {\n return true;\n } else if (!remoteAddress || !remoteFamily) {\n return false;\n }\n\n if (remoteFamily === 'IPv6' && remoteAddress.startsWith(ipv6To4Prefix)) {\n remoteAddress = remoteAddress.slice(ipv6To4Prefix.length);\n }\n\n return remoteAddress === '::1' || remoteAddress.startsWith('127.');\n};\n\ninterface AbstractIncomingMessage {\n headers: IncomingHttpHeaders | Record<string, string | string[]>;\n}\n\nexport const isMatchingOrigin = (\n request: AbstractIncomingMessage,\n serverBaseUrl: string\n): boolean => {\n // NOTE(@kitten): The browser will always send an origin header for websocket upgrade connections\n if (!request.headers.origin) {\n return true;\n }\n const actualHost = new URL(`${request.headers.origin}`).host;\n const expectedHost = new URL(serverBaseUrl).host;\n return actualHost === expectedHost;\n};\n"],"names":["isLocalSocket","isMatchingOrigin","ipv6To4Prefix","socket","localAddress","remoteAddress","remoteFamily","isLoopbackRequest","startsWith","slice","length","request","serverBaseUrl","headers","origin","actualHost","URL","host","expectedHost"],"mappings":";;;;;;;;;;;IAKaA,aAAa;eAAbA;;IAqBAC,gBAAgB;eAAhBA;;;AAvBb,MAAMC,gBAAgB;AAEf,MAAMF,gBAAgB,CAACG;IAC5B,IAAI,EAAEC,YAAY,EAAEC,aAAa,EAAEC,YAAY,EAAE,GAAGH;IAEpD,MAAMI,oBAAoBH,gBAAgBA,iBAAiBC;IAC3D,IAAIE,mBAAmB;QACrB,OAAO;IACT,OAAO,IAAI,CAACF,iBAAiB,CAACC,cAAc;QAC1C,OAAO;IACT;IAEA,IAAIA,iBAAiB,UAAUD,cAAcG,UAAU,CAACN,gBAAgB;QACtEG,gBAAgBA,cAAcI,KAAK,CAACP,cAAcQ,MAAM;IAC1D;IAEA,OAAOL,kBAAkB,SAASA,cAAcG,UAAU,CAAC;AAC7D;AAMO,MAAMP,mBAAmB,CAC9BU,SACAC;IAEA,iGAAiG;IACjG,IAAI,CAACD,QAAQE,OAAO,CAACC,MAAM,EAAE;QAC3B,OAAO;IACT;IACA,MAAMC,aAAa,IAAIC,IAAI,GAAGL,QAAQE,OAAO,CAACC,MAAM,EAAE,EAAEG,IAAI;IAC5D,MAAMC,eAAe,IAAIF,IAAIJ,eAAeK,IAAI;IAChD,OAAOF,eAAeG;AACxB"}
1
+ {"version":3,"sources":["../../../src/utils/net.ts"],"sourcesContent":["import type { IncomingHttpHeaders } from 'node:http';\nimport type { Socket } from 'node:net';\n\nconst ipv6To4Prefix = '::ffff:';\n\nexport const isLocalSocket = (socket: Socket): boolean => {\n let { localAddress, remoteAddress, remoteFamily } = socket;\n\n const isLoopbackRequest = localAddress && localAddress === remoteAddress;\n if (isLoopbackRequest) {\n return true;\n } else if (!remoteAddress || !remoteFamily) {\n return false;\n }\n\n if (remoteFamily === 'IPv6' && remoteAddress.startsWith(ipv6To4Prefix)) {\n remoteAddress = remoteAddress.slice(ipv6To4Prefix.length);\n }\n\n return remoteAddress === '::1' || remoteAddress.startsWith('127.');\n};\n\ninterface AbstractIncomingMessage {\n headers: IncomingHttpHeaders | Record<string, string | string[]>;\n}\n\nexport const isMatchingOrigin = (\n request: AbstractIncomingMessage,\n serverBaseUrl: string\n): boolean => {\n // NOTE(@kitten): The browser will always send an origin header for websocket upgrade connections\n if (!request.headers.origin) {\n return true;\n }\n const actualHost = new URL(`${request.headers.origin}`).host;\n const expectedHost = new URL(serverBaseUrl).host;\n return actualHost === expectedHost;\n};\n\nconst DEV_CALL_THROTTLE_MS = 2_000;\nlet lastRemoteDevCallAt = 0;\n\n/** Process-wide throttle. Returns `true` if another call fired within the cooldown window. */\nexport const shouldThrottleRemoteDevCall = (): boolean => {\n const now = Date.now();\n if (now - lastRemoteDevCallAt < DEV_CALL_THROTTLE_MS) {\n return true;\n }\n lastRemoteDevCallAt = now;\n return false;\n};\n"],"names":["isLocalSocket","isMatchingOrigin","shouldThrottleRemoteDevCall","ipv6To4Prefix","socket","localAddress","remoteAddress","remoteFamily","isLoopbackRequest","startsWith","slice","length","request","serverBaseUrl","headers","origin","actualHost","URL","host","expectedHost","DEV_CALL_THROTTLE_MS","lastRemoteDevCallAt","now","Date"],"mappings":";;;;;;;;;;;IAKaA,aAAa;eAAbA;;IAqBAC,gBAAgB;eAAhBA;;IAiBAC,2BAA2B;eAA3BA;;;AAxCb,MAAMC,gBAAgB;AAEf,MAAMH,gBAAgB,CAACI;IAC5B,IAAI,EAAEC,YAAY,EAAEC,aAAa,EAAEC,YAAY,EAAE,GAAGH;IAEpD,MAAMI,oBAAoBH,gBAAgBA,iBAAiBC;IAC3D,IAAIE,mBAAmB;QACrB,OAAO;IACT,OAAO,IAAI,CAACF,iBAAiB,CAACC,cAAc;QAC1C,OAAO;IACT;IAEA,IAAIA,iBAAiB,UAAUD,cAAcG,UAAU,CAACN,gBAAgB;QACtEG,gBAAgBA,cAAcI,KAAK,CAACP,cAAcQ,MAAM;IAC1D;IAEA,OAAOL,kBAAkB,SAASA,cAAcG,UAAU,CAAC;AAC7D;AAMO,MAAMR,mBAAmB,CAC9BW,SACAC;IAEA,iGAAiG;IACjG,IAAI,CAACD,QAAQE,OAAO,CAACC,MAAM,EAAE;QAC3B,OAAO;IACT;IACA,MAAMC,aAAa,IAAIC,IAAI,GAAGL,QAAQE,OAAO,CAACC,MAAM,EAAE,EAAEG,IAAI;IAC5D,MAAMC,eAAe,IAAIF,IAAIJ,eAAeK,IAAI;IAChD,OAAOF,eAAeG;AACxB;AAEA,MAAMC,uBAAuB;AAC7B,IAAIC,sBAAsB;AAGnB,MAAMnB,8BAA8B;IACzC,MAAMoB,MAAMC,KAAKD,GAAG;IACpB,IAAIA,MAAMD,sBAAsBD,sBAAsB;QACpD,OAAO;IACT;IACAC,sBAAsBC;IACtB,OAAO;AACT"}
@@ -71,8 +71,8 @@ class ChecksumStream extends TransformStream {
71
71
  return this.hash.digest(encoding);
72
72
  }
73
73
  }
74
- async function extractStream(input, output, options = {}) {
75
- output = _nodepath().default.resolve(output);
74
+ async function extractStream(input, targetOutput, options = {}) {
75
+ const output = _nodepath().default.resolve(targetOutput) + _nodepath().default.sep;
76
76
  await _nodefs().default.promises.mkdir(output, {
77
77
  recursive: true
78
78
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/utils/tar.ts"],"sourcesContent":["import { streamToAsyncIterable, TarTypeFlag, untar } from 'multitars';\nimport crypto from 'node:crypto';\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport { Readable } from 'node:stream';\n\nconst debug = require('debug')('expo:utils:tar') as typeof console.log;\n\nclass ChecksumStream extends TransformStream {\n hash: crypto.Hash;\n constructor(algorithm: string) {\n super({\n transform: (chunk, controller) => {\n this.hash.update(chunk);\n controller.enqueue(chunk);\n },\n });\n this.hash = crypto.createHash(algorithm);\n }\n\n digest(): Buffer;\n digest(encoding: crypto.BinaryToTextEncoding): string;\n digest(encoding?: crypto.BinaryToTextEncoding): string | Buffer {\n return this.hash.digest(encoding!);\n }\n}\n\nexport interface ExtractOptions {\n strip?: number;\n filter?(name: string, type: TarTypeFlag): boolean | null | undefined;\n rename?(name: string, type: TarTypeFlag): string | null | undefined;\n checksumAlgorithm?: string;\n}\n\nexport async function extractStream(\n input: ReadableStream,\n output: string,\n options: ExtractOptions = {}\n): Promise<string> {\n output = path.resolve(output);\n await fs.promises.mkdir(output, { recursive: true });\n\n const { checksumAlgorithm, strip = 0, rename, filter } = options;\n\n const checksumStream = new ChecksumStream(checksumAlgorithm || 'md5');\n const decompressionStream = new DecompressionStream('gzip');\n\n const body = input.pipeThrough(checksumStream).pipeThrough(decompressionStream);\n\n for await (const file of untar(body)) {\n let name = path.normalize(file.name);\n if (filter && !filter(name, file.typeflag)) {\n debug(`filtered: ${path.resolve(output, name)}`);\n continue;\n } else if (rename) {\n name = rename(name, file.typeflag) ?? name;\n }\n\n for (let idx = 0; idx < strip; idx++) {\n const sepIdx = name.indexOf(path.sep);\n if (sepIdx > -1) {\n name = name.slice(sepIdx + 1);\n } else {\n break;\n }\n }\n\n const resolved = path.resolve(output, name);\n if (!resolved.startsWith(output)) {\n debug(`skip: ${resolved}`);\n continue;\n }\n\n const parent = path.dirname(resolved);\n if (parent !== output) {\n let exists = false;\n try {\n const stat = await fs.promises.lstat(parent);\n if (stat.isSymbolicLink() || (!stat.isDirectory() && !stat.isFile())) {\n debug(`skip: ${resolved}`);\n continue;\n } else if (stat.isDirectory()) {\n exists = true;\n }\n } catch {}\n\n if (!exists) {\n debug(`mkdir(p): ${parent}`);\n await fs.promises.mkdir(parent, { recursive: true });\n }\n }\n\n switch (file.typeflag) {\n case TarTypeFlag.FILE:\n debug(`write(${file.mode.toString(8)}): ${resolved}`);\n await fs.promises.writeFile(resolved, streamToAsyncIterable(file.stream()), {\n mode: file.mode,\n });\n break;\n case TarTypeFlag.DIRECTORY:\n debug(`mkdir(${file.mode.toString(8)}): ${resolved}`);\n try {\n await fs.promises.mkdir(resolved, { mode: file.mode });\n } catch (error: any) {\n if (error.code !== 'EEXIST') {\n throw error;\n }\n }\n break;\n case TarTypeFlag.SYMLINK:\n case TarTypeFlag.LINK: {\n const target = path.resolve(parent, file.linkname ?? '');\n if (!target.startsWith(output) || target === parent) {\n debug(`skip: ${resolved} -> ${target}`);\n continue;\n }\n\n if (file.typeflag === TarTypeFlag.LINK) {\n debug(`link: ${resolved} -> ${target}`);\n await fs.promises.link(target, resolved);\n } else {\n const stat = await fs.promises.lstat(target).catch(() => null);\n const type = stat?.isDirectory() ? 'dir' : 'file';\n debug(`symlink(${type}): ${resolved} -> ${target}`);\n await fs.promises.symlink(target, resolved, type);\n }\n break;\n }\n }\n }\n\n return checksumStream.digest('hex');\n}\n\n/** Extract a tar using built-in tools if available and falling back on Node.js. */\nexport async function extractAsync(\n input: string,\n output: string,\n options?: ExtractOptions\n): Promise<void> {\n await extractStream(\n Readable.toWeb(fs.createReadStream(input)) as ReadableStream,\n output,\n options\n );\n}\n"],"names":["extractAsync","extractStream","debug","require","ChecksumStream","TransformStream","constructor","algorithm","transform","chunk","controller","hash","update","enqueue","crypto","createHash","digest","encoding","input","output","options","path","resolve","fs","promises","mkdir","recursive","checksumAlgorithm","strip","rename","filter","checksumStream","decompressionStream","DecompressionStream","body","pipeThrough","file","untar","name","normalize","typeflag","idx","sepIdx","indexOf","sep","slice","resolved","startsWith","parent","dirname","exists","stat","lstat","isSymbolicLink","isDirectory","isFile","TarTypeFlag","FILE","mode","toString","writeFile","streamToAsyncIterable","stream","DIRECTORY","error","code","SYMLINK","LINK","target","linkname","link","catch","type","symlink","Readable","toWeb","createReadStream"],"mappings":";;;;;;;;;;;IAuIsBA,YAAY;eAAZA;;IArGAC,aAAa;eAAbA;;;;yBAlCoC;;;;;;;gEACvC;;;;;;;gEACJ;;;;;;;gEACE;;;;;;;yBACQ;;;;;;;;;;;AAEzB,MAAMC,QAAQC,QAAQ,SAAS;AAE/B,MAAMC,uBAAuBC;IAE3BC,YAAYC,SAAiB,CAAE;QAC7B,KAAK,CAAC;YACJC,WAAW,CAACC,OAAOC;gBACjB,IAAI,CAACC,IAAI,CAACC,MAAM,CAACH;gBACjBC,WAAWG,OAAO,CAACJ;YACrB;QACF;QACA,IAAI,CAACE,IAAI,GAAGG,qBAAM,CAACC,UAAU,CAACR;IAChC;IAIAS,OAAOC,QAAsC,EAAmB;QAC9D,OAAO,IAAI,CAACN,IAAI,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mBAAI,CAACC,OAAO,CAAC0B,QAAQZ,KAAKiC,QAAQ,IAAI;oBACrD,IAAI,CAACD,OAAOrB,UAAU,CAAC5B,WAAWiD,WAAWpB,QAAQ;wBACnD9C,MAAM,CAAC,MAAM,EAAE4C,SAAS,IAAI,EAAEsB,QAAQ;wBACtC;oBACF;oBAEA,IAAIhC,KAAKI,QAAQ,KAAKgB,wBAAW,CAACW,IAAI,EAAE;wBACtCjE,MAAM,CAAC,MAAM,EAAE4C,SAAS,IAAI,EAAEsB,QAAQ;wBACtC,MAAM7C,iBAAE,CAACC,QAAQ,CAAC8C,IAAI,CAACF,QAAQtB;oBACjC,OAAO;wBACL,MAAMK,OAAO,MAAM5B,iBAAE,CAACC,QAAQ,CAAC4B,KAAK,CAACgB,QAAQG,KAAK,CAAC,IAAM;wBACzD,MAAMC,OAAOrB,CAAAA,wBAAAA,KAAMG,WAAW,MAAK,QAAQ;wBAC3CpD,MAAM,CAAC,QAAQ,EAAEsE,KAAK,GAAG,EAAE1B,SAAS,IAAI,EAAEsB,QAAQ;wBAClD,MAAM7C,iBAAE,CAACC,QAAQ,CAACiD,OAAO,CAACL,QAAQtB,UAAU0B;oBAC9C;oBACA;gBACF;QACF;IACF;IAEA,OAAOzC,eAAef,MAAM,CAAC;AAC/B;AAGO,eAAehB,aACpBkB,KAAa,EACbC,MAAc,EACdC,OAAwB;IAExB,MAAMnB,cACJyE,sBAAQ,CAACC,KAAK,CAACpD,iBAAE,CAACqD,gBAAgB,CAAC1D,SACnCC,QACAC;AAEJ"}
1
+ {"version":3,"sources":["../../../src/utils/tar.ts"],"sourcesContent":["import { streamToAsyncIterable, TarTypeFlag, untar } from 'multitars';\nimport crypto from 'node:crypto';\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport { Readable } from 'node:stream';\n\nconst debug = require('debug')('expo:utils:tar') as typeof console.log;\n\nclass ChecksumStream extends TransformStream {\n hash: crypto.Hash;\n constructor(algorithm: string) {\n super({\n transform: (chunk, controller) => {\n this.hash.update(chunk);\n controller.enqueue(chunk);\n },\n });\n this.hash = crypto.createHash(algorithm);\n }\n\n digest(): Buffer;\n digest(encoding: crypto.BinaryToTextEncoding): string;\n digest(encoding?: crypto.BinaryToTextEncoding): string | Buffer {\n return this.hash.digest(encoding!);\n }\n}\n\nexport interface ExtractOptions {\n strip?: number;\n filter?(name: string, type: TarTypeFlag): boolean | null | undefined;\n rename?(name: string, type: TarTypeFlag): string | null | undefined;\n checksumAlgorithm?: string;\n}\n\nexport async function extractStream(\n input: ReadableStream,\n targetOutput: string,\n options: ExtractOptions = {}\n): Promise<string> {\n const output = path.resolve(targetOutput) + path.sep;\n await fs.promises.mkdir(output, { recursive: true });\n\n const { checksumAlgorithm, strip = 0, rename, filter } = options;\n\n const checksumStream = new ChecksumStream(checksumAlgorithm || 'md5');\n const decompressionStream = new DecompressionStream('gzip');\n\n const body = input.pipeThrough(checksumStream).pipeThrough(decompressionStream);\n\n for await (const file of untar(body)) {\n let name = path.normalize(file.name);\n if (filter && !filter(name, file.typeflag)) {\n debug(`filtered: ${path.resolve(output, name)}`);\n continue;\n } else if (rename) {\n name = rename(name, file.typeflag) ?? name;\n }\n\n for (let idx = 0; idx < strip; idx++) {\n const sepIdx = name.indexOf(path.sep);\n if (sepIdx > -1) {\n name = name.slice(sepIdx + 1);\n } else {\n break;\n }\n }\n\n const resolved = path.resolve(output, name);\n if (!resolved.startsWith(output)) {\n debug(`skip: ${resolved}`);\n continue;\n }\n\n const parent = path.dirname(resolved);\n if (parent !== output) {\n let exists = false;\n try {\n const stat = await fs.promises.lstat(parent);\n if (stat.isSymbolicLink() || (!stat.isDirectory() && !stat.isFile())) {\n debug(`skip: ${resolved}`);\n continue;\n } else if (stat.isDirectory()) {\n exists = true;\n }\n } catch {}\n\n if (!exists) {\n debug(`mkdir(p): ${parent}`);\n await fs.promises.mkdir(parent, { recursive: true });\n }\n }\n\n switch (file.typeflag) {\n case TarTypeFlag.FILE:\n debug(`write(${file.mode.toString(8)}): ${resolved}`);\n await fs.promises.writeFile(resolved, streamToAsyncIterable(file.stream()), {\n mode: file.mode,\n });\n break;\n case TarTypeFlag.DIRECTORY:\n debug(`mkdir(${file.mode.toString(8)}): ${resolved}`);\n try {\n await fs.promises.mkdir(resolved, { mode: file.mode });\n } catch (error: any) {\n if (error.code !== 'EEXIST') {\n throw error;\n }\n }\n break;\n case TarTypeFlag.SYMLINK:\n case TarTypeFlag.LINK: {\n const target = path.resolve(parent, file.linkname ?? '');\n if (!target.startsWith(output) || target === parent) {\n debug(`skip: ${resolved} -> ${target}`);\n continue;\n }\n\n if (file.typeflag === TarTypeFlag.LINK) {\n debug(`link: ${resolved} -> ${target}`);\n await fs.promises.link(target, resolved);\n } else {\n const stat = await fs.promises.lstat(target).catch(() => null);\n const type = stat?.isDirectory() ? 'dir' : 'file';\n debug(`symlink(${type}): ${resolved} -> ${target}`);\n await fs.promises.symlink(target, resolved, type);\n }\n break;\n }\n }\n }\n\n return checksumStream.digest('hex');\n}\n\n/** Extract a tar using built-in tools if available and falling back on Node.js. */\nexport async function extractAsync(\n input: string,\n output: string,\n options?: ExtractOptions\n): Promise<void> {\n await extractStream(\n Readable.toWeb(fs.createReadStream(input)) as ReadableStream,\n output,\n options\n );\n}\n"],"names":["extractAsync","extractStream","debug","require","ChecksumStream","TransformStream","constructor","algorithm","transform","chunk","controller","hash","update","enqueue","crypto","createHash","digest","encoding","input","targetOutput","options","output","path","resolve","sep","fs","promises","mkdir","recursive","checksumAlgorithm","strip","rename","filter","checksumStream","decompressionStream","DecompressionStream","body","pipeThrough","file","untar","name","normalize","typeflag","idx","sepIdx","indexOf","slice","resolved","startsWith","parent","dirname","exists","stat","lstat","isSymbolicLink","isDirectory","isFile","TarTypeFlag","FILE","mode","toString","writeFile","streamToAsyncIterable","stream","DIRECTORY","error","code","SYMLINK","LINK","target","linkname","link","catch","type","symlink","Readable","toWeb","createReadStream"],"mappings":";;;;;;;;;;;IAuIsBA,YAAY;eAAZA;;IArGAC,aAAa;eAAb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MAAM,CAAC;AAC/B;AAGO,eAAehB,aACpBkB,KAAa,EACbG,MAAc,EACdD,OAAwB;IAExB,MAAMnB,cACJ0E,sBAAQ,CAACC,KAAK,CAACnD,iBAAE,CAACoD,gBAAgB,CAAC3D,SACnCG,QACAD;AAEJ"}
@@ -26,7 +26,7 @@ class FetchClient {
26
26
  this.headers = {
27
27
  accept: 'application/json',
28
28
  'content-type': 'application/json',
29
- 'user-agent': `expo-cli/${"55.0.30"}`,
29
+ 'user-agent': `expo-cli/${"55.0.32"}`,
30
30
  authorization: 'Basic ' + _nodebuffer().Buffer.from(`${target}:`).toString('base64')
31
31
  };
32
32
  }
@@ -83,7 +83,7 @@ function createContext() {
83
83
  cpu: summarizeCpuInfo(),
84
84
  app: {
85
85
  name: 'expo/cli',
86
- version: "55.0.30"
86
+ version: "55.0.32"
87
87
  },
88
88
  ci: _ciinfo().isCI ? {
89
89
  name: _ciinfo().name,
@@ -12,9 +12,6 @@ _export(exports, {
12
12
  isUrlAvailableAsync: function() {
13
13
  return isUrlAvailableAsync;
14
14
  },
15
- isUrlOk: function() {
16
- return isUrlOk;
17
- },
18
15
  stripExtension: function() {
19
16
  return stripExtension;
20
17
  },
@@ -39,7 +36,6 @@ function _url() {
39
36
  };
40
37
  return data;
41
38
  }
42
- const _client = require("../api/rest/client");
43
39
  function _interop_require_default(obj) {
44
40
  return obj && obj.__esModule ? obj : {
45
41
  default: obj
@@ -52,14 +48,6 @@ function isUrlAvailableAsync(url) {
52
48
  });
53
49
  });
54
50
  }
55
- async function isUrlOk(url) {
56
- try {
57
- const res = await (0, _client.fetchAsync)(url);
58
- return res.ok;
59
- } catch {
60
- return false;
61
- }
62
- }
63
51
  function validateUrl(urlString, { protocols, requireProtocol } = {}) {
64
52
  try {
65
53
  const results = new (_url()).URL(urlString);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/utils/url.ts"],"sourcesContent":["import dns from 'dns';\nimport { URL } from 'url';\n\nimport { fetchAsync } from '../api/rest/client';\n\n/** Check if a server is available based on the URL. */\nexport function isUrlAvailableAsync(url: string): Promise<boolean> {\n return new Promise<boolean>((resolve) => {\n dns.lookup(url, (err) => {\n resolve(!err);\n });\n });\n}\n\n/** Check if a request to the given URL is `ok` (status 200). */\nexport async function isUrlOk(url: string): Promise<boolean> {\n try {\n const res = await fetchAsync(url);\n return res.ok;\n } catch {\n return false;\n }\n}\n\n/** Determine if a string is a valid URL, can optionally ensure certain protocols (like `https` or `exp`) are adhered to. */\nexport function validateUrl(\n urlString: string,\n {\n protocols,\n requireProtocol,\n }: {\n /** Set of allowed protocols for the string to adhere to. @example ['exp', 'https'] */\n protocols?: string[];\n /** Ensure the URL has a protocol component (prefix before `://`). */\n requireProtocol?: boolean;\n } = {}\n) {\n try {\n const results = new URL(urlString);\n if (!results.protocol && !requireProtocol) {\n return true;\n }\n return protocols\n ? results.protocol\n ? protocols.map((x) => `${x.toLowerCase()}:`).includes(results.protocol)\n : false\n : true;\n } catch {\n return false;\n }\n}\n\n/** Remove the port from a given `host` URL string. */\nexport function stripPort(host?: string): string | null {\n return coerceUrl(host)?.hostname ?? null;\n}\n\nfunction coerceUrl(urlString?: string): URL | null {\n if (!urlString) {\n return null;\n }\n try {\n return new URL('/', urlString);\n } catch {\n return new URL('/', `http://${urlString}`);\n }\n}\n\n/** Strip a given extension from a URL string. */\nexport function stripExtension(url: string, extension: string): string {\n return url.replace(new RegExp(`.${extension}$`), '');\n}\n"],"names":["isUrlAvailableAsync","isUrlOk","stripExtension","stripPort","validateUrl","url","Promise","resolve","dns","lookup","err","res","fetchAsync","ok","urlString","protocols","requireProtocol","results","URL","protocol","map","x","toLowerCase","includes","host","coerceUrl","hostname","extension","replace","RegExp"],"mappings":";;;;;;;;;;;IAMgBA,mBAAmB;eAAnBA;;IASMC,OAAO;eAAPA;;IAsDNC,cAAc;eAAdA;;IAhBAC,SAAS;eAATA;;IA5BAC,WAAW;eAAXA;;;;gEAzBA;;;;;;;yBACI;;;;;;wBAEO;;;;;;AA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dns';\nimport { URL } from 'url';\n\n/** Check if a server is available based on the URL. */\nexport function isUrlAvailableAsync(url: string): Promise<boolean> {\n return new Promise<boolean>((resolve) => {\n dns.lookup(url, (err) => {\n resolve(!err);\n });\n });\n}\n\n/** Determine if a string is a valid URL, can optionally ensure certain protocols (like `https` or `exp`) are adhered to. */\nexport function validateUrl(\n urlString: string,\n {\n protocols,\n requireProtocol,\n }: {\n /** Set of allowed protocols for the string to adhere to. @example ['exp', 'https'] */\n protocols?: string[];\n /** Ensure the URL has a protocol component (prefix before `://`). */\n requireProtocol?: boolean;\n } = {}\n) {\n try {\n const results = new URL(urlString);\n if (!results.protocol && !requireProtocol) {\n return true;\n }\n return protocols\n ? results.protocol\n ? protocols.map((x) => `${x.toLowerCase()}:`).includes(results.protocol)\n : false\n : true;\n } catch {\n return false;\n }\n}\n\n/** Remove the port from a given `host` URL string. */\nexport function stripPort(host?: string): string | null {\n return coerceUrl(host)?.hostname ?? null;\n}\n\nfunction coerceUrl(urlString?: string): URL | null {\n if (!urlString) {\n return null;\n }\n try {\n return new URL('/', urlString);\n } catch {\n return new URL('/', `http://${urlString}`);\n }\n}\n\n/** Strip a given extension from a URL string. */\nexport function stripExtension(url: string, extension: string): string {\n return url.replace(new RegExp(`.${extension}$`), '');\n}\n"],"names":["isUrlAvailableAsync","stripExtension","stripPort","validateUrl","url","Promise","resolve","dns","lookup","err","urlString","protocols","requireProtocol","results","URL","protocol","map","x","toLowerCase","includes","host","coerceUrl","hostname","extension","replace","RegExp"],"mappings":";;;;;;;;;;;IAIgBA,mBAAmB;eAAnBA;;IAqDAC,cAAc;eAAdA;;IAhBAC,SAAS;eAATA;;IA5BAC,WAAW;eAAXA;;;;gEAbA;;;;;;;yBACI;;;;;;;;;;;AAGb,SAASH,oBAAoBI,GAAW;IAC7C,OAAO,IAAIC,QAAiB,CAACC;QAC3BC,cAAG,CAACC,MAAM,CAACJ,KAAK,CAACK;YACfH,QAAQ,CAACG;QACX;IACF;AACF;AAGO,SAASN,YACdO,SAAiB,EACjB,EACEC,SAAS,EACTC,eAAe,EAMhB,GAAG,CAAC,CAAC;IAEN,IAAI;QACF,MAAMC,UAAU,IAAIC,CAAAA,MAAE,KAAC,CAACJ;QACxB,IAAI,CAACG,QAAQE,QAAQ,IAAI,CAACH,iBAAiB;YACzC,OAAO;QACT;QACA,OAAOD,YACHE,QAAQE,QAAQ,GACdJ,UAAUK,GAAG,CAAC,CAACC,IAAM,GAAGA,EAAEC,WAAW,GAAG,CAAC,CAAC,EAAEC,QAAQ,CAACN,QAAQE,QAAQ,IACrE,QACF;IACN,EAAE,OAAM;QACN,OAAO;IACT;AACF;AAGO,SAASb,UAAUkB,IAAa;QAC9BC;IAAP,OAAOA,EAAAA,aAAAA,UAAUD,0BAAVC,WAAiBC,QAAQ,KAAI;AACtC;AAEA,SAASD,UAAUX,SAAkB;IACnC,IAAI,CAACA,WAAW;QACd,OAAO;IACT;IACA,IAAI;QACF,OAAO,IAAII,CAAAA,MAAE,KAAC,CAAC,KAAKJ;IACtB,EAAE,OAAM;QACN,OAAO,IAAII,CAAAA,MAAE,KAAC,CAAC,KAAK,CAAC,OAAO,EAAEJ,WAAW;IAC3C;AACF;AAGO,SAAST,eAAeG,GAAW,EAAEmB,SAAiB;IAC3D,OAAOnB,IAAIoB,OAAO,CAAC,IAAIC,OAAO,CAAC,CAAC,EAAEF,UAAU,CAAC,CAAC,GAAG;AACnD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@expo/cli",
3
- "version": "55.0.30",
3
+ "version": "55.0.32",
4
4
  "description": "The Expo CLI",
5
5
  "main": "build/bin/cli",
6
6
  "bin": {
@@ -42,20 +42,20 @@
42
42
  "dependencies": {
43
43
  "@expo/code-signing-certificates": "^0.0.6",
44
44
  "@expo/config": "~55.0.17",
45
- "@expo/config-plugins": "~55.0.9",
45
+ "@expo/config-plugins": "~55.0.10",
46
46
  "@expo/devcert": "^1.2.1",
47
47
  "@expo/env": "~2.1.2",
48
48
  "@expo/image-utils": "^0.8.14",
49
- "@expo/json-file": "^10.0.14",
49
+ "@expo/json-file": "^10.0.15",
50
50
  "@expo/log-box": "55.0.12",
51
51
  "@expo/metro": "~55.1.1",
52
- "@expo/metro-config": "~55.0.21",
53
- "@expo/osascript": "^2.4.3",
52
+ "@expo/metro-config": "~55.0.23",
53
+ "@expo/osascript": "^2.4.4",
54
54
  "@expo/package-manager": "^1.10.5",
55
- "@expo/plist": "^0.5.3",
55
+ "@expo/plist": "^0.5.4",
56
56
  "@expo/prebuild-config": "^55.0.18",
57
57
  "@expo/require-utils": "^55.0.5",
58
- "@expo/router-server": "^55.0.16",
58
+ "@expo/router-server": "^55.0.18",
59
59
  "@expo/schema-utils": "^55.0.4",
60
60
  "@expo/spawn-async": "^1.7.2",
61
61
  "@expo/ws-tunnel": "^1.0.1",
@@ -72,7 +72,7 @@
72
72
  "connect": "^3.7.0",
73
73
  "debug": "^4.3.4",
74
74
  "dnssd-advertise": "^1.1.4",
75
- "expo-server": "^55.0.9",
75
+ "expo-server": "^55.0.11",
76
76
  "fetch-nodeshim": "^0.4.10",
77
77
  "getenv": "^2.0.0",
78
78
  "glob": "^13.0.0",
@@ -158,5 +158,5 @@
158
158
  "tree-kill": "^1.2.2",
159
159
  "tsd": "^0.28.1"
160
160
  },
161
- "gitHead": "0675db12d13a5309e3109e8ecf7f6011522194c6"
161
+ "gitHead": "bb1d4bd298e5bcaff86b04aabca7c56659e57138"
162
162
  }
@@ -205,7 +205,7 @@
205
205
  <title>Expo Start | Loading Page</title>
206
206
  </head>
207
207
  <body>
208
- <div id="alert"></div>
208
+ <div id="alert" data-scheme="{{ Scheme }}"></div>
209
209
  <div class="logo-box">
210
210
  <div class="logo-background-box">
211
211
 
@@ -263,12 +263,20 @@
263
263
  <script>
264
264
  const alertElement = document.getElementById("alert");
265
265
 
266
+ const escapeHtml = (value) => value
267
+ .replace(/&/g, '&amp;')
268
+ .replace(/</g, '&lt;')
269
+ .replace(/>/g, '&gt;')
270
+ .replace(/"/g, '&quot;')
271
+ .replace(/'/g, '&#39;');
272
+
266
273
  const showAlert = (isExpoGo) => {
267
274
  if (isExpoGo) {
268
275
  alertElement.innerHTML = 'Unable to open in Expo Go. Please install <b>Expo Go</b> to continue.' +
269
276
  '<br><a href="https://expo.dev/client">Learn more.</a>';
270
277
  } else {
271
- alertElement.innerHTML = 'Unable to open in Development Build with the <b>{{ Scheme }}</b> scheme. Please build and install a compatible <b>Development Build</b> to continue.' +
278
+ const scheme = escapeHtml(alertElement.dataset.scheme || 'Unknown');
279
+ alertElement.innerHTML = 'Unable to open in Development Build with the <b>' + scheme + '</b> scheme. Please build and install a compatible <b>Development Build</b> to continue.' +
272
280
  '<br><a href="https://docs.expo.dev/development/build/">Learn more.</a>';
273
281
  }
274
282