Skip to content

Commit

Permalink
Revert "fix(extension): #107: allow http for localhost" (#145)
Browse files Browse the repository at this point in the history
* Revert "fix(extension): #107: allow http for localhost (#129)"

This reverts commit 8141aa4.

* Update version
  • Loading branch information
grod220 authored Aug 8, 2024
1 parent f71d20b commit 75acabe
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 16 deletions.
2 changes: 1 addition & 1 deletion apps/extension/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "chrome-extension",
"version": "11.13.0",
"version": "11.13.1",
"private": true,
"license": "(MIT OR Apache-2.0)",
"description": "chrome-extension",
Expand Down
6 changes: 3 additions & 3 deletions apps/extension/public/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"manifest_version": 3,
"name": "Prax wallet",
"version": "11.13.0",
"version": "11.13.1",
"description": "For use in interacting with the Penumbra blockchain",
"key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvnucOJi878TGZYnTNTrvXd9krAcpSDR/EgHcQhvjNZrKfRRsKA9O0DnbyM492c3hiicYPevRPLPoKsLgVghGDYPr8eNO7ee165keD5XLxq0wpWu14gHEPdQSRNZPLeawLp4s/rUwtzMcxhVIUYYaa2xZri4Tqx9wpR7YR1mQTAL8UsdjyitrnzTM20ciKXq1pd82MU74YaZzrcQCOmcjJtjHFdMEAYme+LuZuEugAgef9RiE/8kLQ6T7W9feYfQOky1OPjBkflpRXRgW6cACdl+MeYhKJCOHijglFsPOXX6AvnoJSeAJYRXOMVJi0ejLKEcrLpaeHgh+1WXUvc5G4wIDAQAB",
"minimum_chrome_version": "119",
Expand All @@ -16,7 +16,7 @@
},
"content_scripts": [
{
"matches": ["https://*/*", "http://localhost:*/*"],
"matches": ["https://*/*"],
"js": [
"injected-connection-port.js",
"injected-disconnect-listener.js",
Expand All @@ -25,7 +25,7 @@
"run_at": "document_start"
},
{
"matches": ["https://*/*", "http://localhost:*/*"],
"matches": ["https://*/*"],
"js": ["injected-penumbra-global.js"],
"run_at": "document_start",
"world": "MAIN"
Expand Down
18 changes: 6 additions & 12 deletions apps/extension/src/senders/validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ type ValidSender = chrome.runtime.MessageSender & {
frameId: 0;
documentId: string;
tab: chrome.tabs.Tab & { id: number };
origin: string;
url: string;
};

const isHttpLocalhost = (url: URL): boolean =>
url.protocol === 'http:' && url.hostname === 'localhost';
// the relationship between origin and url is pretty complex.
// just rely on the browser's tools.
origin: `${ValidProtocol}//${string}`;
url: `${ValidProtocol}//${string}/${string}`;
};

export const assertValidSender = (sender?: chrome.runtime.MessageSender) => {
if (!sender) {
Expand All @@ -34,13 +34,7 @@ export const assertValidSender = (sender?: chrome.runtime.MessageSender) => {
if (parsedOrigin.origin !== sender.origin) {
throw new Error('Sender origin is invalid');
}

if (
!(
parsedOrigin.protocol in ValidProtocol ||
(globalThis.__DEV__ && isHttpLocalhost(parsedOrigin))
)
) {
if (!(parsedOrigin.protocol in ValidProtocol)) {
throw new Error(`Sender protocol is not ${Object.values(ValidProtocol).join(',')}`);
}

Expand Down

0 comments on commit 75acabe

Please sign in to comment.