aboutsummaryrefslogtreecommitdiffhomepage
path: root/node_modules/engine.io-parser
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/engine.io-parser')
-rw-r--r--node_modules/engine.io-parser/History.md177
-rw-r--r--node_modules/engine.io-parser/LICENSE22
-rw-r--r--node_modules/engine.io-parser/Readme.md202
-rw-r--r--node_modules/engine.io-parser/index.js2
-rw-r--r--node_modules/engine.io-parser/lib/browser.js606
-rw-r--r--node_modules/engine.io-parser/lib/index.js480
-rw-r--r--node_modules/engine.io-parser/lib/keys.js19
-rw-r--r--node_modules/engine.io-parser/lib/utf8.js255
-rw-r--r--node_modules/engine.io-parser/package.json101
9 files changed, 1864 insertions, 0 deletions
diff --git a/node_modules/engine.io-parser/History.md b/node_modules/engine.io-parser/History.md
new file mode 100644
index 0000000..a22d0eb
--- /dev/null
+++ b/node_modules/engine.io-parser/History.md
@@ -0,0 +1,177 @@
+
+2.1.1 / 2017-04-27
+==================
+
+ * [chore] Bump has-binary2 to version 1.0.2 (#93)
+
+2.1.0 / 2017-04-24
+==================
+
+ * [chore] Drop support for old nodejs versions (0.10 & 0.12) (#92)
+ * [revert] "[fix] Enable to utf8-decode string payloads (#88)" (#91)
+
+2.0.3 / 2017-04-05
+==================
+
+ * (chore] Use has-binary2 (#90)
+
+2.0.2 / 2017-03-21
+==================
+
+ * [fix] Enable to utf8-decode string payloads (#88)
+
+2.0.1 / 2017-03-06
+==================
+
+ * [fix] Encode string payloads as strings even if binary supported (#85)
+
+2.0.0 / 2016-12-23
+==================
+
+ * [perf] Micro optimisations (#84)
+ * [fix] Sanitize strings by removing lone surrogates (#82)
+ * [perf] Use strict equality where possible (#77)
+ * [style] Minor style changes (#83)
+ * [fix] Fix double utf8 encoding for payloads (#81)
+ * [chore] Update zuul config to speed up tests (#76)
+
+1.3.2 / 2016-12-07
+==================
+
+ * [chore] Bump dependencies (#78)
+
+1.3.1 / 2016-10-20
+==================
+
+ * [fix] Add safety check for global object (#71)
+ * [fix] decodePacket now accepts both Buffer and ArrayBuffer as data (#64)
+ * [fix] Handle undefined case properly when decoding packet (#74)
+ * [chore] Bump zuul to 3.11.0 & zuul-ngrok to 4.0.0 (#70)
+ * [chore] Update zuul browser settings (#73)
+
+1.3.0 / 2016-09-26
+==================
+
+ * [fix] Fix crashes in React Native "navigator is not defined" (#55)
+ * [refactor] Require base64-arraybuffer module conditionally. (#58)
+ * [perf] Split try catch into separate function (#65)
+ * [chore] Use wtf-8 instead of utf8 to prevent lone surrogates from generating parsing error (#68)
+ * [chore] Restrict files included in npm package (#67)
+ * [chore] Update license and repository url (#66)
+ * [chore] Update zuul browser settings following EOL notices (#62)
+ * [chore] bump zuul (#56)
+
+1.2.4 / 2015-12-04
+==================
+
+ * fix `ArrayBuffer` encoding in base64 string
+
+1.2.3 / 2015-11-28
+==================
+
+ * fix encoding blob as base64
+
+1.2.2 / 2015-09-09
+==================
+
+ * fixes for iojs/node
+
+1.2.1 / 2015-01-17
+==================
+
+ * pass has-binary result to encodePacket [rase-]
+ * Fix parse error [rase-]
+
+1.2.0 / 2015-01-11
+==================
+
+ * fix return type for decodePacket
+ * README fixes
+ * use travis matrix for better test runs
+ * encode into binary only if needed
+ * add test cases for base64 object encoding.
+ * add encodeBase64Object to encoder for browser
+ * avoid sending Blobs on PhantomJS (as on Android)
+ * test that utf8 encoding is not on by default but can be switched on manually
+
+1.1.0 / 2014-07-16
+==================
+
+ * make utf8 encoding/decoding optional
+
+1.0.8 / 2014-07-16
+==================
+
+ * adjust protocol revision
+ * handle invalid utf8 errors gracefully
+ * fix memory leak on browser
+
+1.0.7 / 2014-06-24
+==================
+
+ * fix decodePayloadAsBinary memory leak [christophwitzko]
+ * README improvements
+
+1.0.6 / 2014-05-30
+==================
+
+ * utf8 fixes when using binary encoding [nkzawa]
+
+1.0.5 / 2014-05-06
+==================
+
+ * fix range error
+
+1.0.4 / 2014-04-13
+==================
+
+ * fix `encodePayloadAsBinary` method encodes packets to base64
+
+1.0.3 / 2014-04-10
+==================
+
+ * Fix length calculation when encoding as binary [binlain]
+
+1.0.2 / 2014-03-16
+==================
+
+ * fix binary for android due to a bug in Blob XHR2 implementation [Rase-]
+
+1.0.1 / 2014-03-06
+==================
+
+ * implement `blob` module to simplify code
+ * bump `arraybuffer.slice`
+ * style fixes
+
+1.0.0 / 2014-02-18
+==================
+
+ * parser: added binary encoding [Rase-]
+ * parser: switched to an async interface [Rase-]
+
+0.3.0 / 2013-03-16
+==================
+
+ * parser: if callback returns `false` ignore rest of payload
+ * test: fixed all broken tests
+
+0.2.1 / 2013-03-16
+==================
+
+ * added protocol version to index.js [albertyfwu]
+
+0.2.0 / 2013-02-26
+==================
+
+ * Changed `decodePayload` to use a callback instead of returning an array [sweetieSong, albertyfwu]
+
+0.1.1 / 2013-01-26
+==================
+
+ * package.json fixes
+
+0.1.0 / 2013-01-19
+==================
+
+ * Initial release
diff --git a/node_modules/engine.io-parser/LICENSE b/node_modules/engine.io-parser/LICENSE
new file mode 100644
index 0000000..d8fdaec
--- /dev/null
+++ b/node_modules/engine.io-parser/LICENSE
@@ -0,0 +1,22 @@
+(The MIT License)
+
+Copyright (c) 2016 Guillermo Rauch (@rauchg)
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+'Software'), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file
diff --git a/node_modules/engine.io-parser/Readme.md b/node_modules/engine.io-parser/Readme.md
new file mode 100644
index 0000000..02bf538
--- /dev/null
+++ b/node_modules/engine.io-parser/Readme.md
@@ -0,0 +1,202 @@
+
+# engine.io-parser
+
+[![Build Status](https://secure.travis-ci.org/socketio/engine.io-parser.svg)](http://travis-ci.org/socketio/engine.io-parser)
+[![NPM version](https://badge.fury.io/js/engine.io-parser.svg)](http://badge.fury.io/js/engine.io-parser)
+
+This is the JavaScript parser for the engine.io protocol encoding,
+shared by both
+[engine.io-client](https://github.com/socketio/engine.io-client) and
+[engine.io](https://github.com/socketio/engine.io).
+
+## How to use
+
+### Standalone
+
+The parser can encode/decode packets, payloads, and payloads as binary
+with the following methods: `encodePacket`, `decodePacket`, `encodePayload`,
+`decodePayload`, `encodePayloadAsBinary`, `decodePayloadAsBinary`.
+
+The browser-side parser also includes `encodePayloadAsArrayBuffer` and `encodePayloadAsBlob`.
+
+Example:
+
+```js
+var parser = require('engine.io-parser');
+
+var data = new Buffer(5);
+for (var i = 0; i < data.length; i++) { data[i] = i; }
+
+parser.encodePacket({ type: 'message', data: data }, function(encoded) {
+ var decodedData = parser.decodePacket(encoded); // { type: 'message', data: data }
+});
+```
+
+### With browserify
+
+Engine.IO Parser is a commonjs module, which means you can include it by using
+`require` on the browser and package using [browserify](http://browserify.org/):
+
+1. install the parser package
+
+ ```shell
+ npm install engine.io-parser
+ ```
+
+1. write your app code
+
+ ```js
+ var parser = require('engine.io-parser');
+
+ var testBuffer = new Int8Array(10);
+ for (var i = 0; i < testBuffer.length; i++) testBuffer[i] = i;
+
+ var packets = [{ type: 'message', data: testBuffer.buffer }, { type: 'message', data: 'hello' }];
+
+ parser.encodePayload(packets, function(encoded) {
+ parser.decodePayload(encoded,
+ function(packet, index, total) {
+ var isLast = index + 1 == total;
+ if (!isLast) {
+ var buffer = new Int8Array(packet.data); // testBuffer
+ } else {
+ var message = packet.data; // 'hello'
+ }
+ });
+ });
+ ```
+
+1. build your app bundle
+
+ ```bash
+ $ browserify app.js > bundle.js
+ ```
+
+1. include on your page
+
+ ```html
+ <script src="/path/to/bundle.js"></script>
+ ```
+
+## Features
+
+- Runs on browser and node.js seamlessly
+- Runs inside HTML5 WebWorker
+- Can encode and decode packets
+ - Encodes from/to ArrayBuffer or Blob when in browser, and Buffer or ArrayBuffer in Node
+
+## API
+
+Note: `cb(type)` means the type is a callback function that contains a parameter of type `type` when called.
+
+### Node
+
+- `encodePacket`
+ - Encodes a packet.
+ - **Parameters**
+ - `Object`: the packet to encode, has `type` and `data`.
+ - `data`: can be a `String`, `Number`, `Buffer`, `ArrayBuffer`
+ - `Boolean`: optional, binary support
+ - `Function`: callback, returns the encoded packet (`cb(String)`)
+- `decodePacket`
+ - Decodes a packet. Data also available as an ArrayBuffer if requested.
+ - Returns data as `String` or (`Blob` on browser, `ArrayBuffer` on Node)
+ - **Parameters**
+ - `String` | `ArrayBuffer`: the packet to decode, has `type` and `data`
+ - `String`: optional, the binary type
+
+- `encodeBase64Packet`
+ - Encodes a packet with binary data in a base64 string (`String`)
+ - **Parameters**
+ - `Object`: the packet to encode, has `type` and `data`
+ - `Function`: callback, returns the base64 encoded message (`cb(String)`)
+- `decodeBase64Packet`
+ - Decodes a packet encoded in a base64 string.
+ - **Parameters**
+ - `String`: the base64 encoded message
+ - `String`: optional, the binary type
+
+- `encodePayload`
+ - Encodes multiple messages (payload).
+ - If any contents are binary, they will be encoded as base64 strings. Base64
+ encoded strings are marked with a b before the length specifier
+ - **Parameters**
+ - `Array`: an array of packets
+ - `Boolean`: optional, binary support
+ - `Function`: callback, returns the encoded payload (`cb(String)`)
+- `decodePayload`
+ - Decodes data when a payload is maybe expected. Possible binary contents are
+ decoded from their base64 representation.
+ - **Parameters**
+ - `String`: the payload
+ - `String`: optional, the binary type
+ - `Function`: callback, returns (cb(`Object`: packet, `Number`:packet index, `Number`:packet total))
+
+- `encodePayloadAsBinary`
+ - Encodes multiple messages (payload) as binary.
+ - **Parameters**
+ - `Array`: an array of packets
+ - `Function`: callback, returns the encoded payload (`cb(Buffer)`)
+- `decodePayloadAsBinary`
+ - Decodes data when a payload is maybe expected. Strings are decoded by
+ interpreting each byte as a key code for entries marked to start with 0. See
+ description of encodePayloadAsBinary.
+ - **Parameters**
+ - `Buffer`: the buffer
+ - `String`: optional, the binary type
+ - `Function`: callback, returns the decoded packet (`cb(Object)`)
+
+### Browser
+
+- `encodePayloadAsArrayBuffer`
+ - Encodes multiple messages (payload) as binary.
+ - **Parameters**
+ - `Array`: an array of packets
+ - `Function`: callback, returns the encoded payload (`cb(ArrayBuffer)`)
+- `encodePayloadAsBlob`
+ - Encodes multiple messages (payload) as blob.
+ - **Parameters**
+ - `Array`: an array of packets
+ - `Function`: callback, returns the encoded payload (`cb(Blob)`)
+
+## Tests
+
+Standalone tests can be run with `make test` which will run both node.js and browser tests.
+
+Browser tests are run using [zuul](https://github.com/defunctzombie/zuul).
+(You must have zuul setup with a saucelabs account.)
+
+You can run the tests locally using the following command:
+
+```
+./node_modules/.bin/zuul --local 8080 -- test/index.js
+```
+
+## Support
+
+The support channels for `engine.io-parser` are the same as `socket.io`:
+ - irc.freenode.net **#socket.io**
+ - [Google Groups](http://groups.google.com/group/socket_io)
+ - [Website](http://socket.io)
+
+## Development
+
+To contribute patches, run tests or benchmarks, make sure to clone the
+repository:
+
+```bash
+git clone git://github.com/LearnBoost/engine.io-parser.git
+```
+
+Then:
+
+```bash
+cd engine.io-parser
+npm install
+```
+
+See the `Tests` section above for how to run tests before submitting any patches.
+
+## License
+
+MIT
diff --git a/node_modules/engine.io-parser/index.js b/node_modules/engine.io-parser/index.js
new file mode 100644
index 0000000..887727f
--- /dev/null
+++ b/node_modules/engine.io-parser/index.js
@@ -0,0 +1,2 @@
+
+module.exports = require('./lib/');
diff --git a/node_modules/engine.io-parser/lib/browser.js b/node_modules/engine.io-parser/lib/browser.js
new file mode 100644
index 0000000..5a5e506
--- /dev/null
+++ b/node_modules/engine.io-parser/lib/browser.js
@@ -0,0 +1,606 @@
+/**
+ * Module dependencies.
+ */
+
+var keys = require('./keys');
+var hasBinary = require('has-binary2');
+var sliceBuffer = require('arraybuffer.slice');
+var after = require('after');
+var utf8 = require('./utf8');
+
+var base64encoder;
+if (global && global.ArrayBuffer) {
+ base64encoder = require('base64-arraybuffer');
+}
+
+/**
+ * Check if we are running an android browser. That requires us to use
+ * ArrayBuffer with polling transports...
+ *
+ * http://ghinda.net/jpeg-blob-ajax-android/
+ */
+
+var isAndroid = typeof navigator !== 'undefined' && /Android/i.test(navigator.userAgent);
+
+/**
+ * Check if we are running in PhantomJS.
+ * Uploading a Blob with PhantomJS does not work correctly, as reported here:
+ * https://github.com/ariya/phantomjs/issues/11395
+ * @type boolean
+ */
+var isPhantomJS = typeof navigator !== 'undefined' && /PhantomJS/i.test(navigator.userAgent);
+
+/**
+ * When true, avoids using Blobs to encode payloads.
+ * @type boolean
+ */
+var dontSendBlobs = isAndroid || isPhantomJS;
+
+/**
+ * Current protocol version.
+ */
+
+exports.protocol = 3;
+
+/**
+ * Packet types.
+ */
+
+var packets = exports.packets = {
+ open: 0 // non-ws
+ , close: 1 // non-ws
+ , ping: 2
+ , pong: 3
+ , message: 4
+ , upgrade: 5
+ , noop: 6
+};
+
+var packetslist = keys(packets);
+
+/**
+ * Premade error packet.
+ */
+
+var err = { type: 'error', data: 'parser error' };
+
+/**
+ * Create a blob api even for blob builder when vendor prefixes exist
+ */
+
+var Blob = require('blob');
+
+/**
+ * Encodes a packet.
+ *
+ * <packet type id> [ <data> ]
+ *
+ * Example:
+ *
+ * 5hello world
+ * 3
+ * 4
+ *
+ * Binary is encoded in an identical principle
+ *
+ * @api private
+ */
+
+exports.encodePacket = function (packet, supportsBinary, utf8encode, callback) {
+ if (typeof supportsBinary === 'function') {
+ callback = supportsBinary;
+ supportsBinary = false;
+ }
+
+ if (typeof utf8encode === 'function') {
+ callback = utf8encode;
+ utf8encode = null;
+ }
+
+ var data = (packet.data === undefined)
+ ? undefined
+ : packet.data.buffer || packet.data;
+
+ if (global.ArrayBuffer && data instanceof ArrayBuffer) {
+ return encodeArrayBuffer(packet, supportsBinary, callback);
+ } else if (Blob && data instanceof global.Blob) {
+ return encodeBlob(packet, supportsBinary, callback);
+ }
+
+ // might be an object with { base64: true, data: dataAsBase64String }
+ if (data && data.base64) {
+ return encodeBase64Object(packet, callback);
+ }
+
+ // Sending data as a utf-8 string
+ var encoded = packets[packet.type];
+
+ // data fragment is optional
+ if (undefined !== packet.data) {
+ encoded += utf8encode ? utf8.encode(String(packet.data), { strict: false }) : String(packet.data);
+ }
+
+ return callback('' + encoded);
+
+};
+
+function encodeBase64Object(packet, callback) {
+ // packet data is an object { base64: true, data: dataAsBase64String }
+ var message = 'b' + exports.packets[packet.type] + packet.data.data;
+ return callback(message);
+}
+
+/**
+ * Encode packet helpers for binary types
+ */
+
+function encodeArrayBuffer(packet, supportsBinary, callback) {
+ if (!supportsBinary) {
+ return exports.encodeBase64Packet(packet, callback);
+ }
+
+ var data = packet.data;
+ var contentArray = new Uint8Array(data);
+ var resultBuffer = new Uint8Array(1 + data.byteLength);
+
+ resultBuffer[0] = packets[packet.type];
+ for (var i = 0; i < contentArray.length; i++) {
+ resultBuffer[i+1] = contentArray[i];
+ }
+
+ return callback(resultBuffer.buffer);
+}
+
+function encodeBlobAsArrayBuffer(packet, supportsBinary, callback) {
+ if (!supportsBinary) {
+ return exports.encodeBase64Packet(packet, callback);
+ }
+
+ var fr = new FileReader();
+ fr.onload = function() {
+ packet.data = fr.result;
+ exports.encodePacket(packet, supportsBinary, true, callback);
+ };
+ return fr.readAsArrayBuffer(packet.data);
+}
+
+function encodeBlob(packet, supportsBinary, callback) {
+ if (!supportsBinary) {
+ return exports.encodeBase64Packet(packet, callback);
+ }
+
+ if (dontSendBlobs) {
+ return encodeBlobAsArrayBuffer(packet, supportsBinary, callback);
+ }
+
+ var length = new Uint8Array(1);
+ length[0] = packets[packet.type];
+ var blob = new Blob([length.buffer, packet.data]);
+
+ return callback(blob);
+}
+
+/**
+ * Encodes a packet with binary data in a base64 string
+ *
+ * @param {Object} packet, has `type` and `data`
+ * @return {String} base64 encoded message
+ */
+
+exports.encodeBase64Packet = function(packet, callback) {
+ var message = 'b' + exports.packets[packet.type];
+ if (Blob && packet.data instanceof global.Blob) {
+ var fr = new FileReader();
+ fr.onload = function() {
+ var b64 = fr.result.split(',')[1];
+ callback(message + b64);
+ };
+ return fr.readAsDataURL(packet.data);
+ }
+
+ var b64data;
+ try {
+ b64data = String.fromCharCode.apply(null, new Uint8Array(packet.data));
+ } catch (e) {
+ // iPhone Safari doesn't let you apply with typed arrays
+ var typed = new Uint8Array(packet.data);
+ var basic = new Array(typed.length);
+ for (var i = 0; i < typed.length; i++) {
+ basic[i] = typed[i];
+ }
+ b64data = String.fromCharCode.apply(null, basic);
+ }
+ message += global.btoa(b64data);
+ return callback(message);
+};
+
+/**
+ * Decodes a packet. Changes format to Blob if requested.
+ *
+ * @return {Object} with `type` and `data` (if any)
+ * @api private
+ */
+
+exports.decodePacket = function (data, binaryType, utf8decode) {
+ if (data === undefined) {
+ return err;
+ }
+ // String data
+ if (typeof data === 'string') {
+ if (data.charAt(0) === 'b') {
+ return exports.decodeBase64Packet(data.substr(1), binaryType);
+ }
+
+ if (utf8decode) {
+ data = tryDecode(data);
+ if (data === false) {
+ return err;
+ }
+ }
+ var type = data.charAt(0);
+
+ if (Number(type) != type || !packetslist[type]) {
+ return err;
+ }
+
+ if (data.length > 1) {
+ return { type: packetslist[type], data: data.substring(1) };
+ } else {
+ return { type: packetslist[type] };
+ }
+ }
+
+ var asArray = new Uint8Array(data);
+ var type = asArray[0];
+ var rest = sliceBuffer(data, 1);
+ if (Blob && binaryType === 'blob') {
+ rest = new Blob([rest]);
+ }
+ return { type: packetslist[type], data: rest };
+};
+
+function tryDecode(data) {
+ try {
+ data = utf8.decode(data, { strict: false });
+ } catch (e) {
+ return false;
+ }
+ return data;
+}
+
+/**
+ * Decodes a packet encoded in a base64 string
+ *
+ * @param {String} base64 encoded message
+ * @return {Object} with `type` and `data` (if any)
+ */
+
+exports.decodeBase64Packet = function(msg, binaryType) {
+ var type = packetslist[msg.charAt(0)];
+ if (!base64encoder) {
+ return { type: type, data: { base64: true, data: msg.substr(1) } };
+ }
+
+ var data = base64encoder.decode(msg.substr(1));
+
+ if (binaryType === 'blob' && Blob) {
+ data = new Blob([data]);
+ }
+
+ return { type: type, data: data };
+};
+
+/**
+ * Encodes multiple messages (payload).
+ *
+ * <length>:data
+ *
+ * Example:
+ *
+ * 11:hello world2:hi
+ *
+ * If any contents are binary, they will be encoded as base64 strings. Base64
+ * encoded strings are marked with a b before the length specifier
+ *
+ * @param {Array} packets
+ * @api private
+ */
+
+exports.encodePayload = function (packets, supportsBinary, callback) {
+ if (typeof supportsBinary === 'function') {
+ callback = supportsBinary;
+ supportsBinary = null;
+ }
+
+ var isBinary = hasBinary(packets);
+
+ if (supportsBinary && isBinary) {
+ if (Blob && !dontSendBlobs) {
+ return exports.encodePayloadAsBlob(packets, callback);
+ }
+
+ return exports.encodePayloadAsArrayBuffer(packets, callback);
+ }
+
+ if (!packets.length) {
+ return callback('0:');
+ }
+
+ function setLengthHeader(message) {
+ return message.length + ':' + message;
+ }
+
+ function encodeOne(packet, doneCallback) {
+ exports.encodePacket(packet, !isBinary ? false : supportsBinary, false, function(message) {
+ doneCallback(null, setLengthHeader(message));
+ });
+ }
+
+ map(packets, encodeOne, function(err, results) {
+ return callback(results.join(''));
+ });
+};
+
+/**
+ * Async array map using after
+ */
+
+function map(ary, each, done) {
+ var result = new Array(ary.length);
+ var next = after(ary.length, done);
+
+ var eachWithIndex = function(i, el, cb) {
+ each(el, function(error, msg) {
+ result[i] = msg;
+ cb(error, result);
+ });
+ };
+
+ for (var i = 0; i < ary.length; i++) {
+ eachWithIndex(i, ary[i], next);
+ }
+}
+
+/*
+ * Decodes data when a payload is maybe expected. Possible binary contents are
+ * decoded from their base64 representation
+ *
+ * @param {String} data, callback method
+ * @api public
+ */
+
+exports.decodePayload = function (data, binaryType, callback) {
+ if (typeof data !== 'string') {
+ return exports.decodePayloadAsBinary(data, binaryType, callback);
+ }
+
+ if (typeof binaryType === 'function') {
+ callback = binaryType;
+ binaryType = null;
+ }
+
+ var packet;
+ if (data === '') {
+ // parser error - ignoring payload
+ return callback(err, 0, 1);
+ }
+
+ var length = '', n, msg;
+
+ for (var i = 0, l = data.length; i < l; i++) {
+ var chr = data.charAt(i);
+
+ if (chr !== ':') {
+ length += chr;
+ continue;
+ }
+
+ if (length === '' || (length != (n = Number(length)))) {
+ // parser error - ignoring payload
+ return callback(err, 0, 1);
+ }
+
+ msg = data.substr(i + 1, n);
+
+ if (length != msg.length) {
+ // parser error - ignoring payload
+ return callback(err, 0, 1);
+ }
+
+ if (msg.length) {
+ packet = exports.decodePacket(msg, binaryType, false);
+
+ if (err.type === packet.type && err.data === packet.data) {
+ // parser error in individual packet - ignoring payload
+ return callback(err, 0, 1);
+ }
+
+ var ret = callback(packet, i + n, l);
+ if (false === ret) return;
+ }
+
+ // advance cursor
+ i += n;
+ length = '';
+ }
+
+ if (length !== '') {
+ // parser error - ignoring payload
+ return callback(err, 0, 1);
+ }
+
+};
+
+/**
+ * Encodes multiple messages (payload) as binary.
+ *
+ * <1 = binary, 0 = string><number from 0-9><number from 0-9>[...]<number
+ * 255><data>
+ *
+ * Example:
+ * 1 3 255 1 2 3, if the binary contents are interpreted as 8 bit integers
+ *
+ * @param {Array} packets
+ * @return {ArrayBuffer} encoded payload
+ * @api private
+ */
+
+exports.encodePayloadAsArrayBuffer = function(packets, callback) {
+ if (!packets.length) {
+ return callback(new ArrayBuffer(0));
+ }
+
+ function encodeOne(packet, doneCallback) {
+ exports.encodePacket(packet, true, true, function(data) {
+ return doneCallback(null, data);
+ });
+ }
+
+ map(packets, encodeOne, function(err, encodedPackets) {
+ var totalLength = encodedPackets.reduce(function(acc, p) {
+ var len;
+ if (typeof p === 'string'){
+ len = p.length;
+ } else {
+ len = p.byteLength;
+ }
+ return acc + len.toString().length + len + 2; // string/binary identifier + separator = 2
+ }, 0);
+
+ var resultArray = new Uint8Array(totalLength);
+
+ var bufferIndex = 0;
+ encodedPackets.forEach(function(p) {
+ var isString = typeof p === 'string';
+ var ab = p;
+ if (isString) {
+ var view = new Uint8Array(p.length);
+ for (var i = 0; i < p.length; i++) {
+ view[i] = p.charCodeAt(i);
+ }
+ ab = view.buffer;
+ }
+
+ if (isString) { // not true binary
+ resultArray[bufferIndex++] = 0;
+ } else { // true binary
+ resultArray[bufferIndex++] = 1;
+ }
+
+ var lenStr = ab.byteLength.toString();
+ for (var i = 0; i < lenStr.length; i++) {
+ resultArray[bufferIndex++] = parseInt(lenStr[i]);
+ }
+ resultArray[bufferIndex++] = 255;
+
+ var view = new Uint8Array(ab);
+ for (var i = 0; i < view.length; i++) {
+ resultArray[bufferIndex++] = view[i];
+ }
+ });
+
+ return callback(resultArray.buffer);
+ });
+};
+
+/**
+ * Encode as Blob
+ */
+
+exports.encodePayloadAsBlob = function(packets, callback) {
+ function encodeOne(packet, doneCallback) {
+ exports.encodePacket(packet, true, true, function(encoded) {
+ var binaryIdentifier = new Uint8Array(1);
+ binaryIdentifier[0] = 1;
+ if (typeof encoded === 'string') {
+ var view = new Uint8Array(encoded.length);
+ for (var i = 0; i < encoded.length; i++) {
+ view[i] = encoded.charCodeAt(i);
+ }
+ encoded = view.buffer;
+ binaryIdentifier[0] = 0;
+ }
+
+ var len = (encoded instanceof ArrayBuffer)
+ ? encoded.byteLength
+ : encoded.size;
+
+ var lenStr = len.toString();
+ var lengthAry = new Uint8Array(lenStr.length + 1);
+ for (var i = 0; i < lenStr.length; i++) {
+ lengthAry[i] = parseInt(lenStr[i]);
+ }
+ lengthAry[lenStr.length] = 255;
+
+ if (Blob) {
+ var blob = new Blob([binaryIdentifier.buffer, lengthAry.buffer, encoded]);
+ doneCallback(null, blob);
+ }
+ });
+ }
+
+ map(packets, encodeOne, function(err, results) {
+ return callback(new Blob(results));
+ });
+};
+
+/*
+ * Decodes data when a payload is maybe expected. Strings are decoded by
+ * interpreting each byte as a key code for entries marked to start with 0. See
+ * description of encodePayloadAsBinary
+ *
+ * @param {ArrayBuffer} data, callback method
+ * @api public
+ */
+
+exports.decodePayloadAsBinary = function (data, binaryType, callback) {
+ if (typeof binaryType === 'function') {
+ callback = binaryType;
+ binaryType = null;
+ }
+
+ var bufferTail = data;
+ var buffers = [];
+
+ while (bufferTail.byteLength > 0) {
+ var tailArray = new Uint8Array(bufferTail);
+ var isString = tailArray[0] === 0;
+ var msgLength = '';
+
+ for (var i = 1; ; i++) {
+ if (tailArray[i] === 255) break;
+
+ // 310 = char length of Number.MAX_VALUE
+ if (msgLength.length > 310) {
+ return callback(err, 0, 1);
+ }
+
+ msgLength += tailArray[i];
+ }
+
+ bufferTail = sliceBuffer(bufferTail, 2 + msgLength.length);
+ msgLength = parseInt(msgLength);
+
+ var msg = sliceBuffer(bufferTail, 0, msgLength);
+ if (isString) {
+ try {
+ msg = String.fromCharCode.apply(null, new Uint8Array(msg));
+ } catch (e) {
+ // iPhone Safari doesn't let you apply to typed arrays
+ var typed = new Uint8Array(msg);
+ msg = '';
+ for (var i = 0; i < typed.length; i++) {
+ msg += String.fromCharCode(typed[i]);
+ }
+ }
+ }
+
+ buffers.push(msg);
+ bufferTail = sliceBuffer(bufferTail, msgLength);
+ }
+
+ var total = buffers.length;
+ buffers.forEach(function(buffer, i) {
+ callback(exports.decodePacket(buffer, binaryType, true), i, total);
+ });
+};
diff --git a/node_modules/engine.io-parser/lib/index.js b/node_modules/engine.io-parser/lib/index.js
new file mode 100644
index 0000000..c01b0a0
--- /dev/null
+++ b/node_modules/engine.io-parser/lib/index.js
@@ -0,0 +1,480 @@
+/**
+ * Module dependencies.
+ */
+
+var utf8 = require('./utf8');
+var hasBinary = require('has-binary2');
+var after = require('after');
+var keys = require('./keys');
+
+/**
+ * Current protocol version.
+ */
+exports.protocol = 3;
+
+/**
+ * Packet types.
+ */
+
+var packets = exports.packets = {
+ open: 0 // non-ws
+ , close: 1 // non-ws
+ , ping: 2
+ , pong: 3
+ , message: 4
+ , upgrade: 5
+ , noop: 6
+};
+
+var packetslist = keys(packets);
+
+/**
+ * Premade error packet.
+ */
+
+var err = { type: 'error', data: 'parser error' };
+
+/**
+ * Encodes a packet.
+ *
+ * <packet type id> [ <data> ]
+ *
+ * Example:
+ *
+ * 5hello world
+ * 3
+ * 4
+ *
+ * Binary is encoded in an identical principle
+ *
+ * @api private
+ */
+
+exports.encodePacket = function (packet, supportsBinary, utf8encode, callback) {
+ if (typeof supportsBinary === 'function') {
+ callback = supportsBinary;
+ supportsBinary = null;
+ }
+
+ if (typeof utf8encode === 'function') {
+ callback = utf8encode;
+ utf8encode = null;
+ }
+
+ if (Buffer.isBuffer(packet.data)) {
+ return encodeBuffer(packet, supportsBinary, callback);
+ } else if (packet.data && (packet.data.buffer || packet.data) instanceof ArrayBuffer) {
+ packet.data = arrayBufferToBuffer(packet.data);
+ return encodeBuffer(packet, supportsBinary, callback);
+ }
+
+ // Sending data as a utf-8 string
+ var encoded = packets[packet.type];
+
+ // data fragment is optional
+ if (undefined !== packet.data) {
+ encoded += utf8encode ? utf8.encode(String(packet.data), { strict: false }) : String(packet.data);
+ }
+
+ return callback('' + encoded);
+};
+
+/**
+ * Encode Buffer data
+ */
+
+function encodeBuffer(packet, supportsBinary, callback) {
+ if (!supportsBinary) {
+ return exports.encodeBase64Packet(packet, callback);
+ }
+
+ var data = packet.data;
+ var typeBuffer = new Buffer(1);
+ typeBuffer[0] = packets[packet.type];
+ return callback(Buffer.concat([typeBuffer, data]));
+}
+
+/**
+ * Encodes a packet with binary data in a base64 string
+ *
+ * @param {Object} packet, has `type` and `data`
+ * @return {String} base64 encoded message
+ */
+
+exports.encodeBase64Packet = function(packet, callback){
+ if (!Buffer.isBuffer(packet.data)) {
+ packet.data = arrayBufferToBuffer(packet.data);
+ }
+
+ var message = 'b' + packets[packet.type];
+ message += packet.data.toString('base64');
+ return callback(message);
+};
+
+/**
+ * Decodes a packet. Data also available as an ArrayBuffer if requested.
+ *
+ * @return {Object} with `type` and `data` (if any)
+ * @api private
+ */
+
+exports.decodePacket = function (data, binaryType, utf8decode) {
+ if (data === undefined) {
+ return err;
+ }
+
+ var type;
+
+ // String data
+ if (typeof data === 'string') {
+
+ type = data.charAt(0);
+
+ if (type === 'b') {
+ return exports.decodeBase64Packet(data.substr(1), binaryType);
+ }
+
+ if (utf8decode) {
+ data = tryDecode(data);
+ if (data === false) {
+ return err;
+ }
+ }
+
+ if (Number(type) != type || !packetslist[type]) {
+ return err;
+ }
+
+ if (data.length > 1) {
+ return { type: packetslist[type], data: data.substring(1) };
+ } else {
+ return { type: packetslist[type] };
+ }
+ }
+
+ // Binary data
+ if (binaryType === 'arraybuffer') {
+ // wrap Buffer/ArrayBuffer data into an Uint8Array
+ var intArray = new Uint8Array(data);
+ type = intArray[0];
+ return { type: packetslist[type], data: intArray.buffer.slice(1) };
+ }
+
+ if (data instanceof ArrayBuffer) {
+ data = arrayBufferToBuffer(data);
+ }
+ type = data[0];
+ return { type: packetslist[type], data: data.slice(1) };
+};
+
+function tryDecode(data) {
+ try {
+ data = utf8.decode(data, { strict: false });
+ } catch (e) {
+ return false;
+ }
+ return data;
+}
+
+/**
+ * Decodes a packet encoded in a base64 string.
+ *
+ * @param {String} base64 encoded message
+ * @return {Object} with `type` and `data` (if any)
+ */
+
+exports.decodeBase64Packet = function(msg, binaryType) {
+ var type = packetslist[msg.charAt(0)];
+ var data = new Buffer(msg.substr(1), 'base64');
+ if (binaryType === 'arraybuffer') {
+ var abv = new Uint8Array(data.length);
+ for (var i = 0; i < abv.length; i++){
+ abv[i] = data[i];
+ }
+ data = abv.buffer;
+ }
+ return { type: type, data: data };
+};
+
+/**
+ * Encodes multiple messages (payload).
+ *
+ * <length>:data
+ *
+ * Example:
+ *
+ * 11:hello world2:hi
+ *
+ * If any contents are binary, they will be encoded as base64 strings. Base64
+ * encoded strings are marked with a b before the length specifier
+ *
+ * @param {Array} packets
+ * @api private
+ */
+
+exports.encodePayload = function (packets, supportsBinary, callback) {
+ if (typeof supportsBinary === 'function') {
+ callback = supportsBinary;
+ supportsBinary = null;
+ }
+
+ if (supportsBinary && hasBinary(packets)) {
+ return exports.encodePayloadAsBinary(packets, callback);
+ }
+
+ if (!packets.length) {
+ return callback('0:');
+ }
+
+ function encodeOne(packet, doneCallback) {
+ exports.encodePacket(packet, supportsBinary, false, function(message) {
+ doneCallback(null, setLengthHeader(message));
+ });
+ }
+
+ map(packets, encodeOne, function(err, results) {
+ return callback(results.join(''));
+ });
+};
+
+function setLengthHeader(message) {
+ return message.length + ':' + message;
+}
+
+/**
+ * Async array map using after
+ */
+
+function map(ary, each, done) {
+ var result = new Array(ary.length);
+ var next = after(ary.length, done);
+
+ for (var i = 0; i < ary.length; i++) {
+ each(ary[i], function(error, msg) {
+ result[i] = msg;
+ next(error, result);
+ });
+ }
+}
+
+/*
+ * Decodes data when a payload is maybe expected. Possible binary contents are
+ * decoded from their base64 representation
+ *
+ * @param {String} data, callback method
+ * @api public
+ */
+
+exports.decodePayload = function (data, binaryType, callback) {
+ if (typeof data !== 'string') {
+ return exports.decodePayloadAsBinary(data, binaryType, callback);
+ }
+
+ if (typeof binaryType === 'function') {
+ callback = binaryType;
+ binaryType = null;
+ }
+
+ if (data === '') {
+ // parser error - ignoring payload
+ return callback(err, 0, 1);
+ }
+
+ var length = '', n, msg, packet;
+
+ for (var i = 0, l = data.length; i < l; i++) {
+ var chr = data.charAt(i);
+
+ if (chr !== ':') {
+ length += chr;
+ continue;
+ }
+
+ if (length === '' || (length != (n = Number(length)))) {
+ // parser error - ignoring payload
+ return callback(err, 0, 1);
+ }
+
+ msg = data.substr(i + 1, n);
+
+ if (length != msg.length) {
+ // parser error - ignoring payload
+ return callback(err, 0, 1);
+ }
+
+ if (msg.length) {
+ packet = exports.decodePacket(msg, binaryType, false);
+
+ if (err.type === packet.type && err.data === packet.data) {
+ // parser error in individual packet - ignoring payload
+ return callback(err, 0, 1);
+ }
+
+ var more = callback(packet, i + n, l);
+ if (false === more) return;
+ }
+
+ // advance cursor
+ i += n;
+ length = '';
+ }
+
+ if (length !== '') {
+ // parser error - ignoring payload
+ return callback(err, 0, 1);
+ }
+
+};
+
+/**
+ *
+ * Converts a buffer to a utf8.js encoded string
+ *
+ * @api private
+ */
+
+function bufferToString(buffer) {
+ var str = '';
+ for (var i = 0, l = buffer.length; i < l; i++) {
+ str += String.fromCharCode(buffer[i]);
+ }
+ return str;
+}
+
+/**
+ *
+ * Converts a utf8.js encoded string to a buffer
+ *
+ * @api private
+ */
+
+function stringToBuffer(string) {
+ var buf = new Buffer(string.length);
+ for (var i = 0, l = string.length; i < l; i++) {
+ buf.writeUInt8(string.charCodeAt(i), i);
+ }
+ return buf;
+}
+
+/**
+ *
+ * Converts an ArrayBuffer to a Buffer
+ *
+ * @api private
+ */
+
+function arrayBufferToBuffer(data) {
+ // data is either an ArrayBuffer or ArrayBufferView.
+ var array = new Uint8Array(data.buffer || data);
+ var length = data.byteLength || data.length;
+ var offset = data.byteOffset || 0;
+ var buffer = new Buffer(length);
+
+ for (var i = 0; i < length; i++) {
+ buffer[i] = array[offset + i];
+ }
+ return buffer;
+}
+
+/**
+ * Encodes multiple messages (payload) as binary.
+ *
+ * <1 = binary, 0 = string><number from 0-9><number from 0-9>[...]<number
+ * 255><data>
+ *
+ * Example:
+ * 1 3 255 1 2 3, if the binary contents are interpreted as 8 bit integers
+ *
+ * @param {Array} packets
+ * @return {Buffer} encoded payload
+ * @api private
+ */
+
+exports.encodePayloadAsBinary = function (packets, callback) {
+ if (!packets.length) {
+ return callback(new Buffer(0));
+ }
+
+ map(packets, encodeOneBinaryPacket, function(err, results) {
+ return callback(Buffer.concat(results));
+ });
+};
+
+function encodeOneBinaryPacket(p, doneCallback) {
+
+ function onBinaryPacketEncode(packet) {
+
+ var encodingLength = '' + packet.length;
+ var sizeBuffer;
+
+ if (typeof packet === 'string') {
+ sizeBuffer = new Buffer(encodingLength.length + 2);
+ sizeBuffer[0] = 0; // is a string (not true binary = 0)
+ for (var i = 0; i < encodingLength.length; i++) {
+ sizeBuffer[i + 1] = parseInt(encodingLength[i], 10);
+ }
+ sizeBuffer[sizeBuffer.length - 1] = 255;
+ return doneCallback(null, Buffer.concat([sizeBuffer, stringToBuffer(packet)]));
+ }
+
+ sizeBuffer = new Buffer(encodingLength.length + 2);
+ sizeBuffer[0] = 1; // is binary (true binary = 1)
+ for (var i = 0; i < encodingLength.length; i++) {
+ sizeBuffer[i + 1] = parseInt(encodingLength[i], 10);
+ }
+ sizeBuffer[sizeBuffer.length - 1] = 255;
+
+ doneCallback(null, Buffer.concat([sizeBuffer, packet]));
+ }
+
+ exports.encodePacket(p, true, true, onBinaryPacketEncode);
+
+}
+
+
+/*
+ * Decodes data when a payload is maybe expected. Strings are decoded by
+ * interpreting each byte as a key code for entries marked to start with 0. See
+ * description of encodePayloadAsBinary
+
+ * @param {Buffer} data, callback method
+ * @api public
+ */
+
+exports.decodePayloadAsBinary = function (data, binaryType, callback) {
+ if (typeof binaryType === 'function') {
+ callback = binaryType;
+ binaryType = null;
+ }
+
+ var bufferTail = data;
+ var buffers = [];
+ var i;
+
+ while (bufferTail.length > 0) {
+ var strLen = '';
+ var isString = bufferTail[0] === 0;
+ for (i = 1; ; i++) {
+ if (bufferTail[i] === 255) break;
+ // 310 = char length of Number.MAX_VALUE
+ if (strLen.length > 310) {
+ return callback(err, 0, 1);
+ }
+ strLen += '' + bufferTail[i];
+ }
+ bufferTail = bufferTail.slice(strLen.length + 1);
+
+ var msgLength = parseInt(strLen, 10);
+
+ var msg = bufferTail.slice(1, msgLength + 1);
+ if (isString) msg = bufferToString(msg);
+ buffers.push(msg);
+ bufferTail = bufferTail.slice(msgLength + 1);
+ }
+
+ var total = buffers.length;
+ for (i = 0; i < total; i++) {
+ var buffer = buffers[i];
+ callback(exports.decodePacket(buffer, binaryType, true), i, total);
+ }
+};
diff --git a/node_modules/engine.io-parser/lib/keys.js b/node_modules/engine.io-parser/lib/keys.js
new file mode 100644
index 0000000..947dafd
--- /dev/null
+++ b/node_modules/engine.io-parser/lib/keys.js
@@ -0,0 +1,19 @@
+
+/**
+ * Gets the keys for an object.
+ *
+ * @return {Array} keys
+ * @api private
+ */
+
+module.exports = Object.keys || function keys (obj){
+ var arr = [];
+ var has = Object.prototype.hasOwnProperty;
+
+ for (var i in obj) {
+ if (has.call(obj, i)) {
+ arr.push(i);
+ }
+ }
+ return arr;
+};
diff --git a/node_modules/engine.io-parser/lib/utf8.js b/node_modules/engine.io-parser/lib/utf8.js
new file mode 100644
index 0000000..83e2dd7
--- /dev/null
+++ b/node_modules/engine.io-parser/lib/utf8.js
@@ -0,0 +1,255 @@
+/*! https://mths.be/utf8js v2.1.2 by @mathias */
+;(function(root) {
+
+ // Detect free variables `exports`
+ var freeExports = typeof exports == 'object' && exports;
+
+ // Detect free variable `module`
+ var freeModule = typeof module == 'object' && module &&
+ module.exports == freeExports && module;
+
+ // Detect free variable `global`, from Node.js or Browserified code,
+ // and use it as `root`
+ var freeGlobal = typeof global == 'object' && global;
+ if (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal) {
+ root = freeGlobal;
+ }
+
+ /*--------------------------------------------------------------------------*/
+
+ var stringFromCharCode = String.fromCharCode;
+
+ // Taken from https://mths.be/punycode
+ function ucs2decode(string) {
+ var output = [];
+ var counter = 0;
+ var length = string.length;
+ var value;
+ var extra;
+ while (counter < length) {
+ value = string.charCodeAt(counter++);
+ if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
+ // high surrogate, and there is a next character
+ extra = string.charCodeAt(counter++);
+ if ((extra & 0xFC00) == 0xDC00) { // low surrogate
+ output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
+ } else {
+ // unmatched surrogate; only append this code unit, in case the next
+ // code unit is the high surrogate of a surrogate pair
+ output.push(value);
+ counter--;
+ }
+ } else {
+ output.push(value);
+ }
+ }
+ return output;
+ }
+
+ // Taken from https://mths.be/punycode
+ function ucs2encode(array) {
+ var length = array.length;
+ var index = -1;
+ var value;
+ var output = '';
+ while (++index < length) {
+ value = array[index];
+ if (value > 0xFFFF) {
+ value -= 0x10000;
+ output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800);
+ value = 0xDC00 | value & 0x3FF;
+ }
+ output += stringFromCharCode(value);
+ }
+ return output;
+ }
+
+ function checkScalarValue(codePoint, strict) {
+ if (codePoint >= 0xD800 && codePoint <= 0xDFFF) {
+ if (strict) {
+ throw Error(
+ 'Lone surrogate U+' + codePoint.toString(16).toUpperCase() +
+ ' is not a scalar value'
+ );
+ }
+ return false;
+ }
+ return true;
+ }
+ /*--------------------------------------------------------------------------*/
+
+ function createByte(codePoint, shift) {
+ return stringFromCharCode(((codePoint >> shift) & 0x3F) | 0x80);
+ }
+
+ function encodeCodePoint(codePoint, strict) {
+ if ((codePoint & 0xFFFFFF80) == 0) { // 1-byte sequence
+ return stringFromCharCode(codePoint);
+ }
+ var symbol = '';
+ if ((codePoint & 0xFFFFF800) == 0) { // 2-byte sequence
+ symbol = stringFromCharCode(((codePoint >> 6) & 0x1F) | 0xC0);
+ }
+ else if ((codePoint & 0xFFFF0000) == 0) { // 3-byte sequence
+ if (!checkScalarValue(codePoint, strict)) {
+ codePoint = 0xFFFD;
+ }
+ symbol = stringFromCharCode(((codePoint >> 12) & 0x0F) | 0xE0);
+ symbol += createByte(codePoint, 6);
+ }
+ else if ((codePoint & 0xFFE00000) == 0) { // 4-byte sequence
+ symbol = stringFromCharCode(((codePoint >> 18) & 0x07) | 0xF0);
+ symbol += createByte(codePoint, 12);
+ symbol += createByte(codePoint, 6);
+ }
+ symbol += stringFromCharCode((codePoint & 0x3F) | 0x80);
+ return symbol;
+ }
+
+ function utf8encode(string, opts) {
+ opts = opts || {};
+ var strict = false !== opts.strict;
+
+ var codePoints = ucs2decode(string);
+ var length = codePoints.length;
+ var index = -1;
+ var codePoint;
+ var byteString = '';
+ while (++index < length) {
+ codePoint = codePoints[index];
+ byteString += encodeCodePoint(codePoint, strict);
+ }
+ return byteString;
+ }
+
+ /*--------------------------------------------------------------------------*/
+
+ function readContinuationByte() {
+ if (byteIndex >= byteCount) {
+ throw Error('Invalid byte index');
+ }
+
+ var continuationByte = byteArray[byteIndex] & 0xFF;
+ byteIndex++;
+
+ if ((continuationByte & 0xC0) == 0x80) {
+ return continuationByte & 0x3F;
+ }
+
+ // If we end up here, it’s not a continuation byte
+ throw Error('Invalid continuation byte');
+ }
+
+ function decodeSymbol(strict) {
+ var byte1;
+ var byte2;
+ var byte3;
+ var byte4;
+ var codePoint;
+
+ if (byteIndex > byteCount) {
+ throw Error('Invalid byte index');
+ }
+
+ if (byteIndex == byteCount) {
+ return false;
+ }
+
+ // Read first byte
+ byte1 = byteArray[byteIndex] & 0xFF;
+ byteIndex++;
+
+ // 1-byte sequence (no continuation bytes)
+ if ((byte1 & 0x80) == 0) {
+ return byte1;
+ }
+
+ // 2-byte sequence
+ if ((byte1 & 0xE0) == 0xC0) {
+ byte2 = readContinuationByte();
+ codePoint = ((byte1 & 0x1F) << 6) | byte2;
+ if (codePoint >= 0x80) {
+ return codePoint;
+ } else {
+ throw Error('Invalid continuation byte');
+ }
+ }
+
+ // 3-byte sequence (may include unpaired surrogates)
+ if ((byte1 & 0xF0) == 0xE0) {
+ byte2 = readContinuationByte();
+ byte3 = readContinuationByte();
+ codePoint = ((byte1 & 0x0F) << 12) | (byte2 << 6) | byte3;
+ if (codePoint >= 0x0800) {
+ return checkScalarValue(codePoint, strict) ? codePoint : 0xFFFD;
+ } else {
+ throw Error('Invalid continuation byte');
+ }
+ }
+
+ // 4-byte sequence
+ if ((byte1 & 0xF8) == 0xF0) {
+ byte2 = readContinuationByte();
+ byte3 = readContinuationByte();
+ byte4 = readContinuationByte();
+ codePoint = ((byte1 & 0x07) << 0x12) | (byte2 << 0x0C) |
+ (byte3 << 0x06) | byte4;
+ if (codePoint >= 0x010000 && codePoint <= 0x10FFFF) {
+ return codePoint;
+ }
+ }
+
+ throw Error('Invalid UTF-8 detected');
+ }
+
+ var byteArray;
+ var byteCount;
+ var byteIndex;
+ function utf8decode(byteString, opts) {
+ opts = opts || {};
+ var strict = false !== opts.strict;
+
+ byteArray = ucs2decode(byteString);
+ byteCount = byteArray.length;
+ byteIndex = 0;
+ var codePoints = [];
+ var tmp;
+ while ((tmp = decodeSymbol(strict)) !== false) {
+ codePoints.push(tmp);
+ }
+ return ucs2encode(codePoints);
+ }
+
+ /*--------------------------------------------------------------------------*/
+
+ var utf8 = {
+ 'version': '2.1.2',
+ 'encode': utf8encode,
+ 'decode': utf8decode
+ };
+
+ // Some AMD build optimizers, like r.js, check for specific condition patterns
+ // like the following:
+ if (
+ typeof define == 'function' &&
+ typeof define.amd == 'object' &&
+ define.amd
+ ) {
+ define(function() {
+ return utf8;
+ });
+ } else if (freeExports && !freeExports.nodeType) {
+ if (freeModule) { // in Node.js or RingoJS v0.8.0+
+ freeModule.exports = utf8;
+ } else { // in Narwhal or RingoJS v0.7.0-
+ var object = {};
+ var hasOwnProperty = object.hasOwnProperty;
+ for (var key in utf8) {
+ hasOwnProperty.call(utf8, key) && (freeExports[key] = utf8[key]);
+ }
+ }
+ } else { // in Rhino or a web browser
+ root.utf8 = utf8;
+ }
+
+}(this));
diff --git a/node_modules/engine.io-parser/package.json b/node_modules/engine.io-parser/package.json
new file mode 100644
index 0000000..1f9e9aa
--- /dev/null
+++ b/node_modules/engine.io-parser/package.json
@@ -0,0 +1,101 @@
+{
+ "_args": [
+ [
+ {
+ "raw": "engine.io-parser@~2.1.0",
+ "scope": null,
+ "escapedName": "engine.io-parser",
+ "name": "engine.io-parser",
+ "rawSpec": "~2.1.0",
+ "spec": ">=2.1.0 <2.2.0",
+ "type": "range"
+ },
+ "/mnt/e/Yaroslav/Documents/Webs/nodejs/checkers/node_modules/engine.io"
+ ]
+ ],
+ "_from": "engine.io-parser@>=2.1.0 <2.2.0",
+ "_id": "engine.io-parser@2.1.1",
+ "_inCache": true,
+ "_location": "/engine.io-parser",
+ "_nodeVersion": "6.9.4",
+ "_npmOperationalInternal": {
+ "host": "packages-12-west.internal.npmjs.com",
+ "tmp": "tmp/engine.io-parser-2.1.1.tgz_1493327149955_0.6413915157318115"
+ },
+ "_npmUser": {
+ "name": "darrachequesne",
+ "email": "damien.arrachequesne@gmail.com"
+ },
+ "_npmVersion": "3.10.10",
+ "_phantomChildren": {},
+ "_requested": {
+ "raw": "engine.io-parser@~2.1.0",
+ "scope": null,
+ "escapedName": "engine.io-parser",
+ "name": "engine.io-parser",
+ "rawSpec": "~2.1.0",
+ "spec": ">=2.1.0 <2.2.0",
+ "type": "range"
+ },
+ "_requiredBy": [
+ "/engine.io",
+ "/engine.io-client"
+ ],
+ "_resolved": "https://registry.npmjs.org/engine.io-parser/-/engine.io-parser-2.1.1.tgz",
+ "_shasum": "e0fb3f0e0462f7f58bb77c1a52e9f5a7e26e4668",
+ "_shrinkwrap": null,
+ "_spec": "engine.io-parser@~2.1.0",
+ "_where": "/mnt/e/Yaroslav/Documents/Webs/nodejs/checkers/node_modules/engine.io",
+ "browser": "./lib/browser.js",
+ "bugs": {
+ "url": "https://github.com/socketio/engine.io-parser/issues"
+ },
+ "dependencies": {
+ "after": "0.8.2",
+ "arraybuffer.slice": "0.0.6",
+ "base64-arraybuffer": "0.1.5",
+ "blob": "0.0.4",
+ "has-binary2": "~1.0.2"
+ },
+ "description": "Parser for the client for the realtime Engine",
+ "devDependencies": {
+ "expect.js": "0.3.1",
+ "mocha": "3.2.0",
+ "socket.io-browsers": "^1.0.0",
+ "zuul": "3.11.1",
+ "zuul-ngrok": "4.0.0"
+ },
+ "directories": {},
+ "dist": {
+ "shasum": "e0fb3f0e0462f7f58bb77c1a52e9f5a7e26e4668",
+ "tarball": "https://registry.npmjs.org/engine.io-parser/-/engine.io-parser-2.1.1.tgz"
+ },
+ "files": [
+ "index.js",
+ "lib/"
+ ],
+ "gitHead": "e2422c300e96766c951fdf2432e992c29fc12f1a",
+ "homepage": "https://github.com/socketio/engine.io-parser",
+ "license": "MIT",
+ "maintainers": [
+ {
+ "name": "darrachequesne",
+ "email": "damien.arrachequesne@gmail.com"
+ },
+ {
+ "name": "rauchg",
+ "email": "rauchg@gmail.com"
+ }
+ ],
+ "name": "engine.io-parser",
+ "optionalDependencies": {},
+ "readme": "ERROR: No README data found!",
+ "repository": {
+ "type": "git",
+ "url": "git+ssh://git@github.com/socketio/engine.io-parser.git"
+ },
+ "scripts": {
+ "test": "make test"
+ },
+ "version": "2.1.1"
+}