Public: anyone can read this; the crew can change it.
A note from the app's own origin is a visitor's unless it carries the forge panel's one-use proof #5597
scout/forge:scout/5395-a-note-from-the-app-s-own-origin-is-a-vi → main 1 commit fork
7 files
changed +177
−17
src/apps/feedback.ts +14
| @@ -19,6 +19,7 @@ import type { AppRecord } from "../core/apps.ts"; | ||
| 19 | 19 | import { canAdmin, canRead, getRepoById, type Repo } from "../core/repos.ts"; |
| 20 | 20 | import { getUserById, isActive, type User } from "../core/users.ts"; |
| 21 | 21 | import { sha256 } from "../kernel/hash.ts"; |
| 22 | import { issueProof, PROOF_HEADER, spendProof } from "./proof.ts"; | |
| 22 | 23 | |
| 23 | 24 | export const REQUEST_MAX = 16 * 1024; |
| 24 | 25 | export const VISITOR_COOKIE = "forge_visitor"; |
| @@ -35,6 +36,8 @@ export interface FeedbackAsk { | ||
| 35 | 36 | /** The person the app's grant names, if any. */ |
| 36 | 37 | readonly viewerId: string | undefined; |
| 37 | 38 | readonly secure: boolean; |
| 39 | /** The grant cookie's value, which a proof is bound to. */ | |
| 40 | readonly grant?: string | undefined; | |
| 38 | 41 | /** The client's limit key, from the socket (`clientBucket`). */ |
| 39 | 42 | readonly source: string; |
| 40 | 43 | } |
| @@ -166,6 +169,17 @@ function list(ask: FeedbackAsk, door: Door): Response { | ||
| 166 | 169 | |
| 167 | 170 | /** Answer a `/__forge/note*` request; `undefined` when the path is not one. */ |
| 168 | 171 | export async function feedback(ask: FeedbackAsk): Promise<Response | undefined> { |
| 172 | const path = ask.url.pathname; | |
| 173 | if (path !== "/__forge/note" && path !== "/__forge/notes") return answer(ask); | |
| 174 | // A person is known only by the panel's one-use proof; without it, a visitor. | |
| 175 | const host = ask.request.headers.get("host") ?? ""; | |
| 176 | const proven = spendProof(ask.request.headers.get(PROOF_HEADER), ask.grant, host); | |
| 177 | const res = await answer(proven ? ask : { ...ask, viewerId: undefined }); | |
| 178 | if (proven && res !== undefined && ask.grant !== undefined) res.headers.set(PROOF_HEADER, issueProof(ask.grant, host)); | |
| 179 | return res; | |
| 180 | } | |
| 181 | ||
| 182 | async function answer(ask: FeedbackAsk): Promise<Response | undefined> { | |
| 169 | 183 | const path = ask.url.pathname; |
| 170 | 184 | const method = ask.request.method; |
| 171 | 185 | if (path === "/__forge/note/moderate") return json(404, { error: "not_found" }); |
src/apps/proof.ts added +48
| @@ -0,0 +1,48 @@ | ||
| 1 | /** | |
| 2 | * The forge panel's one-use proof. A note posted from an app's own origin | |
| 3 | * could have been written by the app's own code, so a request there is a | |
| 4 | * visitor's unless it carries a token only the forge-served panel was given: | |
| 5 | * issued into a signed-in person's page load, bound to their grant cookie and | |
| 6 | * the host, spent by the first request that shows it, replaced by the next in | |
| 7 | * `x-forge-proof`. Held in memory: a restart makes every panel a visitor's | |
| 8 | * until the page is loaded again. | |
| 9 | */ | |
| 10 | import { randomBytes } from "node:crypto"; | |
| 11 | import { sha256 } from "../kernel/hash.ts"; | |
| 12 | ||
| 13 | export const PROOF_HEADER = "x-forge-proof"; | |
| 14 | const TTL_MS = 60 * 60 * 1000; | |
| 15 | const MAX = 20_000; | |
| 16 | ||
| 17 | const live = new Map<string, { bound: string; expires: number }>(); | |
| 18 | ||
| 19 | const bind = (grant: string, host: string): string => sha256(`${grant}\n${host}`); | |
| 20 | ||
| 21 | /** A fresh token for this grant on this host. */ | |
| 22 | export function issueProof(grant: string, host: string, now = Date.now()): string { | |
| 23 | if (live.size >= MAX) { | |
| 24 | for (const [token, v] of live) { | |
| 25 | if (v.expires <= now || live.size >= MAX) live.delete(token); | |
| 26 | else break; | |
| 27 | } | |
| 28 | } | |
| 29 | const token = randomBytes(24).toString("hex"); | |
| 30 | live.set(token, { bound: bind(grant, host), expires: now + TTL_MS }); | |
| 31 | return token; | |
| 32 | } | |
| 33 | ||
| 34 | /** Whether `token` is live for this grant and host; it is spent either way. */ | |
| 35 | export function spendProof(token: string | null, grant: string | undefined, host: string, now = Date.now()): boolean { | |
| 36 | if (token === null || grant === undefined || !/^[0-9a-f]{48}$/.test(token)) return false; | |
| 37 | const have = live.get(token); | |
| 38 | if (have === undefined) return false; | |
| 39 | live.delete(token); | |
| 40 | return have.expires > now && have.bound === bind(grant, host); | |
| 41 | } | |
| 42 | ||
| 43 | /** Whether a request is a page load a person's panel is born in. */ | |
| 44 | export function pageLoad(headers: Headers): boolean { | |
| 45 | const dest = headers.get("sec-fetch-dest"); | |
| 46 | if (dest === null || dest === "document") return true; | |
| 47 | return dest === "iframe" && headers.get("sec-fetch-site") === "cross-site"; | |
| 48 | } |
src/apps/proxy.ts +10
| @@ -37,6 +37,7 @@ import { previewEnv, type EnvName } from "./data.ts"; | ||
| 37 | 37 | import type { AppsRuntime, EnvStatus } from "./runtime.ts"; |
| 38 | 38 | import { crewNow, tellLink } from "./crew.ts"; |
| 39 | 39 | import { feedback } from "./feedback.ts"; |
| 40 | import { issueProof, pageLoad } from "./proof.ts"; | |
| 40 | 41 | import { clientBucket } from "../http/peer.ts"; |
| 41 | 42 | import { doorPage } from "./door.ts"; |
| 42 | 43 | import { notFound } from "../http/respond.ts"; |
| @@ -673,6 +674,7 @@ export async function proxyApp( | ||
| 673 | 674 | env: target.env, |
| 674 | 675 | sealed, |
| 675 | 676 | viewerId, |
| 677 | grant: cookie, | |
| 676 | 678 | secure: |
| 677 | 679 | url.protocol === "https:" || |
| 678 | 680 | request.headers.get("x-forwarded-proto") === "https", |
| @@ -811,10 +813,18 @@ export async function proxyApp( | ||
| 811 | 813 | } catch { |
| 812 | 814 | return unavailable(runtime, target, status, "the app stopped answering"); |
| 813 | 815 | } |
| 816 | // A signed-in person's page load carries the panel's one-use proof. | |
| 817 | const grantCookie = cookieValue(request, grantCookieName(target)); | |
| 818 | const proof = | |
| 819 | vouched?.who !== undefined && grantCookie !== undefined && pageLoad(request.headers) | |
| 820 | ? issueProof(grantCookie, request.headers.get("host") ?? "") | |
| 821 | : undefined; | |
| 822 | if (proof !== undefined) out.set("cache-control", "private, no-store"); | |
| 814 | 823 | const page = withToolbar( |
| 815 | 824 | bytes, |
| 816 | 825 | runtime.options.forgeUrl, |
| 817 | 826 | pillWhere(runtime, target, vouched?.who), |
| 827 | proof, | |
| 818 | 828 | ); |
| 819 | 829 | let sent = page; |
| 820 | 830 | // Whether it is gzipped depends on the client, so every copy says so. |
src/apps/toolbar.ts +28 −6
| @@ -30,6 +30,27 @@ export const toolbarJs = `(function () { | ||
| 30 | 30 | var pill = document.createElement("button"); |
| 31 | 31 | pill.type = "button"; |
| 32 | 32 | var d = me.dataset || {}; |
| 33 | // The one-use proof: taken off the tag at once, so the page's own script never reads it. | |
| 34 | var proof = d.proof || ""; | |
| 35 | if (me.removeAttribute) me.removeAttribute("data-proof"); | |
| 36 | var turn = Promise.resolve(); | |
| 37 | // Requests to the notes door go one at a time: each spends the proof and brings the next. | |
| 38 | function door(path, init) { | |
| 39 | var run = function () { | |
| 40 | init.credentials = "same-origin"; | |
| 41 | init.headers = Object.assign({}, init.headers || {}); | |
| 42 | if (proof) init.headers["x-forge-proof"] = proof; | |
| 43 | proof = ""; | |
| 44 | return fetch(path, init).then(function (r) { | |
| 45 | var next = r.headers.get("x-forge-proof"); | |
| 46 | if (next) proof = next; | |
| 47 | return r; | |
| 48 | }); | |
| 49 | }; | |
| 50 | var p = turn.then(run, run); | |
| 51 | turn = p.catch(function () {}); | |
| 52 | return p; | |
| 53 | } | |
| 33 | 54 | var where = d.env === "production" ? "production" : d.pull ? "preview of pull #" + d.pull : ""; |
| 34 | 55 | pill.setAttribute("aria-label", [d.app, where].filter(Boolean).join(", ") || "Forge"); |
| 35 | 56 | pill.setAttribute("aria-expanded", "false"); |
| @@ -140,7 +161,7 @@ export const toolbarJs = `(function () { | ||
| 140 | 161 | }); |
| 141 | 162 | } |
| 142 | 163 | function refresh(sent) { |
| 143 | fetch("/__forge/notes", { credentials: "same-origin", cache: "no-store" }) | |
| 164 | door("/__forge/notes", { cache: "no-store" }) | |
| 144 | 165 | .then(function (r) { return r.ok ? r.json() : null; }) |
| 145 | 166 | .then(function (j) { |
| 146 | 167 | if (!j || !Array.isArray(j.notes)) return; |
| @@ -159,9 +180,8 @@ export const toolbarJs = `(function () { | ||
| 159 | 180 | tellGo.setAttribute("aria-busy", "true"); |
| 160 | 181 | tellGo.style.opacity = ".6"; |
| 161 | 182 | function idle() { tellGo.disabled = false; tellGo.removeAttribute("aria-busy"); tellGo.style.opacity = "1"; } |
| 162 | fetch("/__forge/note", { | |
| 183 | door("/__forge/note", { | |
| 163 | 184 | method: "POST", |
| 164 | credentials: "same-origin", | |
| 165 | 185 | headers: { "content-type": "application/json" }, |
| 166 | 186 | body: JSON.stringify({ text: text, page: location.href, viewport: window.innerWidth + "x" + window.innerHeight }) |
| 167 | 187 | }) |
| @@ -420,7 +440,7 @@ export function escapeAttr(text: string): string { | ||
| 420 | 440 | } |
| 421 | 441 | |
| 422 | 442 | /** The script tag, with where-you-are as escaped data attributes. */ |
| 423 | export function toolbarTag(forgeUrl: string, where?: PillWhere): string { | |
| 443 | export function toolbarTag(forgeUrl: string, where?: PillWhere, proof?: string): string { | |
| 424 | 444 | const data = |
| 425 | 445 | where === undefined |
| 426 | 446 | ? "" |
| @@ -434,7 +454,8 @@ export function toolbarTag(forgeUrl: string, where?: PillWhere): string { | ||
| 434 | 454 | .filter((pair): pair is [string, string] => pair[1] !== undefined) |
| 435 | 455 | .map(([k, v]) => ` data-${k}="${escapeAttr(v)}"`) |
| 436 | 456 | .join(""); |
| 437 | return `<script src="${new URL(TOOLBAR_PATH, forgeUrl).href}"${data} defer></script>`; | |
| 457 | const token = proof === undefined ? "" : ` data-proof="${escapeAttr(proof)}"`; | |
| 458 | return `<script src="${new URL(TOOLBAR_PATH, forgeUrl).href}"${data}${token} defer></script>`; | |
| 438 | 459 | } |
| 439 | 460 | |
| 440 | 461 | /** `bytes` with the pill's tag before the last `</body>`, or at the end. */ |
| @@ -442,8 +463,9 @@ export function withToolbar( | ||
| 442 | 463 | bytes: Uint8Array, |
| 443 | 464 | forgeUrl: string, |
| 444 | 465 | where?: PillWhere, |
| 466 | proof?: string, | |
| 445 | 467 | ): Uint8Array<ArrayBuffer> { |
| 446 | const tag = Buffer.from(toolbarTag(forgeUrl, where)); | |
| 468 | const tag = Buffer.from(toolbarTag(forgeUrl, where, proof)); | |
| 447 | 469 | const buffer = Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength); |
| 448 | 470 | // latin1 is one character per byte, so an index in it is a byte offset. |
| 449 | 471 | const at = buffer.toString("latin1").toLowerCase().lastIndexOf("</body"); |
test/apps-crew-pill.test.ts +1 −1
| @@ -199,7 +199,7 @@ describe("the crew line", () => { | ||
| 199 | 199 | expect(toolbarJs).toContain("/__forge/crew"); |
| 200 | 200 | // The crew line is asked once; the feedback door (#4758) adds the |
| 201 | 201 | // sender's notes, polled only while the panel is open, and the send. |
| 202 | expect(toolbarJs.match(/fetch\(/g)?.length).toBe(3); | |
| 202 | expect(toolbarJs.match(/fetch\(/g)?.length).toBe(2); | |
| 203 | 203 | expect(toolbarJs.match(/setInterval/g)?.length).toBe(1); |
| 204 | 204 | expect(toolbarJs).not.toMatch( |
| 205 | 205 | /document\.cookie|querySelector|getElementById|setTimeout/, |
test/apps-feedback.test.ts +73 −7
| @@ -4,16 +4,17 @@ | ||
| 4 | 4 | * a status that follows the issue, and the owner can hide or ban. |
| 5 | 5 | */ |
| 6 | 6 | |
| 7 | import { afterAll, beforeAll, describe, expect, test } from "bun:test"; | |
| 7 | import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, test } from "bun:test"; | |
| 8 | 8 | import { mkdtemp, rm } from "node:fs/promises"; |
| 9 | 9 | import { tmpdir } from "node:os"; |
| 10 | 10 | import { join } from "node:path"; |
| 11 | 11 | import { createApp, type App } from "../src/app.ts"; |
| 12 | 12 | import { newApp } from "../src/actions/apps.ts"; |
| 13 | 13 | import { AppsRuntime } from "../src/apps/runtime.ts"; |
| 14 | import { toolbarJs } from "../src/apps/toolbar.ts"; | |
| 14 | import { toolbarJs, toolbarTag } from "../src/apps/toolbar.ts"; | |
| 15 | 15 | import { filtered, moderateNote, noteClock, PER_APP_DAY, PER_SENDER, PER_SOURCE, saysFromApp } from "../src/actions/app_notes.ts"; |
| 16 | 16 | import { feedback, REQUEST_MAX } from "../src/apps/feedback.ts"; |
| 17 | import { issueProof, pageLoad, PROOF_HEADER } from "../src/apps/proof.ts"; | |
| 17 | 18 | import { getAppBySlug } from "../src/core/apps.ts"; |
| 18 | 19 | import { getNote, isBanned } from "../src/core/app_notes.ts"; |
| 19 | 20 | import { grantedCookie } from "./helpers/identity.ts"; |
| @@ -83,8 +84,10 @@ describe("the forge button takes notes from anyone", () => { | ||
| 83 | 84 | }, |
| 84 | 85 | redirect: "manual", |
| 85 | 86 | }); |
| 86 | const post = (text: string, cookie = "", source = "", slug = "notes") => | |
| 87 | at(slug, "/__forge/note", { method: "POST", body: JSON.stringify({ text, page: `http://${host(slug)}/lists?x=1`, viewport: "390x844" }) }, cookie, source); | |
| 87 | const post = (text: string, cookie = "", source = "", slug = "notes", proof = "") => | |
| 88 | at(slug, "/__forge/note", { method: "POST", body: JSON.stringify({ text, page: `http://${host(slug)}/lists?x=1`, viewport: "390x844" }), headers: proof ? { [PROOF_HEADER]: proof } : {} }, cookie, source); | |
| 89 | /** What the forge puts in a signed-in person's page load: a token for this grant on this host. */ | |
| 90 | const proofFor = (cookie: string, slug: string) => issueProof(cookie.slice(cookie.indexOf("=") + 1), host(slug)); | |
| 88 | 91 | const cookieOf = (res: Response) => (res.headers.get("set-cookie") ?? "").split(";")[0] ?? ""; |
| 89 | 92 | |
| 90 | 93 | test("a visitor's note files a from-app issue with page, viewport and time", async () => { |
| @@ -186,7 +189,7 @@ describe("the forge button takes notes from anyone", () => { | ||
| 186 | 189 | expect(issues()).toBe(before); |
| 187 | 190 | expect((await at("notes--98", "/__forge/notes")).status).toBe(404); |
| 188 | 191 | const owner = await grantedCookie(app, servers.url, alice, getAppBySlug(app.db, "notes")!, "pull-98"); |
| 189 | expect((await post("from a person", owner, "", "notes--98")).status).toBe(201); | |
| 192 | expect((await post("from a person", owner, "", "notes--98", proofFor(owner, "notes--98"))).status).toBe(201); | |
| 190 | 193 | expect(issues()).toBe(before + 1); |
| 191 | 194 | // The same app's production stays open to visitors. |
| 192 | 195 | expect((await post("still open", "", "", "notes")).status).toBe(201); |
| @@ -297,16 +300,79 @@ describe("the forge button takes notes from anyone", () => { | ||
| 297 | 300 | expect(await Bun.file(join(import.meta.dir, "../src/actions/app_notes.ts")).text()).not.toContain("x-forwarded-for"); |
| 298 | 301 | }); |
| 299 | 302 | |
| 303 | describe("the panel's one-use proof", () => { | |
| 304 | // Each test sends in a window of its own, clear of the bounds the tests before spent. | |
| 305 | let window = 0; | |
| 306 | beforeEach(() => { | |
| 307 | const at = Date.now() + ++window * 3 * 86_400_000; | |
| 308 | noteClock.now = () => at; | |
| 309 | }); | |
| 310 | afterEach(() => { | |
| 311 | noteClock.now = () => Date.now(); | |
| 312 | }); | |
| 313 | const named = async (res: Response) => { const j = (await res.json()) as { name: string }; if (j.name === undefined) throw new Error(JSON.stringify(j)); return j.name; }; | |
| 314 | ||
| 315 | test("an unproven post from a signed-in browser is a visitor's, and its list is the visitor's", async () => { | |
| 316 | const owner = await grantedCookie(app, servers.url, alice, getAppBySlug(app.db, "notes")!); | |
| 317 | const res = await post("no proof here", owner, "10.7.0.1"); | |
| 318 | expect(res.status).toBe(201); | |
| 319 | expect(await named(res)).toMatch(/^visitor-/); | |
| 320 | expect(res.headers.get(PROOF_HEADER)).toBeNull(); | |
| 321 | const list = (await (await at("notes", "/__forge/notes", {}, owner)).json()) as { name: string; admin: boolean }; | |
| 322 | expect(list.name).toMatch(/^visitor-/); | |
| 323 | expect(list.admin).toBe(false); | |
| 324 | }); | |
| 325 | ||
| 326 | test("a proven post is @name, the list is theirs and admin, and each answer brings the next proof", async () => { | |
| 327 | const owner = await grantedCookie(app, servers.url, alice, getAppBySlug(app.db, "notes")!); | |
| 328 | const res = await post("with proof", owner, "10.7.0.2", "notes", proofFor(owner, "notes")); | |
| 329 | expect(await named(res)).toBe("@alice"); | |
| 330 | const next = res.headers.get(PROOF_HEADER)!; | |
| 331 | expect(next).toMatch(/^[0-9a-f]{48}$/); | |
| 332 | const list = await at("notes", "/__forge/notes", { headers: { [PROOF_HEADER]: next } }, owner); | |
| 333 | const j = (await list.json()) as { name: string; admin: boolean }; | |
| 334 | expect(j.name).toBe("@alice"); | |
| 335 | expect(j.admin).toBe(true); | |
| 336 | expect(list.headers.get(PROOF_HEADER)).toMatch(/^[0-9a-f]{48}$/); | |
| 337 | expect(list.headers.get(PROOF_HEADER)).not.toBe(next); | |
| 338 | }); | |
| 339 | ||
| 340 | test("a reused proof, one for another grant and one for another host are a visitor's", async () => { | |
| 341 | const owner = await grantedCookie(app, servers.url, alice, getAppBySlug(app.db, "notes")!); | |
| 342 | const token = proofFor(owner, "notes"); | |
| 343 | expect(await named(await post("first", owner, "10.7.0.3", "notes", token))).toBe("@alice"); | |
| 344 | expect(await named(await post("again", owner, "10.7.0.3", "notes", token))).toMatch(/^visitor-/); | |
| 345 | const foreign = issueProof("someone-elses-grant", host("notes")); | |
| 346 | expect(await named(await post("foreign grant", owner, "10.7.0.4", "notes", foreign))).toMatch(/^visitor-/); | |
| 347 | const elsewhere = issueProof(owner.slice(owner.indexOf("=") + 1), host("diary")); | |
| 348 | expect(await named(await post("foreign host", owner, "10.7.0.5", "notes", elsewhere))).toMatch(/^visitor-/); | |
| 349 | }); | |
| 350 | ||
| 351 | test("only a page load is given a proof: a same-origin fetch of the page gets none", () => { | |
| 352 | expect(pageLoad(new Headers())).toBe(true); | |
| 353 | expect(pageLoad(new Headers({ "sec-fetch-dest": "document", "sec-fetch-site": "none" }))).toBe(true); | |
| 354 | expect(pageLoad(new Headers({ "sec-fetch-dest": "iframe", "sec-fetch-site": "cross-site" }))).toBe(true); | |
| 355 | expect(pageLoad(new Headers({ "sec-fetch-dest": "empty", "sec-fetch-site": "same-origin" }))).toBe(false); | |
| 356 | expect(pageLoad(new Headers({ "sec-fetch-dest": "iframe", "sec-fetch-site": "same-origin" }))).toBe(false); | |
| 357 | }); | |
| 358 | }); | |
| 359 | ||
| 360 | test("the panel's tag carries the proof as a data attribute, and the script strips it on load", () => { | |
| 361 | expect(toolbarTag("http://f.test", undefined, "ab12")).toContain(' data-proof="ab12"'); | |
| 362 | expect(toolbarTag("http://f.test")).not.toContain("data-proof"); | |
| 363 | expect(toolbarJs).toContain('removeAttribute("data-proof")'); | |
| 364 | }); | |
| 365 | ||
| 300 | 366 | test("a private app takes notes from a signed-in reader, as themselves, and from no one else", async () => { |
| 301 | 367 | const reader = await grantedCookie(app, servers.url, alice, getAppBySlug(app.db, "diary")!); |
| 302 | const res = await post("A note on the diary", reader, "10.5.0.1", "diary"); | |
| 368 | const res = await post("A note on the diary", reader, "10.5.0.1", "diary", proofFor(reader, "diary")); | |
| 303 | 369 | expect(res.status).toBe(201); |
| 304 | 370 | expect(((await res.json()) as { name: string }).name).toBe("@alice"); |
| 305 | 371 | const repo = getRepo(app.db, "alice", "diary")!; |
| 306 | 372 | const issue = app.db.query<{ body: string }, [string]>("SELECT body FROM issue WHERE repo_id = ?1 ORDER BY number DESC").get(repo.id)!; |
| 307 | 373 | expect(issue.body).toContain("by @alice."); |
| 308 | 374 | expect(issue.body).toContain("Untrusted data"); |
| 309 | const mine = (await (await at("diary", "/__forge/notes", {}, reader)).json()) as { notes: unknown[]; admin: boolean }; | |
| 375 | const mine = (await (await at("diary", "/__forge/notes", { headers: { [PROOF_HEADER]: proofFor(reader, "diary") } }, reader)).json()) as { notes: unknown[]; admin: boolean }; | |
| 310 | 376 | expect(mine.notes.length).toBe(1); |
| 311 | 377 | expect(mine.admin).toBe(true); |
| 312 | 378 | expect((await at("diary", "/__forge/notes")).status).toBe(404); |
test/toolbar-actions.test.ts +3 −3
| @@ -89,10 +89,10 @@ describe("toolbar actions", () => { | ||
| 89 | 89 | test("the bar links to the forge page and never posts or reads the app", () => { |
| 90 | 90 | expect(toolbarJs).toContain('"/toolbar"'); |
| 91 | 91 | // Its requests are all to the app's own origin: the crew line (#2233) and, |
| 92 | // for the feedback door (#4758), the sender's notes and their status. | |
| 93 | expect(toolbarJs.match(/fetch\(/g)?.length).toBe(3); | |
| 92 | // for the feedback door (#4758), the sender's notes and their status, through one function. | |
| 93 | expect(toolbarJs.match(/fetch\(/g)?.length).toBe(2); | |
| 94 | 94 | expect(toolbarJs).toContain('fetch("/__forge/crew"'); |
| 95 | expect(toolbarJs).toContain('fetch("/__forge/note"'); | |
| 95 | expect(toolbarJs).toContain('door("/__forge/note"'); | |
| 96 | 96 | expect(toolbarJs).not.toMatch(/FormData|\.send\(/); |
| 97 | 97 | expect(toolbarJs).not.toContain("XMLHttpRequest"); |
| 98 | 98 | expect(toolbarJs).not.toContain("document.cookie"); |
new above
offline