Updated script that can be controled by Nodejs web app
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"
|
||||
}
|
||||
}
|
||||
}
|
647
node_modules/socketio/node_modules/engine.io-client/History.md
generated
vendored
Normal file
647
node_modules/socketio/node_modules/engine.io-client/History.md
generated
vendored
Normal file
@ -0,0 +1,647 @@
|
||||
|
||||
1.8.6 / 2021-06-28
|
||||
===================
|
||||
|
||||
* [chore] Bump xmlhttprequest-ssl to version 1.6.3
|
||||
|
||||
1.8.5 / 2017-12-27
|
||||
===================
|
||||
|
||||
* [chore] Bump ws to version 1.1.5
|
||||
|
||||
1.8.4 / 2017-04-28
|
||||
===================
|
||||
|
||||
(following engine.io bump)
|
||||
|
||||
1.8.3 / 2017-02-16
|
||||
===================
|
||||
|
||||
* [chore] Bump ws to version 1.1.2 (vulnerability fix) (#539) (cherry-picked)
|
||||
|
||||
1.8.2 / 2016-12-11
|
||||
===================
|
||||
|
||||
* [chore] Bump engine.io-parser to version 1.3.2 (#523)
|
||||
|
||||
1.8.1 / 2016-11-27
|
||||
===================
|
||||
|
||||
* [fix] Only add defined callbacks to the stack (#447)
|
||||
|
||||
1.8.0 / 2016-11-20
|
||||
===================
|
||||
|
||||
* [fix] Fixed regression creating connection over https from node (#513)
|
||||
* [fix] Fixed regression creating connection over wss from node (#514)
|
||||
* [feature] Enable definition of timeouts for xhr-polling (#456)
|
||||
* [feature] Added flag forceNode to override the normal behavior of prefering Browser based implementations. (#469)
|
||||
* [feature] add localAddress option (#487)
|
||||
* [chore] update dependencies (#516)
|
||||
* [chore] Speed up lint by avoiding '**/*.js' matching pattern (#517)
|
||||
* [chore] Bump debug to version 2.3.3 (#520)
|
||||
|
||||
1.7.2 / 2016-10-24
|
||||
===================
|
||||
|
||||
* [fix] Set accept header to */* to support react app proxy (#508)
|
||||
* [fix] remove a workaround for ios (#465)
|
||||
* [fix] onPacket now emits data on 'closing' state as well (#484)
|
||||
* [fix] Obfuscate `ActiveXObject` occurrences (#509)
|
||||
* [docs] Add missing `onlyBinaryUpgrades` option in the docs (#510)
|
||||
* [chore] Add Github issue and PR templates (#511)
|
||||
|
||||
1.7.1 / 2016-10-20
|
||||
===================
|
||||
|
||||
* [fix] Define "requestsCount" var and "requests" hash unconditionally (#490)
|
||||
* [perf] Add all properties to the socket in the constructor (#488)
|
||||
* [chore] Update zuul browser settings (#504)
|
||||
* [chore] Bump engine.io-parser to 1.3.1 (#505)
|
||||
* [chore] Use more-specific imports for StealJS compatibility (#467)
|
||||
|
||||
1.7.0 / 2016-10-05
|
||||
===================
|
||||
|
||||
* [fix] Revert "default `rejectUnauthorized` to `true`" (#496)
|
||||
* [fix] Use xhr.responseText if xhr.response is not provided (#483)
|
||||
* [fix] Fix issue with errors during WebSocket creation not being caught (#475)
|
||||
* [style] Add missing semi-colon (#501)
|
||||
* [chore] Add gulp & babel in the build process (#455)
|
||||
* [chore] Add eslint (#458)
|
||||
* [chore] Bump zuul (#464)
|
||||
* [chore] Remove unused submodule (#466)
|
||||
* [chore] Bumping ws to 1.1.1 (#478)
|
||||
* [chore] Update zuul browser settings following EOL notices (#486)
|
||||
* [chore] Bump engine.io-parser (#492)
|
||||
* [chore] Make the build status badge point towards master (#497)
|
||||
* [chore] Bump zuul to 3.11.0 & zuul-ngrok to 4.0.0 (#498)
|
||||
* [chore] Restrict files included in npm package (#499)
|
||||
|
||||
1.6.11 / 2016-06-23
|
||||
===================
|
||||
|
||||
* bump version
|
||||
|
||||
1.6.10 / 2016-06-23
|
||||
===================
|
||||
|
||||
* bump version
|
||||
|
||||
1.6.9 / 2016-05-02
|
||||
==================
|
||||
|
||||
* default `rejectUnauthorized` to `true`
|
||||
|
||||
1.6.8 / 2016-01-25
|
||||
==================
|
||||
|
||||
* safely resolve `ws` module
|
||||
|
||||
1.6.7 / 2016-01-10
|
||||
==================
|
||||
|
||||
* prevent `ws` from being added to the bundle
|
||||
* added jsonp fix for when no `<script>` is found
|
||||
|
||||
1.6.6 / 2016-01-07
|
||||
==================
|
||||
|
||||
* support: add fallback to `global` for nativescript [@ligaz]
|
||||
* exclude `ws` instead of ignoring it from build [@lpinca]
|
||||
|
||||
1.6.5 / 2016-01-05
|
||||
==================
|
||||
|
||||
* package: bump `ws` for sec advisory
|
||||
|
||||
1.6.4 / 2015-12-04
|
||||
==================
|
||||
|
||||
* ipv6 url support
|
||||
* README: fix the description of the `timestampRequests` option
|
||||
* transports: use `yeast` to generate the cache busting id
|
||||
* fix arraybuffer > base64 for binary sends
|
||||
|
||||
1.6.3 / 2015-12-01
|
||||
==================
|
||||
|
||||
* remove compress option from control packets
|
||||
* threshold for permessage-deflate
|
||||
|
||||
1.6.2 / 2015-11-30
|
||||
==================
|
||||
|
||||
* package: bump `ws` for memory fix with compression
|
||||
* fix response parsing error for polling (unused)
|
||||
|
||||
1.6.1 / 2015-11-28
|
||||
==================
|
||||
|
||||
* fix packet options that `ws` changes [Nibbler999]
|
||||
* package: use published `engine.io-parser`
|
||||
|
||||
1.6.0 / 2015-11-28
|
||||
==================
|
||||
|
||||
* test with travis containers
|
||||
* socket: remove duplicate declaration (fixes #434)
|
||||
* package: bump `debug` (fixes #433)
|
||||
* bump zuul and zuul-ngrok
|
||||
* package: fix repository url
|
||||
* bump `ws` for several improvements
|
||||
* fix rejectUnauthorized bug
|
||||
* websocket: improve firing of `drain` in websocket transport
|
||||
* socket: clean up buffers right after `close` event
|
||||
* change semantics of the write callback for polling
|
||||
(fire upon flush instead drain)
|
||||
* socket: fix host parsing for IPv6 URLs
|
||||
* socket: handle parser errors appropriately
|
||||
* expose `ping` and `pong` events
|
||||
* enable `supportsBinary` when running as a node client
|
||||
* introduce `extraHeaders` support
|
||||
* fix error when passing `WebSocket#send` second argument on Safari
|
||||
* 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 0.4.0
|
||||
|
||||
1.5.2 / 2015-07-09
|
||||
==================
|
||||
|
||||
* package: bump `ws` to fix windows build issues
|
||||
|
||||
1.5.1 / 2015-01-19
|
||||
==================
|
||||
|
||||
* do not rely on `git(1)` for dep, point to tarball instead
|
||||
|
||||
1.5.0 / 2015-01-18
|
||||
==================
|
||||
|
||||
* package: bump `engine.io-parser`
|
||||
* fix IE tests firing too many connections [rase-]
|
||||
* fix default port detection when host is specified [defunctzombie]
|
||||
* add support for custom SSL options in constructor [rase-]
|
||||
* only call xhr.abort() on error cases in `polling-xhr` [samcday]
|
||||
|
||||
1.4.3 / 2014-11-21
|
||||
==================
|
||||
|
||||
* support: make the build system work with the latest browserify
|
||||
* test: remove test with partial browser support
|
||||
* Fixed calls to addEventListener in old browsers
|
||||
|
||||
1.4.2 / 2014-10-27
|
||||
==================
|
||||
|
||||
* remove invalid value for strict mode
|
||||
* IE10 should prefer using XHR2 over XDR because it's safer
|
||||
* fixed transport close deferring logic [nkzawa]
|
||||
* wait for buffer to be drained before closing [nkzawa]
|
||||
|
||||
1.4.1 / 2014-10-03
|
||||
==================
|
||||
|
||||
* Fixed "jsonp polling iframe removal error"
|
||||
* Move ws upgrade needing connection tests to a block checking browser support.
|
||||
* check `readyState` in `sendPacket` and close on `upgradeError` too
|
||||
* defer close while upgrading a transport
|
||||
|
||||
1.4.0 / 2014-09-03
|
||||
==================
|
||||
|
||||
* add matrix support for travis runs.
|
||||
* add `enablesXDR` option to turn on `XDomainRequest`
|
||||
* package: bump `browserify`
|
||||
* package: bump `engine.io-parser`
|
||||
* style and close socket after assert
|
||||
* add support for `jsonp` option to turn it off
|
||||
|
||||
1.3.1 / 2014-06-19
|
||||
==================
|
||||
|
||||
* transport: catch utf8 decode errors
|
||||
|
||||
1.3.0 / 2014-06-13
|
||||
==================
|
||||
|
||||
* smaller inherits utility
|
||||
* fix a test for ws
|
||||
* upgrade emitter dep to not rely on tarball
|
||||
|
||||
1.2.2 / 2014-05-30
|
||||
==================
|
||||
|
||||
* package: bump `engine.io-parser` for binary utf8 fix
|
||||
|
||||
1.2.1 / 2014-05-22
|
||||
==================
|
||||
|
||||
* build
|
||||
|
||||
1.2.0 / 2014-05-18
|
||||
==================
|
||||
|
||||
* removed flashsocket, moving to userland
|
||||
* new build
|
||||
|
||||
1.1.1 / 2014-05-14
|
||||
==================
|
||||
|
||||
* jsonp-polling: fixed newline double escaping
|
||||
* package: bump parser
|
||||
* remove legacy Socket#onopen call
|
||||
* added tests for multibyte strings
|
||||
|
||||
1.1.0 / 2014-04-27
|
||||
==================
|
||||
|
||||
* bump zuul version
|
||||
* renamed removeAllListeners to cleanup
|
||||
* use inherits package instead of inherit
|
||||
* removed all references to util.js
|
||||
* fix if statement in FlashWS.ready method
|
||||
* polling-jsonp: prevent spurious errors from being emitted when the window is unloaded
|
||||
* polling-xhr: fix a comment and remove unneeded `document` reference
|
||||
* enforce cache busting for all user agents
|
||||
* JSONP and test fixes for fails in IE
|
||||
* package: bump `engine.io-parser`
|
||||
* polling-xhr: abort the request when the window is unloaded
|
||||
|
||||
1.0.5 / 2014-03-18
|
||||
==================
|
||||
|
||||
* package: bump `engine.io-parser` for android binary fix
|
||||
|
||||
1.0.4 / 2014-03-14
|
||||
==================
|
||||
|
||||
* no base64 encoding for no reason when using websockets
|
||||
|
||||
1.0.3 / 2014-03-12
|
||||
==================
|
||||
|
||||
* fix browserify
|
||||
|
||||
1.0.2 / 2014-03-12
|
||||
==================
|
||||
|
||||
* bump `engine.io-parser`
|
||||
* made `parseJSON` and `parseURI` from `util` their own modules [gkoren]
|
||||
* clean up tests
|
||||
* clean up browserify
|
||||
|
||||
1.0.1 / 2014-03-06
|
||||
==================
|
||||
|
||||
* package: bump `engine.io-parser`
|
||||
|
||||
1.0.0 / 2014-03-06
|
||||
==================
|
||||
|
||||
* run browserify without shims
|
||||
* emit socket upgrade event after upgrade done
|
||||
* better feature detection for XHR2
|
||||
* added `rememberUpgrade` option
|
||||
* binary support
|
||||
|
||||
0.9.0 / 2014-02-09
|
||||
==================
|
||||
|
||||
* Fix simple `host:port` URLs and IPV6 [bmalehorn]
|
||||
* Fix XHR cleanup method [poohlty]
|
||||
* Match semantics of `close` event with `WebSocket`. If an error occurs
|
||||
and `open` hadn't fired before, we still emit `close` as per
|
||||
WebSocket spec [mokesmokes].
|
||||
* Removed SPEC (now in `engine.io-protocol` repository)
|
||||
* Remove `Socket#open` docs (private API) [mokesmokes]
|
||||
|
||||
0.8.2 / 2014-01-18
|
||||
==================
|
||||
|
||||
* polling-xhr: avoid catching user-thrown errors
|
||||
* util: remove unused `hasCORS`
|
||||
* polling: remove deferring for faster startup (fixes #174)
|
||||
* engine now works perfectly on workers
|
||||
|
||||
0.8.1 / 2014-01-17
|
||||
==================
|
||||
|
||||
* package: bump debug to fix `localStorage` issue (fixes #213)
|
||||
* remove duplicate xmlhttprequest code
|
||||
* add iphone automated testing
|
||||
* bump zuul to 1.3.0 to improve tests performance
|
||||
* use invalid ip address for incorrect connection test
|
||||
* Fix GH-224, remove sockets array
|
||||
|
||||
0.8.0 / 2014-01-05
|
||||
==================
|
||||
|
||||
* socket: emit upgrade errors as `upgradeError` instead of `error`
|
||||
|
||||
0.7.14 / 2014-01-01
|
||||
===================
|
||||
|
||||
* test: increase timeouts for network tests
|
||||
* test: whitelist globals
|
||||
* test: improve socket closing test
|
||||
* polling: improve url timestamp for ie11 and allow force disabling
|
||||
* polling-xhr: handle errors for xhr creation (fixes `access denied` issues)
|
||||
* polling-xhr: style
|
||||
* socket: more instrumentation for transport creation
|
||||
* socket: allow explicit `false` for `timestampRequests`
|
||||
* socket: accept `null` as first argument
|
||||
* Makefile: cleanup
|
||||
* .travis: deprecate 0.6
|
||||
|
||||
0.7.13 / 2013-12-20
|
||||
===================
|
||||
|
||||
* use `jsonp` in favor of `XDomainRequest` to preserve `Cookie`
|
||||
headers in all situations [3rd-eden] (fixes #217)
|
||||
* run zuul tests after node tests [defunctzombie]
|
||||
* add zuul support for easier browser testing [defunctzombie]
|
||||
|
||||
0.7.12 / 2013-11-11
|
||||
===================
|
||||
|
||||
* engine.io: updated build to fix WebSocket constructor issue
|
||||
* package: move browserify into devDeps
|
||||
|
||||
0.7.11 / 2013-11-06
|
||||
===================
|
||||
|
||||
* AMD support
|
||||
* Makefile: build now smaller thanks to browserify
|
||||
* add browserify support
|
||||
|
||||
0.7.10 / 2013-10-28
|
||||
===================
|
||||
|
||||
* fixed issue which prevented IE9 and under to pass Cookies to server during handshake
|
||||
* package: update "ws" to v0.4.31
|
||||
* fixed - there is no host property only hostname
|
||||
* fixed - flash socket creation
|
||||
* fixed - emit errors thrown by xhr.send()
|
||||
|
||||
0.7.9 / 2013-08-30
|
||||
==================
|
||||
|
||||
* websocket: pass `undefined` as the WebSocket "protocols"
|
||||
|
||||
0.7.8 / 2013-08-30
|
||||
==================
|
||||
|
||||
* package: update "ws"
|
||||
|
||||
0.7.7 / 2013-08-30
|
||||
==================
|
||||
|
||||
* package: bump ws to 0.4.30
|
||||
* websocket: no more env sniffing, just require `ws` [TooTallNate]
|
||||
* websocket: remove the "bufferedAmount" checking logic [TooTallNate]
|
||||
|
||||
0.7.6 / 2013-08-30
|
||||
==================
|
||||
|
||||
* package: revert ws to avoid upgrade fail now
|
||||
|
||||
0.7.5 / 2013-08-30
|
||||
==================
|
||||
|
||||
* package: bump ws to 0.4.30
|
||||
|
||||
0.7.4 / 2013-08-25
|
||||
==================
|
||||
|
||||
* package: rolling back to `ws` `0.4.25` due to disconnection bug
|
||||
|
||||
0.7.3 / 2013-08-23
|
||||
==================
|
||||
|
||||
* noop bump
|
||||
|
||||
0.7.2 / 2013-08-23
|
||||
==================
|
||||
|
||||
* transports: fix WebSocket transport in the web browser (again)
|
||||
|
||||
0.7.1 / 2013-08-23
|
||||
==================
|
||||
|
||||
* transports: fix WebSocket transport in the web browser
|
||||
* package: upgrade "ws" to v0.4.29
|
||||
|
||||
0.7.0 / 2013-08-23
|
||||
==================
|
||||
|
||||
* socket: add `agent` option
|
||||
* package: point "xmlhttprequest" to our LearnBoost fork for agent support
|
||||
* package: specify a newer version of "ws" that includes `agent` support
|
||||
* util: use "component/has-cors"
|
||||
* transport: fix whitespace
|
||||
* util: use "component/global"
|
||||
* package: Add repository field to readme
|
||||
* socket: Don't lose packets writen during upgrade after a re-open
|
||||
* socket: use a consistent "debug" name for socket.js
|
||||
* package: Update emitter dep to 1.0.1 for old IE support
|
||||
|
||||
0.6.3 / 2013-06-21
|
||||
==================
|
||||
|
||||
* fix check readyState in polling transport (Naoyuki Kanezawa)
|
||||
* use http url in npm dependencies for emitter (Eric Schoffstall)
|
||||
|
||||
0.6.2 / 2013-06-15
|
||||
==================
|
||||
|
||||
* transports: improve polling orderly close (fixes #164)
|
||||
* socket: ignore further transport communication upon `onClose`
|
||||
* socket: added missing `socket#onerror` support
|
||||
* socket: don't call `socket#onclose` if previous state was not `open`
|
||||
* transports: fix iOS5 crash issue
|
||||
* Makefile: extra precaution when building to avoid 0.6.0 build problem
|
||||
|
||||
0.6.1 / 2013-06-06
|
||||
==================
|
||||
|
||||
* engine.io: fixed build
|
||||
|
||||
0.6.0 / 2013-05-31
|
||||
==================
|
||||
|
||||
* does not emit close on incorrect socket connection
|
||||
* use indexof component for ie8 and below
|
||||
* improved x-domain handling
|
||||
* introduce public `ping` api
|
||||
* added drain event
|
||||
* fix `flush` and `flushComplete` events
|
||||
* fixed `drain` bug splicing with upgrading
|
||||
* add support for callbacks with socket.send()
|
||||
|
||||
0.5.0 / 2013-03-16
|
||||
==================
|
||||
|
||||
* socket: implement qs support for `string`
|
||||
* added query.EIO to take protocol version from parser
|
||||
* use istanbul for code coverage
|
||||
* integrated engine.io-protocol 0.3.0
|
||||
* updated ws
|
||||
* fixed JSONPPolling iframe removal error
|
||||
* changed error message to match xhr error message on jsonp transport script tag
|
||||
* Added onerror handler for script tag in jsonp transport
|
||||
* remove uid qs
|
||||
* Added missing colon in payload. Thanks @lsm
|
||||
|
||||
0.4.3 / 2013-02-08
|
||||
==================
|
||||
|
||||
* package: removed unusued `parser.js`
|
||||
|
||||
0.4.2 / 2013-02-08
|
||||
==================
|
||||
|
||||
* polling-jsonp: fix ie6 JSONP on SSL
|
||||
* close also if socket.readyState is on "opening"
|
||||
* parser.js: removed the file package.json: added the engine.io-parser dependency everything else: switched to engine.io-parser
|
||||
* fix "TypeError: Object #<Object> has no method 'global'"
|
||||
* client now ignores unsupported upgrades
|
||||
|
||||
0.4.1 / 2013-01-18
|
||||
==================
|
||||
|
||||
* do not shadow global XMLHttpRequest
|
||||
* socket: added `data` event (as synonym to `message`)
|
||||
* socket: remove `resource` and fix `path`
|
||||
* socket: fixed access to `opts`
|
||||
* test: fixed transports tests
|
||||
* socket: constructor can accept uri/opts simultaneously
|
||||
* SPEC: simplified: removed resource from SPEC
|
||||
* socket: proper `host`/`hostname` support
|
||||
* socket: ensure `onclose` idempotency
|
||||
* socket: added `onerror` instrumentation
|
||||
* socket: fix style
|
||||
* use window to detect platform and fix global reference
|
||||
* *: fix references to `global` (fixes #79)
|
||||
|
||||
0.4.0 / 2012-12-09
|
||||
==================
|
||||
|
||||
* *: now based on `component(1)`
|
||||
* *: module now exports `Socket`
|
||||
* socket: export constructors, utils and `protocol`
|
||||
* *: implemented `emitter` component
|
||||
* *: removed browserbuild and preprocessor instructions
|
||||
|
||||
0.3.10 / 2012-12-03
|
||||
===================
|
||||
|
||||
* socket: fix closing the socket in an `open` listener [mmastrac]
|
||||
* socket: perform ping interval/timer cleanup [mmastrac]
|
||||
* fix SPEC (packages -> packets) [jxck]
|
||||
* socket: handle probe's transport errors [indutny]
|
||||
|
||||
0.3.9 / 2012-10-23
|
||||
==================
|
||||
|
||||
* socket: fix `hostname` instead of `host`
|
||||
* socket: avoid duplicate `port` defaults
|
||||
|
||||
0.3.8 / 2012-10-23
|
||||
==================
|
||||
|
||||
* socket: introduce introspection hooks
|
||||
* socket: introduced `host` and `port` `location` defaults
|
||||
* flashsocket: obfuscate activex (fixes #31)
|
||||
* README: documented reconnect (closes #45)
|
||||
* socket: unset `id` upon close
|
||||
* socket: clear transport listeners upon force close
|
||||
|
||||
0.3.7 / 2012-10-21
|
||||
==================
|
||||
|
||||
* fix `version` [quackingduck]
|
||||
* ping timeout gets reset upon any packet received [indutny]
|
||||
* timeout fixes [cadorn, indutny]
|
||||
* transport: fix xdomain detection in absence of location.port (GH-38)
|
||||
* socket: fix passing `false` as secure getting overridden
|
||||
* socket: default `secure` to `true` for SSL-served pages
|
||||
* socket: fix default port for SSL when `secure` is not supplied
|
||||
|
||||
0.3.6 / 2012-10-16
|
||||
==================
|
||||
|
||||
* socket: reset timeout on any incoming data [indutny]
|
||||
|
||||
0.3.5 / 2012-10-14
|
||||
==================
|
||||
|
||||
* new build
|
||||
|
||||
0.3.4 / 2012-10-14
|
||||
==================
|
||||
|
||||
* package: fix `component` exports
|
||||
|
||||
0.3.3 / 2012-10-10
|
||||
==================
|
||||
|
||||
* socket: fix `secure` default value discovery [quackingduck]
|
||||
|
||||
0.3.2 / 2012-10-08
|
||||
==================
|
||||
|
||||
* Bump
|
||||
|
||||
0.3.1 / 2012-10-08
|
||||
==================
|
||||
|
||||
* socket: added `write` alias for `send`
|
||||
* package: added `component`
|
||||
|
||||
0.3.0 / 2012-09-04
|
||||
==================
|
||||
|
||||
* IE's XDomainRequest cannot do requests that go from HTTPS to HTTP or HTTP to HTTPS [mixu]
|
||||
* Switch to client-initiated ping, and set interval in handshake [cadorn]
|
||||
|
||||
0.2.2 / 2012-08-26
|
||||
==================
|
||||
|
||||
* polling-jsonp: allow unneeded global leak (fixes #41)
|
||||
* polling-jsonp: allow for multiple eio's in the same page
|
||||
|
||||
0.2.1 / 2012-08-13
|
||||
==================
|
||||
|
||||
* Bump
|
||||
|
||||
0.2.0 / 2012-08-06
|
||||
==================
|
||||
|
||||
* polling: introduced `poll` and `pollComplete` (formerly `poll`) events
|
||||
|
||||
0.1.2 / 2012-08-02
|
||||
==================
|
||||
|
||||
* Bump
|
||||
|
||||
0.1.1 / 2012-08-01
|
||||
==================
|
||||
|
||||
* Added options for request timestamping
|
||||
* Made timestamp query param customizable
|
||||
* Added automatic timestamping for Android
|
||||
|
||||
0.1.0 / 2012-07-03
|
||||
==================
|
||||
|
||||
* Initial release.
|
22
node_modules/socketio/node_modules/engine.io-client/LICENSE
generated
vendored
Normal file
22
node_modules/socketio/node_modules/engine.io-client/LICENSE
generated
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2014-2015 Automattic <dev@cloudup.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.
|
295
node_modules/socketio/node_modules/engine.io-client/README.md
generated
vendored
Normal file
295
node_modules/socketio/node_modules/engine.io-client/README.md
generated
vendored
Normal file
@ -0,0 +1,295 @@
|
||||
|
||||
# Engine.IO client
|
||||
|
||||
[](http://travis-ci.org/socketio/engine.io-client)
|
||||
[](http://badge.fury.io/js/engine.io-client)
|
||||
|
||||
This is the client for [Engine.IO](http://github.com/socketio/engine.io),
|
||||
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
|
||||
|
||||
### Standalone
|
||||
|
||||
You can find an `engine.io.js` file in this repository, which is a
|
||||
standalone build you can use as follows:
|
||||
|
||||
```html
|
||||
<script src="/path/to/engine.io.js"></script>
|
||||
<script>
|
||||
// eio = Socket
|
||||
var socket = eio('ws://localhost');
|
||||
socket.on('open', function(){
|
||||
socket.on('message', function(data){});
|
||||
socket.on('close', function(){});
|
||||
});
|
||||
</script>
|
||||
```
|
||||
|
||||
### With browserify
|
||||
|
||||
Engine.IO 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 client package
|
||||
|
||||
```bash
|
||||
$ npm install engine.io-client
|
||||
```
|
||||
|
||||
1. write your app code
|
||||
|
||||
```js
|
||||
var socket = require('engine.io-client')('ws://localhost');
|
||||
socket.on('open', function(){
|
||||
socket.on('message', function(data){});
|
||||
socket.on('close', function(){});
|
||||
});
|
||||
```
|
||||
|
||||
1. build your app bundle
|
||||
|
||||
```bash
|
||||
$ browserify app.js > bundle.js
|
||||
```
|
||||
|
||||
1. include on your page
|
||||
|
||||
```html
|
||||
<script src="/path/to/bundle.js"></script>
|
||||
```
|
||||
|
||||
### Sending and receiving binary
|
||||
|
||||
```html
|
||||
<script src="/path/to/engine.io.js"></script>
|
||||
<script>
|
||||
var socket = new eio.Socket('ws://localhost/');
|
||||
socket.binaryType = 'blob';
|
||||
socket.on('open', function () {
|
||||
socket.send(new Int8Array(5));
|
||||
socket.on('message', function(blob){});
|
||||
socket.on('close', function(){ });
|
||||
});
|
||||
</script>
|
||||
```
|
||||
|
||||
### Node.JS
|
||||
|
||||
Add `engine.io-client` to your `package.json` and then:
|
||||
|
||||
```js
|
||||
var socket = require('engine.io-client')('ws://localhost');
|
||||
socket.on('open', function(){
|
||||
socket.on('message', function(data){});
|
||||
socket.on('close', function(){});
|
||||
});
|
||||
```
|
||||
|
||||
### Node.js with certificates
|
||||
```js
|
||||
var opts = {
|
||||
key: fs.readFileSync('test/fixtures/client.key'),
|
||||
cert: fs.readFileSync('test/fixtures/client.crt'),
|
||||
ca: fs.readFileSync('test/fixtures/ca.crt')
|
||||
};
|
||||
|
||||
var socket = require('engine.io-client')('ws://localhost', opts);
|
||||
socket.on('open', function(){
|
||||
socket.on('message', function(data){});
|
||||
socket.on('close', function(){});
|
||||
});
|
||||
```
|
||||
|
||||
### Node.js with extraHeaders
|
||||
```js
|
||||
var opts = {
|
||||
extraHeaders: {
|
||||
'X-Custom-Header-For-My-Project': 'my-secret-access-token',
|
||||
'Cookie': 'user_session=NI2JlCKF90aE0sJZD9ZzujtdsUqNYSBYxzlTsvdSUe35ZzdtVRGqYFr0kdGxbfc5gUOkR9RGp20GVKza; path=/; expires=Tue, 07-Apr-2015 18:18:08 GMT; secure; HttpOnly'
|
||||
}
|
||||
};
|
||||
|
||||
var socket = require('engine.io-client')('ws://localhost', opts);
|
||||
socket.on('open', function(){
|
||||
socket.on('message', function(data){});
|
||||
socket.on('close', function(){});
|
||||
});
|
||||
```
|
||||
|
||||
## Features
|
||||
|
||||
- Lightweight
|
||||
- Runs on browser and node.js seamlessly
|
||||
- Transports are independent of `Engine`
|
||||
- Easy to debug
|
||||
- Easy to unit test
|
||||
- Runs inside HTML5 WebWorker
|
||||
- Can send and receive binary data
|
||||
- Receives as ArrayBuffer or Blob when in browser, and Buffer or ArrayBuffer
|
||||
in Node
|
||||
- When XHR2 or WebSockets are used, binary is emitted directly. Otherwise
|
||||
binary is encoded into base64 strings, and decoded when binary types are
|
||||
supported.
|
||||
- With browsers that don't support ArrayBuffer, an object { base64: true,
|
||||
data: dataAsBase64String } is emitted on the `message` event.
|
||||
|
||||
## API
|
||||
|
||||
### Socket
|
||||
|
||||
The client class. Mixes in [Emitter](http://github.com/component/emitter).
|
||||
Exposed as `eio` in the browser standalone build.
|
||||
|
||||
#### Properties
|
||||
|
||||
- `protocol` _(Number)_: protocol revision number
|
||||
- `binaryType` _(String)_ : can be set to 'arraybuffer' or 'blob' in browsers,
|
||||
and `buffer` or `arraybuffer` in Node. Blob is only used in browser if it's
|
||||
supported.
|
||||
|
||||
#### Events
|
||||
|
||||
- `open`
|
||||
- Fired upon successful connection.
|
||||
- `message`
|
||||
- Fired when data is received from the server.
|
||||
- **Arguments**
|
||||
- `String` | `ArrayBuffer`: utf-8 encoded data or ArrayBuffer containing
|
||||
binary data
|
||||
- `close`
|
||||
- Fired upon disconnection. In compliance with the WebSocket API spec, this event may be
|
||||
fired even if the `open` event does not occur (i.e. due to connection error or `close()`).
|
||||
- `error`
|
||||
- Fired when an error occurs.
|
||||
- `flush`
|
||||
- Fired upon completing a buffer flush
|
||||
- `drain`
|
||||
- Fired after `drain` event of transport if writeBuffer is empty
|
||||
- `upgradeError`
|
||||
- Fired if an error occurs with a transport we're trying to upgrade to.
|
||||
- `upgrade`
|
||||
- Fired upon upgrade success, after the new transport is set
|
||||
- `ping`
|
||||
- Fired upon _flushing_ a ping packet (ie: actual packet write out)
|
||||
- `pong`
|
||||
- Fired upon receiving a pong packet.
|
||||
|
||||
#### Methods
|
||||
|
||||
- **constructor**
|
||||
- Initializes the client
|
||||
- **Parameters**
|
||||
- `String` uri
|
||||
- `Object`: optional, options object
|
||||
- **Options**
|
||||
- `agent` (`http.Agent`): `http.Agent` to use, defaults to `false` (NodeJS only)
|
||||
- `upgrade` (`Boolean`): defaults to true, whether the client should try
|
||||
to upgrade the transport from long-polling to something better.
|
||||
- `forceJSONP` (`Boolean`): forces JSONP for polling transport.
|
||||
- `jsonp` (`Boolean`): determines whether to use JSONP when
|
||||
necessary for polling. If disabled (by settings to false) an error will
|
||||
be emitted (saying "No transports available") if no other transports
|
||||
are available. If another transport is available for opening a
|
||||
connection (e.g. WebSocket) that transport
|
||||
will be used instead.
|
||||
- `forceBase64` (`Boolean`): forces base 64 encoding for polling transport even when XHR2 responseType is available and WebSocket even if the used standard supports binary.
|
||||
- `enablesXDR` (`Boolean`): enables XDomainRequest for IE8 to avoid loading bar flashing with click sound. default to `false` because XDomainRequest has a flaw of not sending cookie.
|
||||
- `timestampRequests` (`Boolean`): whether to add the timestamp with each
|
||||
transport request. Note: polling requests are always stamped unless this
|
||||
option is explicitly set to `false` (`false`)
|
||||
- `timestampParam` (`String`): timestamp parameter (`t`)
|
||||
- `policyPort` (`Number`): port the policy server listens on (`843`)
|
||||
- `path` (`String`): path to connect to, default is `/engine.io`
|
||||
- `transports` (`Array`): a list of transports to try (in order).
|
||||
Defaults to `['polling', 'websocket']`. `Engine`
|
||||
always attempts to connect directly with the first one, provided the
|
||||
feature detection test for it passes.
|
||||
- `rememberUpgrade` (`Boolean`): defaults to false.
|
||||
If true and if the previous websocket connection to the server succeeded,
|
||||
the connection attempt will bypass the normal upgrade process and will initially
|
||||
try websocket. A connection attempt following a transport error will use the
|
||||
normal upgrade process. It is recommended you turn this on only when using
|
||||
SSL/TLS connections, or if you know that your network does not block websockets.
|
||||
- `pfx` (`String`): Certificate, Private key and CA certificates to use for SSL. Can be used in Node.js client environment to manually specify certificate information.
|
||||
- `key` (`String`): Private key to use for SSL. Can be used in Node.js client environment to manually specify certificate information.
|
||||
- `passphrase` (`String`): A string of passphrase for the private key or pfx. Can be used in Node.js client environment to manually specify certificate information.
|
||||
- `cert` (`String`): Public x509 certificate to use. Can be used in Node.js client environment to manually specify certificate information.
|
||||
- `ca` (`String`|`Array`): An authority certificate or array of authority certificates to check the remote host against.. Can be used in Node.js client environment to manually specify certificate information.
|
||||
- `ciphers` (`String`): A string describing the ciphers to use or exclude. Consult the [cipher format list](http://www.openssl.org/docs/apps/ciphers.html#CIPHER_LIST_FORMAT) for details on the format. Can be used in Node.js client environment to manually specify certificate information.
|
||||
- `rejectUnauthorized` (`Boolean`): If true, the server certificate is verified against the list of supplied CAs. An 'error' event is emitted if verification fails. Verification happens at the connection level, before the HTTP request is sent. Can be used in Node.js client environment to manually specify certificate information.
|
||||
- `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. This option is ignored on the browser. (`1024`)
|
||||
- `extraHeaders` (`Object`): Headers that will be passed for each request to the server (via xhr-polling and via websockets). These values then can be used during handshake or for special proxies. Can only be used in Node.js client environment.
|
||||
- `onlyBinaryUpgrades` (`Boolean`): whether transport upgrades should be restricted to transports supporting binary data (`false`)
|
||||
- `requestTimeout` (`Number`): Timeout for xhr-polling requests in milliseconds (`0`)
|
||||
- `forceNode` (`Boolean`): Uses NodeJS implementation for websockets - even if there is a native Browser-Websocket available, which is preferred by default over the NodeJS implementation. (This is useful when using hybrid platforms like nw.js or electron) (`false`, NodeJS only)
|
||||
- `localAddress` (`String`): the local IP address to connect to
|
||||
- `send`
|
||||
- Sends a message to the server
|
||||
- **Parameters**
|
||||
- `String` | `ArrayBuffer` | `ArrayBufferView` | `Blob`: data to send
|
||||
- `Object`: optional, options object
|
||||
- `Function`: optional, callback upon `drain`
|
||||
- **Options**
|
||||
- `compress` (`Boolean`): whether to compress sending data. This option is ignored and forced to be `true` on the browser. (`true`)
|
||||
- `close`
|
||||
- Disconnects the client.
|
||||
|
||||
### Transport
|
||||
|
||||
The transport class. Private. _Inherits from EventEmitter_.
|
||||
|
||||
#### Events
|
||||
|
||||
- `poll`: emitted by polling transports upon starting a new request
|
||||
- `pollComplete`: emitted by polling transports upon completing a request
|
||||
- `drain`: emitted by polling transports upon a buffer drain
|
||||
|
||||
## Tests
|
||||
|
||||
`engine.io-client` is used to test
|
||||
[engine](http://github.com/socketio/engine.io). Running the `engine.io`
|
||||
test suite ensures the client works and vice-versa.
|
||||
|
||||
Browser tests are run using [zuul](https://github.com/defunctzombie/zuul). You can
|
||||
run the tests locally using the following command.
|
||||
|
||||
```
|
||||
./node_modules/.bin/zuul --local 8080 -- test/index.js
|
||||
```
|
||||
|
||||
Additionally, `engine.io-client` has a standalone test suite you can run
|
||||
with `make test` which will run node.js and browser tests. You must have zuul setup with
|
||||
a saucelabs account.
|
||||
|
||||
## Support
|
||||
|
||||
The support channels for `engine.io-client` 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/socketio/engine.io-client.git
|
||||
```
|
||||
|
||||
Then:
|
||||
|
||||
```bash
|
||||
cd engine.io-client
|
||||
npm install
|
||||
```
|
||||
|
||||
See the `Tests` section above for how to run tests before submitting any patches.
|
||||
|
||||
## License
|
||||
|
||||
MIT - Copyright (c) 2014 Automattic, Inc.
|
4670
node_modules/socketio/node_modules/engine.io-client/engine.io.js
generated
vendored
Normal file
4670
node_modules/socketio/node_modules/engine.io-client/engine.io.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
2
node_modules/socketio/node_modules/engine.io-client/index.js
generated
vendored
Normal file
2
node_modules/socketio/node_modules/engine.io-client/index.js
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
|
||||
module.exports = require('./lib/index');
|
10
node_modules/socketio/node_modules/engine.io-client/lib/index.js
generated
vendored
Normal file
10
node_modules/socketio/node_modules/engine.io-client/lib/index.js
generated
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
|
||||
module.exports = require('./socket');
|
||||
|
||||
/**
|
||||
* Exports parser
|
||||
*
|
||||
* @api public
|
||||
*
|
||||
*/
|
||||
module.exports.parser = require('engine.io-parser');
|
738
node_modules/socketio/node_modules/engine.io-client/lib/socket.js
generated
vendored
Normal file
738
node_modules/socketio/node_modules/engine.io-client/lib/socket.js
generated
vendored
Normal file
@ -0,0 +1,738 @@
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var transports = require('./transports/index');
|
||||
var Emitter = require('component-emitter');
|
||||
var debug = require('debug')('engine.io-client:socket');
|
||||
var index = require('indexof');
|
||||
var parser = require('engine.io-parser');
|
||||
var parseuri = require('parseuri');
|
||||
var parsejson = require('parsejson');
|
||||
var parseqs = require('parseqs');
|
||||
|
||||
/**
|
||||
* Module exports.
|
||||
*/
|
||||
|
||||
module.exports = Socket;
|
||||
|
||||
/**
|
||||
* Socket constructor.
|
||||
*
|
||||
* @param {String|Object} uri or options
|
||||
* @param {Object} options
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function Socket (uri, opts) {
|
||||
if (!(this instanceof Socket)) return new Socket(uri, opts);
|
||||
|
||||
opts = opts || {};
|
||||
|
||||
if (uri && 'object' === typeof uri) {
|
||||
opts = uri;
|
||||
uri = null;
|
||||
}
|
||||
|
||||
if (uri) {
|
||||
uri = parseuri(uri);
|
||||
opts.hostname = uri.host;
|
||||
opts.secure = uri.protocol === 'https' || uri.protocol === 'wss';
|
||||
opts.port = uri.port;
|
||||
if (uri.query) opts.query = uri.query;
|
||||
} else if (opts.host) {
|
||||
opts.hostname = parseuri(opts.host).host;
|
||||
}
|
||||
|
||||
this.secure = null != opts.secure ? opts.secure
|
||||
: (global.location && 'https:' === location.protocol);
|
||||
|
||||
if (opts.hostname && !opts.port) {
|
||||
// if no port is specified manually, use the protocol default
|
||||
opts.port = this.secure ? '443' : '80';
|
||||
}
|
||||
|
||||
this.agent = opts.agent || false;
|
||||
this.hostname = opts.hostname ||
|
||||
(global.location ? location.hostname : 'localhost');
|
||||
this.port = opts.port || (global.location && location.port
|
||||
? location.port
|
||||
: (this.secure ? 443 : 80));
|
||||
this.query = opts.query || {};
|
||||
if ('string' === typeof this.query) this.query = parseqs.decode(this.query);
|
||||
this.upgrade = false !== opts.upgrade;
|
||||
this.path = (opts.path || '/engine.io').replace(/\/$/, '') + '/';
|
||||
this.forceJSONP = !!opts.forceJSONP;
|
||||
this.jsonp = false !== opts.jsonp;
|
||||
this.forceBase64 = !!opts.forceBase64;
|
||||
this.enablesXDR = !!opts.enablesXDR;
|
||||
this.timestampParam = opts.timestampParam || 't';
|
||||
this.timestampRequests = opts.timestampRequests;
|
||||
this.transports = opts.transports || ['polling', 'websocket'];
|
||||
this.readyState = '';
|
||||
this.writeBuffer = [];
|
||||
this.prevBufferLen = 0;
|
||||
this.policyPort = opts.policyPort || 843;
|
||||
this.rememberUpgrade = opts.rememberUpgrade || false;
|
||||
this.binaryType = null;
|
||||
this.onlyBinaryUpgrades = opts.onlyBinaryUpgrades;
|
||||
this.perMessageDeflate = false !== opts.perMessageDeflate ? (opts.perMessageDeflate || {}) : false;
|
||||
|
||||
if (true === this.perMessageDeflate) this.perMessageDeflate = {};
|
||||
if (this.perMessageDeflate && null == this.perMessageDeflate.threshold) {
|
||||
this.perMessageDeflate.threshold = 1024;
|
||||
}
|
||||
|
||||
// SSL options for Node.js client
|
||||
this.pfx = opts.pfx || null;
|
||||
this.key = opts.key || null;
|
||||
this.passphrase = opts.passphrase || null;
|
||||
this.cert = opts.cert || null;
|
||||
this.ca = opts.ca || null;
|
||||
this.ciphers = opts.ciphers || null;
|
||||
this.rejectUnauthorized = opts.rejectUnauthorized === undefined ? null : opts.rejectUnauthorized;
|
||||
this.forceNode = !!opts.forceNode;
|
||||
|
||||
// other options for Node.js client
|
||||
var freeGlobal = typeof global === 'object' && global;
|
||||
if (freeGlobal.global === freeGlobal) {
|
||||
if (opts.extraHeaders && Object.keys(opts.extraHeaders).length > 0) {
|
||||
this.extraHeaders = opts.extraHeaders;
|
||||
}
|
||||
|
||||
if (opts.localAddress) {
|
||||
this.localAddress = opts.localAddress;
|
||||
}
|
||||
}
|
||||
|
||||
// set on handshake
|
||||
this.id = null;
|
||||
this.upgrades = null;
|
||||
this.pingInterval = null;
|
||||
this.pingTimeout = null;
|
||||
|
||||
// set on heartbeat
|
||||
this.pingIntervalTimer = null;
|
||||
this.pingTimeoutTimer = null;
|
||||
|
||||
this.open();
|
||||
}
|
||||
|
||||
Socket.priorWebsocketSuccess = false;
|
||||
|
||||
/**
|
||||
* Mix in `Emitter`.
|
||||
*/
|
||||
|
||||
Emitter(Socket.prototype);
|
||||
|
||||
/**
|
||||
* Protocol version.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Socket.protocol = parser.protocol; // this is an int
|
||||
|
||||
/**
|
||||
* Expose deps for legacy compatibility
|
||||
* and standalone browser access.
|
||||
*/
|
||||
|
||||
Socket.Socket = Socket;
|
||||
Socket.Transport = require('./transport');
|
||||
Socket.transports = require('./transports/index');
|
||||
Socket.parser = require('engine.io-parser');
|
||||
|
||||
/**
|
||||
* Creates transport of the given type.
|
||||
*
|
||||
* @param {String} transport name
|
||||
* @return {Transport}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Socket.prototype.createTransport = function (name) {
|
||||
debug('creating transport "%s"', name);
|
||||
var query = clone(this.query);
|
||||
|
||||
// append engine.io protocol identifier
|
||||
query.EIO = parser.protocol;
|
||||
|
||||
// transport name
|
||||
query.transport = name;
|
||||
|
||||
// session id if we already have one
|
||||
if (this.id) query.sid = this.id;
|
||||
|
||||
var transport = new transports[name]({
|
||||
agent: this.agent,
|
||||
hostname: this.hostname,
|
||||
port: this.port,
|
||||
secure: this.secure,
|
||||
path: this.path,
|
||||
query: query,
|
||||
forceJSONP: this.forceJSONP,
|
||||
jsonp: this.jsonp,
|
||||
forceBase64: this.forceBase64,
|
||||
enablesXDR: this.enablesXDR,
|
||||
timestampRequests: this.timestampRequests,
|
||||
timestampParam: this.timestampParam,
|
||||
policyPort: this.policyPort,
|
||||
socket: this,
|
||||
pfx: this.pfx,
|
||||
key: this.key,
|
||||
passphrase: this.passphrase,
|
||||
cert: this.cert,
|
||||
ca: this.ca,
|
||||
ciphers: this.ciphers,
|
||||
rejectUnauthorized: this.rejectUnauthorized,
|
||||
perMessageDeflate: this.perMessageDeflate,
|
||||
extraHeaders: this.extraHeaders,
|
||||
forceNode: this.forceNode,
|
||||
localAddress: this.localAddress
|
||||
});
|
||||
|
||||
return transport;
|
||||
};
|
||||
|
||||
function clone (obj) {
|
||||
var o = {};
|
||||
for (var i in obj) {
|
||||
if (obj.hasOwnProperty(i)) {
|
||||
o[i] = obj[i];
|
||||
}
|
||||
}
|
||||
return o;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes transport to use and starts probe.
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
Socket.prototype.open = function () {
|
||||
var transport;
|
||||
if (this.rememberUpgrade && Socket.priorWebsocketSuccess && this.transports.indexOf('websocket') !== -1) {
|
||||
transport = 'websocket';
|
||||
} else if (0 === this.transports.length) {
|
||||
// Emit error on next tick so it can be listened to
|
||||
var self = this;
|
||||
setTimeout(function () {
|
||||
self.emit('error', 'No transports available');
|
||||
}, 0);
|
||||
return;
|
||||
} else {
|
||||
transport = this.transports[0];
|
||||
}
|
||||
this.readyState = 'opening';
|
||||
|
||||
// Retry with the next transport if the transport is disabled (jsonp: false)
|
||||
try {
|
||||
transport = this.createTransport(transport);
|
||||
} catch (e) {
|
||||
this.transports.shift();
|
||||
this.open();
|
||||
return;
|
||||
}
|
||||
|
||||
transport.open();
|
||||
this.setTransport(transport);
|
||||
};
|
||||
|
||||
/**
|
||||
* Sets the current transport. Disables the existing one (if any).
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Socket.prototype.setTransport = function (transport) {
|
||||
debug('setting transport %s', transport.name);
|
||||
var self = this;
|
||||
|
||||
if (this.transport) {
|
||||
debug('clearing existing transport %s', this.transport.name);
|
||||
this.transport.removeAllListeners();
|
||||
}
|
||||
|
||||
// set up transport
|
||||
this.transport = transport;
|
||||
|
||||
// set up transport listeners
|
||||
transport
|
||||
.on('drain', function () {
|
||||
self.onDrain();
|
||||
})
|
||||
.on('packet', function (packet) {
|
||||
self.onPacket(packet);
|
||||
})
|
||||
.on('error', function (e) {
|
||||
self.onError(e);
|
||||
})
|
||||
.on('close', function () {
|
||||
self.onClose('transport close');
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Probes a transport.
|
||||
*
|
||||
* @param {String} transport name
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Socket.prototype.probe = function (name) {
|
||||
debug('probing transport "%s"', name);
|
||||
var transport = this.createTransport(name, { probe: 1 });
|
||||
var failed = false;
|
||||
var self = this;
|
||||
|
||||
Socket.priorWebsocketSuccess = false;
|
||||
|
||||
function onTransportOpen () {
|
||||
if (self.onlyBinaryUpgrades) {
|
||||
var upgradeLosesBinary = !this.supportsBinary && self.transport.supportsBinary;
|
||||
failed = failed || upgradeLosesBinary;
|
||||
}
|
||||
if (failed) return;
|
||||
|
||||
debug('probe transport "%s" opened', name);
|
||||
transport.send([{ type: 'ping', data: 'probe' }]);
|
||||
transport.once('packet', function (msg) {
|
||||
if (failed) return;
|
||||
if ('pong' === msg.type && 'probe' === msg.data) {
|
||||
debug('probe transport "%s" pong', name);
|
||||
self.upgrading = true;
|
||||
self.emit('upgrading', transport);
|
||||
if (!transport) return;
|
||||
Socket.priorWebsocketSuccess = 'websocket' === transport.name;
|
||||
|
||||
debug('pausing current transport "%s"', self.transport.name);
|
||||
self.transport.pause(function () {
|
||||
if (failed) return;
|
||||
if ('closed' === self.readyState) return;
|
||||
debug('changing transport and sending upgrade packet');
|
||||
|
||||
cleanup();
|
||||
|
||||
self.setTransport(transport);
|
||||
transport.send([{ type: 'upgrade' }]);
|
||||
self.emit('upgrade', transport);
|
||||
transport = null;
|
||||
self.upgrading = false;
|
||||
self.flush();
|
||||
});
|
||||
} else {
|
||||
debug('probe transport "%s" failed', name);
|
||||
var err = new Error('probe error');
|
||||
err.transport = transport.name;
|
||||
self.emit('upgradeError', err);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function freezeTransport () {
|
||||
if (failed) return;
|
||||
|
||||
// Any callback called by transport should be ignored since now
|
||||
failed = true;
|
||||
|
||||
cleanup();
|
||||
|
||||
transport.close();
|
||||
transport = null;
|
||||
}
|
||||
|
||||
// Handle any error that happens while probing
|
||||
function onerror (err) {
|
||||
var error = new Error('probe error: ' + err);
|
||||
error.transport = transport.name;
|
||||
|
||||
freezeTransport();
|
||||
|
||||
debug('probe transport "%s" failed because of error: %s', name, err);
|
||||
|
||||
self.emit('upgradeError', error);
|
||||
}
|
||||
|
||||
function onTransportClose () {
|
||||
onerror('transport closed');
|
||||
}
|
||||
|
||||
// When the socket is closed while we're probing
|
||||
function onclose () {
|
||||
onerror('socket closed');
|
||||
}
|
||||
|
||||
// When the socket is upgraded while we're probing
|
||||
function onupgrade (to) {
|
||||
if (transport && to.name !== transport.name) {
|
||||
debug('"%s" works - aborting "%s"', to.name, transport.name);
|
||||
freezeTransport();
|
||||
}
|
||||
}
|
||||
|
||||
// Remove all listeners on the transport and on self
|
||||
function cleanup () {
|
||||
transport.removeListener('open', onTransportOpen);
|
||||
transport.removeListener('error', onerror);
|
||||
transport.removeListener('close', onTransportClose);
|
||||
self.removeListener('close', onclose);
|
||||
self.removeListener('upgrading', onupgrade);
|
||||
}
|
||||
|
||||
transport.once('open', onTransportOpen);
|
||||
transport.once('error', onerror);
|
||||
transport.once('close', onTransportClose);
|
||||
|
||||
this.once('close', onclose);
|
||||
this.once('upgrading', onupgrade);
|
||||
|
||||
transport.open();
|
||||
};
|
||||
|
||||
/**
|
||||
* Called when connection is deemed open.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Socket.prototype.onOpen = function () {
|
||||
debug('socket open');
|
||||
this.readyState = 'open';
|
||||
Socket.priorWebsocketSuccess = 'websocket' === this.transport.name;
|
||||
this.emit('open');
|
||||
this.flush();
|
||||
|
||||
// we check for `readyState` in case an `open`
|
||||
// listener already closed the socket
|
||||
if ('open' === this.readyState && this.upgrade && this.transport.pause) {
|
||||
debug('starting upgrade probes');
|
||||
for (var i = 0, l = this.upgrades.length; i < l; i++) {
|
||||
this.probe(this.upgrades[i]);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Handles a packet.
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Socket.prototype.onPacket = function (packet) {
|
||||
if ('opening' === this.readyState || 'open' === this.readyState ||
|
||||
'closing' === this.readyState) {
|
||||
debug('socket receive: type "%s", data "%s"', packet.type, packet.data);
|
||||
|
||||
this.emit('packet', packet);
|
||||
|
||||
// Socket is live - any packet counts
|
||||
this.emit('heartbeat');
|
||||
|
||||
switch (packet.type) {
|
||||
case 'open':
|
||||
this.onHandshake(parsejson(packet.data));
|
||||
break;
|
||||
|
||||
case 'pong':
|
||||
this.setPing();
|
||||
this.emit('pong');
|
||||
break;
|
||||
|
||||
case 'error':
|
||||
var err = new Error('server error');
|
||||
err.code = packet.data;
|
||||
this.onError(err);
|
||||
break;
|
||||
|
||||
case 'message':
|
||||
this.emit('data', packet.data);
|
||||
this.emit('message', packet.data);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
debug('packet received with socket readyState "%s"', this.readyState);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Called upon handshake completion.
|
||||
*
|
||||
* @param {Object} handshake obj
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Socket.prototype.onHandshake = function (data) {
|
||||
this.emit('handshake', data);
|
||||
this.id = data.sid;
|
||||
this.transport.query.sid = data.sid;
|
||||
this.upgrades = this.filterUpgrades(data.upgrades);
|
||||
this.pingInterval = data.pingInterval;
|
||||
this.pingTimeout = data.pingTimeout;
|
||||
this.onOpen();
|
||||
// In case open handler closes socket
|
||||
if ('closed' === this.readyState) return;
|
||||
this.setPing();
|
||||
|
||||
// Prolong liveness of socket on heartbeat
|
||||
this.removeListener('heartbeat', this.onHeartbeat);
|
||||
this.on('heartbeat', this.onHeartbeat);
|
||||
};
|
||||
|
||||
/**
|
||||
* Resets ping timeout.
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Socket.prototype.onHeartbeat = function (timeout) {
|
||||
clearTimeout(this.pingTimeoutTimer);
|
||||
var self = this;
|
||||
self.pingTimeoutTimer = setTimeout(function () {
|
||||
if ('closed' === self.readyState) return;
|
||||
self.onClose('ping timeout');
|
||||
}, timeout || (self.pingInterval + self.pingTimeout));
|
||||
};
|
||||
|
||||
/**
|
||||
* Pings server every `this.pingInterval` and expects response
|
||||
* within `this.pingTimeout` or closes connection.
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Socket.prototype.setPing = function () {
|
||||
var self = this;
|
||||
clearTimeout(self.pingIntervalTimer);
|
||||
self.pingIntervalTimer = setTimeout(function () {
|
||||
debug('writing ping packet - expecting pong within %sms', self.pingTimeout);
|
||||
self.ping();
|
||||
self.onHeartbeat(self.pingTimeout);
|
||||
}, self.pingInterval);
|
||||
};
|
||||
|
||||
/**
|
||||
* Sends a ping packet.
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Socket.prototype.ping = function () {
|
||||
var self = this;
|
||||
this.sendPacket('ping', function () {
|
||||
self.emit('ping');
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Called on `drain` event
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Socket.prototype.onDrain = function () {
|
||||
this.writeBuffer.splice(0, this.prevBufferLen);
|
||||
|
||||
// setting prevBufferLen = 0 is very important
|
||||
// for example, when upgrading, upgrade packet is sent over,
|
||||
// and a nonzero prevBufferLen could cause problems on `drain`
|
||||
this.prevBufferLen = 0;
|
||||
|
||||
if (0 === this.writeBuffer.length) {
|
||||
this.emit('drain');
|
||||
} else {
|
||||
this.flush();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Flush write buffers.
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Socket.prototype.flush = function () {
|
||||
if ('closed' !== this.readyState && this.transport.writable &&
|
||||
!this.upgrading && this.writeBuffer.length) {
|
||||
debug('flushing %d packets in socket', this.writeBuffer.length);
|
||||
this.transport.send(this.writeBuffer);
|
||||
// keep track of current length of writeBuffer
|
||||
// splice writeBuffer and callbackBuffer on `drain`
|
||||
this.prevBufferLen = this.writeBuffer.length;
|
||||
this.emit('flush');
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Sends a message.
|
||||
*
|
||||
* @param {String} message.
|
||||
* @param {Function} callback function.
|
||||
* @param {Object} options.
|
||||
* @return {Socket} for chaining.
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Socket.prototype.write =
|
||||
Socket.prototype.send = function (msg, options, fn) {
|
||||
this.sendPacket('message', msg, options, fn);
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Sends a packet.
|
||||
*
|
||||
* @param {String} packet type.
|
||||
* @param {String} data.
|
||||
* @param {Object} options.
|
||||
* @param {Function} callback function.
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Socket.prototype.sendPacket = function (type, data, options, fn) {
|
||||
if ('function' === typeof data) {
|
||||
fn = data;
|
||||
data = undefined;
|
||||
}
|
||||
|
||||
if ('function' === typeof options) {
|
||||
fn = options;
|
||||
options = null;
|
||||
}
|
||||
|
||||
if ('closing' === this.readyState || 'closed' === this.readyState) {
|
||||
return;
|
||||
}
|
||||
|
||||
options = options || {};
|
||||
options.compress = false !== options.compress;
|
||||
|
||||
var packet = {
|
||||
type: type,
|
||||
data: data,
|
||||
options: options
|
||||
};
|
||||
this.emit('packetCreate', packet);
|
||||
this.writeBuffer.push(packet);
|
||||
if (fn) this.once('flush', fn);
|
||||
this.flush();
|
||||
};
|
||||
|
||||
/**
|
||||
* Closes the connection.
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Socket.prototype.close = function () {
|
||||
if ('opening' === this.readyState || 'open' === this.readyState) {
|
||||
this.readyState = 'closing';
|
||||
|
||||
var self = this;
|
||||
|
||||
if (this.writeBuffer.length) {
|
||||
this.once('drain', function () {
|
||||
if (this.upgrading) {
|
||||
waitForUpgrade();
|
||||
} else {
|
||||
close();
|
||||
}
|
||||
});
|
||||
} else if (this.upgrading) {
|
||||
waitForUpgrade();
|
||||
} else {
|
||||
close();
|
||||
}
|
||||
}
|
||||
|
||||
function close () {
|
||||
self.onClose('forced close');
|
||||
debug('socket closing - telling transport to close');
|
||||
self.transport.close();
|
||||
}
|
||||
|
||||
function cleanupAndClose () {
|
||||
self.removeListener('upgrade', cleanupAndClose);
|
||||
self.removeListener('upgradeError', cleanupAndClose);
|
||||
close();
|
||||
}
|
||||
|
||||
function waitForUpgrade () {
|
||||
// wait for upgrade to finish since we can't send packets while pausing a transport
|
||||
self.once('upgrade', cleanupAndClose);
|
||||
self.once('upgradeError', cleanupAndClose);
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Called upon transport error
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Socket.prototype.onError = function (err) {
|
||||
debug('socket error %j', err);
|
||||
Socket.priorWebsocketSuccess = false;
|
||||
this.emit('error', err);
|
||||
this.onClose('transport error', err);
|
||||
};
|
||||
|
||||
/**
|
||||
* Called upon transport close.
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Socket.prototype.onClose = function (reason, desc) {
|
||||
if ('opening' === this.readyState || 'open' === this.readyState || 'closing' === this.readyState) {
|
||||
debug('socket close with reason: "%s"', reason);
|
||||
var self = this;
|
||||
|
||||
// clear timers
|
||||
clearTimeout(this.pingIntervalTimer);
|
||||
clearTimeout(this.pingTimeoutTimer);
|
||||
|
||||
// stop event from firing again for transport
|
||||
this.transport.removeAllListeners('close');
|
||||
|
||||
// ensure transport won't stay open
|
||||
this.transport.close();
|
||||
|
||||
// ignore further transport communication
|
||||
this.transport.removeAllListeners();
|
||||
|
||||
// set ready state
|
||||
this.readyState = 'closed';
|
||||
|
||||
// clear session id
|
||||
this.id = null;
|
||||
|
||||
// emit close event
|
||||
this.emit('close', reason, desc);
|
||||
|
||||
// clean buffers after, so users can still
|
||||
// grab the buffers on `close` event
|
||||
self.writeBuffer = [];
|
||||
self.prevBufferLen = 0;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Filters upgrades, returning only those matching client transports.
|
||||
*
|
||||
* @param {Array} server upgrades
|
||||
* @api private
|
||||
*
|
||||
*/
|
||||
|
||||
Socket.prototype.filterUpgrades = function (upgrades) {
|
||||
var filteredUpgrades = [];
|
||||
for (var i = 0, j = upgrades.length; i < j; i++) {
|
||||
if (~index(this.transports, upgrades[i])) filteredUpgrades.push(upgrades[i]);
|
||||
}
|
||||
return filteredUpgrades;
|
||||
};
|
157
node_modules/socketio/node_modules/engine.io-client/lib/transport.js
generated
vendored
Normal file
157
node_modules/socketio/node_modules/engine.io-client/lib/transport.js
generated
vendored
Normal file
@ -0,0 +1,157 @@
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var parser = require('engine.io-parser');
|
||||
var Emitter = require('component-emitter');
|
||||
|
||||
/**
|
||||
* Module exports.
|
||||
*/
|
||||
|
||||
module.exports = Transport;
|
||||
|
||||
/**
|
||||
* Transport abstract constructor.
|
||||
*
|
||||
* @param {Object} options.
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function Transport (opts) {
|
||||
this.path = opts.path;
|
||||
this.hostname = opts.hostname;
|
||||
this.port = opts.port;
|
||||
this.secure = opts.secure;
|
||||
this.query = opts.query;
|
||||
this.timestampParam = opts.timestampParam;
|
||||
this.timestampRequests = opts.timestampRequests;
|
||||
this.readyState = '';
|
||||
this.agent = opts.agent || false;
|
||||
this.socket = opts.socket;
|
||||
this.enablesXDR = opts.enablesXDR;
|
||||
|
||||
// SSL options for Node.js client
|
||||
this.pfx = opts.pfx;
|
||||
this.key = opts.key;
|
||||
this.passphrase = opts.passphrase;
|
||||
this.cert = opts.cert;
|
||||
this.ca = opts.ca;
|
||||
this.ciphers = opts.ciphers;
|
||||
this.rejectUnauthorized = opts.rejectUnauthorized;
|
||||
this.forceNode = opts.forceNode;
|
||||
|
||||
// other options for Node.js client
|
||||
this.extraHeaders = opts.extraHeaders;
|
||||
this.localAddress = opts.localAddress;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mix in `Emitter`.
|
||||
*/
|
||||
|
||||
Emitter(Transport.prototype);
|
||||
|
||||
/**
|
||||
* Emits an error.
|
||||
*
|
||||
* @param {String} str
|
||||
* @return {Transport} for chaining
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Transport.prototype.onError = function (msg, desc) {
|
||||
var err = new Error(msg);
|
||||
err.type = 'TransportError';
|
||||
err.description = desc;
|
||||
this.emit('error', err);
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Opens the transport.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Transport.prototype.open = function () {
|
||||
if ('closed' === this.readyState || '' === this.readyState) {
|
||||
this.readyState = 'opening';
|
||||
this.doOpen();
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Closes the transport.
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Transport.prototype.close = function () {
|
||||
if ('opening' === this.readyState || 'open' === this.readyState) {
|
||||
this.doClose();
|
||||
this.onClose();
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Sends multiple packets.
|
||||
*
|
||||
* @param {Array} packets
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Transport.prototype.send = function (packets) {
|
||||
if ('open' === this.readyState) {
|
||||
this.write(packets);
|
||||
} else {
|
||||
throw new Error('Transport not open');
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Called upon open
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Transport.prototype.onOpen = function () {
|
||||
this.readyState = 'open';
|
||||
this.writable = true;
|
||||
this.emit('open');
|
||||
};
|
||||
|
||||
/**
|
||||
* Called with data.
|
||||
*
|
||||
* @param {String} data
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Transport.prototype.onData = function (data) {
|
||||
var packet = parser.decodePacket(data, this.socket.binaryType);
|
||||
this.onPacket(packet);
|
||||
};
|
||||
|
||||
/**
|
||||
* Called with a decoded packet.
|
||||
*/
|
||||
|
||||
Transport.prototype.onPacket = function (packet) {
|
||||
this.emit('packet', packet);
|
||||
};
|
||||
|
||||
/**
|
||||
* Called upon close.
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Transport.prototype.onClose = function () {
|
||||
this.readyState = 'closed';
|
||||
this.emit('close');
|
||||
};
|
53
node_modules/socketio/node_modules/engine.io-client/lib/transports/index.js
generated
vendored
Executable file
53
node_modules/socketio/node_modules/engine.io-client/lib/transports/index.js
generated
vendored
Executable file
@ -0,0 +1,53 @@
|
||||
/**
|
||||
* Module dependencies
|
||||
*/
|
||||
|
||||
var XMLHttpRequest = require('xmlhttprequest-ssl');
|
||||
var XHR = require('./polling-xhr');
|
||||
var JSONP = require('./polling-jsonp');
|
||||
var websocket = require('./websocket');
|
||||
|
||||
/**
|
||||
* Export transports.
|
||||
*/
|
||||
|
||||
exports.polling = polling;
|
||||
exports.websocket = websocket;
|
||||
|
||||
/**
|
||||
* Polling transport polymorphic constructor.
|
||||
* Decides on xhr vs jsonp based on feature detection.
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function polling (opts) {
|
||||
var xhr;
|
||||
var xd = false;
|
||||
var xs = false;
|
||||
var jsonp = false !== opts.jsonp;
|
||||
|
||||
if (global.location) {
|
||||
var isSSL = 'https:' === location.protocol;
|
||||
var port = location.port;
|
||||
|
||||
// some user agents have empty `location.port`
|
||||
if (!port) {
|
||||
port = isSSL ? 443 : 80;
|
||||
}
|
||||
|
||||
xd = opts.hostname !== location.hostname || port !== opts.port;
|
||||
xs = opts.secure !== isSSL;
|
||||
}
|
||||
|
||||
opts.xdomain = xd;
|
||||
opts.xscheme = xs;
|
||||
xhr = new XMLHttpRequest(opts);
|
||||
|
||||
if ('open' in xhr && !opts.forceJSONP) {
|
||||
return new XHR(opts);
|
||||
} else {
|
||||
if (!jsonp) throw new Error('JSONP disabled');
|
||||
return new JSONP(opts);
|
||||
}
|
||||
}
|
231
node_modules/socketio/node_modules/engine.io-client/lib/transports/polling-jsonp.js
generated
vendored
Normal file
231
node_modules/socketio/node_modules/engine.io-client/lib/transports/polling-jsonp.js
generated
vendored
Normal file
@ -0,0 +1,231 @@
|
||||
|
||||
/**
|
||||
* Module requirements.
|
||||
*/
|
||||
|
||||
var Polling = require('./polling');
|
||||
var inherit = require('component-inherit');
|
||||
|
||||
/**
|
||||
* Module exports.
|
||||
*/
|
||||
|
||||
module.exports = JSONPPolling;
|
||||
|
||||
/**
|
||||
* Cached regular expressions.
|
||||
*/
|
||||
|
||||
var rNewline = /\n/g;
|
||||
var rEscapedNewline = /\\n/g;
|
||||
|
||||
/**
|
||||
* Global JSONP callbacks.
|
||||
*/
|
||||
|
||||
var callbacks;
|
||||
|
||||
/**
|
||||
* Noop.
|
||||
*/
|
||||
|
||||
function empty () { }
|
||||
|
||||
/**
|
||||
* JSONP Polling constructor.
|
||||
*
|
||||
* @param {Object} opts.
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function JSONPPolling (opts) {
|
||||
Polling.call(this, opts);
|
||||
|
||||
this.query = this.query || {};
|
||||
|
||||
// define global callbacks array if not present
|
||||
// we do this here (lazily) to avoid unneeded global pollution
|
||||
if (!callbacks) {
|
||||
// we need to consider multiple engines in the same page
|
||||
if (!global.___eio) global.___eio = [];
|
||||
callbacks = global.___eio;
|
||||
}
|
||||
|
||||
// callback identifier
|
||||
this.index = callbacks.length;
|
||||
|
||||
// add callback to jsonp global
|
||||
var self = this;
|
||||
callbacks.push(function (msg) {
|
||||
self.onData(msg);
|
||||
});
|
||||
|
||||
// append to query string
|
||||
this.query.j = this.index;
|
||||
|
||||
// prevent spurious errors from being emitted when the window is unloaded
|
||||
if (global.document && global.addEventListener) {
|
||||
global.addEventListener('beforeunload', function () {
|
||||
if (self.script) self.script.onerror = empty;
|
||||
}, false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Inherits from Polling.
|
||||
*/
|
||||
|
||||
inherit(JSONPPolling, Polling);
|
||||
|
||||
/*
|
||||
* JSONP only supports binary as base64 encoded strings
|
||||
*/
|
||||
|
||||
JSONPPolling.prototype.supportsBinary = false;
|
||||
|
||||
/**
|
||||
* Closes the socket.
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
JSONPPolling.prototype.doClose = function () {
|
||||
if (this.script) {
|
||||
this.script.parentNode.removeChild(this.script);
|
||||
this.script = null;
|
||||
}
|
||||
|
||||
if (this.form) {
|
||||
this.form.parentNode.removeChild(this.form);
|
||||
this.form = null;
|
||||
this.iframe = null;
|
||||
}
|
||||
|
||||
Polling.prototype.doClose.call(this);
|
||||
};
|
||||
|
||||
/**
|
||||
* Starts a poll cycle.
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
JSONPPolling.prototype.doPoll = function () {
|
||||
var self = this;
|
||||
var script = document.createElement('script');
|
||||
|
||||
if (this.script) {
|
||||
this.script.parentNode.removeChild(this.script);
|
||||
this.script = null;
|
||||
}
|
||||
|
||||
script.async = true;
|
||||
script.src = this.uri();
|
||||
script.onerror = function (e) {
|
||||
self.onError('jsonp poll error', e);
|
||||
};
|
||||
|
||||
var insertAt = document.getElementsByTagName('script')[0];
|
||||
if (insertAt) {
|
||||
insertAt.parentNode.insertBefore(script, insertAt);
|
||||
} else {
|
||||
(document.head || document.body).appendChild(script);
|
||||
}
|
||||
this.script = script;
|
||||
|
||||
var isUAgecko = 'undefined' !== typeof navigator && /gecko/i.test(navigator.userAgent);
|
||||
|
||||
if (isUAgecko) {
|
||||
setTimeout(function () {
|
||||
var iframe = document.createElement('iframe');
|
||||
document.body.appendChild(iframe);
|
||||
document.body.removeChild(iframe);
|
||||
}, 100);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Writes with a hidden iframe.
|
||||
*
|
||||
* @param {String} data to send
|
||||
* @param {Function} called upon flush.
|
||||
* @api private
|
||||
*/
|
||||
|
||||
JSONPPolling.prototype.doWrite = function (data, fn) {
|
||||
var self = this;
|
||||
|
||||
if (!this.form) {
|
||||
var form = document.createElement('form');
|
||||
var area = document.createElement('textarea');
|
||||
var id = this.iframeId = 'eio_iframe_' + this.index;
|
||||
var iframe;
|
||||
|
||||
form.className = 'socketio';
|
||||
form.style.position = 'absolute';
|
||||
form.style.top = '-1000px';
|
||||
form.style.left = '-1000px';
|
||||
form.target = id;
|
||||
form.method = 'POST';
|
||||
form.setAttribute('accept-charset', 'utf-8');
|
||||
area.name = 'd';
|
||||
form.appendChild(area);
|
||||
document.body.appendChild(form);
|
||||
|
||||
this.form = form;
|
||||
this.area = area;
|
||||
}
|
||||
|
||||
this.form.action = this.uri();
|
||||
|
||||
function complete () {
|
||||
initIframe();
|
||||
fn();
|
||||
}
|
||||
|
||||
function initIframe () {
|
||||
if (self.iframe) {
|
||||
try {
|
||||
self.form.removeChild(self.iframe);
|
||||
} catch (e) {
|
||||
self.onError('jsonp polling iframe removal error', e);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
// ie6 dynamic iframes with target="" support (thanks Chris Lambacher)
|
||||
var html = '<iframe src="javascript:0" name="' + self.iframeId + '">';
|
||||
iframe = document.createElement(html);
|
||||
} catch (e) {
|
||||
iframe = document.createElement('iframe');
|
||||
iframe.name = self.iframeId;
|
||||
iframe.src = 'javascript:0';
|
||||
}
|
||||
|
||||
iframe.id = self.iframeId;
|
||||
|
||||
self.form.appendChild(iframe);
|
||||
self.iframe = iframe;
|
||||
}
|
||||
|
||||
initIframe();
|
||||
|
||||
// escape \n to prevent it from being converted into \r\n by some UAs
|
||||
// double escaping is required for escaped new lines because unescaping of new lines can be done safely on server-side
|
||||
data = data.replace(rEscapedNewline, '\\\n');
|
||||
this.area.value = data.replace(rNewline, '\\n');
|
||||
|
||||
try {
|
||||
this.form.submit();
|
||||
} catch (e) {}
|
||||
|
||||
if (this.iframe.attachEvent) {
|
||||
this.iframe.onreadystatechange = function () {
|
||||
if (self.iframe.readyState === 'complete') {
|
||||
complete();
|
||||
}
|
||||
};
|
||||
} else {
|
||||
this.iframe.onload = complete;
|
||||
}
|
||||
};
|
424
node_modules/socketio/node_modules/engine.io-client/lib/transports/polling-xhr.js
generated
vendored
Executable file
424
node_modules/socketio/node_modules/engine.io-client/lib/transports/polling-xhr.js
generated
vendored
Executable file
@ -0,0 +1,424 @@
|
||||
/**
|
||||
* Module requirements.
|
||||
*/
|
||||
|
||||
var XMLHttpRequest = require('xmlhttprequest-ssl');
|
||||
var Polling = require('./polling');
|
||||
var Emitter = require('component-emitter');
|
||||
var inherit = require('component-inherit');
|
||||
var debug = require('debug')('engine.io-client:polling-xhr');
|
||||
|
||||
/**
|
||||
* Module exports.
|
||||
*/
|
||||
|
||||
module.exports = XHR;
|
||||
module.exports.Request = Request;
|
||||
|
||||
/**
|
||||
* Empty function
|
||||
*/
|
||||
|
||||
function empty () {}
|
||||
|
||||
/**
|
||||
* XHR Polling constructor.
|
||||
*
|
||||
* @param {Object} opts
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function XHR (opts) {
|
||||
Polling.call(this, opts);
|
||||
this.requestTimeout = opts.requestTimeout;
|
||||
|
||||
if (global.location) {
|
||||
var isSSL = 'https:' === location.protocol;
|
||||
var port = location.port;
|
||||
|
||||
// some user agents have empty `location.port`
|
||||
if (!port) {
|
||||
port = isSSL ? 443 : 80;
|
||||
}
|
||||
|
||||
this.xd = opts.hostname !== global.location.hostname ||
|
||||
port !== opts.port;
|
||||
this.xs = opts.secure !== isSSL;
|
||||
} else {
|
||||
this.extraHeaders = opts.extraHeaders;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Inherits from Polling.
|
||||
*/
|
||||
|
||||
inherit(XHR, Polling);
|
||||
|
||||
/**
|
||||
* XHR supports binary
|
||||
*/
|
||||
|
||||
XHR.prototype.supportsBinary = true;
|
||||
|
||||
/**
|
||||
* Creates a request.
|
||||
*
|
||||
* @param {String} method
|
||||
* @api private
|
||||
*/
|
||||
|
||||
XHR.prototype.request = function (opts) {
|
||||
opts = opts || {};
|
||||
opts.uri = this.uri();
|
||||
opts.xd = this.xd;
|
||||
opts.xs = this.xs;
|
||||
opts.agent = this.agent || false;
|
||||
opts.supportsBinary = this.supportsBinary;
|
||||
opts.enablesXDR = this.enablesXDR;
|
||||
|
||||
// SSL options for Node.js client
|
||||
opts.pfx = this.pfx;
|
||||
opts.key = this.key;
|
||||
opts.passphrase = this.passphrase;
|
||||
opts.cert = this.cert;
|
||||
opts.ca = this.ca;
|
||||
opts.ciphers = this.ciphers;
|
||||
opts.rejectUnauthorized = this.rejectUnauthorized;
|
||||
opts.requestTimeout = this.requestTimeout;
|
||||
|
||||
// other options for Node.js client
|
||||
opts.extraHeaders = this.extraHeaders;
|
||||
|
||||
return new Request(opts);
|
||||
};
|
||||
|
||||
/**
|
||||
* Sends data.
|
||||
*
|
||||
* @param {String} data to send.
|
||||
* @param {Function} called upon flush.
|
||||
* @api private
|
||||
*/
|
||||
|
||||
XHR.prototype.doWrite = function (data, fn) {
|
||||
var isBinary = typeof data !== 'string' && data !== undefined;
|
||||
var req = this.request({ method: 'POST', data: data, isBinary: isBinary });
|
||||
var self = this;
|
||||
req.on('success', fn);
|
||||
req.on('error', function (err) {
|
||||
self.onError('xhr post error', err);
|
||||
});
|
||||
this.sendXhr = req;
|
||||
};
|
||||
|
||||
/**
|
||||
* Starts a poll cycle.
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
XHR.prototype.doPoll = function () {
|
||||
debug('xhr poll');
|
||||
var req = this.request();
|
||||
var self = this;
|
||||
req.on('data', function (data) {
|
||||
self.onData(data);
|
||||
});
|
||||
req.on('error', function (err) {
|
||||
self.onError('xhr poll error', err);
|
||||
});
|
||||
this.pollXhr = req;
|
||||
};
|
||||
|
||||
/**
|
||||
* Request constructor
|
||||
*
|
||||
* @param {Object} options
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function Request (opts) {
|
||||
this.method = opts.method || 'GET';
|
||||
this.uri = opts.uri;
|
||||
this.xd = !!opts.xd;
|
||||
this.xs = !!opts.xs;
|
||||
this.async = false !== opts.async;
|
||||
this.data = undefined !== opts.data ? opts.data : null;
|
||||
this.agent = opts.agent;
|
||||
this.isBinary = opts.isBinary;
|
||||
this.supportsBinary = opts.supportsBinary;
|
||||
this.enablesXDR = opts.enablesXDR;
|
||||
this.requestTimeout = opts.requestTimeout;
|
||||
|
||||
// SSL options for Node.js client
|
||||
this.pfx = opts.pfx;
|
||||
this.key = opts.key;
|
||||
this.passphrase = opts.passphrase;
|
||||
this.cert = opts.cert;
|
||||
this.ca = opts.ca;
|
||||
this.ciphers = opts.ciphers;
|
||||
this.rejectUnauthorized = opts.rejectUnauthorized;
|
||||
|
||||
// other options for Node.js client
|
||||
this.extraHeaders = opts.extraHeaders;
|
||||
|
||||
this.create();
|
||||
}
|
||||
|
||||
/**
|
||||
* Mix in `Emitter`.
|
||||
*/
|
||||
|
||||
Emitter(Request.prototype);
|
||||
|
||||
/**
|
||||
* Creates the XHR object and sends the request.
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Request.prototype.create = function () {
|
||||
var opts = { agent: this.agent, xdomain: this.xd, xscheme: this.xs, enablesXDR: this.enablesXDR };
|
||||
|
||||
// SSL options for Node.js client
|
||||
opts.pfx = this.pfx;
|
||||
opts.key = this.key;
|
||||
opts.passphrase = this.passphrase;
|
||||
opts.cert = this.cert;
|
||||
opts.ca = this.ca;
|
||||
opts.ciphers = this.ciphers;
|
||||
opts.rejectUnauthorized = this.rejectUnauthorized;
|
||||
|
||||
var xhr = this.xhr = new XMLHttpRequest(opts);
|
||||
var self = this;
|
||||
|
||||
try {
|
||||
debug('xhr open %s: %s', this.method, this.uri);
|
||||
xhr.open(this.method, this.uri, this.async);
|
||||
try {
|
||||
if (this.extraHeaders) {
|
||||
xhr.setDisableHeaderCheck(true);
|
||||
for (var i in this.extraHeaders) {
|
||||
if (this.extraHeaders.hasOwnProperty(i)) {
|
||||
xhr.setRequestHeader(i, this.extraHeaders[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e) {}
|
||||
if (this.supportsBinary) {
|
||||
// This has to be done after open because Firefox is stupid
|
||||
// http://stackoverflow.com/questions/13216903/get-binary-data-with-xmlhttprequest-in-a-firefox-extension
|
||||
xhr.responseType = 'arraybuffer';
|
||||
}
|
||||
|
||||
if ('POST' === this.method) {
|
||||
try {
|
||||
if (this.isBinary) {
|
||||
xhr.setRequestHeader('Content-type', 'application/octet-stream');
|
||||
} else {
|
||||
xhr.setRequestHeader('Content-type', 'text/plain;charset=UTF-8');
|
||||
}
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
try {
|
||||
xhr.setRequestHeader('Accept', '*/*');
|
||||
} catch (e) {}
|
||||
|
||||
// ie6 check
|
||||
if ('withCredentials' in xhr) {
|
||||
xhr.withCredentials = true;
|
||||
}
|
||||
|
||||
if (this.requestTimeout) {
|
||||
xhr.timeout = this.requestTimeout;
|
||||
}
|
||||
|
||||
if (this.hasXDR()) {
|
||||
xhr.onload = function () {
|
||||
self.onLoad();
|
||||
};
|
||||
xhr.onerror = function () {
|
||||
self.onError(xhr.responseText);
|
||||
};
|
||||
} else {
|
||||
xhr.onreadystatechange = function () {
|
||||
if (4 !== xhr.readyState) return;
|
||||
if (200 === xhr.status || 1223 === xhr.status) {
|
||||
self.onLoad();
|
||||
} else {
|
||||
// make sure the `error` event handler that's user-set
|
||||
// does not throw in the same tick and gets caught here
|
||||
setTimeout(function () {
|
||||
self.onError(xhr.status);
|
||||
}, 0);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
debug('xhr data %s', this.data);
|
||||
xhr.send(this.data);
|
||||
} catch (e) {
|
||||
// Need to defer since .create() is called directly fhrom the constructor
|
||||
// and thus the 'error' event can only be only bound *after* this exception
|
||||
// occurs. Therefore, also, we cannot throw here at all.
|
||||
setTimeout(function () {
|
||||
self.onError(e);
|
||||
}, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
if (global.document) {
|
||||
this.index = Request.requestsCount++;
|
||||
Request.requests[this.index] = this;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Called upon successful response.
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Request.prototype.onSuccess = function () {
|
||||
this.emit('success');
|
||||
this.cleanup();
|
||||
};
|
||||
|
||||
/**
|
||||
* Called if we have data.
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Request.prototype.onData = function (data) {
|
||||
this.emit('data', data);
|
||||
this.onSuccess();
|
||||
};
|
||||
|
||||
/**
|
||||
* Called upon error.
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Request.prototype.onError = function (err) {
|
||||
this.emit('error', err);
|
||||
this.cleanup(true);
|
||||
};
|
||||
|
||||
/**
|
||||
* Cleans up house.
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Request.prototype.cleanup = function (fromError) {
|
||||
if ('undefined' === typeof this.xhr || null === this.xhr) {
|
||||
return;
|
||||
}
|
||||
// xmlhttprequest
|
||||
if (this.hasXDR()) {
|
||||
this.xhr.onload = this.xhr.onerror = empty;
|
||||
} else {
|
||||
this.xhr.onreadystatechange = empty;
|
||||
}
|
||||
|
||||
if (fromError) {
|
||||
try {
|
||||
this.xhr.abort();
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
if (global.document) {
|
||||
delete Request.requests[this.index];
|
||||
}
|
||||
|
||||
this.xhr = null;
|
||||
};
|
||||
|
||||
/**
|
||||
* Called upon load.
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Request.prototype.onLoad = function () {
|
||||
var data;
|
||||
try {
|
||||
var contentType;
|
||||
try {
|
||||
contentType = this.xhr.getResponseHeader('Content-Type').split(';')[0];
|
||||
} catch (e) {}
|
||||
if (contentType === 'application/octet-stream') {
|
||||
data = this.xhr.response || this.xhr.responseText;
|
||||
} else {
|
||||
if (!this.supportsBinary) {
|
||||
data = this.xhr.responseText;
|
||||
} else {
|
||||
try {
|
||||
data = String.fromCharCode.apply(null, new Uint8Array(this.xhr.response));
|
||||
} catch (e) {
|
||||
var ui8Arr = new Uint8Array(this.xhr.response);
|
||||
var dataArray = [];
|
||||
for (var idx = 0, length = ui8Arr.length; idx < length; idx++) {
|
||||
dataArray.push(ui8Arr[idx]);
|
||||
}
|
||||
|
||||
data = String.fromCharCode.apply(null, dataArray);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
this.onError(e);
|
||||
}
|
||||
if (null != data) {
|
||||
this.onData(data);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if it has XDomainRequest.
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Request.prototype.hasXDR = function () {
|
||||
return 'undefined' !== typeof global.XDomainRequest && !this.xs && this.enablesXDR;
|
||||
};
|
||||
|
||||
/**
|
||||
* Aborts the request.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Request.prototype.abort = function () {
|
||||
this.cleanup();
|
||||
};
|
||||
|
||||
/**
|
||||
* Aborts pending requests when unloading the window. This is needed to prevent
|
||||
* memory leaks (e.g. when using IE) and to ensure that no spurious error is
|
||||
* emitted.
|
||||
*/
|
||||
|
||||
Request.requestsCount = 0;
|
||||
Request.requests = {};
|
||||
|
||||
if (global.document) {
|
||||
if (global.attachEvent) {
|
||||
global.attachEvent('onunload', unloadHandler);
|
||||
} else if (global.addEventListener) {
|
||||
global.addEventListener('beforeunload', unloadHandler, false);
|
||||
}
|
||||
}
|
||||
|
||||
function unloadHandler () {
|
||||
for (var i in Request.requests) {
|
||||
if (Request.requests.hasOwnProperty(i)) {
|
||||
Request.requests[i].abort();
|
||||
}
|
||||
}
|
||||
}
|
245
node_modules/socketio/node_modules/engine.io-client/lib/transports/polling.js
generated
vendored
Normal file
245
node_modules/socketio/node_modules/engine.io-client/lib/transports/polling.js
generated
vendored
Normal file
@ -0,0 +1,245 @@
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var Transport = require('../transport');
|
||||
var parseqs = require('parseqs');
|
||||
var parser = require('engine.io-parser');
|
||||
var inherit = require('component-inherit');
|
||||
var yeast = require('yeast');
|
||||
var debug = require('debug')('engine.io-client:polling');
|
||||
|
||||
/**
|
||||
* Module exports.
|
||||
*/
|
||||
|
||||
module.exports = Polling;
|
||||
|
||||
/**
|
||||
* Is XHR2 supported?
|
||||
*/
|
||||
|
||||
var hasXHR2 = (function () {
|
||||
var XMLHttpRequest = require('xmlhttprequest-ssl');
|
||||
var xhr = new XMLHttpRequest({ xdomain: false });
|
||||
return null != xhr.responseType;
|
||||
})();
|
||||
|
||||
/**
|
||||
* Polling interface.
|
||||
*
|
||||
* @param {Object} opts
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function Polling (opts) {
|
||||
var forceBase64 = (opts && opts.forceBase64);
|
||||
if (!hasXHR2 || forceBase64) {
|
||||
this.supportsBinary = false;
|
||||
}
|
||||
Transport.call(this, opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* Inherits from Transport.
|
||||
*/
|
||||
|
||||
inherit(Polling, Transport);
|
||||
|
||||
/**
|
||||
* Transport name.
|
||||
*/
|
||||
|
||||
Polling.prototype.name = 'polling';
|
||||
|
||||
/**
|
||||
* Opens the socket (triggers polling). We write a PING message to determine
|
||||
* when the transport is open.
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Polling.prototype.doOpen = function () {
|
||||
this.poll();
|
||||
};
|
||||
|
||||
/**
|
||||
* Pauses polling.
|
||||
*
|
||||
* @param {Function} callback upon buffers are flushed and transport is paused
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Polling.prototype.pause = function (onPause) {
|
||||
var self = this;
|
||||
|
||||
this.readyState = 'pausing';
|
||||
|
||||
function pause () {
|
||||
debug('paused');
|
||||
self.readyState = 'paused';
|
||||
onPause();
|
||||
}
|
||||
|
||||
if (this.polling || !this.writable) {
|
||||
var total = 0;
|
||||
|
||||
if (this.polling) {
|
||||
debug('we are currently polling - waiting to pause');
|
||||
total++;
|
||||
this.once('pollComplete', function () {
|
||||
debug('pre-pause polling complete');
|
||||
--total || pause();
|
||||
});
|
||||
}
|
||||
|
||||
if (!this.writable) {
|
||||
debug('we are currently writing - waiting to pause');
|
||||
total++;
|
||||
this.once('drain', function () {
|
||||
debug('pre-pause writing complete');
|
||||
--total || pause();
|
||||
});
|
||||
}
|
||||
} else {
|
||||
pause();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Starts polling cycle.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Polling.prototype.poll = function () {
|
||||
debug('polling');
|
||||
this.polling = true;
|
||||
this.doPoll();
|
||||
this.emit('poll');
|
||||
};
|
||||
|
||||
/**
|
||||
* Overloads onData to detect payloads.
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Polling.prototype.onData = function (data) {
|
||||
var self = this;
|
||||
debug('polling got data %s', data);
|
||||
var callback = function (packet, index, total) {
|
||||
// if its the first message we consider the transport open
|
||||
if ('opening' === self.readyState) {
|
||||
self.onOpen();
|
||||
}
|
||||
|
||||
// if its a close packet, we close the ongoing requests
|
||||
if ('close' === packet.type) {
|
||||
self.onClose();
|
||||
return false;
|
||||
}
|
||||
|
||||
// otherwise bypass onData and handle the message
|
||||
self.onPacket(packet);
|
||||
};
|
||||
|
||||
// decode payload
|
||||
parser.decodePayload(data, this.socket.binaryType, callback);
|
||||
|
||||
// if an event did not trigger closing
|
||||
if ('closed' !== this.readyState) {
|
||||
// if we got data we're not polling
|
||||
this.polling = false;
|
||||
this.emit('pollComplete');
|
||||
|
||||
if ('open' === this.readyState) {
|
||||
this.poll();
|
||||
} else {
|
||||
debug('ignoring poll - transport state "%s"', this.readyState);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* For polling, send a close packet.
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Polling.prototype.doClose = function () {
|
||||
var self = this;
|
||||
|
||||
function close () {
|
||||
debug('writing close packet');
|
||||
self.write([{ type: 'close' }]);
|
||||
}
|
||||
|
||||
if ('open' === this.readyState) {
|
||||
debug('transport open - closing');
|
||||
close();
|
||||
} else {
|
||||
// in case we're trying to close while
|
||||
// handshaking is in progress (GH-164)
|
||||
debug('transport not open - deferring close');
|
||||
this.once('open', close);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Writes a packets payload.
|
||||
*
|
||||
* @param {Array} data packets
|
||||
* @param {Function} drain callback
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Polling.prototype.write = function (packets) {
|
||||
var self = this;
|
||||
this.writable = false;
|
||||
var callbackfn = function () {
|
||||
self.writable = true;
|
||||
self.emit('drain');
|
||||
};
|
||||
|
||||
parser.encodePayload(packets, this.supportsBinary, function (data) {
|
||||
self.doWrite(data, callbackfn);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Generates uri for connection.
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Polling.prototype.uri = function () {
|
||||
var query = this.query || {};
|
||||
var schema = this.secure ? 'https' : 'http';
|
||||
var port = '';
|
||||
|
||||
// cache busting is forced
|
||||
if (false !== this.timestampRequests) {
|
||||
query[this.timestampParam] = yeast();
|
||||
}
|
||||
|
||||
if (!this.supportsBinary && !query.sid) {
|
||||
query.b64 = 1;
|
||||
}
|
||||
|
||||
query = parseqs.encode(query);
|
||||
|
||||
// avoid port if default for schema
|
||||
if (this.port && (('https' === schema && Number(this.port) !== 443) ||
|
||||
('http' === schema && Number(this.port) !== 80))) {
|
||||
port = ':' + this.port;
|
||||
}
|
||||
|
||||
// prepend ? to query
|
||||
if (query.length) {
|
||||
query = '?' + query;
|
||||
}
|
||||
|
||||
var ipv6 = this.hostname.indexOf(':') !== -1;
|
||||
return schema + '://' + (ipv6 ? '[' + this.hostname + ']' : this.hostname) + port + this.path + query;
|
||||
};
|
285
node_modules/socketio/node_modules/engine.io-client/lib/transports/websocket.js
generated
vendored
Normal file
285
node_modules/socketio/node_modules/engine.io-client/lib/transports/websocket.js
generated
vendored
Normal file
@ -0,0 +1,285 @@
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var Transport = require('../transport');
|
||||
var parser = require('engine.io-parser');
|
||||
var parseqs = require('parseqs');
|
||||
var inherit = require('component-inherit');
|
||||
var yeast = require('yeast');
|
||||
var debug = require('debug')('engine.io-client:websocket');
|
||||
var BrowserWebSocket = global.WebSocket || global.MozWebSocket;
|
||||
var NodeWebSocket;
|
||||
if (typeof window === 'undefined') {
|
||||
try {
|
||||
NodeWebSocket = require('ws');
|
||||
} catch (e) { }
|
||||
}
|
||||
|
||||
/**
|
||||
* Get either the `WebSocket` or `MozWebSocket` globals
|
||||
* in the browser or try to resolve WebSocket-compatible
|
||||
* interface exposed by `ws` for Node-like environment.
|
||||
*/
|
||||
|
||||
var WebSocket = BrowserWebSocket;
|
||||
if (!WebSocket && typeof window === 'undefined') {
|
||||
WebSocket = NodeWebSocket;
|
||||
}
|
||||
|
||||
/**
|
||||
* Module exports.
|
||||
*/
|
||||
|
||||
module.exports = WS;
|
||||
|
||||
/**
|
||||
* WebSocket transport constructor.
|
||||
*
|
||||
* @api {Object} connection options
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function WS (opts) {
|
||||
var forceBase64 = (opts && opts.forceBase64);
|
||||
if (forceBase64) {
|
||||
this.supportsBinary = false;
|
||||
}
|
||||
this.perMessageDeflate = opts.perMessageDeflate;
|
||||
this.usingBrowserWebSocket = BrowserWebSocket && !opts.forceNode;
|
||||
if (!this.usingBrowserWebSocket) {
|
||||
WebSocket = NodeWebSocket;
|
||||
}
|
||||
Transport.call(this, opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* Inherits from Transport.
|
||||
*/
|
||||
|
||||
inherit(WS, Transport);
|
||||
|
||||
/**
|
||||
* Transport name.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
WS.prototype.name = 'websocket';
|
||||
|
||||
/*
|
||||
* WebSockets support binary
|
||||
*/
|
||||
|
||||
WS.prototype.supportsBinary = true;
|
||||
|
||||
/**
|
||||
* Opens socket.
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
WS.prototype.doOpen = function () {
|
||||
if (!this.check()) {
|
||||
// let probe timeout
|
||||
return;
|
||||
}
|
||||
|
||||
var uri = this.uri();
|
||||
var protocols = void (0);
|
||||
var opts = {
|
||||
agent: this.agent,
|
||||
perMessageDeflate: this.perMessageDeflate
|
||||
};
|
||||
|
||||
// SSL options for Node.js client
|
||||
opts.pfx = this.pfx;
|
||||
opts.key = this.key;
|
||||
opts.passphrase = this.passphrase;
|
||||
opts.cert = this.cert;
|
||||
opts.ca = this.ca;
|
||||
opts.ciphers = this.ciphers;
|
||||
opts.rejectUnauthorized = this.rejectUnauthorized;
|
||||
if (this.extraHeaders) {
|
||||
opts.headers = this.extraHeaders;
|
||||
}
|
||||
if (this.localAddress) {
|
||||
opts.localAddress = this.localAddress;
|
||||
}
|
||||
|
||||
try {
|
||||
this.ws = this.usingBrowserWebSocket ? new WebSocket(uri) : new WebSocket(uri, protocols, opts);
|
||||
} catch (err) {
|
||||
return this.emit('error', err);
|
||||
}
|
||||
|
||||
if (this.ws.binaryType === undefined) {
|
||||
this.supportsBinary = false;
|
||||
}
|
||||
|
||||
if (this.ws.supports && this.ws.supports.binary) {
|
||||
this.supportsBinary = true;
|
||||
this.ws.binaryType = 'nodebuffer';
|
||||
} else {
|
||||
this.ws.binaryType = 'arraybuffer';
|
||||
}
|
||||
|
||||
this.addEventListeners();
|
||||
};
|
||||
|
||||
/**
|
||||
* Adds event listeners to the socket
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
WS.prototype.addEventListeners = function () {
|
||||
var self = this;
|
||||
|
||||
this.ws.onopen = function () {
|
||||
self.onOpen();
|
||||
};
|
||||
this.ws.onclose = function () {
|
||||
self.onClose();
|
||||
};
|
||||
this.ws.onmessage = function (ev) {
|
||||
self.onData(ev.data);
|
||||
};
|
||||
this.ws.onerror = function (e) {
|
||||
self.onError('websocket error', e);
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Writes data to socket.
|
||||
*
|
||||
* @param {Array} array of packets.
|
||||
* @api private
|
||||
*/
|
||||
|
||||
WS.prototype.write = function (packets) {
|
||||
var self = this;
|
||||
this.writable = false;
|
||||
|
||||
// encodePacket efficient as it uses WS framing
|
||||
// no need for encodePayload
|
||||
var total = packets.length;
|
||||
for (var i = 0, l = total; i < l; i++) {
|
||||
(function (packet) {
|
||||
parser.encodePacket(packet, self.supportsBinary, function (data) {
|
||||
if (!self.usingBrowserWebSocket) {
|
||||
// always create a new object (GH-437)
|
||||
var opts = {};
|
||||
if (packet.options) {
|
||||
opts.compress = packet.options.compress;
|
||||
}
|
||||
|
||||
if (self.perMessageDeflate) {
|
||||
var len = 'string' === typeof data ? global.Buffer.byteLength(data) : data.length;
|
||||
if (len < self.perMessageDeflate.threshold) {
|
||||
opts.compress = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Sometimes the websocket has already been closed but the browser didn't
|
||||
// have a chance of informing us about it yet, in that case send will
|
||||
// throw an error
|
||||
try {
|
||||
if (self.usingBrowserWebSocket) {
|
||||
// TypeError is thrown when passing the second argument on Safari
|
||||
self.ws.send(data);
|
||||
} else {
|
||||
self.ws.send(data, opts);
|
||||
}
|
||||
} catch (e) {
|
||||
debug('websocket closed before onclose event');
|
||||
}
|
||||
|
||||
--total || done();
|
||||
});
|
||||
})(packets[i]);
|
||||
}
|
||||
|
||||
function done () {
|
||||
self.emit('flush');
|
||||
|
||||
// fake drain
|
||||
// defer to next tick to allow Socket to clear writeBuffer
|
||||
setTimeout(function () {
|
||||
self.writable = true;
|
||||
self.emit('drain');
|
||||
}, 0);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Called upon close
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
WS.prototype.onClose = function () {
|
||||
Transport.prototype.onClose.call(this);
|
||||
};
|
||||
|
||||
/**
|
||||
* Closes socket.
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
WS.prototype.doClose = function () {
|
||||
if (typeof this.ws !== 'undefined') {
|
||||
this.ws.close();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Generates uri for connection.
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
WS.prototype.uri = function () {
|
||||
var query = this.query || {};
|
||||
var schema = this.secure ? 'wss' : 'ws';
|
||||
var port = '';
|
||||
|
||||
// avoid port if default for schema
|
||||
if (this.port && (('wss' === schema && Number(this.port) !== 443) ||
|
||||
('ws' === schema && Number(this.port) !== 80))) {
|
||||
port = ':' + this.port;
|
||||
}
|
||||
|
||||
// append timestamp to URI
|
||||
if (this.timestampRequests) {
|
||||
query[this.timestampParam] = yeast();
|
||||
}
|
||||
|
||||
// communicate binary support capabilities
|
||||
if (!this.supportsBinary) {
|
||||
query.b64 = 1;
|
||||
}
|
||||
|
||||
query = parseqs.encode(query);
|
||||
|
||||
// prepend ? to query
|
||||
if (query.length) {
|
||||
query = '?' + query;
|
||||
}
|
||||
|
||||
var ipv6 = this.hostname.indexOf(':') !== -1;
|
||||
return schema + '://' + (ipv6 ? '[' + this.hostname + ']' : this.hostname) + port + this.path + query;
|
||||
};
|
||||
|
||||
/**
|
||||
* Feature detection for WebSocket.
|
||||
*
|
||||
* @return {Boolean} whether this transport is available.
|
||||
* @api public
|
||||
*/
|
||||
|
||||
WS.prototype.check = function () {
|
||||
return !!WebSocket && !('__initialize' in WebSocket && this.name === WS.prototype.name);
|
||||
};
|
37
node_modules/socketio/node_modules/engine.io-client/lib/xmlhttprequest.js
generated
vendored
Normal file
37
node_modules/socketio/node_modules/engine.io-client/lib/xmlhttprequest.js
generated
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
// browser shim for xmlhttprequest module
|
||||
|
||||
var hasCORS = require('has-cors');
|
||||
|
||||
module.exports = function (opts) {
|
||||
var xdomain = opts.xdomain;
|
||||
|
||||
// scheme must be same when usign XDomainRequest
|
||||
// http://blogs.msdn.com/b/ieinternals/archive/2010/05/13/xdomainrequest-restrictions-limitations-and-workarounds.aspx
|
||||
var xscheme = opts.xscheme;
|
||||
|
||||
// XDomainRequest has a flow of not sending cookie, therefore it should be disabled as a default.
|
||||
// https://github.com/Automattic/engine.io-client/pull/217
|
||||
var enablesXDR = opts.enablesXDR;
|
||||
|
||||
// XMLHttpRequest can be disabled on IE
|
||||
try {
|
||||
if ('undefined' !== typeof XMLHttpRequest && (!xdomain || hasCORS)) {
|
||||
return new XMLHttpRequest();
|
||||
}
|
||||
} catch (e) { }
|
||||
|
||||
// Use XDomainRequest for IE8 if enablesXDR is true
|
||||
// because loading bar keeps flashing when using jsonp-polling
|
||||
// https://github.com/yujiosaka/socke.io-ie8-loading-example
|
||||
try {
|
||||
if ('undefined' !== typeof XDomainRequest && !xscheme && enablesXDR) {
|
||||
return new XDomainRequest();
|
||||
}
|
||||
} catch (e) { }
|
||||
|
||||
if (!xdomain) {
|
||||
try {
|
||||
return new global[['Active'].concat('Object').join('X')]('Microsoft.XMLHTTP');
|
||||
} catch (e) { }
|
||||
}
|
||||
};
|
68
node_modules/socketio/node_modules/engine.io-client/node_modules/component-emitter/History.md
generated
vendored
Normal file
68
node_modules/socketio/node_modules/engine.io-client/node_modules/component-emitter/History.md
generated
vendored
Normal file
@ -0,0 +1,68 @@
|
||||
|
||||
1.2.1 / 2016-04-18
|
||||
==================
|
||||
|
||||
* enable client side use
|
||||
|
||||
1.2.0 / 2014-02-12
|
||||
==================
|
||||
|
||||
* prefix events with `$` to support object prototype method names
|
||||
|
||||
1.1.3 / 2014-06-20
|
||||
==================
|
||||
|
||||
* republish for npm
|
||||
* add LICENSE file
|
||||
|
||||
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
|
24
node_modules/socketio/node_modules/engine.io-client/node_modules/component-emitter/LICENSE
generated
vendored
Normal file
24
node_modules/socketio/node_modules/engine.io-client/node_modules/component-emitter/LICENSE
generated
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2014 Component contributors <dev@component.io>
|
||||
|
||||
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.
|
74
node_modules/socketio/node_modules/engine.io-client/node_modules/component-emitter/Readme.md
generated
vendored
Normal file
74
node_modules/socketio/node_modules/engine.io-client/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
|
163
node_modules/socketio/node_modules/engine.io-client/node_modules/component-emitter/index.js
generated
vendored
Normal file
163
node_modules/socketio/node_modules/engine.io-client/node_modules/component-emitter/index.js
generated
vendored
Normal file
@ -0,0 +1,163 @@
|
||||
|
||||
/**
|
||||
* Expose `Emitter`.
|
||||
*/
|
||||
|
||||
if (typeof module !== 'undefined') {
|
||||
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){
|
||||
function on() {
|
||||
this.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;
|
||||
};
|
24
node_modules/socketio/node_modules/engine.io-client/node_modules/component-emitter/package.json
generated
vendored
Normal file
24
node_modules/socketio/node_modules/engine.io-client/node_modules/component-emitter/package.json
generated
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
{
|
||||
"name": "component-emitter",
|
||||
"description": "Event emitter",
|
||||
"version": "1.2.1",
|
||||
"license": "MIT",
|
||||
"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"
|
||||
},
|
||||
"files": ["index.js", "LICENSE"]
|
||||
}
|
83
node_modules/socketio/node_modules/engine.io-client/package.json
generated
vendored
Normal file
83
node_modules/socketio/node_modules/engine.io-client/package.json
generated
vendored
Normal file
@ -0,0 +1,83 @@
|
||||
{
|
||||
"name": "engine.io-client",
|
||||
"description": "Client for the realtime Engine",
|
||||
"license": "MIT",
|
||||
"version": "1.8.6",
|
||||
"homepage": "https://github.com/socketio/engine.io-client",
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Guillermo Rauch",
|
||||
"email": "rauchg@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Vladimir Dronnikov",
|
||||
"email": "dronnikov@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Christoph Dorn",
|
||||
"web": "https://github.com/cadorn"
|
||||
},
|
||||
{
|
||||
"name": "Mark Mokryn",
|
||||
"email": "mokesmokes@gmail.com"
|
||||
}
|
||||
],
|
||||
"dependencies": {
|
||||
"component-emitter": "1.2.1",
|
||||
"component-inherit": "0.0.3",
|
||||
"debug": "2.3.3",
|
||||
"engine.io-parser": "1.3.2",
|
||||
"has-cors": "1.1.0",
|
||||
"indexof": "0.0.1",
|
||||
"parsejson": "0.0.3",
|
||||
"parseqs": "0.0.5",
|
||||
"parseuri": "0.0.5",
|
||||
"ws": "~1.1.5",
|
||||
"xmlhttprequest-ssl": "1.6.3",
|
||||
"yeast": "0.1.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-core": "6.4.5",
|
||||
"babel-eslint": "4.1.7",
|
||||
"babel-loader": "6.2.1",
|
||||
"babel-preset-es2015": "6.3.13",
|
||||
"blob": "0.0.4",
|
||||
"concat-stream": "1.4.6",
|
||||
"del": "2.2.0",
|
||||
"derequire": "1.2.0",
|
||||
"eslint-config-standard": "4.4.0",
|
||||
"eslint-plugin-standard": "1.3.1",
|
||||
"engine.io": "1.8.5",
|
||||
"expect.js": "0.2.0",
|
||||
"express": "3.4.8",
|
||||
"gulp": "3.9.0",
|
||||
"gulp-eslint": "1.1.1",
|
||||
"gulp-file": "0.2.0",
|
||||
"gulp-istanbul": "0.10.3",
|
||||
"gulp-mocha": "2.2.0",
|
||||
"gulp-task-listing": "1.0.1",
|
||||
"istanbul": "0.2.3",
|
||||
"mocha": "1.16.2",
|
||||
"webpack": "1.12.12",
|
||||
"webpack-stream": "3.1.0",
|
||||
"zuul": "3.11.0",
|
||||
"zuul-builder-webpack": "1.1.0",
|
||||
"zuul-ngrok": "4.0.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "gulp test"
|
||||
},
|
||||
"browser": {
|
||||
"ws": false,
|
||||
"xmlhttprequest-ssl": "./lib/xmlhttprequest.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/socketio/engine.io-client.git"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"lib/",
|
||||
"engine.io.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)
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user