Snapshots

This commit is contained in:
Luis Fernando Molina committed 2020-05-10 14:17:33 +02:00
1 parent e91125801d
commit 6368221937
75 files changed
+8943 -4332

No files matched your search

+1 -18
View File
@@ -92,7 +92,7 @@ function toBuffer(data) {
if (data instanceof ArrayBuffer) {
buf = Buffer.from(data);
} else if (ArrayBuffer.isView(data)) {
buf = viewToBuffer(data);
buf = Buffer.from(data.buffer, data.byteOffset, data.byteLength);
} else {
buf = Buffer.from(data);
toBuffer.readOnly = false;
@@ -101,23 +101,6 @@ function toBuffer(data) {
return buf;
}
/**
* Converts an `ArrayBuffer` view into a buffer.
*
* @param {(DataView|TypedArray)} view The view to convert
* @return {Buffer} Converted view
* @private
*/
function viewToBuffer(view) {
const buf = Buffer.from(view.buffer);
if (view.byteLength !== view.buffer.byteLength) {
return buf.slice(view.byteOffset, view.byteOffset + view.byteLength);
}
return buf;
}
try {
const bufferUtil = require('bufferutil');
const bu = bufferUtil.BufferUtil || bufferUtil;
+22 -15
View File
@@ -109,11 +109,16 @@ const EventTarget = {
/**
* Register an event listener.
*
* @param {String} method A string representing the event type to listen for
* @param {String} type A string representing the event type to listen for
* @param {Function} listener The listener to add
* @param {Object} options An options object specifies characteristics about
* the event listener
* @param {Boolean} options.once A `Boolean`` indicating that the listener
* should be invoked at most once after being added. If `true`, the
* listener would be automatically removed when invoked.
* @public
*/
addEventListener(method, listener) {
addEventListener(type, listener, options) {
if (typeof listener !== 'function') return;
function onMessage(data) {
@@ -132,36 +137,38 @@ const EventTarget = {
listener.call(this, new OpenEvent(this));
}
if (method === 'message') {
const method = options && options.once ? 'once' : 'on';
if (type === 'message') {
onMessage._listener = listener;
this.on(method, onMessage);
} else if (method === 'close') {
this[method](type, onMessage);
} else if (type === 'close') {
onClose._listener = listener;
this.on(method, onClose);
} else if (method === 'error') {
this[method](type, onClose);
} else if (type === 'error') {
onError._listener = listener;
this.on(method, onError);
} else if (method === 'open') {
this[method](type, onError);
} else if (type === 'open') {
onOpen._listener = listener;
this.on(method, onOpen);
this[method](type, onOpen);
} else {
this.on(method, listener);
this[method](type, listener);
}
},
/**
* Remove an event listener.
*
* @param {String} method A string representing the event type to remove
* @param {String} type A string representing the event type to remove
* @param {Function} listener The listener to remove
* @public
*/
removeEventListener(method, listener) {
const listeners = this.listeners(method);
removeEventListener(type, listener) {
const listeners = this.listeners(type);
for (let i = 0; i < listeners.length; i++) {
if (listeners[i] === listener || listeners[i]._listener === listener) {
this.removeListener(method, listeners[i]);
this.removeListener(type, listeners[i]);
}
}
}
+1 -1
View File
@@ -125,8 +125,8 @@ function createWebSocketStream(ws, options) {
if (ws._socket === null) return;
if (ws._socket._writableState.finished) {
if (duplex._readableState.endEmitted) duplex.destroy();
callback();
if (duplex._readableState.endEmitted) duplex.destroy();
} else {
ws._socket.once('finish', function finish() {
// `duplex` is not destroyed here because the `'end'` event will be
+10 -12
View File
@@ -7,10 +7,9 @@ const { createServer, STATUS_CODES } = require('http');
const PerMessageDeflate = require('./permessage-deflate');
const WebSocket = require('./websocket');
const { format, parse } = require('./extension');
const { GUID } = require('./constants');
const { GUID, kWebSocket } = require('./constants');
const keyRegex = /^[+/0-9A-Za-z]{22}==$/;
const kUsedByWebSocketServer = Symbol('kUsedByWebSocketServer');
/**
* Class representing a WebSocket server.
@@ -79,13 +78,6 @@ class WebSocketServer extends EventEmitter {
callback
);
} else if (options.server) {
if (options.server[kUsedByWebSocketServer]) {
throw new Error(
'The HTTP/S server is already being used by another WebSocket server'
);
}
options.server[kUsedByWebSocketServer] = true;
this._server = options.server;
}
@@ -153,8 +145,6 @@ class WebSocketServer extends EventEmitter {
server.close(() => this.emit('close'));
return;
}
delete server[kUsedByWebSocketServer];
}
process.nextTick(emitClose, this);
@@ -264,6 +254,7 @@ class WebSocketServer extends EventEmitter {
* @param {net.Socket} socket The network socket between the server and client
* @param {Buffer} head The first packet of the upgraded stream
* @param {Function} cb Callback
* @throws {Error} If called more than once with the same socket
* @private
*/
completeUpgrade(key, extensions, req, socket, head, cb) {
@@ -272,6 +263,13 @@ class WebSocketServer extends EventEmitter {
//
if (!socket.readable || !socket.writable) return socket.destroy();
if (socket[kWebSocket]) {
throw new Error(
'server.handleUpgrade() was called more than once with the same ' +
'socket, possibly due to a misconfiguration'
);
}
const digest = createHash('sha1')
.update(key + GUID)
.digest('base64');
@@ -386,7 +384,7 @@ function abortHandshake(socket, code, message, headers) {
message = message || STATUS_CODES[code];
headers = {
Connection: 'close',
'Content-type': 'text/html',
'Content-Type': 'text/html',
'Content-Length': Buffer.byteLength(message),
...headers
};
-1
View File
@@ -456,7 +456,6 @@ function initAsClient(websocket, address, protocols, options) {
protocol: undefined,
timeout: undefined,
method: undefined,
auth: undefined,
host: undefined,
path: undefined,
port: undefined
+21 -60
View File
@@ -1,52 +1,38 @@
{
"_args": [
[
"ws@^7.1.2",
"C:\\Users\\Luis\\source\\repos\\AAMasters\\TaskServer"
]
],
"_from": "ws@>=7.1.2-0 <8.0.0-0",
"_hasShrinkwrap": false,
"_id": "ws@7.2.3",
"_inCache": true,
"_from": "ws@^7.1.2",
"_id": "ws@7.3.0",
"_inBundle": false,
"_integrity": "sha512-iFtXzngZVXPGgpTlP1rBqsUK82p9tKqsWRPg5L56egiljujJT3vGAYnHANvFxBieXrTFavhzhxW52jnaWV+w2w==",
"_location": "/ws",
"_nodeVersion": "13.10.1",
"_npmOperationalInternal": {
"host": "s3://npm-registry-packages",
"tmp": "tmp/ws_7.2.3_1583774852485_0.5683086237203219"
},
"_npmUser": {
"email": "luigipinca@gmail.com",
"name": "lpinca"
},
"_npmVersion": "6.13.7",
"_phantomChildren": {},
"_requested": {
"name": "ws",
"type": "range",
"registry": true,
"raw": "ws@^7.1.2",
"name": "ws",
"escapedName": "ws",
"rawSpec": "^7.1.2",
"scope": null,
"spec": ">=7.1.2-0 <8.0.0-0",
"type": "range"
"saveSpec": null,
"fetchSpec": "^7.1.2"
},
"_requiredBy": [
"/"
],
"_resolved": "https://registry.npmjs.org/ws/-/ws-7.2.3.tgz",
"_shasum": "a5411e1fb04d5ed0efee76d26d5c46d830c39b46",
"_shrinkwrap": null,
"_resolved": "https://registry.npmjs.org/ws/-/ws-7.3.0.tgz",
"_shasum": "4b2f7f219b3d3737bc1a2fbf145d825b94d38ffd",
"_spec": "ws@^7.1.2",
"_where": "C:\\Users\\Luis\\source\\repos\\AAMasters\\TaskServer",
"author": {
"email": "einaros@gmail.com",
"name": "Einar Otto Stangvik",
"email": "einaros@gmail.com",
"url": "http://2x.io"
},
"browser": "browser.js",
"bugs": {
"url": "https://github.com/websockets/ws/issues"
},
"dependencies": {},
"bundleDependencies": false,
"deprecated": false,
"description": "Simple to use, blazing fast and thoroughly tested websocket client and server for Node.js",
"devDependencies": {
"benchmark": "^2.1.4",
@@ -60,19 +46,14 @@
"prettier": "^1.17.0",
"utf-8-validate": "^5.0.2"
},
"directories": {},
"dist": {
"fileCount": 17,
"integrity": "sha512-HTDl9G9hbkNDk98naoR/cHDws7+EyYMOdL1BmjsZXRUjf7d+MficC4B7HLUPlSiho0vg+CWKrGIt/VJBd1xunQ==",
"npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeZnyFCRA9TVsSAnZWagAAUvwP/jAz5ASUvvHJjDMOS+r/\npDkuV2MoMwz6ccV+qfbVRWUKq9DqnK7bZBApyNlzV2I+APDqLOVU+2BazNKh\nqoTcVHYcBYe5oBIYUvEeSK2qyBCNJUcz2f79lVxWagdcax5nl5tOcW3B8v4X\n9T2hSvSuDNz8vg0uhCnLboZ+F4SPXd3lHwwfcZFkNSjTcRog4W4QNQTEaPbi\noqPawUw/NXDJMFILS2m/rerFnEyrDl4VpoAS9GyitCE31g22N03bCbsmaUMo\nHmFmefATEhmtIExXMDW9JGLL9FtTwVEIAJEfAWqjLt3JeAuWHvYKKd7rU/y1\nwPUQJxwGM1HDYaxbDLXRBVYkOja3YHB5txB8d2lHLt98c5DQ/lZCz1XQIRao\nPv48dpOX2Qg69IpMzSHktoRUJpt+0KkLWUhb7XGVY79kCgqt6ZqYxBs7coae\nOeReUBaKc+yuM3k45sHxyqiKCsw/qejgzScPnmU/BaC32vEdjqpysRNDtfZj\nNmizo+cLoiO8stLVCHGBwpIxegM8aGj3/C8emNEsSFi4rXT6LGHaWvNfv3FR\nVY2/4QZFL/ddUQ3yAOKF4znsHBY2qfbpPJVnW7IyxZ2h39HX3PpITCcYDPzu\nj4LV/wXFESBSre9RANqfPfkJC+A3k0V8eAB0bYQJKImeUAiqkOkYMyrX+2Ea\nHUeL\r\n=aUaH\r\n-----END PGP SIGNATURE-----\r\n",
"shasum": "a5411e1fb04d5ed0efee76d26d5c46d830c39b46",
"tarball": "https://registry.npmjs.org/ws/-/ws-7.2.3.tgz",
"unpackedSize": 109814
},
"engines": {
"node": ">=8.3.0"
},
"gitHead": "5fcdc42ef76d2d0ab920aa37631468e6f1066bcd",
"files": [
"browser.js",
"index.js",
"lib/*.js"
],
"greenkeeper": {
"commitMessages": {
"dependencyUpdate": "[pkg] Update ${dependency} to version ${version}",
@@ -80,7 +61,6 @@
}
},
"homepage": "https://github.com/websockets/ws",
"installable": true,
"keywords": [
"HyBi",
"Push",
@@ -91,26 +71,7 @@
],
"license": "MIT",
"main": "index.js",
"maintainers": [
{
"email": "npm@3rd-Eden.com",
"name": "3rdeden"
},
{
"email": "einaros@gmail.com",
"name": "einaros"
},
{
"email": "luigipinca@gmail.com",
"name": "lpinca"
},
{
"email": "npm@3rd-Eden.com",
"name": "v1"
}
],
"name": "ws",
"optionalDependencies": {},
"peerDependencies": {
"bufferutil": "^4.0.1",
"utf-8-validate": "^5.0.2"
@@ -132,5 +93,5 @@
"lint": "eslint --ignore-path .gitignore . && prettier --check --ignore-path .gitignore \"**/*.{json,md,yaml,yml}\"",
"test": "npm run lint && nyc --reporter=html --reporter=text mocha --throw-deprecation test/*.test.js"
},
"version": "7.2.3"
"version": "7.3.0"
}