Add hubble.links.open so HTML Apps can open external links - #263
Closed
marcodlk wants to merge 2 commits into
Closed
Add hubble.links.open so HTML Apps can open external links#263marcodlk wants to merge 2 commits into
marcodlk wants to merge 2 commits into
Conversation
HTML Apps render in a sandboxed iframe without allow-popups or allow-top-navigation, so window.open and target="_blank" are no-ops and apps have no way to send the user to an external URL. Add a links.open method to the runtime broker: the injected runtime exposes hubble.links.open(url) / hubble.links.safeOpen(url) in the same style as files.*, and the renderer dispatch validates the URL (http/https only, mirroring the main-process guard) before forwarding to the existing desktop:open-external-url IPC handler. No new IPC surface is added. Closes bholmesdev#262
|
@marcodlk is attempting to deploy a commit to the bholmesdev's projects Team on Vercel. A member of the Team first needs to authorize it. |
Author
|
PR created by clanker by mistake. apologies. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Pairs with #262. Opened as a draft per CONTRIBUTING until there's consensus on the approach in the issue.
What changed
HTML Apps render in a sandboxed iframe (
sandbox="allow-scripts allow-forms", noallow-popups, noallow-top-navigation), sowindow.open()andtarget="_blank"are no-ops and an app has no way to send the user to an external URL.This adds a
links.openmethod to the HTML App runtime broker:packages/runtime/global.js):hubble.links.open(url)andhubble.links.safeOpen(url), matching the existinghubble.files.*/safe*style.IframeView.tsx): thehubble:requestdispatch validates the URL — http/https only, mirroring the existing main-process guard — and forwards to the existingdesktopApi.openExternalUrl, i.e. the same validateddesktop:open-external-urlIPC path the Markdown editor uses for note links. No new IPC surface. Non-http(s) URLs (file:,javascript:, scheme-less strings) are rejected withOnly http(s) external URLs are allowedbefore ever reaching the desktop API.links.openis handled before the workspace guard since opening a link doesn't depend on workspace file access.links.open, with a decision bullet explaining the sandbox limitation and the reuse of the external-URL path (following its "future APIs should extend the runtime broker" consequence).Existing
files.*methods and the unknown-method error are unchanged.How I tested
IframeView.test.ts(exportedhandleHtmlAppRequestthe same wayresolveHtmlAppGlobalready is): http(s) URLs resolve{ ok: true, value: { url } }and reachopenExternalUrl;file:/javascript:/scheme-less/non-string inputs return{ ok: false }without calling the desktop API; unknown methods still throw the same error.pnpm --filter @hubble.md/desktop test— 23 files, 208 tests pass.pnpm build:desktop(Biome + tsc + electron-vite build) passes; React compiler audit passes for the desktop package.hubble.links.safeOpen("https://example.com")returned{ ok: true }and opened the system browser,safeOpen("file:///etc/passwd")andsafeOpen("example.com")both returned{ ok: false, error: { message: "Only http(s) external URLs are allowed" } }without reaching the desktop API, andhubble.files.safeList()kept working.Changelog
Added under
[Unreleased]→Added.