Socket
Socket
Sign inDemoInstall

socket.io-parser

Package Overview
Dependencies
3
Maintainers
2
Versions
53
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 4.2.3 to 4.2.4

23

build/cjs/index.js

@@ -10,2 +10,13 @@ "use strict";

/**
* These strings must not be used as event names, as they have a special meaning.
*/
const RESERVED_EVENTS = [
"connect",
"connect_error",
"disconnect",
"disconnecting",
"newListener",
"removeListener", // used by the Node.js EventEmitter
];
/**
* Protocol version.

@@ -101,2 +112,6 @@ *

exports.Encoder = Encoder;
// see https://stackoverflow.com/questions/8511281/check-if-a-value-is-an-object-in-javascript
function isObject(value) {
return Object.prototype.toString.call(value) === "[object Object]";
}
/**

@@ -242,11 +257,13 @@ * A socket.io Decoder instance

case PacketType.CONNECT:
return typeof payload === "object";
return isObject(payload);
case PacketType.DISCONNECT:
return payload === undefined;
case PacketType.CONNECT_ERROR:
return typeof payload === "string" || typeof payload === "object";
return typeof payload === "string" || isObject(payload);
case PacketType.EVENT:
case PacketType.BINARY_EVENT:
return (Array.isArray(payload) &&
(typeof payload[0] === "string" || typeof payload[0] === "number"));
(typeof payload[0] === "number" ||
(typeof payload[0] === "string" &&
RESERVED_EVENTS.indexOf(payload[0]) === -1)));
case PacketType.ACK:

@@ -253,0 +270,0 @@ case PacketType.BINARY_ACK:

@@ -7,2 +7,13 @@ import { Emitter } from "@socket.io/component-emitter";

/**
* These strings must not be used as event names, as they have a special meaning.
*/
const RESERVED_EVENTS = [
"connect",
"connect_error",
"disconnect",
"disconnecting",
"newListener",
"removeListener", // used by the Node.js EventEmitter
];
/**
* Protocol version.

@@ -97,2 +108,6 @@ *

}
// see https://stackoverflow.com/questions/8511281/check-if-a-value-is-an-object-in-javascript
function isObject(value) {
return Object.prototype.toString.call(value) === "[object Object]";
}
/**

@@ -238,11 +253,13 @@ * A socket.io Decoder instance

case PacketType.CONNECT:
return typeof payload === "object";
return isObject(payload);
case PacketType.DISCONNECT:
return payload === undefined;
case PacketType.CONNECT_ERROR:
return typeof payload === "string" || typeof payload === "object";
return typeof payload === "string" || isObject(payload);
case PacketType.EVENT:
case PacketType.BINARY_EVENT:
return (Array.isArray(payload) &&
(typeof payload[0] === "string" || typeof payload[0] === "number"));
(typeof payload[0] === "number" ||
(typeof payload[0] === "string" &&
RESERVED_EVENTS.indexOf(payload[0]) === -1)));
case PacketType.ACK:

@@ -249,0 +266,0 @@ case PacketType.BINARY_ACK:

@@ -5,2 +5,13 @@ import { Emitter } from "@socket.io/component-emitter";

/**
* These strings must not be used as event names, as they have a special meaning.
*/
const RESERVED_EVENTS = [
"connect",
"connect_error",
"disconnect",
"disconnecting",
"newListener",
"removeListener", // used by the Node.js EventEmitter
];
/**
* Protocol version.

@@ -93,2 +104,6 @@ *

}
// see https://stackoverflow.com/questions/8511281/check-if-a-value-is-an-object-in-javascript
function isObject(value) {
return Object.prototype.toString.call(value) === "[object Object]";
}
/**

@@ -233,11 +248,13 @@ * A socket.io Decoder instance

case PacketType.CONNECT:
return typeof payload === "object";
return isObject(payload);
case PacketType.DISCONNECT:
return payload === undefined;
case PacketType.CONNECT_ERROR:
return typeof payload === "string" || typeof payload === "object";
return typeof payload === "string" || isObject(payload);
case PacketType.EVENT:
case PacketType.BINARY_EVENT:
return (Array.isArray(payload) &&
(typeof payload[0] === "string" || typeof payload[0] === "number"));
(typeof payload[0] === "number" ||
(typeof payload[0] === "string" &&
RESERVED_EVENTS.indexOf(payload[0]) === -1)));
case PacketType.ACK:

@@ -244,0 +261,0 @@ case PacketType.BINARY_ACK:

2

package.json
{
"name": "socket.io-parser",
"version": "4.2.3",
"version": "4.2.4",
"description": "socket.io protocol parser",

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

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc