-
Notifications
You must be signed in to change notification settings - Fork 97
Port Registrar: Local-view port registration + Origin gate #2376
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
TalZaccai
wants to merge
4
commits into
main
Choose a base branch
from
talzacc/dangling-ports-phase-a
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
90388f2
phase A: register local-view ports + Origin gate (browser/montage/mar…
TalZaccai 2b36099
view servers: use shared originAllowlist helper
TalZaccai bb9ff04
view servers: tighten Origin gate + release port on child crash
TalZaccai 98a9c1d
Merge remote-tracking branch 'origin/main' into talzacc/dangling-port…
TalZaccai File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
ts/packages/agents/browser/src/views/server/core/originAllowlist.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT License. | ||
|
|
||
| import { createAgentOriginAllowlist } from "websocket-utils/originAllowlist"; | ||
|
|
||
| /** | ||
| * Origin allowlist for the browser views server (PDF viewer + other | ||
| * per-session HTML views forked as a child process by the browser | ||
| * agent). | ||
| * | ||
| * Distinct from `agents/browser/src/agent/originAllowlist.mts`, which | ||
| * gates the WS bridge used by the typeagent Chrome/Edge extension. The | ||
| * views server is consumed by: | ||
| * - the Electron shell's inline browser (origin | ||
| * `http(s)://localhost(:port)` / `127.0.0.1` / `[::1]`), | ||
| * - external loopback browser tabs the user opens manually, | ||
| * - same-origin XHR/fetch from the served HTML (Origin absent or the | ||
| * server's own loopback origin). | ||
| * | ||
| * No browser-extension scheme is accepted here — this listener does not | ||
| * back any extension UI. See {@link createAgentOriginAllowlist} for the | ||
| * shared loopback + no-Origin baseline. | ||
| * | ||
| * `Origin: "null"` (sent by `file://` pages and sandboxed iframes) is | ||
| * rejected — only regular browser tabs and same-origin fetches are | ||
| * legitimate clients, so an opaque-origin caller is necessarily | ||
| * something we do not want to honor. | ||
| * | ||
| * Anything else is rejected with HTTP 403 before the route handler runs. | ||
| */ | ||
| export const isAllowedViewOrigin = createAgentOriginAllowlist({ | ||
| allowNullOrigin: false, | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
ts/packages/agents/markdown/src/view/route/originAllowlist.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT License. | ||
|
|
||
| import { createAgentOriginAllowlist } from "websocket-utils/originAllowlist"; | ||
|
|
||
| /** | ||
| * Origin allowlist for the markdown view server (HTTP preview + Yjs | ||
| * collaboration WebSocket). | ||
| * | ||
| * Accepts only the shared loopback + no-Origin baseline documented on | ||
| * {@link createAgentOriginAllowlist} (loopback browser tabs, the | ||
| * Electron shell's inline browser, same-origin XHR/fetch from the | ||
| * preview page, and Node `ws`/HTTP clients). The server binds to | ||
| * localhost, so this is loopback-restricted at the OS level. | ||
| * | ||
| * `Origin: "null"` (sent by `file://` pages and sandboxed iframes) is | ||
| * rejected — the preview server only ever serves regular browser tabs | ||
| * and same-origin fetches, so an opaque-origin caller is necessarily | ||
| * something we do not want to honor. | ||
| * | ||
| * Anything else is rejected with HTTP 403 (HTTP routes) or 403 on the | ||
| * upgrade response (WebSocket). | ||
| */ | ||
| export const isAllowedViewOrigin = createAgentOriginAllowlist({ | ||
| allowNullOrigin: false, | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.