eas-cli 25.0.0 → 25.2.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 (60) hide show
  1. package/README.md +285 -150
  2. package/build/analytics/AnalyticsManager.d.ts +6 -1
  3. package/build/analytics/AnalyticsManager.js +11 -1
  4. package/build/build/build.d.ts +2 -1
  5. package/build/build/build.js +5 -4
  6. package/build/build/context.d.ts +2 -0
  7. package/build/build/createContext.d.ts +3 -1
  8. package/build/build/createContext.js +2 -1
  9. package/build/build/freeTierLimitGuidance.d.ts +19 -0
  10. package/build/build/freeTierLimitGuidance.js +39 -0
  11. package/build/build/runBuildAndSubmit.d.ts +4 -1
  12. package/build/build/runBuildAndSubmit.js +4 -2
  13. package/build/commandUtils/EasCommand.d.ts +9 -0
  14. package/build/commandUtils/EasCommand.js +9 -0
  15. package/build/commandUtils/context/ExperimentationContextField.d.ts +13 -0
  16. package/build/commandUtils/context/ExperimentationContextField.js +79 -0
  17. package/build/commandUtils/context/contextUtils/createGraphqlClient.d.ts +3 -0
  18. package/build/commandUtils/context/contextUtils/createGraphqlClient.js +29 -2
  19. package/build/commandUtils/usageUtils.d.ts +14 -0
  20. package/build/commandUtils/usageUtils.js +40 -2
  21. package/build/commands/account/usage.js +55 -2
  22. package/build/commands/analytics.js +1 -1
  23. package/build/commands/build/index.d.ts +1 -0
  24. package/build/commands/build/index.js +3 -1
  25. package/build/commands/simulator/control.d.ts +26 -0
  26. package/build/commands/simulator/control.js +250 -0
  27. package/build/commands/simulator/index.d.ts +2 -0
  28. package/build/commands/simulator/index.js +28 -1
  29. package/build/commands/update/republish.d.ts +1 -1
  30. package/build/env.d.ts +6 -0
  31. package/build/env.js +6 -0
  32. package/build/experimentation/AnalyticsExposureLogger.d.ts +7 -0
  33. package/build/experimentation/AnalyticsExposureLogger.js +21 -0
  34. package/build/experimentation/ExperimentNamespace.d.ts +24 -0
  35. package/build/experimentation/ExperimentNamespace.js +69 -0
  36. package/build/experimentation/ExperimentOverrides.d.ts +17 -0
  37. package/build/experimentation/ExperimentOverrides.js +68 -0
  38. package/build/experimentation/ExperimentationClient.d.ts +32 -0
  39. package/build/experimentation/ExperimentationClient.js +125 -0
  40. package/build/experimentation/LazyExperimentationClient.d.ts +12 -0
  41. package/build/experimentation/LazyExperimentationClient.js +22 -0
  42. package/build/graphql/generated.d.ts +124 -0
  43. package/build/graphql/queries/AccountQuery.js +25 -0
  44. package/build/graphql/queries/ExperimentationConfigQuery.d.ts +10 -0
  45. package/build/graphql/queries/ExperimentationConfigQuery.js +49 -0
  46. package/build/graphql/queries/UserQuery.d.ts +3 -1
  47. package/build/graphql/queries/UserQuery.js +2 -1
  48. package/build/graphql/types/Account.js +5 -0
  49. package/build/help.d.ts +4 -0
  50. package/build/help.js +56 -0
  51. package/build/simulator/frameAncestors.d.ts +9 -0
  52. package/build/simulator/frameAncestors.js +66 -0
  53. package/build/simulator/hostActions.d.ts +70 -0
  54. package/build/simulator/hostActions.js +411 -0
  55. package/build/simulator/utils.d.ts +19 -2
  56. package/build/simulator/utils.js +68 -8
  57. package/build/user/SessionManager.d.ts +8 -1
  58. package/build/user/SessionManager.js +7 -2
  59. package/oclif.manifest.json +1164 -243
  60. package/package.json +8 -6
@@ -5,12 +5,14 @@ exports.formatSimulatorUnavailableMessage = formatSimulatorUnavailableMessage;
5
5
  exports.deviceRunSessionTypesForFlagValue = deviceRunSessionTypesForFlagValue;
6
6
  exports.deviceRunSessionTypeToFlagValue = deviceRunSessionTypeToFlagValue;
7
7
  exports.getLocalEgressConfig = getLocalEgressConfig;
8
+ exports.getPreviewApiAccess = getPreviewApiAccess;
8
9
  exports.getLoopbackForwardPlan = getLoopbackForwardPlan;
9
10
  exports.formatLoopbackForwardNotice = formatLoopbackForwardNotice;
10
11
  exports.getLocalEgressEnvironmentVariables = getLocalEgressEnvironmentVariables;
11
12
  exports.getRemoteSessionEnvironmentVariables = getRemoteSessionEnvironmentVariables;
12
13
  exports.formatPreviewUrl = formatPreviewUrl;
13
14
  exports.sanitizeRemoteConfigForJson = sanitizeRemoteConfigForJson;
15
+ exports.formatEmbedPreviewUrl = formatEmbedPreviewUrl;
14
16
  exports.formatRemoteSessionInstructions = formatRemoteSessionInstructions;
15
17
  const tslib_1 = require("tslib");
16
18
  const chalk_1 = tslib_1.__importDefault(require("chalk"));
@@ -75,6 +77,16 @@ function getLocalEgressConfig(remoteConfig, allow = [], platform = generated_1.A
75
77
  platform,
76
78
  };
77
79
  }
80
+ function getPreviewApiAccess(remoteConfig) {
81
+ const token = remoteConfig.__typename === 'ServeSimRunSessionRemoteConfig' ||
82
+ remoteConfig.__typename === 'WebPreviewOnlyRunSessionRemoteConfig'
83
+ ? remoteConfig.previewToken
84
+ : remoteConfig.webPreviewToken;
85
+ if (!remoteConfig.previewApiUrl || !token) {
86
+ return null;
87
+ }
88
+ return { apiUrl: remoteConfig.previewApiUrl, token };
89
+ }
78
90
  /** The worker relay that the Android emulator's proxy points at; see build-tools androidLocalEgress.ts. */
79
91
  exports.ANDROID_EMULATOR_EGRESS_RELAY_PORT = 8898;
80
92
  /**
@@ -214,8 +226,11 @@ function formatBrowserPreviewInstructions(remoteConfig, url, token, options) {
214
226
  /**
215
227
  * Remote config for `--json`. Private sessions omit the direct preview API address and preview
216
228
  * tokens. Public sessions include bearer preview links while preserving controller credentials.
229
+ * A session with frame ancestors or CORS origins also includes the preview API address, since
230
+ * the page on those origins needs it.
217
231
  */
218
- function sanitizeRemoteConfigForJson(remoteConfig, privatePreviewUrl, publicLink = false) {
232
+ function sanitizeRemoteConfigForJson(remoteConfig, privatePreviewUrl, publicLink = false, { frameAncestors = [], corsOrigins = [] } = {}) {
233
+ const includePreviewApiUrl = publicLink || frameAncestors.length > 0 || corsOrigins.length > 0;
219
234
  switch (remoteConfig.__typename) {
220
235
  case 'ServeSimRunSessionRemoteConfig':
221
236
  case 'WebPreviewOnlyRunSessionRemoteConfig': {
@@ -226,7 +241,7 @@ function sanitizeRemoteConfigForJson(remoteConfig, privatePreviewUrl, publicLink
226
241
  privatePreviewUrl,
227
242
  publicLink,
228
243
  }),
229
- previewApiUrl: publicLink
244
+ previewApiUrl: includePreviewApiUrl
230
245
  ? remoteConfig.previewApiUrl &&
231
246
  formatPreviewApiUrl(remoteConfig.previewApiUrl, previewToken)
232
247
  : null,
@@ -244,7 +259,7 @@ function sanitizeRemoteConfigForJson(remoteConfig, privatePreviewUrl, publicLink
244
259
  publicLink,
245
260
  })
246
261
  : remoteConfig.webPreviewUrl,
247
- previewApiUrl: publicLink
262
+ previewApiUrl: includePreviewApiUrl
248
263
  ? remoteConfig.previewApiUrl &&
249
264
  formatPreviewApiUrl(remoteConfig.previewApiUrl, webPreviewToken)
250
265
  : null,
@@ -252,11 +267,56 @@ function sanitizeRemoteConfigForJson(remoteConfig, privatePreviewUrl, publicLink
252
267
  }
253
268
  }
254
269
  }
255
- function formatRemoteSessionInstructions(remoteConfig, configType, { egressAllow, egressClientRunsInline = false, sessionUrl, platform, privatePreviewUrl, publicLink, } = {}) {
256
- const instructions = formatControllerInstructions(remoteConfig, configType, {
257
- privatePreviewUrl,
258
- publicLink,
259
- });
270
+ /**
271
+ * The preview host address with the session token, which an embedding page loads directly. The
272
+ * expo.dev preview page cannot be framed by other sites. Null until the worker reports the host.
273
+ */
274
+ function formatEmbedPreviewUrl(remoteConfig) {
275
+ switch (remoteConfig.__typename) {
276
+ case 'ServeSimRunSessionRemoteConfig':
277
+ case 'WebPreviewOnlyRunSessionRemoteConfig':
278
+ return remoteConfig.previewApiUrl
279
+ ? formatPreviewApiUrl(remoteConfig.previewApiUrl, remoteConfig.previewToken)
280
+ : null;
281
+ case 'AgentDeviceRunSessionRemoteConfig':
282
+ case 'ArgentRunSessionRemoteConfig':
283
+ case 'AppiumRunSessionRemoteConfig':
284
+ return remoteConfig.previewApiUrl
285
+ ? formatPreviewApiUrl(remoteConfig.previewApiUrl, remoteConfig.webPreviewToken)
286
+ : null;
287
+ }
288
+ }
289
+ function formatEmbedInstructions(remoteConfig, { frameAncestors = [], corsOrigins = [] }) {
290
+ if (frameAncestors.length === 0 && corsOrigins.length === 0) {
291
+ return [];
292
+ }
293
+ const embedUrl = formatEmbedPreviewUrl(remoteConfig);
294
+ const grants = [
295
+ ...(frameAncestors.length > 0
296
+ ? [`Pages on ${frameAncestors.join(', ')} may embed the preview in a frame.`]
297
+ : []),
298
+ ...(corsOrigins.length > 0
299
+ ? [
300
+ `Pages on ${corsOrigins.join(', ')} may call the preview API, for example with @expo/hub-client.`,
301
+ ]
302
+ : []),
303
+ ];
304
+ return [
305
+ '',
306
+ `🖼 ${grants.join(' ')} Use this URL there:`,
307
+ '',
308
+ embedUrl ?? 'The preview host has not reported its address yet.',
309
+ 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.'),
310
+ ];
311
+ }
312
+ function formatRemoteSessionInstructions(remoteConfig, configType, { egressAllow, egressClientRunsInline = false, sessionUrl, platform, privatePreviewUrl, publicLink, frameAncestors = [], corsOrigins = [], } = {}) {
313
+ const instructions = [
314
+ formatControllerInstructions(remoteConfig, configType, {
315
+ privatePreviewUrl,
316
+ publicLink,
317
+ }),
318
+ ...formatEmbedInstructions(remoteConfig, { frameAncestors, corsOrigins }),
319
+ ].join('\n');
260
320
  const egress = getLocalEgressConfig(remoteConfig, egressAllow, platform);
261
321
  if (!egress) {
262
322
  return instructions;
@@ -17,7 +17,14 @@ export default class SessionManager {
17
17
  private getSession;
18
18
  private setSessionAsync;
19
19
  logoutAsync(): Promise<void>;
20
- getUserAsync(): Promise<Actor | undefined>;
20
+ /**
21
+ * @param requestTimeoutMs caps the actor lookup when no actor is cached yet. Callers that must
22
+ * not delay a command past a deadline pass it; the default has no timeout. A capped lookup
23
+ * also skips the retry exchange, since a retry would double the wait.
24
+ */
25
+ getUserAsync({ requestTimeoutMs }?: {
26
+ requestTimeoutMs?: number;
27
+ }): Promise<Actor | undefined>;
21
28
  /**
22
29
  * Ensure that there is a logged-in actor. Show a login prompt if not.
23
30
  *
@@ -59,13 +59,18 @@ class SessionManager {
59
59
  this.currentActor = undefined;
60
60
  await this.setSessionAsync(undefined);
61
61
  }
62
- async getUserAsync() {
62
+ /**
63
+ * @param requestTimeoutMs caps the actor lookup when no actor is cached yet. Callers that must
64
+ * not delay a command past a deadline pass it; the default has no timeout. A capped lookup
65
+ * also skips the retry exchange, since a retry would double the wait.
66
+ */
67
+ async getUserAsync({ requestTimeoutMs } = {}) {
63
68
  if (!this.currentActor && (this.getAccessToken() || this.getSessionSecret())) {
64
69
  const authenticationInfo = {
65
70
  accessToken: this.getAccessToken(),
66
71
  sessionSecret: this.getSessionSecret(),
67
72
  };
68
- const actor = await UserQuery_1.UserQuery.currentUserAsync((0, createGraphqlClient_1.createGraphqlClient)(authenticationInfo));
73
+ const actor = await UserQuery_1.UserQuery.currentUserAsync((0, createGraphqlClient_1.createGraphqlClient)(authenticationInfo, { requestTimeoutMs }), { noRetry: requestTimeoutMs !== undefined });
69
74
  this.currentActor = actor ?? undefined;
70
75
  if (actor) {
71
76
  this.analytics.setActor(actor);