diff --git a/.changeset/nice-mangos-hammer.md b/.changeset/nice-mangos-hammer.md new file mode 100644 index 0000000000..dfd5812b31 --- /dev/null +++ b/.changeset/nice-mangos-hammer.md @@ -0,0 +1,5 @@ +--- +'@penumbra-zone/transport-chrome': patch +--- + +Allow http://localhost to establish the connection with chrome extensions diff --git a/packages/transport-chrome/src/session-manager.ts b/packages/transport-chrome/src/session-manager.ts index 64aa4339ec..be867fe398 100644 --- a/packages/transport-chrome/src/session-manager.ts +++ b/packages/transport-chrome/src/session-manager.ts @@ -96,11 +96,15 @@ export class CRSessionManager { return; } - // origin restrictions const fromThisExtension = sender.id === chrome.runtime.id; - // frameId == 0 for top-level documents - const fromPageHttps = !sender.frameId && sender.tab?.id && sender.origin.startsWith('https://'); - if (!(fromThisExtension || fromPageHttps)) { + const fromPageHttps = + !sender.frameId && !!sender.tab?.id && sender.origin.startsWith('https://'); + const isLocalhost = + sender.origin.startsWith('http://localhost:') || sender.origin === 'http://localhost'; + + // Allow connections from the same extension, from https pages, or from http://localhost + const validOrigin = isLocalhost || fromPageHttps || fromThisExtension; + if (!validOrigin) { return; }