Skip to content
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

Revert "fix(extension): #107: allow http for localhost" #145

Merged
merged 2 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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