@expo/serve-sim 0.2.0 → 0.2.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@expo/serve-sim",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "type": "module",
5
5
  "author": {
6
6
  "name": "Evan Bacon",
package/src/middleware.ts CHANGED
@@ -16,7 +16,7 @@ import { createAxStreamerCache } from "./ax";
16
16
  import { readCameraStatus } from "./camera-helper";
17
17
  import { createMetricsSamplerCache, MetricsSampler, type MetricsSamplerCache } from "./metrics-sampler";
18
18
  import { foregroundTracker, type ForegroundApp, type ForegroundTrackerCache } from "./foreground-tracker";
19
- import { corsAllowOriginHeaders } from "./middleware-utils";
19
+ import { corsAllowOriginHeaders, frameAncestorsPolicy } from "./middleware-utils";
20
20
  import {
21
21
  closeDeviceSession,
22
22
  getDeviceSession,
@@ -1501,6 +1501,7 @@ export interface SimMiddlewareOptions {
1501
1501
  * same-origin + token-gated regardless. Loopback is always allowed.
1502
1502
  */
1503
1503
  metricsCorsOrigins?: string[];
1504
+ frameAncestors?: string[];
1504
1505
  /** @deprecated Use `streamSettings: { transport: "http", codec }`. */
1505
1506
  codec?: string;
1506
1507
  /**
@@ -1586,6 +1587,7 @@ export function simMiddleware(options?: SimMiddlewareOptions): SimMiddleware {
1586
1587
  const execToken = options?.execToken ?? randomBytes(32).toString("base64url");
1587
1588
  const requirePreviewToken = options?.requirePreviewToken ?? false;
1588
1589
  const metricsCorsOrigins = options?.metricsCorsOrigins ?? [];
1590
+ const frameAncestors = options?.frameAncestors ?? [];
1589
1591
 
1590
1592
  // Simulator-settings requests run in-process (just the underlying simctl /
1591
1593
  // ax-tool spawn) instead of round-tripping a full `node <cli>` exec per
@@ -1721,6 +1723,9 @@ export function simMiddleware(options?: SimMiddlewareOptions): SimMiddleware {
1721
1723
  res.writeHead(200, {
1722
1724
  "Content-Type": "text/html; charset=utf-8",
1723
1725
  "Cache-Control": "no-store",
1726
+ ...(requirePreviewToken
1727
+ ? { "Content-Security-Policy": frameAncestorsPolicy(frameAncestors) }
1728
+ : {}),
1724
1729
  });
1725
1730
  res.end(html);
1726
1731
  return;