From b4d2eda3e646bd0a9f46544e884e5ac42c370fc5 Mon Sep 17 00:00:00 2001 From: Carlos Quintana Date: Mon, 15 Jul 2024 09:01:17 +0200 Subject: [PATCH 1/3] chore: upgrade version in package-lock.json --- package-lock.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 3e8cbf6..aaca01c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "simplelogin-extension", - "version": "2.11.1", + "version": "3.0.5", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "simplelogin-extension", - "version": "2.11.1", + "version": "3.0.5", "license": "MIT", "dependencies": { "@fortawesome/fontawesome-svg-core": "^1.2.36", From cead8c33d5af0b7d0dfa945a63a1f3afed3073d8 Mon Sep 17 00:00:00 2001 From: Carlos Quintana Date: Mon, 15 Jul 2024 09:05:01 +0200 Subject: [PATCH 2/3] fix: extension automatic setup --- src/background/content-script.js | 33 -------------------------------- src/background/index.js | 13 ++++++------- src/manifest.json | 16 +++++++++++++++- webpack.config.js | 4 ++-- 4 files changed, 23 insertions(+), 43 deletions(-) delete mode 100644 src/background/content-script.js diff --git a/src/background/content-script.js b/src/background/content-script.js deleted file mode 100644 index 9721313..0000000 --- a/src/background/content-script.js +++ /dev/null @@ -1,33 +0,0 @@ -import browser from "webextension-polyfill"; -import SLStorage from "../popup/SLStorage"; - -async function setupContentScript() { - const apiUrl = SLStorage.get(SLStorage.SETTINGS.API_URL); - - browser.tabs.onUpdated.addListener(function (tabId, changeInfo, tab) { - if ( - tab.url.startsWith("chrome") || // chrome internal pages - tab.url.startsWith("about") || // firefox internal pages - tab.url.startsWith("moz") || // firefox internal pages - tab.url.startsWith(apiUrl) // app domain - ) { - return; - } - - browser.scripting - .registerContentScripts([ - { - id: "input-tools", - js: ["content_script/input_tools.js"], - css: ["content_script/input_tools.css"], - persistAcrossSessions: false, - matches: ["*://*/*"], - runAt: "document_idle", - }, - ]) - .then(() => console.log("registration input tools complete")) - .catch((err) => console.warn("unexpected error", err)); - }); -} - -setupContentScript(); diff --git a/src/background/index.js b/src/background/index.js index 733eb0b..045b622 100644 --- a/src/background/index.js +++ b/src/background/index.js @@ -2,7 +2,6 @@ import browser from "webextension-polyfill"; import APIService, { API_ROUTE } from "../popup/APIService"; import SLStorage from "../popup/SLStorage"; import Onboarding from "./onboarding"; -import "./content-script"; import { handleNewRandomAlias } from "./create-alias"; import { @@ -66,13 +65,12 @@ async function handleExtensionSetup() { /** * Check if a message comes from an authorized source * @param {string} url - * @returns boolean + * @returns Promise */ -const isMessageAllowed = (url) => { +const isMessageAllowed = async (url) => { const requestUrl = new URL(url); - const apiUrl = new URL( - SLStorage.DEFAULT_SETTINGS[SLStorage.SETTINGS.API_URL] - ); + const apiUrlValue = await SLStorage.get(SLStorage.SETTINGS.API_URL); + const apiUrl = new URL(apiUrlValue); let allowedSources = [ new RegExp(apiUrl.hostname), @@ -119,7 +117,8 @@ browser.runtime.onMessage.addListener(async function (request, sender) { } // Check messages allowed only from authorized sources - if (!isMessageAllowed(sender.url)) return; + const messageAllowed = await isMessageAllowed(sender.url); + if (!messageAllowed) return; if (request.tag === "EXTENSION_SETUP") { return await handleExtensionSetup(); diff --git a/src/manifest.json b/src/manifest.json index 8368d85..ae33a18 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -53,5 +53,19 @@ }, "description": "Open the extension action menu" } - } + }, + "content_scripts": [ + { + "js": ["content_script/input_tools.js"], + "css": ["content_script/input_tools.css"], + "matches": ["*://*/*"], + "exclude_matches": [ + "chrome*", + "about*", + "moz*", + "app.simplelogin.io*" + ], + "run_at": "document_idle" + } + ] } \ No newline at end of file diff --git a/webpack.config.js b/webpack.config.js index fba8010..681e978 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -119,12 +119,12 @@ const config = { if (process.env.FIREFOX) { jsonContent.background = { "scripts": ["background.js"] - } + }; } else { // CHROME jsonContent.background = { "service_worker": "background.js", "type": "module" - } + }; } if (process.env.LITE) { From 191926758f7b7c1104890ffd25083a517071f3c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A0=20Casaj=C3=BAs?= Date: Mon, 15 Jul 2024 10:19:37 +0200 Subject: [PATCH 3/3] Update manifest to fullfill firefox requirements --- src/manifest.json | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/manifest.json b/src/manifest.json index ae33a18..0bef6b8 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -58,14 +58,9 @@ { "js": ["content_script/input_tools.js"], "css": ["content_script/input_tools.css"], - "matches": ["*://*/*"], - "exclude_matches": [ - "chrome*", - "about*", - "moz*", - "app.simplelogin.io*" - ], + "matches": ["http://*/*", "https://*/*"], + "exclude_matches" : ["https://app.simplelogin.io/dashboard/*"], "run_at": "document_idle" } ] -} \ No newline at end of file +}