Socket
Socket
Sign inDemoInstall

metro-inspector-proxy

Package Overview
Dependencies
Maintainers
2
Versions
70
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

metro-inspector-proxy - npm Package Compare versions

Comparing version 0.72.3 to 0.73.0

4

package.json
{
"name": "metro-inspector-proxy",
"version": "0.72.3",
"version": "0.73.0",
"description": "🚇 Inspector proxy for React Native and dev tools integration.",

@@ -23,4 +23,4 @@ "main": "src/index.js",

"ws": "^7.5.1",
"yargs": "^15.3.1"
"yargs": "^17.5.1"
}
}

@@ -9,2 +9,3 @@ /**

* @format
* @oncall react_native
*/

@@ -29,3 +30,4 @@ "use strict";

default: "",
}).argv;
})
.parseSync();
runInspectorProxy(argv.port, argv.root);

@@ -5,2 +5,4 @@ "use strict";

var http = _interopRequireWildcard(require("http"));
var path = _interopRequireWildcard(require("path"));

@@ -64,2 +66,3 @@

* @format
* @oncall react_native
*/

@@ -186,10 +189,9 @@ const debug = require("debug")("Metro:InspectorProxy");

const interceptedResponse = this._interceptMessageFromDebugger(
const handled = this._interceptMessageFromDebugger(
debuggerRequest,
debuggerInfo
debuggerInfo,
socket
);
if (interceptedResponse) {
socket.send(JSON.stringify(interceptedResponse));
} else {
if (!handled) {
this._sendMessageToDevice({

@@ -477,17 +479,16 @@ event: "wrappedEvent",

}
} // Allows to make changes in incoming messages from debugger.
} // Allows to make changes in incoming messages from debugger. Returns a boolean
// indicating whether the message has been handled locally (i.e. does not need
// to be forwarded to the target).
_interceptMessageFromDebugger(req, debuggerInfo) {
let response = null;
_interceptMessageFromDebugger(req, debuggerInfo, socket) {
if (req.method === "Debugger.setBreakpointByUrl") {
this._processDebuggerSetBreakpointByUrl(req, debuggerInfo);
} else if (req.method === "Debugger.getScriptSource") {
response = {
id: req.id,
result: this._processDebuggerGetScriptSource(req),
};
this._processDebuggerGetScriptSource(req, socket);
return true;
}
return response;
return false;
}

@@ -524,5 +525,17 @@

_processDebuggerGetScriptSource(req) {
_processDebuggerGetScriptSource(req, socket) {
let scriptSource = `Source for script with id '${req.params.scriptId}' was not found.`;
const sendResponse = () => {
const result = {
scriptSource,
};
socket.send(
JSON.stringify({
id: req.id,
result,
})
);
};
const pathToSource = this._scriptIdToSourcePathMapping.get(

@@ -533,15 +546,45 @@ req.params.scriptId

if (pathToSource) {
let pathIsURL = false;
try {
scriptSource = fs.readFileSync(
path.resolve(this._projectRoot, pathToSource),
"utf8"
);
} catch (err) {
scriptSource = err.message;
pathIsURL = new URL(pathToSource).hostname == "localhost";
} catch {}
if (pathIsURL) {
http
.get(pathToSource, (httpResponse) => {
const { statusCode } = httpResponse;
if (statusCode == 200) {
httpResponse.setEncoding("utf8");
scriptSource = "";
httpResponse.on("data", (body) => {
scriptSource += body;
});
httpResponse.on("end", () => {
sendResponse();
});
} else {
scriptSource = `Fetching ${pathToSource} returned status ${statusCode}`;
sendResponse();
httpResponse.resume();
}
})
.on("error", (e) => {
scriptSource = `Fetching ${pathToSource} failed with error ${e.message}`;
sendResponse();
});
} else {
try {
scriptSource = fs.readFileSync(
path.resolve(this._projectRoot, pathToSource),
"utf8"
);
} catch (err) {
scriptSource = err.message;
}
sendResponse();
}
}
return {
scriptSource,
};
}

@@ -548,0 +591,0 @@

@@ -9,2 +9,3 @@ /**

* @format
* @oncall react_native
*/

@@ -11,0 +12,0 @@ "use strict";

@@ -9,2 +9,3 @@ /**

* @format
* @oncall react_native
*/

@@ -11,0 +12,0 @@ "use strict";

@@ -9,2 +9,3 @@ /**

* @format
* @oncall react_native
*/

@@ -11,0 +12,0 @@ "use strict"; // Page information received from the device. New page is created for

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc