Socket
Socket
Sign inDemoInstall

engine.io

Package Overview
Dependencies
20
Maintainers
2
Versions
147
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 6.1.2 to 6.1.3

4

build/server.d.ts

@@ -5,3 +5,3 @@ /// <reference types="node" />

import { CookieSerializeOptions } from "cookie";
import { CorsOptions } from "cors";
import { CorsOptions, CorsOptionsDelegate } from "cors";
declare type Transport = "polling" | "websocket";

@@ -96,3 +96,3 @@ export interface AttachOptions {

*/
cors?: CorsOptions;
cors?: CorsOptions | CorsOptionsDelegate;
/**

@@ -99,0 +99,0 @@ * whether to enable compatibility with Socket.IO v2 clients

@@ -44,2 +44,8 @@ import { Transport } from "../transport";

/**
* Cleanup request.
*
* @api private
*/
private onDataRequestCleanup;
/**
* Processes the incoming data payload.

@@ -46,0 +52,0 @@ *

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

}
const expectedContentLength = Number(req.headers["content-length"]);
if (!expectedContentLength) {
this.onError("content-length header required");
res.writeStatus("411 Length Required").end();
return;
}
if (expectedContentLength > this.maxHttpBufferSize) {
this.onError("payload too large");
res.writeStatus("413 Payload Too Large").end();
return;
}
const isBinary = "application/octet-stream" === req.headers["content-type"];

@@ -108,11 +119,4 @@ if (isBinary && this.protocol === 4) {

this.dataRes = res;
let chunks = [];
let contentLength = 0;
const cleanup = () => {
this.dataReq = this.dataRes = chunks = null;
};
const onClose = () => {
cleanup();
this.onError("data request connection closed prematurely");
};
let buffer;
let offset = 0;
const headers = {

@@ -124,28 +128,51 @@ // text/html is required instead of text/plain to avoid an

this.headers(req, headers);
Object.keys(headers).forEach(key => {
for (let key in headers) {
res.writeHeader(key, String(headers[key]));
}
const onEnd = buffer => {
this.onData(buffer.toString());
this.onDataRequestCleanup();
res.end("ok");
};
res.onAborted(() => {
this.onDataRequestCleanup();
this.onError("data request connection closed prematurely");
});
const onEnd = () => {
this.onData(Buffer.concat(chunks).toString());
if (this.readyState !== "closing") {
res.end("ok");
}
cleanup();
};
res.onAborted(onClose);
res.onData((chunk, isLast) => {
chunks.push(Buffer.from(chunk));
contentLength += Buffer.byteLength(chunk);
if (contentLength > this.maxHttpBufferSize) {
this.onError("payload too large");
res.writeStatus("413 Payload Too Large");
res.end();
res.onData((arrayBuffer, isLast) => {
const totalLength = offset + arrayBuffer.byteLength;
if (totalLength > expectedContentLength) {
this.onError("content-length mismatch");
res.close(); // calls onAborted
return;
}
if (!buffer) {
if (isLast) {
onEnd(Buffer.from(arrayBuffer));
return;
}
buffer = Buffer.allocUnsafe(expectedContentLength);
}
Buffer.from(arrayBuffer).copy(buffer, offset);
if (isLast) {
onEnd();
if (totalLength != expectedContentLength) {
this.onError("content-length mismatch");
res.writeStatus("400 Content-Length Mismatch").end();
this.onDataRequestCleanup();
return;
}
onEnd(buffer);
return;
}
offset = totalLength;
});
}
/**
* Cleanup request.
*
* @api private
*/
onDataRequestCleanup() {
this.dataReq = this.dataRes = null;
}
/**
* Processes the incoming data payload.

@@ -152,0 +179,0 @@ *

{
"name": "engine.io",
"version": "6.1.2",
"version": "6.1.3",
"description": "The realtime engine behind Socket.IO. Provides the foundation of a bidirectional connection between client and server",

@@ -42,3 +42,3 @@ "type": "commonjs",

"debug": "~4.3.1",
"engine.io-parser": "~5.0.0",
"engine.io-parser": "~5.0.3",
"ws": "~8.2.3"

@@ -45,0 +45,0 @@ },

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