You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

socket.io-parser

Package Overview
Dependencies
Maintainers
2
Versions
54
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 4.0.1-rc1 to 4.0.1-rc2

9

CHANGELOG.md

@@ -0,1 +1,10 @@

## [4.0.1-rc2](https://github.com/socketio/socket.io-parser/compare/4.0.1-rc1...4.0.1-rc2) (2020-10-15)
### Features
* move binary detection back to the parser ([285e7cd](https://github.com/socketio/socket.io-parser/commit/285e7cd0d837adfc911c999e7294788681226ae1))
## [4.0.1-rc1](https://github.com/socketio/socket.io-parser/compare/4.0.0...4.0.1-rc1) (2020-10-12)

@@ -2,0 +11,0 @@

7

dist/binary.js
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.reconstructPacket = exports.deconstructPacket = void 0;
const is_binary_1 = __importDefault(require("./is-binary"));
const is_binary_1 = require("./is-binary");
/**

@@ -27,3 +24,3 @@ * Replaces every Buffer | ArrayBuffer | Blob | File in packet with a numbered placeholder.

return data;
if (is_binary_1.default(data)) {
if (is_binary_1.isBinary(data)) {
const placeholder = { _placeholder: true, num: buffers.length };

@@ -30,0 +27,0 @@ buffers.push(data);

@@ -1,2 +0,2 @@

import Emitter from "component-emitter";
import Emitter = require("component-emitter");
/**

@@ -3,0 +3,0 @@ * Protocol version.

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Decoder = exports.Encoder = exports.PacketType = exports.protocol = void 0;
const component_emitter_1 = __importDefault(require("component-emitter"));
const Emitter = require("component-emitter");
const binary_1 = require("./binary");
const is_binary_1 = __importDefault(require("./is-binary"));
const is_binary_1 = require("./is-binary");
const debug = require("debug")("socket.io-parser");

@@ -16,3 +13,3 @@ /**

*/
exports.protocol = 4;
exports.protocol = 5;
var PacketType;

@@ -40,10 +37,12 @@ (function (PacketType) {

debug("encoding packet %j", obj);
if (obj.type === PacketType.BINARY_EVENT ||
obj.type === PacketType.BINARY_ACK) {
return this.encodeAsBinary(obj);
if (obj.type === PacketType.EVENT || obj.type === PacketType.ACK) {
if (is_binary_1.hasBinary(obj)) {
obj.type =
obj.type === PacketType.EVENT
? PacketType.BINARY_EVENT
: PacketType.BINARY_ACK;
return this.encodeAsBinary(obj);
}
}
else {
const encoding = this.encodeAsString(obj);
return [encoding];
}
return [this.encodeAsString(obj)];
}

@@ -96,3 +95,3 @@ /**

*/
class Decoder extends component_emitter_1.default {
class Decoder extends Emitter {
constructor() {

@@ -124,3 +123,3 @@ super();

}
else if (is_binary_1.default(obj) || obj.base64) {
else if (is_binary_1.isBinary(obj) || obj.base64) {
// raw binary data

@@ -127,0 +126,0 @@ if (!this.reconstructor) {

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

*/
export default function isBinary(obj: any): boolean;
export declare function isBinary(obj: any): boolean;
export declare function hasBinary(obj: any, toJSON?: boolean): any;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const withNativeBuffer = typeof Buffer === "function" && typeof Buffer.isBuffer === "function";
exports.hasBinary = exports.isBinary = void 0;
const withNativeArrayBuffer = typeof ArrayBuffer === "function";

@@ -23,7 +23,34 @@ const isView = (obj) => {

function isBinary(obj) {
return ((withNativeBuffer && Buffer.isBuffer(obj)) ||
(withNativeArrayBuffer && (obj instanceof ArrayBuffer || isView(obj))) ||
return ((withNativeArrayBuffer && (obj instanceof ArrayBuffer || isView(obj))) ||
(withNativeBlob && obj instanceof Blob) ||
(withNativeFile && obj instanceof File));
}
exports.default = isBinary;
exports.isBinary = isBinary;
function hasBinary(obj, toJSON) {
if (!obj || typeof obj !== "object") {
return false;
}
if (Array.isArray(obj)) {
for (let i = 0, l = obj.length; i < l; i++) {
if (hasBinary(obj[i])) {
return true;
}
}
return false;
}
if (isBinary(obj)) {
return true;
}
if (obj.toJSON &&
typeof obj.toJSON === "function" &&
arguments.length === 1) {
return hasBinary(obj.toJSON(), true);
}
for (const key in obj) {
if (Object.prototype.hasOwnProperty.call(obj, key) && hasBinary(obj[key])) {
return true;
}
}
return false;
}
exports.hasBinary = hasBinary;
{
"name": "socket.io-parser",
"version": "4.0.1-rc1",
"version": "4.0.1-rc2",
"description": "socket.io protocol parser",

@@ -5,0 +5,0 @@ "repository": {

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc