Init. Map does not function and only working on backend at the moment.
This commit is contained in:
15
node_modules/socketio/demo.js
generated
vendored
Normal file
15
node_modules/socketio/demo.js
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
var express = require('express');
|
||||
var app = express();
|
||||
|
||||
app.get('/', function (req, res) {
|
||||
res.send('Hello World');
|
||||
})
|
||||
|
||||
var server = app.listen(8081, function () {
|
||||
|
||||
var host = server.address().address
|
||||
var port = server.address().port
|
||||
|
||||
console.log("http://%s:%s", host, port)
|
||||
|
||||
})
|
0
node_modules/socketio/demo.js~
generated
vendored
Normal file
0
node_modules/socketio/demo.js~
generated
vendored
Normal file
15
node_modules/socketio/index.js
generated
vendored
Normal file
15
node_modules/socketio/index.js
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
var app = require('express')();
|
||||
var http = require('http').Server(app);
|
||||
var io = require('socket.io')(http);
|
||||
|
||||
app.get('/', function(req, res){
|
||||
res.sendfile('index.html');
|
||||
});
|
||||
|
||||
io.on('connection', function(socket){
|
||||
console.log('a user connected');
|
||||
});
|
||||
|
||||
http.listen(3000, function(){
|
||||
console.log('listening on *:3000');
|
||||
});
|
0
node_modules/socketio/index.js~
generated
vendored
Normal file
0
node_modules/socketio/index.js~
generated
vendored
Normal file
212
node_modules/socketio/node_modules/accepts/HISTORY.md
generated
vendored
Normal file
212
node_modules/socketio/node_modules/accepts/HISTORY.md
generated
vendored
Normal file
@ -0,0 +1,212 @@
|
||||
1.3.3 / 2016-05-02
|
||||
==================
|
||||
|
||||
* deps: mime-types@~2.1.11
|
||||
- deps: mime-db@~1.23.0
|
||||
* deps: negotiator@0.6.1
|
||||
- perf: improve `Accept` parsing speed
|
||||
- perf: improve `Accept-Charset` parsing speed
|
||||
- perf: improve `Accept-Encoding` parsing speed
|
||||
- perf: improve `Accept-Language` parsing speed
|
||||
|
||||
1.3.2 / 2016-03-08
|
||||
==================
|
||||
|
||||
* deps: mime-types@~2.1.10
|
||||
- Fix extension of `application/dash+xml`
|
||||
- Update primary extension for `audio/mp4`
|
||||
- deps: mime-db@~1.22.0
|
||||
|
||||
1.3.1 / 2016-01-19
|
||||
==================
|
||||
|
||||
* deps: mime-types@~2.1.9
|
||||
- deps: mime-db@~1.21.0
|
||||
|
||||
1.3.0 / 2015-09-29
|
||||
==================
|
||||
|
||||
* deps: mime-types@~2.1.7
|
||||
- deps: mime-db@~1.19.0
|
||||
* deps: negotiator@0.6.0
|
||||
- Fix including type extensions in parameters in `Accept` parsing
|
||||
- Fix parsing `Accept` parameters with quoted equals
|
||||
- Fix parsing `Accept` parameters with quoted semicolons
|
||||
- Lazy-load modules from main entry point
|
||||
- perf: delay type concatenation until needed
|
||||
- perf: enable strict mode
|
||||
- perf: hoist regular expressions
|
||||
- perf: remove closures getting spec properties
|
||||
- perf: remove a closure from media type parsing
|
||||
- perf: remove property delete from media type parsing
|
||||
|
||||
1.2.13 / 2015-09-06
|
||||
===================
|
||||
|
||||
* deps: mime-types@~2.1.6
|
||||
- deps: mime-db@~1.18.0
|
||||
|
||||
1.2.12 / 2015-07-30
|
||||
===================
|
||||
|
||||
* deps: mime-types@~2.1.4
|
||||
- deps: mime-db@~1.16.0
|
||||
|
||||
1.2.11 / 2015-07-16
|
||||
===================
|
||||
|
||||
* deps: mime-types@~2.1.3
|
||||
- deps: mime-db@~1.15.0
|
||||
|
||||
1.2.10 / 2015-07-01
|
||||
===================
|
||||
|
||||
* deps: mime-types@~2.1.2
|
||||
- deps: mime-db@~1.14.0
|
||||
|
||||
1.2.9 / 2015-06-08
|
||||
==================
|
||||
|
||||
* deps: mime-types@~2.1.1
|
||||
- perf: fix deopt during mapping
|
||||
|
||||
1.2.8 / 2015-06-07
|
||||
==================
|
||||
|
||||
* deps: mime-types@~2.1.0
|
||||
- deps: mime-db@~1.13.0
|
||||
* perf: avoid argument reassignment & argument slice
|
||||
* perf: avoid negotiator recursive construction
|
||||
* perf: enable strict mode
|
||||
* perf: remove unnecessary bitwise operator
|
||||
|
||||
1.2.7 / 2015-05-10
|
||||
==================
|
||||
|
||||
* deps: negotiator@0.5.3
|
||||
- Fix media type parameter matching to be case-insensitive
|
||||
|
||||
1.2.6 / 2015-05-07
|
||||
==================
|
||||
|
||||
* deps: mime-types@~2.0.11
|
||||
- deps: mime-db@~1.9.1
|
||||
* deps: negotiator@0.5.2
|
||||
- Fix comparing media types with quoted values
|
||||
- Fix splitting media types with quoted commas
|
||||
|
||||
1.2.5 / 2015-03-13
|
||||
==================
|
||||
|
||||
* deps: mime-types@~2.0.10
|
||||
- deps: mime-db@~1.8.0
|
||||
|
||||
1.2.4 / 2015-02-14
|
||||
==================
|
||||
|
||||
* Support Node.js 0.6
|
||||
* deps: mime-types@~2.0.9
|
||||
- deps: mime-db@~1.7.0
|
||||
* deps: negotiator@0.5.1
|
||||
- Fix preference sorting to be stable for long acceptable lists
|
||||
|
||||
1.2.3 / 2015-01-31
|
||||
==================
|
||||
|
||||
* deps: mime-types@~2.0.8
|
||||
- deps: mime-db@~1.6.0
|
||||
|
||||
1.2.2 / 2014-12-30
|
||||
==================
|
||||
|
||||
* deps: mime-types@~2.0.7
|
||||
- deps: mime-db@~1.5.0
|
||||
|
||||
1.2.1 / 2014-12-30
|
||||
==================
|
||||
|
||||
* deps: mime-types@~2.0.5
|
||||
- deps: mime-db@~1.3.1
|
||||
|
||||
1.2.0 / 2014-12-19
|
||||
==================
|
||||
|
||||
* deps: negotiator@0.5.0
|
||||
- Fix list return order when large accepted list
|
||||
- Fix missing identity encoding when q=0 exists
|
||||
- Remove dynamic building of Negotiator class
|
||||
|
||||
1.1.4 / 2014-12-10
|
||||
==================
|
||||
|
||||
* deps: mime-types@~2.0.4
|
||||
- deps: mime-db@~1.3.0
|
||||
|
||||
1.1.3 / 2014-11-09
|
||||
==================
|
||||
|
||||
* deps: mime-types@~2.0.3
|
||||
- deps: mime-db@~1.2.0
|
||||
|
||||
1.1.2 / 2014-10-14
|
||||
==================
|
||||
|
||||
* deps: negotiator@0.4.9
|
||||
- Fix error when media type has invalid parameter
|
||||
|
||||
1.1.1 / 2014-09-28
|
||||
==================
|
||||
|
||||
* deps: mime-types@~2.0.2
|
||||
- deps: mime-db@~1.1.0
|
||||
* deps: negotiator@0.4.8
|
||||
- Fix all negotiations to be case-insensitive
|
||||
- Stable sort preferences of same quality according to client order
|
||||
|
||||
1.1.0 / 2014-09-02
|
||||
==================
|
||||
|
||||
* update `mime-types`
|
||||
|
||||
1.0.7 / 2014-07-04
|
||||
==================
|
||||
|
||||
* Fix wrong type returned from `type` when match after unknown extension
|
||||
|
||||
1.0.6 / 2014-06-24
|
||||
==================
|
||||
|
||||
* deps: negotiator@0.4.7
|
||||
|
||||
1.0.5 / 2014-06-20
|
||||
==================
|
||||
|
||||
* fix crash when unknown extension given
|
||||
|
||||
1.0.4 / 2014-06-19
|
||||
==================
|
||||
|
||||
* use `mime-types`
|
||||
|
||||
1.0.3 / 2014-06-11
|
||||
==================
|
||||
|
||||
* deps: negotiator@0.4.6
|
||||
- Order by specificity when quality is the same
|
||||
|
||||
1.0.2 / 2014-05-29
|
||||
==================
|
||||
|
||||
* Fix interpretation when header not in request
|
||||
* deps: pin negotiator@0.4.5
|
||||
|
||||
1.0.1 / 2014-01-18
|
||||
==================
|
||||
|
||||
* Identity encoding isn't always acceptable
|
||||
* deps: negotiator@~0.4.0
|
||||
|
||||
1.0.0 / 2013-12-27
|
||||
==================
|
||||
|
||||
* Genesis
|
23
node_modules/socketio/node_modules/accepts/LICENSE
generated
vendored
Normal file
23
node_modules/socketio/node_modules/accepts/LICENSE
generated
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2014 Jonathan Ong <me@jongleberry.com>
|
||||
Copyright (c) 2015 Douglas Christopher Wilson <doug@somethingdoug.com>
|
||||
|
||||
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.
|
135
node_modules/socketio/node_modules/accepts/README.md
generated
vendored
Normal file
135
node_modules/socketio/node_modules/accepts/README.md
generated
vendored
Normal file
@ -0,0 +1,135 @@
|
||||
# accepts
|
||||
|
||||
[![NPM Version][npm-image]][npm-url]
|
||||
[![NPM Downloads][downloads-image]][downloads-url]
|
||||
[![Node.js Version][node-version-image]][node-version-url]
|
||||
[![Build Status][travis-image]][travis-url]
|
||||
[![Test Coverage][coveralls-image]][coveralls-url]
|
||||
|
||||
Higher level content negotiation based on [negotiator](https://www.npmjs.com/package/negotiator). Extracted from [koa](https://www.npmjs.com/package/koa) for general use.
|
||||
|
||||
In addition to negotiator, it allows:
|
||||
|
||||
- Allows types as an array or arguments list, ie `(['text/html', 'application/json'])` as well as `('text/html', 'application/json')`.
|
||||
- Allows type shorthands such as `json`.
|
||||
- Returns `false` when no types match
|
||||
- Treats non-existent headers as `*`
|
||||
|
||||
## Installation
|
||||
|
||||
```sh
|
||||
npm install accepts
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
```js
|
||||
var accepts = require('accepts')
|
||||
```
|
||||
|
||||
### accepts(req)
|
||||
|
||||
Create a new `Accepts` object for the given `req`.
|
||||
|
||||
#### .charset(charsets)
|
||||
|
||||
Return the first accepted charset. If nothing in `charsets` is accepted,
|
||||
then `false` is returned.
|
||||
|
||||
#### .charsets()
|
||||
|
||||
Return the charsets that the request accepts, in the order of the client's
|
||||
preference (most preferred first).
|
||||
|
||||
#### .encoding(encodings)
|
||||
|
||||
Return the first accepted encoding. If nothing in `encodings` is accepted,
|
||||
then `false` is returned.
|
||||
|
||||
#### .encodings()
|
||||
|
||||
Return the encodings that the request accepts, in the order of the client's
|
||||
preference (most preferred first).
|
||||
|
||||
#### .language(languages)
|
||||
|
||||
Return the first accepted language. If nothing in `languages` is accepted,
|
||||
then `false` is returned.
|
||||
|
||||
#### .languages()
|
||||
|
||||
Return the languages that the request accepts, in the order of the client's
|
||||
preference (most preferred first).
|
||||
|
||||
#### .type(types)
|
||||
|
||||
Return the first accepted type (and it is returned as the same text as what
|
||||
appears in the `types` array). If nothing in `types` is accepted, then `false`
|
||||
is returned.
|
||||
|
||||
The `types` array can contain full MIME types or file extensions. Any value
|
||||
that is not a full MIME types is passed to `require('mime-types').lookup`.
|
||||
|
||||
#### .types()
|
||||
|
||||
Return the types that the request accepts, in the order of the client's
|
||||
preference (most preferred first).
|
||||
|
||||
## Examples
|
||||
|
||||
### Simple type negotiation
|
||||
|
||||
This simple example shows how to use `accepts` to return a different typed
|
||||
respond body based on what the client wants to accept. The server lists it's
|
||||
preferences in order and will get back the best match between the client and
|
||||
server.
|
||||
|
||||
```js
|
||||
var accepts = require('accepts')
|
||||
var http = require('http')
|
||||
|
||||
function app(req, res) {
|
||||
var accept = accepts(req)
|
||||
|
||||
// the order of this list is significant; should be server preferred order
|
||||
switch(accept.type(['json', 'html'])) {
|
||||
case 'json':
|
||||
res.setHeader('Content-Type', 'application/json')
|
||||
res.write('{"hello":"world!"}')
|
||||
break
|
||||
case 'html':
|
||||
res.setHeader('Content-Type', 'text/html')
|
||||
res.write('<b>hello, world!</b>')
|
||||
break
|
||||
default:
|
||||
// the fallback is text/plain, so no need to specify it above
|
||||
res.setHeader('Content-Type', 'text/plain')
|
||||
res.write('hello, world!')
|
||||
break
|
||||
}
|
||||
|
||||
res.end()
|
||||
}
|
||||
|
||||
http.createServer(app).listen(3000)
|
||||
```
|
||||
|
||||
You can test this out with the cURL program:
|
||||
```sh
|
||||
curl -I -H'Accept: text/html' http://localhost:3000/
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
[MIT](LICENSE)
|
||||
|
||||
[npm-image]: https://img.shields.io/npm/v/accepts.svg
|
||||
[npm-url]: https://npmjs.org/package/accepts
|
||||
[node-version-image]: https://img.shields.io/node/v/accepts.svg
|
||||
[node-version-url]: http://nodejs.org/download/
|
||||
[travis-image]: https://img.shields.io/travis/jshttp/accepts/master.svg
|
||||
[travis-url]: https://travis-ci.org/jshttp/accepts
|
||||
[coveralls-image]: https://img.shields.io/coveralls/jshttp/accepts/master.svg
|
||||
[coveralls-url]: https://coveralls.io/r/jshttp/accepts
|
||||
[downloads-image]: https://img.shields.io/npm/dm/accepts.svg
|
||||
[downloads-url]: https://npmjs.org/package/accepts
|
231
node_modules/socketio/node_modules/accepts/index.js
generated
vendored
Normal file
231
node_modules/socketio/node_modules/accepts/index.js
generated
vendored
Normal file
@ -0,0 +1,231 @@
|
||||
/*!
|
||||
* accepts
|
||||
* Copyright(c) 2014 Jonathan Ong
|
||||
* Copyright(c) 2015 Douglas Christopher Wilson
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
'use strict'
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
* @private
|
||||
*/
|
||||
|
||||
var Negotiator = require('negotiator')
|
||||
var mime = require('mime-types')
|
||||
|
||||
/**
|
||||
* Module exports.
|
||||
* @public
|
||||
*/
|
||||
|
||||
module.exports = Accepts
|
||||
|
||||
/**
|
||||
* Create a new Accepts object for the given req.
|
||||
*
|
||||
* @param {object} req
|
||||
* @public
|
||||
*/
|
||||
|
||||
function Accepts(req) {
|
||||
if (!(this instanceof Accepts))
|
||||
return new Accepts(req)
|
||||
|
||||
this.headers = req.headers
|
||||
this.negotiator = new Negotiator(req)
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the given `type(s)` is acceptable, returning
|
||||
* the best match when true, otherwise `undefined`, in which
|
||||
* case you should respond with 406 "Not Acceptable".
|
||||
*
|
||||
* The `type` value may be a single mime type string
|
||||
* such as "application/json", the extension name
|
||||
* such as "json" or an array `["json", "html", "text/plain"]`. When a list
|
||||
* or array is given the _best_ match, if any is returned.
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* // Accept: text/html
|
||||
* this.types('html');
|
||||
* // => "html"
|
||||
*
|
||||
* // Accept: text/*, application/json
|
||||
* this.types('html');
|
||||
* // => "html"
|
||||
* this.types('text/html');
|
||||
* // => "text/html"
|
||||
* this.types('json', 'text');
|
||||
* // => "json"
|
||||
* this.types('application/json');
|
||||
* // => "application/json"
|
||||
*
|
||||
* // Accept: text/*, application/json
|
||||
* this.types('image/png');
|
||||
* this.types('png');
|
||||
* // => undefined
|
||||
*
|
||||
* // Accept: text/*;q=.5, application/json
|
||||
* this.types(['html', 'json']);
|
||||
* this.types('html', 'json');
|
||||
* // => "json"
|
||||
*
|
||||
* @param {String|Array} types...
|
||||
* @return {String|Array|Boolean}
|
||||
* @public
|
||||
*/
|
||||
|
||||
Accepts.prototype.type =
|
||||
Accepts.prototype.types = function (types_) {
|
||||
var types = types_
|
||||
|
||||
// support flattened arguments
|
||||
if (types && !Array.isArray(types)) {
|
||||
types = new Array(arguments.length)
|
||||
for (var i = 0; i < types.length; i++) {
|
||||
types[i] = arguments[i]
|
||||
}
|
||||
}
|
||||
|
||||
// no types, return all requested types
|
||||
if (!types || types.length === 0) {
|
||||
return this.negotiator.mediaTypes()
|
||||
}
|
||||
|
||||
if (!this.headers.accept) return types[0];
|
||||
var mimes = types.map(extToMime);
|
||||
var accepts = this.negotiator.mediaTypes(mimes.filter(validMime));
|
||||
var first = accepts[0];
|
||||
if (!first) return false;
|
||||
return types[mimes.indexOf(first)];
|
||||
}
|
||||
|
||||
/**
|
||||
* Return accepted encodings or best fit based on `encodings`.
|
||||
*
|
||||
* Given `Accept-Encoding: gzip, deflate`
|
||||
* an array sorted by quality is returned:
|
||||
*
|
||||
* ['gzip', 'deflate']
|
||||
*
|
||||
* @param {String|Array} encodings...
|
||||
* @return {String|Array}
|
||||
* @public
|
||||
*/
|
||||
|
||||
Accepts.prototype.encoding =
|
||||
Accepts.prototype.encodings = function (encodings_) {
|
||||
var encodings = encodings_
|
||||
|
||||
// support flattened arguments
|
||||
if (encodings && !Array.isArray(encodings)) {
|
||||
encodings = new Array(arguments.length)
|
||||
for (var i = 0; i < encodings.length; i++) {
|
||||
encodings[i] = arguments[i]
|
||||
}
|
||||
}
|
||||
|
||||
// no encodings, return all requested encodings
|
||||
if (!encodings || encodings.length === 0) {
|
||||
return this.negotiator.encodings()
|
||||
}
|
||||
|
||||
return this.negotiator.encodings(encodings)[0] || false
|
||||
}
|
||||
|
||||
/**
|
||||
* Return accepted charsets or best fit based on `charsets`.
|
||||
*
|
||||
* Given `Accept-Charset: utf-8, iso-8859-1;q=0.2, utf-7;q=0.5`
|
||||
* an array sorted by quality is returned:
|
||||
*
|
||||
* ['utf-8', 'utf-7', 'iso-8859-1']
|
||||
*
|
||||
* @param {String|Array} charsets...
|
||||
* @return {String|Array}
|
||||
* @public
|
||||
*/
|
||||
|
||||
Accepts.prototype.charset =
|
||||
Accepts.prototype.charsets = function (charsets_) {
|
||||
var charsets = charsets_
|
||||
|
||||
// support flattened arguments
|
||||
if (charsets && !Array.isArray(charsets)) {
|
||||
charsets = new Array(arguments.length)
|
||||
for (var i = 0; i < charsets.length; i++) {
|
||||
charsets[i] = arguments[i]
|
||||
}
|
||||
}
|
||||
|
||||
// no charsets, return all requested charsets
|
||||
if (!charsets || charsets.length === 0) {
|
||||
return this.negotiator.charsets()
|
||||
}
|
||||
|
||||
return this.negotiator.charsets(charsets)[0] || false
|
||||
}
|
||||
|
||||
/**
|
||||
* Return accepted languages or best fit based on `langs`.
|
||||
*
|
||||
* Given `Accept-Language: en;q=0.8, es, pt`
|
||||
* an array sorted by quality is returned:
|
||||
*
|
||||
* ['es', 'pt', 'en']
|
||||
*
|
||||
* @param {String|Array} langs...
|
||||
* @return {Array|String}
|
||||
* @public
|
||||
*/
|
||||
|
||||
Accepts.prototype.lang =
|
||||
Accepts.prototype.langs =
|
||||
Accepts.prototype.language =
|
||||
Accepts.prototype.languages = function (languages_) {
|
||||
var languages = languages_
|
||||
|
||||
// support flattened arguments
|
||||
if (languages && !Array.isArray(languages)) {
|
||||
languages = new Array(arguments.length)
|
||||
for (var i = 0; i < languages.length; i++) {
|
||||
languages[i] = arguments[i]
|
||||
}
|
||||
}
|
||||
|
||||
// no languages, return all requested languages
|
||||
if (!languages || languages.length === 0) {
|
||||
return this.negotiator.languages()
|
||||
}
|
||||
|
||||
return this.negotiator.languages(languages)[0] || false
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert extnames to mime.
|
||||
*
|
||||
* @param {String} type
|
||||
* @return {String}
|
||||
* @private
|
||||
*/
|
||||
|
||||
function extToMime(type) {
|
||||
return type.indexOf('/') === -1
|
||||
? mime.lookup(type)
|
||||
: type
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if mime is valid.
|
||||
*
|
||||
* @param {String} type
|
||||
* @return {String}
|
||||
* @private
|
||||
*/
|
||||
|
||||
function validMime(type) {
|
||||
return typeof type === 'string';
|
||||
}
|
38
node_modules/socketio/node_modules/accepts/package.json
generated
vendored
Normal file
38
node_modules/socketio/node_modules/accepts/package.json
generated
vendored
Normal file
@ -0,0 +1,38 @@
|
||||
{
|
||||
"name": "accepts",
|
||||
"description": "Higher-level content negotiation",
|
||||
"version": "1.3.3",
|
||||
"contributors": [
|
||||
"Douglas Christopher Wilson <doug@somethingdoug.com>",
|
||||
"Jonathan Ong <me@jongleberry.com> (http://jongleberry.com)"
|
||||
],
|
||||
"license": "MIT",
|
||||
"repository": "jshttp/accepts",
|
||||
"dependencies": {
|
||||
"mime-types": "~2.1.11",
|
||||
"negotiator": "0.6.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"istanbul": "0.4.3",
|
||||
"mocha": "~1.21.5"
|
||||
},
|
||||
"files": [
|
||||
"LICENSE",
|
||||
"HISTORY.md",
|
||||
"index.js"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha --reporter spec --check-leaks --bail test/",
|
||||
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/",
|
||||
"test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/"
|
||||
},
|
||||
"keywords": [
|
||||
"content",
|
||||
"negotiation",
|
||||
"accept",
|
||||
"accepts"
|
||||
]
|
||||
}
|
3
node_modules/socketio/node_modules/base64id/.npmignore
generated
vendored
Normal file
3
node_modules/socketio/node_modules/base64id/.npmignore
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
support
|
||||
test
|
||||
examples
|
22
node_modules/socketio/node_modules/base64id/LICENSE
generated
vendored
Normal file
22
node_modules/socketio/node_modules/base64id/LICENSE
generated
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2012-2016 Kristian Faeldt <faeldt_kristian@cyberagent.co.jp>
|
||||
|
||||
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.
|
18
node_modules/socketio/node_modules/base64id/README.md
generated
vendored
Normal file
18
node_modules/socketio/node_modules/base64id/README.md
generated
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
base64id
|
||||
========
|
||||
|
||||
Node.js module that generates a base64 id.
|
||||
|
||||
Uses crypto.randomBytes when available, falls back to unsafe methods for node.js <= 0.4.
|
||||
|
||||
To increase performance, random bytes are buffered to minimize the number of synchronous calls to crypto.randomBytes.
|
||||
|
||||
## Installation
|
||||
|
||||
$ npm install base64id
|
||||
|
||||
## Usage
|
||||
|
||||
var base64id = require('base64id');
|
||||
|
||||
var id = base64id.generateId();
|
103
node_modules/socketio/node_modules/base64id/lib/base64id.js
generated
vendored
Normal file
103
node_modules/socketio/node_modules/base64id/lib/base64id.js
generated
vendored
Normal file
@ -0,0 +1,103 @@
|
||||
/*!
|
||||
* base64id v0.1.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* Module dependencies
|
||||
*/
|
||||
|
||||
var crypto = require('crypto');
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
|
||||
var Base64Id = function() { };
|
||||
|
||||
/**
|
||||
* Get random bytes
|
||||
*
|
||||
* Uses a buffer if available, falls back to crypto.randomBytes
|
||||
*/
|
||||
|
||||
Base64Id.prototype.getRandomBytes = function(bytes) {
|
||||
|
||||
var BUFFER_SIZE = 4096
|
||||
var self = this;
|
||||
|
||||
bytes = bytes || 12;
|
||||
|
||||
if (bytes > BUFFER_SIZE) {
|
||||
return crypto.randomBytes(bytes);
|
||||
}
|
||||
|
||||
var bytesInBuffer = parseInt(BUFFER_SIZE/bytes);
|
||||
var threshold = parseInt(bytesInBuffer*0.85);
|
||||
|
||||
if (!threshold) {
|
||||
return crypto.randomBytes(bytes);
|
||||
}
|
||||
|
||||
if (this.bytesBufferIndex == null) {
|
||||
this.bytesBufferIndex = -1;
|
||||
}
|
||||
|
||||
if (this.bytesBufferIndex == bytesInBuffer) {
|
||||
this.bytesBuffer = null;
|
||||
this.bytesBufferIndex = -1;
|
||||
}
|
||||
|
||||
// No buffered bytes available or index above threshold
|
||||
if (this.bytesBufferIndex == -1 || this.bytesBufferIndex > threshold) {
|
||||
|
||||
if (!this.isGeneratingBytes) {
|
||||
this.isGeneratingBytes = true;
|
||||
crypto.randomBytes(BUFFER_SIZE, function(err, bytes) {
|
||||
self.bytesBuffer = bytes;
|
||||
self.bytesBufferIndex = 0;
|
||||
self.isGeneratingBytes = false;
|
||||
});
|
||||
}
|
||||
|
||||
// Fall back to sync call when no buffered bytes are available
|
||||
if (this.bytesBufferIndex == -1) {
|
||||
return crypto.randomBytes(bytes);
|
||||
}
|
||||
}
|
||||
|
||||
var result = this.bytesBuffer.slice(bytes*this.bytesBufferIndex, bytes*(this.bytesBufferIndex+1));
|
||||
this.bytesBufferIndex++;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a base64 id
|
||||
*
|
||||
* (Original version from socket.io <http://socket.io>)
|
||||
*/
|
||||
|
||||
Base64Id.prototype.generateId = function () {
|
||||
var rand = new Buffer(15); // multiple of 3 for base64
|
||||
if (!rand.writeInt32BE) {
|
||||
return Math.abs(Math.random() * Math.random() * Date.now() | 0).toString()
|
||||
+ Math.abs(Math.random() * Math.random() * Date.now() | 0).toString();
|
||||
}
|
||||
this.sequenceNumber = (this.sequenceNumber + 1) | 0;
|
||||
rand.writeInt32BE(this.sequenceNumber, 11);
|
||||
if (crypto.randomBytes) {
|
||||
this.getRandomBytes(12).copy(rand);
|
||||
} else {
|
||||
// not secure for node 0.4
|
||||
[0, 4, 8].forEach(function(i) {
|
||||
rand.writeInt32BE(Math.random() * Math.pow(2, 32) | 0, i);
|
||||
});
|
||||
}
|
||||
return rand.toString('base64').replace(/\//g, '_').replace(/\+/g, '-');
|
||||
};
|
||||
|
||||
/**
|
||||
* Export
|
||||
*/
|
||||
|
||||
exports = module.exports = new Base64Id();
|
13
node_modules/socketio/node_modules/base64id/package.json
generated
vendored
Normal file
13
node_modules/socketio/node_modules/base64id/package.json
generated
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
{
|
||||
"name": "base64id"
|
||||
, "version": "1.0.0"
|
||||
, "license": "MIT"
|
||||
, "description": "Generates a base64 id"
|
||||
, "author": "Kristian Faeldt <faeldt_kristian@cyberagent.co.jp>"
|
||||
, "repository": {
|
||||
"type": "git"
|
||||
, "url": "https://github.com/faeldt/base64id.git"
|
||||
}
|
||||
, "main": "./lib/base64id.js"
|
||||
, "engines": { "node": ">= 0.4.0" }
|
||||
}
|
2
node_modules/socketio/node_modules/component-emitter/.npmignore
generated
vendored
Normal file
2
node_modules/socketio/node_modules/component-emitter/.npmignore
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
node_modules
|
||||
test
|
4
node_modules/socketio/node_modules/component-emitter/.travis.yml
generated
vendored
Normal file
4
node_modules/socketio/node_modules/component-emitter/.travis.yml
generated
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
node_js:
|
||||
- "0.8"
|
||||
- "0.10"
|
||||
language: node_js
|
52
node_modules/socketio/node_modules/component-emitter/History.md
generated
vendored
Normal file
52
node_modules/socketio/node_modules/component-emitter/History.md
generated
vendored
Normal file
@ -0,0 +1,52 @@
|
||||
|
||||
1.1.2 / 2014-02-10
|
||||
==================
|
||||
|
||||
* package: rename to "component-emitter"
|
||||
* package: update "main" and "component" fields
|
||||
* Add license to Readme (same format as the other components)
|
||||
* created .npmignore
|
||||
* travis stuff
|
||||
|
||||
1.1.1 / 2013-12-01
|
||||
==================
|
||||
|
||||
* fix .once adding .on to the listener
|
||||
* docs: Emitter#off()
|
||||
* component: add `.repo` prop
|
||||
|
||||
1.1.0 / 2013-10-20
|
||||
==================
|
||||
|
||||
* add `.addEventListener()` and `.removeEventListener()` aliases
|
||||
|
||||
1.0.1 / 2013-06-27
|
||||
==================
|
||||
|
||||
* add support for legacy ie
|
||||
|
||||
1.0.0 / 2013-02-26
|
||||
==================
|
||||
|
||||
* add `.off()` support for removing all listeners
|
||||
|
||||
0.0.6 / 2012-10-08
|
||||
==================
|
||||
|
||||
* add `this._callbacks` initialization to prevent funky gotcha
|
||||
|
||||
0.0.5 / 2012-09-07
|
||||
==================
|
||||
|
||||
* fix `Emitter.call(this)` usage
|
||||
|
||||
0.0.3 / 2012-07-11
|
||||
==================
|
||||
|
||||
* add `.listeners()`
|
||||
* rename `.has()` to `.hasListeners()`
|
||||
|
||||
0.0.2 / 2012-06-28
|
||||
==================
|
||||
|
||||
* fix `.off()` with `.once()`-registered callbacks
|
7
node_modules/socketio/node_modules/component-emitter/Makefile
generated
vendored
Normal file
7
node_modules/socketio/node_modules/component-emitter/Makefile
generated
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
|
||||
test:
|
||||
@./node_modules/.bin/mocha \
|
||||
--require should \
|
||||
--reporter spec
|
||||
|
||||
.PHONY: test
|
74
node_modules/socketio/node_modules/component-emitter/Readme.md
generated
vendored
Normal file
74
node_modules/socketio/node_modules/component-emitter/Readme.md
generated
vendored
Normal file
@ -0,0 +1,74 @@
|
||||
# Emitter [](https://travis-ci.org/component/emitter)
|
||||
|
||||
Event emitter component.
|
||||
|
||||
## Installation
|
||||
|
||||
```
|
||||
$ component install component/emitter
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### Emitter(obj)
|
||||
|
||||
The `Emitter` may also be used as a mixin. For example
|
||||
a "plain" object may become an emitter, or you may
|
||||
extend an existing prototype.
|
||||
|
||||
As an `Emitter` instance:
|
||||
|
||||
```js
|
||||
var Emitter = require('emitter');
|
||||
var emitter = new Emitter;
|
||||
emitter.emit('something');
|
||||
```
|
||||
|
||||
As a mixin:
|
||||
|
||||
```js
|
||||
var Emitter = require('emitter');
|
||||
var user = { name: 'tobi' };
|
||||
Emitter(user);
|
||||
|
||||
user.emit('im a user');
|
||||
```
|
||||
|
||||
As a prototype mixin:
|
||||
|
||||
```js
|
||||
var Emitter = require('emitter');
|
||||
Emitter(User.prototype);
|
||||
```
|
||||
|
||||
### Emitter#on(event, fn)
|
||||
|
||||
Register an `event` handler `fn`.
|
||||
|
||||
### Emitter#once(event, fn)
|
||||
|
||||
Register a single-shot `event` handler `fn`,
|
||||
removed immediately after it is invoked the
|
||||
first time.
|
||||
|
||||
### Emitter#off(event, fn)
|
||||
|
||||
* Pass `event` and `fn` to remove a listener.
|
||||
* Pass `event` to remove all listeners on that event.
|
||||
* Pass nothing to remove all listeners on all events.
|
||||
|
||||
### Emitter#emit(event, ...)
|
||||
|
||||
Emit an `event` with variable option args.
|
||||
|
||||
### Emitter#listeners(event)
|
||||
|
||||
Return an array of callbacks, or an empty array.
|
||||
|
||||
### Emitter#hasListeners(event)
|
||||
|
||||
Check if this emitter has `event` handlers.
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
21
node_modules/socketio/node_modules/component-emitter/bower.json
generated
vendored
Normal file
21
node_modules/socketio/node_modules/component-emitter/bower.json
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
{
|
||||
"name": "emitter",
|
||||
"description": "Event emitter",
|
||||
"keywords": [
|
||||
"emitter",
|
||||
"events"
|
||||
],
|
||||
"version": "1.1.2",
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"homepage": "https://github.com/component/emitter",
|
||||
"ignore": [
|
||||
"**/.*",
|
||||
"node_modules",
|
||||
"bower_components",
|
||||
"test",
|
||||
"Makefile",
|
||||
"package.json",
|
||||
"component.json"
|
||||
]
|
||||
}
|
14
node_modules/socketio/node_modules/component-emitter/component.json
generated
vendored
Normal file
14
node_modules/socketio/node_modules/component-emitter/component.json
generated
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
{
|
||||
"name": "emitter",
|
||||
"repo": "component/emitter",
|
||||
"description": "Event emitter",
|
||||
"keywords": [
|
||||
"emitter",
|
||||
"events"
|
||||
],
|
||||
"version": "1.1.2",
|
||||
"scripts": [
|
||||
"index.js"
|
||||
],
|
||||
"license": "MIT"
|
||||
}
|
164
node_modules/socketio/node_modules/component-emitter/index.js
generated
vendored
Normal file
164
node_modules/socketio/node_modules/component-emitter/index.js
generated
vendored
Normal file
@ -0,0 +1,164 @@
|
||||
|
||||
/**
|
||||
* Expose `Emitter`.
|
||||
*/
|
||||
|
||||
module.exports = Emitter;
|
||||
|
||||
/**
|
||||
* Initialize a new `Emitter`.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function Emitter(obj) {
|
||||
if (obj) return mixin(obj);
|
||||
};
|
||||
|
||||
/**
|
||||
* Mixin the emitter properties.
|
||||
*
|
||||
* @param {Object} obj
|
||||
* @return {Object}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function mixin(obj) {
|
||||
for (var key in Emitter.prototype) {
|
||||
obj[key] = Emitter.prototype[key];
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Listen on the given `event` with `fn`.
|
||||
*
|
||||
* @param {String} event
|
||||
* @param {Function} fn
|
||||
* @return {Emitter}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Emitter.prototype.on =
|
||||
Emitter.prototype.addEventListener = function(event, fn){
|
||||
this._callbacks = this._callbacks || {};
|
||||
(this._callbacks[event] = this._callbacks[event] || [])
|
||||
.push(fn);
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Adds an `event` listener that will be invoked a single
|
||||
* time then automatically removed.
|
||||
*
|
||||
* @param {String} event
|
||||
* @param {Function} fn
|
||||
* @return {Emitter}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Emitter.prototype.once = function(event, fn){
|
||||
var self = this;
|
||||
this._callbacks = this._callbacks || {};
|
||||
|
||||
function on() {
|
||||
self.off(event, on);
|
||||
fn.apply(this, arguments);
|
||||
}
|
||||
|
||||
on.fn = fn;
|
||||
this.on(event, on);
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Remove the given callback for `event` or all
|
||||
* registered callbacks.
|
||||
*
|
||||
* @param {String} event
|
||||
* @param {Function} fn
|
||||
* @return {Emitter}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Emitter.prototype.off =
|
||||
Emitter.prototype.removeListener =
|
||||
Emitter.prototype.removeAllListeners =
|
||||
Emitter.prototype.removeEventListener = function(event, fn){
|
||||
this._callbacks = this._callbacks || {};
|
||||
|
||||
// all
|
||||
if (0 == arguments.length) {
|
||||
this._callbacks = {};
|
||||
return this;
|
||||
}
|
||||
|
||||
// specific event
|
||||
var callbacks = this._callbacks[event];
|
||||
if (!callbacks) return this;
|
||||
|
||||
// remove all handlers
|
||||
if (1 == arguments.length) {
|
||||
delete this._callbacks[event];
|
||||
return this;
|
||||
}
|
||||
|
||||
// remove specific handler
|
||||
var cb;
|
||||
for (var i = 0; i < callbacks.length; i++) {
|
||||
cb = callbacks[i];
|
||||
if (cb === fn || cb.fn === fn) {
|
||||
callbacks.splice(i, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Emit `event` with the given args.
|
||||
*
|
||||
* @param {String} event
|
||||
* @param {Mixed} ...
|
||||
* @return {Emitter}
|
||||
*/
|
||||
|
||||
Emitter.prototype.emit = function(event){
|
||||
this._callbacks = this._callbacks || {};
|
||||
var args = [].slice.call(arguments, 1)
|
||||
, callbacks = this._callbacks[event];
|
||||
|
||||
if (callbacks) {
|
||||
callbacks = callbacks.slice(0);
|
||||
for (var i = 0, len = callbacks.length; i < len; ++i) {
|
||||
callbacks[i].apply(this, args);
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return array of callbacks for `event`.
|
||||
*
|
||||
* @param {String} event
|
||||
* @return {Array}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Emitter.prototype.listeners = function(event){
|
||||
this._callbacks = this._callbacks || {};
|
||||
return this._callbacks[event] || [];
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if this emitter has `event` handlers.
|
||||
*
|
||||
* @param {String} event
|
||||
* @return {Boolean}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Emitter.prototype.hasListeners = function(event){
|
||||
return !! this.listeners(event).length;
|
||||
};
|
22
node_modules/socketio/node_modules/component-emitter/package.json
generated
vendored
Normal file
22
node_modules/socketio/node_modules/component-emitter/package.json
generated
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
{
|
||||
"name": "component-emitter",
|
||||
"description": "Event emitter",
|
||||
"version": "1.1.2",
|
||||
"devDependencies": {
|
||||
"mocha": "*",
|
||||
"should": "*"
|
||||
},
|
||||
"component": {
|
||||
"scripts": {
|
||||
"emitter/index.js": "index.js"
|
||||
}
|
||||
},
|
||||
"main": "index.js",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/component/emitter.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "make test"
|
||||
}
|
||||
}
|
118
node_modules/socketio/node_modules/cookie/HISTORY.md
generated
vendored
Normal file
118
node_modules/socketio/node_modules/cookie/HISTORY.md
generated
vendored
Normal file
@ -0,0 +1,118 @@
|
||||
0.3.1 / 2016-05-26
|
||||
==================
|
||||
|
||||
* Fix `sameSite: true` to work with draft-7 clients
|
||||
- `true` now sends `SameSite=Strict` instead of `SameSite`
|
||||
|
||||
0.3.0 / 2016-05-26
|
||||
==================
|
||||
|
||||
* Add `sameSite` option
|
||||
- Replaces `firstPartyOnly` option, never implemented by browsers
|
||||
* Improve error message when `encode` is not a function
|
||||
* Improve error message when `expires` is not a `Date`
|
||||
|
||||
0.2.4 / 2016-05-20
|
||||
==================
|
||||
|
||||
* perf: enable strict mode
|
||||
* perf: use for loop in parse
|
||||
* perf: use string concatination for serialization
|
||||
|
||||
0.2.3 / 2015-10-25
|
||||
==================
|
||||
|
||||
* Fix cookie `Max-Age` to never be a floating point number
|
||||
|
||||
0.2.2 / 2015-09-17
|
||||
==================
|
||||
|
||||
* Fix regression when setting empty cookie value
|
||||
- Ease the new restriction, which is just basic header-level validation
|
||||
* Fix typo in invalid value errors
|
||||
|
||||
0.2.1 / 2015-09-17
|
||||
==================
|
||||
|
||||
* Throw on invalid values provided to `serialize`
|
||||
- Ensures the resulting string is a valid HTTP header value
|
||||
|
||||
0.2.0 / 2015-08-13
|
||||
==================
|
||||
|
||||
* Add `firstPartyOnly` option
|
||||
* Throw better error for invalid argument to parse
|
||||
* perf: hoist regular expression
|
||||
|
||||
0.1.5 / 2015-09-17
|
||||
==================
|
||||
|
||||
* Fix regression when setting empty cookie value
|
||||
- Ease the new restriction, which is just basic header-level validation
|
||||
* Fix typo in invalid value errors
|
||||
|
||||
0.1.4 / 2015-09-17
|
||||
==================
|
||||
|
||||
* Throw better error for invalid argument to parse
|
||||
* Throw on invalid values provided to `serialize`
|
||||
- Ensures the resulting string is a valid HTTP header value
|
||||
|
||||
0.1.3 / 2015-05-19
|
||||
==================
|
||||
|
||||
* Reduce the scope of try-catch deopt
|
||||
* Remove argument reassignments
|
||||
|
||||
0.1.2 / 2014-04-16
|
||||
==================
|
||||
|
||||
* Remove unnecessary files from npm package
|
||||
|
||||
0.1.1 / 2014-02-23
|
||||
==================
|
||||
|
||||
* Fix bad parse when cookie value contained a comma
|
||||
* Fix support for `maxAge` of `0`
|
||||
|
||||
0.1.0 / 2013-05-01
|
||||
==================
|
||||
|
||||
* Add `decode` option
|
||||
* Add `encode` option
|
||||
|
||||
0.0.6 / 2013-04-08
|
||||
==================
|
||||
|
||||
* Ignore cookie parts missing `=`
|
||||
|
||||
0.0.5 / 2012-10-29
|
||||
==================
|
||||
|
||||
* Return raw cookie value if value unescape errors
|
||||
|
||||
0.0.4 / 2012-06-21
|
||||
==================
|
||||
|
||||
* Use encode/decodeURIComponent for cookie encoding/decoding
|
||||
- Improve server/client interoperability
|
||||
|
||||
0.0.3 / 2012-06-06
|
||||
==================
|
||||
|
||||
* Only escape special characters per the cookie RFC
|
||||
|
||||
0.0.2 / 2012-06-01
|
||||
==================
|
||||
|
||||
* Fix `maxAge` option to not throw error
|
||||
|
||||
0.0.1 / 2012-05-28
|
||||
==================
|
||||
|
||||
* Add more tests
|
||||
|
||||
0.0.0 / 2012-05-28
|
||||
==================
|
||||
|
||||
* Initial release
|
24
node_modules/socketio/node_modules/cookie/LICENSE
generated
vendored
Normal file
24
node_modules/socketio/node_modules/cookie/LICENSE
generated
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2012-2014 Roman Shtylman <shtylman@gmail.com>
|
||||
Copyright (c) 2015 Douglas Christopher Wilson <doug@somethingdoug.com>
|
||||
|
||||
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.
|
||||
|
220
node_modules/socketio/node_modules/cookie/README.md
generated
vendored
Normal file
220
node_modules/socketio/node_modules/cookie/README.md
generated
vendored
Normal file
@ -0,0 +1,220 @@
|
||||
# cookie
|
||||
|
||||
[![NPM Version][npm-image]][npm-url]
|
||||
[![NPM Downloads][downloads-image]][downloads-url]
|
||||
[![Node.js Version][node-version-image]][node-version-url]
|
||||
[![Build Status][travis-image]][travis-url]
|
||||
[![Test Coverage][coveralls-image]][coveralls-url]
|
||||
|
||||
Basic HTTP cookie parser and serializer for HTTP servers.
|
||||
|
||||
## Installation
|
||||
|
||||
```sh
|
||||
$ npm install cookie
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
```js
|
||||
var cookie = require('cookie');
|
||||
```
|
||||
|
||||
### cookie.parse(str, options)
|
||||
|
||||
Parse an HTTP `Cookie` header string and returning an object of all cookie name-value pairs.
|
||||
The `str` argument is the string representing a `Cookie` header value and `options` is an
|
||||
optional object containing additional parsing options.
|
||||
|
||||
```js
|
||||
var cookies = cookie.parse('foo=bar; equation=E%3Dmc%5E2');
|
||||
// { foo: 'bar', equation: 'E=mc^2' }
|
||||
```
|
||||
|
||||
#### Options
|
||||
|
||||
`cookie.parse` accepts these properties in the options object.
|
||||
|
||||
##### decode
|
||||
|
||||
Specifies a function that will be used to decode a cookie's value. Since the value of a cookie
|
||||
has a limited character set (and must be a simple string), this function can be used to decode
|
||||
a previously-encoded cookie value into a JavaScript string or other object.
|
||||
|
||||
The default function is the global `decodeURIComponent`, which will decode any URL-encoded
|
||||
sequences into their byte representations.
|
||||
|
||||
**note** if an error is thrown from this function, the original, non-decoded cookie value will
|
||||
be returned as the cookie's value.
|
||||
|
||||
### cookie.serialize(name, value, options)
|
||||
|
||||
Serialize a cookie name-value pair into a `Set-Cookie` header string. The `name` argument is the
|
||||
name for the cookie, the `value` argument is the value to set the cookie to, and the `options`
|
||||
argument is an optional object containing additional serialization options.
|
||||
|
||||
```js
|
||||
var setCookie = cookie.serialize('foo', 'bar');
|
||||
// foo=bar
|
||||
```
|
||||
|
||||
#### Options
|
||||
|
||||
`cookie.serialize` accepts these properties in the options object.
|
||||
|
||||
##### domain
|
||||
|
||||
Specifies the value for the [`Domain` `Set-Cookie` attribute][rfc-6266-5.2.3]. By default, no
|
||||
domain is set, and most clients will consider the cookie to apply to only the current domain.
|
||||
|
||||
##### encode
|
||||
|
||||
Specifies a function that will be used to encode a cookie's value. Since value of a cookie
|
||||
has a limited character set (and must be a simple string), this function can be used to encode
|
||||
a value into a string suited for a cookie's value.
|
||||
|
||||
The default function is the global `ecodeURIComponent`, which will encode a JavaScript string
|
||||
into UTF-8 byte sequences and then URL-encode any that fall outside of the cookie range.
|
||||
|
||||
##### expires
|
||||
|
||||
Specifies the `Date` object to be the value for the [`Expires` `Set-Cookie` attribute][rfc-6266-5.2.1].
|
||||
By default, no expiration is set, and most clients will consider this a "non-persistent cookie" and
|
||||
will delete it on a condition like exiting a web browser application.
|
||||
|
||||
**note** the [cookie storage model specification][rfc-6266-5.3] states that if both `expires` and
|
||||
`magAge` are set, then `maxAge` takes precedence, but it is possiblke not all clients by obey this,
|
||||
so if both are set, they should point to the same date and time.
|
||||
|
||||
##### httpOnly
|
||||
|
||||
Specifies the `boolean` value for the [`HttpOnly` `Set-Cookie` attribute][rfc-6266-5.2.6]. When truthy,
|
||||
the `HttpOnly` attribute is set, otherwise it is not. By default, the `HttpOnly` attribute is not set.
|
||||
|
||||
**note** be careful when setting this to `true`, as compliant clients will not allow client-side
|
||||
JavaScript to see the cookie in `document.cookie`.
|
||||
|
||||
##### maxAge
|
||||
|
||||
Specifies the `number` (in seconds) to be the value for the [`Max-Age` `Set-Cookie` attribute][rfc-6266-5.2.2].
|
||||
The given number will be converted to an integer by rounding down. By default, no maximum age is set.
|
||||
|
||||
**note** the [cookie storage model specification][rfc-6266-5.3] states that if both `expires` and
|
||||
`magAge` are set, then `maxAge` takes precedence, but it is possiblke not all clients by obey this,
|
||||
so if both are set, they should point to the same date and time.
|
||||
|
||||
##### path
|
||||
|
||||
Specifies the value for the [`Path` `Set-Cookie` attribute][rfc-6266-5.2.4]. By default, the path
|
||||
is considered the ["default path"][rfc-6266-5.1.4]. By default, no maximum age is set, and most
|
||||
clients will consider this a "non-persistent cookie" and will delete it on a condition like exiting
|
||||
a web browser application.
|
||||
|
||||
##### sameSite
|
||||
|
||||
Specifies the `boolean` or `string` to be the value for the [`SameSite` `Set-Cookie` attribute][draft-west-first-party-cookies-07].
|
||||
|
||||
- `true` will set the `SameSite` attribute to `Strict` for strict same site enforcement.
|
||||
- `false` will not set the `SameSite` attribute.
|
||||
- `'lax'` will set the `SameSite` attribute to `Lax` for lax same site enforcement.
|
||||
- `'strict'` will set the `SameSite` attribute to `Strict` for strict same site enforcement.
|
||||
|
||||
More information about the different enforcement levels can be found in the specification
|
||||
https://tools.ietf.org/html/draft-west-first-party-cookies-07#section-4.1.1
|
||||
|
||||
**note** This is an attribute that has not yet been fully standardized, and may change in the future.
|
||||
This also means many clients may ignore this attribute until they understand it.
|
||||
|
||||
##### secure
|
||||
|
||||
Specifies the `boolean` value for the [`Secure` `Set-Cookie` attribute][rfc-6266-5.2.5]. When truthy,
|
||||
the `Secure` attribute is set, otherwise it is not. By default, the `Secure` attribute is not set.
|
||||
|
||||
**note** be careful when setting this to `true`, as compliant clients will not send the cookie back to
|
||||
the server in the future if the browser does not have an HTTPS connection.
|
||||
|
||||
## Example
|
||||
|
||||
The following example uses this module in conjunction with the Node.js core HTTP server
|
||||
to prompt a user for their name and display it back on future visits.
|
||||
|
||||
```js
|
||||
var cookie = require('cookie');
|
||||
var escapeHtml = require('escape-html');
|
||||
var http = require('http');
|
||||
var url = require('url');
|
||||
|
||||
function onRequest(req, res) {
|
||||
// Parse the query string
|
||||
var query = url.parse(req.url, true, true).query;
|
||||
|
||||
if (query && query.name) {
|
||||
// Set a new cookie with the name
|
||||
res.setHeader('Set-Cookie', cookie.serialize('name', String(query.name), {
|
||||
httpOnly: true,
|
||||
maxAge: 60 * 60 * 24 * 7 // 1 week
|
||||
}));
|
||||
|
||||
// Redirect back after setting cookie
|
||||
res.statusCode = 302;
|
||||
res.setHeader('Location', req.headers.referer || '/');
|
||||
res.end();
|
||||
return;
|
||||
}
|
||||
|
||||
// Parse the cookies on the request
|
||||
var cookies = cookie.parse(req.headers.cookie || '');
|
||||
|
||||
// Get the visitor name set in the cookie
|
||||
var name = cookies.name;
|
||||
|
||||
res.setHeader('Content-Type', 'text/html; charset=UTF-8');
|
||||
|
||||
if (name) {
|
||||
res.write('<p>Welcome back, <b>' + escapeHtml(name) + '</b>!</p>');
|
||||
} else {
|
||||
res.write('<p>Hello, new visitor!</p>');
|
||||
}
|
||||
|
||||
res.write('<form method="GET">');
|
||||
res.write('<input placeholder="enter your name" name="name"> <input type="submit" value="Set Name">');
|
||||
res.end('</form');
|
||||
}
|
||||
|
||||
http.createServer(onRequest).listen(3000);
|
||||
```
|
||||
|
||||
## Testing
|
||||
|
||||
```sh
|
||||
$ npm test
|
||||
```
|
||||
|
||||
## References
|
||||
|
||||
- [RFC 6266: HTTP State Management Mechanism][rfc-6266]
|
||||
- [Same-site Cookies][draft-west-first-party-cookies-07]
|
||||
|
||||
[draft-west-first-party-cookies-07]: https://tools.ietf.org/html/draft-west-first-party-cookies-07
|
||||
[rfc-6266]: https://tools.ietf.org/html/rfc6266
|
||||
[rfc-6266-5.1.4]: https://tools.ietf.org/html/rfc6266#section-5.1.4
|
||||
[rfc-6266-5.2.1]: https://tools.ietf.org/html/rfc6266#section-5.2.1
|
||||
[rfc-6266-5.2.2]: https://tools.ietf.org/html/rfc6266#section-5.2.2
|
||||
[rfc-6266-5.2.3]: https://tools.ietf.org/html/rfc6266#section-5.2.3
|
||||
[rfc-6266-5.2.4]: https://tools.ietf.org/html/rfc6266#section-5.2.4
|
||||
[rfc-6266-5.3]: https://tools.ietf.org/html/rfc6266#section-5.3
|
||||
|
||||
## License
|
||||
|
||||
[MIT](LICENSE)
|
||||
|
||||
[npm-image]: https://img.shields.io/npm/v/cookie.svg
|
||||
[npm-url]: https://npmjs.org/package/cookie
|
||||
[node-version-image]: https://img.shields.io/node/v/cookie.svg
|
||||
[node-version-url]: https://nodejs.org/en/download
|
||||
[travis-image]: https://img.shields.io/travis/jshttp/cookie/master.svg
|
||||
[travis-url]: https://travis-ci.org/jshttp/cookie
|
||||
[coveralls-image]: https://img.shields.io/coveralls/jshttp/cookie/master.svg
|
||||
[coveralls-url]: https://coveralls.io/r/jshttp/cookie?branch=master
|
||||
[downloads-image]: https://img.shields.io/npm/dm/cookie.svg
|
||||
[downloads-url]: https://npmjs.org/package/cookie
|
195
node_modules/socketio/node_modules/cookie/index.js
generated
vendored
Normal file
195
node_modules/socketio/node_modules/cookie/index.js
generated
vendored
Normal file
@ -0,0 +1,195 @@
|
||||
/*!
|
||||
* cookie
|
||||
* Copyright(c) 2012-2014 Roman Shtylman
|
||||
* Copyright(c) 2015 Douglas Christopher Wilson
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Module exports.
|
||||
* @public
|
||||
*/
|
||||
|
||||
exports.parse = parse;
|
||||
exports.serialize = serialize;
|
||||
|
||||
/**
|
||||
* Module variables.
|
||||
* @private
|
||||
*/
|
||||
|
||||
var decode = decodeURIComponent;
|
||||
var encode = encodeURIComponent;
|
||||
var pairSplitRegExp = /; */;
|
||||
|
||||
/**
|
||||
* RegExp to match field-content in RFC 7230 sec 3.2
|
||||
*
|
||||
* field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ]
|
||||
* field-vchar = VCHAR / obs-text
|
||||
* obs-text = %x80-FF
|
||||
*/
|
||||
|
||||
var fieldContentRegExp = /^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;
|
||||
|
||||
/**
|
||||
* Parse a cookie header.
|
||||
*
|
||||
* Parse the given cookie header string into an object
|
||||
* The object has the various cookies as keys(names) => values
|
||||
*
|
||||
* @param {string} str
|
||||
* @param {object} [options]
|
||||
* @return {object}
|
||||
* @public
|
||||
*/
|
||||
|
||||
function parse(str, options) {
|
||||
if (typeof str !== 'string') {
|
||||
throw new TypeError('argument str must be a string');
|
||||
}
|
||||
|
||||
var obj = {}
|
||||
var opt = options || {};
|
||||
var pairs = str.split(pairSplitRegExp);
|
||||
var dec = opt.decode || decode;
|
||||
|
||||
for (var i = 0; i < pairs.length; i++) {
|
||||
var pair = pairs[i];
|
||||
var eq_idx = pair.indexOf('=');
|
||||
|
||||
// skip things that don't look like key=value
|
||||
if (eq_idx < 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
var key = pair.substr(0, eq_idx).trim()
|
||||
var val = pair.substr(++eq_idx, pair.length).trim();
|
||||
|
||||
// quoted values
|
||||
if ('"' == val[0]) {
|
||||
val = val.slice(1, -1);
|
||||
}
|
||||
|
||||
// only assign once
|
||||
if (undefined == obj[key]) {
|
||||
obj[key] = tryDecode(val, dec);
|
||||
}
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize data into a cookie header.
|
||||
*
|
||||
* Serialize the a name value pair into a cookie string suitable for
|
||||
* http headers. An optional options object specified cookie parameters.
|
||||
*
|
||||
* serialize('foo', 'bar', { httpOnly: true })
|
||||
* => "foo=bar; httpOnly"
|
||||
*
|
||||
* @param {string} name
|
||||
* @param {string} val
|
||||
* @param {object} [options]
|
||||
* @return {string}
|
||||
* @public
|
||||
*/
|
||||
|
||||
function serialize(name, val, options) {
|
||||
var opt = options || {};
|
||||
var enc = opt.encode || encode;
|
||||
|
||||
if (typeof enc !== 'function') {
|
||||
throw new TypeError('option encode is invalid');
|
||||
}
|
||||
|
||||
if (!fieldContentRegExp.test(name)) {
|
||||
throw new TypeError('argument name is invalid');
|
||||
}
|
||||
|
||||
var value = enc(val);
|
||||
|
||||
if (value && !fieldContentRegExp.test(value)) {
|
||||
throw new TypeError('argument val is invalid');
|
||||
}
|
||||
|
||||
var str = name + '=' + value;
|
||||
|
||||
if (null != opt.maxAge) {
|
||||
var maxAge = opt.maxAge - 0;
|
||||
if (isNaN(maxAge)) throw new Error('maxAge should be a Number');
|
||||
str += '; Max-Age=' + Math.floor(maxAge);
|
||||
}
|
||||
|
||||
if (opt.domain) {
|
||||
if (!fieldContentRegExp.test(opt.domain)) {
|
||||
throw new TypeError('option domain is invalid');
|
||||
}
|
||||
|
||||
str += '; Domain=' + opt.domain;
|
||||
}
|
||||
|
||||
if (opt.path) {
|
||||
if (!fieldContentRegExp.test(opt.path)) {
|
||||
throw new TypeError('option path is invalid');
|
||||
}
|
||||
|
||||
str += '; Path=' + opt.path;
|
||||
}
|
||||
|
||||
if (opt.expires) {
|
||||
if (typeof opt.expires.toUTCString !== 'function') {
|
||||
throw new TypeError('option expires is invalid');
|
||||
}
|
||||
|
||||
str += '; Expires=' + opt.expires.toUTCString();
|
||||
}
|
||||
|
||||
if (opt.httpOnly) {
|
||||
str += '; HttpOnly';
|
||||
}
|
||||
|
||||
if (opt.secure) {
|
||||
str += '; Secure';
|
||||
}
|
||||
|
||||
if (opt.sameSite) {
|
||||
var sameSite = typeof opt.sameSite === 'string'
|
||||
? opt.sameSite.toLowerCase() : opt.sameSite;
|
||||
|
||||
switch (sameSite) {
|
||||
case true:
|
||||
str += '; SameSite=Strict';
|
||||
break;
|
||||
case 'lax':
|
||||
str += '; SameSite=Lax';
|
||||
break;
|
||||
case 'strict':
|
||||
str += '; SameSite=Strict';
|
||||
break;
|
||||
default:
|
||||
throw new TypeError('option sameSite is invalid');
|
||||
}
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
/**
|
||||
* Try decoding a string using a decoding function.
|
||||
*
|
||||
* @param {string} str
|
||||
* @param {function} decode
|
||||
* @private
|
||||
*/
|
||||
|
||||
function tryDecode(str, decode) {
|
||||
try {
|
||||
return decode(str);
|
||||
} catch (e) {
|
||||
return str;
|
||||
}
|
||||
}
|
33
node_modules/socketio/node_modules/cookie/package.json
generated
vendored
Normal file
33
node_modules/socketio/node_modules/cookie/package.json
generated
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
{
|
||||
"name": "cookie",
|
||||
"description": "HTTP server cookie parsing and serialization",
|
||||
"version": "0.3.1",
|
||||
"author": "Roman Shtylman <shtylman@gmail.com>",
|
||||
"contributors": [
|
||||
"Douglas Christopher Wilson <doug@somethingdoug.com>"
|
||||
],
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"cookie",
|
||||
"cookies"
|
||||
],
|
||||
"repository": "jshttp/cookie",
|
||||
"devDependencies": {
|
||||
"istanbul": "0.4.3",
|
||||
"mocha": "1.21.5"
|
||||
},
|
||||
"files": [
|
||||
"HISTORY.md",
|
||||
"LICENSE",
|
||||
"README.md",
|
||||
"index.js"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha --reporter spec --bail --check-leaks test/",
|
||||
"test-ci": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/",
|
||||
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/"
|
||||
}
|
||||
}
|
3
node_modules/socketio/node_modules/debug/.jshintrc
generated
vendored
Normal file
3
node_modules/socketio/node_modules/debug/.jshintrc
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"laxbreak": true
|
||||
}
|
7
node_modules/socketio/node_modules/debug/.npmignore
generated
vendored
Normal file
7
node_modules/socketio/node_modules/debug/.npmignore
generated
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
support
|
||||
test
|
||||
examples
|
||||
example
|
||||
*.sock
|
||||
dist
|
||||
yarn.lock
|
235
node_modules/socketio/node_modules/debug/CHANGELOG.md
generated
vendored
Normal file
235
node_modules/socketio/node_modules/debug/CHANGELOG.md
generated
vendored
Normal file
@ -0,0 +1,235 @@
|
||||
2.3.3 / 2016-11-09
|
||||
==================
|
||||
|
||||
* Fix: Catch `JSON.stringify()` errors (#195, Jovan Alleyne)
|
||||
* Fix: Returning `localStorage` saved values (#331, Levi Thomason)
|
||||
* Improvement: Don't create an empty object when no `process` (Nathan Rajlich)
|
||||
|
||||
2.3.2 / 2016-11-09
|
||||
==================
|
||||
|
||||
* Fix: be super-safe in index.js as well (@TooTallNate)
|
||||
* Fix: should check whether process exists (Tom Newby)
|
||||
|
||||
2.3.1 / 2016-11-09
|
||||
==================
|
||||
|
||||
* Fix: Added electron compatibility (#324, @paulcbetts)
|
||||
* Improvement: Added performance optimizations (@tootallnate)
|
||||
* Readme: Corrected PowerShell environment variable example (#252, @gimre)
|
||||
* Misc: Removed yarn lock file from source control (#321, @fengmk2)
|
||||
|
||||
2.3.0 / 2016-11-07
|
||||
==================
|
||||
|
||||
* Fix: Consistent placement of ms diff at end of output (#215, @gorangajic)
|
||||
* Fix: Escaping of regex special characters in namespace strings (#250, @zacronos)
|
||||
* Fix: Fixed bug causing crash on react-native (#282, @vkarpov15)
|
||||
* Feature: Enabled ES6+ compatible import via default export (#212 @bucaran)
|
||||
* Feature: Added %O formatter to reflect Chrome's console.log capability (#279, @oncletom)
|
||||
* Package: Update "ms" to 0.7.2 (#315, @DevSide)
|
||||
* Package: removed superfluous version property from bower.json (#207 @kkirsche)
|
||||
* Readme: fix USE_COLORS to DEBUG_COLORS
|
||||
* Readme: Doc fixes for format string sugar (#269, @mlucool)
|
||||
* Readme: Updated docs for DEBUG_FD and DEBUG_COLORS environment variables (#232, @mattlyons0)
|
||||
* Readme: doc fixes for PowerShell (#271 #243, @exoticknight @unreadable)
|
||||
* Readme: better docs for browser support (#224, @matthewmueller)
|
||||
* Tooling: Added yarn integration for development (#317, @thebigredgeek)
|
||||
* Misc: Renamed History.md to CHANGELOG.md (@thebigredgeek)
|
||||
* Misc: Added license file (#226 #274, @CantemoInternal @sdaitzman)
|
||||
* Misc: Updated contributors (@thebigredgeek)
|
||||
|
||||
2.2.0 / 2015-05-09
|
||||
==================
|
||||
|
||||
* package: update "ms" to v0.7.1 (#202, @dougwilson)
|
||||
* README: add logging to file example (#193, @DanielOchoa)
|
||||
* README: fixed a typo (#191, @amir-s)
|
||||
* browser: expose `storage` (#190, @stephenmathieson)
|
||||
* Makefile: add a `distclean` target (#189, @stephenmathieson)
|
||||
|
||||
2.1.3 / 2015-03-13
|
||||
==================
|
||||
|
||||
* Updated stdout/stderr example (#186)
|
||||
* Updated example/stdout.js to match debug current behaviour
|
||||
* Renamed example/stderr.js to stdout.js
|
||||
* Update Readme.md (#184)
|
||||
* replace high intensity foreground color for bold (#182, #183)
|
||||
|
||||
2.1.2 / 2015-03-01
|
||||
==================
|
||||
|
||||
* dist: recompile
|
||||
* update "ms" to v0.7.0
|
||||
* package: update "browserify" to v9.0.3
|
||||
* component: fix "ms.js" repo location
|
||||
* changed bower package name
|
||||
* updated documentation about using debug in a browser
|
||||
* fix: security error on safari (#167, #168, @yields)
|
||||
|
||||
2.1.1 / 2014-12-29
|
||||
==================
|
||||
|
||||
* browser: use `typeof` to check for `console` existence
|
||||
* browser: check for `console.log` truthiness (fix IE 8/9)
|
||||
* browser: add support for Chrome apps
|
||||
* Readme: added Windows usage remarks
|
||||
* Add `bower.json` to properly support bower install
|
||||
|
||||
2.1.0 / 2014-10-15
|
||||
==================
|
||||
|
||||
* node: implement `DEBUG_FD` env variable support
|
||||
* package: update "browserify" to v6.1.0
|
||||
* package: add "license" field to package.json (#135, @panuhorsmalahti)
|
||||
|
||||
2.0.0 / 2014-09-01
|
||||
==================
|
||||
|
||||
* package: update "browserify" to v5.11.0
|
||||
* node: use stderr rather than stdout for logging (#29, @stephenmathieson)
|
||||
|
||||
1.0.4 / 2014-07-15
|
||||
==================
|
||||
|
||||
* dist: recompile
|
||||
* example: remove `console.info()` log usage
|
||||
* example: add "Content-Type" UTF-8 header to browser example
|
||||
* browser: place %c marker after the space character
|
||||
* browser: reset the "content" color via `color: inherit`
|
||||
* browser: add colors support for Firefox >= v31
|
||||
* debug: prefer an instance `log()` function over the global one (#119)
|
||||
* Readme: update documentation about styled console logs for FF v31 (#116, @wryk)
|
||||
|
||||
1.0.3 / 2014-07-09
|
||||
==================
|
||||
|
||||
* Add support for multiple wildcards in namespaces (#122, @seegno)
|
||||
* browser: fix lint
|
||||
|
||||
1.0.2 / 2014-06-10
|
||||
==================
|
||||
|
||||
* browser: update color palette (#113, @gscottolson)
|
||||
* common: make console logging function configurable (#108, @timoxley)
|
||||
* node: fix %o colors on old node <= 0.8.x
|
||||
* Makefile: find node path using shell/which (#109, @timoxley)
|
||||
|
||||
1.0.1 / 2014-06-06
|
||||
==================
|
||||
|
||||
* browser: use `removeItem()` to clear localStorage
|
||||
* browser, node: don't set DEBUG if namespaces is undefined (#107, @leedm777)
|
||||
* package: add "contributors" section
|
||||
* node: fix comment typo
|
||||
* README: list authors
|
||||
|
||||
1.0.0 / 2014-06-04
|
||||
==================
|
||||
|
||||
* make ms diff be global, not be scope
|
||||
* debug: ignore empty strings in enable()
|
||||
* node: make DEBUG_COLORS able to disable coloring
|
||||
* *: export the `colors` array
|
||||
* npmignore: don't publish the `dist` dir
|
||||
* Makefile: refactor to use browserify
|
||||
* package: add "browserify" as a dev dependency
|
||||
* Readme: add Web Inspector Colors section
|
||||
* node: reset terminal color for the debug content
|
||||
* node: map "%o" to `util.inspect()`
|
||||
* browser: map "%j" to `JSON.stringify()`
|
||||
* debug: add custom "formatters"
|
||||
* debug: use "ms" module for humanizing the diff
|
||||
* Readme: add "bash" syntax highlighting
|
||||
* browser: add Firebug color support
|
||||
* browser: add colors for WebKit browsers
|
||||
* node: apply log to `console`
|
||||
* rewrite: abstract common logic for Node & browsers
|
||||
* add .jshintrc file
|
||||
|
||||
0.8.1 / 2014-04-14
|
||||
==================
|
||||
|
||||
* package: re-add the "component" section
|
||||
|
||||
0.8.0 / 2014-03-30
|
||||
==================
|
||||
|
||||
* add `enable()` method for nodejs. Closes #27
|
||||
* change from stderr to stdout
|
||||
* remove unnecessary index.js file
|
||||
|
||||
0.7.4 / 2013-11-13
|
||||
==================
|
||||
|
||||
* remove "browserify" key from package.json (fixes something in browserify)
|
||||
|
||||
0.7.3 / 2013-10-30
|
||||
==================
|
||||
|
||||
* fix: catch localStorage security error when cookies are blocked (Chrome)
|
||||
* add debug(err) support. Closes #46
|
||||
* add .browser prop to package.json. Closes #42
|
||||
|
||||
0.7.2 / 2013-02-06
|
||||
==================
|
||||
|
||||
* fix package.json
|
||||
* fix: Mobile Safari (private mode) is broken with debug
|
||||
* fix: Use unicode to send escape character to shell instead of octal to work with strict mode javascript
|
||||
|
||||
0.7.1 / 2013-02-05
|
||||
==================
|
||||
|
||||
* add repository URL to package.json
|
||||
* add DEBUG_COLORED to force colored output
|
||||
* add browserify support
|
||||
* fix component. Closes #24
|
||||
|
||||
0.7.0 / 2012-05-04
|
||||
==================
|
||||
|
||||
* Added .component to package.json
|
||||
* Added debug.component.js build
|
||||
|
||||
0.6.0 / 2012-03-16
|
||||
==================
|
||||
|
||||
* Added support for "-" prefix in DEBUG [Vinay Pulim]
|
||||
* Added `.enabled` flag to the node version [TooTallNate]
|
||||
|
||||
0.5.0 / 2012-02-02
|
||||
==================
|
||||
|
||||
* Added: humanize diffs. Closes #8
|
||||
* Added `debug.disable()` to the CS variant
|
||||
* Removed padding. Closes #10
|
||||
* Fixed: persist client-side variant again. Closes #9
|
||||
|
||||
0.4.0 / 2012-02-01
|
||||
==================
|
||||
|
||||
* Added browser variant support for older browsers [TooTallNate]
|
||||
* Added `debug.enable('project:*')` to browser variant [TooTallNate]
|
||||
* Added padding to diff (moved it to the right)
|
||||
|
||||
0.3.0 / 2012-01-26
|
||||
==================
|
||||
|
||||
* Added millisecond diff when isatty, otherwise UTC string
|
||||
|
||||
0.2.0 / 2012-01-22
|
||||
==================
|
||||
|
||||
* Added wildcard support
|
||||
|
||||
0.1.0 / 2011-12-02
|
||||
==================
|
||||
|
||||
* Added: remove colors unless stderr isatty [TooTallNate]
|
||||
|
||||
0.0.1 / 2010-01-03
|
||||
==================
|
||||
|
||||
* Initial release
|
19
node_modules/socketio/node_modules/debug/LICENSE
generated
vendored
Normal file
19
node_modules/socketio/node_modules/debug/LICENSE
generated
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2014 TJ Holowaychuk <tj@vision-media.ca>
|
||||
|
||||
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.
|
||||
|
37
node_modules/socketio/node_modules/debug/Makefile
generated
vendored
Normal file
37
node_modules/socketio/node_modules/debug/Makefile
generated
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
|
||||
# get Makefile directory name: http://stackoverflow.com/a/5982798/376773
|
||||
THIS_MAKEFILE_PATH:=$(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))
|
||||
THIS_DIR:=$(shell cd $(dir $(THIS_MAKEFILE_PATH));pwd)
|
||||
|
||||
# BIN directory
|
||||
BIN := $(THIS_DIR)/node_modules/.bin
|
||||
|
||||
# applications
|
||||
NODE ?= $(shell which node)
|
||||
YARN ?= $(shell which yarn)
|
||||
PKG ?= $(if $(YARN),$(YARN),$(NODE) $(shell which npm))
|
||||
BROWSERIFY ?= $(NODE) $(BIN)/browserify
|
||||
|
||||
all: dist/debug.js
|
||||
|
||||
install: node_modules
|
||||
|
||||
clean:
|
||||
@rm -rf dist
|
||||
|
||||
dist:
|
||||
@mkdir -p $@
|
||||
|
||||
dist/debug.js: node_modules browser.js debug.js dist
|
||||
@$(BROWSERIFY) \
|
||||
--standalone debug \
|
||||
. > $@
|
||||
|
||||
distclean: clean
|
||||
@rm -rf node_modules
|
||||
|
||||
node_modules: package.json
|
||||
@NODE_ENV= $(PKG) install
|
||||
@touch node_modules
|
||||
|
||||
.PHONY: all install clean distclean
|
199
node_modules/socketio/node_modules/debug/Readme.md
generated
vendored
Normal file
199
node_modules/socketio/node_modules/debug/Readme.md
generated
vendored
Normal file
@ -0,0 +1,199 @@
|
||||
# debug
|
||||
|
||||
tiny node.js debugging utility modelled after node core's debugging technique.
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
$ npm install debug
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
With `debug` you simply invoke the exported function to generate your debug function, passing it a name which will determine if a noop function is returned, or a decorated `console.error`, so all of the `console` [format string goodies](https://developer.chrome.com/devtools/docs/console-api#consolelogobject-object) you're used to work fine. A unique color is selected per-function for visibility.
|
||||
|
||||
Example _app.js_:
|
||||
|
||||
```js
|
||||
var debug = require('debug')('http')
|
||||
, http = require('http')
|
||||
, name = 'My App';
|
||||
|
||||
// fake app
|
||||
|
||||
debug('booting %s', name);
|
||||
|
||||
http.createServer(function(req, res){
|
||||
debug(req.method + ' ' + req.url);
|
||||
res.end('hello\n');
|
||||
}).listen(3000, function(){
|
||||
debug('listening');
|
||||
});
|
||||
|
||||
// fake worker of some kind
|
||||
|
||||
require('./worker');
|
||||
```
|
||||
|
||||
Example _worker.js_:
|
||||
|
||||
```js
|
||||
var debug = require('debug')('worker');
|
||||
|
||||
setInterval(function(){
|
||||
debug('doing some work');
|
||||
}, 1000);
|
||||
```
|
||||
|
||||
The __DEBUG__ environment variable is then used to enable these based on space or comma-delimited names. Here are some examples:
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
#### Windows note
|
||||
|
||||
On Windows the environment variable is set using the `set` command.
|
||||
|
||||
```cmd
|
||||
set DEBUG=*,-not_this
|
||||
```
|
||||
|
||||
Note that PowerShell using different syntax to set environment variables.
|
||||
|
||||
```cmd
|
||||
$env:DEBUG = "*,-not_this"
|
||||
```
|
||||
|
||||
Then, run the program to be debugged as usual.
|
||||
|
||||
## Millisecond diff
|
||||
|
||||
When actively developing an application it can be useful to see when the time spent between one `debug()` call and the next. Suppose for example you invoke `debug()` before requesting a resource, and after as well, the "+NNNms" will show you how much time was spent between calls.
|
||||
|
||||

|
||||
|
||||
When stdout is not a TTY, `Date#toUTCString()` is used, making it more useful for logging the debug information as shown below:
|
||||
|
||||

|
||||
|
||||
## Conventions
|
||||
|
||||
If you're using this in one or more of your libraries, you _should_ use the name of your library so that developers may toggle debugging as desired without guessing names. If you have more than one debuggers you _should_ prefix them with your library name and use ":" to separate features. For example "bodyParser" from Connect would then be "connect:bodyParser".
|
||||
|
||||
## Wildcards
|
||||
|
||||
The `*` character may be used as a wildcard. Suppose for example your library has debuggers named "connect:bodyParser", "connect:compress", "connect:session", instead of listing all three with `DEBUG=connect:bodyParser,connect:compress,connect:session`, you may simply do `DEBUG=connect:*`, or to run everything using this module simply use `DEBUG=*`.
|
||||
|
||||
You can also exclude specific debuggers by prefixing them with a "-" character. For example, `DEBUG=*,-connect:*` would include all debuggers except those starting with "connect:".
|
||||
|
||||
## Browser support
|
||||
|
||||
Debug works in the browser as well, currently persisted by `localStorage`. Consider the situation shown below where you have `worker:a` and `worker:b`, and wish to debug both. You can enable this using `localStorage.debug`:
|
||||
|
||||
```js
|
||||
localStorage.debug = 'worker:*'
|
||||
```
|
||||
|
||||
And then refresh the page.
|
||||
|
||||
```js
|
||||
a = debug('worker:a');
|
||||
b = debug('worker:b');
|
||||
|
||||
setInterval(function(){
|
||||
a('doing some work');
|
||||
}, 1000);
|
||||
|
||||
setInterval(function(){
|
||||
b('doing some work');
|
||||
}, 1200);
|
||||
```
|
||||
|
||||
#### Web Inspector Colors
|
||||
|
||||
Colors are also enabled on "Web Inspectors" that understand the `%c` formatting
|
||||
option. These are WebKit web inspectors, Firefox ([since version
|
||||
31](https://hacks.mozilla.org/2014/05/editable-box-model-multiple-selection-sublime-text-keys-much-more-firefox-developer-tools-episode-31/))
|
||||
and the Firebug plugin for Firefox (any version).
|
||||
|
||||
Colored output looks something like:
|
||||
|
||||

|
||||
|
||||
## Output streams
|
||||
|
||||
|
||||
### stderr vs stdout
|
||||
By default `debug` will log to stderr, however this can be changed by setting the environment variable `DEBUG_FD` to `1` for stdout and `2` for stderr (the default value).
|
||||
|
||||
You can also set an alternative logging method per-namespace by overriding the `log` method on a per-namespace or globally:
|
||||
|
||||
Example _stdout.js_:
|
||||
|
||||
```js
|
||||
var debug = require('debug');
|
||||
var error = debug('app:error');
|
||||
|
||||
// by default stderr is used
|
||||
error('goes to stderr!');
|
||||
|
||||
var log = debug('app:log');
|
||||
// set this namespace to log via console.log
|
||||
log.log = console.log.bind(console); // don't forget to bind to console!
|
||||
log('goes to stdout');
|
||||
error('still goes to stderr!');
|
||||
|
||||
// set all output to go via console.info
|
||||
// overrides all per-namespace log settings
|
||||
debug.log = console.info.bind(console);
|
||||
error('now goes to stdout via console.info');
|
||||
log('still goes to stdout, but via console.info now');
|
||||
```
|
||||
|
||||
### Save debug output to a file
|
||||
|
||||
You can save all debug statements to a file by piping them.
|
||||
|
||||
Example:
|
||||
|
||||
```bash
|
||||
$ DEBUG_FD=3 node your-app.js 3> whatever.log
|
||||
```
|
||||
|
||||
### Terminal colors
|
||||
|
||||
By default colors will only be used in a TTY. However this can be overridden by setting the environment variable `DEBUG_COLORS` to `1`.
|
||||
|
||||
Note: Certain IDEs (such as WebStorm) don't support colors on stderr. In these cases you must set `DEBUG_COLORS` to `1` and additionally change `DEBUG_FD` to `1`.
|
||||
|
||||
## Authors
|
||||
|
||||
- TJ Holowaychuk
|
||||
- Nathan Rajlich
|
||||
- Andrew Rhyne
|
||||
|
||||
## License
|
||||
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2014-2016 TJ Holowaychuk <tj@vision-media.ca>
|
||||
|
||||
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.
|
29
node_modules/socketio/node_modules/debug/bower.json
generated
vendored
Normal file
29
node_modules/socketio/node_modules/debug/bower.json
generated
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
{
|
||||
"name": "visionmedia-debug",
|
||||
"main": "dist/debug.js",
|
||||
"homepage": "https://github.com/visionmedia/debug",
|
||||
"authors": [
|
||||
"TJ Holowaychuk <tj@vision-media.ca>",
|
||||
"Nathan Rajlich <nathan@tootallnate.net> (http://n8.io)",
|
||||
"Andrew Rhyne <rhyneandrew@gmail.com>"
|
||||
],
|
||||
"description": "visionmedia-debug",
|
||||
"moduleType": [
|
||||
"amd",
|
||||
"es6",
|
||||
"globals",
|
||||
"node"
|
||||
],
|
||||
"keywords": [
|
||||
"visionmedia",
|
||||
"debug"
|
||||
],
|
||||
"license": "MIT",
|
||||
"ignore": [
|
||||
"**/.*",
|
||||
"node_modules",
|
||||
"bower_components",
|
||||
"test",
|
||||
"tests"
|
||||
]
|
||||
}
|
177
node_modules/socketio/node_modules/debug/browser.js
generated
vendored
Normal file
177
node_modules/socketio/node_modules/debug/browser.js
generated
vendored
Normal file
@ -0,0 +1,177 @@
|
||||
|
||||
/**
|
||||
* This is the web browser implementation of `debug()`.
|
||||
*
|
||||
* Expose `debug()` as the module.
|
||||
*/
|
||||
|
||||
exports = module.exports = require('./debug');
|
||||
exports.log = log;
|
||||
exports.formatArgs = formatArgs;
|
||||
exports.save = save;
|
||||
exports.load = load;
|
||||
exports.useColors = useColors;
|
||||
exports.storage = 'undefined' != typeof chrome
|
||||
&& 'undefined' != typeof chrome.storage
|
||||
? chrome.storage.local
|
||||
: localstorage();
|
||||
|
||||
/**
|
||||
* Colors.
|
||||
*/
|
||||
|
||||
exports.colors = [
|
||||
'lightseagreen',
|
||||
'forestgreen',
|
||||
'goldenrod',
|
||||
'dodgerblue',
|
||||
'darkorchid',
|
||||
'crimson'
|
||||
];
|
||||
|
||||
/**
|
||||
* Currently only WebKit-based Web Inspectors, Firefox >= v31,
|
||||
* and the Firebug extension (any Firefox version) are known
|
||||
* to support "%c" CSS customizations.
|
||||
*
|
||||
* TODO: add a `localStorage` variable to explicitly enable/disable colors
|
||||
*/
|
||||
|
||||
function useColors() {
|
||||
// is webkit? http://stackoverflow.com/a/16459606/376773
|
||||
// document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
|
||||
return (typeof document !== 'undefined' && 'WebkitAppearance' in document.documentElement.style) ||
|
||||
// is firebug? http://stackoverflow.com/a/398120/376773
|
||||
(window.console && (console.firebug || (console.exception && console.table))) ||
|
||||
// is firefox >= v31?
|
||||
// https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
|
||||
(navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31);
|
||||
}
|
||||
|
||||
/**
|
||||
* Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
|
||||
*/
|
||||
|
||||
exports.formatters.j = function(v) {
|
||||
try {
|
||||
return JSON.stringify(v);
|
||||
} catch (err) {
|
||||
return '[UnexpectedJSONParseError]: ' + err.message;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Colorize log arguments if enabled.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function formatArgs() {
|
||||
var args = arguments;
|
||||
var useColors = this.useColors;
|
||||
|
||||
args[0] = (useColors ? '%c' : '')
|
||||
+ this.namespace
|
||||
+ (useColors ? ' %c' : ' ')
|
||||
+ args[0]
|
||||
+ (useColors ? '%c ' : ' ')
|
||||
+ '+' + exports.humanize(this.diff);
|
||||
|
||||
if (!useColors) return args;
|
||||
|
||||
var c = 'color: ' + this.color;
|
||||
args = [args[0], c, 'color: inherit'].concat(Array.prototype.slice.call(args, 1));
|
||||
|
||||
// the final "%c" is somewhat tricky, because there could be other
|
||||
// arguments passed either before or after the %c, so we need to
|
||||
// figure out the correct index to insert the CSS into
|
||||
var index = 0;
|
||||
var lastC = 0;
|
||||
args[0].replace(/%[a-z%]/g, function(match) {
|
||||
if ('%%' === match) return;
|
||||
index++;
|
||||
if ('%c' === match) {
|
||||
// we only are interested in the *last* %c
|
||||
// (the user may have provided their own)
|
||||
lastC = index;
|
||||
}
|
||||
});
|
||||
|
||||
args.splice(lastC, 0, c);
|
||||
return args;
|
||||
}
|
||||
|
||||
/**
|
||||
* Invokes `console.log()` when available.
|
||||
* No-op when `console.log` is not a "function".
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function log() {
|
||||
// this hackery is required for IE8/9, where
|
||||
// the `console.log` function doesn't have 'apply'
|
||||
return 'object' === typeof console
|
||||
&& console.log
|
||||
&& Function.prototype.apply.call(console.log, console, arguments);
|
||||
}
|
||||
|
||||
/**
|
||||
* Save `namespaces`.
|
||||
*
|
||||
* @param {String} namespaces
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function save(namespaces) {
|
||||
try {
|
||||
if (null == namespaces) {
|
||||
exports.storage.removeItem('debug');
|
||||
} else {
|
||||
exports.storage.debug = namespaces;
|
||||
}
|
||||
} catch(e) {}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load `namespaces`.
|
||||
*
|
||||
* @return {String} returns the previously persisted debug modes
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function load() {
|
||||
var r;
|
||||
try {
|
||||
return exports.storage.debug;
|
||||
} catch(e) {}
|
||||
|
||||
// If debug isn't set in LS, and we're in Electron, try to load $DEBUG
|
||||
if (typeof process !== 'undefined' && 'env' in process) {
|
||||
return process.env.DEBUG;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable namespaces listed in `localStorage.debug` initially.
|
||||
*/
|
||||
|
||||
exports.enable(load());
|
||||
|
||||
/**
|
||||
* Localstorage attempts to return the localstorage.
|
||||
*
|
||||
* This is necessary because safari throws
|
||||
* when a user disables cookies/localstorage
|
||||
* and you attempt to access it.
|
||||
*
|
||||
* @return {LocalStorage}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function localstorage(){
|
||||
try {
|
||||
return window.localStorage;
|
||||
} catch (e) {}
|
||||
}
|
19
node_modules/socketio/node_modules/debug/component.json
generated
vendored
Normal file
19
node_modules/socketio/node_modules/debug/component.json
generated
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
{
|
||||
"name": "debug",
|
||||
"repo": "visionmedia/debug",
|
||||
"description": "small debugging utility",
|
||||
"version": "2.3.3",
|
||||
"keywords": [
|
||||
"debug",
|
||||
"log",
|
||||
"debugger"
|
||||
],
|
||||
"main": "browser.js",
|
||||
"scripts": [
|
||||
"browser.js",
|
||||
"debug.js"
|
||||
],
|
||||
"dependencies": {
|
||||
"rauchg/ms.js": "0.7.1"
|
||||
}
|
||||
}
|
200
node_modules/socketio/node_modules/debug/debug.js
generated
vendored
Normal file
200
node_modules/socketio/node_modules/debug/debug.js
generated
vendored
Normal file
@ -0,0 +1,200 @@
|
||||
|
||||
/**
|
||||
* This is the common logic for both the Node.js and web browser
|
||||
* implementations of `debug()`.
|
||||
*
|
||||
* Expose `debug()` as the module.
|
||||
*/
|
||||
|
||||
exports = module.exports = debug.debug = debug;
|
||||
exports.coerce = coerce;
|
||||
exports.disable = disable;
|
||||
exports.enable = enable;
|
||||
exports.enabled = enabled;
|
||||
exports.humanize = require('ms');
|
||||
|
||||
/**
|
||||
* The currently active debug mode names, and names to skip.
|
||||
*/
|
||||
|
||||
exports.names = [];
|
||||
exports.skips = [];
|
||||
|
||||
/**
|
||||
* Map of special "%n" handling functions, for the debug "format" argument.
|
||||
*
|
||||
* Valid key names are a single, lowercased letter, i.e. "n".
|
||||
*/
|
||||
|
||||
exports.formatters = {};
|
||||
|
||||
/**
|
||||
* Previously assigned color.
|
||||
*/
|
||||
|
||||
var prevColor = 0;
|
||||
|
||||
/**
|
||||
* Previous log timestamp.
|
||||
*/
|
||||
|
||||
var prevTime;
|
||||
|
||||
/**
|
||||
* Select a color.
|
||||
*
|
||||
* @return {Number}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function selectColor() {
|
||||
return exports.colors[prevColor++ % exports.colors.length];
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a debugger with the given `namespace`.
|
||||
*
|
||||
* @param {String} namespace
|
||||
* @return {Function}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function debug(namespace) {
|
||||
|
||||
// define the `disabled` version
|
||||
function disabled() {
|
||||
}
|
||||
disabled.enabled = false;
|
||||
|
||||
// define the `enabled` version
|
||||
function enabled() {
|
||||
|
||||
var self = enabled;
|
||||
|
||||
// set `diff` timestamp
|
||||
var curr = +new Date();
|
||||
var ms = curr - (prevTime || curr);
|
||||
self.diff = ms;
|
||||
self.prev = prevTime;
|
||||
self.curr = curr;
|
||||
prevTime = curr;
|
||||
|
||||
// add the `color` if not set
|
||||
if (null == self.useColors) self.useColors = exports.useColors();
|
||||
if (null == self.color && self.useColors) self.color = selectColor();
|
||||
|
||||
var args = new Array(arguments.length);
|
||||
for (var i = 0; i < args.length; i++) {
|
||||
args[i] = arguments[i];
|
||||
}
|
||||
|
||||
args[0] = exports.coerce(args[0]);
|
||||
|
||||
if ('string' !== typeof args[0]) {
|
||||
// anything else let's inspect with %o
|
||||
args = ['%o'].concat(args);
|
||||
}
|
||||
|
||||
// apply any `formatters` transformations
|
||||
var index = 0;
|
||||
args[0] = args[0].replace(/%([a-z%])/g, function(match, format) {
|
||||
// if we encounter an escaped % then don't increase the array index
|
||||
if (match === '%%') return match;
|
||||
index++;
|
||||
var formatter = exports.formatters[format];
|
||||
if ('function' === typeof formatter) {
|
||||
var val = args[index];
|
||||
match = formatter.call(self, val);
|
||||
|
||||
// now we need to remove `args[index]` since it's inlined in the `format`
|
||||
args.splice(index, 1);
|
||||
index--;
|
||||
}
|
||||
return match;
|
||||
});
|
||||
|
||||
// apply env-specific formatting
|
||||
args = exports.formatArgs.apply(self, args);
|
||||
|
||||
var logFn = enabled.log || exports.log || console.log.bind(console);
|
||||
logFn.apply(self, args);
|
||||
}
|
||||
enabled.enabled = true;
|
||||
|
||||
var fn = exports.enabled(namespace) ? enabled : disabled;
|
||||
|
||||
fn.namespace = namespace;
|
||||
|
||||
return fn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables a debug mode by namespaces. This can include modes
|
||||
* separated by a colon and wildcards.
|
||||
*
|
||||
* @param {String} namespaces
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function enable(namespaces) {
|
||||
exports.save(namespaces);
|
||||
|
||||
var split = (namespaces || '').split(/[\s,]+/);
|
||||
var len = split.length;
|
||||
|
||||
for (var i = 0; i < len; i++) {
|
||||
if (!split[i]) continue; // ignore empty strings
|
||||
namespaces = split[i].replace(/[\\^$+?.()|[\]{}]/g, '\\$&').replace(/\*/g, '.*?');
|
||||
if (namespaces[0] === '-') {
|
||||
exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));
|
||||
} else {
|
||||
exports.names.push(new RegExp('^' + namespaces + '$'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable debug output.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function disable() {
|
||||
exports.enable('');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the given mode name is enabled, false otherwise.
|
||||
*
|
||||
* @param {String} name
|
||||
* @return {Boolean}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function enabled(name) {
|
||||
var i, len;
|
||||
for (i = 0, len = exports.skips.length; i < len; i++) {
|
||||
if (exports.skips[i].test(name)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
for (i = 0, len = exports.names.length; i < len; i++) {
|
||||
if (exports.names[i].test(name)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Coerce `val`.
|
||||
*
|
||||
* @param {Mixed} val
|
||||
* @return {Mixed}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function coerce(val) {
|
||||
if (val instanceof Error) return val.stack || val.message;
|
||||
return val;
|
||||
}
|
10
node_modules/socketio/node_modules/debug/index.js
generated
vendored
Normal file
10
node_modules/socketio/node_modules/debug/index.js
generated
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
/**
|
||||
* Detect Electron renderer process, which is node, but we should
|
||||
* treat as a browser.
|
||||
*/
|
||||
|
||||
if (typeof process !== 'undefined' && process.type === 'renderer') {
|
||||
module.exports = require('./browser.js');
|
||||
} else {
|
||||
module.exports = require('./node.js');
|
||||
}
|
213
node_modules/socketio/node_modules/debug/node.js
generated
vendored
Normal file
213
node_modules/socketio/node_modules/debug/node.js
generated
vendored
Normal file
@ -0,0 +1,213 @@
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var tty = require('tty');
|
||||
var util = require('util');
|
||||
|
||||
/**
|
||||
* This is the Node.js implementation of `debug()`.
|
||||
*
|
||||
* Expose `debug()` as the module.
|
||||
*/
|
||||
|
||||
exports = module.exports = require('./debug');
|
||||
exports.log = log;
|
||||
exports.formatArgs = formatArgs;
|
||||
exports.save = save;
|
||||
exports.load = load;
|
||||
exports.useColors = useColors;
|
||||
|
||||
/**
|
||||
* Colors.
|
||||
*/
|
||||
|
||||
exports.colors = [6, 2, 3, 4, 5, 1];
|
||||
|
||||
/**
|
||||
* The file descriptor to write the `debug()` calls to.
|
||||
* Set the `DEBUG_FD` env variable to override with another value. i.e.:
|
||||
*
|
||||
* $ DEBUG_FD=3 node script.js 3>debug.log
|
||||
*/
|
||||
|
||||
var fd = parseInt(process.env.DEBUG_FD, 10) || 2;
|
||||
var stream = 1 === fd ? process.stdout :
|
||||
2 === fd ? process.stderr :
|
||||
createWritableStdioStream(fd);
|
||||
|
||||
/**
|
||||
* Is stdout a TTY? Colored output is enabled when `true`.
|
||||
*/
|
||||
|
||||
function useColors() {
|
||||
var debugColors = (process.env.DEBUG_COLORS || '').trim().toLowerCase();
|
||||
if (0 === debugColors.length) {
|
||||
return tty.isatty(fd);
|
||||
} else {
|
||||
return '0' !== debugColors
|
||||
&& 'no' !== debugColors
|
||||
&& 'false' !== debugColors
|
||||
&& 'disabled' !== debugColors;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Map %o to `util.inspect()`, since Node doesn't do that out of the box.
|
||||
*/
|
||||
|
||||
var inspect = (4 === util.inspect.length ?
|
||||
// node <= 0.8.x
|
||||
function (v, colors) {
|
||||
return util.inspect(v, void 0, void 0, colors);
|
||||
} :
|
||||
// node > 0.8.x
|
||||
function (v, colors) {
|
||||
return util.inspect(v, { colors: colors });
|
||||
}
|
||||
);
|
||||
|
||||
exports.formatters.o = exports.formatters.O = function(v) {
|
||||
return inspect(v, this.useColors)
|
||||
.replace(/\s*\n\s*/g, ' ');
|
||||
};
|
||||
|
||||
/**
|
||||
* Adds ANSI color escape codes if enabled.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function formatArgs() {
|
||||
var len = arguments.length;
|
||||
var args = new Array(len);
|
||||
var useColors = this.useColors;
|
||||
var name = this.namespace;
|
||||
for (var i = 0; i < len; i++) {
|
||||
args[i] = arguments[i];
|
||||
}
|
||||
|
||||
if (useColors) {
|
||||
var c = this.color;
|
||||
|
||||
args[0] = ' \u001b[3' + c + ';1m' + name + ' '
|
||||
+ '\u001b[0m'
|
||||
+ args[0];
|
||||
args.push('\u001b[3' + c + 'm+' + exports.humanize(this.diff) + '\u001b[0m');
|
||||
} else {
|
||||
args[0] = new Date().toUTCString()
|
||||
+ ' ' + name + ' ' + args[0];
|
||||
}
|
||||
return args;
|
||||
}
|
||||
|
||||
/**
|
||||
* Invokes `console.error()` with the specified arguments.
|
||||
*/
|
||||
|
||||
function log() {
|
||||
return stream.write(util.format.apply(this, arguments) + '\n');
|
||||
}
|
||||
|
||||
/**
|
||||
* Save `namespaces`.
|
||||
*
|
||||
* @param {String} namespaces
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function save(namespaces) {
|
||||
if (null == namespaces) {
|
||||
// If you set a process.env field to null or undefined, it gets cast to the
|
||||
// string 'null' or 'undefined'. Just delete instead.
|
||||
delete process.env.DEBUG;
|
||||
} else {
|
||||
process.env.DEBUG = namespaces;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load `namespaces`.
|
||||
*
|
||||
* @return {String} returns the previously persisted debug modes
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function load() {
|
||||
return process.env.DEBUG;
|
||||
}
|
||||
|
||||
/**
|
||||
* Copied from `node/src/node.js`.
|
||||
*
|
||||
* XXX: It's lame that node doesn't expose this API out-of-the-box. It also
|
||||
* relies on the undocumented `tty_wrap.guessHandleType()` which is also lame.
|
||||
*/
|
||||
|
||||
function createWritableStdioStream (fd) {
|
||||
var stream;
|
||||
var tty_wrap = process.binding('tty_wrap');
|
||||
|
||||
// Note stream._type is used for test-module-load-list.js
|
||||
|
||||
switch (tty_wrap.guessHandleType(fd)) {
|
||||
case 'TTY':
|
||||
stream = new tty.WriteStream(fd);
|
||||
stream._type = 'tty';
|
||||
|
||||
// Hack to have stream not keep the event loop alive.
|
||||
// See https://github.com/joyent/node/issues/1726
|
||||
if (stream._handle && stream._handle.unref) {
|
||||
stream._handle.unref();
|
||||
}
|
||||
break;
|
||||
|
||||
case 'FILE':
|
||||
var fs = require('fs');
|
||||
stream = new fs.SyncWriteStream(fd, { autoClose: false });
|
||||
stream._type = 'fs';
|
||||
break;
|
||||
|
||||
case 'PIPE':
|
||||
case 'TCP':
|
||||
var net = require('net');
|
||||
stream = new net.Socket({
|
||||
fd: fd,
|
||||
readable: false,
|
||||
writable: true
|
||||
});
|
||||
|
||||
// FIXME Should probably have an option in net.Socket to create a
|
||||
// stream from an existing fd which is writable only. But for now
|
||||
// we'll just add this hack and set the `readable` member to false.
|
||||
// Test: ./node test/fixtures/echo.js < /etc/passwd
|
||||
stream.readable = false;
|
||||
stream.read = null;
|
||||
stream._type = 'pipe';
|
||||
|
||||
// FIXME Hack to have stream not keep the event loop alive.
|
||||
// See https://github.com/joyent/node/issues/1726
|
||||
if (stream._handle && stream._handle.unref) {
|
||||
stream._handle.unref();
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
// Probably an error on in uv_guess_handle()
|
||||
throw new Error('Implement me. Unknown stream file type!');
|
||||
}
|
||||
|
||||
// For supporting legacy API we put the FD here.
|
||||
stream.fd = fd;
|
||||
|
||||
stream._isStdio = true;
|
||||
|
||||
return stream;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable namespaces listed in `process.env.DEBUG` initially.
|
||||
*/
|
||||
|
||||
exports.enable(load());
|
35
node_modules/socketio/node_modules/debug/package.json
generated
vendored
Normal file
35
node_modules/socketio/node_modules/debug/package.json
generated
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
{
|
||||
"name": "debug",
|
||||
"version": "2.3.3",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/visionmedia/debug.git"
|
||||
},
|
||||
"description": "small debugging utility",
|
||||
"keywords": [
|
||||
"debug",
|
||||
"log",
|
||||
"debugger"
|
||||
],
|
||||
"author": "TJ Holowaychuk <tj@vision-media.ca>",
|
||||
"contributors": [
|
||||
"Nathan Rajlich <nathan@tootallnate.net> (http://n8.io)",
|
||||
"Andrew Rhyne <rhyneandrew@gmail.com>"
|
||||
],
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"ms": "0.7.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"browserify": "9.0.3",
|
||||
"mocha": "*"
|
||||
},
|
||||
"main": "./index.js",
|
||||
"browser": "./browser.js",
|
||||
"component": {
|
||||
"scripts": {
|
||||
"debug/index.js": "browser.js",
|
||||
"debug/debug.js": "debug.js"
|
||||
}
|
||||
}
|
||||
}
|
141
node_modules/socketio/node_modules/engine.io-parser/History.md
generated
vendored
Normal file
141
node_modules/socketio/node_modules/engine.io-parser/History.md
generated
vendored
Normal file
@ -0,0 +1,141 @@
|
||||
|
||||
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
|
22
node_modules/socketio/node_modules/engine.io-parser/LICENSE
generated
vendored
Normal file
22
node_modules/socketio/node_modules/engine.io-parser/LICENSE
generated
vendored
Normal file
@ -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.
|
202
node_modules/socketio/node_modules/engine.io-parser/Readme.md
generated
vendored
Normal file
202
node_modules/socketio/node_modules/engine.io-parser/Readme.md
generated
vendored
Normal file
@ -0,0 +1,202 @@
|
||||
|
||||
# engine.io-parser
|
||||
|
||||
[](http://travis-ci.org/socketio/engine.io-parser)
|
||||
[](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
|
2
node_modules/socketio/node_modules/engine.io-parser/index.js
generated
vendored
Normal file
2
node_modules/socketio/node_modules/engine.io-parser/index.js
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
|
||||
module.exports = require('./lib/');
|
609
node_modules/socketio/node_modules/engine.io-parser/lib/browser.js
generated
vendored
Normal file
609
node_modules/socketio/node_modules/engine.io-parser/lib/browser.js
generated
vendored
Normal file
@ -0,0 +1,609 @@
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var keys = require('./keys');
|
||||
var hasBinary = require('has-binary');
|
||||
var sliceBuffer = require('arraybuffer.slice');
|
||||
var after = require('after');
|
||||
var utf8 = require('wtf-8');
|
||||
|
||||
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 ('function' == typeof supportsBinary) {
|
||||
callback = supportsBinary;
|
||||
supportsBinary = false;
|
||||
}
|
||||
|
||||
if ('function' == typeof utf8encode) {
|
||||
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)) : 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);
|
||||
} 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, true, 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;
|
||||
} else {
|
||||
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, true);
|
||||
|
||||
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 = [];
|
||||
|
||||
var numberTooLong = false;
|
||||
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;
|
||||
|
||||
if (msgLength.length > 310) {
|
||||
numberTooLong = true;
|
||||
break;
|
||||
}
|
||||
|
||||
msgLength += tailArray[i];
|
||||
}
|
||||
|
||||
if(numberTooLong) return callback(err, 0, 1);
|
||||
|
||||
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);
|
||||
});
|
||||
};
|
474
node_modules/socketio/node_modules/engine.io-parser/lib/index.js
generated
vendored
Normal file
474
node_modules/socketio/node_modules/engine.io-parser/lib/index.js
generated
vendored
Normal file
@ -0,0 +1,474 @@
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var utf8 = require('wtf-8');
|
||||
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 ('function' == typeof supportsBinary) {
|
||||
callback = supportsBinary;
|
||||
supportsBinary = null;
|
||||
}
|
||||
|
||||
if ('function' == typeof utf8encode ) {
|
||||
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)) : String(packet.data);
|
||||
}
|
||||
|
||||
return callback('' + encoded);
|
||||
};
|
||||
|
||||
/**
|
||||
* Encode Buffer data
|
||||
*/
|
||||
|
||||
function encodeBuffer(packet, supportsBinary, callback) {
|
||||
var data = packet.data;
|
||||
if (!supportsBinary) {
|
||||
return exports.encodeBase64Packet(packet, callback);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
// String data
|
||||
if (typeof data == 'string') {
|
||||
if (data.charAt(0) == 'b') {
|
||||
return exports.decodeBase64Packet(data.substr(1), binaryType);
|
||||
}
|
||||
|
||||
var type = data.charAt(0);
|
||||
|
||||
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);
|
||||
var type = intArray[0];
|
||||
return { type: packetslist[type], data: intArray.buffer.slice(1) };
|
||||
}
|
||||
|
||||
if (data instanceof ArrayBuffer) {
|
||||
data = arrayBufferToBuffer(data);
|
||||
}
|
||||
var type = data[0];
|
||||
return { type: packetslist[type], data: data.slice(1) };
|
||||
};
|
||||
|
||||
function tryDecode(data) {
|
||||
try {
|
||||
data = utf8.decode(data);
|
||||
} 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) {
|
||||
return exports.encodePayloadAsBinary(packets, callback);
|
||||
}
|
||||
|
||||
if (!packets.length) {
|
||||
return callback('0:');
|
||||
}
|
||||
|
||||
function setLengthHeader(message) {
|
||||
return message.length + ':' + message;
|
||||
}
|
||||
|
||||
function encodeOne(packet, doneCallback) {
|
||||
exports.encodePacket(packet, supportsBinary, true, 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 ('string' != typeof data) {
|
||||
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;
|
||||
} else {
|
||||
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, true);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* Converts a buffer to a utf8.js encoded string
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function bufferToString(buffer) {
|
||||
var str = '';
|
||||
for (var i = 0; i < buffer.length; 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; i < string.length; 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));
|
||||
}
|
||||
|
||||
function encodeOne(p, doneCallback) {
|
||||
exports.encodePacket(p, true, true, function(packet) {
|
||||
|
||||
if (typeof packet === 'string') {
|
||||
var encodingLength = '' + packet.length;
|
||||
var 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)]));
|
||||
}
|
||||
|
||||
var encodingLength = '' + packet.length;
|
||||
var 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]));
|
||||
});
|
||||
}
|
||||
|
||||
map(packets, encodeOne, function(err, results) {
|
||||
return callback(Buffer.concat(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 {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 = [];
|
||||
|
||||
while (bufferTail.length > 0) {
|
||||
var strLen = '';
|
||||
var isString = bufferTail[0] === 0;
|
||||
var numberTooLong = false;
|
||||
for (var i = 1; ; i++) {
|
||||
if (bufferTail[i] == 255) break;
|
||||
// 310 = char length of Number.MAX_VALUE
|
||||
if (strLen.length > 310) {
|
||||
numberTooLong = true;
|
||||
break;
|
||||
}
|
||||
strLen += '' + bufferTail[i];
|
||||
}
|
||||
if(numberTooLong) return callback(err, 0, 1);
|
||||
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;
|
||||
buffers.forEach(function(buffer, i) {
|
||||
callback(exports.decodePacket(buffer, binaryType, true), i, total);
|
||||
});
|
||||
};
|
19
node_modules/socketio/node_modules/engine.io-parser/lib/keys.js
generated
vendored
Normal file
19
node_modules/socketio/node_modules/engine.io-parser/lib/keys.js
generated
vendored
Normal file
@ -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;
|
||||
};
|
33
node_modules/socketio/node_modules/engine.io-parser/package.json
generated
vendored
Normal file
33
node_modules/socketio/node_modules/engine.io-parser/package.json
generated
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
{
|
||||
"name": "engine.io-parser",
|
||||
"description": "Parser for the client for the realtime Engine",
|
||||
"license": "MIT",
|
||||
"version": "1.3.2",
|
||||
"homepage": "https://github.com/socketio/engine.io-parser",
|
||||
"devDependencies": {
|
||||
"expect.js": "0.3.1",
|
||||
"mocha": "3.2.0",
|
||||
"zuul": "3.11.1",
|
||||
"zuul-ngrok": "4.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"after": "0.8.2",
|
||||
"arraybuffer.slice": "0.0.6",
|
||||
"base64-arraybuffer": "0.1.5",
|
||||
"blob": "0.0.4",
|
||||
"has-binary": "0.1.7",
|
||||
"wtf-8": "1.0.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "make test"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git@github.com:socketio/engine.io-parser.git"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"lib/"
|
||||
],
|
||||
"browser": "./lib/browser.js"
|
||||
}
|
570
node_modules/socketio/node_modules/engine.io/History.md
generated
vendored
Normal file
570
node_modules/socketio/node_modules/engine.io/History.md
generated
vendored
Normal file
@ -0,0 +1,570 @@
|
||||
|
||||
1.8.5 / 2017-12-27
|
||||
===================
|
||||
|
||||
* [chore] Bump ws to version 1.1.5
|
||||
|
||||
1.8.4 / 2017-04-28
|
||||
===================
|
||||
|
||||
* [fix] Fix null payload when aborting connection (#503) (cherry-picked)
|
||||
* [chore] Bump ws to version 1.1.4 (#495)
|
||||
|
||||
1.8.3 / 2017-02-16
|
||||
===================
|
||||
|
||||
* [chore] Bump ws to version 1.1.2 (vulnerability fix) (#480) (cherry-picked)
|
||||
|
||||
1.8.2 / 2016-12-11
|
||||
===================
|
||||
|
||||
* [fix] Add proper response when handleUpgrade fails (#458)
|
||||
* [test] Use explicit versions for travis tests (#457)
|
||||
* [refactor] Remove deprecated code used for nodejs v0.8 (#456)
|
||||
* [chore] Bump engine.io-parser to version 1.3.2 (#455)
|
||||
* [perf] websocket optimisation (#453)
|
||||
* [docs] Rename ServerRequest to IncomingMessage (#448)
|
||||
* [chore] Bump base64id to version 1.0.0 (#451)
|
||||
|
||||
1.8.1 / 2016-11-27
|
||||
===================
|
||||
|
||||
* [fix] Only add defined callbacks to the stack (#447)
|
||||
|
||||
1.8.0 / 2016-11-20
|
||||
===================
|
||||
|
||||
* [style] Fix some typos (#439)
|
||||
* [style] Add ESlint (#385)
|
||||
* [test] fix tests for NodeJS v7 (#441)
|
||||
* [feature] Fix cookiePath empty bug and add cookieHttpOnly option (#423)
|
||||
* [fix] Don't delete ws when closing the server (#444)
|
||||
* [chore] Bump debug to version 2.3.3 (#445)
|
||||
|
||||
1.7.2 / 2016-10-24
|
||||
===================
|
||||
|
||||
* [docs] Add missing `upgradeTimeout` option in the docs (#437)
|
||||
* [chore] Add Github issue and PR templates (#436)
|
||||
|
||||
1.7.1 / 2016-10-20
|
||||
===================
|
||||
|
||||
* [fix] Close and free webSocketServer (#393)
|
||||
* [chore] Bump engine.io-client to 1.7.0 (#429)
|
||||
* [chore] Bump engine.io-parser to 1.3.1 (#433)
|
||||
* [chore] Add latest nodejs release in travis settings (#434)
|
||||
|
||||
1.7.0 / 2016-10-05
|
||||
===================
|
||||
|
||||
* [feature] Give the ability to dynamically choose ws implementation (#390)
|
||||
* [chore] Add gulp & babel in the build process (#384)
|
||||
* [chore] Ignore dist not to release for now (#387)
|
||||
* [chore] Upgrade accepts to 1.3.3
|
||||
* [chore] Bumping ws to 1.1.1 to address https://nodesecurity.io/advisories/120 (#411)
|
||||
* [chore] Restoring require('ws') as separate expression for browserify. (#418)
|
||||
* [chore] Bump engine.io-parser to 1.3.0 (#425)
|
||||
* [chore] Make the build status badge point towards master (#426)
|
||||
* [chore] Restrict files included in npm package (#427)
|
||||
|
||||
1.6.11 / 2016-06-23
|
||||
===================
|
||||
|
||||
* package: bump `ws` to support `maxPayload`
|
||||
|
||||
1.6.10 / 2016-06-23
|
||||
===================
|
||||
|
||||
* set a default ws `maxPayload` [security fix]
|
||||
* bump `accepts` [security fix]
|
||||
|
||||
1.6.9 / 2016-05-03
|
||||
==================
|
||||
|
||||
* bump client
|
||||
|
||||
1.6.8 / 2016-01-25
|
||||
==================
|
||||
|
||||
* fix graceful close [nkzawa]
|
||||
* polling: don't set the `closeTimeoutTimer` if the transport is upgraded
|
||||
|
||||
1.6.7 / 2016-01-10
|
||||
==================
|
||||
|
||||
* bump version
|
||||
|
||||
1.6.6 / 2016-01-07
|
||||
==================
|
||||
|
||||
* bump version
|
||||
|
||||
1.6.5 / 2016-01-05
|
||||
==================
|
||||
|
||||
* package: upgrade ws for sec advisory
|
||||
* server: catch websocket errors before upgrade
|
||||
|
||||
1.6.4 / 2015-12-04
|
||||
==================
|
||||
|
||||
* package: bump parser for arraybuffer base64 fix
|
||||
|
||||
1.6.3 / 2015-12-01
|
||||
==================
|
||||
|
||||
* restore testing on 0.8
|
||||
* improve X-XSS-Protection header definition [nkzawa]
|
||||
* add threshold for permessage-deflate [nkzawa]
|
||||
|
||||
1.6.2 / 2015-11-30
|
||||
==================
|
||||
|
||||
* don't compress control packets
|
||||
|
||||
1.6.1 / 2015-11-28
|
||||
==================
|
||||
|
||||
* package: bump `engine.io-client` for `ws` options fix
|
||||
* fix `latency` example
|
||||
|
||||
1.6.0 / 2015-11-28
|
||||
==================
|
||||
|
||||
* add support for environments that extend `Object.prototype`
|
||||
* remove listeners upon `clearTransport`
|
||||
* support for all versions of node
|
||||
* fix lingering sockets that can stay open when upgrade failed
|
||||
* ensure sockets are closed on error
|
||||
* bump `ws` for several improvements
|
||||
* fix for a rare race condition on some error scenarios
|
||||
* support custom socket id
|
||||
* use container-based infrastructure for faster build
|
||||
* fix package.json wrongly referrering to self
|
||||
* allow overriding the `cookiePath`
|
||||
* fix potential encoding errors under certain conditions
|
||||
* support compression
|
||||
|
||||
1.5.4 / 2015-09-09
|
||||
==================
|
||||
|
||||
* package: bump `engine.io-parser`
|
||||
|
||||
1.5.3 / 2015-09-09
|
||||
==================
|
||||
|
||||
* package: bump `ws` to fix node 4.0.0
|
||||
|
||||
1.5.2 / 2015-07-09
|
||||
==================
|
||||
|
||||
* package: bump `ws` to fix build issues
|
||||
|
||||
1.5.1 / 2015-01-19
|
||||
==================
|
||||
|
||||
* no change on this release
|
||||
* package: bump `engine.io-client`
|
||||
|
||||
1.5.0 / 2015-01-18
|
||||
==================
|
||||
|
||||
* package: bump `engine.io-parser`
|
||||
* polling: correctly abort the ongoing data request when closing [lpinca]
|
||||
* add cert-related client tests [rase-]
|
||||
|
||||
1.4.3 / 2014-11-21
|
||||
==================
|
||||
|
||||
* package: bump `ws` to fix fd leaks
|
||||
* socket: flush the write buffer before closing the socket [lpinca]
|
||||
* polling: close the pending poll request when closing transport [lpinca]
|
||||
|
||||
1.4.2 / 2014-10-08
|
||||
==================
|
||||
|
||||
* add iframe onload handling to jsonp tests [rase-]
|
||||
|
||||
1.4.1 / 2014-10-03
|
||||
==================
|
||||
|
||||
* socket: allow upgrades if the socket is still in closing state
|
||||
* README: fix typo
|
||||
|
||||
1.4.0 / 2014-09-03
|
||||
==================
|
||||
|
||||
* readme: fix formatting for goals numbering
|
||||
* server: ref fix by @nicokaiser
|
||||
* server: fix ws memory leak (fixes #268)
|
||||
* cache remote address in handshake since it might be lost later.
|
||||
* correct git ref
|
||||
* update client to commit with bumped parser
|
||||
* package: bump parser
|
||||
* npmignore: ignore `.gitignore`
|
||||
* package: bump `debug`
|
||||
* package: bump `engine.io-parser` for memleak fix
|
||||
|
||||
1.3.1 / 2014-06-19
|
||||
==================
|
||||
|
||||
* package: bump `engine.io-client`
|
||||
|
||||
1.3.0 / 2014-06-13
|
||||
==================
|
||||
|
||||
* update example to use v1.2.2
|
||||
* fixed newline parsing in jsonp
|
||||
* make require('engine.io')() return a new Server instance [defunctzombie]
|
||||
* add Server.attach method [defunctzombie]
|
||||
* fix GH-211, set CORS headers when sending error message [mokesmokes]
|
||||
|
||||
1.2.2 / 2014-05-30
|
||||
==================
|
||||
|
||||
* package: bump `engine.io-parser` for binary utf8 fix
|
||||
|
||||
1.2.1 / 2014-05-22
|
||||
==================
|
||||
|
||||
* package: bump engine.io-client
|
||||
|
||||
1.2.0 / 2014-05-18
|
||||
==================
|
||||
|
||||
* removed flashsocket, moving to userland
|
||||
|
||||
1.1.1 / 2014-05-14
|
||||
==================
|
||||
|
||||
* test: reduce packet size
|
||||
* package: bump parser
|
||||
|
||||
1.1.0 / 2014-04-27
|
||||
==================
|
||||
|
||||
* socket: removed unneeded `clearTimeout` (fixes #250)
|
||||
* made the request verification process async
|
||||
* package: bump `engine.io-parser`
|
||||
* use _query instead of query, fixes compat with restify
|
||||
* added a maximum buffer size to received data from polling
|
||||
* fixing looping array via for in to normal loop
|
||||
|
||||
1.0.5 / 2014-03-18
|
||||
==================
|
||||
|
||||
* package: bump `engine.io-parser` and `engine.io-client`
|
||||
|
||||
1.0.4 / 2014-03-14
|
||||
==================
|
||||
|
||||
* package: bump `engine.io-client`
|
||||
|
||||
1.0.3 / 2014-03-12
|
||||
==================
|
||||
|
||||
* package: bump `engine.io-client`
|
||||
|
||||
1.0.2 / 2014-03-12
|
||||
==================
|
||||
|
||||
* bump engine.io-client
|
||||
|
||||
1.0.1 / 2014-03-06
|
||||
==================
|
||||
|
||||
* package: bump `engine.io-parser`
|
||||
* transports: fix jshint warnings and style
|
||||
|
||||
1.0.0 / 2014-03-06
|
||||
==================
|
||||
|
||||
* polling-xhr: added `OPTIONS` support, fixes CORS
|
||||
* close() properly when triggered in connection handler
|
||||
* fix DDOS vector by setting up too many intervals
|
||||
* binary support
|
||||
|
||||
0.9.0 / 2014-02-09
|
||||
==================
|
||||
|
||||
* Prevent errors with connections behind proxies without WS support
|
||||
like Squid [nicklagrow, samaanghani, davidhcummings]
|
||||
* Socket#request a simple property [mokesmokes]
|
||||
* Changed `Socket`'s `upgrade` event to happen after upgrade [mokesmokes]
|
||||
* Document `Socket#id` [mokesmokes]
|
||||
|
||||
0.8.2 / 2014-01-18
|
||||
==================
|
||||
|
||||
* package: bump `engine.io-client`
|
||||
|
||||
0.8.1 / 2014-01-17
|
||||
==================
|
||||
|
||||
* package: bump `engine.io-client`
|
||||
* package: pin dev deps
|
||||
* examples: fix port output
|
||||
* fix latency example
|
||||
|
||||
0.8.0 / 2014-01-05
|
||||
==================
|
||||
|
||||
* package: bump `engine.io-client` to `0.8.0`
|
||||
* test: fix syntax, remove globals
|
||||
|
||||
0.7.14 / 2014-01-01
|
||||
===================
|
||||
|
||||
* package: bump `engine.io-client` to `0.7.14`
|
||||
|
||||
0.7.13 / 2013-12-20
|
||||
===================
|
||||
|
||||
* package: bump `engine.io-client`
|
||||
* transports: added support for XSS filters on IE [guille, 3rd-eden]
|
||||
|
||||
0.7.12 / 2013-11-11
|
||||
===================
|
||||
|
||||
* package: bump `engine.io-client`
|
||||
|
||||
0.7.11 / 2013-11-06
|
||||
===================
|
||||
|
||||
* package: bump engine.io-client
|
||||
* fix GH-198
|
||||
|
||||
0.7.10 / 2013-10-28
|
||||
===================
|
||||
|
||||
* package: bump `engine.io-client`
|
||||
* package: update "ws" to v0.4.31
|
||||
|
||||
0.7.9 / 2013-08-30
|
||||
==================
|
||||
|
||||
* package: bump `engine.io-client`
|
||||
|
||||
0.7.8 / 2013-08-30
|
||||
==================
|
||||
|
||||
* package: bump `engine.io-client`
|
||||
* package: bump ws
|
||||
|
||||
0.7.7 / 2013-08-30
|
||||
==================
|
||||
|
||||
* package: bump `engine.io-client`
|
||||
|
||||
0.7.6 / 2013-08-30
|
||||
==================
|
||||
|
||||
* package: bump engine.io-client
|
||||
|
||||
0.7.5 / 2013-08-30
|
||||
==================
|
||||
|
||||
* package: bump engine.io-client
|
||||
|
||||
0.7.4 / 2013-08-25
|
||||
==================
|
||||
|
||||
* package: bump `engine.io-client`
|
||||
|
||||
0.7.3 / 2013-08-23
|
||||
==================
|
||||
|
||||
* package: bump engine.io-client (noop)
|
||||
* package: fix regresison in upgrade cause by ws update
|
||||
|
||||
0.7.2 / 2013-08-23
|
||||
==================
|
||||
|
||||
* package: bump `engine.io-client` for `WebSocket` browser fix
|
||||
|
||||
0.7.1 / 2013-08-23
|
||||
==================
|
||||
|
||||
* package: bump engine.io-client for ws fix
|
||||
|
||||
0.7.0 / 2013-08-23
|
||||
==================
|
||||
|
||||
* package: bump engine.io-client
|
||||
* updated example
|
||||
* inline merge
|
||||
* added support node version 0.10 to .travis.yml
|
||||
* fixed respond to flash policy request test. Closes #184
|
||||
* fixed upgrade with timeout test. Closes #185
|
||||
* engine.io: don't use __proto__, closes #170
|
||||
|
||||
0.6.3 / 2013-06-21
|
||||
==================
|
||||
|
||||
* package: bumped `engine.io-client` to `0.6.3`
|
||||
|
||||
0.6.2 / 2013-06-15
|
||||
==================
|
||||
|
||||
* fix upgrade stalling edge case introduced with #174 fix
|
||||
* remove unneeded client code related to iOS
|
||||
* added test for `engine.io-client` `0.6.1`
|
||||
|
||||
0.6.1 / 2013-06-06
|
||||
==================
|
||||
|
||||
* package: bumped `engine.io-client` to `0.6.1`
|
||||
|
||||
0.6.0 / 2013-05-31
|
||||
==================
|
||||
|
||||
* socket: clear timer after sending one noop packet (fixes #174)
|
||||
* clear all timers on socket close
|
||||
* sending error on transport creation upon a bad request
|
||||
* added test for client-side buffer cleanup
|
||||
* changed flushComplete to flush
|
||||
* ended support for node 0.6
|
||||
|
||||
0.5.0 / 2013-03-16
|
||||
==================
|
||||
|
||||
* polling: implemented new parser
|
||||
* test writeBuffer isn't cleared onError, removed 'closing' check in .flush()
|
||||
* fixed bug89 and added tests: writeBuffer not flushed until nextTick
|
||||
|
||||
0.4.3 / 2013-02-08
|
||||
==================
|
||||
|
||||
* package: bumped `engine.io-client` to `0.4.3`
|
||||
|
||||
0.4.2 / 2013-02-08
|
||||
==================
|
||||
|
||||
* Only end upgrade socket connections if unhandled
|
||||
* Fix websocket dependency
|
||||
* Close socket if upgrade is received and socket.readyState != open
|
||||
|
||||
0.4.1 / 2013-01-18
|
||||
==================
|
||||
|
||||
* package: bumped versions
|
||||
* Fixed bugs in previous send callback fix and updated test cases
|
||||
* Added a test case which makes the code before the send callback fix fail
|
||||
* socket: emit `data` event (synonym with `message`)
|
||||
* socket: added `Socket#write`
|
||||
* engine.io: cleanup
|
||||
* engine.io: deprecated `resource`
|
||||
* `npm docs engine.io` works now
|
||||
|
||||
0.3.10 / 2012-12-03
|
||||
===================
|
||||
|
||||
* package: bumped `engine.io-client` with `close` fixes
|
||||
* add packetCreate event [jxck]
|
||||
* add packet event to socket [jxck]
|
||||
* transport: remove `Connection` headers and let node handle it
|
||||
* server: send validation failure reason to clients
|
||||
* engine: invoking as a function causes attach
|
||||
* socket: reset `writeBuffer` before send
|
||||
|
||||
0.3.9 / 2012-10-23
|
||||
==================
|
||||
|
||||
* package: bumped `engine.io-client`
|
||||
|
||||
0.3.8 / 2012-10-23
|
||||
==================
|
||||
|
||||
* package: bumped engine.io-client
|
||||
* examples: added first example
|
||||
|
||||
0.3.7 / 2012-10-21
|
||||
==================
|
||||
|
||||
* package: bumped `engine.io-client`
|
||||
|
||||
0.3.6 / 2012-10-21
|
||||
==================
|
||||
|
||||
[skipped]
|
||||
|
||||
0.3.5 / 2012-10-14
|
||||
==================
|
||||
|
||||
* package: reverted last commit - we use the parser from the client
|
||||
|
||||
0.3.4 / 2012-10-14
|
||||
==================
|
||||
|
||||
* package: `engine.io-client` moved to `devDependencies`
|
||||
* socket: added missing jsdoc
|
||||
|
||||
0.3.3 / 2012-10-10
|
||||
==================
|
||||
|
||||
* socket: fixed check interval clearing [joewalnes]
|
||||
* transports: improved instrumentation
|
||||
|
||||
0.3.2 / 2012-10-08
|
||||
==================
|
||||
|
||||
* socket: improve check interval for upgrade
|
||||
|
||||
0.3.1 / 2012-10-08
|
||||
==================
|
||||
|
||||
* socket: faster upgrades (we perform a check immediately)
|
||||
* server: don't assume sid is numeric
|
||||
|
||||
0.3.0 / 2012-10-04
|
||||
==================
|
||||
|
||||
* socket: `writeBuffer` now gets sliced, and is recoverable after `close` [afshinm]
|
||||
* server: expect ping from client and send interval with handshake [cadorn]
|
||||
* polling-jsonp: prevent client breakage with utf8 whitespace
|
||||
* socket: fix `flush` and `drain` events
|
||||
* socket: add `send` callback [afshinm]
|
||||
* transport: avoid unhandled error events for stale transports
|
||||
* README: documentation improvements [EugenDueck]
|
||||
|
||||
0.2.2 / 2012-08-26
|
||||
==================
|
||||
|
||||
* server: remove buffering for flash policy requests
|
||||
* transport: avoid unhandled error events for stale transports (fixes #69)
|
||||
* readme: documented `toString` behavior on `send` [EugenDueck]
|
||||
|
||||
0.2.1 / 2012-08-13
|
||||
==================
|
||||
|
||||
* polling-xhr: skip Keep-Alive when it's implied [EugenDueck]
|
||||
* polling-jsonp: skip Keep-Alive when it's implied [EugenDueck]
|
||||
* README: added plugins list with engine.io-conflation
|
||||
* socket: added flush/drain events (fixes #56)
|
||||
* server: avoid passing websocket to non-websocket transports (fixes #24)
|
||||
|
||||
0.2.0 / 2012-08-06
|
||||
==================
|
||||
|
||||
* Bumped client
|
||||
* test: added closing connection test
|
||||
* server: implemented stronger id generator with collision detection
|
||||
|
||||
0.1.2 / 2012-08-02
|
||||
==================
|
||||
|
||||
* Fixed a jsonp bug in Nokia mobile phones and potentially other UAs.
|
||||
|
||||
0.1.1 / 2012-08-01
|
||||
==================
|
||||
|
||||
* Fixed errors when a socket is closed while upgrade probe is happening.
|
||||
* Improved WS error handling
|
||||
* Replaced websocket.io with ws, now that it supports older drafts
|
||||
* README fixes
|
||||
|
||||
0.1.0 / 2012-07-03
|
||||
==================
|
||||
|
||||
* Initial release.
|
19
node_modules/socketio/node_modules/engine.io/LICENSE
generated
vendored
Normal file
19
node_modules/socketio/node_modules/engine.io/LICENSE
generated
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2014 Guillermo Rauch <guillermo@learnboost.com>
|
||||
|
||||
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.
|
||||
|
537
node_modules/socketio/node_modules/engine.io/README.md
generated
vendored
Normal file
537
node_modules/socketio/node_modules/engine.io/README.md
generated
vendored
Normal file
@ -0,0 +1,537 @@
|
||||
|
||||
# Engine.IO: the realtime engine
|
||||
|
||||
[](http://travis-ci.org/socketio/engine.io)
|
||||
[](http://badge.fury.io/js/engine.io)
|
||||
|
||||
`Engine.IO` is the implementation of transport-based
|
||||
cross-browser/cross-device bi-directional communication layer for
|
||||
[Socket.IO](http://github.com/socketio/socket.io).
|
||||
|
||||
## How to use
|
||||
|
||||
### Server
|
||||
|
||||
#### (A) Listening on a port
|
||||
|
||||
```js
|
||||
var engine = require('engine.io');
|
||||
var server = engine.listen(80);
|
||||
|
||||
server.on('connection', function(socket){
|
||||
socket.send('utf 8 string');
|
||||
socket.send(new Buffer([0, 1, 2, 3, 4, 5])); // binary data
|
||||
});
|
||||
```
|
||||
|
||||
#### (B) Intercepting requests for a http.Server
|
||||
|
||||
```js
|
||||
var engine = require('engine.io');
|
||||
var http = require('http').createServer().listen(3000);
|
||||
var server = engine.attach(http);
|
||||
|
||||
server.on('connection', function (socket) {
|
||||
socket.on('message', function(data){ });
|
||||
socket.on('close', function(){ });
|
||||
});
|
||||
```
|
||||
|
||||
#### (C) Passing in requests
|
||||
|
||||
```js
|
||||
var engine = require('engine.io');
|
||||
var server = new engine.Server();
|
||||
|
||||
server.on('connection', function(socket){
|
||||
socket.send('hi');
|
||||
});
|
||||
|
||||
// …
|
||||
httpServer.on('upgrade', function(req, socket, head){
|
||||
server.handleUpgrade(req, socket, head);
|
||||
});
|
||||
httpServer.on('request', function(req, res){
|
||||
server.handleRequest(req, res);
|
||||
});
|
||||
```
|
||||
|
||||
### Client
|
||||
|
||||
```html
|
||||
<script src="/path/to/engine.io.js"></script>
|
||||
<script>
|
||||
var socket = new eio.Socket('ws://localhost/');
|
||||
socket.on('open', function(){
|
||||
socket.on('message', function(data){});
|
||||
socket.on('close', function(){});
|
||||
});
|
||||
</script>
|
||||
```
|
||||
|
||||
For more information on the client refer to the
|
||||
[engine-client](http://github.com/learnboost/engine.io-client) repository.
|
||||
|
||||
## What features does it have?
|
||||
|
||||
- **Maximum reliability**. Connections are established even in the presence of:
|
||||
- proxies and load balancers.
|
||||
- personal firewall and antivirus software.
|
||||
- for more information refer to **Goals** and **Architecture** sections
|
||||
- **Minimal client size** aided by:
|
||||
- lazy loading of flash transports.
|
||||
- lack of redundant transports.
|
||||
- **Scalable**
|
||||
- load balancer friendly
|
||||
- **Future proof**
|
||||
- **100% Node.JS core style**
|
||||
- No API sugar (left for higher level projects)
|
||||
- Written in readable vanilla JavaScript
|
||||
|
||||
## API
|
||||
|
||||
### Server
|
||||
|
||||
<hr><br>
|
||||
|
||||
#### Top-level
|
||||
|
||||
These are exposed by `require('engine.io')`:
|
||||
|
||||
##### Events
|
||||
|
||||
- `flush`
|
||||
- Called when a socket buffer is being flushed.
|
||||
- **Arguments**
|
||||
- `Socket`: socket being flushed
|
||||
- `Array`: write buffer
|
||||
- `drain`
|
||||
- Called when a socket buffer is drained
|
||||
- **Arguments**
|
||||
- `Socket`: socket being flushed
|
||||
|
||||
##### Properties
|
||||
|
||||
- `protocol` _(Number)_: protocol revision number
|
||||
- `Server`: Server class constructor
|
||||
- `Socket`: Socket class constructor
|
||||
- `Transport` _(Function)_: transport constructor
|
||||
- `transports` _(Object)_: map of available transports
|
||||
|
||||
##### Methods
|
||||
|
||||
- `()`
|
||||
- Returns a new `Server` instance. If the first argument is an `http.Server` then the
|
||||
new `Server` instance will be attached to it. Otherwise, the arguments are passed
|
||||
directly to the `Server` constructor.
|
||||
- **Parameters**
|
||||
- `http.Server`: optional, server to attach to.
|
||||
- `Object`: optional, options object (see `Server#constructor` api docs below)
|
||||
|
||||
The following are identical ways to instantiate a server and then attach it.
|
||||
```js
|
||||
var httpServer; // previously created with `http.createServer();` from node.js api.
|
||||
|
||||
// create a server first, and then attach
|
||||
var eioServer = require('engine.io').Server();
|
||||
eioServer.attach(httpServer);
|
||||
|
||||
// or call the module as a function to get `Server`
|
||||
var eioServer = require('engine.io')();
|
||||
eioServer.attach(httpServer);
|
||||
|
||||
// immediately attach
|
||||
var eioServer = require('engine.io')(httpServer);
|
||||
```
|
||||
|
||||
- `listen`
|
||||
- Creates an `http.Server` which listens on the given port and attaches WS
|
||||
to it. It returns `501 Not Implemented` for regular http requests.
|
||||
- **Parameters**
|
||||
- `Number`: port to listen on.
|
||||
- `Object`: optional, options object
|
||||
- `Function`: callback for `listen`.
|
||||
- **Options**
|
||||
- All options from `Server.attach` method, documented below.
|
||||
- **Additionally** See Server `constructor` below for options you can pass for creating the new Server
|
||||
- **Returns** `Server`
|
||||
- `attach`
|
||||
- Captures `upgrade` requests for a `http.Server`. In other words, makes
|
||||
a regular http.Server WebSocket-compatible.
|
||||
- **Parameters**
|
||||
- `http.Server`: server to attach to.
|
||||
- `Object`: optional, options object
|
||||
- **Options**
|
||||
- All options from `Server.attach` method, documented below.
|
||||
- **Additionally** See Server `constructor` below for options you can pass for creating the new Server
|
||||
- **Returns** `Server` a new Server instance.
|
||||
|
||||
<hr><br>
|
||||
|
||||
#### Server
|
||||
|
||||
The main server/manager. _Inherits from EventEmitter_.
|
||||
|
||||
##### Events
|
||||
|
||||
- `connection`
|
||||
- Fired when a new connection is established.
|
||||
- **Arguments**
|
||||
- `Socket`: a Socket object
|
||||
|
||||
##### Properties
|
||||
|
||||
**Important**: if you plan to use Engine.IO in a scalable way, please
|
||||
keep in mind the properties below will only reflect the clients connected
|
||||
to a single process.
|
||||
|
||||
- `clients` _(Object)_: hash of connected clients by id.
|
||||
- `clientsCount` _(Number)_: number of connected clients.
|
||||
|
||||
##### Methods
|
||||
|
||||
- **constructor**
|
||||
- Initializes the server
|
||||
- **Parameters**
|
||||
- `Object`: optional, options object
|
||||
- **Options**
|
||||
- `pingTimeout` (`Number`): how many ms without a pong packet to
|
||||
consider the connection closed (`60000`)
|
||||
- `pingInterval` (`Number`): how many ms before sending a new ping
|
||||
packet (`25000`)
|
||||
- `upgradeTimeout` (`Number`): how many ms before an uncompleted transport upgrade is cancelled (`10000`)
|
||||
- `maxHttpBufferSize` (`Number`): how many bytes or characters a message
|
||||
can be when polling, before closing the session (to avoid DoS). Default
|
||||
value is `10E7`.
|
||||
- `allowRequest` (`Function`): A function that receives a given handshake
|
||||
or upgrade request as its first parameter, and can decide whether to
|
||||
continue or not. The second argument is a function that needs to be
|
||||
called with the decided information: `fn(err, success)`, where
|
||||
`success` is a boolean value where false means that the request is
|
||||
rejected, and err is an error code.
|
||||
- `transports` (`<Array> String`): transports to allow connections
|
||||
to (`['polling', 'websocket']`)
|
||||
- `allowUpgrades` (`Boolean`): whether to allow transport upgrades
|
||||
(`true`)
|
||||
- `perMessageDeflate` (`Object|Boolean`): parameters of the WebSocket permessage-deflate extension
|
||||
(see [ws module](https://github.com/einaros/ws) api docs). Set to `false` to disable. (`true`)
|
||||
- `threshold` (`Number`): data is compressed only if the byte size is above this value (`1024`)
|
||||
- `httpCompression` (`Object|Boolean`): parameters of the http compression for the polling transports
|
||||
(see [zlib](http://nodejs.org/api/zlib.html#zlib_options) api docs). Set to `false` to disable. (`true`)
|
||||
- `threshold` (`Number`): data is compressed only if the byte size is above this value (`1024`)
|
||||
- `cookie` (`String|Boolean`): name of the HTTP cookie that
|
||||
contains the client sid to send as part of handshake response
|
||||
headers. Set to `false` to not send one. (`io`)
|
||||
- `cookiePath` (`String|Boolean`): path of the above `cookie`
|
||||
option. If false, no path will be sent, which means browsers will only send the cookie on the engine.io attached path (`/engine.io`).
|
||||
Set false to not save io cookie on all requests. (`/`)
|
||||
- `cookieHttpOnly` (`Boolean`): If `true` HttpOnly io cookie cannot be accessed by client-side APIs, such as JavaScript. (`true`) _This option has no effect if `cookie` or `cookiePath` is set to `false`._
|
||||
- `wsEngine` (`String`): what WebSocket server implementation to use. Specified module must conform to the `ws` interface (see [ws module api docs](https://github.com/websockets/ws/blob/master/doc/ws.md)). Default value is `ws`. An alternative c++ addon is also available by installing `uws` module.
|
||||
- `close`
|
||||
- Closes all clients
|
||||
- **Returns** `Server` for chaining
|
||||
- `handleRequest`
|
||||
- Called internally when a `Engine` request is intercepted.
|
||||
- **Parameters**
|
||||
- `http.IncomingMessage`: a node request object
|
||||
- `http.ServerResponse`: a node response object
|
||||
- **Returns** `Server` for chaining
|
||||
- `handleUpgrade`
|
||||
- Called internally when a `Engine` ws upgrade is intercepted.
|
||||
- **Parameters** (same as `upgrade` event)
|
||||
- `http.IncomingMessage`: a node request object
|
||||
- `net.Stream`: TCP socket for the request
|
||||
- `Buffer`: legacy tail bytes
|
||||
- **Returns** `Server` for chaining
|
||||
- `attach`
|
||||
- Attach this Server instance to an `http.Server`
|
||||
- Captures `upgrade` requests for a `http.Server`. In other words, makes
|
||||
a regular http.Server WebSocket-compatible.
|
||||
- **Parameters**
|
||||
- `http.Server`: server to attach to.
|
||||
- `Object`: optional, options object
|
||||
- **Options**
|
||||
- `path` (`String`): name of the path to capture (`/engine.io`).
|
||||
- `destroyUpgrade` (`Boolean`): destroy unhandled upgrade requests (`true`)
|
||||
- `destroyUpgradeTimeout` (`Number`): milliseconds after which unhandled requests are ended (`1000`)
|
||||
- `generateId`
|
||||
- Generate a socket id.
|
||||
- Overwrite this method to generate your custom socket id.
|
||||
- **Parameters**
|
||||
- `http.IncomingMessage`: a node request object
|
||||
- **Returns** A socket id for connected client.
|
||||
|
||||
<hr><br>
|
||||
|
||||
#### Socket
|
||||
|
||||
A representation of a client. _Inherits from EventEmitter_.
|
||||
|
||||
##### Events
|
||||
|
||||
- `close`
|
||||
- Fired when the client is disconnected.
|
||||
- **Arguments**
|
||||
- `String`: reason for closing
|
||||
- `Object`: description object (optional)
|
||||
- `message`
|
||||
- Fired when the client sends a message.
|
||||
- **Arguments**
|
||||
- `String` or `Buffer`: Unicode string or Buffer with binary contents
|
||||
- `error`
|
||||
- Fired when an error occurs.
|
||||
- **Arguments**
|
||||
- `Error`: error object
|
||||
- `flush`
|
||||
- Called when the write buffer is being flushed.
|
||||
- **Arguments**
|
||||
- `Array`: write buffer
|
||||
- `drain`
|
||||
- Called when the write buffer is drained
|
||||
- `packet`
|
||||
- Called when a socket received a packet (`message`, `ping`)
|
||||
- **Arguments**
|
||||
- `type`: packet type
|
||||
- `data`: packet data (if type is message)
|
||||
- `packetCreate`
|
||||
- Called before a socket sends a packet (`message`, `pong`)
|
||||
- **Arguments**
|
||||
- `type`: packet type
|
||||
- `data`: packet data (if type is message)
|
||||
|
||||
##### Properties
|
||||
|
||||
- `id` _(String)_: unique identifier
|
||||
- `server` _(Server)_: engine parent reference
|
||||
- `request` _(http.IncomingMessage)_: request that originated the Socket
|
||||
- `upgraded` _(Boolean)_: whether the transport has been upgraded
|
||||
- `readyState` _(String)_: opening|open|closing|closed
|
||||
- `transport` _(Transport)_: transport reference
|
||||
|
||||
##### Methods
|
||||
|
||||
- `send`:
|
||||
- Sends a message, performing `message = toString(arguments[0])` unless
|
||||
sending binary data, which is sent as is.
|
||||
- **Parameters**
|
||||
- `String` | `Buffer` | `ArrayBuffer` | `ArrayBufferView`: a string or any object implementing `toString()`, with outgoing data, or a Buffer or ArrayBuffer with binary data. Also any ArrayBufferView can be sent as is.
|
||||
- `Object`: optional, options object
|
||||
- `Function`: optional, a callback executed when the message gets flushed out by the transport
|
||||
- **Options**
|
||||
- `compress` (`Boolean`): whether to compress sending data. This option might be ignored and forced to be `true` when using polling. (`true`)
|
||||
- **Returns** `Socket` for chaining
|
||||
- `close`
|
||||
- Disconnects the client
|
||||
- **Returns** `Socket` for chaining
|
||||
|
||||
### Client
|
||||
|
||||
<hr><br>
|
||||
|
||||
Exposed in the `eio` global namespace (in the browser), or by
|
||||
`require('engine.io-client')` (in Node.JS).
|
||||
|
||||
For the client API refer to the
|
||||
[engine-client](http://github.com/learnboost/engine.io-client) repository.
|
||||
|
||||
## Debug / logging
|
||||
|
||||
Engine.IO is powered by [debug](http://github.com/visionmedia/debug).
|
||||
In order to see all the debug output, run your app with the environment variable
|
||||
`DEBUG` including the desired scope.
|
||||
|
||||
To see the output from all of Engine.IO's debugging scopes you can use:
|
||||
|
||||
```
|
||||
DEBUG=engine* node myapp
|
||||
```
|
||||
|
||||
## Transports
|
||||
|
||||
- `polling`: XHR / JSONP polling transport.
|
||||
- `websocket`: WebSocket transport.
|
||||
|
||||
## Plugins
|
||||
|
||||
- [engine.io-conflation](https://github.com/EugenDueck/engine.io-conflation): Makes **conflation and aggregation** of messages straightforward.
|
||||
|
||||
## Support
|
||||
|
||||
The support channels for `engine.io` 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:
|
||||
|
||||
```
|
||||
git clone git://github.com/LearnBoost/engine.io.git
|
||||
```
|
||||
|
||||
Then:
|
||||
|
||||
```
|
||||
cd engine.io
|
||||
npm install
|
||||
```
|
||||
|
||||
## Tests
|
||||
|
||||
Tests run with `make test`. It runs the server tests that are aided by
|
||||
the usage of `engine.io-client`.
|
||||
|
||||
Make sure `npm install` is run first.
|
||||
|
||||
## Goals
|
||||
|
||||
The main goal of `Engine` is ensuring the most reliable realtime communication.
|
||||
Unlike the previous Socket.IO core, it always establishes a long-polling
|
||||
connection first, then tries to upgrade to better transports that are "tested" on
|
||||
the side.
|
||||
|
||||
During the lifetime of the Socket.IO projects, we've found countless drawbacks
|
||||
to relying on `HTML5 WebSocket` or `Flash Socket` as the first connection
|
||||
mechanisms.
|
||||
|
||||
Both are clearly the _right way_ of establishing a bidirectional communication,
|
||||
with HTML5 WebSocket being the way of the future. However, to answer most business
|
||||
needs, alternative traditional HTTP 1.1 mechanisms are just as good as delivering
|
||||
the same solution.
|
||||
|
||||
WebSocket based connections have two fundamental benefits:
|
||||
|
||||
1. **Better server performance**
|
||||
- _A: Load balancers_<br>
|
||||
Load balancing a long polling connection poses a serious architectural nightmare
|
||||
since requests can come from any number of open sockets by the user agent, but
|
||||
they all need to be routed to the process and computer that owns the `Engine`
|
||||
connection. This negatively impacts RAM and CPU usage.
|
||||
- _B: Network traffic_<br>
|
||||
WebSocket is designed around the premise that each message frame has to be
|
||||
surrounded by the least amount of data. In HTTP 1.1 transports, each message
|
||||
frame is surrounded by HTTP headers and chunked encoding frames. If you try to
|
||||
send the message _"Hello world"_ with xhr-polling, the message ultimately
|
||||
becomes larger than if you were to send it with WebSocket.
|
||||
- _C: Lightweight parser_<br>
|
||||
As an effect of **B**, the server has to do a lot more work to parse the network
|
||||
data and figure out the message when traditional HTTP requests are used
|
||||
(as in long polling). This means that another advantage of WebSocket is
|
||||
less server CPU usage.
|
||||
|
||||
2. **Better user experience**
|
||||
|
||||
Due to the reasons stated in point **1**, the most important effect of being able
|
||||
to establish a WebSocket connection is raw data transfer speed, which translates
|
||||
in _some_ cases in better user experience.
|
||||
|
||||
Applications with heavy realtime interaction (such as games) will benefit greatly,
|
||||
whereas applications like realtime chat (Gmail/Facebook), newsfeeds (Facebook) or
|
||||
timelines (Twitter) will have negligible user experience improvements.
|
||||
|
||||
Having said this, attempting to establish a WebSocket connection directly so far has
|
||||
proven problematic:
|
||||
|
||||
1. **Proxies**<br>
|
||||
Many corporate proxies block WebSocket traffic.
|
||||
|
||||
2. **Personal firewall and antivirus software**<br>
|
||||
As a result of our research, we've found that at least 3 personal security
|
||||
applications block WebSocket traffic.
|
||||
|
||||
3. **Cloud application platforms**<br>
|
||||
Platforms like Heroku or No.de have had trouble keeping up with the fast-paced
|
||||
nature of the evolution of the WebSocket protocol. Applications therefore end up
|
||||
inevitably using long polling, but the seamless installation experience of
|
||||
Socket.IO we strive for (_"require() it and it just works"_) disappears.
|
||||
|
||||
Some of these problems have solutions. In the case of proxies and personal programs,
|
||||
however, the solutions many times involve upgrading software. Experience has shown
|
||||
that relying on client software upgrades to deliver a business solution is
|
||||
fruitless: the very existence of this project has to do with a fragmented panorama
|
||||
of user agent distribution, with clients connecting with latest versions of the most
|
||||
modern user agents (Chrome, Firefox and Safari), but others with versions as low as
|
||||
IE 5.5.
|
||||
|
||||
From the user perspective, an unsuccessful WebSocket connection can translate in
|
||||
up to at least 10 seconds of waiting for the realtime application to begin
|
||||
exchanging data. This **perceptively** hurts user experience.
|
||||
|
||||
To summarize, **Engine** focuses on reliability and user experience first, marginal
|
||||
potential UX improvements and increased server performance second. `Engine` is the
|
||||
result of all the lessons learned with WebSocket in the wild.
|
||||
|
||||
## Architecture
|
||||
|
||||
The main premise of `Engine`, and the core of its existence, is the ability to
|
||||
swap transports on the fly. A connection starts as xhr-polling, but it can
|
||||
switch to WebSocket.
|
||||
|
||||
The central problem this poses is: how do we switch transports without losing
|
||||
messages?
|
||||
|
||||
`Engine` only switches from polling to another transport in between polling
|
||||
cycles. Since the server closes the connection after a certain timeout when
|
||||
there's no activity, and the polling transport implementation buffers messages
|
||||
in between connections, this ensures no message loss and optimal performance.
|
||||
|
||||
Another benefit of this design is that we workaround almost all the limitations
|
||||
of **Flash Socket**, such as slow connection times, increased file size (we can
|
||||
safely lazy load it without hurting user experience), etc.
|
||||
|
||||
## FAQ
|
||||
|
||||
### Can I use engine without Socket.IO ?
|
||||
|
||||
Absolutely. Although the recommended framework for building realtime applications
|
||||
is Socket.IO, since it provides fundamental features for real-world applications
|
||||
such as multiplexing, reconnection support, etc.
|
||||
|
||||
`Engine` is to Socket.IO what Connect is to Express. An essential piece for building
|
||||
realtime frameworks, but something you _probably_ won't be using for building
|
||||
actual applications.
|
||||
|
||||
### Does the server serve the client?
|
||||
|
||||
No. The main reason is that `Engine` is meant to be bundled with frameworks.
|
||||
Socket.IO includes `Engine`, therefore serving two clients is not necessary. If
|
||||
you use Socket.IO, including
|
||||
|
||||
```html
|
||||
<script src="/socket.io/socket.io.js">
|
||||
```
|
||||
|
||||
has you covered.
|
||||
|
||||
### Can I implement `Engine` in other languages?
|
||||
|
||||
Absolutely. The [engine.io-protocol](https://github.com/LearnBoost/engine.io-protocol)
|
||||
repository contains the most up to date description of the specification
|
||||
at all times, and the parser implementation in JavaScript.
|
||||
|
||||
## License
|
||||
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2014 Guillermo Rauch <guillermo@learnboost.com>
|
||||
|
||||
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.
|
4
node_modules/socketio/node_modules/engine.io/index.js
generated
vendored
Normal file
4
node_modules/socketio/node_modules/engine.io/index.js
generated
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
|
||||
module.exports = process.env.EIO_COV
|
||||
? require('./lib-cov/engine.io')
|
||||
: require('./lib/engine.io');
|
126
node_modules/socketio/node_modules/engine.io/lib/engine.io.js
generated
vendored
Normal file
126
node_modules/socketio/node_modules/engine.io/lib/engine.io.js
generated
vendored
Normal file
@ -0,0 +1,126 @@
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var http = require('http');
|
||||
|
||||
/**
|
||||
* Invoking the library as a function delegates to attach if the first argument
|
||||
* is an `http.Server`.
|
||||
*
|
||||
* If there are no arguments or the first argument is an options object, then
|
||||
* a new Server instance is returned.
|
||||
*
|
||||
* @param {http.Server} server (if specified, will be attached to by the new Server instance)
|
||||
* @param {Object} options
|
||||
* @return {Server} engine server
|
||||
* @api public
|
||||
*/
|
||||
|
||||
exports = module.exports = function () {
|
||||
// backwards compatible use as `.attach`
|
||||
// if first argument is an http server
|
||||
if (arguments.length && arguments[0] instanceof http.Server) {
|
||||
return attach.apply(this, arguments);
|
||||
}
|
||||
|
||||
// if first argument is not an http server, then just make a regular eio server
|
||||
return exports.Server.apply(null, arguments);
|
||||
};
|
||||
|
||||
/**
|
||||
* Protocol revision number.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
exports.protocol = 1;
|
||||
|
||||
/**
|
||||
* Expose Server constructor.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
exports.Server = require('./server');
|
||||
|
||||
/**
|
||||
* Expose Socket constructor.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
exports.Socket = require('./socket');
|
||||
|
||||
/**
|
||||
* Expose Transport constructor.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
exports.Transport = require('./transport');
|
||||
|
||||
/**
|
||||
* Expose mutable list of available transports.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
exports.transports = require('./transports');
|
||||
|
||||
/**
|
||||
* Exports parser.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
exports.parser = require('engine.io-parser');
|
||||
|
||||
/**
|
||||
* Creates an http.Server exclusively used for WS upgrades.
|
||||
*
|
||||
* @param {Number} port
|
||||
* @param {Function} callback
|
||||
* @param {Object} options
|
||||
* @return {Server} websocket.io server
|
||||
* @api public
|
||||
*/
|
||||
|
||||
exports.listen = listen;
|
||||
|
||||
function listen (port, options, fn) {
|
||||
if ('function' === typeof options) {
|
||||
fn = options;
|
||||
options = {};
|
||||
}
|
||||
|
||||
var server = http.createServer(function (req, res) {
|
||||
res.writeHead(501);
|
||||
res.end('Not Implemented');
|
||||
});
|
||||
|
||||
server.listen(port, fn);
|
||||
|
||||
// create engine server
|
||||
var engine = exports.attach(server, options);
|
||||
engine.httpServer = server;
|
||||
|
||||
return engine;
|
||||
}
|
||||
|
||||
/**
|
||||
* Captures upgrade requests for a http.Server.
|
||||
*
|
||||
* @param {http.Server} server
|
||||
* @param {Object} options
|
||||
* @return {Server} engine server
|
||||
* @api public
|
||||
*/
|
||||
|
||||
exports.attach = attach;
|
||||
|
||||
function attach (server, options) {
|
||||
var engine = new exports.Server(options);
|
||||
engine.attach(server, options);
|
||||
return engine;
|
||||
}
|
481
node_modules/socketio/node_modules/engine.io/lib/server.js
generated
vendored
Normal file
481
node_modules/socketio/node_modules/engine.io/lib/server.js
generated
vendored
Normal file
@ -0,0 +1,481 @@
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var qs = require('querystring');
|
||||
var parse = require('url').parse;
|
||||
var base64id = require('base64id');
|
||||
var transports = require('./transports');
|
||||
var EventEmitter = require('events').EventEmitter;
|
||||
var Socket = require('./socket');
|
||||
var util = require('util');
|
||||
var debug = require('debug')('engine');
|
||||
var cookieMod = require('cookie');
|
||||
|
||||
/**
|
||||
* Module exports.
|
||||
*/
|
||||
|
||||
module.exports = Server;
|
||||
|
||||
/**
|
||||
* Server constructor.
|
||||
*
|
||||
* @param {Object} options
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function Server (opts) {
|
||||
if (!(this instanceof Server)) {
|
||||
return new Server(opts);
|
||||
}
|
||||
|
||||
this.clients = {};
|
||||
this.clientsCount = 0;
|
||||
|
||||
opts = opts || {};
|
||||
|
||||
this.wsEngine = opts.wsEngine || process.env.EIO_WS_ENGINE;
|
||||
this.pingTimeout = opts.pingTimeout || 60000;
|
||||
this.pingInterval = opts.pingInterval || 25000;
|
||||
this.upgradeTimeout = opts.upgradeTimeout || 10000;
|
||||
this.maxHttpBufferSize = opts.maxHttpBufferSize || 10E7;
|
||||
this.transports = opts.transports || Object.keys(transports);
|
||||
this.allowUpgrades = false !== opts.allowUpgrades;
|
||||
this.allowRequest = opts.allowRequest;
|
||||
this.cookie = false !== opts.cookie ? (opts.cookie || 'io') : false;
|
||||
this.cookiePath = false !== opts.cookiePath ? (opts.cookiePath || '/') : false;
|
||||
this.cookieHttpOnly = false !== opts.cookieHttpOnly;
|
||||
this.perMessageDeflate = false !== opts.perMessageDeflate ? (opts.perMessageDeflate || true) : false;
|
||||
this.httpCompression = false !== opts.httpCompression ? (opts.httpCompression || {}) : false;
|
||||
|
||||
var self = this;
|
||||
|
||||
// initialize compression options
|
||||
['perMessageDeflate', 'httpCompression'].forEach(function (type) {
|
||||
var compression = self[type];
|
||||
if (true === compression) self[type] = compression = {};
|
||||
if (compression && null == compression.threshold) {
|
||||
compression.threshold = 1024;
|
||||
}
|
||||
});
|
||||
|
||||
// initialize websocket server
|
||||
if (~this.transports.indexOf('websocket')) {
|
||||
// keep require('ws') as separate expression for packers (browserify, etc)
|
||||
var WebSocketServer = (this.wsEngine ? require(this.wsEngine) : require('ws')).Server;
|
||||
this.ws = new WebSocketServer({
|
||||
noServer: true,
|
||||
clientTracking: false,
|
||||
perMessageDeflate: this.perMessageDeflate,
|
||||
maxPayload: this.maxHttpBufferSize
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Protocol errors mappings.
|
||||
*/
|
||||
|
||||
Server.errors = {
|
||||
UNKNOWN_TRANSPORT: 0,
|
||||
UNKNOWN_SID: 1,
|
||||
BAD_HANDSHAKE_METHOD: 2,
|
||||
BAD_REQUEST: 3
|
||||
};
|
||||
|
||||
Server.errorMessages = {
|
||||
0: 'Transport unknown',
|
||||
1: 'Session ID unknown',
|
||||
2: 'Bad handshake method',
|
||||
3: 'Bad request'
|
||||
};
|
||||
|
||||
/**
|
||||
* Inherits from EventEmitter.
|
||||
*/
|
||||
|
||||
util.inherits(Server, EventEmitter);
|
||||
|
||||
/**
|
||||
* Hash of open clients.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Server.prototype.clients;
|
||||
|
||||
/**
|
||||
* Returns a list of available transports for upgrade given a certain transport.
|
||||
*
|
||||
* @return {Array}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Server.prototype.upgrades = function (transport) {
|
||||
if (!this.allowUpgrades) return [];
|
||||
return transports[transport].upgradesTo || [];
|
||||
};
|
||||
|
||||
/**
|
||||
* Verifies a request.
|
||||
*
|
||||
* @param {http.IncomingMessage}
|
||||
* @return {Boolean} whether the request is valid
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Server.prototype.verify = function (req, upgrade, fn) {
|
||||
// transport check
|
||||
var transport = req._query.transport;
|
||||
if (!~this.transports.indexOf(transport)) {
|
||||
debug('unknown transport "%s"', transport);
|
||||
return fn(Server.errors.UNKNOWN_TRANSPORT, false);
|
||||
}
|
||||
|
||||
// sid check
|
||||
var sid = req._query.sid;
|
||||
if (sid) {
|
||||
if (!this.clients.hasOwnProperty(sid)) {
|
||||
return fn(Server.errors.UNKNOWN_SID, false);
|
||||
}
|
||||
if (!upgrade && this.clients[sid].transport.name !== transport) {
|
||||
debug('bad request: unexpected transport without upgrade');
|
||||
return fn(Server.errors.BAD_REQUEST, false);
|
||||
}
|
||||
} else {
|
||||
// handshake is GET only
|
||||
if ('GET' !== req.method) return fn(Server.errors.BAD_HANDSHAKE_METHOD, false);
|
||||
if (!this.allowRequest) return fn(null, true);
|
||||
return this.allowRequest(req, fn);
|
||||
}
|
||||
|
||||
fn(null, true);
|
||||
};
|
||||
|
||||
/**
|
||||
* Prepares a request by processing the query string.
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Server.prototype.prepare = function (req) {
|
||||
// try to leverage pre-existing `req._query` (e.g: from connect)
|
||||
if (!req._query) {
|
||||
req._query = ~req.url.indexOf('?') ? qs.parse(parse(req.url).query) : {};
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Closes all clients.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Server.prototype.close = function () {
|
||||
debug('closing all open clients');
|
||||
for (var i in this.clients) {
|
||||
if (this.clients.hasOwnProperty(i)) {
|
||||
this.clients[i].close(true);
|
||||
}
|
||||
}
|
||||
if (this.ws) {
|
||||
debug('closing webSocketServer');
|
||||
this.ws.close();
|
||||
// don't delete this.ws because it can be used again if the http server starts listening again
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Handles an Engine.IO HTTP request.
|
||||
*
|
||||
* @param {http.IncomingMessage} request
|
||||
* @param {http.ServerResponse|http.OutgoingMessage} response
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Server.prototype.handleRequest = function (req, res) {
|
||||
debug('handling "%s" http request "%s"', req.method, req.url);
|
||||
this.prepare(req);
|
||||
req.res = res;
|
||||
|
||||
var self = this;
|
||||
this.verify(req, false, function (err, success) {
|
||||
if (!success) {
|
||||
sendErrorMessage(req, res, err);
|
||||
return;
|
||||
}
|
||||
|
||||
if (req._query.sid) {
|
||||
debug('setting new request for existing client');
|
||||
self.clients[req._query.sid].transport.onRequest(req);
|
||||
} else {
|
||||
self.handshake(req._query.transport, req);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Sends an Engine.IO Error Message
|
||||
*
|
||||
* @param {http.ServerResponse} response
|
||||
* @param {code} error code
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function sendErrorMessage (req, res, code) {
|
||||
var headers = { 'Content-Type': 'application/json' };
|
||||
|
||||
if (req.headers.origin) {
|
||||
headers['Access-Control-Allow-Credentials'] = 'true';
|
||||
headers['Access-Control-Allow-Origin'] = req.headers.origin;
|
||||
} else {
|
||||
headers['Access-Control-Allow-Origin'] = '*';
|
||||
}
|
||||
res.writeHead(400, headers);
|
||||
res.end(JSON.stringify({
|
||||
code: code,
|
||||
message: Server.errorMessages[code]
|
||||
}));
|
||||
}
|
||||
|
||||
/**
|
||||
* generate a socket id.
|
||||
* Overwrite this method to generate your custom socket id
|
||||
*
|
||||
* @param {Object} request object
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Server.prototype.generateId = function (req) {
|
||||
return base64id.generateId();
|
||||
};
|
||||
|
||||
/**
|
||||
* Handshakes a new client.
|
||||
*
|
||||
* @param {String} transport name
|
||||
* @param {Object} request object
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Server.prototype.handshake = function (transportName, req) {
|
||||
var id = this.generateId(req);
|
||||
|
||||
debug('handshaking client "%s"', id);
|
||||
|
||||
try {
|
||||
var transport = new transports[transportName](req);
|
||||
if ('polling' === transportName) {
|
||||
transport.maxHttpBufferSize = this.maxHttpBufferSize;
|
||||
transport.httpCompression = this.httpCompression;
|
||||
} else if ('websocket' === transportName) {
|
||||
transport.perMessageDeflate = this.perMessageDeflate;
|
||||
}
|
||||
|
||||
if (req._query && req._query.b64) {
|
||||
transport.supportsBinary = false;
|
||||
} else {
|
||||
transport.supportsBinary = true;
|
||||
}
|
||||
} catch (e) {
|
||||
sendErrorMessage(req, req.res, Server.errors.BAD_REQUEST);
|
||||
return;
|
||||
}
|
||||
var socket = new Socket(id, this, transport, req);
|
||||
var self = this;
|
||||
|
||||
if (false !== this.cookie) {
|
||||
transport.on('headers', function (headers) {
|
||||
headers['Set-Cookie'] = cookieMod.serialize(self.cookie, id,
|
||||
{
|
||||
path: self.cookiePath,
|
||||
httpOnly: self.cookiePath ? self.cookieHttpOnly : false
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
transport.onRequest(req);
|
||||
|
||||
this.clients[id] = socket;
|
||||
this.clientsCount++;
|
||||
|
||||
socket.once('close', function () {
|
||||
delete self.clients[id];
|
||||
self.clientsCount--;
|
||||
});
|
||||
|
||||
this.emit('connection', socket);
|
||||
};
|
||||
|
||||
/**
|
||||
* Handles an Engine.IO HTTP Upgrade.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Server.prototype.handleUpgrade = function (req, socket, upgradeHead) {
|
||||
this.prepare(req);
|
||||
|
||||
var self = this;
|
||||
this.verify(req, true, function (err, success) {
|
||||
if (!success) {
|
||||
abortConnection(socket, err);
|
||||
return;
|
||||
}
|
||||
|
||||
var head = new Buffer(upgradeHead.length);
|
||||
upgradeHead.copy(head);
|
||||
upgradeHead = null;
|
||||
|
||||
// delegate to ws
|
||||
self.ws.handleUpgrade(req, socket, head, function (conn) {
|
||||
self.onWebSocket(req, conn);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Called upon a ws.io connection.
|
||||
*
|
||||
* @param {ws.Socket} websocket
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Server.prototype.onWebSocket = function (req, socket) {
|
||||
socket.on('error', onUpgradeError);
|
||||
|
||||
if (!transports[req._query.transport].prototype.handlesUpgrades) {
|
||||
debug('transport doesnt handle upgraded requests');
|
||||
socket.close();
|
||||
return;
|
||||
}
|
||||
|
||||
// get client id
|
||||
var id = req._query.sid;
|
||||
|
||||
// keep a reference to the ws.Socket
|
||||
req.websocket = socket;
|
||||
|
||||
if (id) {
|
||||
var client = this.clients[id];
|
||||
if (!client) {
|
||||
debug('upgrade attempt for closed client');
|
||||
socket.close();
|
||||
} else if (client.upgrading) {
|
||||
debug('transport has already been trying to upgrade');
|
||||
socket.close();
|
||||
} else if (client.upgraded) {
|
||||
debug('transport had already been upgraded');
|
||||
socket.close();
|
||||
} else {
|
||||
debug('upgrading existing transport');
|
||||
|
||||
// transport error handling takes over
|
||||
socket.removeListener('error', onUpgradeError);
|
||||
|
||||
var transport = new transports[req._query.transport](req);
|
||||
if (req._query && req._query.b64) {
|
||||
transport.supportsBinary = false;
|
||||
} else {
|
||||
transport.supportsBinary = true;
|
||||
}
|
||||
transport.perMessageDeflate = this.perMessageDeflate;
|
||||
client.maybeUpgrade(transport);
|
||||
}
|
||||
} else {
|
||||
// transport error handling takes over
|
||||
socket.removeListener('error', onUpgradeError);
|
||||
|
||||
this.handshake(req._query.transport, req);
|
||||
}
|
||||
|
||||
function onUpgradeError () {
|
||||
debug('websocket error before upgrade');
|
||||
// socket.close() not needed
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Captures upgrade requests for a http.Server.
|
||||
*
|
||||
* @param {http.Server} server
|
||||
* @param {Object} options
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Server.prototype.attach = function (server, options) {
|
||||
var self = this;
|
||||
options = options || {};
|
||||
var path = (options.path || '/engine.io').replace(/\/$/, '');
|
||||
|
||||
var destroyUpgradeTimeout = options.destroyUpgradeTimeout || 1000;
|
||||
|
||||
// normalize path
|
||||
path += '/';
|
||||
|
||||
function check (req) {
|
||||
return path === req.url.substr(0, path.length);
|
||||
}
|
||||
|
||||
// cache and clean up listeners
|
||||
var listeners = server.listeners('request').slice(0);
|
||||
server.removeAllListeners('request');
|
||||
server.on('close', self.close.bind(self));
|
||||
|
||||
// add request handler
|
||||
server.on('request', function (req, res) {
|
||||
if (check(req)) {
|
||||
debug('intercepting request for path "%s"', path);
|
||||
self.handleRequest(req, res);
|
||||
} else {
|
||||
for (var i = 0, l = listeners.length; i < l; i++) {
|
||||
listeners[i].call(server, req, res);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (~self.transports.indexOf('websocket')) {
|
||||
server.on('upgrade', function (req, socket, head) {
|
||||
if (check(req)) {
|
||||
self.handleUpgrade(req, socket, head);
|
||||
} else if (false !== options.destroyUpgrade) {
|
||||
// default node behavior is to disconnect when no handlers
|
||||
// but by adding a handler, we prevent that
|
||||
// and if no eio thing handles the upgrade
|
||||
// then the socket needs to die!
|
||||
setTimeout(function () {
|
||||
if (socket.writable && socket.bytesWritten <= 0) {
|
||||
return socket.end();
|
||||
}
|
||||
}, destroyUpgradeTimeout);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Closes the connection
|
||||
*
|
||||
* @param {net.Socket} socket
|
||||
* @param {code} error code
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function abortConnection (socket, code) {
|
||||
if (socket.writable) {
|
||||
var message = Server.errorMessages.hasOwnProperty(code) ? Server.errorMessages[code] : (code || '');
|
||||
var length = Buffer.byteLength(message);
|
||||
socket.write(
|
||||
'HTTP/1.1 400 Bad Request\r\n' +
|
||||
'Connection: close\r\n' +
|
||||
'Content-type: text/html\r\n' +
|
||||
'Content-Length: ' + length + '\r\n' +
|
||||
'\r\n' +
|
||||
message
|
||||
);
|
||||
}
|
||||
socket.destroy();
|
||||
}
|
479
node_modules/socketio/node_modules/engine.io/lib/socket.js
generated
vendored
Normal file
479
node_modules/socketio/node_modules/engine.io/lib/socket.js
generated
vendored
Normal file
@ -0,0 +1,479 @@
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var EventEmitter = require('events').EventEmitter;
|
||||
var util = require('util');
|
||||
var debug = require('debug')('engine:socket');
|
||||
|
||||
/**
|
||||
* Module exports.
|
||||
*/
|
||||
|
||||
module.exports = Socket;
|
||||
|
||||
/**
|
||||
* Client class (abstract).
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function Socket (id, server, transport, req) {
|
||||
this.id = id;
|
||||
this.server = server;
|
||||
this.upgrading = false;
|
||||
this.upgraded = false;
|
||||
this.readyState = 'opening';
|
||||
this.writeBuffer = [];
|
||||
this.packetsFn = [];
|
||||
this.sentCallbackFn = [];
|
||||
this.cleanupFn = [];
|
||||
this.request = req;
|
||||
|
||||
// Cache IP since it might not be in the req later
|
||||
this.remoteAddress = req.connection.remoteAddress;
|
||||
|
||||
this.checkIntervalTimer = null;
|
||||
this.upgradeTimeoutTimer = null;
|
||||
this.pingTimeoutTimer = null;
|
||||
|
||||
this.setTransport(transport);
|
||||
this.onOpen();
|
||||
}
|
||||
|
||||
/**
|
||||
* Inherits from EventEmitter.
|
||||
*/
|
||||
|
||||
util.inherits(Socket, EventEmitter);
|
||||
|
||||
/**
|
||||
* Called upon transport considered open.
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Socket.prototype.onOpen = function () {
|
||||
this.readyState = 'open';
|
||||
|
||||
// sends an `open` packet
|
||||
this.transport.sid = this.id;
|
||||
this.sendPacket('open', JSON.stringify({
|
||||
sid: this.id,
|
||||
upgrades: this.getAvailableUpgrades(),
|
||||
pingInterval: this.server.pingInterval,
|
||||
pingTimeout: this.server.pingTimeout
|
||||
}));
|
||||
|
||||
this.emit('open');
|
||||
this.setPingTimeout();
|
||||
};
|
||||
|
||||
/**
|
||||
* Called upon transport packet.
|
||||
*
|
||||
* @param {Object} packet
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Socket.prototype.onPacket = function (packet) {
|
||||
if ('open' === this.readyState) {
|
||||
// export packet event
|
||||
debug('packet');
|
||||
this.emit('packet', packet);
|
||||
|
||||
// Reset ping timeout on any packet, incoming data is a good sign of
|
||||
// other side's liveness
|
||||
this.setPingTimeout();
|
||||
|
||||
switch (packet.type) {
|
||||
|
||||
case 'ping':
|
||||
debug('got ping');
|
||||
this.sendPacket('pong');
|
||||
this.emit('heartbeat');
|
||||
break;
|
||||
|
||||
case 'error':
|
||||
this.onClose('parse error');
|
||||
break;
|
||||
|
||||
case 'message':
|
||||
this.emit('data', packet.data);
|
||||
this.emit('message', packet.data);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
debug('packet received with closed socket');
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Called upon transport error.
|
||||
*
|
||||
* @param {Error} error object
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Socket.prototype.onError = function (err) {
|
||||
debug('transport error');
|
||||
this.onClose('transport error', err);
|
||||
};
|
||||
|
||||
/**
|
||||
* Sets and resets ping timeout timer based on client pings.
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Socket.prototype.setPingTimeout = function () {
|
||||
var self = this;
|
||||
clearTimeout(self.pingTimeoutTimer);
|
||||
self.pingTimeoutTimer = setTimeout(function () {
|
||||
self.onClose('ping timeout');
|
||||
}, self.server.pingInterval + self.server.pingTimeout);
|
||||
};
|
||||
|
||||
/**
|
||||
* Attaches handlers for the given transport.
|
||||
*
|
||||
* @param {Transport} transport
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Socket.prototype.setTransport = function (transport) {
|
||||
var onError = this.onError.bind(this);
|
||||
var onPacket = this.onPacket.bind(this);
|
||||
var flush = this.flush.bind(this);
|
||||
var onClose = this.onClose.bind(this, 'transport close');
|
||||
|
||||
this.transport = transport;
|
||||
this.transport.once('error', onError);
|
||||
this.transport.on('packet', onPacket);
|
||||
this.transport.on('drain', flush);
|
||||
this.transport.once('close', onClose);
|
||||
// this function will manage packet events (also message callbacks)
|
||||
this.setupSendCallback();
|
||||
|
||||
this.cleanupFn.push(function () {
|
||||
transport.removeListener('error', onError);
|
||||
transport.removeListener('packet', onPacket);
|
||||
transport.removeListener('drain', flush);
|
||||
transport.removeListener('close', onClose);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Upgrades socket to the given transport
|
||||
*
|
||||
* @param {Transport} transport
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Socket.prototype.maybeUpgrade = function (transport) {
|
||||
debug('might upgrade socket transport from "%s" to "%s"'
|
||||
, this.transport.name, transport.name);
|
||||
|
||||
this.upgrading = true;
|
||||
|
||||
var self = this;
|
||||
|
||||
// set transport upgrade timer
|
||||
self.upgradeTimeoutTimer = setTimeout(function () {
|
||||
debug('client did not complete upgrade - closing transport');
|
||||
cleanup();
|
||||
if ('open' === transport.readyState) {
|
||||
transport.close();
|
||||
}
|
||||
}, this.server.upgradeTimeout);
|
||||
|
||||
function onPacket (packet) {
|
||||
if ('ping' === packet.type && 'probe' === packet.data) {
|
||||
transport.send([{ type: 'pong', data: 'probe' }]);
|
||||
self.emit('upgrading', transport);
|
||||
clearInterval(self.checkIntervalTimer);
|
||||
self.checkIntervalTimer = setInterval(check, 100);
|
||||
} else if ('upgrade' === packet.type && self.readyState !== 'closed') {
|
||||
debug('got upgrade packet - upgrading');
|
||||
cleanup();
|
||||
self.transport.discard();
|
||||
self.upgraded = true;
|
||||
self.clearTransport();
|
||||
self.setTransport(transport);
|
||||
self.emit('upgrade', transport);
|
||||
self.setPingTimeout();
|
||||
self.flush();
|
||||
if (self.readyState === 'closing') {
|
||||
transport.close(function () {
|
||||
self.onClose('forced close');
|
||||
});
|
||||
}
|
||||
} else {
|
||||
cleanup();
|
||||
transport.close();
|
||||
}
|
||||
}
|
||||
|
||||
// we force a polling cycle to ensure a fast upgrade
|
||||
function check () {
|
||||
if ('polling' === self.transport.name && self.transport.writable) {
|
||||
debug('writing a noop packet to polling for fast upgrade');
|
||||
self.transport.send([{ type: 'noop' }]);
|
||||
}
|
||||
}
|
||||
|
||||
function cleanup () {
|
||||
self.upgrading = false;
|
||||
|
||||
clearInterval(self.checkIntervalTimer);
|
||||
self.checkIntervalTimer = null;
|
||||
|
||||
clearTimeout(self.upgradeTimeoutTimer);
|
||||
self.upgradeTimeoutTimer = null;
|
||||
|
||||
transport.removeListener('packet', onPacket);
|
||||
transport.removeListener('close', onTransportClose);
|
||||
transport.removeListener('error', onError);
|
||||
self.removeListener('close', onClose);
|
||||
}
|
||||
|
||||
function onError (err) {
|
||||
debug('client did not complete upgrade - %s', err);
|
||||
cleanup();
|
||||
transport.close();
|
||||
transport = null;
|
||||
}
|
||||
|
||||
function onTransportClose () {
|
||||
onError('transport closed');
|
||||
}
|
||||
|
||||
function onClose () {
|
||||
onError('socket closed');
|
||||
}
|
||||
|
||||
transport.on('packet', onPacket);
|
||||
transport.once('close', onTransportClose);
|
||||
transport.once('error', onError);
|
||||
|
||||
self.once('close', onClose);
|
||||
};
|
||||
|
||||
/**
|
||||
* Clears listeners and timers associated with current transport.
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Socket.prototype.clearTransport = function () {
|
||||
var cleanup;
|
||||
|
||||
var toCleanUp = this.cleanupFn.length;
|
||||
|
||||
for (var i = 0; i < toCleanUp; i++) {
|
||||
cleanup = this.cleanupFn.shift();
|
||||
cleanup();
|
||||
}
|
||||
|
||||
// silence further transport errors and prevent uncaught exceptions
|
||||
this.transport.on('error', function () {
|
||||
debug('error triggered by discarded transport');
|
||||
});
|
||||
|
||||
// ensure transport won't stay open
|
||||
this.transport.close();
|
||||
|
||||
clearTimeout(this.pingTimeoutTimer);
|
||||
};
|
||||
|
||||
/**
|
||||
* Called upon transport considered closed.
|
||||
* Possible reasons: `ping timeout`, `client error`, `parse error`,
|
||||
* `transport error`, `server close`, `transport close`
|
||||
*/
|
||||
|
||||
Socket.prototype.onClose = function (reason, description) {
|
||||
if ('closed' !== this.readyState) {
|
||||
this.readyState = 'closed';
|
||||
clearTimeout(this.pingTimeoutTimer);
|
||||
clearInterval(this.checkIntervalTimer);
|
||||
this.checkIntervalTimer = null;
|
||||
clearTimeout(this.upgradeTimeoutTimer);
|
||||
var self = this;
|
||||
// clean writeBuffer in next tick, so developers can still
|
||||
// grab the writeBuffer on 'close' event
|
||||
process.nextTick(function () {
|
||||
self.writeBuffer = [];
|
||||
});
|
||||
this.packetsFn = [];
|
||||
this.sentCallbackFn = [];
|
||||
this.clearTransport();
|
||||
this.emit('close', reason, description);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Setup and manage send callback
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Socket.prototype.setupSendCallback = function () {
|
||||
var self = this;
|
||||
this.transport.on('drain', onDrain);
|
||||
|
||||
this.cleanupFn.push(function () {
|
||||
self.transport.removeListener('drain', onDrain);
|
||||
});
|
||||
|
||||
// the message was sent successfully, execute the callback
|
||||
function onDrain () {
|
||||
if (self.sentCallbackFn.length > 0) {
|
||||
var seqFn = self.sentCallbackFn.splice(0, 1)[0];
|
||||
if ('function' === typeof seqFn) {
|
||||
debug('executing send callback');
|
||||
seqFn(self.transport);
|
||||
} else if (Array.isArray(seqFn)) {
|
||||
debug('executing batch send callback');
|
||||
for (var l = seqFn.length, i = 0; i < l; i++) {
|
||||
if ('function' === typeof seqFn[i]) {
|
||||
seqFn[i](self.transport);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Sends a message packet.
|
||||
*
|
||||
* @param {String} message
|
||||
* @param {Object} options
|
||||
* @param {Function} callback
|
||||
* @return {Socket} for chaining
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Socket.prototype.send =
|
||||
Socket.prototype.write = function (data, options, callback) {
|
||||
this.sendPacket('message', data, options, callback);
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Sends a packet.
|
||||
*
|
||||
* @param {String} packet type
|
||||
* @param {String} optional, data
|
||||
* @param {Object} options
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Socket.prototype.sendPacket = function (type, data, options, callback) {
|
||||
if ('function' === typeof options) {
|
||||
callback = options;
|
||||
options = null;
|
||||
}
|
||||
|
||||
options = options || {};
|
||||
options.compress = false !== options.compress;
|
||||
|
||||
if ('closing' !== this.readyState) {
|
||||
debug('sending packet "%s" (%s)', type, data);
|
||||
|
||||
var packet = {
|
||||
type: type,
|
||||
options: options
|
||||
};
|
||||
if (data) packet.data = data;
|
||||
|
||||
// exports packetCreate event
|
||||
this.emit('packetCreate', packet);
|
||||
|
||||
this.writeBuffer.push(packet);
|
||||
|
||||
// add send callback to object, if defined
|
||||
if (callback) this.packetsFn.push(callback);
|
||||
|
||||
this.flush();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Attempts to flush the packets buffer.
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Socket.prototype.flush = function () {
|
||||
if ('closed' !== this.readyState &&
|
||||
this.transport.writable &&
|
||||
this.writeBuffer.length) {
|
||||
debug('flushing buffer to transport');
|
||||
this.emit('flush', this.writeBuffer);
|
||||
this.server.emit('flush', this, this.writeBuffer);
|
||||
var wbuf = this.writeBuffer;
|
||||
this.writeBuffer = [];
|
||||
if (!this.transport.supportsFraming) {
|
||||
this.sentCallbackFn.push(this.packetsFn);
|
||||
} else {
|
||||
this.sentCallbackFn.push.apply(this.sentCallbackFn, this.packetsFn);
|
||||
}
|
||||
this.packetsFn = [];
|
||||
this.transport.send(wbuf);
|
||||
this.emit('drain');
|
||||
this.server.emit('drain', this);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Get available upgrades for this socket.
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Socket.prototype.getAvailableUpgrades = function () {
|
||||
var availableUpgrades = [];
|
||||
var allUpgrades = this.server.upgrades(this.transport.name);
|
||||
for (var i = 0, l = allUpgrades.length; i < l; ++i) {
|
||||
var upg = allUpgrades[i];
|
||||
if (this.server.transports.indexOf(upg) !== -1) {
|
||||
availableUpgrades.push(upg);
|
||||
}
|
||||
}
|
||||
return availableUpgrades;
|
||||
};
|
||||
|
||||
/**
|
||||
* Closes the socket and underlying transport.
|
||||
*
|
||||
* @param {Boolean} optional, discard
|
||||
* @return {Socket} for chaining
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Socket.prototype.close = function (discard) {
|
||||
if ('open' !== this.readyState) return;
|
||||
|
||||
this.readyState = 'closing';
|
||||
|
||||
if (this.writeBuffer.length) {
|
||||
this.once('drain', this.closeTransport.bind(this, discard));
|
||||
return;
|
||||
}
|
||||
|
||||
this.closeTransport(discard);
|
||||
};
|
||||
|
||||
/**
|
||||
* Closes the underlying transport.
|
||||
*
|
||||
* @param {Boolean} discard
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Socket.prototype.closeTransport = function (discard) {
|
||||
if (discard) this.transport.discard();
|
||||
this.transport.close(this.onClose.bind(this, 'forced close'));
|
||||
};
|
128
node_modules/socketio/node_modules/engine.io/lib/transport.js
generated
vendored
Normal file
128
node_modules/socketio/node_modules/engine.io/lib/transport.js
generated
vendored
Normal file
@ -0,0 +1,128 @@
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var EventEmitter = require('events').EventEmitter;
|
||||
var parser = require('engine.io-parser');
|
||||
var util = require('util');
|
||||
var debug = require('debug')('engine:transport');
|
||||
|
||||
/**
|
||||
* Expose the constructor.
|
||||
*/
|
||||
|
||||
module.exports = Transport;
|
||||
|
||||
/**
|
||||
* Noop function.
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function noop () {}
|
||||
|
||||
/**
|
||||
* Transport constructor.
|
||||
*
|
||||
* @param {http.IncomingMessage} request
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function Transport (req) {
|
||||
this.readyState = 'open';
|
||||
this.discarded = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inherits from EventEmitter.
|
||||
*/
|
||||
|
||||
util.inherits(Transport, EventEmitter);
|
||||
|
||||
/**
|
||||
* Flags the transport as discarded.
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Transport.prototype.discard = function () {
|
||||
this.discarded = true;
|
||||
};
|
||||
|
||||
/**
|
||||
* Called with an incoming HTTP request.
|
||||
*
|
||||
* @param {http.IncomingMessage} request
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Transport.prototype.onRequest = function (req) {
|
||||
debug('setting request');
|
||||
this.req = req;
|
||||
};
|
||||
|
||||
/**
|
||||
* Closes the transport.
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Transport.prototype.close = function (fn) {
|
||||
if ('closed' === this.readyState || 'closing' === this.readyState) return;
|
||||
|
||||
this.readyState = 'closing';
|
||||
this.doClose(fn || noop);
|
||||
};
|
||||
|
||||
/**
|
||||
* Called with a transport error.
|
||||
*
|
||||
* @param {String} message error
|
||||
* @param {Object} error description
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Transport.prototype.onError = function (msg, desc) {
|
||||
if (this.listeners('error').length) {
|
||||
var err = new Error(msg);
|
||||
err.type = 'TransportError';
|
||||
err.description = desc;
|
||||
this.emit('error', err);
|
||||
} else {
|
||||
debug('ignored transport error %s (%s)', msg, desc);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Called with parsed out a packets from the data stream.
|
||||
*
|
||||
* @param {Object} packet
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Transport.prototype.onPacket = function (packet) {
|
||||
this.emit('packet', packet);
|
||||
};
|
||||
|
||||
/**
|
||||
* Called with the encoded packet data.
|
||||
*
|
||||
* @param {String} data
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Transport.prototype.onData = function (data) {
|
||||
this.onPacket(parser.decodePacket(data));
|
||||
};
|
||||
|
||||
/**
|
||||
* Called upon transport close.
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Transport.prototype.onClose = function () {
|
||||
this.readyState = 'closed';
|
||||
this.emit('close');
|
||||
};
|
36
node_modules/socketio/node_modules/engine.io/lib/transports/index.js
generated
vendored
Normal file
36
node_modules/socketio/node_modules/engine.io/lib/transports/index.js
generated
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var XHR = require('./polling-xhr');
|
||||
var JSONP = require('./polling-jsonp');
|
||||
|
||||
/**
|
||||
* Export transports.
|
||||
*/
|
||||
|
||||
module.exports = exports = {
|
||||
polling: polling,
|
||||
websocket: require('./websocket')
|
||||
};
|
||||
|
||||
/**
|
||||
* Export upgrades map.
|
||||
*/
|
||||
|
||||
exports.polling.upgradesTo = ['websocket'];
|
||||
|
||||
/**
|
||||
* Polling polymorphic constructor.
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function polling (req) {
|
||||
if ('string' === typeof req._query.j) {
|
||||
return new JSONP(req);
|
||||
} else {
|
||||
return new XHR(req);
|
||||
}
|
||||
}
|
75
node_modules/socketio/node_modules/engine.io/lib/transports/polling-jsonp.js
generated
vendored
Normal file
75
node_modules/socketio/node_modules/engine.io/lib/transports/polling-jsonp.js
generated
vendored
Normal file
@ -0,0 +1,75 @@
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var Polling = require('./polling');
|
||||
var qs = require('querystring');
|
||||
var rDoubleSlashes = /\\\\n/g;
|
||||
var rSlashes = /(\\)?\\n/g;
|
||||
var util = require('util');
|
||||
|
||||
/**
|
||||
* Module exports.
|
||||
*/
|
||||
|
||||
module.exports = JSONP;
|
||||
|
||||
/**
|
||||
* JSON-P polling transport.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function JSONP (req) {
|
||||
Polling.call(this, req);
|
||||
|
||||
this.head = '___eio[' + (req._query.j || '').replace(/[^0-9]/g, '') + '](';
|
||||
this.foot = ');';
|
||||
}
|
||||
|
||||
/**
|
||||
* Inherits from Polling.
|
||||
*/
|
||||
|
||||
util.inherits(JSONP, Polling);
|
||||
|
||||
/**
|
||||
* Handles incoming data.
|
||||
* Due to a bug in \n handling by browsers, we expect a escaped string.
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
JSONP.prototype.onData = function (data) {
|
||||
// we leverage the qs module so that we get built-in DoS protection
|
||||
// and the fast alternative to decodeURIComponent
|
||||
data = qs.parse(data).d;
|
||||
if ('string' === typeof data) {
|
||||
// client will send already escaped newlines as \\\\n and newlines as \\n
|
||||
// \\n must be replaced with \n and \\\\n with \\n
|
||||
data = data.replace(rSlashes, function (match, slashes) {
|
||||
return slashes ? match : '\n';
|
||||
});
|
||||
Polling.prototype.onData.call(this, data.replace(rDoubleSlashes, '\\n'));
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Performs the write.
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
JSONP.prototype.doWrite = function (data, options, callback) {
|
||||
// we must output valid javascript, not valid json
|
||||
// see: http://timelessrepo.com/json-isnt-a-javascript-subset
|
||||
var js = JSON.stringify(data)
|
||||
.replace(/\u2028/g, '\\u2028')
|
||||
.replace(/\u2029/g, '\\u2029');
|
||||
|
||||
// prepare response
|
||||
data = this.head + js + this.foot;
|
||||
|
||||
Polling.prototype.doWrite.call(this, data, options, callback);
|
||||
};
|
69
node_modules/socketio/node_modules/engine.io/lib/transports/polling-xhr.js
generated
vendored
Normal file
69
node_modules/socketio/node_modules/engine.io/lib/transports/polling-xhr.js
generated
vendored
Normal file
@ -0,0 +1,69 @@
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var Polling = require('./polling');
|
||||
var util = require('util');
|
||||
|
||||
/**
|
||||
* Module exports.
|
||||
*/
|
||||
|
||||
module.exports = XHR;
|
||||
|
||||
/**
|
||||
* Ajax polling transport.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function XHR (req) {
|
||||
Polling.call(this, req);
|
||||
}
|
||||
|
||||
/**
|
||||
* Inherits from Polling.
|
||||
*/
|
||||
|
||||
util.inherits(XHR, Polling);
|
||||
|
||||
/**
|
||||
* Overrides `onRequest` to handle `OPTIONS`..
|
||||
*
|
||||
* @param {http.IncomingMessage}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
XHR.prototype.onRequest = function (req) {
|
||||
if ('OPTIONS' === req.method) {
|
||||
var res = req.res;
|
||||
var headers = this.headers(req);
|
||||
headers['Access-Control-Allow-Headers'] = 'Content-Type';
|
||||
res.writeHead(200, headers);
|
||||
res.end();
|
||||
} else {
|
||||
Polling.prototype.onRequest.call(this, req);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns headers for a response.
|
||||
*
|
||||
* @param {http.IncomingMessage} request
|
||||
* @param {Object} extra headers
|
||||
* @api private
|
||||
*/
|
||||
|
||||
XHR.prototype.headers = function (req, headers) {
|
||||
headers = headers || {};
|
||||
|
||||
if (req.headers.origin) {
|
||||
headers['Access-Control-Allow-Credentials'] = 'true';
|
||||
headers['Access-Control-Allow-Origin'] = req.headers.origin;
|
||||
} else {
|
||||
headers['Access-Control-Allow-Origin'] = '*';
|
||||
}
|
||||
|
||||
return Polling.prototype.headers.call(this, req, headers);
|
||||
};
|
408
node_modules/socketio/node_modules/engine.io/lib/transports/polling.js
generated
vendored
Normal file
408
node_modules/socketio/node_modules/engine.io/lib/transports/polling.js
generated
vendored
Normal file
@ -0,0 +1,408 @@
|
||||
|
||||
/**
|
||||
* Module requirements.
|
||||
*/
|
||||
|
||||
var Transport = require('../transport');
|
||||
var parser = require('engine.io-parser');
|
||||
var zlib = require('zlib');
|
||||
var accepts = require('accepts');
|
||||
var util = require('util');
|
||||
var debug = require('debug')('engine:polling');
|
||||
|
||||
var compressionMethods = {
|
||||
gzip: zlib.createGzip,
|
||||
deflate: zlib.createDeflate
|
||||
};
|
||||
|
||||
/**
|
||||
* Exports the constructor.
|
||||
*/
|
||||
|
||||
module.exports = Polling;
|
||||
|
||||
/**
|
||||
* HTTP polling constructor.
|
||||
*
|
||||
* @api public.
|
||||
*/
|
||||
|
||||
function Polling (req) {
|
||||
Transport.call(this, req);
|
||||
|
||||
this.closeTimeout = 30 * 1000;
|
||||
this.maxHttpBufferSize = null;
|
||||
this.httpCompression = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inherits from Transport.
|
||||
*
|
||||
* @api public.
|
||||
*/
|
||||
|
||||
util.inherits(Polling, Transport);
|
||||
|
||||
/**
|
||||
* Transport name
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Polling.prototype.name = 'polling';
|
||||
|
||||
/**
|
||||
* Overrides onRequest.
|
||||
*
|
||||
* @param {http.IncomingMessage}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Polling.prototype.onRequest = function (req) {
|
||||
var res = req.res;
|
||||
|
||||
if ('GET' === req.method) {
|
||||
this.onPollRequest(req, res);
|
||||
} else if ('POST' === req.method) {
|
||||
this.onDataRequest(req, res);
|
||||
} else {
|
||||
res.writeHead(500);
|
||||
res.end();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* The client sends a request awaiting for us to send data.
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Polling.prototype.onPollRequest = function (req, res) {
|
||||
if (this.req) {
|
||||
debug('request overlap');
|
||||
// assert: this.res, '.req and .res should be (un)set together'
|
||||
this.onError('overlap from client');
|
||||
res.writeHead(500);
|
||||
res.end();
|
||||
return;
|
||||
}
|
||||
|
||||
debug('setting request');
|
||||
|
||||
this.req = req;
|
||||
this.res = res;
|
||||
|
||||
var self = this;
|
||||
|
||||
function onClose () {
|
||||
self.onError('poll connection closed prematurely');
|
||||
}
|
||||
|
||||
function cleanup () {
|
||||
req.removeListener('close', onClose);
|
||||
self.req = self.res = null;
|
||||
}
|
||||
|
||||
req.cleanup = cleanup;
|
||||
req.on('close', onClose);
|
||||
|
||||
this.writable = true;
|
||||
this.emit('drain');
|
||||
|
||||
// if we're still writable but had a pending close, trigger an empty send
|
||||
if (this.writable && this.shouldClose) {
|
||||
debug('triggering empty send to append close packet');
|
||||
this.send([{ type: 'noop' }]);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* The client sends a request with data.
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Polling.prototype.onDataRequest = function (req, res) {
|
||||
if (this.dataReq) {
|
||||
// assert: this.dataRes, '.dataReq and .dataRes should be (un)set together'
|
||||
this.onError('data request overlap from client');
|
||||
res.writeHead(500);
|
||||
res.end();
|
||||
return;
|
||||
}
|
||||
|
||||
var isBinary = 'application/octet-stream' === req.headers['content-type'];
|
||||
|
||||
this.dataReq = req;
|
||||
this.dataRes = res;
|
||||
|
||||
var chunks = isBinary ? new Buffer(0) : '';
|
||||
var self = this;
|
||||
|
||||
function cleanup () {
|
||||
chunks = isBinary ? new Buffer(0) : '';
|
||||
req.removeListener('data', onData);
|
||||
req.removeListener('end', onEnd);
|
||||
req.removeListener('close', onClose);
|
||||
self.dataReq = self.dataRes = null;
|
||||
}
|
||||
|
||||
function onClose () {
|
||||
cleanup();
|
||||
self.onError('data request connection closed prematurely');
|
||||
}
|
||||
|
||||
function onData (data) {
|
||||
var contentLength;
|
||||
if (typeof data === 'string') {
|
||||
chunks += data;
|
||||
contentLength = Buffer.byteLength(chunks);
|
||||
} else {
|
||||
chunks = Buffer.concat([chunks, data]);
|
||||
contentLength = chunks.length;
|
||||
}
|
||||
|
||||
if (contentLength > self.maxHttpBufferSize) {
|
||||
chunks = '';
|
||||
req.connection.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
function onEnd () {
|
||||
self.onData(chunks);
|
||||
|
||||
var headers = {
|
||||
// text/html is required instead of text/plain to avoid an
|
||||
// unwanted download dialog on certain user-agents (GH-43)
|
||||
'Content-Type': 'text/html',
|
||||
'Content-Length': 2
|
||||
};
|
||||
|
||||
res.writeHead(200, self.headers(req, headers));
|
||||
res.end('ok');
|
||||
cleanup();
|
||||
}
|
||||
|
||||
req.on('close', onClose);
|
||||
if (!isBinary) req.setEncoding('utf8');
|
||||
req.on('data', onData);
|
||||
req.on('end', onEnd);
|
||||
};
|
||||
|
||||
/**
|
||||
* Processes the incoming data payload.
|
||||
*
|
||||
* @param {String} encoded payload
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Polling.prototype.onData = function (data) {
|
||||
debug('received "%s"', data);
|
||||
var self = this;
|
||||
var callback = function (packet) {
|
||||
if ('close' === packet.type) {
|
||||
debug('got xhr close packet');
|
||||
self.onClose();
|
||||
return false;
|
||||
}
|
||||
|
||||
self.onPacket(packet);
|
||||
};
|
||||
|
||||
parser.decodePayload(data, callback);
|
||||
};
|
||||
|
||||
/**
|
||||
* Overrides onClose.
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Polling.prototype.onClose = function () {
|
||||
if (this.writable) {
|
||||
// close pending poll request
|
||||
this.send([{ type: 'noop' }]);
|
||||
}
|
||||
Transport.prototype.onClose.call(this);
|
||||
};
|
||||
|
||||
/**
|
||||
* Writes a packet payload.
|
||||
*
|
||||
* @param {Object} packet
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Polling.prototype.send = function (packets) {
|
||||
this.writable = false;
|
||||
|
||||
if (this.shouldClose) {
|
||||
debug('appending close packet to payload');
|
||||
packets.push({ type: 'close' });
|
||||
this.shouldClose();
|
||||
this.shouldClose = null;
|
||||
}
|
||||
|
||||
var self = this;
|
||||
parser.encodePayload(packets, this.supportsBinary, function (data) {
|
||||
var compress = packets.some(function (packet) {
|
||||
return packet.options && packet.options.compress;
|
||||
});
|
||||
self.write(data, { compress: compress });
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Writes data as response to poll request.
|
||||
*
|
||||
* @param {String} data
|
||||
* @param {Object} options
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Polling.prototype.write = function (data, options) {
|
||||
debug('writing "%s"', data);
|
||||
var self = this;
|
||||
this.doWrite(data, options, function () {
|
||||
self.req.cleanup();
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Performs the write.
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Polling.prototype.doWrite = function (data, options, callback) {
|
||||
var self = this;
|
||||
|
||||
// explicit UTF-8 is required for pages not served under utf
|
||||
var isString = typeof data === 'string';
|
||||
var contentType = isString
|
||||
? 'text/plain; charset=UTF-8'
|
||||
: 'application/octet-stream';
|
||||
|
||||
var headers = {
|
||||
'Content-Type': contentType
|
||||
};
|
||||
|
||||
if (!this.httpCompression || !options.compress) {
|
||||
respond(data);
|
||||
return;
|
||||
}
|
||||
|
||||
var len = isString ? Buffer.byteLength(data) : data.length;
|
||||
if (len < this.httpCompression.threshold) {
|
||||
respond(data);
|
||||
return;
|
||||
}
|
||||
|
||||
var encoding = accepts(this.req).encodings(['gzip', 'deflate']);
|
||||
if (!encoding) {
|
||||
respond(data);
|
||||
return;
|
||||
}
|
||||
|
||||
this.compress(data, encoding, function (err, data) {
|
||||
if (err) {
|
||||
self.res.writeHead(500);
|
||||
self.res.end();
|
||||
callback(err);
|
||||
return;
|
||||
}
|
||||
|
||||
headers['Content-Encoding'] = encoding;
|
||||
respond(data);
|
||||
});
|
||||
|
||||
function respond (data) {
|
||||
headers['Content-Length'] = 'string' === typeof data ? Buffer.byteLength(data) : data.length;
|
||||
self.res.writeHead(200, self.headers(self.req, headers));
|
||||
self.res.end(data);
|
||||
callback();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Comparesses data.
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Polling.prototype.compress = function (data, encoding, callback) {
|
||||
debug('compressing');
|
||||
|
||||
var buffers = [];
|
||||
var nread = 0;
|
||||
|
||||
compressionMethods[encoding](this.httpCompression)
|
||||
.on('error', callback)
|
||||
.on('data', function (chunk) {
|
||||
buffers.push(chunk);
|
||||
nread += chunk.length;
|
||||
})
|
||||
.on('end', function () {
|
||||
callback(null, Buffer.concat(buffers, nread));
|
||||
})
|
||||
.end(data);
|
||||
};
|
||||
|
||||
/**
|
||||
* Closes the transport.
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Polling.prototype.doClose = function (fn) {
|
||||
debug('closing');
|
||||
|
||||
var self = this;
|
||||
var closeTimeoutTimer;
|
||||
|
||||
if (this.dataReq) {
|
||||
debug('aborting ongoing data request');
|
||||
this.dataReq.destroy();
|
||||
}
|
||||
|
||||
if (this.writable) {
|
||||
debug('transport writable - closing right away');
|
||||
this.send([{ type: 'close' }]);
|
||||
onClose();
|
||||
} else if (this.discarded) {
|
||||
debug('transport discarded - closing right away');
|
||||
onClose();
|
||||
} else {
|
||||
debug('transport not writable - buffering orderly close');
|
||||
this.shouldClose = onClose;
|
||||
closeTimeoutTimer = setTimeout(onClose, this.closeTimeout);
|
||||
}
|
||||
|
||||
function onClose () {
|
||||
clearTimeout(closeTimeoutTimer);
|
||||
fn();
|
||||
self.onClose();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns headers for a response.
|
||||
*
|
||||
* @param {http.IncomingMessage} request
|
||||
* @param {Object} extra headers
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Polling.prototype.headers = function (req, headers) {
|
||||
headers = headers || {};
|
||||
|
||||
// prevent XSS warnings on IE
|
||||
// https://github.com/LearnBoost/socket.io/pull/1333
|
||||
var ua = req.headers['user-agent'];
|
||||
if (ua && (~ua.indexOf(';MSIE') || ~ua.indexOf('Trident/'))) {
|
||||
headers['X-XSS-Protection'] = '0';
|
||||
}
|
||||
|
||||
this.emit('headers', headers);
|
||||
return headers;
|
||||
};
|
134
node_modules/socketio/node_modules/engine.io/lib/transports/websocket.js
generated
vendored
Normal file
134
node_modules/socketio/node_modules/engine.io/lib/transports/websocket.js
generated
vendored
Normal file
@ -0,0 +1,134 @@
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var Transport = require('../transport');
|
||||
var parser = require('engine.io-parser');
|
||||
var util = require('util');
|
||||
var debug = require('debug')('engine:ws');
|
||||
|
||||
/**
|
||||
* Export the constructor.
|
||||
*/
|
||||
|
||||
module.exports = WebSocket;
|
||||
|
||||
/**
|
||||
* WebSocket transport
|
||||
*
|
||||
* @param {http.IncomingMessage}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function WebSocket (req) {
|
||||
Transport.call(this, req);
|
||||
var self = this;
|
||||
this.socket = req.websocket;
|
||||
this.socket.on('message', this.onData.bind(this));
|
||||
this.socket.once('close', this.onClose.bind(this));
|
||||
this.socket.on('error', this.onError.bind(this));
|
||||
this.socket.on('headers', onHeaders);
|
||||
this.writable = true;
|
||||
this.perMessageDeflate = null;
|
||||
|
||||
function onHeaders (headers) {
|
||||
self.emit('headers', headers);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Inherits from Transport.
|
||||
*/
|
||||
|
||||
util.inherits(WebSocket, Transport);
|
||||
|
||||
/**
|
||||
* Transport name
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
WebSocket.prototype.name = 'websocket';
|
||||
|
||||
/**
|
||||
* Advertise upgrade support.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
WebSocket.prototype.handlesUpgrades = true;
|
||||
|
||||
/**
|
||||
* Advertise framing support.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
WebSocket.prototype.supportsFraming = true;
|
||||
|
||||
/**
|
||||
* Processes the incoming data.
|
||||
*
|
||||
* @param {String} encoded packet
|
||||
* @api private
|
||||
*/
|
||||
|
||||
WebSocket.prototype.onData = function (data) {
|
||||
debug('received "%s"', data);
|
||||
Transport.prototype.onData.call(this, data);
|
||||
};
|
||||
|
||||
/**
|
||||
* Writes a packet payload.
|
||||
*
|
||||
* @param {Array} packets
|
||||
* @api private
|
||||
*/
|
||||
|
||||
WebSocket.prototype.send = function (packets) {
|
||||
var self = this;
|
||||
|
||||
for (var i = 0; i < packets.length; i++) {
|
||||
var packet = packets[i];
|
||||
parser.encodePacket(packet, self.supportsBinary, send);
|
||||
}
|
||||
|
||||
function send (data) {
|
||||
debug('writing "%s"', data);
|
||||
|
||||
// always creates a new object since ws modifies it
|
||||
var opts = {};
|
||||
if (packet.options) {
|
||||
opts.compress = packet.options.compress;
|
||||
}
|
||||
|
||||
if (self.perMessageDeflate) {
|
||||
var len = 'string' === typeof data ? Buffer.byteLength(data) : data.length;
|
||||
if (len < self.perMessageDeflate.threshold) {
|
||||
opts.compress = false;
|
||||
}
|
||||
}
|
||||
|
||||
self.writable = false;
|
||||
self.socket.send(data, opts, onEnd);
|
||||
}
|
||||
|
||||
function onEnd (err) {
|
||||
if (err) return self.onError('write error', err.stack);
|
||||
self.writable = true;
|
||||
self.emit('drain');
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Closes the transport.
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
WebSocket.prototype.doClose = function (fn) {
|
||||
debug('closing');
|
||||
this.socket.close();
|
||||
fn && fn();
|
||||
};
|
63
node_modules/socketio/node_modules/engine.io/package.json
generated
vendored
Normal file
63
node_modules/socketio/node_modules/engine.io/package.json
generated
vendored
Normal file
@ -0,0 +1,63 @@
|
||||
{
|
||||
"name": "engine.io",
|
||||
"version": "1.8.5",
|
||||
"description": "The realtime engine behind Socket.IO. Provides the foundation of a bidirectional connection between client and server",
|
||||
"main": "./lib/engine.io",
|
||||
"author": "Guillermo Rauch <guillermo@learnboost.com>",
|
||||
"homepage": "https://github.com/socketio/engine.io",
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Eugen Dueck",
|
||||
"web": "https://github.com/EugenDueck"
|
||||
},
|
||||
{
|
||||
"name": "Afshin Mehrabani",
|
||||
"web": "https://github.com/afshinm"
|
||||
},
|
||||
{
|
||||
"name": "Christoph Dorn",
|
||||
"web": "https://github.com/cadorn"
|
||||
},
|
||||
{
|
||||
"name": "Mark Mokryn",
|
||||
"email": "mokesmokes@gmail.com"
|
||||
}
|
||||
],
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"accepts": "1.3.3",
|
||||
"base64id": "1.0.0",
|
||||
"debug": "2.3.3",
|
||||
"engine.io-parser": "1.3.2",
|
||||
"ws": "~1.1.5",
|
||||
"cookie": "0.3.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-eslint": "5.0.0",
|
||||
"babel-preset-es2015": "6.3.13",
|
||||
"engine.io-client": "1.8.5",
|
||||
"eslint-config-standard": "4.4.0",
|
||||
"eslint-plugin-standard": "1.3.2",
|
||||
"expect.js": "0.2.0",
|
||||
"gulp": "3.9.0",
|
||||
"gulp-babel": "6.1.1",
|
||||
"gulp-eslint": "1.1.1",
|
||||
"gulp-mocha": "2.2.0",
|
||||
"gulp-nsp": "^2.4.1",
|
||||
"mocha": "2.3.4",
|
||||
"s": "0.1.1",
|
||||
"superagent": "0.15.4",
|
||||
"uws": "0.14.1"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "gulp test; EIO_WS_ENGINE=uws gulp test;"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git@github.com:socketio/engine.io.git"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"lib/"
|
||||
]
|
||||
}
|
21
node_modules/socketio/node_modules/ms/LICENSE.md
generated
vendored
Normal file
21
node_modules/socketio/node_modules/ms/LICENSE.md
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2016 Zeit, Inc.
|
||||
|
||||
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.
|
52
node_modules/socketio/node_modules/ms/README.md
generated
vendored
Normal file
52
node_modules/socketio/node_modules/ms/README.md
generated
vendored
Normal file
@ -0,0 +1,52 @@
|
||||
# ms
|
||||
|
||||
[](https://travis-ci.org/zeit/ms)
|
||||
[](https://github.com/sindresorhus/xo)
|
||||
[](https://zeit.chat/)
|
||||
|
||||
Use this package to easily convert various time formats to milliseconds.
|
||||
|
||||
## Examples
|
||||
|
||||
```js
|
||||
ms('2 days') // 172800000
|
||||
ms('1d') // 86400000
|
||||
ms('10h') // 36000000
|
||||
ms('2.5 hrs') // 9000000
|
||||
ms('2h') // 7200000
|
||||
ms('1m') // 60000
|
||||
ms('5s') // 5000
|
||||
ms('1y') // 31557600000
|
||||
ms('100') // 100
|
||||
```
|
||||
|
||||
### Convert from milliseconds
|
||||
|
||||
```js
|
||||
ms(60000) // "1m"
|
||||
ms(2 * 60000) // "2m"
|
||||
ms(ms('10 hours')) // "10h"
|
||||
```
|
||||
|
||||
### Time format written-out
|
||||
|
||||
```js
|
||||
ms(60000, { long: true }) // "1 minute"
|
||||
ms(2 * 60000, { long: true }) // "2 minutes"
|
||||
ms(ms('10 hours'), { long: true }) // "10 hours"
|
||||
```
|
||||
|
||||
## Features
|
||||
|
||||
- Works both in [node](https://nodejs.org) and in the browser.
|
||||
- If a number is supplied to `ms`, a string with a unit is returned.
|
||||
- If a string that contains the number is supplied, it returns it as a number (e.g.: it returns `100` for `'100'`).
|
||||
- If you pass a string with a number and a valid unit, the number of equivalent ms is returned.
|
||||
|
||||
## Caught a bug?
|
||||
|
||||
1. [Fork](https://help.github.com/articles/fork-a-repo/) this repository to your own GitHub account and then [clone](https://help.github.com/articles/cloning-a-repository/) it to your local device
|
||||
2. Link the package to the global module directory: `npm link`
|
||||
3. Within the module you want to test your local development instance of ms, just link it to the dependencies: `npm link ms`. Instead of the default one from npm, node will now use your clone of ms!
|
||||
|
||||
As always, you can run the tests using: `npm test`
|
149
node_modules/socketio/node_modules/ms/index.js
generated
vendored
Normal file
149
node_modules/socketio/node_modules/ms/index.js
generated
vendored
Normal file
@ -0,0 +1,149 @@
|
||||
/**
|
||||
* Helpers.
|
||||
*/
|
||||
|
||||
var s = 1000
|
||||
var m = s * 60
|
||||
var h = m * 60
|
||||
var d = h * 24
|
||||
var y = d * 365.25
|
||||
|
||||
/**
|
||||
* Parse or format the given `val`.
|
||||
*
|
||||
* Options:
|
||||
*
|
||||
* - `long` verbose formatting [false]
|
||||
*
|
||||
* @param {String|Number} val
|
||||
* @param {Object} options
|
||||
* @throws {Error} throw an error if val is not a non-empty string or a number
|
||||
* @return {String|Number}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
module.exports = function (val, options) {
|
||||
options = options || {}
|
||||
var type = typeof val
|
||||
if (type === 'string' && val.length > 0) {
|
||||
return parse(val)
|
||||
} else if (type === 'number' && isNaN(val) === false) {
|
||||
return options.long ?
|
||||
fmtLong(val) :
|
||||
fmtShort(val)
|
||||
}
|
||||
throw new Error('val is not a non-empty string or a valid number. val=' + JSON.stringify(val))
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the given `str` and return milliseconds.
|
||||
*
|
||||
* @param {String} str
|
||||
* @return {Number}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function parse(str) {
|
||||
str = String(str)
|
||||
if (str.length > 10000) {
|
||||
return
|
||||
}
|
||||
var match = /^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(str)
|
||||
if (!match) {
|
||||
return
|
||||
}
|
||||
var n = parseFloat(match[1])
|
||||
var type = (match[2] || 'ms').toLowerCase()
|
||||
switch (type) {
|
||||
case 'years':
|
||||
case 'year':
|
||||
case 'yrs':
|
||||
case 'yr':
|
||||
case 'y':
|
||||
return n * y
|
||||
case 'days':
|
||||
case 'day':
|
||||
case 'd':
|
||||
return n * d
|
||||
case 'hours':
|
||||
case 'hour':
|
||||
case 'hrs':
|
||||
case 'hr':
|
||||
case 'h':
|
||||
return n * h
|
||||
case 'minutes':
|
||||
case 'minute':
|
||||
case 'mins':
|
||||
case 'min':
|
||||
case 'm':
|
||||
return n * m
|
||||
case 'seconds':
|
||||
case 'second':
|
||||
case 'secs':
|
||||
case 'sec':
|
||||
case 's':
|
||||
return n * s
|
||||
case 'milliseconds':
|
||||
case 'millisecond':
|
||||
case 'msecs':
|
||||
case 'msec':
|
||||
case 'ms':
|
||||
return n
|
||||
default:
|
||||
return undefined
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Short format for `ms`.
|
||||
*
|
||||
* @param {Number} ms
|
||||
* @return {String}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function fmtShort(ms) {
|
||||
if (ms >= d) {
|
||||
return Math.round(ms / d) + 'd'
|
||||
}
|
||||
if (ms >= h) {
|
||||
return Math.round(ms / h) + 'h'
|
||||
}
|
||||
if (ms >= m) {
|
||||
return Math.round(ms / m) + 'm'
|
||||
}
|
||||
if (ms >= s) {
|
||||
return Math.round(ms / s) + 's'
|
||||
}
|
||||
return ms + 'ms'
|
||||
}
|
||||
|
||||
/**
|
||||
* Long format for `ms`.
|
||||
*
|
||||
* @param {Number} ms
|
||||
* @return {String}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function fmtLong(ms) {
|
||||
return plural(ms, d, 'day') ||
|
||||
plural(ms, h, 'hour') ||
|
||||
plural(ms, m, 'minute') ||
|
||||
plural(ms, s, 'second') ||
|
||||
ms + ' ms'
|
||||
}
|
||||
|
||||
/**
|
||||
* Pluralization helper.
|
||||
*/
|
||||
|
||||
function plural(ms, n, name) {
|
||||
if (ms < n) {
|
||||
return
|
||||
}
|
||||
if (ms < n * 1.5) {
|
||||
return Math.floor(ms / n) + ' ' + name
|
||||
}
|
||||
return Math.ceil(ms / n) + ' ' + name + 's'
|
||||
}
|
36
node_modules/socketio/node_modules/ms/package.json
generated
vendored
Normal file
36
node_modules/socketio/node_modules/ms/package.json
generated
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
{
|
||||
"name": "ms",
|
||||
"version": "0.7.2",
|
||||
"description": "Tiny milisecond conversion utility",
|
||||
"repository": "zeit/ms",
|
||||
"main": "./index",
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"scripts": {
|
||||
"test": "xo && mocha test/index.js",
|
||||
"test-browser": "serve ./test"
|
||||
},
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"expect.js": "^0.3.1",
|
||||
"mocha": "^3.0.2",
|
||||
"serve": "^1.4.0",
|
||||
"xo": "^0.17.0"
|
||||
},
|
||||
"component": {
|
||||
"scripts": {
|
||||
"ms/index.js": "index.js"
|
||||
}
|
||||
},
|
||||
"xo": {
|
||||
"space": true,
|
||||
"semicolon": false,
|
||||
"envs": [
|
||||
"mocha"
|
||||
],
|
||||
"rules": {
|
||||
"complexity": 0
|
||||
}
|
||||
}
|
||||
}
|
98
node_modules/socketio/node_modules/negotiator/HISTORY.md
generated
vendored
Normal file
98
node_modules/socketio/node_modules/negotiator/HISTORY.md
generated
vendored
Normal file
@ -0,0 +1,98 @@
|
||||
0.6.1 / 2016-05-02
|
||||
==================
|
||||
|
||||
* perf: improve `Accept` parsing speed
|
||||
* perf: improve `Accept-Charset` parsing speed
|
||||
* perf: improve `Accept-Encoding` parsing speed
|
||||
* perf: improve `Accept-Language` parsing speed
|
||||
|
||||
0.6.0 / 2015-09-29
|
||||
==================
|
||||
|
||||
* Fix including type extensions in parameters in `Accept` parsing
|
||||
* Fix parsing `Accept` parameters with quoted equals
|
||||
* Fix parsing `Accept` parameters with quoted semicolons
|
||||
* Lazy-load modules from main entry point
|
||||
* perf: delay type concatenation until needed
|
||||
* perf: enable strict mode
|
||||
* perf: hoist regular expressions
|
||||
* perf: remove closures getting spec properties
|
||||
* perf: remove a closure from media type parsing
|
||||
* perf: remove property delete from media type parsing
|
||||
|
||||
0.5.3 / 2015-05-10
|
||||
==================
|
||||
|
||||
* Fix media type parameter matching to be case-insensitive
|
||||
|
||||
0.5.2 / 2015-05-06
|
||||
==================
|
||||
|
||||
* Fix comparing media types with quoted values
|
||||
* Fix splitting media types with quoted commas
|
||||
|
||||
0.5.1 / 2015-02-14
|
||||
==================
|
||||
|
||||
* Fix preference sorting to be stable for long acceptable lists
|
||||
|
||||
0.5.0 / 2014-12-18
|
||||
==================
|
||||
|
||||
* Fix list return order when large accepted list
|
||||
* Fix missing identity encoding when q=0 exists
|
||||
* Remove dynamic building of Negotiator class
|
||||
|
||||
0.4.9 / 2014-10-14
|
||||
==================
|
||||
|
||||
* Fix error when media type has invalid parameter
|
||||
|
||||
0.4.8 / 2014-09-28
|
||||
==================
|
||||
|
||||
* Fix all negotiations to be case-insensitive
|
||||
* Stable sort preferences of same quality according to client order
|
||||
* Support Node.js 0.6
|
||||
|
||||
0.4.7 / 2014-06-24
|
||||
==================
|
||||
|
||||
* Handle invalid provided languages
|
||||
* Handle invalid provided media types
|
||||
|
||||
0.4.6 / 2014-06-11
|
||||
==================
|
||||
|
||||
* Order by specificity when quality is the same
|
||||
|
||||
0.4.5 / 2014-05-29
|
||||
==================
|
||||
|
||||
* Fix regression in empty header handling
|
||||
|
||||
0.4.4 / 2014-05-29
|
||||
==================
|
||||
|
||||
* Fix behaviors when headers are not present
|
||||
|
||||
0.4.3 / 2014-04-16
|
||||
==================
|
||||
|
||||
* Handle slashes on media params correctly
|
||||
|
||||
0.4.2 / 2014-02-28
|
||||
==================
|
||||
|
||||
* Fix media type sorting
|
||||
* Handle media types params strictly
|
||||
|
||||
0.4.1 / 2014-01-16
|
||||
==================
|
||||
|
||||
* Use most specific matches
|
||||
|
||||
0.4.0 / 2014-01-09
|
||||
==================
|
||||
|
||||
* Remove preferred prefix from methods
|
24
node_modules/socketio/node_modules/negotiator/LICENSE
generated
vendored
Normal file
24
node_modules/socketio/node_modules/negotiator/LICENSE
generated
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2012-2014 Federico Romero
|
||||
Copyright (c) 2012-2014 Isaac Z. Schlueter
|
||||
Copyright (c) 2014-2015 Douglas Christopher Wilson
|
||||
|
||||
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.
|
203
node_modules/socketio/node_modules/negotiator/README.md
generated
vendored
Normal file
203
node_modules/socketio/node_modules/negotiator/README.md
generated
vendored
Normal file
@ -0,0 +1,203 @@
|
||||
# negotiator
|
||||
|
||||
[![NPM Version][npm-image]][npm-url]
|
||||
[![NPM Downloads][downloads-image]][downloads-url]
|
||||
[![Node.js Version][node-version-image]][node-version-url]
|
||||
[![Build Status][travis-image]][travis-url]
|
||||
[![Test Coverage][coveralls-image]][coveralls-url]
|
||||
|
||||
An HTTP content negotiator for Node.js
|
||||
|
||||
## Installation
|
||||
|
||||
```sh
|
||||
$ npm install negotiator
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
```js
|
||||
var Negotiator = require('negotiator')
|
||||
```
|
||||
|
||||
### Accept Negotiation
|
||||
|
||||
```js
|
||||
availableMediaTypes = ['text/html', 'text/plain', 'application/json']
|
||||
|
||||
// The negotiator constructor receives a request object
|
||||
negotiator = new Negotiator(request)
|
||||
|
||||
// Let's say Accept header is 'text/html, application/*;q=0.2, image/jpeg;q=0.8'
|
||||
|
||||
negotiator.mediaTypes()
|
||||
// -> ['text/html', 'image/jpeg', 'application/*']
|
||||
|
||||
negotiator.mediaTypes(availableMediaTypes)
|
||||
// -> ['text/html', 'application/json']
|
||||
|
||||
negotiator.mediaType(availableMediaTypes)
|
||||
// -> 'text/html'
|
||||
```
|
||||
|
||||
You can check a working example at `examples/accept.js`.
|
||||
|
||||
#### Methods
|
||||
|
||||
##### mediaType()
|
||||
|
||||
Returns the most preferred media type from the client.
|
||||
|
||||
##### mediaType(availableMediaType)
|
||||
|
||||
Returns the most preferred media type from a list of available media types.
|
||||
|
||||
##### mediaTypes()
|
||||
|
||||
Returns an array of preferred media types ordered by the client preference.
|
||||
|
||||
##### mediaTypes(availableMediaTypes)
|
||||
|
||||
Returns an array of preferred media types ordered by priority from a list of
|
||||
available media types.
|
||||
|
||||
### Accept-Language Negotiation
|
||||
|
||||
```js
|
||||
negotiator = new Negotiator(request)
|
||||
|
||||
availableLanguages = ['en', 'es', 'fr']
|
||||
|
||||
// Let's say Accept-Language header is 'en;q=0.8, es, pt'
|
||||
|
||||
negotiator.languages()
|
||||
// -> ['es', 'pt', 'en']
|
||||
|
||||
negotiator.languages(availableLanguages)
|
||||
// -> ['es', 'en']
|
||||
|
||||
language = negotiator.language(availableLanguages)
|
||||
// -> 'es'
|
||||
```
|
||||
|
||||
You can check a working example at `examples/language.js`.
|
||||
|
||||
#### Methods
|
||||
|
||||
##### language()
|
||||
|
||||
Returns the most preferred language from the client.
|
||||
|
||||
##### language(availableLanguages)
|
||||
|
||||
Returns the most preferred language from a list of available languages.
|
||||
|
||||
##### languages()
|
||||
|
||||
Returns an array of preferred languages ordered by the client preference.
|
||||
|
||||
##### languages(availableLanguages)
|
||||
|
||||
Returns an array of preferred languages ordered by priority from a list of
|
||||
available languages.
|
||||
|
||||
### Accept-Charset Negotiation
|
||||
|
||||
```js
|
||||
availableCharsets = ['utf-8', 'iso-8859-1', 'iso-8859-5']
|
||||
|
||||
negotiator = new Negotiator(request)
|
||||
|
||||
// Let's say Accept-Charset header is 'utf-8, iso-8859-1;q=0.8, utf-7;q=0.2'
|
||||
|
||||
negotiator.charsets()
|
||||
// -> ['utf-8', 'iso-8859-1', 'utf-7']
|
||||
|
||||
negotiator.charsets(availableCharsets)
|
||||
// -> ['utf-8', 'iso-8859-1']
|
||||
|
||||
negotiator.charset(availableCharsets)
|
||||
// -> 'utf-8'
|
||||
```
|
||||
|
||||
You can check a working example at `examples/charset.js`.
|
||||
|
||||
#### Methods
|
||||
|
||||
##### charset()
|
||||
|
||||
Returns the most preferred charset from the client.
|
||||
|
||||
##### charset(availableCharsets)
|
||||
|
||||
Returns the most preferred charset from a list of available charsets.
|
||||
|
||||
##### charsets()
|
||||
|
||||
Returns an array of preferred charsets ordered by the client preference.
|
||||
|
||||
##### charsets(availableCharsets)
|
||||
|
||||
Returns an array of preferred charsets ordered by priority from a list of
|
||||
available charsets.
|
||||
|
||||
### Accept-Encoding Negotiation
|
||||
|
||||
```js
|
||||
availableEncodings = ['identity', 'gzip']
|
||||
|
||||
negotiator = new Negotiator(request)
|
||||
|
||||
// Let's say Accept-Encoding header is 'gzip, compress;q=0.2, identity;q=0.5'
|
||||
|
||||
negotiator.encodings()
|
||||
// -> ['gzip', 'identity', 'compress']
|
||||
|
||||
negotiator.encodings(availableEncodings)
|
||||
// -> ['gzip', 'identity']
|
||||
|
||||
negotiator.encoding(availableEncodings)
|
||||
// -> 'gzip'
|
||||
```
|
||||
|
||||
You can check a working example at `examples/encoding.js`.
|
||||
|
||||
#### Methods
|
||||
|
||||
##### encoding()
|
||||
|
||||
Returns the most preferred encoding from the client.
|
||||
|
||||
##### encoding(availableEncodings)
|
||||
|
||||
Returns the most preferred encoding from a list of available encodings.
|
||||
|
||||
##### encodings()
|
||||
|
||||
Returns an array of preferred encodings ordered by the client preference.
|
||||
|
||||
##### encodings(availableEncodings)
|
||||
|
||||
Returns an array of preferred encodings ordered by priority from a list of
|
||||
available encodings.
|
||||
|
||||
## See Also
|
||||
|
||||
The [accepts](https://npmjs.org/package/accepts#readme) module builds on
|
||||
this module and provides an alternative interface, mime type validation,
|
||||
and more.
|
||||
|
||||
## License
|
||||
|
||||
[MIT](LICENSE)
|
||||
|
||||
[npm-image]: https://img.shields.io/npm/v/negotiator.svg
|
||||
[npm-url]: https://npmjs.org/package/negotiator
|
||||
[node-version-image]: https://img.shields.io/node/v/negotiator.svg
|
||||
[node-version-url]: https://nodejs.org/en/download/
|
||||
[travis-image]: https://img.shields.io/travis/jshttp/negotiator/master.svg
|
||||
[travis-url]: https://travis-ci.org/jshttp/negotiator
|
||||
[coveralls-image]: https://img.shields.io/coveralls/jshttp/negotiator/master.svg
|
||||
[coveralls-url]: https://coveralls.io/r/jshttp/negotiator?branch=master
|
||||
[downloads-image]: https://img.shields.io/npm/dm/negotiator.svg
|
||||
[downloads-url]: https://npmjs.org/package/negotiator
|
124
node_modules/socketio/node_modules/negotiator/index.js
generated
vendored
Normal file
124
node_modules/socketio/node_modules/negotiator/index.js
generated
vendored
Normal file
@ -0,0 +1,124 @@
|
||||
/*!
|
||||
* negotiator
|
||||
* Copyright(c) 2012 Federico Romero
|
||||
* Copyright(c) 2012-2014 Isaac Z. Schlueter
|
||||
* Copyright(c) 2015 Douglas Christopher Wilson
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Cached loaded submodules.
|
||||
* @private
|
||||
*/
|
||||
|
||||
var modules = Object.create(null);
|
||||
|
||||
/**
|
||||
* Module exports.
|
||||
* @public
|
||||
*/
|
||||
|
||||
module.exports = Negotiator;
|
||||
module.exports.Negotiator = Negotiator;
|
||||
|
||||
/**
|
||||
* Create a Negotiator instance from a request.
|
||||
* @param {object} request
|
||||
* @public
|
||||
*/
|
||||
|
||||
function Negotiator(request) {
|
||||
if (!(this instanceof Negotiator)) {
|
||||
return new Negotiator(request);
|
||||
}
|
||||
|
||||
this.request = request;
|
||||
}
|
||||
|
||||
Negotiator.prototype.charset = function charset(available) {
|
||||
var set = this.charsets(available);
|
||||
return set && set[0];
|
||||
};
|
||||
|
||||
Negotiator.prototype.charsets = function charsets(available) {
|
||||
var preferredCharsets = loadModule('charset').preferredCharsets;
|
||||
return preferredCharsets(this.request.headers['accept-charset'], available);
|
||||
};
|
||||
|
||||
Negotiator.prototype.encoding = function encoding(available) {
|
||||
var set = this.encodings(available);
|
||||
return set && set[0];
|
||||
};
|
||||
|
||||
Negotiator.prototype.encodings = function encodings(available) {
|
||||
var preferredEncodings = loadModule('encoding').preferredEncodings;
|
||||
return preferredEncodings(this.request.headers['accept-encoding'], available);
|
||||
};
|
||||
|
||||
Negotiator.prototype.language = function language(available) {
|
||||
var set = this.languages(available);
|
||||
return set && set[0];
|
||||
};
|
||||
|
||||
Negotiator.prototype.languages = function languages(available) {
|
||||
var preferredLanguages = loadModule('language').preferredLanguages;
|
||||
return preferredLanguages(this.request.headers['accept-language'], available);
|
||||
};
|
||||
|
||||
Negotiator.prototype.mediaType = function mediaType(available) {
|
||||
var set = this.mediaTypes(available);
|
||||
return set && set[0];
|
||||
};
|
||||
|
||||
Negotiator.prototype.mediaTypes = function mediaTypes(available) {
|
||||
var preferredMediaTypes = loadModule('mediaType').preferredMediaTypes;
|
||||
return preferredMediaTypes(this.request.headers.accept, available);
|
||||
};
|
||||
|
||||
// Backwards compatibility
|
||||
Negotiator.prototype.preferredCharset = Negotiator.prototype.charset;
|
||||
Negotiator.prototype.preferredCharsets = Negotiator.prototype.charsets;
|
||||
Negotiator.prototype.preferredEncoding = Negotiator.prototype.encoding;
|
||||
Negotiator.prototype.preferredEncodings = Negotiator.prototype.encodings;
|
||||
Negotiator.prototype.preferredLanguage = Negotiator.prototype.language;
|
||||
Negotiator.prototype.preferredLanguages = Negotiator.prototype.languages;
|
||||
Negotiator.prototype.preferredMediaType = Negotiator.prototype.mediaType;
|
||||
Negotiator.prototype.preferredMediaTypes = Negotiator.prototype.mediaTypes;
|
||||
|
||||
/**
|
||||
* Load the given module.
|
||||
* @private
|
||||
*/
|
||||
|
||||
function loadModule(moduleName) {
|
||||
var module = modules[moduleName];
|
||||
|
||||
if (module !== undefined) {
|
||||
return module;
|
||||
}
|
||||
|
||||
// This uses a switch for static require analysis
|
||||
switch (moduleName) {
|
||||
case 'charset':
|
||||
module = require('./lib/charset');
|
||||
break;
|
||||
case 'encoding':
|
||||
module = require('./lib/encoding');
|
||||
break;
|
||||
case 'language':
|
||||
module = require('./lib/language');
|
||||
break;
|
||||
case 'mediaType':
|
||||
module = require('./lib/mediaType');
|
||||
break;
|
||||
default:
|
||||
throw new Error('Cannot find module \'' + moduleName + '\'');
|
||||
}
|
||||
|
||||
// Store to prevent invoking require()
|
||||
modules[moduleName] = module;
|
||||
|
||||
return module;
|
||||
}
|
169
node_modules/socketio/node_modules/negotiator/lib/charset.js
generated
vendored
Normal file
169
node_modules/socketio/node_modules/negotiator/lib/charset.js
generated
vendored
Normal file
@ -0,0 +1,169 @@
|
||||
/**
|
||||
* negotiator
|
||||
* Copyright(c) 2012 Isaac Z. Schlueter
|
||||
* Copyright(c) 2014 Federico Romero
|
||||
* Copyright(c) 2014-2015 Douglas Christopher Wilson
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Module exports.
|
||||
* @public
|
||||
*/
|
||||
|
||||
module.exports = preferredCharsets;
|
||||
module.exports.preferredCharsets = preferredCharsets;
|
||||
|
||||
/**
|
||||
* Module variables.
|
||||
* @private
|
||||
*/
|
||||
|
||||
var simpleCharsetRegExp = /^\s*([^\s;]+)\s*(?:;(.*))?$/;
|
||||
|
||||
/**
|
||||
* Parse the Accept-Charset header.
|
||||
* @private
|
||||
*/
|
||||
|
||||
function parseAcceptCharset(accept) {
|
||||
var accepts = accept.split(',');
|
||||
|
||||
for (var i = 0, j = 0; i < accepts.length; i++) {
|
||||
var charset = parseCharset(accepts[i].trim(), i);
|
||||
|
||||
if (charset) {
|
||||
accepts[j++] = charset;
|
||||
}
|
||||
}
|
||||
|
||||
// trim accepts
|
||||
accepts.length = j;
|
||||
|
||||
return accepts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a charset from the Accept-Charset header.
|
||||
* @private
|
||||
*/
|
||||
|
||||
function parseCharset(str, i) {
|
||||
var match = simpleCharsetRegExp.exec(str);
|
||||
if (!match) return null;
|
||||
|
||||
var charset = match[1];
|
||||
var q = 1;
|
||||
if (match[2]) {
|
||||
var params = match[2].split(';')
|
||||
for (var i = 0; i < params.length; i ++) {
|
||||
var p = params[i].trim().split('=');
|
||||
if (p[0] === 'q') {
|
||||
q = parseFloat(p[1]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
charset: charset,
|
||||
q: q,
|
||||
i: i
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the priority of a charset.
|
||||
* @private
|
||||
*/
|
||||
|
||||
function getCharsetPriority(charset, accepted, index) {
|
||||
var priority = {o: -1, q: 0, s: 0};
|
||||
|
||||
for (var i = 0; i < accepted.length; i++) {
|
||||
var spec = specify(charset, accepted[i], index);
|
||||
|
||||
if (spec && (priority.s - spec.s || priority.q - spec.q || priority.o - spec.o) < 0) {
|
||||
priority = spec;
|
||||
}
|
||||
}
|
||||
|
||||
return priority;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the specificity of the charset.
|
||||
* @private
|
||||
*/
|
||||
|
||||
function specify(charset, spec, index) {
|
||||
var s = 0;
|
||||
if(spec.charset.toLowerCase() === charset.toLowerCase()){
|
||||
s |= 1;
|
||||
} else if (spec.charset !== '*' ) {
|
||||
return null
|
||||
}
|
||||
|
||||
return {
|
||||
i: index,
|
||||
o: spec.i,
|
||||
q: spec.q,
|
||||
s: s
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the preferred charsets from an Accept-Charset header.
|
||||
* @public
|
||||
*/
|
||||
|
||||
function preferredCharsets(accept, provided) {
|
||||
// RFC 2616 sec 14.2: no header = *
|
||||
var accepts = parseAcceptCharset(accept === undefined ? '*' : accept || '');
|
||||
|
||||
if (!provided) {
|
||||
// sorted list of all charsets
|
||||
return accepts
|
||||
.filter(isQuality)
|
||||
.sort(compareSpecs)
|
||||
.map(getFullCharset);
|
||||
}
|
||||
|
||||
var priorities = provided.map(function getPriority(type, index) {
|
||||
return getCharsetPriority(type, accepts, index);
|
||||
});
|
||||
|
||||
// sorted list of accepted charsets
|
||||
return priorities.filter(isQuality).sort(compareSpecs).map(function getCharset(priority) {
|
||||
return provided[priorities.indexOf(priority)];
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare two specs.
|
||||
* @private
|
||||
*/
|
||||
|
||||
function compareSpecs(a, b) {
|
||||
return (b.q - a.q) || (b.s - a.s) || (a.o - b.o) || (a.i - b.i) || 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get full charset string.
|
||||
* @private
|
||||
*/
|
||||
|
||||
function getFullCharset(spec) {
|
||||
return spec.charset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a spec has any quality.
|
||||
* @private
|
||||
*/
|
||||
|
||||
function isQuality(spec) {
|
||||
return spec.q > 0;
|
||||
}
|
184
node_modules/socketio/node_modules/negotiator/lib/encoding.js
generated
vendored
Normal file
184
node_modules/socketio/node_modules/negotiator/lib/encoding.js
generated
vendored
Normal file
@ -0,0 +1,184 @@
|
||||
/**
|
||||
* negotiator
|
||||
* Copyright(c) 2012 Isaac Z. Schlueter
|
||||
* Copyright(c) 2014 Federico Romero
|
||||
* Copyright(c) 2014-2015 Douglas Christopher Wilson
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Module exports.
|
||||
* @public
|
||||
*/
|
||||
|
||||
module.exports = preferredEncodings;
|
||||
module.exports.preferredEncodings = preferredEncodings;
|
||||
|
||||
/**
|
||||
* Module variables.
|
||||
* @private
|
||||
*/
|
||||
|
||||
var simpleEncodingRegExp = /^\s*([^\s;]+)\s*(?:;(.*))?$/;
|
||||
|
||||
/**
|
||||
* Parse the Accept-Encoding header.
|
||||
* @private
|
||||
*/
|
||||
|
||||
function parseAcceptEncoding(accept) {
|
||||
var accepts = accept.split(',');
|
||||
var hasIdentity = false;
|
||||
var minQuality = 1;
|
||||
|
||||
for (var i = 0, j = 0; i < accepts.length; i++) {
|
||||
var encoding = parseEncoding(accepts[i].trim(), i);
|
||||
|
||||
if (encoding) {
|
||||
accepts[j++] = encoding;
|
||||
hasIdentity = hasIdentity || specify('identity', encoding);
|
||||
minQuality = Math.min(minQuality, encoding.q || 1);
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasIdentity) {
|
||||
/*
|
||||
* If identity doesn't explicitly appear in the accept-encoding header,
|
||||
* it's added to the list of acceptable encoding with the lowest q
|
||||
*/
|
||||
accepts[j++] = {
|
||||
encoding: 'identity',
|
||||
q: minQuality,
|
||||
i: i
|
||||
};
|
||||
}
|
||||
|
||||
// trim accepts
|
||||
accepts.length = j;
|
||||
|
||||
return accepts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse an encoding from the Accept-Encoding header.
|
||||
* @private
|
||||
*/
|
||||
|
||||
function parseEncoding(str, i) {
|
||||
var match = simpleEncodingRegExp.exec(str);
|
||||
if (!match) return null;
|
||||
|
||||
var encoding = match[1];
|
||||
var q = 1;
|
||||
if (match[2]) {
|
||||
var params = match[2].split(';');
|
||||
for (var i = 0; i < params.length; i ++) {
|
||||
var p = params[i].trim().split('=');
|
||||
if (p[0] === 'q') {
|
||||
q = parseFloat(p[1]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
encoding: encoding,
|
||||
q: q,
|
||||
i: i
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the priority of an encoding.
|
||||
* @private
|
||||
*/
|
||||
|
||||
function getEncodingPriority(encoding, accepted, index) {
|
||||
var priority = {o: -1, q: 0, s: 0};
|
||||
|
||||
for (var i = 0; i < accepted.length; i++) {
|
||||
var spec = specify(encoding, accepted[i], index);
|
||||
|
||||
if (spec && (priority.s - spec.s || priority.q - spec.q || priority.o - spec.o) < 0) {
|
||||
priority = spec;
|
||||
}
|
||||
}
|
||||
|
||||
return priority;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the specificity of the encoding.
|
||||
* @private
|
||||
*/
|
||||
|
||||
function specify(encoding, spec, index) {
|
||||
var s = 0;
|
||||
if(spec.encoding.toLowerCase() === encoding.toLowerCase()){
|
||||
s |= 1;
|
||||
} else if (spec.encoding !== '*' ) {
|
||||
return null
|
||||
}
|
||||
|
||||
return {
|
||||
i: index,
|
||||
o: spec.i,
|
||||
q: spec.q,
|
||||
s: s
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the preferred encodings from an Accept-Encoding header.
|
||||
* @public
|
||||
*/
|
||||
|
||||
function preferredEncodings(accept, provided) {
|
||||
var accepts = parseAcceptEncoding(accept || '');
|
||||
|
||||
if (!provided) {
|
||||
// sorted list of all encodings
|
||||
return accepts
|
||||
.filter(isQuality)
|
||||
.sort(compareSpecs)
|
||||
.map(getFullEncoding);
|
||||
}
|
||||
|
||||
var priorities = provided.map(function getPriority(type, index) {
|
||||
return getEncodingPriority(type, accepts, index);
|
||||
});
|
||||
|
||||
// sorted list of accepted encodings
|
||||
return priorities.filter(isQuality).sort(compareSpecs).map(function getEncoding(priority) {
|
||||
return provided[priorities.indexOf(priority)];
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare two specs.
|
||||
* @private
|
||||
*/
|
||||
|
||||
function compareSpecs(a, b) {
|
||||
return (b.q - a.q) || (b.s - a.s) || (a.o - b.o) || (a.i - b.i) || 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get full encoding string.
|
||||
* @private
|
||||
*/
|
||||
|
||||
function getFullEncoding(spec) {
|
||||
return spec.encoding;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a spec has any quality.
|
||||
* @private
|
||||
*/
|
||||
|
||||
function isQuality(spec) {
|
||||
return spec.q > 0;
|
||||
}
|
179
node_modules/socketio/node_modules/negotiator/lib/language.js
generated
vendored
Normal file
179
node_modules/socketio/node_modules/negotiator/lib/language.js
generated
vendored
Normal file
@ -0,0 +1,179 @@
|
||||
/**
|
||||
* negotiator
|
||||
* Copyright(c) 2012 Isaac Z. Schlueter
|
||||
* Copyright(c) 2014 Federico Romero
|
||||
* Copyright(c) 2014-2015 Douglas Christopher Wilson
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Module exports.
|
||||
* @public
|
||||
*/
|
||||
|
||||
module.exports = preferredLanguages;
|
||||
module.exports.preferredLanguages = preferredLanguages;
|
||||
|
||||
/**
|
||||
* Module variables.
|
||||
* @private
|
||||
*/
|
||||
|
||||
var simpleLanguageRegExp = /^\s*([^\s\-;]+)(?:-([^\s;]+))?\s*(?:;(.*))?$/;
|
||||
|
||||
/**
|
||||
* Parse the Accept-Language header.
|
||||
* @private
|
||||
*/
|
||||
|
||||
function parseAcceptLanguage(accept) {
|
||||
var accepts = accept.split(',');
|
||||
|
||||
for (var i = 0, j = 0; i < accepts.length; i++) {
|
||||
var langauge = parseLanguage(accepts[i].trim(), i);
|
||||
|
||||
if (langauge) {
|
||||
accepts[j++] = langauge;
|
||||
}
|
||||
}
|
||||
|
||||
// trim accepts
|
||||
accepts.length = j;
|
||||
|
||||
return accepts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a language from the Accept-Language header.
|
||||
* @private
|
||||
*/
|
||||
|
||||
function parseLanguage(str, i) {
|
||||
var match = simpleLanguageRegExp.exec(str);
|
||||
if (!match) return null;
|
||||
|
||||
var prefix = match[1],
|
||||
suffix = match[2],
|
||||
full = prefix;
|
||||
|
||||
if (suffix) full += "-" + suffix;
|
||||
|
||||
var q = 1;
|
||||
if (match[3]) {
|
||||
var params = match[3].split(';')
|
||||
for (var i = 0; i < params.length; i ++) {
|
||||
var p = params[i].split('=');
|
||||
if (p[0] === 'q') q = parseFloat(p[1]);
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
prefix: prefix,
|
||||
suffix: suffix,
|
||||
q: q,
|
||||
i: i,
|
||||
full: full
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the priority of a language.
|
||||
* @private
|
||||
*/
|
||||
|
||||
function getLanguagePriority(language, accepted, index) {
|
||||
var priority = {o: -1, q: 0, s: 0};
|
||||
|
||||
for (var i = 0; i < accepted.length; i++) {
|
||||
var spec = specify(language, accepted[i], index);
|
||||
|
||||
if (spec && (priority.s - spec.s || priority.q - spec.q || priority.o - spec.o) < 0) {
|
||||
priority = spec;
|
||||
}
|
||||
}
|
||||
|
||||
return priority;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the specificity of the language.
|
||||
* @private
|
||||
*/
|
||||
|
||||
function specify(language, spec, index) {
|
||||
var p = parseLanguage(language)
|
||||
if (!p) return null;
|
||||
var s = 0;
|
||||
if(spec.full.toLowerCase() === p.full.toLowerCase()){
|
||||
s |= 4;
|
||||
} else if (spec.prefix.toLowerCase() === p.full.toLowerCase()) {
|
||||
s |= 2;
|
||||
} else if (spec.full.toLowerCase() === p.prefix.toLowerCase()) {
|
||||
s |= 1;
|
||||
} else if (spec.full !== '*' ) {
|
||||
return null
|
||||
}
|
||||
|
||||
return {
|
||||
i: index,
|
||||
o: spec.i,
|
||||
q: spec.q,
|
||||
s: s
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the preferred languages from an Accept-Language header.
|
||||
* @public
|
||||
*/
|
||||
|
||||
function preferredLanguages(accept, provided) {
|
||||
// RFC 2616 sec 14.4: no header = *
|
||||
var accepts = parseAcceptLanguage(accept === undefined ? '*' : accept || '');
|
||||
|
||||
if (!provided) {
|
||||
// sorted list of all languages
|
||||
return accepts
|
||||
.filter(isQuality)
|
||||
.sort(compareSpecs)
|
||||
.map(getFullLanguage);
|
||||
}
|
||||
|
||||
var priorities = provided.map(function getPriority(type, index) {
|
||||
return getLanguagePriority(type, accepts, index);
|
||||
});
|
||||
|
||||
// sorted list of accepted languages
|
||||
return priorities.filter(isQuality).sort(compareSpecs).map(function getLanguage(priority) {
|
||||
return provided[priorities.indexOf(priority)];
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare two specs.
|
||||
* @private
|
||||
*/
|
||||
|
||||
function compareSpecs(a, b) {
|
||||
return (b.q - a.q) || (b.s - a.s) || (a.o - b.o) || (a.i - b.i) || 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get full language string.
|
||||
* @private
|
||||
*/
|
||||
|
||||
function getFullLanguage(spec) {
|
||||
return spec.full;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a spec has any quality.
|
||||
* @private
|
||||
*/
|
||||
|
||||
function isQuality(spec) {
|
||||
return spec.q > 0;
|
||||
}
|
294
node_modules/socketio/node_modules/negotiator/lib/mediaType.js
generated
vendored
Normal file
294
node_modules/socketio/node_modules/negotiator/lib/mediaType.js
generated
vendored
Normal file
@ -0,0 +1,294 @@
|
||||
/**
|
||||
* negotiator
|
||||
* Copyright(c) 2012 Isaac Z. Schlueter
|
||||
* Copyright(c) 2014 Federico Romero
|
||||
* Copyright(c) 2014-2015 Douglas Christopher Wilson
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Module exports.
|
||||
* @public
|
||||
*/
|
||||
|
||||
module.exports = preferredMediaTypes;
|
||||
module.exports.preferredMediaTypes = preferredMediaTypes;
|
||||
|
||||
/**
|
||||
* Module variables.
|
||||
* @private
|
||||
*/
|
||||
|
||||
var simpleMediaTypeRegExp = /^\s*([^\s\/;]+)\/([^;\s]+)\s*(?:;(.*))?$/;
|
||||
|
||||
/**
|
||||
* Parse the Accept header.
|
||||
* @private
|
||||
*/
|
||||
|
||||
function parseAccept(accept) {
|
||||
var accepts = splitMediaTypes(accept);
|
||||
|
||||
for (var i = 0, j = 0; i < accepts.length; i++) {
|
||||
var mediaType = parseMediaType(accepts[i].trim(), i);
|
||||
|
||||
if (mediaType) {
|
||||
accepts[j++] = mediaType;
|
||||
}
|
||||
}
|
||||
|
||||
// trim accepts
|
||||
accepts.length = j;
|
||||
|
||||
return accepts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a media type from the Accept header.
|
||||
* @private
|
||||
*/
|
||||
|
||||
function parseMediaType(str, i) {
|
||||
var match = simpleMediaTypeRegExp.exec(str);
|
||||
if (!match) return null;
|
||||
|
||||
var params = Object.create(null);
|
||||
var q = 1;
|
||||
var subtype = match[2];
|
||||
var type = match[1];
|
||||
|
||||
if (match[3]) {
|
||||
var kvps = splitParameters(match[3]).map(splitKeyValuePair);
|
||||
|
||||
for (var j = 0; j < kvps.length; j++) {
|
||||
var pair = kvps[j];
|
||||
var key = pair[0].toLowerCase();
|
||||
var val = pair[1];
|
||||
|
||||
// get the value, unwrapping quotes
|
||||
var value = val && val[0] === '"' && val[val.length - 1] === '"'
|
||||
? val.substr(1, val.length - 2)
|
||||
: val;
|
||||
|
||||
if (key === 'q') {
|
||||
q = parseFloat(value);
|
||||
break;
|
||||
}
|
||||
|
||||
// store parameter
|
||||
params[key] = value;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
type: type,
|
||||
subtype: subtype,
|
||||
params: params,
|
||||
q: q,
|
||||
i: i
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the priority of a media type.
|
||||
* @private
|
||||
*/
|
||||
|
||||
function getMediaTypePriority(type, accepted, index) {
|
||||
var priority = {o: -1, q: 0, s: 0};
|
||||
|
||||
for (var i = 0; i < accepted.length; i++) {
|
||||
var spec = specify(type, accepted[i], index);
|
||||
|
||||
if (spec && (priority.s - spec.s || priority.q - spec.q || priority.o - spec.o) < 0) {
|
||||
priority = spec;
|
||||
}
|
||||
}
|
||||
|
||||
return priority;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the specificity of the media type.
|
||||
* @private
|
||||
*/
|
||||
|
||||
function specify(type, spec, index) {
|
||||
var p = parseMediaType(type);
|
||||
var s = 0;
|
||||
|
||||
if (!p) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if(spec.type.toLowerCase() == p.type.toLowerCase()) {
|
||||
s |= 4
|
||||
} else if(spec.type != '*') {
|
||||
return null;
|
||||
}
|
||||
|
||||
if(spec.subtype.toLowerCase() == p.subtype.toLowerCase()) {
|
||||
s |= 2
|
||||
} else if(spec.subtype != '*') {
|
||||
return null;
|
||||
}
|
||||
|
||||
var keys = Object.keys(spec.params);
|
||||
if (keys.length > 0) {
|
||||
if (keys.every(function (k) {
|
||||
return spec.params[k] == '*' || (spec.params[k] || '').toLowerCase() == (p.params[k] || '').toLowerCase();
|
||||
})) {
|
||||
s |= 1
|
||||
} else {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
i: index,
|
||||
o: spec.i,
|
||||
q: spec.q,
|
||||
s: s,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the preferred media types from an Accept header.
|
||||
* @public
|
||||
*/
|
||||
|
||||
function preferredMediaTypes(accept, provided) {
|
||||
// RFC 2616 sec 14.2: no header = */*
|
||||
var accepts = parseAccept(accept === undefined ? '*/*' : accept || '');
|
||||
|
||||
if (!provided) {
|
||||
// sorted list of all types
|
||||
return accepts
|
||||
.filter(isQuality)
|
||||
.sort(compareSpecs)
|
||||
.map(getFullType);
|
||||
}
|
||||
|
||||
var priorities = provided.map(function getPriority(type, index) {
|
||||
return getMediaTypePriority(type, accepts, index);
|
||||
});
|
||||
|
||||
// sorted list of accepted types
|
||||
return priorities.filter(isQuality).sort(compareSpecs).map(function getType(priority) {
|
||||
return provided[priorities.indexOf(priority)];
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare two specs.
|
||||
* @private
|
||||
*/
|
||||
|
||||
function compareSpecs(a, b) {
|
||||
return (b.q - a.q) || (b.s - a.s) || (a.o - b.o) || (a.i - b.i) || 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get full type string.
|
||||
* @private
|
||||
*/
|
||||
|
||||
function getFullType(spec) {
|
||||
return spec.type + '/' + spec.subtype;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a spec has any quality.
|
||||
* @private
|
||||
*/
|
||||
|
||||
function isQuality(spec) {
|
||||
return spec.q > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Count the number of quotes in a string.
|
||||
* @private
|
||||
*/
|
||||
|
||||
function quoteCount(string) {
|
||||
var count = 0;
|
||||
var index = 0;
|
||||
|
||||
while ((index = string.indexOf('"', index)) !== -1) {
|
||||
count++;
|
||||
index++;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Split a key value pair.
|
||||
* @private
|
||||
*/
|
||||
|
||||
function splitKeyValuePair(str) {
|
||||
var index = str.indexOf('=');
|
||||
var key;
|
||||
var val;
|
||||
|
||||
if (index === -1) {
|
||||
key = str;
|
||||
} else {
|
||||
key = str.substr(0, index);
|
||||
val = str.substr(index + 1);
|
||||
}
|
||||
|
||||
return [key, val];
|
||||
}
|
||||
|
||||
/**
|
||||
* Split an Accept header into media types.
|
||||
* @private
|
||||
*/
|
||||
|
||||
function splitMediaTypes(accept) {
|
||||
var accepts = accept.split(',');
|
||||
|
||||
for (var i = 1, j = 0; i < accepts.length; i++) {
|
||||
if (quoteCount(accepts[j]) % 2 == 0) {
|
||||
accepts[++j] = accepts[i];
|
||||
} else {
|
||||
accepts[j] += ',' + accepts[i];
|
||||
}
|
||||
}
|
||||
|
||||
// trim accepts
|
||||
accepts.length = j + 1;
|
||||
|
||||
return accepts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Split a string of parameters.
|
||||
* @private
|
||||
*/
|
||||
|
||||
function splitParameters(str) {
|
||||
var parameters = str.split(';');
|
||||
|
||||
for (var i = 1, j = 0; i < parameters.length; i++) {
|
||||
if (quoteCount(parameters[j]) % 2 == 0) {
|
||||
parameters[++j] = parameters[i];
|
||||
} else {
|
||||
parameters[j] += ';' + parameters[i];
|
||||
}
|
||||
}
|
||||
|
||||
// trim parameters
|
||||
parameters.length = j + 1;
|
||||
|
||||
for (var i = 0; i < parameters.length; i++) {
|
||||
parameters[i] = parameters[i].trim();
|
||||
}
|
||||
|
||||
return parameters;
|
||||
}
|
39
node_modules/socketio/node_modules/negotiator/package.json
generated
vendored
Normal file
39
node_modules/socketio/node_modules/negotiator/package.json
generated
vendored
Normal file
@ -0,0 +1,39 @@
|
||||
{
|
||||
"name": "negotiator",
|
||||
"description": "HTTP content negotiation",
|
||||
"version": "0.6.1",
|
||||
"contributors": [
|
||||
"Douglas Christopher Wilson <doug@somethingdoug.com>",
|
||||
"Federico Romero <federico.romero@outboxlabs.com>",
|
||||
"Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)"
|
||||
],
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"http",
|
||||
"content negotiation",
|
||||
"accept",
|
||||
"accept-language",
|
||||
"accept-encoding",
|
||||
"accept-charset"
|
||||
],
|
||||
"repository": "jshttp/negotiator",
|
||||
"devDependencies": {
|
||||
"istanbul": "0.4.3",
|
||||
"mocha": "~1.21.5"
|
||||
},
|
||||
"files": [
|
||||
"lib/",
|
||||
"HISTORY.md",
|
||||
"LICENSE",
|
||||
"index.js",
|
||||
"README.md"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha --reporter spec --check-leaks --bail test/",
|
||||
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/",
|
||||
"test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/"
|
||||
}
|
||||
}
|
83
node_modules/socketio/node_modules/object-assign/index.js
generated
vendored
Normal file
83
node_modules/socketio/node_modules/object-assign/index.js
generated
vendored
Normal file
@ -0,0 +1,83 @@
|
||||
'use strict';
|
||||
/* eslint-disable no-unused-vars */
|
||||
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
||||
var propIsEnumerable = Object.prototype.propertyIsEnumerable;
|
||||
|
||||
function toObject(val) {
|
||||
if (val === null || val === undefined) {
|
||||
throw new TypeError('Object.assign cannot be called with null or undefined');
|
||||
}
|
||||
|
||||
return Object(val);
|
||||
}
|
||||
|
||||
function shouldUseNative() {
|
||||
try {
|
||||
if (!Object.assign) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Detect buggy property enumeration order in older V8 versions.
|
||||
|
||||
// https://bugs.chromium.org/p/v8/issues/detail?id=4118
|
||||
var test1 = new String('abc'); // eslint-disable-line
|
||||
test1[5] = 'de';
|
||||
if (Object.getOwnPropertyNames(test1)[0] === '5') {
|
||||
return false;
|
||||
}
|
||||
|
||||
// https://bugs.chromium.org/p/v8/issues/detail?id=3056
|
||||
var test2 = {};
|
||||
for (var i = 0; i < 10; i++) {
|
||||
test2['_' + String.fromCharCode(i)] = i;
|
||||
}
|
||||
var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
|
||||
return test2[n];
|
||||
});
|
||||
if (order2.join('') !== '0123456789') {
|
||||
return false;
|
||||
}
|
||||
|
||||
// https://bugs.chromium.org/p/v8/issues/detail?id=3056
|
||||
var test3 = {};
|
||||
'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
|
||||
test3[letter] = letter;
|
||||
});
|
||||
if (Object.keys(Object.assign({}, test3)).join('') !==
|
||||
'abcdefghijklmnopqrst') {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
} catch (e) {
|
||||
// We don't expect any of the above to throw, but better to be safe.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = shouldUseNative() ? Object.assign : function (target, source) {
|
||||
var from;
|
||||
var to = toObject(target);
|
||||
var symbols;
|
||||
|
||||
for (var s = 1; s < arguments.length; s++) {
|
||||
from = Object(arguments[s]);
|
||||
|
||||
for (var key in from) {
|
||||
if (hasOwnProperty.call(from, key)) {
|
||||
to[key] = from[key];
|
||||
}
|
||||
}
|
||||
|
||||
if (Object.getOwnPropertySymbols) {
|
||||
symbols = Object.getOwnPropertySymbols(from);
|
||||
for (var i = 0; i < symbols.length; i++) {
|
||||
if (propIsEnumerable.call(from, symbols[i])) {
|
||||
to[symbols[i]] = from[symbols[i]];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return to;
|
||||
};
|
21
node_modules/socketio/node_modules/object-assign/license
generated
vendored
Normal file
21
node_modules/socketio/node_modules/object-assign/license
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
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.
|
42
node_modules/socketio/node_modules/object-assign/package.json
generated
vendored
Normal file
42
node_modules/socketio/node_modules/object-assign/package.json
generated
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
{
|
||||
"name": "object-assign",
|
||||
"version": "4.1.0",
|
||||
"description": "ES2015 Object.assign() ponyfill",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/object-assign",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && mocha",
|
||||
"bench": "matcha bench.js"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"keywords": [
|
||||
"object",
|
||||
"assign",
|
||||
"extend",
|
||||
"properties",
|
||||
"es2015",
|
||||
"ecmascript",
|
||||
"harmony",
|
||||
"ponyfill",
|
||||
"prollyfill",
|
||||
"polyfill",
|
||||
"shim",
|
||||
"browser"
|
||||
],
|
||||
"devDependencies": {
|
||||
"lodash": "^4.8.2",
|
||||
"matcha": "^0.7.0",
|
||||
"mocha": "*",
|
||||
"xo": "*"
|
||||
}
|
||||
}
|
56
node_modules/socketio/node_modules/object-assign/readme.md
generated
vendored
Normal file
56
node_modules/socketio/node_modules/object-assign/readme.md
generated
vendored
Normal file
@ -0,0 +1,56 @@
|
||||
# object-assign [](https://travis-ci.org/sindresorhus/object-assign)
|
||||
|
||||
> ES2015 [`Object.assign()`](http://www.2ality.com/2014/01/object-assign.html) ponyfill
|
||||
|
||||
> Ponyfill: A polyfill that doesn't overwrite the native method
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install --save object-assign
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const objectAssign = require('object-assign');
|
||||
|
||||
objectAssign({foo: 0}, {bar: 1});
|
||||
//=> {foo: 0, bar: 1}
|
||||
|
||||
// multiple sources
|
||||
objectAssign({foo: 0}, {bar: 1}, {baz: 2});
|
||||
//=> {foo: 0, bar: 1, baz: 2}
|
||||
|
||||
// overwrites equal keys
|
||||
objectAssign({foo: 0}, {foo: 1}, {foo: 2});
|
||||
//=> {foo: 2}
|
||||
|
||||
// ignores null and undefined sources
|
||||
objectAssign({foo: 0}, null, {bar: 1}, undefined);
|
||||
//=> {foo: 0, bar: 1}
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### objectAssign(target, source, [source, ...])
|
||||
|
||||
Assigns enumerable own properties of `source` objects to the `target` object and returns the `target` object. Additional `source` objects will overwrite previous ones.
|
||||
|
||||
|
||||
## Resources
|
||||
|
||||
- [ES2015 spec - Object.assign](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.assign)
|
||||
|
||||
|
||||
## Related
|
||||
|
||||
- [deep-assign](https://github.com/sindresorhus/deep-assign) - Recursive `Object.assign()`
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Sindre Sorhus](https://sindresorhus.com)
|
1
node_modules/socketio/node_modules/socket.io-adapter/.npmignore
generated
vendored
Normal file
1
node_modules/socketio/node_modules/socket.io-adapter/.npmignore
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
node_modules
|
41
node_modules/socketio/node_modules/socket.io-adapter/History.md
generated
vendored
Normal file
41
node_modules/socketio/node_modules/socket.io-adapter/History.md
generated
vendored
Normal file
@ -0,0 +1,41 @@
|
||||
|
||||
0.5.0 / 2016-11-20
|
||||
==================
|
||||
|
||||
* [docs] Fix typo in Readme.md (#37)
|
||||
* [chore] Bump socket.io-parser to version 2.3.1 (#43)
|
||||
* [chore] Bump debug to version 2.3.3 (#42)
|
||||
* [feature] Add clientRooms method (#41)
|
||||
|
||||
0.4.0 / 2015-12-03
|
||||
==================
|
||||
|
||||
* package: bump `debug`
|
||||
* use a `Room` class to efficiently track room size
|
||||
* allow `clients(fn)`
|
||||
* call the callback on `delAll`
|
||||
|
||||
0.3.1 / 2014-10-27
|
||||
==================
|
||||
|
||||
* bump parser version
|
||||
* fix room autopruning
|
||||
* add autoprunning of empty rooms
|
||||
* rooms are now created as objects
|
||||
* added the repository field.
|
||||
* updated the debug dependency.
|
||||
|
||||
0.3.0 / 2014-05-30
|
||||
==================
|
||||
|
||||
* bump `socket.io-parser` for binary ack fix
|
||||
|
||||
0.2.0 / 2014-03-14
|
||||
==================
|
||||
|
||||
* upgraded faster parser
|
||||
|
||||
0.1.0 / 2014-03-07
|
||||
==================
|
||||
|
||||
* initial commit
|
20
node_modules/socketio/node_modules/socket.io-adapter/LICENSE
generated
vendored
Normal file
20
node_modules/socketio/node_modules/socket.io-adapter/LICENSE
generated
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2014 Guillermo Rauch <guillermo@learnboost.com>
|
||||
|
||||
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.
|
16
node_modules/socketio/node_modules/socket.io-adapter/Readme.md
generated
vendored
Normal file
16
node_modules/socketio/node_modules/socket.io-adapter/Readme.md
generated
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
|
||||
# socket.io-adapter
|
||||
|
||||
Default socket.io in-memory adapter class.
|
||||
|
||||
## How to use
|
||||
|
||||
This module is not intended for end-user usage, but can be used as an
|
||||
interface to inherit from from other adapters you might want to build.
|
||||
|
||||
As an example of an adapter that builds on top of this, please take a look
|
||||
at [socket.io-redis](https://github.com/learnboost/socket.io-redis).
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
249
node_modules/socketio/node_modules/socket.io-adapter/index.js
generated
vendored
Normal file
249
node_modules/socketio/node_modules/socket.io-adapter/index.js
generated
vendored
Normal file
@ -0,0 +1,249 @@
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var Emitter = require('events').EventEmitter;
|
||||
var parser = require('socket.io-parser');
|
||||
|
||||
/**
|
||||
* Module exports.
|
||||
*/
|
||||
|
||||
module.exports = Adapter;
|
||||
|
||||
/**
|
||||
* Memory adapter constructor.
|
||||
*
|
||||
* @param {Namespace} nsp
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function Adapter(nsp){
|
||||
this.nsp = nsp;
|
||||
this.rooms = {};
|
||||
this.sids = {};
|
||||
this.encoder = new parser.Encoder();
|
||||
}
|
||||
|
||||
/**
|
||||
* Inherits from `EventEmitter`.
|
||||
*/
|
||||
|
||||
Adapter.prototype.__proto__ = Emitter.prototype;
|
||||
|
||||
/**
|
||||
* Adds a socket to a room.
|
||||
*
|
||||
* @param {String} socket id
|
||||
* @param {String} room name
|
||||
* @param {Function} callback
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Adapter.prototype.add = function(id, room, fn){
|
||||
this.sids[id] = this.sids[id] || {};
|
||||
this.sids[id][room] = true;
|
||||
this.rooms[room] = this.rooms[room] || Room();
|
||||
this.rooms[room].add(id);
|
||||
if (fn) process.nextTick(fn.bind(null, null));
|
||||
};
|
||||
|
||||
/**
|
||||
* Removes a socket from a room.
|
||||
*
|
||||
* @param {String} socket id
|
||||
* @param {String} room name
|
||||
* @param {Function} callback
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Adapter.prototype.del = function(id, room, fn){
|
||||
this.sids[id] = this.sids[id] || {};
|
||||
delete this.sids[id][room];
|
||||
if (this.rooms.hasOwnProperty(room)) {
|
||||
this.rooms[room].del(id);
|
||||
if (this.rooms[room].length === 0) delete this.rooms[room];
|
||||
}
|
||||
|
||||
if (fn) process.nextTick(fn.bind(null, null));
|
||||
};
|
||||
|
||||
/**
|
||||
* Removes a socket from all rooms it's joined.
|
||||
*
|
||||
* @param {String} socket id
|
||||
* @param {Function} callback
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Adapter.prototype.delAll = function(id, fn){
|
||||
var rooms = this.sids[id];
|
||||
if (rooms) {
|
||||
for (var room in rooms) {
|
||||
if (this.rooms.hasOwnProperty(room)) {
|
||||
this.rooms[room].del(id);
|
||||
if (this.rooms[room].length === 0) delete this.rooms[room];
|
||||
}
|
||||
}
|
||||
}
|
||||
delete this.sids[id];
|
||||
|
||||
if (fn) process.nextTick(fn.bind(null, null));
|
||||
};
|
||||
|
||||
/**
|
||||
* Broadcasts a packet.
|
||||
*
|
||||
* Options:
|
||||
* - `flags` {Object} flags for this packet
|
||||
* - `except` {Array} sids that should be excluded
|
||||
* - `rooms` {Array} list of rooms to broadcast to
|
||||
*
|
||||
* @param {Object} packet object
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Adapter.prototype.broadcast = function(packet, opts){
|
||||
var rooms = opts.rooms || [];
|
||||
var except = opts.except || [];
|
||||
var flags = opts.flags || {};
|
||||
var packetOpts = {
|
||||
preEncoded: true,
|
||||
volatile: flags.volatile,
|
||||
compress: flags.compress
|
||||
};
|
||||
var ids = {};
|
||||
var self = this;
|
||||
var socket;
|
||||
|
||||
packet.nsp = this.nsp.name;
|
||||
this.encoder.encode(packet, function(encodedPackets) {
|
||||
if (rooms.length) {
|
||||
for (var i = 0; i < rooms.length; i++) {
|
||||
var room = self.rooms[rooms[i]];
|
||||
if (!room) continue;
|
||||
var sockets = room.sockets;
|
||||
for (var id in sockets) {
|
||||
if (sockets.hasOwnProperty(id)) {
|
||||
if (ids[id] || ~except.indexOf(id)) continue;
|
||||
socket = self.nsp.connected[id];
|
||||
if (socket) {
|
||||
socket.packet(encodedPackets, packetOpts);
|
||||
ids[id] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (var id in self.sids) {
|
||||
if (self.sids.hasOwnProperty(id)) {
|
||||
if (~except.indexOf(id)) continue;
|
||||
socket = self.nsp.connected[id];
|
||||
if (socket) socket.packet(encodedPackets, packetOpts);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Gets a list of clients by sid.
|
||||
*
|
||||
* @param {Array} explicit set of rooms to check.
|
||||
* @param {Function} callback
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Adapter.prototype.clients = function(rooms, fn){
|
||||
if ('function' == typeof rooms){
|
||||
fn = rooms;
|
||||
rooms = null;
|
||||
}
|
||||
|
||||
rooms = rooms || [];
|
||||
|
||||
var ids = {};
|
||||
var self = this;
|
||||
var sids = [];
|
||||
var socket;
|
||||
|
||||
if (rooms.length) {
|
||||
for (var i = 0; i < rooms.length; i++) {
|
||||
var room = self.rooms[rooms[i]];
|
||||
if (!room) continue;
|
||||
var sockets = room.sockets;
|
||||
for (var id in sockets) {
|
||||
if (sockets.hasOwnProperty(id)) {
|
||||
if (ids[id]) continue;
|
||||
socket = self.nsp.connected[id];
|
||||
if (socket) {
|
||||
sids.push(id);
|
||||
ids[id] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (var id in self.sids) {
|
||||
if (self.sids.hasOwnProperty(id)) {
|
||||
socket = self.nsp.connected[id];
|
||||
if (socket) sids.push(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (fn) process.nextTick(fn.bind(null, null, sids));
|
||||
};
|
||||
|
||||
/**
|
||||
* Gets the list of rooms a given client has joined.
|
||||
*
|
||||
* @param {String} socket id
|
||||
* @param {Function} callback
|
||||
* @api public
|
||||
*/
|
||||
Adapter.prototype.clientRooms = function(id, fn){
|
||||
var rooms = this.sids[id];
|
||||
if (fn) process.nextTick(fn.bind(null, null, rooms ? Object.keys(rooms) : null));
|
||||
};
|
||||
|
||||
/**
|
||||
* Room constructor.
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function Room(){
|
||||
if (!(this instanceof Room)) return new Room();
|
||||
this.sockets = {};
|
||||
this.length = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a socket to a room.
|
||||
*
|
||||
* @param {String} socket id
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Room.prototype.add = function(id){
|
||||
if (!this.sockets.hasOwnProperty(id)) {
|
||||
this.sockets[id] = true;
|
||||
this.length++;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Removes a socket from a room.
|
||||
*
|
||||
* @param {String} socket id
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Room.prototype.del = function(id){
|
||||
if (this.sockets.hasOwnProperty(id)) {
|
||||
delete this.sockets[id];
|
||||
this.length--;
|
||||
}
|
||||
};
|
14
node_modules/socketio/node_modules/socket.io-adapter/package.json
generated
vendored
Normal file
14
node_modules/socketio/node_modules/socket.io-adapter/package.json
generated
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
{
|
||||
"name": "socket.io-adapter",
|
||||
"version": "0.5.0",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/Automattic/socket.io-adapter.git"
|
||||
},
|
||||
"description": "",
|
||||
"dependencies": {
|
||||
"debug": "2.3.3",
|
||||
"socket.io-parser": "2.3.1"
|
||||
}
|
||||
}
|
127
node_modules/socketio/node_modules/socket.io-parser/History.md
generated
vendored
Normal file
127
node_modules/socketio/node_modules/socket.io-parser/History.md
generated
vendored
Normal file
@ -0,0 +1,127 @@
|
||||
|
||||
2.3.1 / 2016-10-24
|
||||
==================
|
||||
|
||||
* [chore] Revert "Remove deprecated isarray dependency" (#50)
|
||||
|
||||
2.3.0 / 2016-10-21
|
||||
==================
|
||||
|
||||
* [perf] Split try catch into separate function (#40)
|
||||
* [chore] remove browsers setting from .zuul.yml (#34)
|
||||
* [chore] bump zuul (#37)
|
||||
* [chore] Bump zuul to 3.11.0 & zuul-ngrok to 4.0.0 (#41)
|
||||
* [chore] Update zuul browser settings following EOL notices (#42)
|
||||
* [chore] Restrict files included in npm package (#45)
|
||||
* [chore] Update zuul browser settings (#44)
|
||||
* [chore] Remove deprecated isarray dependency (#46)
|
||||
* [chore] Make the build status badge point towards master (#47)
|
||||
* [chore] Move benchmark to dev dependencies (#48)
|
||||
|
||||
2.2.6 / 2015-11-25
|
||||
==================
|
||||
|
||||
* fix the order of exported events [chylli]
|
||||
|
||||
2.2.5 / 2015-11-21
|
||||
==================
|
||||
|
||||
* package: bump debug
|
||||
* update JSON3 to 3.3.2
|
||||
|
||||
2.2.4 / 2015-03-03
|
||||
==================
|
||||
|
||||
* index: fix off-by-one bound checks
|
||||
|
||||
2.2.3 / 2015-02-03
|
||||
==================
|
||||
|
||||
* index: fix potential infinite loop with malicious binary packet
|
||||
|
||||
2.2.2 / 2014-09-04
|
||||
==================
|
||||
|
||||
* prevent direct `Buffer` reference that breaks browserify
|
||||
* binary: reuse `isBuf` helper
|
||||
|
||||
2.2.1 / 2014-06-20
|
||||
==================
|
||||
|
||||
* added benchmarking [kevin-roark]
|
||||
* upgrade component-emitter to 1.1.2 [kevin-roark]
|
||||
* update protocol version [kevin-roark]
|
||||
* less indentation and a small optimization [kevin-roark]
|
||||
|
||||
2.2.0 / 2014-05-30
|
||||
==================
|
||||
|
||||
* added a BINARY_ACK type [kevin-roark]
|
||||
|
||||
2.1.5 / 2014-05-24
|
||||
==================
|
||||
|
||||
* don't iterate keys of `Date` objects [Rase-]
|
||||
|
||||
2.1.4 / 2014-05-17
|
||||
==================
|
||||
|
||||
* fix null reconstruction bug [kevin-roark]
|
||||
|
||||
2.1.3 / 2014-04-27
|
||||
==================
|
||||
|
||||
* bump zuul version
|
||||
* updated protocol version
|
||||
|
||||
2.1.2 / 2014-03-06
|
||||
==================
|
||||
|
||||
* added support for binary in ACK packets
|
||||
|
||||
2.1.1 / 2014-03-04
|
||||
==================
|
||||
|
||||
* removed has-binary-data dependency
|
||||
* fixed the object check in binary.removeBlobs
|
||||
|
||||
2.1.0 / 2014-03-01
|
||||
==================
|
||||
|
||||
* faster and smaller binary parser and protocol [kevin-roark]
|
||||
|
||||
2.0.0 / 2014-02-19
|
||||
==================
|
||||
|
||||
* binary support [kevin-roark]
|
||||
|
||||
1.1.2 / 2014-02-11
|
||||
==================
|
||||
|
||||
* package: bump `json3` to fix IE6-7
|
||||
|
||||
1.1.1 / 2014-02-10
|
||||
==================
|
||||
|
||||
* package: bump debug to fix browserify issues
|
||||
|
||||
1.1.0 / 2013-12-25
|
||||
==================
|
||||
|
||||
* index: use `json3`
|
||||
|
||||
1.0.3 / 2012-12-18
|
||||
==================
|
||||
|
||||
* index: added instrumentation through `debug`
|
||||
* index: make sure decoded `id` is a `Number`
|
||||
|
||||
1.0.2 / 2012-12-18
|
||||
==================
|
||||
|
||||
* index: allow for falsy values in `id` and `data`
|
||||
|
||||
1.0.1 / 2012-12-10
|
||||
==================
|
||||
|
||||
* Revision 1
|
20
node_modules/socketio/node_modules/socket.io-parser/LICENSE
generated
vendored
Normal file
20
node_modules/socketio/node_modules/socket.io-parser/LICENSE
generated
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2014 Guillermo Rauch <guillermo@learnboost.com>
|
||||
|
||||
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.
|
73
node_modules/socketio/node_modules/socket.io-parser/Readme.md
generated
vendored
Normal file
73
node_modules/socketio/node_modules/socket.io-parser/Readme.md
generated
vendored
Normal file
@ -0,0 +1,73 @@
|
||||
|
||||
# socket.io-parser
|
||||
|
||||
[](http://travis-ci.org/socketio/socket.io-parser)
|
||||
[](http://badge.fury.io/js/socket.io-parser)
|
||||
|
||||
A socket.io encoder and decoder written in JavaScript complying with version `3`
|
||||
of [socket.io-protocol](https://github.com/socketio/socket.io-protocol).
|
||||
Used by [socket.io](https://github.com/automattic/socket.io) and
|
||||
[socket.io-client](https://github.com/automattic/socket.io-client).
|
||||
|
||||
## Parser API
|
||||
|
||||
socket.io-parser is the reference implementation of socket.io-protocol. Read
|
||||
the full API here:
|
||||
[socket.io-protocol](https://github.com/learnboost/socket.io-protocol).
|
||||
|
||||
## Example Usage
|
||||
|
||||
### Encoding and decoding a packet
|
||||
|
||||
```js
|
||||
var parser = require('socket.io-parser');
|
||||
var encoder = new parser.Encoder();
|
||||
var packet = {
|
||||
type: parser.EVENT,
|
||||
data: 'test-packet',
|
||||
id: 13
|
||||
};
|
||||
encoder.encode(packet, function(encodedPackets) {
|
||||
var decoder = new parser.Decoder();
|
||||
decoder.on('decoded', function(decodedPacket) {
|
||||
// decodedPacket.type == parser.EVENT
|
||||
// decodedPacket.data == 'test-packet'
|
||||
// decodedPacket.id == 13
|
||||
});
|
||||
|
||||
for (var i = 0; i < encodedPackets.length; i++) {
|
||||
decoder.add(encodedPackets[i]);
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
### Encoding and decoding a packet with binary data
|
||||
|
||||
```js
|
||||
var parser = require('socket.io-parser');
|
||||
var encoder = new parser.Encoder();
|
||||
var packet = {
|
||||
type: parser.BINARY_EVENT,
|
||||
data: {i: new Buffer(1234), j: new Blob([new ArrayBuffer(2)])}
|
||||
id: 15
|
||||
};
|
||||
encoder.encode(packet, function(encodedPackets) {
|
||||
var decoder = new parser.Decoder();
|
||||
decoder.on('decoded', function(decodedPacket) {
|
||||
// decodedPacket.type == parser.BINARY_EVENTEVENT
|
||||
// Buffer.isBuffer(decodedPacket.data.i) == true
|
||||
// Buffer.isBuffer(decodedPacket.data.j) == true
|
||||
// decodedPacket.id == 15
|
||||
});
|
||||
|
||||
for (var i = 0; i < encodedPackets.length; i++) {
|
||||
decoder.add(encodedPackets[i]);
|
||||
}
|
||||
});
|
||||
```
|
||||
See the test suite for more examples of how socket.io-parser is used.
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
141
node_modules/socketio/node_modules/socket.io-parser/binary.js
generated
vendored
Normal file
141
node_modules/socketio/node_modules/socket.io-parser/binary.js
generated
vendored
Normal file
@ -0,0 +1,141 @@
|
||||
/*global Blob,File*/
|
||||
|
||||
/**
|
||||
* Module requirements
|
||||
*/
|
||||
|
||||
var isArray = require('isarray');
|
||||
var isBuf = require('./is-buffer');
|
||||
|
||||
/**
|
||||
* Replaces every Buffer | ArrayBuffer in packet with a numbered placeholder.
|
||||
* Anything with blobs or files should be fed through removeBlobs before coming
|
||||
* here.
|
||||
*
|
||||
* @param {Object} packet - socket.io event packet
|
||||
* @return {Object} with deconstructed packet and list of buffers
|
||||
* @api public
|
||||
*/
|
||||
|
||||
exports.deconstructPacket = function(packet){
|
||||
var buffers = [];
|
||||
var packetData = packet.data;
|
||||
|
||||
function _deconstructPacket(data) {
|
||||
if (!data) return data;
|
||||
|
||||
if (isBuf(data)) {
|
||||
var placeholder = { _placeholder: true, num: buffers.length };
|
||||
buffers.push(data);
|
||||
return placeholder;
|
||||
} else if (isArray(data)) {
|
||||
var newData = new Array(data.length);
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
newData[i] = _deconstructPacket(data[i]);
|
||||
}
|
||||
return newData;
|
||||
} else if ('object' == typeof data && !(data instanceof Date)) {
|
||||
var newData = {};
|
||||
for (var key in data) {
|
||||
newData[key] = _deconstructPacket(data[key]);
|
||||
}
|
||||
return newData;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
var pack = packet;
|
||||
pack.data = _deconstructPacket(packetData);
|
||||
pack.attachments = buffers.length; // number of binary 'attachments'
|
||||
return {packet: pack, buffers: buffers};
|
||||
};
|
||||
|
||||
/**
|
||||
* Reconstructs a binary packet from its placeholder packet and buffers
|
||||
*
|
||||
* @param {Object} packet - event packet with placeholders
|
||||
* @param {Array} buffers - binary buffers to put in placeholder positions
|
||||
* @return {Object} reconstructed packet
|
||||
* @api public
|
||||
*/
|
||||
|
||||
exports.reconstructPacket = function(packet, buffers) {
|
||||
var curPlaceHolder = 0;
|
||||
|
||||
function _reconstructPacket(data) {
|
||||
if (data && data._placeholder) {
|
||||
var buf = buffers[data.num]; // appropriate buffer (should be natural order anyway)
|
||||
return buf;
|
||||
} else if (isArray(data)) {
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
data[i] = _reconstructPacket(data[i]);
|
||||
}
|
||||
return data;
|
||||
} else if (data && 'object' == typeof data) {
|
||||
for (var key in data) {
|
||||
data[key] = _reconstructPacket(data[key]);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
packet.data = _reconstructPacket(packet.data);
|
||||
packet.attachments = undefined; // no longer useful
|
||||
return packet;
|
||||
};
|
||||
|
||||
/**
|
||||
* Asynchronously removes Blobs or Files from data via
|
||||
* FileReader's readAsArrayBuffer method. Used before encoding
|
||||
* data as msgpack. Calls callback with the blobless data.
|
||||
*
|
||||
* @param {Object} data
|
||||
* @param {Function} callback
|
||||
* @api private
|
||||
*/
|
||||
|
||||
exports.removeBlobs = function(data, callback) {
|
||||
function _removeBlobs(obj, curKey, containingObject) {
|
||||
if (!obj) return obj;
|
||||
|
||||
// convert any blob
|
||||
if ((global.Blob && obj instanceof Blob) ||
|
||||
(global.File && obj instanceof File)) {
|
||||
pendingBlobs++;
|
||||
|
||||
// async filereader
|
||||
var fileReader = new FileReader();
|
||||
fileReader.onload = function() { // this.result == arraybuffer
|
||||
if (containingObject) {
|
||||
containingObject[curKey] = this.result;
|
||||
}
|
||||
else {
|
||||
bloblessData = this.result;
|
||||
}
|
||||
|
||||
// if nothing pending its callback time
|
||||
if(! --pendingBlobs) {
|
||||
callback(bloblessData);
|
||||
}
|
||||
};
|
||||
|
||||
fileReader.readAsArrayBuffer(obj); // blob -> arraybuffer
|
||||
} else if (isArray(obj)) { // handle array
|
||||
for (var i = 0; i < obj.length; i++) {
|
||||
_removeBlobs(obj[i], i, obj);
|
||||
}
|
||||
} else if (obj && 'object' == typeof obj && !isBuf(obj)) { // and object
|
||||
for (var key in obj) {
|
||||
_removeBlobs(obj[key], key, obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var pendingBlobs = 0;
|
||||
var bloblessData = data;
|
||||
_removeBlobs(bloblessData);
|
||||
if (!pendingBlobs) {
|
||||
callback(bloblessData);
|
||||
}
|
||||
};
|
404
node_modules/socketio/node_modules/socket.io-parser/index.js
generated
vendored
Normal file
404
node_modules/socketio/node_modules/socket.io-parser/index.js
generated
vendored
Normal file
@ -0,0 +1,404 @@
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var debug = require('debug')('socket.io-parser');
|
||||
var json = require('json3');
|
||||
var Emitter = require('component-emitter');
|
||||
var binary = require('./binary');
|
||||
var isBuf = require('./is-buffer');
|
||||
|
||||
/**
|
||||
* Protocol version.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
exports.protocol = 4;
|
||||
|
||||
/**
|
||||
* Packet types.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
exports.types = [
|
||||
'CONNECT',
|
||||
'DISCONNECT',
|
||||
'EVENT',
|
||||
'ACK',
|
||||
'ERROR',
|
||||
'BINARY_EVENT',
|
||||
'BINARY_ACK'
|
||||
];
|
||||
|
||||
/**
|
||||
* Packet type `connect`.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
exports.CONNECT = 0;
|
||||
|
||||
/**
|
||||
* Packet type `disconnect`.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
exports.DISCONNECT = 1;
|
||||
|
||||
/**
|
||||
* Packet type `event`.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
exports.EVENT = 2;
|
||||
|
||||
/**
|
||||
* Packet type `ack`.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
exports.ACK = 3;
|
||||
|
||||
/**
|
||||
* Packet type `error`.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
exports.ERROR = 4;
|
||||
|
||||
/**
|
||||
* Packet type 'binary event'
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
exports.BINARY_EVENT = 5;
|
||||
|
||||
/**
|
||||
* Packet type `binary ack`. For acks with binary arguments.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
exports.BINARY_ACK = 6;
|
||||
|
||||
/**
|
||||
* Encoder constructor.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
exports.Encoder = Encoder;
|
||||
|
||||
/**
|
||||
* Decoder constructor.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
exports.Decoder = Decoder;
|
||||
|
||||
/**
|
||||
* A socket.io Encoder instance
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function Encoder() {}
|
||||
|
||||
/**
|
||||
* Encode a packet as a single string if non-binary, or as a
|
||||
* buffer sequence, depending on packet type.
|
||||
*
|
||||
* @param {Object} obj - packet object
|
||||
* @param {Function} callback - function to handle encodings (likely engine.write)
|
||||
* @return Calls callback with Array of encodings
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Encoder.prototype.encode = function(obj, callback){
|
||||
debug('encoding packet %j', obj);
|
||||
|
||||
if (exports.BINARY_EVENT == obj.type || exports.BINARY_ACK == obj.type) {
|
||||
encodeAsBinary(obj, callback);
|
||||
}
|
||||
else {
|
||||
var encoding = encodeAsString(obj);
|
||||
callback([encoding]);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Encode packet as string.
|
||||
*
|
||||
* @param {Object} packet
|
||||
* @return {String} encoded
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function encodeAsString(obj) {
|
||||
var str = '';
|
||||
var nsp = false;
|
||||
|
||||
// first is type
|
||||
str += obj.type;
|
||||
|
||||
// attachments if we have them
|
||||
if (exports.BINARY_EVENT == obj.type || exports.BINARY_ACK == obj.type) {
|
||||
str += obj.attachments;
|
||||
str += '-';
|
||||
}
|
||||
|
||||
// if we have a namespace other than `/`
|
||||
// we append it followed by a comma `,`
|
||||
if (obj.nsp && '/' != obj.nsp) {
|
||||
nsp = true;
|
||||
str += obj.nsp;
|
||||
}
|
||||
|
||||
// immediately followed by the id
|
||||
if (null != obj.id) {
|
||||
if (nsp) {
|
||||
str += ',';
|
||||
nsp = false;
|
||||
}
|
||||
str += obj.id;
|
||||
}
|
||||
|
||||
// json data
|
||||
if (null != obj.data) {
|
||||
if (nsp) str += ',';
|
||||
str += json.stringify(obj.data);
|
||||
}
|
||||
|
||||
debug('encoded %j as %s', obj, str);
|
||||
return str;
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode packet as 'buffer sequence' by removing blobs, and
|
||||
* deconstructing packet into object with placeholders and
|
||||
* a list of buffers.
|
||||
*
|
||||
* @param {Object} packet
|
||||
* @return {Buffer} encoded
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function encodeAsBinary(obj, callback) {
|
||||
|
||||
function writeEncoding(bloblessData) {
|
||||
var deconstruction = binary.deconstructPacket(bloblessData);
|
||||
var pack = encodeAsString(deconstruction.packet);
|
||||
var buffers = deconstruction.buffers;
|
||||
|
||||
buffers.unshift(pack); // add packet info to beginning of data list
|
||||
callback(buffers); // write all the buffers
|
||||
}
|
||||
|
||||
binary.removeBlobs(obj, writeEncoding);
|
||||
}
|
||||
|
||||
/**
|
||||
* A socket.io Decoder instance
|
||||
*
|
||||
* @return {Object} decoder
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function Decoder() {
|
||||
this.reconstructor = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mix in `Emitter` with Decoder.
|
||||
*/
|
||||
|
||||
Emitter(Decoder.prototype);
|
||||
|
||||
/**
|
||||
* Decodes an ecoded packet string into packet JSON.
|
||||
*
|
||||
* @param {String} obj - encoded packet
|
||||
* @return {Object} packet
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Decoder.prototype.add = function(obj) {
|
||||
var packet;
|
||||
if ('string' == typeof obj) {
|
||||
packet = decodeString(obj);
|
||||
if (exports.BINARY_EVENT == packet.type || exports.BINARY_ACK == packet.type) { // binary packet's json
|
||||
this.reconstructor = new BinaryReconstructor(packet);
|
||||
|
||||
// no attachments, labeled binary but no binary data to follow
|
||||
if (this.reconstructor.reconPack.attachments === 0) {
|
||||
this.emit('decoded', packet);
|
||||
}
|
||||
} else { // non-binary full packet
|
||||
this.emit('decoded', packet);
|
||||
}
|
||||
}
|
||||
else if (isBuf(obj) || obj.base64) { // raw binary data
|
||||
if (!this.reconstructor) {
|
||||
throw new Error('got binary data when not reconstructing a packet');
|
||||
} else {
|
||||
packet = this.reconstructor.takeBinaryData(obj);
|
||||
if (packet) { // received final buffer
|
||||
this.reconstructor = null;
|
||||
this.emit('decoded', packet);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw new Error('Unknown type: ' + obj);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Decode a packet String (JSON data)
|
||||
*
|
||||
* @param {String} str
|
||||
* @return {Object} packet
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function decodeString(str) {
|
||||
var p = {};
|
||||
var i = 0;
|
||||
|
||||
// look up type
|
||||
p.type = Number(str.charAt(0));
|
||||
if (null == exports.types[p.type]) return error();
|
||||
|
||||
// look up attachments if type binary
|
||||
if (exports.BINARY_EVENT == p.type || exports.BINARY_ACK == p.type) {
|
||||
var buf = '';
|
||||
while (str.charAt(++i) != '-') {
|
||||
buf += str.charAt(i);
|
||||
if (i == str.length) break;
|
||||
}
|
||||
if (buf != Number(buf) || str.charAt(i) != '-') {
|
||||
throw new Error('Illegal attachments');
|
||||
}
|
||||
p.attachments = Number(buf);
|
||||
}
|
||||
|
||||
// look up namespace (if any)
|
||||
if ('/' == str.charAt(i + 1)) {
|
||||
p.nsp = '';
|
||||
while (++i) {
|
||||
var c = str.charAt(i);
|
||||
if (',' == c) break;
|
||||
p.nsp += c;
|
||||
if (i == str.length) break;
|
||||
}
|
||||
} else {
|
||||
p.nsp = '/';
|
||||
}
|
||||
|
||||
// look up id
|
||||
var next = str.charAt(i + 1);
|
||||
if ('' !== next && Number(next) == next) {
|
||||
p.id = '';
|
||||
while (++i) {
|
||||
var c = str.charAt(i);
|
||||
if (null == c || Number(c) != c) {
|
||||
--i;
|
||||
break;
|
||||
}
|
||||
p.id += str.charAt(i);
|
||||
if (i == str.length) break;
|
||||
}
|
||||
p.id = Number(p.id);
|
||||
}
|
||||
|
||||
// look up json data
|
||||
if (str.charAt(++i)) {
|
||||
p = tryParse(p, str.substr(i));
|
||||
}
|
||||
|
||||
debug('decoded %s as %j', str, p);
|
||||
return p;
|
||||
}
|
||||
|
||||
function tryParse(p, str) {
|
||||
try {
|
||||
p.data = json.parse(str);
|
||||
} catch(e){
|
||||
return error();
|
||||
}
|
||||
return p;
|
||||
};
|
||||
|
||||
/**
|
||||
* Deallocates a parser's resources
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Decoder.prototype.destroy = function() {
|
||||
if (this.reconstructor) {
|
||||
this.reconstructor.finishedReconstruction();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* A manager of a binary event's 'buffer sequence'. Should
|
||||
* be constructed whenever a packet of type BINARY_EVENT is
|
||||
* decoded.
|
||||
*
|
||||
* @param {Object} packet
|
||||
* @return {BinaryReconstructor} initialized reconstructor
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function BinaryReconstructor(packet) {
|
||||
this.reconPack = packet;
|
||||
this.buffers = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to be called when binary data received from connection
|
||||
* after a BINARY_EVENT packet.
|
||||
*
|
||||
* @param {Buffer | ArrayBuffer} binData - the raw binary data received
|
||||
* @return {null | Object} returns null if more binary data is expected or
|
||||
* a reconstructed packet object if all buffers have been received.
|
||||
* @api private
|
||||
*/
|
||||
|
||||
BinaryReconstructor.prototype.takeBinaryData = function(binData) {
|
||||
this.buffers.push(binData);
|
||||
if (this.buffers.length == this.reconPack.attachments) { // done with buffer list
|
||||
var packet = binary.reconstructPacket(this.reconPack, this.buffers);
|
||||
this.finishedReconstruction();
|
||||
return packet;
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
/**
|
||||
* Cleans up binary packet reconstruction variables.
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
BinaryReconstructor.prototype.finishedReconstruction = function() {
|
||||
this.reconPack = null;
|
||||
this.buffers = [];
|
||||
};
|
||||
|
||||
function error(data){
|
||||
return {
|
||||
type: exports.ERROR,
|
||||
data: 'parser error'
|
||||
};
|
||||
}
|
13
node_modules/socketio/node_modules/socket.io-parser/is-buffer.js
generated
vendored
Normal file
13
node_modules/socketio/node_modules/socket.io-parser/is-buffer.js
generated
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
|
||||
module.exports = isBuf;
|
||||
|
||||
/**
|
||||
* Returns true if obj is a buffer or an arraybuffer.
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function isBuf(obj) {
|
||||
return (global.Buffer && global.Buffer.isBuffer(obj)) ||
|
||||
(global.ArrayBuffer && obj instanceof ArrayBuffer);
|
||||
}
|
3
node_modules/socketio/node_modules/socket.io-parser/node_modules/debug/.jshintrc
generated
vendored
Normal file
3
node_modules/socketio/node_modules/socket.io-parser/node_modules/debug/.jshintrc
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"laxbreak": true
|
||||
}
|
6
node_modules/socketio/node_modules/socket.io-parser/node_modules/debug/.npmignore
generated
vendored
Normal file
6
node_modules/socketio/node_modules/socket.io-parser/node_modules/debug/.npmignore
generated
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
support
|
||||
test
|
||||
examples
|
||||
example
|
||||
*.sock
|
||||
dist
|
195
node_modules/socketio/node_modules/socket.io-parser/node_modules/debug/History.md
generated
vendored
Normal file
195
node_modules/socketio/node_modules/socket.io-parser/node_modules/debug/History.md
generated
vendored
Normal file
@ -0,0 +1,195 @@
|
||||
|
||||
2.2.0 / 2015-05-09
|
||||
==================
|
||||
|
||||
* package: update "ms" to v0.7.1 (#202, @dougwilson)
|
||||
* README: add logging to file example (#193, @DanielOchoa)
|
||||
* README: fixed a typo (#191, @amir-s)
|
||||
* browser: expose `storage` (#190, @stephenmathieson)
|
||||
* Makefile: add a `distclean` target (#189, @stephenmathieson)
|
||||
|
||||
2.1.3 / 2015-03-13
|
||||
==================
|
||||
|
||||
* Updated stdout/stderr example (#186)
|
||||
* Updated example/stdout.js to match debug current behaviour
|
||||
* Renamed example/stderr.js to stdout.js
|
||||
* Update Readme.md (#184)
|
||||
* replace high intensity foreground color for bold (#182, #183)
|
||||
|
||||
2.1.2 / 2015-03-01
|
||||
==================
|
||||
|
||||
* dist: recompile
|
||||
* update "ms" to v0.7.0
|
||||
* package: update "browserify" to v9.0.3
|
||||
* component: fix "ms.js" repo location
|
||||
* changed bower package name
|
||||
* updated documentation about using debug in a browser
|
||||
* fix: security error on safari (#167, #168, @yields)
|
||||
|
||||
2.1.1 / 2014-12-29
|
||||
==================
|
||||
|
||||
* browser: use `typeof` to check for `console` existence
|
||||
* browser: check for `console.log` truthiness (fix IE 8/9)
|
||||
* browser: add support for Chrome apps
|
||||
* Readme: added Windows usage remarks
|
||||
* Add `bower.json` to properly support bower install
|
||||
|
||||
2.1.0 / 2014-10-15
|
||||
==================
|
||||
|
||||
* node: implement `DEBUG_FD` env variable support
|
||||
* package: update "browserify" to v6.1.0
|
||||
* package: add "license" field to package.json (#135, @panuhorsmalahti)
|
||||
|
||||
2.0.0 / 2014-09-01
|
||||
==================
|
||||
|
||||
* package: update "browserify" to v5.11.0
|
||||
* node: use stderr rather than stdout for logging (#29, @stephenmathieson)
|
||||
|
||||
1.0.4 / 2014-07-15
|
||||
==================
|
||||
|
||||
* dist: recompile
|
||||
* example: remove `console.info()` log usage
|
||||
* example: add "Content-Type" UTF-8 header to browser example
|
||||
* browser: place %c marker after the space character
|
||||
* browser: reset the "content" color via `color: inherit`
|
||||
* browser: add colors support for Firefox >= v31
|
||||
* debug: prefer an instance `log()` function over the global one (#119)
|
||||
* Readme: update documentation about styled console logs for FF v31 (#116, @wryk)
|
||||
|
||||
1.0.3 / 2014-07-09
|
||||
==================
|
||||
|
||||
* Add support for multiple wildcards in namespaces (#122, @seegno)
|
||||
* browser: fix lint
|
||||
|
||||
1.0.2 / 2014-06-10
|
||||
==================
|
||||
|
||||
* browser: update color palette (#113, @gscottolson)
|
||||
* common: make console logging function configurable (#108, @timoxley)
|
||||
* node: fix %o colors on old node <= 0.8.x
|
||||
* Makefile: find node path using shell/which (#109, @timoxley)
|
||||
|
||||
1.0.1 / 2014-06-06
|
||||
==================
|
||||
|
||||
* browser: use `removeItem()` to clear localStorage
|
||||
* browser, node: don't set DEBUG if namespaces is undefined (#107, @leedm777)
|
||||
* package: add "contributors" section
|
||||
* node: fix comment typo
|
||||
* README: list authors
|
||||
|
||||
1.0.0 / 2014-06-04
|
||||
==================
|
||||
|
||||
* make ms diff be global, not be scope
|
||||
* debug: ignore empty strings in enable()
|
||||
* node: make DEBUG_COLORS able to disable coloring
|
||||
* *: export the `colors` array
|
||||
* npmignore: don't publish the `dist` dir
|
||||
* Makefile: refactor to use browserify
|
||||
* package: add "browserify" as a dev dependency
|
||||
* Readme: add Web Inspector Colors section
|
||||
* node: reset terminal color for the debug content
|
||||
* node: map "%o" to `util.inspect()`
|
||||
* browser: map "%j" to `JSON.stringify()`
|
||||
* debug: add custom "formatters"
|
||||
* debug: use "ms" module for humanizing the diff
|
||||
* Readme: add "bash" syntax highlighting
|
||||
* browser: add Firebug color support
|
||||
* browser: add colors for WebKit browsers
|
||||
* node: apply log to `console`
|
||||
* rewrite: abstract common logic for Node & browsers
|
||||
* add .jshintrc file
|
||||
|
||||
0.8.1 / 2014-04-14
|
||||
==================
|
||||
|
||||
* package: re-add the "component" section
|
||||
|
||||
0.8.0 / 2014-03-30
|
||||
==================
|
||||
|
||||
* add `enable()` method for nodejs. Closes #27
|
||||
* change from stderr to stdout
|
||||
* remove unnecessary index.js file
|
||||
|
||||
0.7.4 / 2013-11-13
|
||||
==================
|
||||
|
||||
* remove "browserify" key from package.json (fixes something in browserify)
|
||||
|
||||
0.7.3 / 2013-10-30
|
||||
==================
|
||||
|
||||
* fix: catch localStorage security error when cookies are blocked (Chrome)
|
||||
* add debug(err) support. Closes #46
|
||||
* add .browser prop to package.json. Closes #42
|
||||
|
||||
0.7.2 / 2013-02-06
|
||||
==================
|
||||
|
||||
* fix package.json
|
||||
* fix: Mobile Safari (private mode) is broken with debug
|
||||
* fix: Use unicode to send escape character to shell instead of octal to work with strict mode javascript
|
||||
|
||||
0.7.1 / 2013-02-05
|
||||
==================
|
||||
|
||||
* add repository URL to package.json
|
||||
* add DEBUG_COLORED to force colored output
|
||||
* add browserify support
|
||||
* fix component. Closes #24
|
||||
|
||||
0.7.0 / 2012-05-04
|
||||
==================
|
||||
|
||||
* Added .component to package.json
|
||||
* Added debug.component.js build
|
||||
|
||||
0.6.0 / 2012-03-16
|
||||
==================
|
||||
|
||||
* Added support for "-" prefix in DEBUG [Vinay Pulim]
|
||||
* Added `.enabled` flag to the node version [TooTallNate]
|
||||
|
||||
0.5.0 / 2012-02-02
|
||||
==================
|
||||
|
||||
* Added: humanize diffs. Closes #8
|
||||
* Added `debug.disable()` to the CS variant
|
||||
* Removed padding. Closes #10
|
||||
* Fixed: persist client-side variant again. Closes #9
|
||||
|
||||
0.4.0 / 2012-02-01
|
||||
==================
|
||||
|
||||
* Added browser variant support for older browsers [TooTallNate]
|
||||
* Added `debug.enable('project:*')` to browser variant [TooTallNate]
|
||||
* Added padding to diff (moved it to the right)
|
||||
|
||||
0.3.0 / 2012-01-26
|
||||
==================
|
||||
|
||||
* Added millisecond diff when isatty, otherwise UTC string
|
||||
|
||||
0.2.0 / 2012-01-22
|
||||
==================
|
||||
|
||||
* Added wildcard support
|
||||
|
||||
0.1.0 / 2011-12-02
|
||||
==================
|
||||
|
||||
* Added: remove colors unless stderr isatty [TooTallNate]
|
||||
|
||||
0.0.1 / 2010-01-03
|
||||
==================
|
||||
|
||||
* Initial release
|
36
node_modules/socketio/node_modules/socket.io-parser/node_modules/debug/Makefile
generated
vendored
Normal file
36
node_modules/socketio/node_modules/socket.io-parser/node_modules/debug/Makefile
generated
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
|
||||
# get Makefile directory name: http://stackoverflow.com/a/5982798/376773
|
||||
THIS_MAKEFILE_PATH:=$(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))
|
||||
THIS_DIR:=$(shell cd $(dir $(THIS_MAKEFILE_PATH));pwd)
|
||||
|
||||
# BIN directory
|
||||
BIN := $(THIS_DIR)/node_modules/.bin
|
||||
|
||||
# applications
|
||||
NODE ?= $(shell which node)
|
||||
NPM ?= $(NODE) $(shell which npm)
|
||||
BROWSERIFY ?= $(NODE) $(BIN)/browserify
|
||||
|
||||
all: dist/debug.js
|
||||
|
||||
install: node_modules
|
||||
|
||||
clean:
|
||||
@rm -rf dist
|
||||
|
||||
dist:
|
||||
@mkdir -p $@
|
||||
|
||||
dist/debug.js: node_modules browser.js debug.js dist
|
||||
@$(BROWSERIFY) \
|
||||
--standalone debug \
|
||||
. > $@
|
||||
|
||||
distclean: clean
|
||||
@rm -rf node_modules
|
||||
|
||||
node_modules: package.json
|
||||
@NODE_ENV= $(NPM) install
|
||||
@touch node_modules
|
||||
|
||||
.PHONY: all install clean distclean
|
188
node_modules/socketio/node_modules/socket.io-parser/node_modules/debug/Readme.md
generated
vendored
Normal file
188
node_modules/socketio/node_modules/socket.io-parser/node_modules/debug/Readme.md
generated
vendored
Normal file
@ -0,0 +1,188 @@
|
||||
# debug
|
||||
|
||||
tiny node.js debugging utility modelled after node core's debugging technique.
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
$ npm install debug
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
With `debug` you simply invoke the exported function to generate your debug function, passing it a name which will determine if a noop function is returned, or a decorated `console.error`, so all of the `console` format string goodies you're used to work fine. A unique color is selected per-function for visibility.
|
||||
|
||||
Example _app.js_:
|
||||
|
||||
```js
|
||||
var debug = require('debug')('http')
|
||||
, http = require('http')
|
||||
, name = 'My App';
|
||||
|
||||
// fake app
|
||||
|
||||
debug('booting %s', name);
|
||||
|
||||
http.createServer(function(req, res){
|
||||
debug(req.method + ' ' + req.url);
|
||||
res.end('hello\n');
|
||||
}).listen(3000, function(){
|
||||
debug('listening');
|
||||
});
|
||||
|
||||
// fake worker of some kind
|
||||
|
||||
require('./worker');
|
||||
```
|
||||
|
||||
Example _worker.js_:
|
||||
|
||||
```js
|
||||
var debug = require('debug')('worker');
|
||||
|
||||
setInterval(function(){
|
||||
debug('doing some work');
|
||||
}, 1000);
|
||||
```
|
||||
|
||||
The __DEBUG__ environment variable is then used to enable these based on space or comma-delimited names. Here are some examples:
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
#### Windows note
|
||||
|
||||
On Windows the environment variable is set using the `set` command.
|
||||
|
||||
```cmd
|
||||
set DEBUG=*,-not_this
|
||||
```
|
||||
|
||||
Then, run the program to be debugged as usual.
|
||||
|
||||
## Millisecond diff
|
||||
|
||||
When actively developing an application it can be useful to see when the time spent between one `debug()` call and the next. Suppose for example you invoke `debug()` before requesting a resource, and after as well, the "+NNNms" will show you how much time was spent between calls.
|
||||
|
||||

|
||||
|
||||
When stdout is not a TTY, `Date#toUTCString()` is used, making it more useful for logging the debug information as shown below:
|
||||
|
||||

|
||||
|
||||
## Conventions
|
||||
|
||||
If you're using this in one or more of your libraries, you _should_ use the name of your library so that developers may toggle debugging as desired without guessing names. If you have more than one debuggers you _should_ prefix them with your library name and use ":" to separate features. For example "bodyParser" from Connect would then be "connect:bodyParser".
|
||||
|
||||
## Wildcards
|
||||
|
||||
The `*` character may be used as a wildcard. Suppose for example your library has debuggers named "connect:bodyParser", "connect:compress", "connect:session", instead of listing all three with `DEBUG=connect:bodyParser,connect:compress,connect:session`, you may simply do `DEBUG=connect:*`, or to run everything using this module simply use `DEBUG=*`.
|
||||
|
||||
You can also exclude specific debuggers by prefixing them with a "-" character. For example, `DEBUG=*,-connect:*` would include all debuggers except those starting with "connect:".
|
||||
|
||||
## Browser support
|
||||
|
||||
Debug works in the browser as well, currently persisted by `localStorage`. Consider the situation shown below where you have `worker:a` and `worker:b`, and wish to debug both. Somewhere in the code on your page, include:
|
||||
|
||||
```js
|
||||
window.myDebug = require("debug");
|
||||
```
|
||||
|
||||
("debug" is a global object in the browser so we give this object a different name.) When your page is open in the browser, type the following in the console:
|
||||
|
||||
```js
|
||||
myDebug.enable("worker:*")
|
||||
```
|
||||
|
||||
Refresh the page. Debug output will continue to be sent to the console until it is disabled by typing `myDebug.disable()` in the console.
|
||||
|
||||
```js
|
||||
a = debug('worker:a');
|
||||
b = debug('worker:b');
|
||||
|
||||
setInterval(function(){
|
||||
a('doing some work');
|
||||
}, 1000);
|
||||
|
||||
setInterval(function(){
|
||||
b('doing some work');
|
||||
}, 1200);
|
||||
```
|
||||
|
||||
#### Web Inspector Colors
|
||||
|
||||
Colors are also enabled on "Web Inspectors" that understand the `%c` formatting
|
||||
option. These are WebKit web inspectors, Firefox ([since version
|
||||
31](https://hacks.mozilla.org/2014/05/editable-box-model-multiple-selection-sublime-text-keys-much-more-firefox-developer-tools-episode-31/))
|
||||
and the Firebug plugin for Firefox (any version).
|
||||
|
||||
Colored output looks something like:
|
||||
|
||||

|
||||
|
||||
### stderr vs stdout
|
||||
|
||||
You can set an alternative logging method per-namespace by overriding the `log` method on a per-namespace or globally:
|
||||
|
||||
Example _stdout.js_:
|
||||
|
||||
```js
|
||||
var debug = require('debug');
|
||||
var error = debug('app:error');
|
||||
|
||||
// by default stderr is used
|
||||
error('goes to stderr!');
|
||||
|
||||
var log = debug('app:log');
|
||||
// set this namespace to log via console.log
|
||||
log.log = console.log.bind(console); // don't forget to bind to console!
|
||||
log('goes to stdout');
|
||||
error('still goes to stderr!');
|
||||
|
||||
// set all output to go via console.info
|
||||
// overrides all per-namespace log settings
|
||||
debug.log = console.info.bind(console);
|
||||
error('now goes to stdout via console.info');
|
||||
log('still goes to stdout, but via console.info now');
|
||||
```
|
||||
|
||||
### Save debug output to a file
|
||||
|
||||
You can save all debug statements to a file by piping them.
|
||||
|
||||
Example:
|
||||
|
||||
```bash
|
||||
$ DEBUG_FD=3 node your-app.js 3> whatever.log
|
||||
```
|
||||
|
||||
## Authors
|
||||
|
||||
- TJ Holowaychuk
|
||||
- Nathan Rajlich
|
||||
|
||||
## License
|
||||
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2014 TJ Holowaychuk <tj@vision-media.ca>
|
||||
|
||||
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.
|
28
node_modules/socketio/node_modules/socket.io-parser/node_modules/debug/bower.json
generated
vendored
Normal file
28
node_modules/socketio/node_modules/socket.io-parser/node_modules/debug/bower.json
generated
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
{
|
||||
"name": "visionmedia-debug",
|
||||
"main": "dist/debug.js",
|
||||
"version": "2.2.0",
|
||||
"homepage": "https://github.com/visionmedia/debug",
|
||||
"authors": [
|
||||
"TJ Holowaychuk <tj@vision-media.ca>"
|
||||
],
|
||||
"description": "visionmedia-debug",
|
||||
"moduleType": [
|
||||
"amd",
|
||||
"es6",
|
||||
"globals",
|
||||
"node"
|
||||
],
|
||||
"keywords": [
|
||||
"visionmedia",
|
||||
"debug"
|
||||
],
|
||||
"license": "MIT",
|
||||
"ignore": [
|
||||
"**/.*",
|
||||
"node_modules",
|
||||
"bower_components",
|
||||
"test",
|
||||
"tests"
|
||||
]
|
||||
}
|
168
node_modules/socketio/node_modules/socket.io-parser/node_modules/debug/browser.js
generated
vendored
Normal file
168
node_modules/socketio/node_modules/socket.io-parser/node_modules/debug/browser.js
generated
vendored
Normal file
@ -0,0 +1,168 @@
|
||||
|
||||
/**
|
||||
* This is the web browser implementation of `debug()`.
|
||||
*
|
||||
* Expose `debug()` as the module.
|
||||
*/
|
||||
|
||||
exports = module.exports = require('./debug');
|
||||
exports.log = log;
|
||||
exports.formatArgs = formatArgs;
|
||||
exports.save = save;
|
||||
exports.load = load;
|
||||
exports.useColors = useColors;
|
||||
exports.storage = 'undefined' != typeof chrome
|
||||
&& 'undefined' != typeof chrome.storage
|
||||
? chrome.storage.local
|
||||
: localstorage();
|
||||
|
||||
/**
|
||||
* Colors.
|
||||
*/
|
||||
|
||||
exports.colors = [
|
||||
'lightseagreen',
|
||||
'forestgreen',
|
||||
'goldenrod',
|
||||
'dodgerblue',
|
||||
'darkorchid',
|
||||
'crimson'
|
||||
];
|
||||
|
||||
/**
|
||||
* Currently only WebKit-based Web Inspectors, Firefox >= v31,
|
||||
* and the Firebug extension (any Firefox version) are known
|
||||
* to support "%c" CSS customizations.
|
||||
*
|
||||
* TODO: add a `localStorage` variable to explicitly enable/disable colors
|
||||
*/
|
||||
|
||||
function useColors() {
|
||||
// is webkit? http://stackoverflow.com/a/16459606/376773
|
||||
return ('WebkitAppearance' in document.documentElement.style) ||
|
||||
// is firebug? http://stackoverflow.com/a/398120/376773
|
||||
(window.console && (console.firebug || (console.exception && console.table))) ||
|
||||
// is firefox >= v31?
|
||||
// https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
|
||||
(navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31);
|
||||
}
|
||||
|
||||
/**
|
||||
* Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
|
||||
*/
|
||||
|
||||
exports.formatters.j = function(v) {
|
||||
return JSON.stringify(v);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Colorize log arguments if enabled.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function formatArgs() {
|
||||
var args = arguments;
|
||||
var useColors = this.useColors;
|
||||
|
||||
args[0] = (useColors ? '%c' : '')
|
||||
+ this.namespace
|
||||
+ (useColors ? ' %c' : ' ')
|
||||
+ args[0]
|
||||
+ (useColors ? '%c ' : ' ')
|
||||
+ '+' + exports.humanize(this.diff);
|
||||
|
||||
if (!useColors) return args;
|
||||
|
||||
var c = 'color: ' + this.color;
|
||||
args = [args[0], c, 'color: inherit'].concat(Array.prototype.slice.call(args, 1));
|
||||
|
||||
// the final "%c" is somewhat tricky, because there could be other
|
||||
// arguments passed either before or after the %c, so we need to
|
||||
// figure out the correct index to insert the CSS into
|
||||
var index = 0;
|
||||
var lastC = 0;
|
||||
args[0].replace(/%[a-z%]/g, function(match) {
|
||||
if ('%%' === match) return;
|
||||
index++;
|
||||
if ('%c' === match) {
|
||||
// we only are interested in the *last* %c
|
||||
// (the user may have provided their own)
|
||||
lastC = index;
|
||||
}
|
||||
});
|
||||
|
||||
args.splice(lastC, 0, c);
|
||||
return args;
|
||||
}
|
||||
|
||||
/**
|
||||
* Invokes `console.log()` when available.
|
||||
* No-op when `console.log` is not a "function".
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function log() {
|
||||
// this hackery is required for IE8/9, where
|
||||
// the `console.log` function doesn't have 'apply'
|
||||
return 'object' === typeof console
|
||||
&& console.log
|
||||
&& Function.prototype.apply.call(console.log, console, arguments);
|
||||
}
|
||||
|
||||
/**
|
||||
* Save `namespaces`.
|
||||
*
|
||||
* @param {String} namespaces
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function save(namespaces) {
|
||||
try {
|
||||
if (null == namespaces) {
|
||||
exports.storage.removeItem('debug');
|
||||
} else {
|
||||
exports.storage.debug = namespaces;
|
||||
}
|
||||
} catch(e) {}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load `namespaces`.
|
||||
*
|
||||
* @return {String} returns the previously persisted debug modes
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function load() {
|
||||
var r;
|
||||
try {
|
||||
r = exports.storage.debug;
|
||||
} catch(e) {}
|
||||
return r;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable namespaces listed in `localStorage.debug` initially.
|
||||
*/
|
||||
|
||||
exports.enable(load());
|
||||
|
||||
/**
|
||||
* Localstorage attempts to return the localstorage.
|
||||
*
|
||||
* This is necessary because safari throws
|
||||
* when a user disables cookies/localstorage
|
||||
* and you attempt to access it.
|
||||
*
|
||||
* @return {LocalStorage}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function localstorage(){
|
||||
try {
|
||||
return window.localStorage;
|
||||
} catch (e) {}
|
||||
}
|
19
node_modules/socketio/node_modules/socket.io-parser/node_modules/debug/component.json
generated
vendored
Normal file
19
node_modules/socketio/node_modules/socket.io-parser/node_modules/debug/component.json
generated
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
{
|
||||
"name": "debug",
|
||||
"repo": "visionmedia/debug",
|
||||
"description": "small debugging utility",
|
||||
"version": "2.2.0",
|
||||
"keywords": [
|
||||
"debug",
|
||||
"log",
|
||||
"debugger"
|
||||
],
|
||||
"main": "browser.js",
|
||||
"scripts": [
|
||||
"browser.js",
|
||||
"debug.js"
|
||||
],
|
||||
"dependencies": {
|
||||
"rauchg/ms.js": "0.7.1"
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user