@expo/cli 0.7.3 → 0.9.0

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 (200) hide show
  1. package/README.md +1 -1
  2. package/build/bin/cli +17 -3
  3. package/build/bin/cli.map +1 -1
  4. package/build/src/api/getExpoGoIntermediateCertificate.js +0 -2
  5. package/build/src/api/getExpoGoIntermediateCertificate.js.map +1 -1
  6. package/build/src/api/getProjectDevelopmentCertificate.js +0 -2
  7. package/build/src/api/getProjectDevelopmentCertificate.js.map +1 -1
  8. package/build/src/api/graphql/queries/AppQuery.js +39 -0
  9. package/build/src/api/graphql/queries/AppQuery.js.map +1 -0
  10. package/build/src/api/graphql/queries/UserQuery.js +10 -3
  11. package/build/src/api/graphql/queries/UserQuery.js.map +1 -1
  12. package/build/src/api/graphql/types/App.js +23 -0
  13. package/build/src/api/graphql/types/App.js.map +1 -0
  14. package/build/src/api/signManifest.js +0 -12
  15. package/build/src/api/signManifest.js.map +1 -1
  16. package/build/src/api/user/UserSettings.js.map +1 -1
  17. package/build/src/api/user/user.js.map +1 -1
  18. package/build/src/config/configAsync.js +3 -0
  19. package/build/src/config/configAsync.js.map +1 -1
  20. package/build/src/customize/customizeAsync.js +3 -0
  21. package/build/src/customize/customizeAsync.js.map +1 -1
  22. package/build/src/export/createBundles.js +8 -3
  23. package/build/src/export/createBundles.js.map +1 -1
  24. package/build/src/export/embed/exportEmbedAsync.js +23 -0
  25. package/build/src/export/embed/exportEmbedAsync.js.map +1 -0
  26. package/build/src/export/embed/index.js +117 -0
  27. package/build/src/export/embed/index.js.map +1 -0
  28. package/build/src/export/embed/resolveOptions.js +63 -0
  29. package/build/src/export/embed/resolveOptions.js.map +1 -0
  30. package/build/src/export/exportApp.js +58 -31
  31. package/build/src/export/exportApp.js.map +1 -1
  32. package/build/src/export/exportAssets.js +17 -0
  33. package/build/src/export/exportAssets.js.map +1 -1
  34. package/build/src/export/exportAsync.js +3 -0
  35. package/build/src/export/exportAsync.js.map +1 -1
  36. package/build/src/export/exportStaticAsync.js +179 -0
  37. package/build/src/export/exportStaticAsync.js.map +1 -0
  38. package/build/src/export/fork-bundleAsync.js +15 -43
  39. package/build/src/export/fork-bundleAsync.js.map +1 -1
  40. package/build/src/export/html.js +21 -0
  41. package/build/src/export/html.js.map +1 -0
  42. package/build/src/export/index.js +5 -1
  43. package/build/src/export/index.js.map +1 -1
  44. package/build/src/export/printBundleSizes.js +2 -2
  45. package/build/src/export/printBundleSizes.js.map +1 -1
  46. package/build/src/export/resolveOptions.js +1 -0
  47. package/build/src/export/resolveOptions.js.map +1 -1
  48. package/build/src/export/web/exportWebAsync.js +3 -0
  49. package/build/src/export/web/exportWebAsync.js.map +1 -1
  50. package/build/src/export/writeContents.js +5 -2
  51. package/build/src/export/writeContents.js.map +1 -1
  52. package/build/src/graphql/generated.js +462 -0
  53. package/build/src/graphql/generated.js.map +1 -0
  54. package/build/src/install/checkPackages.js +6 -0
  55. package/build/src/install/checkPackages.js.map +1 -1
  56. package/build/src/install/installAsync.js +18 -1
  57. package/build/src/install/installAsync.js.map +1 -1
  58. package/build/src/prebuild/clearNativeFolder.js +6 -1
  59. package/build/src/prebuild/clearNativeFolder.js.map +1 -1
  60. package/build/src/prebuild/copyTemplateFiles.js +3 -33
  61. package/build/src/prebuild/copyTemplateFiles.js.map +1 -1
  62. package/build/src/prebuild/ensureConfigAsync.js +1 -12
  63. package/build/src/prebuild/ensureConfigAsync.js.map +1 -1
  64. package/build/src/prebuild/prebuildAsync.js +7 -2
  65. package/build/src/prebuild/prebuildAsync.js.map +1 -1
  66. package/build/src/prebuild/resolveOptions.js +7 -8
  67. package/build/src/prebuild/resolveOptions.js.map +1 -1
  68. package/build/src/prebuild/resolveTemplate.js +5 -0
  69. package/build/src/prebuild/resolveTemplate.js.map +1 -1
  70. package/build/src/prebuild/updateFromTemplate.js +6 -8
  71. package/build/src/prebuild/updateFromTemplate.js.map +1 -1
  72. package/build/src/prebuild/updatePackageJson.js +33 -47
  73. package/build/src/prebuild/updatePackageJson.js.map +1 -1
  74. package/build/src/prebuild/validateTemplatePlatforms.js +48 -0
  75. package/build/src/prebuild/validateTemplatePlatforms.js.map +1 -0
  76. package/build/src/run/android/runAndroidAsync.js +4 -0
  77. package/build/src/run/android/runAndroidAsync.js.map +1 -1
  78. package/build/src/run/ios/appleDevice/AppleDevice.js +25 -19
  79. package/build/src/run/ios/appleDevice/AppleDevice.js.map +1 -1
  80. package/build/src/run/ios/appleDevice/client/InstallationProxyClient.js.map +1 -1
  81. package/build/src/run/ios/options/resolveNativeScheme.js +13 -4
  82. package/build/src/run/ios/options/resolveNativeScheme.js.map +1 -1
  83. package/build/src/run/ios/runIosAsync.js +3 -0
  84. package/build/src/run/ios/runIosAsync.js.map +1 -1
  85. package/build/src/run/startBundler.js +4 -0
  86. package/build/src/run/startBundler.js.map +1 -1
  87. package/build/src/start/doctor/Prerequisite.js.map +1 -1
  88. package/build/src/start/doctor/dependencies/ensureDependenciesAsync.js +12 -6
  89. package/build/src/start/doctor/dependencies/ensureDependenciesAsync.js.map +1 -1
  90. package/build/src/start/doctor/dependencies/getVersionedPackages.js +13 -2
  91. package/build/src/start/doctor/dependencies/getVersionedPackages.js.map +1 -1
  92. package/build/src/start/doctor/dependencies/validateDependenciesVersions.js +12 -4
  93. package/build/src/start/doctor/dependencies/validateDependenciesVersions.js.map +1 -1
  94. package/build/src/start/doctor/typescript/TypeScriptProjectPrerequisite.js +31 -5
  95. package/build/src/start/doctor/typescript/TypeScriptProjectPrerequisite.js.map +1 -1
  96. package/build/src/start/doctor/typescript/updateTSConfig.js +6 -0
  97. package/build/src/start/doctor/typescript/updateTSConfig.js.map +1 -1
  98. package/build/src/start/doctor/web/WebSupportProjectPrerequisite.js +1 -0
  99. package/build/src/start/doctor/web/WebSupportProjectPrerequisite.js.map +1 -1
  100. package/build/src/start/index.js +3 -1
  101. package/build/src/start/index.js.map +1 -1
  102. package/build/src/start/platforms/android/adb.js +1 -1
  103. package/build/src/start/platforms/android/adb.js.map +1 -1
  104. package/build/src/start/platforms/ios/AppleDeviceManager.js +1 -1
  105. package/build/src/start/platforms/ios/AppleDeviceManager.js.map +1 -1
  106. package/build/src/start/server/BundlerDevServer.js +16 -2
  107. package/build/src/start/server/BundlerDevServer.js.map +1 -1
  108. package/build/src/start/server/DevServerManager.js +33 -2
  109. package/build/src/start/server/DevServerManager.js.map +1 -1
  110. package/build/src/start/server/getStaticRenderFunctions.js +167 -0
  111. package/build/src/start/server/getStaticRenderFunctions.js.map +1 -0
  112. package/build/src/start/server/metro/MetroBundlerDevServer.js +262 -3
  113. package/build/src/start/server/metro/MetroBundlerDevServer.js.map +1 -1
  114. package/build/src/start/server/metro/MetroTerminalReporter.js +2 -34
  115. package/build/src/start/server/metro/MetroTerminalReporter.js.map +1 -1
  116. package/build/src/start/server/metro/externals.js +72 -0
  117. package/build/src/start/server/metro/externals.js.map +1 -0
  118. package/build/src/start/server/metro/getCssModulesFromBundler.js +77 -0
  119. package/build/src/start/server/metro/getCssModulesFromBundler.js.map +1 -0
  120. package/build/src/start/server/metro/inspector-proxy/index.js +2 -2
  121. package/build/src/start/server/metro/inspector-proxy/index.js.map +1 -1
  122. package/build/src/start/server/metro/inspector-proxy/proxy.js +1 -3
  123. package/build/src/start/server/metro/inspector-proxy/proxy.js.map +1 -1
  124. package/build/src/start/server/metro/instantiateMetro.js +47 -48
  125. package/build/src/start/server/metro/instantiateMetro.js.map +1 -1
  126. package/build/src/start/server/metro/metroErrorInterface.js +137 -0
  127. package/build/src/start/server/metro/metroErrorInterface.js.map +1 -0
  128. package/build/src/start/server/metro/metroWatchTypeScriptFiles.js +51 -0
  129. package/build/src/start/server/metro/metroWatchTypeScriptFiles.js.map +1 -0
  130. package/build/src/start/server/metro/resolveFromProject.js +26 -3
  131. package/build/src/start/server/metro/resolveFromProject.js.map +1 -1
  132. package/build/src/start/server/metro/router.js +15 -2
  133. package/build/src/start/server/metro/router.js.map +1 -1
  134. package/build/src/start/server/metro/runServer-fork.js +107 -0
  135. package/build/src/start/server/metro/runServer-fork.js.map +1 -0
  136. package/build/src/start/server/metro/symbolicate.js +6 -0
  137. package/build/src/start/server/metro/symbolicate.js.map +1 -0
  138. package/build/src/start/server/metro/waitForMetroToObserveTypeScriptFile.js +70 -0
  139. package/build/src/start/server/metro/waitForMetroToObserveTypeScriptFile.js.map +1 -0
  140. package/build/src/start/server/metro/withMetroMultiPlatform.js +188 -45
  141. package/build/src/start/server/metro/withMetroMultiPlatform.js.map +1 -1
  142. package/build/src/start/server/middleware/ClassicManifestMiddleware.js +8 -1
  143. package/build/src/start/server/middleware/ClassicManifestMiddleware.js.map +1 -1
  144. package/build/src/start/server/middleware/CreateFileMiddleware.js +6 -3
  145. package/build/src/start/server/middleware/CreateFileMiddleware.js.map +1 -1
  146. package/build/src/start/server/middleware/ExpoGoManifestHandlerMiddleware.js +113 -47
  147. package/build/src/start/server/middleware/ExpoGoManifestHandlerMiddleware.js.map +1 -1
  148. package/build/src/start/server/middleware/ManifestMiddleware.js +59 -20
  149. package/build/src/start/server/middleware/ManifestMiddleware.js.map +1 -1
  150. package/build/src/start/server/type-generation/expo-env.js +27 -0
  151. package/build/src/start/server/type-generation/expo-env.js.map +1 -0
  152. package/build/src/start/server/type-generation/index.js +57 -0
  153. package/build/src/start/server/type-generation/index.js.map +1 -0
  154. package/build/src/start/server/type-generation/routes.js +291 -0
  155. package/build/src/start/server/type-generation/routes.js.map +1 -0
  156. package/build/src/start/server/type-generation/tsconfig.js +89 -0
  157. package/build/src/start/server/type-generation/tsconfig.js.map +1 -0
  158. package/build/src/start/server/webTemplate.js +20 -4
  159. package/build/src/start/server/webTemplate.js.map +1 -1
  160. package/build/src/start/server/webpack/WebpackBundlerDevServer.js +4 -6
  161. package/build/src/start/server/webpack/WebpackBundlerDevServer.js.map +1 -1
  162. package/build/src/start/startAsync.js +30 -8
  163. package/build/src/start/startAsync.js.map +1 -1
  164. package/build/src/utils/FileNotifier.js +11 -4
  165. package/build/src/utils/FileNotifier.js.map +1 -1
  166. package/build/src/utils/analytics/getMetroProperties.js +1 -1
  167. package/build/src/utils/analytics/getMetroProperties.js.map +1 -1
  168. package/build/src/utils/analytics/rudderstackClient.js +2 -2
  169. package/build/src/utils/codesigning.js +31 -7
  170. package/build/src/utils/codesigning.js.map +1 -1
  171. package/build/src/utils/dir.js +16 -6
  172. package/build/src/utils/dir.js.map +1 -1
  173. package/build/src/utils/env.js +6 -0
  174. package/build/src/utils/env.js.map +1 -1
  175. package/build/src/utils/mergeGitIgnorePaths.js +42 -0
  176. package/build/src/utils/mergeGitIgnorePaths.js.map +1 -1
  177. package/build/src/utils/nodeEnv.js +11 -0
  178. package/build/src/utils/nodeEnv.js.map +1 -0
  179. package/build/src/utils/resolveArgs.js +43 -0
  180. package/build/src/utils/resolveArgs.js.map +1 -1
  181. package/build/src/utils/strings.js +24 -0
  182. package/build/src/utils/strings.js.map +1 -0
  183. package/build/src/utils/template.js +21 -0
  184. package/build/src/utils/template.js.map +1 -0
  185. package/build/src/utils/tsconfig/evaluateTsConfig.js +61 -0
  186. package/build/src/utils/tsconfig/evaluateTsConfig.js.map +1 -0
  187. package/build/src/utils/tsconfig/loadTsConfigPaths.js +69 -0
  188. package/build/src/utils/tsconfig/loadTsConfigPaths.js.map +1 -0
  189. package/build/src/utils/tsconfig/matchTsConfigPathAlias.js +88 -0
  190. package/build/src/utils/tsconfig/matchTsConfigPathAlias.js.map +1 -0
  191. package/build/src/utils/tsconfig/resolveWithTsConfigPaths.js +41 -0
  192. package/build/src/utils/tsconfig/resolveWithTsConfigPaths.js.map +1 -0
  193. package/package.json +16 -10
  194. package/static/template/metro.config.js +4 -1
  195. package/build/src/api/getProject.js +0 -19
  196. package/build/src/api/getProject.js.map +0 -1
  197. package/build/src/api/graphql/generated.js +0 -113
  198. package/build/src/api/graphql/generated.js.map +0 -1
  199. package/build/src/prebuild/writeMetroConfig.js +0 -89
  200. package/build/src/prebuild/writeMetroConfig.js.map +0 -1
@@ -2,21 +2,19 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
+ exports.ResponseContentType = void 0;
5
6
  var _configPlugins = require("@expo/config-plugins");
6
7
  var _accepts = _interopRequireDefault(require("accepts"));
7
- var _assert = _interopRequireDefault(require("assert"));
8
8
  var _crypto = _interopRequireDefault(require("crypto"));
9
9
  var _formData = _interopRequireDefault(require("form-data"));
10
10
  var _structuredHeaders = require("structured-headers");
11
- var _getProject = require("../../../api/getProject");
12
11
  var _settings = require("../../../api/settings");
13
- var _signManifest = require("../../../api/signManifest");
14
12
  var _userSettings = _interopRequireDefault(require("../../../api/user/UserSettings"));
15
13
  var _user = require("../../../api/user/user");
14
+ var Log = _interopRequireWildcard(require("../../../log"));
16
15
  var _rudderstackClient = require("../../../utils/analytics/rudderstackClient");
17
16
  var _codesigning = require("../../../utils/codesigning");
18
17
  var _errors = require("../../../utils/errors");
19
- var _fn = require("../../../utils/fn");
20
18
  var _url = require("../../../utils/url");
21
19
  var _manifestMiddleware = require("./ManifestMiddleware");
22
20
  var _resolvePlatform = require("./resolvePlatform");
@@ -25,7 +23,36 @@ function _interopRequireDefault(obj) {
25
23
  default: obj
26
24
  };
27
25
  }
26
+ function _interopRequireWildcard(obj) {
27
+ if (obj && obj.__esModule) {
28
+ return obj;
29
+ } else {
30
+ var newObj = {};
31
+ if (obj != null) {
32
+ for(var key in obj){
33
+ if (Object.prototype.hasOwnProperty.call(obj, key)) {
34
+ var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {};
35
+ if (desc.get || desc.set) {
36
+ Object.defineProperty(newObj, key, desc);
37
+ } else {
38
+ newObj[key] = obj[key];
39
+ }
40
+ }
41
+ }
42
+ }
43
+ newObj.default = obj;
44
+ return newObj;
45
+ }
46
+ }
28
47
  const debug = require("debug")("expo:start:server:middleware:ExpoGoManifestHandlerMiddleware");
48
+ var ResponseContentType;
49
+ exports.ResponseContentType = ResponseContentType;
50
+ (function(ResponseContentType) {
51
+ ResponseContentType[ResponseContentType["TEXT_PLAIN"] = 0] = "TEXT_PLAIN";
52
+ ResponseContentType[ResponseContentType["APPLICATION_JSON"] = 1] = "APPLICATION_JSON";
53
+ ResponseContentType[ResponseContentType["APPLICATION_EXPO_JSON"] = 2] = "APPLICATION_EXPO_JSON";
54
+ ResponseContentType[ResponseContentType["MULTIPART_MIXED"] = 3] = "MULTIPART_MIXED";
55
+ })(ResponseContentType || (exports.ResponseContentType = ResponseContentType = {}));
29
56
  class ExpoGoManifestHandlerMiddleware extends _manifestMiddleware.ManifestMiddleware {
30
57
  getParsedHeaders(req) {
31
58
  let platform = (0, _resolvePlatform).parsePlatformHeader(req);
@@ -39,15 +66,32 @@ class ExpoGoManifestHandlerMiddleware extends _manifestMiddleware.ManifestMiddle
39
66
  // URLs in a browser, we denote the response as "text/plain" if the user agent appears not to be
40
67
  // an Expo Updates client.
41
68
  const accept = (0, _accepts).default(req);
42
- const explicitlyPrefersMultipartMixed = accept.types([
69
+ const acceptedType = accept.types([
43
70
  "unknown/unknown",
44
- "multipart/mixed"
45
- ]) === "multipart/mixed";
71
+ "multipart/mixed",
72
+ "application/json",
73
+ "application/expo+json",
74
+ "text/plain",
75
+ ]);
76
+ let responseContentType;
77
+ switch(acceptedType){
78
+ case "multipart/mixed":
79
+ responseContentType = 3;
80
+ break;
81
+ case "application/json":
82
+ responseContentType = 1;
83
+ break;
84
+ case "application/expo+json":
85
+ responseContentType = 2;
86
+ break;
87
+ default:
88
+ responseContentType = 0;
89
+ break;
90
+ }
46
91
  const expectSignature = req.headers["expo-expect-signature"];
47
92
  return {
48
- explicitlyPrefersMultipartMixed,
93
+ responseContentType,
49
94
  platform,
50
- acceptSignature: this.getLegacyAcceptSignatureHeader(req),
51
95
  expectSignature: expectSignature ? String(expectSignature) : null,
52
96
  hostname: (0, _url).stripPort(req.headers["host"])
53
97
  };
@@ -75,12 +119,10 @@ class ExpoGoManifestHandlerMiddleware extends _manifestMiddleware.ManifestMiddle
75
119
  }
76
120
  const codeSigningInfo = await (0, _codesigning).getCodeSigningInfoAsync(exp, requestOptions.expectSignature, this.options.privateKeyPath);
77
121
  const easProjectId = (ref = exp.extra) == null ? void 0 : (ref1 = ref.eas) == null ? void 0 : ref1.projectId;
78
- const shouldUseAnonymousManifest = await shouldUseAnonymousManifestAsync(easProjectId, codeSigningInfo);
79
- const userAnonymousIdentifier = await _userSettings.default.getAnonymousIdentifierAsync();
80
- if (!shouldUseAnonymousManifest) {
81
- (0, _assert).default(easProjectId);
82
- }
83
- const scopeKey = shouldUseAnonymousManifest ? `@${_user.ANONYMOUS_USERNAME}/${exp.slug}-${userAnonymousIdentifier}` : await this.getScopeKeyForProjectIdAsync(easProjectId);
122
+ const scopeKey = await ExpoGoManifestHandlerMiddleware.getScopeKeyAsync({
123
+ slug: exp.slug,
124
+ codeSigningInfo
125
+ });
84
126
  const expoUpdatesManifest = {
85
127
  id: _crypto.default.randomUUID(),
86
128
  createdAt: new Date().toISOString(),
@@ -104,11 +146,6 @@ class ExpoGoManifestHandlerMiddleware extends _manifestMiddleware.ManifestMiddle
104
146
  scopeKey
105
147
  }
106
148
  };
107
- const headers = this.getDefaultResponseHeaders();
108
- if (requestOptions.acceptSignature && !shouldUseAnonymousManifest) {
109
- const manifestSignature = await this.getSignedManifestStringAsync(expoUpdatesManifest);
110
- headers.set("expo-manifest-signature", manifestSignature);
111
- }
112
149
  const stringifiedManifest = JSON.stringify(expoUpdatesManifest);
113
150
  let manifestPartHeaders = null;
114
151
  let certificateChainBody = null;
@@ -123,17 +160,51 @@ class ExpoGoManifestHandlerMiddleware extends _manifestMiddleware.ManifestMiddle
123
160
  };
124
161
  certificateChainBody = codeSigningInfo.certificateChainForResponse.join("\n");
125
162
  }
126
- const form = this.getFormData({
127
- stringifiedManifest,
128
- manifestPartHeaders,
129
- certificateChainBody
130
- });
131
- headers.set("content-type", requestOptions.explicitlyPrefersMultipartMixed ? `multipart/mixed; boundary=${form.getBoundary()}` : "text/plain");
132
- return {
133
- body: form.getBuffer().toString(),
134
- version: runtimeVersion,
135
- headers
136
- };
163
+ const headers = this.getDefaultResponseHeaders();
164
+ switch(requestOptions.responseContentType){
165
+ case 3:
166
+ {
167
+ const form = this.getFormData({
168
+ stringifiedManifest,
169
+ manifestPartHeaders,
170
+ certificateChainBody
171
+ });
172
+ headers.set("content-type", `multipart/mixed; boundary=${form.getBoundary()}`);
173
+ return {
174
+ body: form.getBuffer().toString(),
175
+ version: runtimeVersion,
176
+ headers
177
+ };
178
+ }
179
+ case 2:
180
+ case 1:
181
+ case 0:
182
+ {
183
+ headers.set("content-type", ExpoGoManifestHandlerMiddleware.getContentTypeForResponseContentType(requestOptions.responseContentType));
184
+ if (manifestPartHeaders) {
185
+ Object.entries(manifestPartHeaders).forEach(([key, value])=>{
186
+ headers.set(key, value);
187
+ });
188
+ }
189
+ return {
190
+ body: stringifiedManifest,
191
+ version: runtimeVersion,
192
+ headers
193
+ };
194
+ }
195
+ }
196
+ }
197
+ static getContentTypeForResponseContentType(responseContentType) {
198
+ switch(responseContentType){
199
+ case 3:
200
+ return "multipart/mixed";
201
+ case 2:
202
+ return "application/expo+json";
203
+ case 1:
204
+ return "application/json";
205
+ case 0:
206
+ return "text/plain";
207
+ }
137
208
  }
138
209
  getFormData({ stringifiedManifest , manifestPartHeaders , certificateChainBody }) {
139
210
  const form = new _formData.default();
@@ -155,24 +226,19 @@ class ExpoGoManifestHandlerMiddleware extends _manifestMiddleware.ManifestMiddle
155
226
  runtimeVersion: version
156
227
  });
157
228
  }
158
- getSignedManifestStringAsync = (0, _fn).memoize(_signManifest.signExpoGoManifestAsync);
159
- getScopeKeyForProjectIdAsync = (0, _fn).memoize(getScopeKeyForProjectIdAsync);
160
- }
161
- exports.ExpoGoManifestHandlerMiddleware = ExpoGoManifestHandlerMiddleware;
162
- /**
163
- * 1. No EAS project ID in config, then use anonymous scope key
164
- * 2. When offline or not logged in
165
- * a. If code signing not accepted by client (only legacy manifest signing is supported), then use anonymous scope key
166
- * b. If code signing accepted by client and no development code signing certificate is cached, then use anonymous scope key
167
- */ async function shouldUseAnonymousManifestAsync(easProjectId, codeSigningInfo) {
168
- if (!easProjectId || _settings.APISettings.isOffline && codeSigningInfo === null) {
169
- return true;
229
+ static async getScopeKeyAsync({ slug , codeSigningInfo }) {
230
+ const scopeKeyFromCodeSigningInfo = codeSigningInfo == null ? void 0 : codeSigningInfo.scopeKey;
231
+ if (scopeKeyFromCodeSigningInfo) {
232
+ return scopeKeyFromCodeSigningInfo;
233
+ }
234
+ Log.warn(_settings.APISettings.isOffline ? "Using anonymous scope key in manifest for offline mode." : "Using anonymous scope key in manifest.");
235
+ return await getAnonymousScopeKeyAsync(slug);
170
236
  }
171
- return !await (0, _user).getUserAsync();
172
237
  }
173
- async function getScopeKeyForProjectIdAsync(projectId) {
174
- const project = await (0, _getProject).getProjectAsync(projectId);
175
- return project.scopeKey;
238
+ exports.ExpoGoManifestHandlerMiddleware = ExpoGoManifestHandlerMiddleware;
239
+ async function getAnonymousScopeKeyAsync(slug) {
240
+ const userAnonymousIdentifier = await _userSettings.default.getAnonymousIdentifierAsync();
241
+ return `@${_user.ANONYMOUS_USERNAME}/${slug}-${userAnonymousIdentifier}`;
176
242
  }
177
243
  function convertToDictionaryItemsRepresentation(obj) {
178
244
  return new Map(Object.entries(obj).map(([k, v])=>{
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/start/server/middleware/ExpoGoManifestHandlerMiddleware.ts"],"sourcesContent":["import { ExpoUpdatesManifest } from '@expo/config';\nimport { Updates } from '@expo/config-plugins';\nimport accepts from 'accepts';\nimport assert from 'assert';\nimport crypto from 'crypto';\nimport FormData from 'form-data';\nimport { serializeDictionary, Dictionary } from 'structured-headers';\n\nimport { getProjectAsync } from '../../../api/getProject';\nimport { APISettings } from '../../../api/settings';\nimport { signExpoGoManifestAsync } from '../../../api/signManifest';\nimport UserSettings from '../../../api/user/UserSettings';\nimport { ANONYMOUS_USERNAME, getUserAsync } from '../../../api/user/user';\nimport { logEventAsync } from '../../../utils/analytics/rudderstackClient';\nimport {\n CodeSigningInfo,\n getCodeSigningInfoAsync,\n signManifestString,\n} from '../../../utils/codesigning';\nimport { CommandError } from '../../../utils/errors';\nimport { memoize } from '../../../utils/fn';\nimport { stripPort } from '../../../utils/url';\nimport { ManifestMiddleware, ManifestRequestInfo } from './ManifestMiddleware';\nimport { assertRuntimePlatform, parsePlatformHeader } from './resolvePlatform';\nimport { ServerHeaders, ServerRequest } from './server.types';\n\nconst debug = require('debug')('expo:start:server:middleware:ExpoGoManifestHandlerMiddleware');\n\ninterface ExpoGoManifestRequestInfo extends ManifestRequestInfo {\n explicitlyPrefersMultipartMixed: boolean;\n expectSignature: string | null;\n}\n\nexport class ExpoGoManifestHandlerMiddleware extends ManifestMiddleware<ExpoGoManifestRequestInfo> {\n public getParsedHeaders(req: ServerRequest): ExpoGoManifestRequestInfo {\n let platform = parsePlatformHeader(req);\n\n if (!platform) {\n debug(\n `No \"expo-platform\" header or \"platform\" query parameter specified. Falling back to \"none\".`\n );\n platform = 'none';\n }\n\n assertRuntimePlatform(platform);\n\n // Expo Updates clients explicitly accept \"multipart/mixed\" responses while browsers implicitly\n // accept them with \"accept: */*\". To make it easier to debug manifest responses by visiting their\n // URLs in a browser, we denote the response as \"text/plain\" if the user agent appears not to be\n // an Expo Updates client.\n const accept = accepts(req);\n const explicitlyPrefersMultipartMixed =\n accept.types(['unknown/unknown', 'multipart/mixed']) === 'multipart/mixed';\n\n const expectSignature = req.headers['expo-expect-signature'];\n\n return {\n explicitlyPrefersMultipartMixed,\n platform,\n acceptSignature: this.getLegacyAcceptSignatureHeader(req),\n expectSignature: expectSignature ? String(expectSignature) : null,\n hostname: stripPort(req.headers['host']),\n };\n }\n\n private getDefaultResponseHeaders(): ServerHeaders {\n const headers = new Map<string, number | string | readonly string[]>();\n // set required headers for Expo Updates manifest specification\n headers.set('expo-protocol-version', 0);\n headers.set('expo-sfv-version', 0);\n headers.set('cache-control', 'private, max-age=0');\n return headers;\n }\n\n public async _getManifestResponseAsync(requestOptions: ExpoGoManifestRequestInfo): Promise<{\n body: string;\n version: string;\n headers: ServerHeaders;\n }> {\n const { exp, hostUri, expoGoConfig, bundleUrl } = await this._resolveProjectSettingsAsync(\n requestOptions\n );\n\n const runtimeVersion = Updates.getRuntimeVersion(\n { ...exp, runtimeVersion: exp.runtimeVersion ?? { policy: 'sdkVersion' } },\n requestOptions.platform\n );\n if (!runtimeVersion) {\n throw new CommandError(\n 'MANIFEST_MIDDLEWARE',\n `Unable to determine runtime version for platform '${requestOptions.platform}'`\n );\n }\n\n const codeSigningInfo = await getCodeSigningInfoAsync(\n exp,\n requestOptions.expectSignature,\n this.options.privateKeyPath\n );\n\n const easProjectId = exp.extra?.eas?.projectId;\n const shouldUseAnonymousManifest = await shouldUseAnonymousManifestAsync(\n easProjectId,\n codeSigningInfo\n );\n const userAnonymousIdentifier = await UserSettings.getAnonymousIdentifierAsync();\n if (!shouldUseAnonymousManifest) {\n assert(easProjectId);\n }\n const scopeKey = shouldUseAnonymousManifest\n ? `@${ANONYMOUS_USERNAME}/${exp.slug}-${userAnonymousIdentifier}`\n : await this.getScopeKeyForProjectIdAsync(easProjectId);\n\n const expoUpdatesManifest: ExpoUpdatesManifest = {\n id: crypto.randomUUID(),\n createdAt: new Date().toISOString(),\n runtimeVersion,\n launchAsset: {\n key: 'bundle',\n contentType: 'application/javascript',\n url: bundleUrl,\n },\n assets: [], // assets are not used in development\n metadata: {}, // required for the client to detect that this is an expo-updates manifest\n extra: {\n eas: {\n projectId: easProjectId ?? undefined,\n },\n expoClient: {\n ...exp,\n hostUri,\n },\n expoGo: expoGoConfig,\n scopeKey,\n },\n };\n\n const headers = this.getDefaultResponseHeaders();\n if (requestOptions.acceptSignature && !shouldUseAnonymousManifest) {\n const manifestSignature = await this.getSignedManifestStringAsync(expoUpdatesManifest);\n headers.set('expo-manifest-signature', manifestSignature);\n }\n\n const stringifiedManifest = JSON.stringify(expoUpdatesManifest);\n\n let manifestPartHeaders: { 'expo-signature': string } | null = null;\n let certificateChainBody: string | null = null;\n if (codeSigningInfo) {\n const signature = signManifestString(stringifiedManifest, codeSigningInfo);\n manifestPartHeaders = {\n 'expo-signature': serializeDictionary(\n convertToDictionaryItemsRepresentation({\n keyid: codeSigningInfo.keyId,\n sig: signature,\n alg: 'rsa-v1_5-sha256',\n })\n ),\n };\n certificateChainBody = codeSigningInfo.certificateChainForResponse.join('\\n');\n }\n\n const form = this.getFormData({\n stringifiedManifest,\n manifestPartHeaders,\n certificateChainBody,\n });\n\n headers.set(\n 'content-type',\n requestOptions.explicitlyPrefersMultipartMixed\n ? `multipart/mixed; boundary=${form.getBoundary()}`\n : 'text/plain'\n );\n\n return {\n body: form.getBuffer().toString(),\n version: runtimeVersion,\n headers,\n };\n }\n\n private getFormData({\n stringifiedManifest,\n manifestPartHeaders,\n certificateChainBody,\n }: {\n stringifiedManifest: string;\n manifestPartHeaders: { 'expo-signature': string } | null;\n certificateChainBody: string | null;\n }): FormData {\n const form = new FormData();\n form.append('manifest', stringifiedManifest, {\n contentType: 'application/json',\n header: {\n ...manifestPartHeaders,\n },\n });\n if (certificateChainBody && certificateChainBody.length > 0) {\n form.append('certificate_chain', certificateChainBody, {\n contentType: 'application/x-pem-file',\n });\n }\n return form;\n }\n\n protected trackManifest(version?: string) {\n logEventAsync('Serve Expo Updates Manifest', {\n runtimeVersion: version,\n });\n }\n\n private getSignedManifestStringAsync = memoize(signExpoGoManifestAsync);\n\n private getScopeKeyForProjectIdAsync = memoize(getScopeKeyForProjectIdAsync);\n}\n\n/**\n * 1. No EAS project ID in config, then use anonymous scope key\n * 2. When offline or not logged in\n * a. If code signing not accepted by client (only legacy manifest signing is supported), then use anonymous scope key\n * b. If code signing accepted by client and no development code signing certificate is cached, then use anonymous scope key\n */\nasync function shouldUseAnonymousManifestAsync(\n easProjectId: string | undefined | null,\n codeSigningInfo: CodeSigningInfo | null\n): Promise<boolean> {\n if (!easProjectId || (APISettings.isOffline && codeSigningInfo === null)) {\n return true;\n }\n\n return !(await getUserAsync());\n}\n\nasync function getScopeKeyForProjectIdAsync(projectId: string): Promise<string> {\n const project = await getProjectAsync(projectId);\n return project.scopeKey;\n}\n\nfunction convertToDictionaryItemsRepresentation(obj: { [key: string]: string }): Dictionary {\n return new Map(\n Object.entries(obj).map(([k, v]) => {\n return [k, [v, new Map()]];\n })\n );\n}\n"],"names":["debug","require","ExpoGoManifestHandlerMiddleware","ManifestMiddleware","getParsedHeaders","req","platform","parsePlatformHeader","assertRuntimePlatform","accept","accepts","explicitlyPrefersMultipartMixed","types","expectSignature","headers","acceptSignature","getLegacyAcceptSignatureHeader","String","hostname","stripPort","getDefaultResponseHeaders","Map","set","_getManifestResponseAsync","requestOptions","exp","hostUri","expoGoConfig","bundleUrl","_resolveProjectSettingsAsync","runtimeVersion","Updates","getRuntimeVersion","policy","CommandError","codeSigningInfo","getCodeSigningInfoAsync","options","privateKeyPath","easProjectId","extra","eas","projectId","shouldUseAnonymousManifest","shouldUseAnonymousManifestAsync","userAnonymousIdentifier","UserSettings","getAnonymousIdentifierAsync","assert","scopeKey","ANONYMOUS_USERNAME","slug","getScopeKeyForProjectIdAsync","expoUpdatesManifest","id","crypto","randomUUID","createdAt","Date","toISOString","launchAsset","key","contentType","url","assets","metadata","undefined","expoClient","expoGo","manifestSignature","getSignedManifestStringAsync","stringifiedManifest","JSON","stringify","manifestPartHeaders","certificateChainBody","signature","signManifestString","serializeDictionary","convertToDictionaryItemsRepresentation","keyid","keyId","sig","alg","certificateChainForResponse","join","form","getFormData","getBoundary","body","getBuffer","toString","version","FormData","append","header","length","trackManifest","logEventAsync","memoize","signExpoGoManifestAsync","APISettings","isOffline","getUserAsync","project","getProjectAsync","obj","Object","entries","map","k","v"],"mappings":"AAAA;;;;AACwB,IAAA,cAAsB,WAAtB,sBAAsB,CAAA;AAC1B,IAAA,QAAS,kCAAT,SAAS,EAAA;AACV,IAAA,OAAQ,kCAAR,QAAQ,EAA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,GAAO,AAA8B,CAAA,QAA9B,CAAC/C,4BAA4B,CAAC,CAAC;CAC9E;QArLYlD,+BAA+B,GAA/BA,+BAA+B;AAuL5C;;;;;GAKG,CACH,eAAe0C,+BAA+B,CAC5CL,YAAuC,EACvCJ,eAAuC,EACrB;IAClB,IAAI,CAACI,YAAY,IAAK8D,SAAW,YAAA,CAACC,SAAS,IAAInE,eAAe,KAAK,IAAI,AAAC,EAAE;QACxE,OAAO,IAAI,CAAC;KACb;IAED,OAAO,CAAE,MAAMoE,CAAAA,GAAAA,KAAY,AAAE,CAAA,aAAF,EAAE,AAAC,CAAC;CAChC;AAED,eAAenD,4BAA4B,CAACV,SAAiB,EAAmB;IAC9E,MAAM8D,OAAO,GAAG,MAAMC,CAAAA,GAAAA,WAAe,AAAW,CAAA,gBAAX,CAAC/D,SAAS,CAAC,AAAC;IACjD,OAAO8D,OAAO,CAACvD,QAAQ,CAAC;CACzB;AAED,SAAS8B,sCAAsC,CAAC2B,GAA8B,EAAc;IAC1F,OAAO,IAAIrF,GAAG,CACZsF,MAAM,CAACC,OAAO,CAACF,GAAG,CAAC,CAACG,GAAG,CAAC,CAAC,CAACC,CAAC,EAAEC,CAAC,CAAC,GAAK;QAClC,OAAO;YAACD,CAAC;YAAE;gBAACC,CAAC;gBAAE,IAAI1F,GAAG,EAAE;aAAC;SAAC,CAAC;KAC5B,CAAC,CACH,CAAC;CACH"}
1
+ {"version":3,"sources":["../../../../../src/start/server/middleware/ExpoGoManifestHandlerMiddleware.ts"],"sourcesContent":["import { ExpoUpdatesManifest } from '@expo/config';\nimport { Updates } from '@expo/config-plugins';\nimport accepts from 'accepts';\nimport crypto from 'crypto';\nimport FormData from 'form-data';\nimport { serializeDictionary, Dictionary } from 'structured-headers';\n\nimport { APISettings } from '../../../api/settings';\nimport UserSettings from '../../../api/user/UserSettings';\nimport { ANONYMOUS_USERNAME } from '../../../api/user/user';\nimport * as Log from '../../../log';\nimport { logEventAsync } from '../../../utils/analytics/rudderstackClient';\nimport {\n CodeSigningInfo,\n getCodeSigningInfoAsync,\n signManifestString,\n} from '../../../utils/codesigning';\nimport { CommandError } from '../../../utils/errors';\nimport { stripPort } from '../../../utils/url';\nimport { ManifestMiddleware, ManifestRequestInfo } from './ManifestMiddleware';\nimport { assertRuntimePlatform, parsePlatformHeader } from './resolvePlatform';\nimport { ServerHeaders, ServerRequest } from './server.types';\n\nconst debug = require('debug')('expo:start:server:middleware:ExpoGoManifestHandlerMiddleware');\n\nexport enum ResponseContentType {\n TEXT_PLAIN,\n APPLICATION_JSON,\n APPLICATION_EXPO_JSON,\n MULTIPART_MIXED,\n}\n\ninterface ExpoGoManifestRequestInfo extends ManifestRequestInfo {\n responseContentType: ResponseContentType;\n expectSignature: string | null;\n}\n\nexport class ExpoGoManifestHandlerMiddleware extends ManifestMiddleware<ExpoGoManifestRequestInfo> {\n public getParsedHeaders(req: ServerRequest): ExpoGoManifestRequestInfo {\n let platform = parsePlatformHeader(req);\n\n if (!platform) {\n debug(\n `No \"expo-platform\" header or \"platform\" query parameter specified. Falling back to \"none\".`\n );\n platform = 'none';\n }\n\n assertRuntimePlatform(platform);\n\n // Expo Updates clients explicitly accept \"multipart/mixed\" responses while browsers implicitly\n // accept them with \"accept: */*\". To make it easier to debug manifest responses by visiting their\n // URLs in a browser, we denote the response as \"text/plain\" if the user agent appears not to be\n // an Expo Updates client.\n const accept = accepts(req);\n const acceptedType = accept.types([\n 'unknown/unknown',\n 'multipart/mixed',\n 'application/json',\n 'application/expo+json',\n 'text/plain',\n ]);\n\n let responseContentType;\n switch (acceptedType) {\n case 'multipart/mixed':\n responseContentType = ResponseContentType.MULTIPART_MIXED;\n break;\n case 'application/json':\n responseContentType = ResponseContentType.APPLICATION_JSON;\n break;\n case 'application/expo+json':\n responseContentType = ResponseContentType.APPLICATION_EXPO_JSON;\n break;\n default:\n responseContentType = ResponseContentType.TEXT_PLAIN;\n break;\n }\n\n const expectSignature = req.headers['expo-expect-signature'];\n\n return {\n responseContentType,\n platform,\n expectSignature: expectSignature ? String(expectSignature) : null,\n hostname: stripPort(req.headers['host']),\n };\n }\n\n private getDefaultResponseHeaders(): ServerHeaders {\n const headers = new Map<string, number | string | readonly string[]>();\n // set required headers for Expo Updates manifest specification\n headers.set('expo-protocol-version', 0);\n headers.set('expo-sfv-version', 0);\n headers.set('cache-control', 'private, max-age=0');\n return headers;\n }\n\n public async _getManifestResponseAsync(requestOptions: ExpoGoManifestRequestInfo): Promise<{\n body: string;\n version: string;\n headers: ServerHeaders;\n }> {\n const { exp, hostUri, expoGoConfig, bundleUrl } = await this._resolveProjectSettingsAsync(\n requestOptions\n );\n\n const runtimeVersion = Updates.getRuntimeVersion(\n { ...exp, runtimeVersion: exp.runtimeVersion ?? { policy: 'sdkVersion' } },\n requestOptions.platform\n );\n if (!runtimeVersion) {\n throw new CommandError(\n 'MANIFEST_MIDDLEWARE',\n `Unable to determine runtime version for platform '${requestOptions.platform}'`\n );\n }\n\n const codeSigningInfo = await getCodeSigningInfoAsync(\n exp,\n requestOptions.expectSignature,\n this.options.privateKeyPath\n );\n\n const easProjectId = exp.extra?.eas?.projectId as string | undefined | null;\n const scopeKey = await ExpoGoManifestHandlerMiddleware.getScopeKeyAsync({\n slug: exp.slug,\n codeSigningInfo,\n });\n\n const expoUpdatesManifest: ExpoUpdatesManifest = {\n id: crypto.randomUUID(),\n createdAt: new Date().toISOString(),\n runtimeVersion,\n launchAsset: {\n key: 'bundle',\n contentType: 'application/javascript',\n url: bundleUrl,\n },\n assets: [], // assets are not used in development\n metadata: {}, // required for the client to detect that this is an expo-updates manifest\n extra: {\n eas: {\n projectId: easProjectId ?? undefined,\n },\n expoClient: {\n ...exp,\n hostUri,\n },\n expoGo: expoGoConfig,\n scopeKey,\n },\n };\n\n const stringifiedManifest = JSON.stringify(expoUpdatesManifest);\n\n let manifestPartHeaders: { 'expo-signature': string } | null = null;\n let certificateChainBody: string | null = null;\n if (codeSigningInfo) {\n const signature = signManifestString(stringifiedManifest, codeSigningInfo);\n manifestPartHeaders = {\n 'expo-signature': serializeDictionary(\n convertToDictionaryItemsRepresentation({\n keyid: codeSigningInfo.keyId,\n sig: signature,\n alg: 'rsa-v1_5-sha256',\n })\n ),\n };\n certificateChainBody = codeSigningInfo.certificateChainForResponse.join('\\n');\n }\n\n const headers = this.getDefaultResponseHeaders();\n\n switch (requestOptions.responseContentType) {\n case ResponseContentType.MULTIPART_MIXED: {\n const form = this.getFormData({\n stringifiedManifest,\n manifestPartHeaders,\n certificateChainBody,\n });\n headers.set('content-type', `multipart/mixed; boundary=${form.getBoundary()}`);\n return {\n body: form.getBuffer().toString(),\n version: runtimeVersion,\n headers,\n };\n }\n case ResponseContentType.APPLICATION_EXPO_JSON:\n case ResponseContentType.APPLICATION_JSON:\n case ResponseContentType.TEXT_PLAIN: {\n headers.set(\n 'content-type',\n ExpoGoManifestHandlerMiddleware.getContentTypeForResponseContentType(\n requestOptions.responseContentType\n )\n );\n if (manifestPartHeaders) {\n Object.entries(manifestPartHeaders).forEach(([key, value]) => {\n headers.set(key, value);\n });\n }\n\n return {\n body: stringifiedManifest,\n version: runtimeVersion,\n headers,\n };\n }\n }\n }\n\n private static getContentTypeForResponseContentType(\n responseContentType: ResponseContentType\n ): string {\n switch (responseContentType) {\n case ResponseContentType.MULTIPART_MIXED:\n return 'multipart/mixed';\n case ResponseContentType.APPLICATION_EXPO_JSON:\n return 'application/expo+json';\n case ResponseContentType.APPLICATION_JSON:\n return 'application/json';\n case ResponseContentType.TEXT_PLAIN:\n return 'text/plain';\n }\n }\n\n private getFormData({\n stringifiedManifest,\n manifestPartHeaders,\n certificateChainBody,\n }: {\n stringifiedManifest: string;\n manifestPartHeaders: { 'expo-signature': string } | null;\n certificateChainBody: string | null;\n }): FormData {\n const form = new FormData();\n form.append('manifest', stringifiedManifest, {\n contentType: 'application/json',\n header: {\n ...manifestPartHeaders,\n },\n });\n if (certificateChainBody && certificateChainBody.length > 0) {\n form.append('certificate_chain', certificateChainBody, {\n contentType: 'application/x-pem-file',\n });\n }\n return form;\n }\n\n protected trackManifest(version?: string) {\n logEventAsync('Serve Expo Updates Manifest', {\n runtimeVersion: version,\n });\n }\n\n private static async getScopeKeyAsync({\n slug,\n codeSigningInfo,\n }: {\n slug: string;\n codeSigningInfo: CodeSigningInfo | null;\n }): Promise<string> {\n const scopeKeyFromCodeSigningInfo = codeSigningInfo?.scopeKey;\n if (scopeKeyFromCodeSigningInfo) {\n return scopeKeyFromCodeSigningInfo;\n }\n\n Log.warn(\n APISettings.isOffline\n ? 'Using anonymous scope key in manifest for offline mode.'\n : 'Using anonymous scope key in manifest.'\n );\n return await getAnonymousScopeKeyAsync(slug);\n }\n}\n\nasync function getAnonymousScopeKeyAsync(slug: string): Promise<string> {\n const userAnonymousIdentifier = await UserSettings.getAnonymousIdentifierAsync();\n return `@${ANONYMOUS_USERNAME}/${slug}-${userAnonymousIdentifier}`;\n}\n\nfunction convertToDictionaryItemsRepresentation(obj: { [key: string]: string }): Dictionary {\n return new Map(\n Object.entries(obj).map(([k, v]) => {\n return [k, [v, new Map()]];\n })\n );\n}\n"],"names":["Log","debug","require","ResponseContentType","TEXT_PLAIN","APPLICATION_JSON","APPLICATION_EXPO_JSON","MULTIPART_MIXED","ExpoGoManifestHandlerMiddleware","ManifestMiddleware","getParsedHeaders","req","platform","parsePlatformHeader","assertRuntimePlatform","accept","accepts","acceptedType","types","responseContentType","expectSignature","headers","String","hostname","stripPort","getDefaultResponseHeaders","Map","set","_getManifestResponseAsync","requestOptions","exp","hostUri","expoGoConfig","bundleUrl","_resolveProjectSettingsAsync","runtimeVersion","Updates","getRuntimeVersion","policy","CommandError","codeSigningInfo","getCodeSigningInfoAsync","options","privateKeyPath","easProjectId","extra","eas","projectId","scopeKey","getScopeKeyAsync","slug","expoUpdatesManifest","id","crypto","randomUUID","createdAt","Date","toISOString","launchAsset","key","contentType","url","assets","metadata","undefined","expoClient","expoGo","stringifiedManifest","JSON","stringify","manifestPartHeaders","certificateChainBody","signature","signManifestString","serializeDictionary","convertToDictionaryItemsRepresentation","keyid","keyId","sig","alg","certificateChainForResponse","join","form","getFormData","getBoundary","body","getBuffer","toString","version","getContentTypeForResponseContentType","Object","entries","forEach","value","FormData","append","header","length","trackManifest","logEventAsync","scopeKeyFromCodeSigningInfo","warn","APISettings","isOffline","getAnonymousScopeKeyAsync","userAnonymousIdentifier","UserSettings","getAnonymousIdentifierAsync","ANONYMOUS_USERNAME","obj","map","k","v"],"mappings":"AAAA;;;;;AACwB,IAAA,cAAsB,WAAtB,sBAAsB,CAAA;AAC1B,IAAA,QAAS,kCAAT,SAAS,EAAA;AACV,IAAA,OAAQ,kCAAR,QAAQ,EAAA;AACN,IAAA,SAAW,kCAAX,WAAW,EAAA;AACgB,IAAA,kBAAoB,WAApB,oBAAoB,CAAA;AAExC,IAAA,SAAuB,WAAvB,uBAAuB,CAAA;AAC1B,IAAA,aAAgC,kCAAhC,gCAAgC,EAAA;AACtB,IAAA,KAAwB,WAAxB,wBAAwB,CAAA;AAC/CA,IAAAA,GAAG,mCAAM,cAAc,EAApB;AACe,IAAA,kBAA4C,WAA5C,4CAA4C,CAAA;AAKnE,IAAA,YAA4B,WAA5B,4BAA4B,CAAA;AACN,IAAA,OAAuB,WAAvB,uBAAuB,CAAA;AAC1B,IAAA,IAAoB,WAApB,oBAAoB,CAAA;AACU,IAAA,mBAAsB,WAAtB,sBAAsB,CAAA;AACnB,IAAA,gBAAmB,WAAnB,mBAAmB,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAG9E,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,8DAA8D,CAAC,AAAC;IAExF,mBAKN;;UALWC,mBAAmB;IAAnBA,mBAAmB,CAAnBA,mBAAmB,CAC7BC,YAAU,IAAVA,CAAU,IAAVA,YAAU;IADAD,mBAAmB,CAAnBA,mBAAmB,CAE7BE,kBAAgB,IAAhBA,CAAgB,IAAhBA,kBAAgB;IAFNF,mBAAmB,CAAnBA,mBAAmB,CAG7BG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,CAAA,EAIhB,EAAmB;QAClB,MAAM4D,2BAA2B,GAAG5D,eAAe,QAAU,GAAzBA,KAAAA,CAAyB,GAAzBA,eAAe,CAAEQ,QAAQ,AAAC;QAC9D,IAAIoD,2BAA2B,EAAE;YAC/B,OAAOA,2BAA2B,CAAC;SACpC;QAEDpG,GAAG,CAACqG,IAAI,CACNC,SAAW,YAAA,CAACC,SAAS,GACjB,yDAAyD,GACzD,wCAAwC,CAC7C,CAAC;QACF,OAAO,MAAMC,yBAAyB,CAACtD,IAAI,CAAC,CAAC;KAC9C;CACF;QA/OY1C,+BAA+B,GAA/BA,+BAA+B;AAiP5C,eAAegG,yBAAyB,CAACtD,IAAY,EAAmB;IACtE,MAAMuD,uBAAuB,GAAG,MAAMC,aAAY,QAAA,CAACC,2BAA2B,EAAE,AAAC;IACjF,OAAO,CAAC,CAAC,EAAEC,KAAkB,mBAAA,CAAC,CAAC,EAAE1D,IAAI,CAAC,CAAC,EAAEuD,uBAAuB,CAAC,CAAC,CAAC;CACpE;AAED,SAAS9B,sCAAsC,CAACkC,GAA8B,EAAc;IAC1F,OAAO,IAAInF,GAAG,CACZgE,MAAM,CAACC,OAAO,CAACkB,GAAG,CAAC,CAACC,GAAG,CAAC,CAAC,CAACC,CAAC,EAAEC,CAAC,CAAC,GAAK;QAClC,OAAO;YAACD,CAAC;YAAE;gBAACC,CAAC;gBAAE,IAAItF,GAAG,EAAE;aAAC;SAAC,CAAC;KAC5B,CAAC,CACH,CAAC;CACH"}
@@ -3,7 +3,10 @@ Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
5
  exports.getWorkspaceRoot = getWorkspaceRoot;
6
+ exports.getEntryWithServerRoot = getEntryWithServerRoot;
6
7
  exports.getMetroServerRoot = getMetroServerRoot;
8
+ exports.resolveMainModuleName = resolveMainModuleName;
9
+ exports.createBundleUrlPath = createBundleUrlPath;
7
10
  exports.DEVELOPER_TOOL = void 0;
8
11
  var _config = require("@expo/config");
9
12
  var _findYarnWorkspaceRoot = _interopRequireDefault(require("find-yarn-workspace-root"));
@@ -56,6 +59,9 @@ function getWorkspaceRoot(projectRoot) {
56
59
  throw error;
57
60
  }
58
61
  }
62
+ function getEntryWithServerRoot(projectRoot, projectConfig, platform) {
63
+ return _path.default.relative(getMetroServerRoot(projectRoot), (0, _resolveEntryPoint).resolveAbsoluteEntryPoint(projectRoot, platform, projectConfig));
64
+ }
59
65
  function getMetroServerRoot(projectRoot) {
60
66
  if (_env.env.EXPO_USE_METRO_WORKSPACE_ROOT) {
61
67
  var ref;
@@ -63,6 +69,31 @@ function getMetroServerRoot(projectRoot) {
63
69
  }
64
70
  return projectRoot;
65
71
  }
72
+ function resolveMainModuleName(projectRoot, projectConfig, platform) {
73
+ const entryPoint = getEntryWithServerRoot(projectRoot, projectConfig, platform);
74
+ debug(`Resolved entry point: ${entryPoint} (project root: ${projectRoot})`);
75
+ return (0, _url1).stripExtension(entryPoint, "js");
76
+ }
77
+ function createBundleUrlPath({ platform , mainModuleName , mode , minify =mode === "production" , environment , serializerOutput }) {
78
+ const queryParams = new URLSearchParams({
79
+ platform: encodeURIComponent(platform),
80
+ dev: String(mode !== "production"),
81
+ // TODO: Is this still needed?
82
+ hot: String(false),
83
+ lazy: String(!_env.env.EXPO_NO_METRO_LAZY)
84
+ });
85
+ if (minify) {
86
+ queryParams.append("minify", String(minify));
87
+ }
88
+ if (environment) {
89
+ queryParams.append("resolver.environment", environment);
90
+ queryParams.append("transform.environment", environment);
91
+ }
92
+ if (serializerOutput) {
93
+ queryParams.append("serializer.output", serializerOutput);
94
+ }
95
+ return `/${encodeURI(mainModuleName)}.bundle?${queryParams.toString()}`;
96
+ }
66
97
  const DEVELOPER_TOOL = "expo-cli";
67
98
  exports.DEVELOPER_TOOL = DEVELOPER_TOOL;
68
99
  class ManifestMiddleware extends _expoMiddleware.ExpoMiddleware {
@@ -107,7 +138,7 @@ class ManifestMiddleware extends _expoMiddleware.ExpoMiddleware {
107
138
  };
108
139
  }
109
140
  /** Get the main entry module ID (file) relative to the project root. */ resolveMainModuleName(projectConfig, platform) {
110
- let entryPoint = _path.default.relative(getMetroServerRoot(this.projectRoot), (0, _resolveEntryPoint).resolveAbsoluteEntryPoint(this.projectRoot, platform, projectConfig));
141
+ let entryPoint = getEntryWithServerRoot(this.projectRoot, projectConfig, platform);
111
142
  debug(`Resolved entry point: ${entryPoint} (project root: ${this.projectRoot})`);
112
143
  // NOTE(Bacon): Webpack is currently hardcoded to index.bundle on native
113
144
  // in the future (TODO) we should move this logic into a Webpack plugin and use
@@ -120,13 +151,6 @@ class ManifestMiddleware extends _expoMiddleware.ExpoMiddleware {
120
151
  }
121
152
  return (0, _url1).stripExtension(entryPoint, "js");
122
153
  }
123
- /**
124
- * This header is specified as a string "true" or "false", in one of two headers:
125
- * - exponent-accept-signature
126
- * - expo-accept-signature
127
- */ getLegacyAcceptSignatureHeader(req) {
128
- return req.headers["exponent-accept-signature"] === "true" || req.headers["expo-accept-signature"] === "true";
129
- }
130
154
  /** Store device IDs that were sent in the request headers. */ async saveDevicesAsync(req) {
131
155
  var ref;
132
156
  const deviceIds = (ref = req.headers) == null ? void 0 : ref["expo-dev-client-id"];
@@ -136,7 +160,10 @@ class ManifestMiddleware extends _expoMiddleware.ExpoMiddleware {
136
160
  }
137
161
  }
138
162
  /** Create the bundle URL (points to the single JS entry file). Exposed for testing. */ _getBundleUrl({ platform , mainModuleName , hostname }) {
139
- const path = this._getBundleUrlPath({
163
+ var _mode;
164
+ const path = createBundleUrlPath({
165
+ mode: (_mode = this.options.mode) != null ? _mode : "development",
166
+ minify: this.options.minify,
140
167
  platform,
141
168
  mainModuleName
142
169
  });
@@ -151,7 +178,8 @@ class ManifestMiddleware extends _expoMiddleware.ExpoMiddleware {
151
178
  platform: encodeURIComponent(platform),
152
179
  dev: String(this.options.mode !== "production"),
153
180
  // TODO: Is this still needed?
154
- hot: String(false)
181
+ hot: String(false),
182
+ lazy: String(!_env.env.EXPO_NO_METRO_LAZY)
155
183
  });
156
184
  if (this.options.minify) {
157
185
  queryParams.append("minify", String(this.options.minify));
@@ -204,19 +232,23 @@ class ManifestMiddleware extends _expoMiddleware.ExpoMiddleware {
204
232
  // The server normally inserts this but if we're offline we'll do it here
205
233
  await (0, _resolveAssets).resolveGoogleServicesFile(this.projectRoot, manifest);
206
234
  }
235
+ getWebBundleUrl() {
236
+ const platform = "web";
237
+ // Read from headers
238
+ const mainModuleName = this.resolveMainModuleName(this.initialProjectConfig, platform);
239
+ return this._getBundleUrlPath({
240
+ platform,
241
+ mainModuleName
242
+ });
243
+ }
207
244
  /**
208
245
  * Web platforms should create an index.html response using the same script resolution as native.
209
246
  *
210
247
  * Instead of adding a `bundleUrl` to a `manifest.json` (native) we'll add a `<script src="">`
211
248
  * to an `index.html`, this enables the web platform to load JavaScript from the server.
212
249
  */ async handleWebRequestAsync(req, res) {
213
- const platform = "web";
214
250
  // Read from headers
215
- const mainModuleName = this.resolveMainModuleName(this.initialProjectConfig, platform);
216
- const bundleUrl = this._getBundleUrlPath({
217
- platform,
218
- mainModuleName
219
- });
251
+ const bundleUrl = this.getWebBundleUrl();
220
252
  res.setHeader("Content-Type", "text/html");
221
253
  res.end(await (0, _webTemplate).createTemplateHtmlFromExpoConfigAsync(this.projectRoot, {
222
254
  exp: this.initialProjectConfig.exp,
@@ -225,7 +257,7 @@ class ManifestMiddleware extends _expoMiddleware.ExpoMiddleware {
225
257
  ]
226
258
  }));
227
259
  }
228
- /** Exposed for testing. */ async checkBrowserRequestAsync(req, res) {
260
+ /** Exposed for testing. */ async checkBrowserRequestAsync(req, res, next) {
229
261
  // Read the config
230
262
  const bundlers = (0, _platformBundlers).getPlatformBundlers(this.initialProjectConfig.exp);
231
263
  if (bundlers.web === "metro") {
@@ -235,15 +267,22 @@ class ManifestMiddleware extends _expoMiddleware.ExpoMiddleware {
235
267
  const platform = (0, _resolvePlatform).parsePlatformHeader(req);
236
268
  // On web, serve the public folder
237
269
  if (!platform || platform === "web") {
238
- await this.handleWebRequestAsync(req, res);
239
- return true;
270
+ var ref;
271
+ if (((ref = this.initialProjectConfig.exp.web) == null ? void 0 : ref.output) === "static") {
272
+ // Skip the spa-styled index.html when static generation is enabled.
273
+ next();
274
+ return true;
275
+ } else {
276
+ await this.handleWebRequestAsync(req, res);
277
+ return true;
278
+ }
240
279
  }
241
280
  }
242
281
  return false;
243
282
  }
244
283
  async handleRequestAsync(req, res, next) {
245
284
  // First check for standard JavaScript runtimes (aka legacy browsers like Chrome).
246
- if (await this.checkBrowserRequestAsync(req, res)) {
285
+ if (await this.checkBrowserRequestAsync(req, res, next)) {
247
286
  return;
248
287
  }
249
288
  // Save device IDs for dev client.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/start/server/middleware/ManifestMiddleware.ts"],"sourcesContent":["import { ExpoConfig, ExpoGoConfig, getConfig, ProjectConfig } from '@expo/config';\nimport findWorkspaceRoot from 'find-yarn-workspace-root';\nimport path from 'path';\nimport { resolve } from 'url';\n\nimport * as Log from '../../../log';\nimport { env } from '../../../utils/env';\nimport { stripExtension } from '../../../utils/url';\nimport * as ProjectDevices from '../../project/devices';\nimport { UrlCreator } from '../UrlCreator';\nimport { getPlatformBundlers } from '../platformBundlers';\nimport { createTemplateHtmlFromExpoConfigAsync } from '../webTemplate';\nimport { ExpoMiddleware } from './ExpoMiddleware';\nimport { resolveGoogleServicesFile, resolveManifestAssets } from './resolveAssets';\nimport { resolveAbsoluteEntryPoint } from './resolveEntryPoint';\nimport { parsePlatformHeader, RuntimePlatform } from './resolvePlatform';\nimport { ServerHeaders, ServerNext, ServerRequest, ServerResponse } from './server.types';\n\nconst debug = require('debug')('expo:start:server:middleware:manifest') as typeof console.log;\n\n/** Wraps `findWorkspaceRoot` and guards against having an empty `package.json` file in an upper directory. */\nexport function getWorkspaceRoot(projectRoot: string): string | null {\n try {\n return findWorkspaceRoot(projectRoot);\n } catch (error: any) {\n if (error.message.includes('Unexpected end of JSON input')) {\n return null;\n }\n throw error;\n }\n}\n\nexport function getMetroServerRoot(projectRoot: string) {\n if (env.EXPO_USE_METRO_WORKSPACE_ROOT) {\n return getWorkspaceRoot(projectRoot) ?? projectRoot;\n }\n\n return projectRoot;\n}\n\n/** Info about the computer hosting the dev server. */\nexport interface HostInfo {\n host: string;\n server: 'expo';\n serverVersion: string;\n serverDriver: string | null;\n serverOS: NodeJS.Platform;\n serverOSVersion: string;\n}\n\n/** Parsed values from the supported request headers. */\nexport interface ManifestRequestInfo {\n /** Should return the signed manifest. */\n acceptSignature: boolean;\n /** Platform to serve. */\n platform: RuntimePlatform;\n /** Requested host name. */\n hostname?: string | null;\n}\n\n/** Project related info. */\nexport type ResponseProjectSettings = {\n expoGoConfig: ExpoGoConfig;\n hostUri: string;\n bundleUrl: string;\n exp: ExpoConfig;\n};\n\nexport const DEVELOPER_TOOL = 'expo-cli';\n\nexport type ManifestMiddlewareOptions = {\n /** Should start the dev servers in development mode (minify). */\n mode?: 'development' | 'production';\n /** Should instruct the bundler to create minified bundles. */\n minify?: boolean;\n constructUrl: UrlCreator['constructUrl'];\n isNativeWebpack?: boolean;\n privateKeyPath?: string;\n};\n\n/** Base middleware creator for serving the Expo manifest (like the index.html but for native runtimes). */\nexport abstract class ManifestMiddleware<\n TManifestRequestInfo extends ManifestRequestInfo\n> extends ExpoMiddleware {\n private initialProjectConfig: ProjectConfig;\n\n constructor(protected projectRoot: string, protected options: ManifestMiddlewareOptions) {\n super(\n projectRoot,\n /**\n * Only support `/`, `/manifest`, `/index.exp` for the manifest middleware.\n */\n ['/', '/manifest', '/index.exp']\n );\n this.initialProjectConfig = getConfig(projectRoot);\n }\n\n /** Exposed for testing. */\n public async _resolveProjectSettingsAsync({\n platform,\n hostname,\n }: Pick<TManifestRequestInfo, 'hostname' | 'platform'>): Promise<ResponseProjectSettings> {\n // Read the config\n const projectConfig = getConfig(this.projectRoot);\n\n // Read from headers\n const mainModuleName = this.resolveMainModuleName(projectConfig, platform);\n\n // Create the manifest and set fields within it\n const expoGoConfig = this.getExpoGoConfig({\n mainModuleName,\n hostname,\n });\n\n const hostUri = this.options.constructUrl({ scheme: '', hostname });\n\n const bundleUrl = this._getBundleUrl({\n platform,\n mainModuleName,\n hostname,\n });\n\n // Resolve all assets and set them on the manifest as URLs\n await this.mutateManifestWithAssetsAsync(projectConfig.exp, bundleUrl);\n\n return {\n expoGoConfig,\n hostUri,\n bundleUrl,\n exp: projectConfig.exp,\n };\n }\n\n /** Get the main entry module ID (file) relative to the project root. */\n private resolveMainModuleName(projectConfig: ProjectConfig, platform: string): string {\n let entryPoint = path.relative(\n getMetroServerRoot(this.projectRoot),\n resolveAbsoluteEntryPoint(this.projectRoot, platform, projectConfig)\n );\n\n debug(`Resolved entry point: ${entryPoint} (project root: ${this.projectRoot})`);\n\n // NOTE(Bacon): Webpack is currently hardcoded to index.bundle on native\n // in the future (TODO) we should move this logic into a Webpack plugin and use\n // a generated file name like we do on web.\n // const server = getDefaultDevServer();\n // // TODO: Move this into BundlerDevServer and read this info from self.\n // const isNativeWebpack = server instanceof WebpackBundlerDevServer && server.isTargetingNative();\n if (this.options.isNativeWebpack) {\n entryPoint = 'index.js';\n }\n\n return stripExtension(entryPoint, 'js');\n }\n\n /** Parse request headers into options. */\n public abstract getParsedHeaders(req: ServerRequest): TManifestRequestInfo;\n\n /**\n * This header is specified as a string \"true\" or \"false\", in one of two headers:\n * - exponent-accept-signature\n * - expo-accept-signature\n */\n protected getLegacyAcceptSignatureHeader(req: ServerRequest): boolean {\n return (\n req.headers['exponent-accept-signature'] === 'true' ||\n req.headers['expo-accept-signature'] === 'true'\n );\n }\n\n /** Store device IDs that were sent in the request headers. */\n private async saveDevicesAsync(req: ServerRequest) {\n const deviceIds = req.headers?.['expo-dev-client-id'];\n if (deviceIds) {\n await ProjectDevices.saveDevicesAsync(this.projectRoot, deviceIds).catch((e) =>\n Log.exception(e)\n );\n }\n }\n\n /** Create the bundle URL (points to the single JS entry file). Exposed for testing. */\n public _getBundleUrl({\n platform,\n mainModuleName,\n hostname,\n }: {\n platform: string;\n hostname?: string | null;\n mainModuleName: string;\n }): string {\n const path = this._getBundleUrlPath({ platform, mainModuleName });\n\n return (\n this.options.constructUrl({\n scheme: 'http',\n // hostType: this.options.location.hostType,\n hostname,\n }) + path\n );\n }\n\n public _getBundleUrlPath({\n platform,\n mainModuleName,\n }: {\n platform: string;\n mainModuleName: string;\n }): string {\n const queryParams = new URLSearchParams({\n platform: encodeURIComponent(platform),\n dev: String(this.options.mode !== 'production'),\n // TODO: Is this still needed?\n hot: String(false),\n });\n\n if (this.options.minify) {\n queryParams.append('minify', String(this.options.minify));\n }\n\n return `/${encodeURI(mainModuleName)}.bundle?${queryParams.toString()}`;\n }\n\n /** Log telemetry. */\n protected abstract trackManifest(version?: string): void;\n\n /** Get the manifest response to return to the runtime. This file contains info regarding where the assets can be loaded from. Exposed for testing. */\n public abstract _getManifestResponseAsync(options: TManifestRequestInfo): Promise<{\n body: string;\n version: string;\n headers: ServerHeaders;\n }>;\n\n private getExpoGoConfig({\n mainModuleName,\n hostname,\n }: {\n mainModuleName: string;\n hostname?: string | null;\n }): ExpoGoConfig {\n return {\n // localhost:19000\n debuggerHost: this.options.constructUrl({ scheme: '', hostname }),\n // http://localhost:19000/logs -- used to send logs to the CLI for displaying in the terminal.\n // This is deprecated in favor of the WebSocket connection setup in Metro.\n logUrl: this.options.constructUrl({ scheme: 'http', hostname }) + '/logs',\n // Required for Expo Go to function.\n developer: {\n tool: DEVELOPER_TOOL,\n projectRoot: this.projectRoot,\n },\n packagerOpts: {\n // Required for dev client.\n dev: this.options.mode !== 'production',\n },\n // Indicates the name of the main bundle.\n mainModuleName,\n // Add this string to make Flipper register React Native / Metro as \"running\".\n // Can be tested by running:\n // `METRO_SERVER_PORT=19000 open -a flipper.app`\n // Where 19000 is the port where the Expo project is being hosted.\n __flipperHack: 'React Native packager is running',\n };\n }\n\n /** Resolve all assets and set them on the manifest as URLs */\n private async mutateManifestWithAssetsAsync(manifest: ExpoConfig, bundleUrl: string) {\n await resolveManifestAssets(this.projectRoot, {\n manifest,\n resolver: async (path) => {\n if (this.options.isNativeWebpack) {\n // When using our custom dev server, just do assets normally\n // without the `assets/` subpath redirect.\n return resolve(bundleUrl!.match(/^https?:\\/\\/.*?\\//)![0], path);\n }\n return bundleUrl!.match(/^https?:\\/\\/.*?\\//)![0] + 'assets/' + path;\n },\n });\n // The server normally inserts this but if we're offline we'll do it here\n await resolveGoogleServicesFile(this.projectRoot, manifest);\n }\n\n /**\n * Web platforms should create an index.html response using the same script resolution as native.\n *\n * Instead of adding a `bundleUrl` to a `manifest.json` (native) we'll add a `<script src=\"\">`\n * to an `index.html`, this enables the web platform to load JavaScript from the server.\n */\n private async handleWebRequestAsync(req: ServerRequest, res: ServerResponse) {\n const platform = 'web';\n // Read from headers\n const mainModuleName = this.resolveMainModuleName(this.initialProjectConfig, platform);\n const bundleUrl = this._getBundleUrlPath({\n platform,\n mainModuleName,\n });\n\n res.setHeader('Content-Type', 'text/html');\n\n res.end(\n await createTemplateHtmlFromExpoConfigAsync(this.projectRoot, {\n exp: this.initialProjectConfig.exp,\n scripts: [bundleUrl],\n })\n );\n }\n\n /** Exposed for testing. */\n async checkBrowserRequestAsync(req: ServerRequest, res: ServerResponse) {\n // Read the config\n const bundlers = getPlatformBundlers(this.initialProjectConfig.exp);\n if (bundlers.web === 'metro') {\n // NOTE(EvanBacon): This effectively disables the safety check we do on custom runtimes to ensure\n // the `expo-platform` header is included. When `web.bundler=web`, if the user has non-standard Expo\n // code loading then they'll get a web bundle without a clear assertion of platform support.\n const platform = parsePlatformHeader(req);\n // On web, serve the public folder\n if (!platform || platform === 'web') {\n await this.handleWebRequestAsync(req, res);\n return true;\n }\n }\n return false;\n }\n\n async handleRequestAsync(\n req: ServerRequest,\n res: ServerResponse,\n next: ServerNext\n ): Promise<void> {\n // First check for standard JavaScript runtimes (aka legacy browsers like Chrome).\n if (await this.checkBrowserRequestAsync(req, res)) {\n return;\n }\n\n // Save device IDs for dev client.\n await this.saveDevicesAsync(req);\n\n // Read from headers\n const options = this.getParsedHeaders(req);\n const { body, version, headers } = await this._getManifestResponseAsync(options);\n for (const [headerName, headerValue] of headers) {\n res.setHeader(headerName, headerValue);\n }\n res.end(body);\n\n // Log analytics\n this.trackManifest(version ?? null);\n }\n}\n"],"names":["getWorkspaceRoot","getMetroServerRoot","Log","ProjectDevices","debug","require","projectRoot","findWorkspaceRoot","error","message","includes","env","EXPO_USE_METRO_WORKSPACE_ROOT","DEVELOPER_TOOL","ManifestMiddleware","ExpoMiddleware","constructor","options","initialProjectConfig","getConfig","_resolveProjectSettingsAsync","platform","hostname","projectConfig","mainModuleName","resolveMainModuleName","expoGoConfig","getExpoGoConfig","hostUri","constructUrl","scheme","bundleUrl","_getBundleUrl","mutateManifestWithAssetsAsync","exp","entryPoint","path","relative","resolveAbsoluteEntryPoint","isNativeWebpack","stripExtension","getLegacyAcceptSignatureHeader","req","headers","saveDevicesAsync","deviceIds","catch","e","exception","_getBundleUrlPath","queryParams","URLSearchParams","encodeURIComponent","dev","String","mode","hot","minify","append","encodeURI","toString","debuggerHost","logUrl","developer","tool","packagerOpts","__flipperHack","manifest","resolveManifestAssets","resolver","resolve","match","resolveGoogleServicesFile","handleWebRequestAsync","res","setHeader","end","createTemplateHtmlFromExpoConfigAsync","scripts","checkBrowserRequestAsync","bundlers","getPlatformBundlers","web","parsePlatformHeader","handleRequestAsync","next","getParsedHeaders","body","version","_getManifestResponseAsync","headerName","headerValue","trackManifest"],"mappings":"AAAA;;;;QAqBgBA,gBAAgB,GAAhBA,gBAAgB;QAWhBC,kBAAkB,GAAlBA,kBAAkB;;AAhCiC,IAAA,OAAc,WAAd,cAAc,CAAA;AACnD,IAAA,sBAA0B,kCAA1B,0BAA0B,EAAA;AACvC,IAAA,KAAM,kCAAN,MAAM,EAAA;AACC,IAAA,IAAK,WAAL,KAAK,CAAA;AAEjBC,IAAAA,GAAG,mCAAM,cAAc,EAApB;AACK,IAAA,IAAoB,WAApB,oBAAoB,CAAA;AACT,IAA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AC9B,gBAAgB,CAACF,GAAG,CAAC,CAAC;QAEjC,oBAAoB;QACpB,MAAMzB,OAAO,GAAG,IAAI,CAACqE,gBAAgB,CAAC5C,GAAG,CAAC,AAAC;QAC3C,MAAM,EAAE6C,IAAI,CAAA,EAAEC,OAAO,CAAA,EAAE7C,OAAO,CAAA,EAAE,GAAG,MAAM,IAAI,CAAC8C,yBAAyB,CAACxE,OAAO,CAAC,AAAC;QACjF,KAAK,MAAM,CAACyE,UAAU,EAAEC,WAAW,CAAC,IAAIhD,OAAO,CAAE;YAC/C+B,GAAG,CAACC,SAAS,CAACe,UAAU,EAAEC,WAAW,CAAC,CAAC;SACxC;QACDjB,GAAG,CAACE,GAAG,CAACW,IAAI,CAAC,CAAC;QAEd,gBAAgB;QAChB,IAAI,CAACK,aAAa,CAACJ,OAAO,WAAPA,OAAO,GAAI,IAAI,CAAC,CAAC;KACrC;CACF;QA3QqB1E,kBAAkB,GAAlBA,kBAAkB"}
1
+ {"version":3,"sources":["../../../../../src/start/server/middleware/ManifestMiddleware.ts"],"sourcesContent":["import { ExpoConfig, ExpoGoConfig, getConfig, ProjectConfig } from '@expo/config';\nimport findWorkspaceRoot from 'find-yarn-workspace-root';\nimport path from 'path';\nimport { resolve } from 'url';\n\nimport * as Log from '../../../log';\nimport { env } from '../../../utils/env';\nimport { stripExtension } from '../../../utils/url';\nimport * as ProjectDevices from '../../project/devices';\nimport { UrlCreator } from '../UrlCreator';\nimport { getPlatformBundlers } from '../platformBundlers';\nimport { createTemplateHtmlFromExpoConfigAsync } from '../webTemplate';\nimport { ExpoMiddleware } from './ExpoMiddleware';\nimport { resolveGoogleServicesFile, resolveManifestAssets } from './resolveAssets';\nimport { resolveAbsoluteEntryPoint } from './resolveEntryPoint';\nimport { parsePlatformHeader, RuntimePlatform } from './resolvePlatform';\nimport { ServerHeaders, ServerNext, ServerRequest, ServerResponse } from './server.types';\n\nconst debug = require('debug')('expo:start:server:middleware:manifest') as typeof console.log;\n\n/** Wraps `findWorkspaceRoot` and guards against having an empty `package.json` file in an upper directory. */\nexport function getWorkspaceRoot(projectRoot: string): string | null {\n try {\n return findWorkspaceRoot(projectRoot);\n } catch (error: any) {\n if (error.message.includes('Unexpected end of JSON input')) {\n return null;\n }\n throw error;\n }\n}\n\nexport function getEntryWithServerRoot(\n projectRoot: string,\n projectConfig: ProjectConfig,\n platform: string\n) {\n return path.relative(\n getMetroServerRoot(projectRoot),\n resolveAbsoluteEntryPoint(projectRoot, platform, projectConfig)\n );\n}\n\nexport function getMetroServerRoot(projectRoot: string) {\n if (env.EXPO_USE_METRO_WORKSPACE_ROOT) {\n return getWorkspaceRoot(projectRoot) ?? projectRoot;\n }\n\n return projectRoot;\n}\n\n/** Get the main entry module ID (file) relative to the project root. */\nexport function resolveMainModuleName(\n projectRoot: string,\n projectConfig: ProjectConfig,\n platform: string\n): string {\n const entryPoint = getEntryWithServerRoot(projectRoot, projectConfig, platform);\n\n debug(`Resolved entry point: ${entryPoint} (project root: ${projectRoot})`);\n\n return stripExtension(entryPoint, 'js');\n}\n\nexport function createBundleUrlPath({\n platform,\n mainModuleName,\n mode,\n minify = mode === 'production',\n environment,\n serializerOutput,\n}: {\n platform: string;\n mainModuleName: string;\n mode: string;\n minify?: boolean;\n environment?: string;\n serializerOutput?: 'static';\n}): string {\n const queryParams = new URLSearchParams({\n platform: encodeURIComponent(platform),\n dev: String(mode !== 'production'),\n // TODO: Is this still needed?\n hot: String(false),\n lazy: String(!env.EXPO_NO_METRO_LAZY),\n });\n\n if (minify) {\n queryParams.append('minify', String(minify));\n }\n if (environment) {\n queryParams.append('resolver.environment', environment);\n queryParams.append('transform.environment', environment);\n }\n if (serializerOutput) {\n queryParams.append('serializer.output', serializerOutput);\n }\n\n return `/${encodeURI(mainModuleName)}.bundle?${queryParams.toString()}`;\n}\n\n/** Info about the computer hosting the dev server. */\nexport interface HostInfo {\n host: string;\n server: 'expo';\n serverVersion: string;\n serverDriver: string | null;\n serverOS: NodeJS.Platform;\n serverOSVersion: string;\n}\n\n/** Parsed values from the supported request headers. */\nexport interface ManifestRequestInfo {\n /** Platform to serve. */\n platform: RuntimePlatform;\n /** Requested host name. */\n hostname?: string | null;\n}\n\n/** Project related info. */\nexport type ResponseProjectSettings = {\n expoGoConfig: ExpoGoConfig;\n hostUri: string;\n bundleUrl: string;\n exp: ExpoConfig;\n};\n\nexport const DEVELOPER_TOOL = 'expo-cli';\n\nexport type ManifestMiddlewareOptions = {\n /** Should start the dev servers in development mode (minify). */\n mode?: 'development' | 'production';\n /** Should instruct the bundler to create minified bundles. */\n minify?: boolean;\n constructUrl: UrlCreator['constructUrl'];\n isNativeWebpack?: boolean;\n privateKeyPath?: string;\n};\n\n/** Base middleware creator for serving the Expo manifest (like the index.html but for native runtimes). */\nexport abstract class ManifestMiddleware<\n TManifestRequestInfo extends ManifestRequestInfo\n> extends ExpoMiddleware {\n private initialProjectConfig: ProjectConfig;\n\n constructor(protected projectRoot: string, protected options: ManifestMiddlewareOptions) {\n super(\n projectRoot,\n /**\n * Only support `/`, `/manifest`, `/index.exp` for the manifest middleware.\n */\n ['/', '/manifest', '/index.exp']\n );\n this.initialProjectConfig = getConfig(projectRoot);\n }\n\n /** Exposed for testing. */\n public async _resolveProjectSettingsAsync({\n platform,\n hostname,\n }: Pick<TManifestRequestInfo, 'hostname' | 'platform'>): Promise<ResponseProjectSettings> {\n // Read the config\n const projectConfig = getConfig(this.projectRoot);\n\n // Read from headers\n const mainModuleName = this.resolveMainModuleName(projectConfig, platform);\n\n // Create the manifest and set fields within it\n const expoGoConfig = this.getExpoGoConfig({\n mainModuleName,\n hostname,\n });\n\n const hostUri = this.options.constructUrl({ scheme: '', hostname });\n\n const bundleUrl = this._getBundleUrl({\n platform,\n mainModuleName,\n hostname,\n });\n\n // Resolve all assets and set them on the manifest as URLs\n await this.mutateManifestWithAssetsAsync(projectConfig.exp, bundleUrl);\n\n return {\n expoGoConfig,\n hostUri,\n bundleUrl,\n exp: projectConfig.exp,\n };\n }\n\n /** Get the main entry module ID (file) relative to the project root. */\n private resolveMainModuleName(projectConfig: ProjectConfig, platform: string): string {\n let entryPoint = getEntryWithServerRoot(this.projectRoot, projectConfig, platform);\n\n debug(`Resolved entry point: ${entryPoint} (project root: ${this.projectRoot})`);\n\n // NOTE(Bacon): Webpack is currently hardcoded to index.bundle on native\n // in the future (TODO) we should move this logic into a Webpack plugin and use\n // a generated file name like we do on web.\n // const server = getDefaultDevServer();\n // // TODO: Move this into BundlerDevServer and read this info from self.\n // const isNativeWebpack = server instanceof WebpackBundlerDevServer && server.isTargetingNative();\n if (this.options.isNativeWebpack) {\n entryPoint = 'index.js';\n }\n\n return stripExtension(entryPoint, 'js');\n }\n\n /** Parse request headers into options. */\n public abstract getParsedHeaders(req: ServerRequest): TManifestRequestInfo;\n\n /** Store device IDs that were sent in the request headers. */\n private async saveDevicesAsync(req: ServerRequest) {\n const deviceIds = req.headers?.['expo-dev-client-id'];\n if (deviceIds) {\n await ProjectDevices.saveDevicesAsync(this.projectRoot, deviceIds).catch((e) =>\n Log.exception(e)\n );\n }\n }\n\n /** Create the bundle URL (points to the single JS entry file). Exposed for testing. */\n public _getBundleUrl({\n platform,\n mainModuleName,\n hostname,\n }: {\n platform: string;\n hostname?: string | null;\n mainModuleName: string;\n }): string {\n const path = createBundleUrlPath({\n mode: this.options.mode ?? 'development',\n minify: this.options.minify,\n platform,\n mainModuleName,\n });\n\n return (\n this.options.constructUrl({\n scheme: 'http',\n // hostType: this.options.location.hostType,\n hostname,\n }) + path\n );\n }\n\n public _getBundleUrlPath({\n platform,\n mainModuleName,\n }: {\n platform: string;\n mainModuleName: string;\n }): string {\n const queryParams = new URLSearchParams({\n platform: encodeURIComponent(platform),\n dev: String(this.options.mode !== 'production'),\n // TODO: Is this still needed?\n hot: String(false),\n lazy: String(!env.EXPO_NO_METRO_LAZY),\n });\n\n if (this.options.minify) {\n queryParams.append('minify', String(this.options.minify));\n }\n\n return `/${encodeURI(mainModuleName)}.bundle?${queryParams.toString()}`;\n }\n\n /** Log telemetry. */\n protected abstract trackManifest(version?: string): void;\n\n /** Get the manifest response to return to the runtime. This file contains info regarding where the assets can be loaded from. Exposed for testing. */\n public abstract _getManifestResponseAsync(options: TManifestRequestInfo): Promise<{\n body: string;\n version: string;\n headers: ServerHeaders;\n }>;\n\n private getExpoGoConfig({\n mainModuleName,\n hostname,\n }: {\n mainModuleName: string;\n hostname?: string | null;\n }): ExpoGoConfig {\n return {\n // localhost:19000\n debuggerHost: this.options.constructUrl({ scheme: '', hostname }),\n // http://localhost:19000/logs -- used to send logs to the CLI for displaying in the terminal.\n // This is deprecated in favor of the WebSocket connection setup in Metro.\n logUrl: this.options.constructUrl({ scheme: 'http', hostname }) + '/logs',\n // Required for Expo Go to function.\n developer: {\n tool: DEVELOPER_TOOL,\n projectRoot: this.projectRoot,\n },\n packagerOpts: {\n // Required for dev client.\n dev: this.options.mode !== 'production',\n },\n // Indicates the name of the main bundle.\n mainModuleName,\n // Add this string to make Flipper register React Native / Metro as \"running\".\n // Can be tested by running:\n // `METRO_SERVER_PORT=19000 open -a flipper.app`\n // Where 19000 is the port where the Expo project is being hosted.\n __flipperHack: 'React Native packager is running',\n };\n }\n\n /** Resolve all assets and set them on the manifest as URLs */\n private async mutateManifestWithAssetsAsync(manifest: ExpoConfig, bundleUrl: string) {\n await resolveManifestAssets(this.projectRoot, {\n manifest,\n resolver: async (path) => {\n if (this.options.isNativeWebpack) {\n // When using our custom dev server, just do assets normally\n // without the `assets/` subpath redirect.\n return resolve(bundleUrl!.match(/^https?:\\/\\/.*?\\//)![0], path);\n }\n return bundleUrl!.match(/^https?:\\/\\/.*?\\//)![0] + 'assets/' + path;\n },\n });\n // The server normally inserts this but if we're offline we'll do it here\n await resolveGoogleServicesFile(this.projectRoot, manifest);\n }\n\n public getWebBundleUrl() {\n const platform = 'web';\n // Read from headers\n const mainModuleName = this.resolveMainModuleName(this.initialProjectConfig, platform);\n return this._getBundleUrlPath({\n platform,\n mainModuleName,\n });\n }\n\n /**\n * Web platforms should create an index.html response using the same script resolution as native.\n *\n * Instead of adding a `bundleUrl` to a `manifest.json` (native) we'll add a `<script src=\"\">`\n * to an `index.html`, this enables the web platform to load JavaScript from the server.\n */\n private async handleWebRequestAsync(req: ServerRequest, res: ServerResponse) {\n // Read from headers\n const bundleUrl = this.getWebBundleUrl();\n\n res.setHeader('Content-Type', 'text/html');\n\n res.end(\n await createTemplateHtmlFromExpoConfigAsync(this.projectRoot, {\n exp: this.initialProjectConfig.exp,\n scripts: [bundleUrl],\n })\n );\n }\n\n /** Exposed for testing. */\n async checkBrowserRequestAsync(req: ServerRequest, res: ServerResponse, next: ServerNext) {\n // Read the config\n const bundlers = getPlatformBundlers(this.initialProjectConfig.exp);\n if (bundlers.web === 'metro') {\n // NOTE(EvanBacon): This effectively disables the safety check we do on custom runtimes to ensure\n // the `expo-platform` header is included. When `web.bundler=web`, if the user has non-standard Expo\n // code loading then they'll get a web bundle without a clear assertion of platform support.\n const platform = parsePlatformHeader(req);\n // On web, serve the public folder\n if (!platform || platform === 'web') {\n if (this.initialProjectConfig.exp.web?.output === 'static') {\n // Skip the spa-styled index.html when static generation is enabled.\n next();\n return true;\n } else {\n await this.handleWebRequestAsync(req, res);\n return true;\n }\n }\n }\n return false;\n }\n\n async handleRequestAsync(\n req: ServerRequest,\n res: ServerResponse,\n next: ServerNext\n ): Promise<void> {\n // First check for standard JavaScript runtimes (aka legacy browsers like Chrome).\n if (await this.checkBrowserRequestAsync(req, res, next)) {\n return;\n }\n\n // Save device IDs for dev client.\n await this.saveDevicesAsync(req);\n\n // Read from headers\n const options = this.getParsedHeaders(req);\n const { body, version, headers } = await this._getManifestResponseAsync(options);\n for (const [headerName, headerValue] of headers) {\n res.setHeader(headerName, headerValue);\n }\n res.end(body);\n\n // Log analytics\n this.trackManifest(version ?? null);\n }\n}\n"],"names":["getWorkspaceRoot","getEntryWithServerRoot","getMetroServerRoot","resolveMainModuleName","createBundleUrlPath","Log","ProjectDevices","debug","require","projectRoot","findWorkspaceRoot","error","message","includes","projectConfig","platform","path","relative","resolveAbsoluteEntryPoint","env","EXPO_USE_METRO_WORKSPACE_ROOT","entryPoint","stripExtension","mainModuleName","mode","minify","environment","serializerOutput","queryParams","URLSearchParams","encodeURIComponent","dev","String","hot","lazy","EXPO_NO_METRO_LAZY","append","encodeURI","toString","DEVELOPER_TOOL","ManifestMiddleware","ExpoMiddleware","constructor","options","initialProjectConfig","getConfig","_resolveProjectSettingsAsync","hostname","expoGoConfig","getExpoGoConfig","hostUri","constructUrl","scheme","bundleUrl","_getBundleUrl","mutateManifestWithAssetsAsync","exp","isNativeWebpack","saveDevicesAsync","req","deviceIds","headers","catch","e","exception","_getBundleUrlPath","debuggerHost","logUrl","developer","tool","packagerOpts","__flipperHack","manifest","resolveManifestAssets","resolver","resolve","match","resolveGoogleServicesFile","getWebBundleUrl","handleWebRequestAsync","res","setHeader","end","createTemplateHtmlFromExpoConfigAsync","scripts","checkBrowserRequestAsync","next","bundlers","getPlatformBundlers","web","parsePlatformHeader","output","handleRequestAsync","getParsedHeaders","body","version","_getManifestResponseAsync","headerName","headerValue","trackManifest"],"mappings":"AAAA;;;;QAqBgBA,gBAAgB,GAAhBA,gBAAgB;QAWhBC,sBAAsB,GAAtBA,sBAAsB;QAWtBC,kBAAkB,GAAlBA,kBAAkB;QASlBC,qBAAqB,GAArBA,qBAAqB;QAYrBC,mBAAmB,GAAnBA,mBAAmB;;AAhEgC,IAAA,OAAc,WAAd,cAAc,CAAA;AACnD,IAAA,sBAA0B,kCAA1B,0BAA0B,EAAA;AACvC,IAAA,KAAM,kCAAN,MAAM,EAAA;AACC,IAAA,IAAK,WAAL,KAAK,CAAA;AAEjBC,IAAAA,GAAG,mCAAM,cAAc,EAApB;AACK,IAAA,IAAoB,WAApB,oBAAoB,CAAA;AACT,IAAA,KAAoB,WAApB,oBAAoB,CAAA;AACvCC,IAAAA,cAAc,mCAAM,uBAAuB,EAA7B;AAEU,IAAA,iBAAqB,WAArB,qBAAqB,CA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
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ exports.writeExpoEnvDTS = writeExpoEnvDTS;
6
+ exports.removeExpoEnvDTS = removeExpoEnvDTS;
7
+ var _promises = _interopRequireDefault(require("fs/promises"));
8
+ var _path = _interopRequireDefault(require("path"));
9
+ function _interopRequireDefault(obj) {
10
+ return obj && obj.__esModule ? obj : {
11
+ default: obj
12
+ };
13
+ }
14
+ const template = `/// <reference types="expo-router/types" />
15
+
16
+ // NOTE: This file should not be edited and should be in your git ignore`;
17
+ async function writeExpoEnvDTS(projectRoot) {
18
+ return _promises.default.writeFile(_path.default.join(projectRoot, "expo-env.d.ts"), template);
19
+ }
20
+ async function removeExpoEnvDTS(projectRoot) {
21
+ // Force removal of expo-env.d.ts - Ignore any errors if the file does not exist
22
+ return _promises.default.rm(_path.default.join(projectRoot, "expo-env.d.ts"), {
23
+ force: true
24
+ });
25
+ }
26
+
27
+ //# sourceMappingURL=expo-env.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../src/start/server/type-generation/expo-env.ts"],"sourcesContent":["import fs from 'fs/promises';\nimport path from 'path';\n\nconst template = `/// <reference types=\"expo-router/types\" />\n\n// NOTE: This file should not be edited and should be in your git ignore`;\n\nexport async function writeExpoEnvDTS(projectRoot: string) {\n return fs.writeFile(path.join(projectRoot, 'expo-env.d.ts'), template);\n}\n\nexport async function removeExpoEnvDTS(projectRoot: string) {\n // Force removal of expo-env.d.ts - Ignore any errors if the file does not exist\n return fs.rm(path.join(projectRoot, 'expo-env.d.ts'), { force: true });\n}\n"],"names":["writeExpoEnvDTS","removeExpoEnvDTS","template","projectRoot","fs","writeFile","path","join","rm","force"],"mappings":"AAAA;;;;QAOsBA,eAAe,GAAfA,eAAe;QAIfC,gBAAgB,GAAhBA,gBAAgB;AAXvB,IAAA,SAAa,kCAAb,aAAa,EAAA;AACX,IAAA,KAAM,kCAAN,MAAM,EAAA;;;;;;AAEvB,MAAMC,QAAQ,GAAG,CAAC;;wEAEsD,CAAC,AAAC;AAEnE,eAAeF,eAAe,CAACG,WAAmB,EAAE;IACzD,OAAOC,SAAE,QAAA,CAACC,SAAS,CAACC,KAAI,QAAA,CAACC,IAAI,CAACJ,WAAW,EAAE,eAAe,CAAC,EAAED,QAAQ,CAAC,CAAC;CACxE;AAEM,eAAeD,gBAAgB,CAACE,WAAmB,EAAE;IAC1D,gFAAgF;IAChF,OAAOC,SAAE,QAAA,CAACI,EAAE,CAACF,KAAI,QAAA,CAACC,IAAI,CAACJ,WAAW,EAAE,eAAe,CAAC,EAAE;QAAEM,KAAK,EAAE,IAAI;KAAE,CAAC,CAAC;CACxE"}