@botiverse/porthole 0.14.5 → 0.14.7

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 (76) hide show
  1. package/CHANGELOG.md +66 -0
  2. package/dist/check/page-source.js +1 -1
  3. package/dist/check/page.js +5 -1
  4. package/dist/compile/policy.d.ts +6 -0
  5. package/dist/compile/policy.js +6 -0
  6. package/dist/conformance/entry.d.ts +25 -6
  7. package/dist/conformance/entry.js +69 -18
  8. package/dist/conformance/harness/page.d.ts +12 -0
  9. package/dist/conformance/harness/page.js +95 -51
  10. package/dist/conformance/harness-source.js +1 -1
  11. package/dist/conformance/host-kit.js +39 -13
  12. package/dist/conformance/served.js +148 -0
  13. package/dist/files/paths.d.ts +2 -2
  14. package/dist/files/paths.js +12 -2
  15. package/dist/host/client.d.ts +8 -0
  16. package/dist/host/client.js +47 -17
  17. package/dist/host/create-host.d.ts +10 -0
  18. package/dist/host/create-host.js +124 -10
  19. package/dist/host/door.d.ts +41 -0
  20. package/dist/host/door.js +55 -0
  21. package/dist/host/locate.js +2 -0
  22. package/dist/host/locator.d.ts +55 -3
  23. package/dist/host/locator.js +152 -42
  24. package/dist/host/outcome.d.ts +54 -1
  25. package/dist/host/outcome.js +33 -8
  26. package/dist/host/types.d.ts +10 -2
  27. package/dist/isolation/served.d.ts +1 -1
  28. package/dist/isolation/served.js +35 -0
  29. package/dist/isolation/types.d.ts +20 -2
  30. package/dist/isolation/types.js +2 -0
  31. package/dist/platform/types.d.ts +22 -0
  32. package/dist/platform/web.js +55 -12
  33. package/dist/react/view.d.ts +13 -0
  34. package/dist/react/view.js +101 -2
  35. package/dist/server/files.d.ts +11 -0
  36. package/dist/server/files.js +26 -4
  37. package/dist/server/host.js +106 -28
  38. package/dist/server/index.d.ts +2 -1
  39. package/dist/server/index.js +7 -1
  40. package/dist/server/pages.d.ts +32 -0
  41. package/dist/server/pages.js +82 -6
  42. package/dist/server/server.js +194 -16
  43. package/dist/server/types.d.ts +38 -1
  44. package/dist/transport/post-message.d.ts +1 -9
  45. package/dist/transport/post-message.js +2 -8
  46. package/docs/ADOPTING.md +73 -4
  47. package/docs/DECISIONS.md +245 -0
  48. package/docs/DESIGN.md +24 -18
  49. package/docs/THREAT_MODEL.md +79 -13
  50. package/package.json +1 -1
  51. package/src/check/page.ts +6 -1
  52. package/src/compile/policy.ts +7 -0
  53. package/src/conformance/entry.ts +129 -24
  54. package/src/conformance/harness/page.ts +112 -49
  55. package/src/conformance/host-kit.ts +53 -16
  56. package/src/conformance/served.ts +184 -0
  57. package/src/files/paths.ts +11 -2
  58. package/src/host/client.ts +59 -22
  59. package/src/host/create-host.ts +144 -18
  60. package/src/host/door.ts +97 -0
  61. package/src/host/locate.ts +2 -0
  62. package/src/host/locator.ts +208 -57
  63. package/src/host/outcome.ts +41 -9
  64. package/src/host/types.ts +10 -2
  65. package/src/isolation/served.ts +40 -1
  66. package/src/isolation/types.ts +19 -2
  67. package/src/platform/types.ts +21 -0
  68. package/src/platform/web.ts +55 -20
  69. package/src/react/view.tsx +149 -2
  70. package/src/server/files.ts +37 -5
  71. package/src/server/host.ts +131 -46
  72. package/src/server/index.ts +7 -1
  73. package/src/server/pages.ts +101 -6
  74. package/src/server/server.ts +266 -32
  75. package/src/server/types.ts +41 -1
  76. package/src/transport/post-message.ts +1 -9
@@ -3,7 +3,7 @@ import { base64url, fromBase64url, fromUtf8, hmacSha256, timingSafeEqual, utf8 }
3
3
  import { ContentDomainError, contentDomain, serverDomain, } from "./domain.js";
4
4
  import { reservedLabels } from "./naming.js";
5
5
  import { peerAddress } from "./peer.js";
6
- import { appStatusPage } from "./pages.js";
6
+ import { appStatusPage, tabOnlyPage } from "./pages.js";
7
7
  import { createServer } from "./server.js";
8
8
  /**
9
9
  * The host kit (P066): everything around `/server` that every host wrote, so an app writes only
@@ -425,6 +425,20 @@ export function createContentHost(options) {
425
425
  };
426
426
  // Issues per key per minute, in this process.
427
427
  const issued = new Map();
428
+ /**
429
+ * What a clean address names (P068, P125): its label's scope (the naming's `scopeOf`) and what
430
+ * `entry.at` answers for its path, for this viewer. One mapping for a tab (`authorize`) and for a
431
+ * frame (`issue` given `{ address }`), so a frame shows what the address's tab would.
432
+ */
433
+ const entryAt = async (label, pathname, viewer, request) => {
434
+ const scope = options.name?.scopeOf?.(label) ?? null;
435
+ const at = options.entry?.at;
436
+ const answer = scope === null || at === undefined
437
+ ? null
438
+ : ((await at(scope, new URL(pathname, "https://x.invalid").pathname, viewer, request)) ??
439
+ null);
440
+ return { scope, answer };
441
+ };
428
442
  const withinRate = (key) => {
429
443
  const limit = options.rateLimit;
430
444
  if (limit === undefined) {
@@ -619,6 +633,10 @@ export function createContentHost(options) {
619
633
  catch {
620
634
  return refusal(400, "bad-json", "The body is JSON: { instance }");
621
635
  }
636
+ // A clean address (P125): what it names, as its tab would open it, issued for a frame.
637
+ if (isRecord(body) && body.instance === undefined && body.address !== undefined) {
638
+ return issueAddress(body.address, viewer, request);
639
+ }
622
640
  const proposal = isRecord(body) ? body.instance : undefined;
623
641
  if (!isRecord(proposal) ||
624
642
  typeof proposal.scope !== "string" ||
@@ -637,28 +655,86 @@ export function createContentHost(options) {
637
655
  ? refusal(401, "unauthenticated", "Sign in to see this")
638
656
  : refusal(403, "forbidden", "You can't see this");
639
657
  }
640
- let location;
641
- try {
642
- location = await server.issue(instance, grant);
643
- }
644
- catch (error) {
645
- return refusal(409, "refused", error instanceof Error ? error.message : String(error));
658
+ return issuedFor(instance, grant, request);
659
+ }
660
+ catch {
661
+ return refusal(500, "failed", "The app's policy failed");
662
+ }
663
+ };
664
+ /** A location issued for what the host's access granted, with its clean address. */
665
+ async function issuedFor(instance, grant, request, more = {}) {
666
+ let location;
667
+ try {
668
+ location = await server.issue(instance, grant, more.page === undefined ? undefined : { page: more.page });
669
+ }
670
+ catch (error) {
671
+ return refusal(409, "refused", error instanceof Error ? error.message : String(error));
672
+ }
673
+ // The clean address, where the app says the instance's path (P072, P074).
674
+ let link = null;
675
+ try {
676
+ const path = (await options.entry?.pathOf?.(instance, request)) ?? null;
677
+ link = path === null ? null : server.urlOf(instance.scope, path);
678
+ }
679
+ catch {
680
+ link = null;
681
+ }
682
+ return json(201, {
683
+ ...location,
684
+ ...(link === null ? {} : { link }),
685
+ // What a clean address named (P125): the instance its later frames are issued for.
686
+ ...(more.resolved === true ? { instance } : {}),
687
+ });
688
+ }
689
+ /**
690
+ * A clean address asked about for a frame (P125): resolved as its tab's authorize would
691
+ * resolve it (`entry.at`, then the host's access), and answered before any frame: a location
692
+ * with its door, or the same refusal the tab would get (401 signed out, 403 no access, 404
693
+ * nothing there). Never a redirect, never a page: the host shows its fallback from this.
694
+ */
695
+ async function issueAddress(given, viewer, request) {
696
+ let url;
697
+ try {
698
+ if (typeof given !== "string" || given.length > 4_096) {
699
+ throw new TypeError("not an address");
646
700
  }
647
- // The clean address, where the app says the instance's path (P072, P074).
648
- let link = null;
649
- try {
650
- const path = (await options.entry?.pathOf?.(instance, request)) ?? null;
651
- link = path === null ? null : server.urlOf(instance.scope, path);
701
+ url = new URL(given);
702
+ }
703
+ catch {
704
+ return refusal(400, "bad-request", "The body is { address: <a clean address> }");
705
+ }
706
+ const label = domain?.labelOf(url.host) ?? null;
707
+ if (options.entry === undefined ||
708
+ domain === null ||
709
+ label === null ||
710
+ domain.originOf(label) !== url.origin ||
711
+ url.pathname.startsWith("/__porthole/")) {
712
+ return refusal(404, "not-found", "That address names nothing here");
713
+ }
714
+ try {
715
+ const { answer } = await entryAt(label, `${url.pathname}${url.search}`, viewer, request);
716
+ const address = answer !== null && isFileAddress(answer) ? answer : null;
717
+ const instance = address === null ? answer : address.instance;
718
+ if (instance === null) {
719
+ return refusal(404, "not-found", "That address names nothing here");
652
720
  }
653
- catch {
654
- link = null;
721
+ const grant = await options.access(instance, viewer, request);
722
+ if (grant === null) {
723
+ return viewer === null
724
+ ? refusal(401, "unauthenticated", "Sign in to see this")
725
+ : refusal(403, "forbidden", "You can't see this");
655
726
  }
656
- return json(201, link === null ? location : { ...location, link });
727
+ // A file set's address below its version (P081): the frame opens at that page.
728
+ const page = address?.file !== undefined && address.file !== "" ? address.file : undefined;
729
+ return await issuedFor(instance, grant, request, {
730
+ ...(page === undefined ? {} : { page }),
731
+ resolved: true,
732
+ });
657
733
  }
658
734
  catch {
659
735
  return refusal(500, "failed", "The app's policy failed");
660
736
  }
661
- };
737
+ }
662
738
  },
663
739
  meta: () => ({
664
740
  served: served(),
@@ -777,13 +853,19 @@ export function createContentHost(options) {
777
853
  if (state === null) {
778
854
  return appPage(400, "This link isn't valid", "Open the address again.", "error", method);
779
855
  }
856
+ // Redirect entry is for a tab alone (P125): asked in a frame, it never shows the app's
857
+ // sign-in or refusal there, and says nothing to the page that frames it.
780
858
  const dest = request.headers.get("sec-fetch-dest");
781
- const framed = dest === null ? state.framed : dest !== "document";
859
+ if (dest === "iframe" || dest === "frame") {
860
+ return tabOnlyPage(options.appOrigins.join(" "), method);
861
+ }
782
862
  const clean = `${domain.originOf(state.label)}${state.path}`;
783
863
  if (state.expired) {
784
- return appPage(401, "This took too long", "Open the address again.", "session", method, framed ? undefined : { href: clean, text: "Open it again" });
864
+ return appPage(401, "This took too long", "Open the address again.", "session", method, {
865
+ href: clean,
866
+ text: "Open it again",
867
+ });
785
868
  }
786
- const scope = options.name?.scopeOf?.(state.label) ?? null;
787
869
  let viewer;
788
870
  try {
789
871
  viewer = (await viewerOf(request)) ?? (await handedOver(request));
@@ -792,9 +874,7 @@ export function createContentHost(options) {
792
874
  return appPage(500, "Something went wrong", "The app couldn't tell who is asking.", "error", method);
793
875
  }
794
876
  try {
795
- const answer = scope === null
796
- ? null
797
- : ((await entry.at(scope, new URL(state.path, "https://x.invalid").pathname, viewer, request)) ?? null);
877
+ const { scope, answer } = await entryAt(state.label, state.path, viewer, request);
798
878
  // A file set's address (P081) names its instance and where its version lives.
799
879
  const address = answer !== null && isFileAddress(answer) ? answer : null;
800
880
  const instance = address === null ? answer : address.instance;
@@ -806,17 +886,15 @@ export function createContentHost(options) {
806
886
  path: state.path,
807
887
  url: clean,
808
888
  instance,
809
- framed,
889
+ // A frame never gets here since P125: kept for the hooks' type.
890
+ framed: false,
810
891
  };
811
892
  if (instance === null || grant === null) {
812
893
  if (viewer === null) {
813
- // The app's sign-in never shows in a frame: the person opens a tab for it.
814
- return framed
815
- ? appPage(401, "Open this in a new tab to sign in", "Signing in doesn't work inside a frame.", "sign-in", method)
816
- : await signInWith(entry, request, context);
894
+ return await signInWith(entry, request, context);
817
895
  }
818
896
  const status = instance === null ? 404 : 403;
819
- const own = framed ? null : await entry.refusal?.(status, request, context);
897
+ const own = await entry.refusal?.(status, request, context);
820
898
  if (own !== null && own !== undefined) {
821
899
  return own;
822
900
  }
@@ -36,7 +36,8 @@ export { createServer } from "./server.ts";
36
36
  export { createContentHost, HEALTH_PATH, ISSUE_BODY_BYTES, type ContentHealthView, type ContentHost, type ContentHostEvent, type ContentHostOptions, type ContentClientMeta, type ContentLogger, type EntryContext, type EntryOptions, ASSET_LIBRARY_PATH, type FileAddress, isFileAddress, versionBase, versionedAddress, type ContentMeta, type HealthOptions, type HealthProbe, } from "./host.ts";
37
37
  export { clashOf, contentDomain, ContentDomainError, hostnameOf, type ContentDomainInfo, type ContentDomainProblem, } from "./domain.ts";
38
38
  export { d1TicketSchema, d1TicketStore, memoryTicketStore, type D1Like, type D1StatementLike, } from "./tickets.ts";
39
- export { FRAME_STATUS_METHOD } from "../isolation/types.ts";
39
+ export { DOOR_PATH, FRAME_STATUS_METHOD } from "../isolation/types.ts";
40
+ export { doorResponse, doorStatusResponse, type DoorOptions } from "./pages.ts";
40
41
  export { isNestedLabel, NESTED_FILE_HEADERS, NESTED_FILES_PREFIX, nestedAncestors, nestedFileCsp, nestedLabelOf, nestedShellCsp, nestedShellResponse, PORTHOLE_LABEL_PREFIX, } from "./nested.ts";
41
42
  export { isHostLabel, prefixedName, type Naming } from "./naming.ts";
42
43
  export { conformancePage } from "../conformance/page.ts";
@@ -36,7 +36,13 @@ export { createServer } from "./server.js";
36
36
  export { createContentHost, HEALTH_PATH, ISSUE_BODY_BYTES, ASSET_LIBRARY_PATH, isFileAddress, versionBase, versionedAddress, } from "./host.js";
37
37
  export { clashOf, contentDomain, ContentDomainError, hostnameOf, } from "./domain.js";
38
38
  export { d1TicketSchema, d1TicketStore, memoryTicketStore, } from "./tickets.js";
39
- export { FRAME_STATUS_METHOD } from "../isolation/types.js";
39
+ export { DOOR_PATH, FRAME_STATUS_METHOD } from "../isolation/types.js";
40
+ // A served display's door (P125): `/server` serves it for a shell, a page that isn't nested and the
41
+ // sandbox proxy; a content Worker of a host's own answers the same at `DOOR_PATH<key>`, after
42
+ // taking the door's own ticket (`TicketRecord.door`) and running the checks its content's address
43
+ // runs (docs/ADOPTING.md, "The door"). A host that signs its own tickets answers it with
44
+ // `PortholeServer.doorAnswer` once it has admitted the request itself (P126).
45
+ export { doorResponse, doorStatusResponse } from "./pages.js";
40
46
  // A nested page (P111): Porthole's shell at the framed address, the page and its files below the
41
47
  // sealed prefix, all on the shell's own label (P114, `nestedLabelOf`). `/server` serves them for a
42
48
  // config with `nested`; a content Worker of its own answers the same (docs/ADOPTING.md, "Nested
@@ -37,3 +37,35 @@ export declare function statusPageOf(options: {
37
37
  };
38
38
  readonly method?: string;
39
39
  }): Response;
40
+ /** What a door is given: the host origins it tells, and who may frame it (default, those). */
41
+ export interface DoorOptions {
42
+ readonly hostOrigins: readonly string[];
43
+ readonly frameAncestors?: string;
44
+ readonly method?: string;
45
+ }
46
+ /**
47
+ * A door that opens (P125): its display may be framed. It says `open` to the page that frames it,
48
+ * at each web host origin and (a desktop scheme among them) to its parent (P070), once, as it
49
+ * parses. For a content Worker of a host's own: answer it at `DOOR_PATH<key>` only once the door's
50
+ * own ticket was taken and the checks the content's address runs passed for the same grant.
51
+ */
52
+ export declare function doorResponse(options: DoorOptions): Response;
53
+ /**
54
+ * A door that doesn't open (P125): why, said `blocked` to the page that frames it, as a content
55
+ * origin's status page says it (`session` 401: no ticket, or one used, ended, or not a door's of
56
+ * this instance on this origin; `denied` 403 with the host's code; `not-found` 404: no document, or
57
+ * a file set whose entry isn't a page; `error` 500).
58
+ */
59
+ export declare function doorStatusResponse(options: DoorOptions & {
60
+ readonly status: number;
61
+ readonly reason: FrameBlock;
62
+ readonly code?: string;
63
+ }): Response;
64
+ /**
65
+ * What a clean address answers in a frame (P125): a clean address is for a tab of its own, so in a
66
+ * frame it never goes to the app (no authorize, no sign-in, no refusal page of the app's) and says
67
+ * nothing to the page that frames it: no script at all, under the status pages' policy without
68
+ * `script-src` (so `default-src 'none'` forbids every script), framed by the host origins only. A
69
+ * host frames what a clean address names by resolving it through `issue` (`client.resolve`).
70
+ */
71
+ export declare function tabOnlyPage(frameAncestors: string, method?: string): Response;
@@ -1,3 +1,4 @@
1
+ import { DOOR_SANDBOX_TOKENS } from "../compile/policy.js";
1
2
  import { FRAME_STATUS_METHOD } from "../isolation/types.js";
2
3
  import { base64url, sha256, utf8 } from "./crypto.js";
3
4
  /**
@@ -109,15 +110,16 @@ export function enterPage(target, frameAncestors, hostOrigins, cookie) {
109
110
  headers.set("set-cookie", cookie);
110
111
  return new Response(body, { status: 200, headers });
111
112
  }
112
- /** The status script's hash, for a page that carries it inline (`script-src 'sha256-…'`). */
113
- let statusHash = null;
114
- const hashOfStatus = () => {
115
- statusHash ??= base64url(sha256(utf8(STATUS_SCRIPT)))
113
+ /** A script's hash, for a page that carries it inline (`script-src 'sha256-…'`). */
114
+ const hashOf = (script) => {
115
+ const hash = base64url(sha256(utf8(script)))
116
116
  .replace(/-/gu, "+")
117
117
  .replace(/_/gu, "/");
118
- const padding = (4 - (statusHash.length % 4)) % 4;
119
- return `'sha256-${statusHash}${"=".repeat(padding)}'`;
118
+ const padding = (4 - (hash.length % 4)) % 4;
119
+ return `'sha256-${hash}${"=".repeat(padding)}'`;
120
120
  };
121
+ let statusHash = null;
122
+ const hashOfStatus = () => (statusHash ??= hashOf(STATUS_SCRIPT));
121
123
  /**
122
124
  * A redirect entry's page on the app's own origin (P068): why it shows nothing, told to the page
123
125
  * that frames it like a content origin's page. Plain, no app chrome; its one script inline under
@@ -148,3 +150,77 @@ export function appStatusPage(status, title, detail, frameAncestors, reason, hos
148
150
  export function statusPageOf(options) {
149
151
  return appStatusPage(options.status, options.title, options.detail, options.frameAncestors ?? options.hostOrigins.join(" "), options.reason ?? "error", options.hostOrigins, options.link, options.method);
150
152
  }
153
+ /** A door's word that its display may be framed (P125), from the page's data attributes. */
154
+ const DOOR_SCRIPT = `(() => {
155
+ const main = document.querySelector("[data-porthole-door]");
156
+ if (main === null) return;
157
+ const hosts = JSON.parse(main.dataset.portholeHosts || "[]");
158
+ ${say()}
159
+ say({ state: "open" });
160
+ })();`;
161
+ let doorHash = null;
162
+ const hashOfDoor = () => (doorHash ??= hashOf(DOOR_SCRIPT));
163
+ /**
164
+ * A door's headers (P125): its one script by its hash (an opaque document has no `'self'` to load
165
+ * one from), nothing else loads, sandboxed with scripts alone in its header too (opaque on a tab, and
166
+ * in a frame whose attribute a host's own platform forgot), framed by the host origins, never
167
+ * cached, never sent on, no cookie.
168
+ */
169
+ const doorHeaders = (script, frameAncestors) => new Headers({
170
+ "content-type": "text/html; charset=utf-8",
171
+ "cache-control": "no-store",
172
+ "content-security-policy": `default-src 'none'; script-src ${script}; base-uri 'none'; form-action 'none'; sandbox ${DOOR_SANDBOX_TOKENS.join(" ")}; frame-ancestors ${frameAncestors}`,
173
+ "referrer-policy": "no-referrer",
174
+ "x-content-type-options": "nosniff",
175
+ "x-robots-tag": "noindex, nofollow",
176
+ });
177
+ /**
178
+ * A door that opens (P125): its display may be framed. It says `open` to the page that frames it,
179
+ * at each web host origin and (a desktop scheme among them) to its parent (P070), once, as it
180
+ * parses. For a content Worker of a host's own: answer it at `DOOR_PATH<key>` only once the door's
181
+ * own ticket was taken and the checks the content's address runs passed for the same grant.
182
+ */
183
+ export function doorResponse(options) {
184
+ const hosts = escape(JSON.stringify(options.hostOrigins));
185
+ const body = `<!doctype html><html lang="en"><head><meta charset="utf-8"><title>Opening</title></head><body><main data-porthole-door="" data-porthole-hosts="${hosts}"></main><script>${DOOR_SCRIPT}</script></body></html>`;
186
+ return new Response(options.method?.toUpperCase() === "HEAD" ? null : body, {
187
+ status: 200,
188
+ headers: doorHeaders(hashOfDoor(), options.frameAncestors ?? options.hostOrigins.join(" ")),
189
+ });
190
+ }
191
+ /**
192
+ * A door that doesn't open (P125): why, said `blocked` to the page that frames it, as a content
193
+ * origin's status page says it (`session` 401: no ticket, or one used, ended, or not a door's of
194
+ * this instance on this origin; `denied` 403 with the host's code; `not-found` 404: no document, or
195
+ * a file set whose entry isn't a page; `error` 500).
196
+ */
197
+ export function doorStatusResponse(options) {
198
+ const { status, reason, code } = options;
199
+ const hosts = escape(JSON.stringify(options.hostOrigins));
200
+ const body = `<!doctype html><html lang="en"><head><meta charset="utf-8"><title>Not shown</title></head><body><main data-porthole-status="${status}" data-porthole-reason="${escape(reason)}"${code === undefined ? "" : ` data-porthole-code="${escape(code)}"`} data-porthole-hosts="${hosts}"></main><script>${STATUS_SCRIPT}</script></body></html>`;
201
+ return new Response(options.method?.toUpperCase() === "HEAD" ? null : body, {
202
+ status,
203
+ headers: doorHeaders(hashOfStatus(), options.frameAncestors ?? options.hostOrigins.join(" ")),
204
+ });
205
+ }
206
+ /**
207
+ * What a clean address answers in a frame (P125): a clean address is for a tab of its own, so in a
208
+ * frame it never goes to the app (no authorize, no sign-in, no refusal page of the app's) and says
209
+ * nothing to the page that frames it: no script at all, under the status pages' policy without
210
+ * `script-src` (so `default-src 'none'` forbids every script), framed by the host origins only. A
211
+ * host frames what a clean address names by resolving it through `issue` (`client.resolve`).
212
+ */
213
+ export function tabOnlyPage(frameAncestors, method = "GET") {
214
+ const body = `<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><title>Open this in a new tab</title><style>${STYLE}</style></head><body><main data-porthole-tab-only=""><h1>Open this in a new tab</h1><p>This address opens in a tab of its own, not inside a frame.</p></main></body></html>`;
215
+ return new Response(method.toUpperCase() === "HEAD" ? null : body, {
216
+ status: 403,
217
+ headers: {
218
+ "content-type": "text/html; charset=utf-8",
219
+ "cache-control": "no-store",
220
+ "content-security-policy": `default-src 'none'; style-src 'unsafe-inline'; base-uri 'none'; form-action 'none'; frame-ancestors ${frameAncestors}`,
221
+ "referrer-policy": "no-referrer",
222
+ "x-content-type-options": "nosniff",
223
+ "x-robots-tag": "noindex, nofollow",
224
+ },
225
+ });
226
+ }