eas-cli 25.0.0 → 25.1.1

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.
@@ -11,6 +11,7 @@ exports.getLocalEgressEnvironmentVariables = getLocalEgressEnvironmentVariables;
11
11
  exports.getRemoteSessionEnvironmentVariables = getRemoteSessionEnvironmentVariables;
12
12
  exports.formatPreviewUrl = formatPreviewUrl;
13
13
  exports.sanitizeRemoteConfigForJson = sanitizeRemoteConfigForJson;
14
+ exports.formatEmbedPreviewUrl = formatEmbedPreviewUrl;
14
15
  exports.formatRemoteSessionInstructions = formatRemoteSessionInstructions;
15
16
  const tslib_1 = require("tslib");
16
17
  const chalk_1 = tslib_1.__importDefault(require("chalk"));
@@ -214,8 +215,11 @@ function formatBrowserPreviewInstructions(remoteConfig, url, token, options) {
214
215
  /**
215
216
  * Remote config for `--json`. Private sessions omit the direct preview API address and preview
216
217
  * tokens. Public sessions include bearer preview links while preserving controller credentials.
218
+ * A session with frame ancestors or CORS origins also includes the preview API address, since
219
+ * the page on those origins needs it.
217
220
  */
218
- function sanitizeRemoteConfigForJson(remoteConfig, privatePreviewUrl, publicLink = false) {
221
+ function sanitizeRemoteConfigForJson(remoteConfig, privatePreviewUrl, publicLink = false, { frameAncestors = [], corsOrigins = [] } = {}) {
222
+ const includePreviewApiUrl = publicLink || frameAncestors.length > 0 || corsOrigins.length > 0;
219
223
  switch (remoteConfig.__typename) {
220
224
  case 'ServeSimRunSessionRemoteConfig':
221
225
  case 'WebPreviewOnlyRunSessionRemoteConfig': {
@@ -226,7 +230,7 @@ function sanitizeRemoteConfigForJson(remoteConfig, privatePreviewUrl, publicLink
226
230
  privatePreviewUrl,
227
231
  publicLink,
228
232
  }),
229
- previewApiUrl: publicLink
233
+ previewApiUrl: includePreviewApiUrl
230
234
  ? remoteConfig.previewApiUrl &&
231
235
  formatPreviewApiUrl(remoteConfig.previewApiUrl, previewToken)
232
236
  : null,
@@ -244,7 +248,7 @@ function sanitizeRemoteConfigForJson(remoteConfig, privatePreviewUrl, publicLink
244
248
  publicLink,
245
249
  })
246
250
  : remoteConfig.webPreviewUrl,
247
- previewApiUrl: publicLink
251
+ previewApiUrl: includePreviewApiUrl
248
252
  ? remoteConfig.previewApiUrl &&
249
253
  formatPreviewApiUrl(remoteConfig.previewApiUrl, webPreviewToken)
250
254
  : null,
@@ -252,11 +256,56 @@ function sanitizeRemoteConfigForJson(remoteConfig, privatePreviewUrl, publicLink
252
256
  }
253
257
  }
254
258
  }
255
- function formatRemoteSessionInstructions(remoteConfig, configType, { egressAllow, egressClientRunsInline = false, sessionUrl, platform, privatePreviewUrl, publicLink, } = {}) {
256
- const instructions = formatControllerInstructions(remoteConfig, configType, {
257
- privatePreviewUrl,
258
- publicLink,
259
- });
259
+ /**
260
+ * The preview host address with the session token, which an embedding page loads directly. The
261
+ * expo.dev preview page cannot be framed by other sites. Null until the worker reports the host.
262
+ */
263
+ function formatEmbedPreviewUrl(remoteConfig) {
264
+ switch (remoteConfig.__typename) {
265
+ case 'ServeSimRunSessionRemoteConfig':
266
+ case 'WebPreviewOnlyRunSessionRemoteConfig':
267
+ return remoteConfig.previewApiUrl
268
+ ? formatPreviewApiUrl(remoteConfig.previewApiUrl, remoteConfig.previewToken)
269
+ : null;
270
+ case 'AgentDeviceRunSessionRemoteConfig':
271
+ case 'ArgentRunSessionRemoteConfig':
272
+ case 'AppiumRunSessionRemoteConfig':
273
+ return remoteConfig.previewApiUrl
274
+ ? formatPreviewApiUrl(remoteConfig.previewApiUrl, remoteConfig.webPreviewToken)
275
+ : null;
276
+ }
277
+ }
278
+ function formatEmbedInstructions(remoteConfig, { frameAncestors = [], corsOrigins = [] }) {
279
+ if (frameAncestors.length === 0 && corsOrigins.length === 0) {
280
+ return [];
281
+ }
282
+ const embedUrl = formatEmbedPreviewUrl(remoteConfig);
283
+ const grants = [
284
+ ...(frameAncestors.length > 0
285
+ ? [`Pages on ${frameAncestors.join(', ')} may embed the preview in a frame.`]
286
+ : []),
287
+ ...(corsOrigins.length > 0
288
+ ? [
289
+ `Pages on ${corsOrigins.join(', ')} may call the preview API, for example with @expo/hub-client.`,
290
+ ]
291
+ : []),
292
+ ];
293
+ return [
294
+ '',
295
+ `🖼 ${grants.join(' ')} Use this URL there:`,
296
+ '',
297
+ embedUrl ?? 'The preview host has not reported its address yet.',
298
+ chalk_1.default.yellow('Warning: Anyone who can read this URL can view and control the simulator, including your app and logs that may contain sensitive data.'),
299
+ ];
300
+ }
301
+ function formatRemoteSessionInstructions(remoteConfig, configType, { egressAllow, egressClientRunsInline = false, sessionUrl, platform, privatePreviewUrl, publicLink, frameAncestors = [], corsOrigins = [], } = {}) {
302
+ const instructions = [
303
+ formatControllerInstructions(remoteConfig, configType, {
304
+ privatePreviewUrl,
305
+ publicLink,
306
+ }),
307
+ ...formatEmbedInstructions(remoteConfig, { frameAncestors, corsOrigins }),
308
+ ].join('\n');
260
309
  const egress = getLocalEgressConfig(remoteConfig, egressAllow, platform);
261
310
  if (!egress) {
262
311
  return instructions;