mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-10-03 02:21:05 +08:00
This change addresses 2 issues in uglify-js and socket.io-parser. See reports below for details: - https://www.mend.io/vulnerability-database/CVE-2022-37598 - https://nvd.nist.gov/vuln/detail/CVE-2022-2421 The socket.io-parser issue was addressed by running npm audit via the following command: `npm run install-deps audit fix --audit-level=critical` Since audit didn't recognize the uglify-js issue, I updated uglify-js to version 3.13.10 "manually" by adding an entry in manage_node_deps.py. running install-deps to update package-lock.json and then removing the entry from manage_node_deps.py. Bug: None Change-Id: I29238b14773a1b94b973886b0bb700f50e45cfa9 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/4061168 Reviewed-by: Benedikt Meurer <bmeurer@chromium.org> Commit-Queue: Brandon Walderman <brwalder@microsoft.com>
52 lines
1.6 KiB
JavaScript
52 lines
1.6 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
const commons_js_1 = require("./commons.js");
|
|
const base64_arraybuffer_js_1 = require("./contrib/base64-arraybuffer.js");
|
|
const withNativeArrayBuffer = typeof ArrayBuffer === "function";
|
|
const decodePacket = (encodedPacket, binaryType) => {
|
|
if (typeof encodedPacket !== "string") {
|
|
return {
|
|
type: "message",
|
|
data: mapBinary(encodedPacket, binaryType)
|
|
};
|
|
}
|
|
const type = encodedPacket.charAt(0);
|
|
if (type === "b") {
|
|
return {
|
|
type: "message",
|
|
data: decodeBase64Packet(encodedPacket.substring(1), binaryType)
|
|
};
|
|
}
|
|
const packetType = commons_js_1.PACKET_TYPES_REVERSE[type];
|
|
if (!packetType) {
|
|
return commons_js_1.ERROR_PACKET;
|
|
}
|
|
return encodedPacket.length > 1
|
|
? {
|
|
type: commons_js_1.PACKET_TYPES_REVERSE[type],
|
|
data: encodedPacket.substring(1)
|
|
}
|
|
: {
|
|
type: commons_js_1.PACKET_TYPES_REVERSE[type]
|
|
};
|
|
};
|
|
const decodeBase64Packet = (data, binaryType) => {
|
|
if (withNativeArrayBuffer) {
|
|
const decoded = (0, base64_arraybuffer_js_1.decode)(data);
|
|
return mapBinary(decoded, binaryType);
|
|
}
|
|
else {
|
|
return { base64: true, data }; // fallback for old browsers
|
|
}
|
|
};
|
|
const mapBinary = (data, binaryType) => {
|
|
switch (binaryType) {
|
|
case "blob":
|
|
return data instanceof ArrayBuffer ? new Blob([data]) : data;
|
|
case "arraybuffer":
|
|
default:
|
|
return data; // assuming the data is already an ArrayBuffer
|
|
}
|
|
};
|
|
exports.default = decodePacket;
|