@sixb/app 0.1.16 → 0.1.17

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/README.md CHANGED
@@ -216,6 +216,14 @@ Tailwind's source detection is scoped to `app/`, and the CLI is resolved from th
216
216
 
217
217
  `createCustomApp().start(options)` serves the built app from `.sixb/dist/app/` on a Bun server. When `apiBaseUrl` is provided, it is injected into the served HTML at runtime so the public custom app shell can call the Sixb API origin with credentials.
218
218
 
219
+ Every app and shared page, in `dev()` too, carries `frame-src` for the API's origin plus the sites
220
+ in `SIXB_APP_FRAME_ORIGINS`, read when `dev()` or `start()` starts. That directive is what keeps an
221
+ artifact frame's own navigations on those origins (its sandbox already denies popups and top
222
+ navigation), so the list takes exact origins only: a wildcard would let an artifact send what it
223
+ reads to any site it matches. When the browser refuses an `<iframe>` the page itself rendered, the
224
+ generated runtime names the variable in the console; an artifact frame's refused navigation stays
225
+ unexplained.
226
+
219
227
  Shared links require the built-in server in V1; static SPA fallbacks and external hosting adapters
220
228
  are unsupported. It serves the isolated shell with a fresh CSP nonce, `no-store`, `no-referrer`,
221
229
  and no eager asset loading. App and API must be same-site (`SameSite=Strict` cookies).
@@ -1 +1 @@
1
- {"version":3,"file":"codegen.d.ts","sourceRoot":"","sources":["../src/codegen.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,SAAS,EAAmB,MAAM,WAAW,CAAA;AAEhF,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAA;IAChC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,oFAAoF;IACpF,QAAQ,CAAC,eAAe,CAAC,EAAE,OAAO,CAAA;CACnC;AAED,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,CAAC,aAAa,CAAC,EAAE,SAAS,yBAAyB,EAAE,CAAA;IAC7D,QAA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f,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,WAAW,CAAC,EAAE,OAAO,CAAA;CACtB;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAA;IACZ,sEAAsE;IACtE,IAAI,EAAE,MAAM,CAAA;IACZ,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;CACtB;AAED,MAAM,WAAW,kBAAmB,SAAQ,eAAe;IACzD,+FAA+F;IAC/F,cAAc,EAAE,OAAO,CAAA;CACxB;AAED,MAAM,WAAW,iBAAiB;IAChC,UAAU,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC,CAAA;IAClC,qBAAqB,CACnB,OAAO,CAAC,EAAE,gCAAgC,GACzC,OAAO,CAAC,+BAA+B,GAAG,IAAI,CAAC,CAAA;IAClD,GAAG,CAAC,OAAO,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAA;IAC/D,KAAK,CAAC,OAAO,CAAC,EAAE,qBAAqB,GAAG,OAAO,CAAC,cAAc,CAAC,CAAA;IAC/D,KAAK,CAAC,OAAO,CAAC,EAAE,qBAAqB,GAAG,OAAO,CAAC,eAAe,CAAC,CAAA;CACjE;AAuBD,wBAAsB,eAAe,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CA0kBjG;AA2BD,4FAA4F;AAC5F,qBAAa,uBAAwB,SAAQ,KAAK;IAGpC,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE;IAF/C,QAAQ,CAAC,IAAI,6BAA4B;gBAEpB,OAAO,EAAE,SAAS,MAAM,EAAE;CAMhD"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * The sites besides the API that the app's pages may show in an `<iframe>`, from a comma-separated
3
+ * list such as `https://www.youtube-nocookie.com,https://contoso.sharepoint.com`.
4
+ *
5
+ * They join the `frame-src` that keeps artifact frames on the API's origin, and a frame may navigate
6
+ * itself to any site the policy allows: an artifact page could send what it reads to a site listed
7
+ * here. Each entry is therefore one exact origin, never a wildcard, a scheme, or a keyword.
8
+ */
9
+ export declare function readAppFrameOrigins(env: Readonly<Record<string, string | undefined>>): readonly string[];
10
+ //# sourceMappingURL=frame-origins.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"frame-origins.d.ts","sourceRoot":"","sources":["../src/frame-origins.ts"],"names":[],"mappings":"AAMA;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,GAChD,SAAS,MAAM,EAAE,CAOnB"}
package/dist/server.js CHANGED
@@ -1109,6 +1109,49 @@ function InternalLinkInterceptor({ basename }: { readonly basename?: string }) {
1109
1109
  return null
1110
1110
  }
1111
1111
 
1112
+ // The page frames only the API and the sites SIXB_APP_FRAME_ORIGINS lists. The browser logs a
1113
+ // refused <iframe> without saying where that list lives: name it, once per site. A site counts
1114
+ // only when an <iframe> asked for it: an artifact frame that navigates elsewhere keeps the API's
1115
+ // address as its src, and the list is no place for wherever its code tried to go.
1116
+ function RefusedFrameReporter() {
1117
+ // Subscribed before the browser can report a frame rendered in the same commit.
1118
+ React.useLayoutEffect(() => {
1119
+ const reported = new Set<string>()
1120
+
1121
+ function onViolation(event: SecurityPolicyViolationEvent) {
1122
+ if (event.effectiveDirective !== "frame-src") return
1123
+
1124
+ const origin = originOf(event.blockedURI)
1125
+ if (!origin || reported.has(origin)) return
1126
+
1127
+ const frames = Array.from(document.querySelectorAll("iframe"))
1128
+ if (!frames.some((frame) => originOf(frame.src) === origin)) return
1129
+
1130
+ reported.add(origin)
1131
+ console.warn(
1132
+ "[SixbApp] The app refused to frame " +
1133
+ origin +
1134
+ ". Add each site a frame loads, redirects included, to SIXB_APP_FRAME_ORIGINS on the " +
1135
+ "app server."
1136
+ )
1137
+ }
1138
+
1139
+ document.addEventListener("securitypolicyviolation", onViolation)
1140
+ return () => document.removeEventListener("securitypolicyviolation", onViolation)
1141
+ }, [])
1142
+
1143
+ return null
1144
+ }
1145
+
1146
+ function originOf(url: string): string | null {
1147
+ try {
1148
+ const { origin } = new URL(url)
1149
+ return origin === "null" ? null : origin
1150
+ } catch {
1151
+ return null
1152
+ }
1153
+ }
1154
+
1112
1155
  function pathInsideApp(pathname: string, basename: string | undefined): string {
1113
1156
  if (
1114
1157
  basename &&
@@ -1379,6 +1422,7 @@ function App({ basename }: StartAppOptions) {
1379
1422
  ${sectionsStart}
1380
1423
  <BrowserRouter basename={basename}>
1381
1424
  <ActivityPageView />
1425
+ <RefusedFrameReporter />
1382
1426
  <SharedDocumentLinkInterceptor basename={basename} />
1383
1427
  <InternalLinkInterceptor basename={basename} />
1384
1428
  {basename ? (
@@ -1955,6 +1999,32 @@ function devReloadResponse(request) {
1955
1999
  return new Response(script, { headers });
1956
2000
  }
1957
2001
 
2002
+ // src/frame-origins.ts
2003
+ var APP_FRAME_ORIGINS_ENV = "SIXB_APP_FRAME_ORIGINS";
2004
+ var CSP_HOST = /^[a-z0-9-]+(?:\.[a-z0-9-]+)*$/;
2005
+ function readAppFrameOrigins(env) {
2006
+ const entries = (env[APP_FRAME_ORIGINS_ENV] ?? "").split(",").map((entry) => entry.trim()).filter((entry) => entry !== "");
2007
+ return [...new Set(entries.map(frameOrigin))];
2008
+ }
2009
+ function frameOrigin(entry) {
2010
+ if (entry.includes("*")) {
2011
+ throw new Error(`[SixbCustomApp] ${APP_FRAME_ORIGINS_ENV}: '${entry}' is a wildcard. List each site, such as ` + "https://contoso.sharepoint.com: an artifact's frame can navigate to any site this " + "variable allows.");
2012
+ }
2013
+ let url;
2014
+ try {
2015
+ url = new URL(entry);
2016
+ } catch {
2017
+ throw notAnOrigin(entry);
2018
+ }
2019
+ const exact = (url.protocol === "https:" || url.protocol === "http:") && CSP_HOST.test(url.hostname) && !url.username && !url.password && url.pathname === "/" && !url.search && !url.hash;
2020
+ if (!exact)
2021
+ throw notAnOrigin(entry);
2022
+ return url.origin;
2023
+ }
2024
+ function notAnOrigin(entry) {
2025
+ return new Error(`[SixbCustomApp] ${APP_FRAME_ORIGINS_ENV}: '${entry}' is not an origin. Give the scheme, host ` + "and optional port of each site, such as https://contoso.sharepoint.com.");
2026
+ }
2027
+
1958
2028
  // src/styles.ts
1959
2029
  import { readFile as readFile4 } from "fs/promises";
1960
2030
  import { join as join6 } from "path";
@@ -2286,6 +2356,7 @@ async function createCustomApp(options) {
2286
2356
  },
2287
2357
  async dev(devOptions = {}) {
2288
2358
  const publicEnv = collectPublicEnv();
2359
+ const frameOrigins = readAppFrameOrigins(process.env);
2289
2360
  const withRuntime = (html) => injectRuntimeConfig(html, { apiBaseUrl, authEnabled, publicEnv });
2290
2361
  const host = devOptions.host ?? "0.0.0.0";
2291
2362
  const port = devOptions.port ?? 3000;
@@ -2322,16 +2393,18 @@ async function createCustomApp(options) {
2322
2393
  apiBaseUrl,
2323
2394
  authEnabled: false,
2324
2395
  publicEnv
2325
- }), apiBaseUrl),
2396
+ }), apiBaseUrl, frameOrigins),
2326
2397
  "/": spaHtmlRoute(() => internalOrigin, {
2327
2398
  shellRoute: privateAppShellRoute,
2328
2399
  transformHtml: withRuntime,
2329
- apiBaseUrl
2400
+ apiBaseUrl,
2401
+ frameOrigins
2330
2402
  }),
2331
2403
  "/*": spaHtmlRoute(() => internalOrigin, {
2332
2404
  shellRoute: privateAppShellRoute,
2333
2405
  transformHtml: withRuntime,
2334
- apiBaseUrl
2406
+ apiBaseUrl,
2407
+ frameOrigins
2335
2408
  })
2336
2409
  }
2337
2410
  });
@@ -2459,6 +2532,7 @@ async function createCustomApp(options) {
2459
2532
  },
2460
2533
  async start(startOptions = {}) {
2461
2534
  const publicEnv = collectPublicEnv();
2535
+ const frameOrigins = readAppFrameOrigins(process.env);
2462
2536
  const host = startOptions.host ?? "0.0.0.0";
2463
2537
  const port = startOptions.port ?? 3000;
2464
2538
  const outdir = resolve3(rootDir, startOptions.outdir ?? join7(".sixb", "dist", "app"));
@@ -2503,13 +2577,13 @@ async function createCustomApp(options) {
2503
2577
  if (isAssetRequest(url.pathname)) {
2504
2578
  return notFoundResponse();
2505
2579
  }
2506
- return sharedHtmlResponse(req, sharedIndexHtml, runtimeApiBaseUrl);
2580
+ return sharedHtmlResponse(req, sharedIndexHtml, runtimeApiBaseUrl, frameOrigins);
2507
2581
  }
2508
2582
  if (isSharedNamespace(url.pathname)) {
2509
2583
  return notFoundResponse();
2510
2584
  }
2511
2585
  if (url.pathname === "/" || url.pathname === "") {
2512
- return htmlResponse(req, indexHtml, runtimeApiBaseUrl);
2586
+ return htmlResponse(req, indexHtml, runtimeApiBaseUrl, frameOrigins);
2513
2587
  }
2514
2588
  const resolvedPath = resolveStaticPath(outdir, url.pathname);
2515
2589
  if (!resolvedPath) {
@@ -2518,7 +2592,7 @@ async function createCustomApp(options) {
2518
2592
  const directFile = Bun.file(resolvedPath);
2519
2593
  if (await directFile.exists()) {
2520
2594
  if (resolvedPath === indexPath) {
2521
- return htmlResponse(req, indexHtml, runtimeApiBaseUrl);
2595
+ return htmlResponse(req, indexHtml, runtimeApiBaseUrl, frameOrigins);
2522
2596
  }
2523
2597
  return staticFileResponse(req, resolvedPath, staticAssetHeaders(url.pathname));
2524
2598
  }
@@ -2528,7 +2602,7 @@ async function createCustomApp(options) {
2528
2602
  const htmlFile = Bun.file(`${resolvedPath}.html`);
2529
2603
  if (await htmlFile.exists()) {
2530
2604
  if (`${resolvedPath}.html` === indexPath) {
2531
- return htmlResponse(req, indexHtml, runtimeApiBaseUrl);
2605
+ return htmlResponse(req, indexHtml, runtimeApiBaseUrl, frameOrigins);
2532
2606
  }
2533
2607
  return fileResponse(req, htmlFile);
2534
2608
  }
@@ -2536,7 +2610,7 @@ async function createCustomApp(options) {
2536
2610
  if (await nestedIndexFile.exists()) {
2537
2611
  return fileResponse(req, nestedIndexFile);
2538
2612
  }
2539
- return htmlResponse(req, indexHtml, runtimeApiBaseUrl);
2613
+ return htmlResponse(req, indexHtml, runtimeApiBaseUrl, frameOrigins);
2540
2614
  }
2541
2615
  });
2542
2616
  const displayHost = host === "0.0.0.0" ? "localhost" : host;
@@ -2702,14 +2776,14 @@ function reservedSixbRoutes() {
2702
2776
  "/docs/*": allMethodsRoute(handler)
2703
2777
  };
2704
2778
  }
2705
- function sharedAppDevRoutes(html, apiBaseUrl) {
2779
+ function sharedAppDevRoutes(html, apiBaseUrl, frameOrigins) {
2706
2780
  const reject = () => notFoundResponse();
2707
2781
  const guardedHandler = async (request) => {
2708
2782
  const pathname = new URL(request.url).pathname;
2709
2783
  if (!isSharedAppRoute(pathname) || isAssetRequest(pathname)) {
2710
2784
  return notFoundResponse();
2711
2785
  }
2712
- return sharedHtmlResponse(request, await html(), apiBaseUrl);
2786
+ return sharedHtmlResponse(request, await html(), apiBaseUrl, frameOrigins);
2713
2787
  };
2714
2788
  return {
2715
2789
  "/shared": allMethodsRoute(reject),
@@ -2835,21 +2909,22 @@ function injectRuntimeConfig(html, config) {
2835
2909
  return `${script}
2836
2910
  ${html}`;
2837
2911
  }
2838
- function htmlResponse(request, html, apiBaseUrl) {
2912
+ function htmlResponse(request, html, apiBaseUrl, frameOrigins) {
2839
2913
  return new Response(request.method === "HEAD" ? null : html, {
2840
2914
  headers: {
2841
2915
  "content-type": "text/html; charset=utf-8",
2842
2916
  "cache-control": "no-store",
2843
- "content-security-policy": appContentSecurityPolicy(request, apiBaseUrl)
2917
+ "content-security-policy": appContentSecurityPolicy(request, apiBaseUrl, frameOrigins)
2844
2918
  }
2845
2919
  });
2846
2920
  }
2847
- function appContentSecurityPolicy(request, apiBaseUrl) {
2848
- return `frame-src ${frameSource(request, apiBaseUrl)}`;
2921
+ function appContentSecurityPolicy(request, apiBaseUrl, frameOrigins) {
2922
+ return `frame-src ${frameSources(request, apiBaseUrl, frameOrigins)}`;
2849
2923
  }
2850
- function frameSource(request, apiBaseUrl) {
2924
+ function frameSources(request, apiBaseUrl, frameOrigins) {
2851
2925
  const { requestOrigin, apiOrigin } = resolveOrigins(request, apiBaseUrl);
2852
- return apiOrigin === requestOrigin ? "'self'" : apiOrigin;
2926
+ const api = apiOrigin === requestOrigin ? "'self'" : apiOrigin;
2927
+ return [api, ...frameOrigins.filter((origin) => origin !== apiOrigin)].join(" ");
2853
2928
  }
2854
2929
  function resolveOrigins(request, apiBaseUrl) {
2855
2930
  const requestOrigin = new URL(request.url).origin;
@@ -2859,8 +2934,8 @@ function resolveOrigins(request, apiBaseUrl) {
2859
2934
  return { requestOrigin, apiOrigin: requestOrigin };
2860
2935
  }
2861
2936
  }
2862
- function sharedHtmlResponse(request, html, apiBaseUrl) {
2863
- const secured = secureSharedHtml(html, request, { apiBaseUrl });
2937
+ function sharedHtmlResponse(request, html, apiBaseUrl, frameOrigins) {
2938
+ const secured = secureSharedHtml(html, request, { apiBaseUrl, frameOrigins });
2864
2939
  return new Response(request.method === "HEAD" ? null : secured.html, {
2865
2940
  headers: {
2866
2941
  "content-type": "text/html; charset=utf-8",
@@ -2887,7 +2962,7 @@ function secureSharedHtml(html, request, options) {
2887
2962
  `media-src ${fileSources.join(" ")}`,
2888
2963
  "font-src 'self' data: https:",
2889
2964
  `connect-src ${connectSources.join(" ")}`,
2890
- `frame-src ${frameSource(request, options.apiBaseUrl)}`,
2965
+ `frame-src ${frameSources(request, options.apiBaseUrl, options.frameOrigins)}`,
2891
2966
  "manifest-src 'none'"
2892
2967
  ].join("; ");
2893
2968
  return {
@@ -3022,7 +3097,7 @@ function devServerInternalOrigin(host, port) {
3022
3097
  const urlHost = host.includes(":") && !host.startsWith("[") ? `[${host}]` : host;
3023
3098
  return `http://${urlHost}:${port}`;
3024
3099
  }
3025
- function spaHtmlRoute(internalOrigin, options = {}) {
3100
+ function spaHtmlRoute(internalOrigin, options) {
3026
3101
  return getHeadRoute(async (request) => {
3027
3102
  const publicUrl = new URL(request.url);
3028
3103
  if (isReservedSixbRoute(publicUrl.pathname) || isSharedNamespace(publicUrl.pathname) || isFrameworkPrivateRoute(publicUrl.pathname)) {
@@ -3047,7 +3122,7 @@ function spaHtmlRoute(internalOrigin, options = {}) {
3047
3122
  const responseHeaders = new Headers(bundleResponse.headers);
3048
3123
  responseHeaders.delete("content-length");
3049
3124
  responseHeaders.delete("etag");
3050
- responseHeaders.set("content-security-policy", appContentSecurityPolicy(request, options.apiBaseUrl));
3125
+ responseHeaders.set("content-security-policy", appContentSecurityPolicy(request, options.apiBaseUrl, options.frameOrigins));
3051
3126
  if (request.method === "HEAD") {
3052
3127
  return new Response(null, {
3053
3128
  status: bundleResponse.status,
@@ -3068,4 +3143,4 @@ export {
3068
3143
  createCustomApp
3069
3144
  };
3070
3145
 
3071
- //# debugId=09F38C785FF2F5BB64756E2164756E21
3146
+ //# debugId=9EABE79BF0F648AF64756E2164756E21