This commit is contained in:
lalBi94
2023-03-05 13:23:23 +01:00
commit 7bc56c09b5
14034 changed files with 1834369 additions and 0 deletions

28
node_modules/websocket-extensions/CHANGELOG.md generated vendored Normal file
View File

@@ -0,0 +1,28 @@
### 0.1.4 / 2020-06-02
- Remove a ReDoS vulnerability in the header parser (CVE-2020-7662, reported by
Robert McLaughlin)
- Change license from MIT to Apache 2.0
### 0.1.3 / 2017-11-11
- Accept extension names and parameters including uppercase letters
- Handle extension names that clash with `Object.prototype` properties
### 0.1.2 / 2017-09-10
- Catch synchronous exceptions thrown when calling an extension
- Fix race condition caused when a message is pushed after a cell has stopped
due to an error
- Fix failure of `close()` to return if a message that's queued after one that
produces an error never finishes being processed
### 0.1.1 / 2015-02-19
- Prevent sessions being closed before they have finished processing messages
- Add a callback to `Extensions.close()` so the caller can tell when it's safe
to close the socket
### 0.1.0 / 2014-12-12
- Initial release

12
node_modules/websocket-extensions/LICENSE.md generated vendored Normal file
View File

@@ -0,0 +1,12 @@
Copyright 2014-2020 James Coglan
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.

331
node_modules/websocket-extensions/README.md generated vendored Normal file
View File

@@ -0,0 +1,331 @@
# websocket-extensions [![Build status](https://secure.travis-ci.org/faye/websocket-extensions-node.svg)](http://travis-ci.org/faye/websocket-extensions-node)
A minimal framework that supports the implementation of WebSocket extensions in
a way that's decoupled from the main protocol. This library aims to allow a
WebSocket extension to be written and used with any protocol library, by
defining abstract representations of frames and messages that allow modules to
co-operate.
`websocket-extensions` provides a container for registering extension plugins,
and provides all the functions required to negotiate which extensions to use
during a session via the `Sec-WebSocket-Extensions` header. By implementing the
APIs defined in this document, an extension may be used by any WebSocket library
based on this framework.
## Installation
```
$ npm install websocket-extensions
```
## Usage
There are two main audiences for this library: authors implementing the
WebSocket protocol, and authors implementing extensions. End users of a
WebSocket library or an extension should be able to use any extension by passing
it as an argument to their chosen protocol library, without needing to know how
either of them work, or how the `websocket-extensions` framework operates.
The library is designed with the aim that any protocol implementation and any
extension can be used together, so long as they support the same abstract
representation of frames and messages.
### Data types
The APIs provided by the framework rely on two data types; extensions will
expect to be given data and to be able to return data in these formats:
#### *Frame*
*Frame* is a structure representing a single WebSocket frame of any type. Frames
are simple objects that must have at least the following properties, which
represent the data encoded in the frame:
| property | description |
| ------------ | ------------------------------------------------------------------ |
| `final` | `true` if the `FIN` bit is set, `false` otherwise |
| `rsv1` | `true` if the `RSV1` bit is set, `false` otherwise |
| `rsv2` | `true` if the `RSV2` bit is set, `false` otherwise |
| `rsv3` | `true` if the `RSV3` bit is set, `false` otherwise |
| `opcode` | the numeric opcode (`0`, `1`, `2`, `8`, `9`, or `10`) of the frame |
| `masked` | `true` if the `MASK` bit is set, `false` otherwise |
| `maskingKey` | a 4-byte `Buffer` if `masked` is `true`, otherwise `null` |
| `payload` | a `Buffer` containing the (unmasked) application data |
#### *Message*
A *Message* represents a complete application message, which can be formed from
text, binary and continuation frames. It has the following properties:
| property | description |
| -------- | ----------------------------------------------------------------- |
| `rsv1` | `true` if the first frame of the message has the `RSV1` bit set |
| `rsv2` | `true` if the first frame of the message has the `RSV2` bit set |
| `rsv3` | `true` if the first frame of the message has the `RSV3` bit set |
| `opcode` | the numeric opcode (`1` or `2`) of the first frame of the message |
| `data` | the concatenation of all the frame payloads in the message |
### For driver authors
A driver author is someone implementing the WebSocket protocol proper, and who
wishes end users to be able to use WebSocket extensions with their library.
At the start of a WebSocket session, on both the client and the server side,
they should begin by creating an extension container and adding whichever
extensions they want to use.
```js
var Extensions = require('websocket-extensions'),
deflate = require('permessage-deflate');
var exts = new Extensions();
exts.add(deflate);
```
In the following examples, `exts` refers to this `Extensions` instance.
#### Client sessions
Clients will use the methods `generateOffer()` and `activate(header)`.
As part of the handshake process, the client must send a
`Sec-WebSocket-Extensions` header to advertise that it supports the registered
extensions. This header should be generated using:
```js
request.headers['sec-websocket-extensions'] = exts.generateOffer();
```
This returns a string, for example `"permessage-deflate;
client_max_window_bits"`, that represents all the extensions the client is
offering to use, and their parameters. This string may contain multiple offers
for the same extension.
When the client receives the handshake response from the server, it should pass
the incoming `Sec-WebSocket-Extensions` header in to `exts` to activate the
extensions the server has accepted:
```js
exts.activate(response.headers['sec-websocket-extensions']);
```
If the server has sent any extension responses that the client does not
recognize, or are in conflict with one another for use of RSV bits, or that use
invalid parameters for the named extensions, then `exts.activate()` will
`throw`. In this event, the client driver should fail the connection with
closing code `1010`.
#### Server sessions
Servers will use the method `generateResponse(header)`.
A server session needs to generate a `Sec-WebSocket-Extensions` header to send
in its handshake response:
```js
var clientOffer = request.headers['sec-websocket-extensions'],
extResponse = exts.generateResponse(clientOffer);
response.headers['sec-websocket-extensions'] = extResponse;
```
Calling `exts.generateResponse(header)` activates those extensions the client
has asked to use, if they are registered, asks each extension for a set of
response parameters, and returns a string containing the response parameters for
all accepted extensions.
#### In both directions
Both clients and servers will use the methods `validFrameRsv(frame)`,
`processIncomingMessage(message)` and `processOutgoingMessage(message)`.
The WebSocket protocol requires that frames do not have any of the `RSV` bits
set unless there is an extension in use that allows otherwise. When processing
an incoming frame, sessions should pass a *Frame* object to:
```js
exts.validFrameRsv(frame)
```
If this method returns `false`, the session should fail the WebSocket connection
with closing code `1002`.
To pass incoming messages through the extension stack, a session should
construct a *Message* object according to the above datatype definitions, and
call:
```js
exts.processIncomingMessage(message, function(error, msg) {
// hand the message off to the application
});
```
If any extensions fail to process the message, then the callback will yield an
error and the session should fail the WebSocket connection with closing code
`1010`. If `error` is `null`, then `msg` should be passed on to the application.
To pass outgoing messages through the extension stack, a session should
construct a *Message* as before, and call:
```js
exts.processOutgoingMessage(message, function(error, msg) {
// write message to the transport
});
```
If any extensions fail to process the message, then the callback will yield an
error and the session should fail the WebSocket connection with closing code
`1010`. If `error` is `null`, then `message` should be converted into frames
(with the message's `rsv1`, `rsv2`, `rsv3` and `opcode` set on the first frame)
and written to the transport.
At the end of the WebSocket session (either when the protocol is explicitly
ended or the transport connection disconnects), the driver should call:
```js
exts.close(function() {})
```
The callback is invoked when all extensions have finished processing any
messages in the pipeline and it's safe to close the socket.
### For extension authors
An extension author is someone implementing an extension that transforms
WebSocket messages passing between the client and server. They would like to
implement their extension once and have it work with any protocol library.
Extension authors will not install `websocket-extensions` or call it directly.
Instead, they should implement the following API to allow their extension to
plug into the `websocket-extensions` framework.
An `Extension` is any object that has the following properties:
| property | description |
| -------- | ---------------------------------------------------------------------------- |
| `name` | a string containing the name of the extension as used in negotiation headers |
| `type` | a string, must be `"permessage"` |
| `rsv1` | either `true` if the extension uses the RSV1 bit, `false` otherwise |
| `rsv2` | either `true` if the extension uses the RSV2 bit, `false` otherwise |
| `rsv3` | either `true` if the extension uses the RSV3 bit, `false` otherwise |
It must also implement the following methods:
```js
ext.createClientSession()
```
This returns a *ClientSession*, whose interface is defined below.
```js
ext.createServerSession(offers)
```
This takes an array of offer params and returns a *ServerSession*, whose
interface is defined below. For example, if the client handshake contains the
offer header:
```
Sec-WebSocket-Extensions: permessage-deflate; server_no_context_takeover; server_max_window_bits=8, \
permessage-deflate; server_max_window_bits=15
```
then the `permessage-deflate` extension will receive the call:
```js
ext.createServerSession([
{ server_no_context_takeover: true, server_max_window_bits: 8 },
{ server_max_window_bits: 15 }
]);
```
The extension must decide which set of parameters it wants to accept, if any,
and return a *ServerSession* if it wants to accept the parameters and `null`
otherwise.
#### *ClientSession*
A *ClientSession* is the type returned by `ext.createClientSession()`. It must
implement the following methods, as well as the *Session* API listed below.
```js
clientSession.generateOffer()
// e.g. -> [
// { server_no_context_takeover: true, server_max_window_bits: 8 },
// { server_max_window_bits: 15 }
// ]
```
This must return a set of parameters to include in the client's
`Sec-WebSocket-Extensions` offer header. If the session wants to offer multiple
configurations, it can return an array of sets of parameters as shown above.
```js
clientSession.activate(params) // -> true
```
This must take a single set of parameters from the server's handshake response
and use them to configure the client session. If the client accepts the given
parameters, then this method must return `true`. If it returns any other value,
the framework will interpret this as the client rejecting the response, and will
`throw`.
#### *ServerSession*
A *ServerSession* is the type returned by `ext.createServerSession(offers)`. It
must implement the following methods, as well as the *Session* API listed below.
```js
serverSession.generateResponse()
// e.g. -> { server_max_window_bits: 8 }
```
This returns the set of parameters the server session wants to send in its
`Sec-WebSocket-Extensions` response header. Only one set of parameters is
returned to the client per extension. Server sessions that would confict on
their use of RSV bits are not activated.
#### *Session*
The *Session* API must be implemented by both client and server sessions. It
contains two methods, `processIncomingMessage(message)` and
`processOutgoingMessage(message)`.
```js
session.processIncomingMessage(message, function(error, msg) { ... })
```
The session must implement this method to take an incoming *Message* as defined
above, transform it in any way it needs, then return it via the callback. If
there is an error processing the message, this method should yield an error as
the first argument.
```js
session.processOutgoingMessage(message, function(error, msg) { ... })
```
The session must implement this method to take an outgoing *Message* as defined
above, transform it in any way it needs, then return it via the callback. If
there is an error processing the message, this method should yield an error as
the first argument.
Note that both `processIncomingMessage()` and `processOutgoingMessage()` can
perform their logic asynchronously, are allowed to process multiple messages
concurrently, and are not required to complete working on messages in the same
order the messages arrive. `websocket-extensions` will reorder messages as your
extension emits them and will make sure every extension is given messages in the
order they arrive from the driver. This allows extensions to maintain state that
depends on the messages' wire order, for example keeping a DEFLATE compression
context between messages.
```js
session.close()
```
The framework will call this method when the WebSocket session ends, allowing
the session to release any resources it's using.
## Examples
- Consumer: [websocket-driver](https://github.com/faye/websocket-driver-node)
- Provider: [permessage-deflate](https://github.com/faye/permessage-deflate-node)

103
node_modules/websocket-extensions/lib/parser.js generated vendored Normal file
View File

@@ -0,0 +1,103 @@
'use strict';
var TOKEN = /([!#\$%&'\*\+\-\.\^_`\|~0-9A-Za-z]+)/,
NOTOKEN = /([^!#\$%&'\*\+\-\.\^_`\|~0-9A-Za-z])/g,
QUOTED = /"((?:\\[\x00-\x7f]|[^\x00-\x08\x0a-\x1f\x7f"\\])*)"/,
PARAM = new RegExp(TOKEN.source + '(?:=(?:' + TOKEN.source + '|' + QUOTED.source + '))?'),
EXT = new RegExp(TOKEN.source + '(?: *; *' + PARAM.source + ')*', 'g'),
EXT_LIST = new RegExp('^' + EXT.source + '(?: *, *' + EXT.source + ')*$'),
NUMBER = /^-?(0|[1-9][0-9]*)(\.[0-9]+)?$/;
var hasOwnProperty = Object.prototype.hasOwnProperty;
var Parser = {
parseHeader: function(header) {
var offers = new Offers();
if (header === '' || header === undefined) return offers;
if (!EXT_LIST.test(header))
throw new SyntaxError('Invalid Sec-WebSocket-Extensions header: ' + header);
var values = header.match(EXT);
values.forEach(function(value) {
var params = value.match(new RegExp(PARAM.source, 'g')),
name = params.shift(),
offer = {};
params.forEach(function(param) {
var args = param.match(PARAM), key = args[1], data;
if (args[2] !== undefined) {
data = args[2];
} else if (args[3] !== undefined) {
data = args[3].replace(/\\/g, '');
} else {
data = true;
}
if (NUMBER.test(data)) data = parseFloat(data);
if (hasOwnProperty.call(offer, key)) {
offer[key] = [].concat(offer[key]);
offer[key].push(data);
} else {
offer[key] = data;
}
}, this);
offers.push(name, offer);
}, this);
return offers;
},
serializeParams: function(name, params) {
var values = [];
var print = function(key, value) {
if (value instanceof Array) {
value.forEach(function(v) { print(key, v) });
} else if (value === true) {
values.push(key);
} else if (typeof value === 'number') {
values.push(key + '=' + value);
} else if (NOTOKEN.test(value)) {
values.push(key + '="' + value.replace(/"/g, '\\"') + '"');
} else {
values.push(key + '=' + value);
}
};
for (var key in params) print(key, params[key]);
return [name].concat(values).join('; ');
}
};
var Offers = function() {
this._byName = {};
this._inOrder = [];
};
Offers.prototype.push = function(name, params) {
if (!hasOwnProperty.call(this._byName, name))
this._byName[name] = [];
this._byName[name].push(params);
this._inOrder.push({ name: name, params: params });
};
Offers.prototype.eachOffer = function(callback, context) {
var list = this._inOrder;
for (var i = 0, n = list.length; i < n; i++)
callback.call(context, list[i].name, list[i].params);
};
Offers.prototype.byName = function(name) {
return this._byName[name] || [];
};
Offers.prototype.toArray = function() {
return this._inOrder.slice();
};
module.exports = Parser;

File diff suppressed because it is too large Load Diff

53
node_modules/websocket-extensions/lib/pipeline/cell.js generated vendored Normal file
View File

@@ -0,0 +1,53 @@
'use strict';
var Functor = require('./functor'),
Pledge = require('./pledge');
var Cell = function(tuple) {
this._ext = tuple[0];
this._session = tuple[1];
this._functors = {
incoming: new Functor(this._session, 'processIncomingMessage'),
outgoing: new Functor(this._session, 'processOutgoingMessage')
};
};
Cell.prototype.pending = function(direction) {
var functor = this._functors[direction];
if (!functor._stopped) functor.pending += 1;
};
Cell.prototype.incoming = function(error, message, callback, context) {
this._exec('incoming', error, message, callback, context);
};
Cell.prototype.outgoing = function(error, message, callback, context) {
this._exec('outgoing', error, message, callback, context);
};
Cell.prototype.close = function() {
this._closed = this._closed || new Pledge();
this._doClose();
return this._closed;
};
Cell.prototype._exec = function(direction, error, message, callback, context) {
this._functors[direction].call(error, message, function(err, msg) {
if (err) err.message = this._ext.name + ': ' + err.message;
callback.call(context, err, msg);
this._doClose();
}, this);
};
Cell.prototype._doClose = function() {
var fin = this._functors.incoming,
fout = this._functors.outgoing;
if (!this._closed || fin.pending + fout.pending !== 0) return;
if (this._session) this._session.close();
this._session = null;
this._closed.done();
};
module.exports = Cell;

View File

@@ -0,0 +1,72 @@
'use strict';
var RingBuffer = require('./ring_buffer');
var Functor = function(session, method) {
this._session = session;
this._method = method;
this._queue = new RingBuffer(Functor.QUEUE_SIZE);
this._stopped = false;
this.pending = 0;
};
Functor.QUEUE_SIZE = 8;
Functor.prototype.call = function(error, message, callback, context) {
if (this._stopped) return;
var record = { error: error, message: message, callback: callback, context: context, done: false },
called = false,
self = this;
this._queue.push(record);
if (record.error) {
record.done = true;
this._stop();
return this._flushQueue();
}
var handler = function(err, msg) {
if (!(called ^ (called = true))) return;
if (err) {
self._stop();
record.error = err;
record.message = null;
} else {
record.message = msg;
}
record.done = true;
self._flushQueue();
};
try {
this._session[this._method](message, handler);
} catch (err) {
handler(err);
}
};
Functor.prototype._stop = function() {
this.pending = this._queue.length;
this._stopped = true;
};
Functor.prototype._flushQueue = function() {
var queue = this._queue, record;
while (queue.length > 0 && queue.peek().done) {
record = queue.shift();
if (record.error) {
this.pending = 0;
queue.clear();
} else {
this.pending -= 1;
}
record.callback.call(record.context, record.error, record.message);
}
};
module.exports = Functor;

View File

@@ -0,0 +1,47 @@
'use strict';
var Cell = require('./cell'),
Pledge = require('./pledge');
var Pipeline = function(sessions) {
this._cells = sessions.map(function(session) { return new Cell(session) });
this._stopped = { incoming: false, outgoing: false };
};
Pipeline.prototype.processIncomingMessage = function(message, callback, context) {
if (this._stopped.incoming) return;
this._loop('incoming', this._cells.length - 1, -1, -1, message, callback, context);
};
Pipeline.prototype.processOutgoingMessage = function(message, callback, context) {
if (this._stopped.outgoing) return;
this._loop('outgoing', 0, this._cells.length, 1, message, callback, context);
};
Pipeline.prototype.close = function(callback, context) {
this._stopped = { incoming: true, outgoing: true };
var closed = this._cells.map(function(a) { return a.close() });
if (callback)
Pledge.all(closed).then(function() { callback.call(context) });
};
Pipeline.prototype._loop = function(direction, start, end, step, message, callback, context) {
var cells = this._cells,
n = cells.length,
self = this;
while (n--) cells[n].pending(direction);
var pipe = function(index, error, msg) {
if (index === end) return callback.call(context, error, msg);
cells[index][direction](error, msg, function(err, m) {
if (err) self._stopped[direction] = true;
pipe(index + step, err, m);
});
};
pipe(start, null, message);
};
module.exports = Pipeline;

View File

@@ -0,0 +1,37 @@
'use strict';
var RingBuffer = require('./ring_buffer');
var Pledge = function() {
this._complete = false;
this._callbacks = new RingBuffer(Pledge.QUEUE_SIZE);
};
Pledge.QUEUE_SIZE = 4;
Pledge.all = function(list) {
var pledge = new Pledge(),
pending = list.length,
n = pending;
if (pending === 0) pledge.done();
while (n--) list[n].then(function() {
pending -= 1;
if (pending === 0) pledge.done();
});
return pledge;
};
Pledge.prototype.then = function(callback) {
if (this._complete) callback();
else this._callbacks.push(callback);
};
Pledge.prototype.done = function() {
this._complete = true;
var callbacks = this._callbacks, callback;
while (callback = callbacks.shift()) callback();
};
module.exports = Pledge;

View File

@@ -0,0 +1,66 @@
'use strict';
var RingBuffer = function(bufferSize) {
this._bufferSize = bufferSize;
this.clear();
};
RingBuffer.prototype.clear = function() {
this._buffer = new Array(this._bufferSize);
this._ringOffset = 0;
this._ringSize = this._bufferSize;
this._head = 0;
this._tail = 0;
this.length = 0;
};
RingBuffer.prototype.push = function(value) {
var expandBuffer = false,
expandRing = false;
if (this._ringSize < this._bufferSize) {
expandBuffer = (this._tail === 0);
} else if (this._ringOffset === this._ringSize) {
expandBuffer = true;
expandRing = (this._tail === 0);
}
if (expandBuffer) {
this._tail = this._bufferSize;
this._buffer = this._buffer.concat(new Array(this._bufferSize));
this._bufferSize = this._buffer.length;
if (expandRing)
this._ringSize = this._bufferSize;
}
this._buffer[this._tail] = value;
this.length += 1;
if (this._tail < this._ringSize) this._ringOffset += 1;
this._tail = (this._tail + 1) % this._bufferSize;
};
RingBuffer.prototype.peek = function() {
if (this.length === 0) return void 0;
return this._buffer[this._head];
};
RingBuffer.prototype.shift = function() {
if (this.length === 0) return void 0;
var value = this._buffer[this._head];
this._buffer[this._head] = void 0;
this.length -= 1;
this._ringOffset -= 1;
if (this._ringOffset === 0 && this.length > 0) {
this._head = this._ringSize;
this._ringOffset = this.length;
this._ringSize = this._bufferSize;
} else {
this._head = (this._head + 1) % this._ringSize;
}
return value;
};
module.exports = RingBuffer;

View File

@@ -0,0 +1,162 @@
'use strict';
var Parser = require('./parser'),
Pipeline = require('./pipeline');
var Extensions = function() {
this._rsv1 = this._rsv2 = this._rsv3 = null;
this._byName = {};
this._inOrder = [];
this._sessions = [];
this._index = {};
};
Extensions.MESSAGE_OPCODES = [1, 2];
var instance = {
add: function(ext) {
if (typeof ext.name !== 'string') throw new TypeError('extension.name must be a string');
if (ext.type !== 'permessage') throw new TypeError('extension.type must be "permessage"');
if (typeof ext.rsv1 !== 'boolean') throw new TypeError('extension.rsv1 must be true or false');
if (typeof ext.rsv2 !== 'boolean') throw new TypeError('extension.rsv2 must be true or false');
if (typeof ext.rsv3 !== 'boolean') throw new TypeError('extension.rsv3 must be true or false');
if (this._byName.hasOwnProperty(ext.name))
throw new TypeError('An extension with name "' + ext.name + '" is already registered');
this._byName[ext.name] = ext;
this._inOrder.push(ext);
},
generateOffer: function() {
var sessions = [],
offer = [],
index = {};
this._inOrder.forEach(function(ext) {
var session = ext.createClientSession();
if (!session) return;
var record = [ext, session];
sessions.push(record);
index[ext.name] = record;
var offers = session.generateOffer();
offers = offers ? [].concat(offers) : [];
offers.forEach(function(off) {
offer.push(Parser.serializeParams(ext.name, off));
}, this);
}, this);
this._sessions = sessions;
this._index = index;
return offer.length > 0 ? offer.join(', ') : null;
},
activate: function(header) {
var responses = Parser.parseHeader(header),
sessions = [];
responses.eachOffer(function(name, params) {
var record = this._index[name];
if (!record)
throw new Error('Server sent an extension response for unknown extension "' + name + '"');
var ext = record[0],
session = record[1],
reserved = this._reserved(ext);
if (reserved)
throw new Error('Server sent two extension responses that use the RSV' +
reserved[0] + ' bit: "' +
reserved[1] + '" and "' + ext.name + '"');
if (session.activate(params) !== true)
throw new Error('Server sent unacceptable extension parameters: ' +
Parser.serializeParams(name, params));
this._reserve(ext);
sessions.push(record);
}, this);
this._sessions = sessions;
this._pipeline = new Pipeline(sessions);
},
generateResponse: function(header) {
var sessions = [],
response = [],
offers = Parser.parseHeader(header);
this._inOrder.forEach(function(ext) {
var offer = offers.byName(ext.name);
if (offer.length === 0 || this._reserved(ext)) return;
var session = ext.createServerSession(offer);
if (!session) return;
this._reserve(ext);
sessions.push([ext, session]);
response.push(Parser.serializeParams(ext.name, session.generateResponse()));
}, this);
this._sessions = sessions;
this._pipeline = new Pipeline(sessions);
return response.length > 0 ? response.join(', ') : null;
},
validFrameRsv: function(frame) {
var allowed = { rsv1: false, rsv2: false, rsv3: false },
ext;
if (Extensions.MESSAGE_OPCODES.indexOf(frame.opcode) >= 0) {
for (var i = 0, n = this._sessions.length; i < n; i++) {
ext = this._sessions[i][0];
allowed.rsv1 = allowed.rsv1 || ext.rsv1;
allowed.rsv2 = allowed.rsv2 || ext.rsv2;
allowed.rsv3 = allowed.rsv3 || ext.rsv3;
}
}
return (allowed.rsv1 || !frame.rsv1) &&
(allowed.rsv2 || !frame.rsv2) &&
(allowed.rsv3 || !frame.rsv3);
},
processIncomingMessage: function(message, callback, context) {
this._pipeline.processIncomingMessage(message, callback, context);
},
processOutgoingMessage: function(message, callback, context) {
this._pipeline.processOutgoingMessage(message, callback, context);
},
close: function(callback, context) {
if (!this._pipeline) return callback.call(context);
this._pipeline.close(callback, context);
},
_reserve: function(ext) {
this._rsv1 = this._rsv1 || (ext.rsv1 && ext.name);
this._rsv2 = this._rsv2 || (ext.rsv2 && ext.name);
this._rsv3 = this._rsv3 || (ext.rsv3 && ext.name);
},
_reserved: function(ext) {
if (this._rsv1 && ext.rsv1) return [1, this._rsv1];
if (this._rsv2 && ext.rsv2) return [2, this._rsv2];
if (this._rsv3 && ext.rsv3) return [3, this._rsv3];
return false;
}
};
for (var key in instance)
Extensions.prototype[key] = instance[key];
module.exports = Extensions;

29
node_modules/websocket-extensions/package.json generated vendored Normal file
View File

@@ -0,0 +1,29 @@
{
"name": "websocket-extensions",
"description": "Generic extension manager for WebSocket connections",
"homepage": "http://github.com/faye/websocket-extensions-node",
"author": "James Coglan <jcoglan@gmail.com> (http://jcoglan.com/)",
"keywords": [
"websocket"
],
"license": "Apache-2.0",
"version": "0.1.4",
"engines": {
"node": ">=0.8.0"
},
"files": [
"lib"
],
"main": "./lib/websocket_extensions",
"devDependencies": {
"jstest": "*"
},
"scripts": {
"test": "jstest spec/runner.js"
},
"repository": {
"type": "git",
"url": "git://github.com/faye/websocket-extensions-node.git"
},
"bugs": "http://github.com/faye/websocket-extensions-node/issues"
}