Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia
TypeScript apiapi-clientapi-restapi-testingdeveloper-toolsgraphqlhttphttp-clientpwarestrest-apispatestingtesting-toolstoolsvuevuejswebsocket
Added FirefoxStrategy to interact with the Firefox extension for Postwoman
Andrew Bastin5070d9fe95f5
diff --git a/functions/network.js b/functions/network.jsindex cf16b4c55..7ed233cf8 100644--- a/functions/network.js+++ b/functions/network.js@@ -4,6 +4,11 @@ import FirefoxStrategy from "./strategies/FirefoxStrategy";const runAppropriateStrategy = (req, store) => {+ // The firefox plugin injects a function to send requests through it+ // If that is available, then we can use the FirefoxStrategy+ if (window.firefoxExtSendRequest) {+ return FirefoxStrategy(req, store);+ }if (store.state.postwoman.settings.PROXY_ENABLED) {return ProxyStrategy(req, store);diff --git a/functions/strategies/FirefoxStrategy.js b/functions/strategies/FirefoxStrategy.jsnew file mode 100644index 000000000..77b15f453--- /dev/null+++ b/functions/strategies/FirefoxStrategy.js@@ -0,0 +1,15 @@+const firefoxStrategy = (req, _store) => new Promise((resolve, reject) => {++ const eventListener = (event) => {+ window.removeEventListener("firefoxExtSendRequestComplete", eventListener);++ if (event.detail.error) reject(JSON.parse(event.detail.error));+ else resolve(JSON.parse(event.detail.response));+ };++ window.addEventListener("firefoxExtSendRequestComplete", eventListener);++ window.firefoxExtSendRequest(req);+});++export default firefoxStrategy;