Repository navigation
fix(plugins): a plugin page's own scripts load, and it may ask for the location - #323
Merged
Merged
Conversation
…e location After #320, Music, Sunrise & Sunset and WeatherGlance broke on hgtest. - The SDK never loaded. Some browsers send Origin: null with a sandboxed page's script and style loads, and the request policy answered every Origin: null request without a token with 403, /plugin-sdk/v1.js included. Without window.HomeGlow, Music threw on HG.settings, and Sunrise & Sunset and WeatherGlance couldn't read their saved locations (WeatherGlance then asked /api/weather with no location: 404). A GET or HEAD the policy refuses now goes through without CORS headers, so the page can use but not read it; no GET route changes anything. A fetch the policy refuses (Sec-Fetch-Mode: cors) still gets the readable 403, and writes still need a token and an allowed route. - Location detection was blocked by permissions policy: a cross-origin (here opaque) frame can't ask for the location unless its iframe allows it. Plugin frames, and the Admin preview, now carry allow="geolocation". The browser still asks the household first. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
After #320, Music, Sunrise & Sunset and WeatherGlance broke on hgtest. This fixes both causes.
Causes
The SDK never loaded.
Origin: nullwith a sandboxed page's script and style loads. fix(plugins): isolate plugins from HomeGlow and from each other #320's request policy answered everyOrigin: nullrequest without a token with403, and that included/plugin-sdk/v1.js. Fetching hgtest's SDK withOrigin: nullconfirms the403.window.HomeGlow:Cannot read properties of undefined (reading 'settings')./api/weatherwith no location, which answered404.Location detection was blocked by permissions policy. A cross-origin frame, here an opaque one, can't ask for the location unless its iframe allows it.
Changes
GETorHEADthe policy refuses now goes through, without CORS headers.GETroute changes anything. I audited every one for the fix(plugins): isolate plugins from HomeGlow and from each other #320 review.fetchthe policy refuses (Sec-Fetch-Mode: cors) still gets the readable403, and writes still need a token and an allowed route.allow="geolocation". It's scoped to the plugin's own address, and the browser still asks the household first. In Edge, a sandboxed frame is refused without it, and bothgeolocationandgeolocation *work.Testing
Edge, forcing
Origin: nullon the frame's script and style loads, as the affected browser does, with Sunrise & Sunset (a location saved in its settings) and a probe plugin:HomeGlow is not defined, "No location configured yet", and the same geolocation permissions-policy error.pluginIsolation.test.js:Origin: nulland with or withoutSec-Fetch-Mode;The new test fails on fix(plugins): isolate plugins from HomeGlow and from each other #320's code with the same
403. Its fetch-style requests now sendSec-Fetch-Mode: cors, as browsers do.Server
npm test(626), clientvitest(749) andbuildall pass.On hgtest itself: in a clean sandboxed frame in Edge and in Chrome, all three plugins already work, because those browsers send no
Originon script loads. So the affected browser is a different one. Worth checking which display or browser showed the errors.🤖 Generated with Claude Code