Project files
This commit is contained in:
6
receipeServer/frontend_old/node_modules/sockjs/COPYING
generated
vendored
Normal file
6
receipeServer/frontend_old/node_modules/sockjs/COPYING
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
Parts of the code are derived from various open source projects.
|
||||
|
||||
For code derived from Socket.IO by Guillermo Rauch see
|
||||
https://github.com/LearnBoost/socket.io/tree/0.6.17#readme.
|
||||
|
||||
All other code is released on MIT license, see LICENSE.
|
||||
291
receipeServer/frontend_old/node_modules/sockjs/Changelog
generated
vendored
Normal file
291
receipeServer/frontend_old/node_modules/sockjs/Changelog
generated
vendored
Normal file
@@ -0,0 +1,291 @@
|
||||
0.3.24
|
||||
======
|
||||
* Remove excess file from npm package
|
||||
|
||||
0.3.23
|
||||
======
|
||||
* Fix `uuid` usage
|
||||
|
||||
0.3.22
|
||||
======
|
||||
* Update `uuid`
|
||||
|
||||
0.3.21
|
||||
======
|
||||
* Update `faye-websocket` and `websocket-driver` to address DDoS vulnerability #275
|
||||
|
||||
0.3.20
|
||||
======
|
||||
* Updated `node-uuid` and `coffeescript`
|
||||
* Exclude `examples`, `tests`, and `Makefile` from npm package
|
||||
* Update examples to use latest jQuery and sockjs-client #271
|
||||
* Don't call `res.end` in `writeHead` #266
|
||||
* Pin `websocket-driver` as later versions cause some tests from `sockjs-protocol` to fail
|
||||
|
||||
0.3.19
|
||||
======
|
||||
|
||||
* Update `node-uuid` version #224
|
||||
* Add `disable_cors` option to prevent CORS headers from being added to responses #218
|
||||
* Add `dnt` header to whitelist #212
|
||||
* Add `x-forwarded-host` and `x-forwarded-port` headers to whitelist #208
|
||||
* Update `sockjs_url` default to latest 1.x target #223
|
||||
* Updated hapi.js example #216
|
||||
|
||||
0.3.18
|
||||
======
|
||||
|
||||
* Change to using `res.statusCode` instead of manual parsing of `res._header` #213
|
||||
* Update sockjs-protocol filename in README #203
|
||||
|
||||
0.3.17
|
||||
======
|
||||
|
||||
* Fix usage of undefined `session` in `heartbeat_timeout` #179
|
||||
|
||||
0.3.16
|
||||
======
|
||||
|
||||
* Fix CORS response for null origin #177
|
||||
* Add websocket ping-pong and close if no response #129, #162, #169
|
||||
* Update sockjs-client version in examples #182
|
||||
* Add koa example #180
|
||||
* Disable raw websocket endpoint when websocket = false #183
|
||||
* Upgrade to faye-websocket 0.10.0 and use proper close code
|
||||
* When connection is aborted, don't delay the teardown
|
||||
* Forward additional headers #188
|
||||
* Add `no-transform` to Cache-Control headers #189
|
||||
* Update documentation about heartbeats #192
|
||||
|
||||
|
||||
0.3.15
|
||||
======
|
||||
|
||||
* Remove usage of naked '@' function params to be compatible with coffeescript 1.9.0 #175
|
||||
|
||||
0.3.14
|
||||
======
|
||||
|
||||
* Re-publish to npm because of build issue in 0.3.13
|
||||
|
||||
0.3.13
|
||||
======
|
||||
|
||||
* Upgrade faye-websocket to 0.9.3 to fix #171
|
||||
|
||||
0.3.12
|
||||
======
|
||||
|
||||
* Allow Faye socket constructor options to be passed with
|
||||
faye_server_options option to createServer
|
||||
* Fix websocket bad json tests
|
||||
* Upgrade Faye to allow 0.9.*
|
||||
|
||||
0.3.11
|
||||
======
|
||||
|
||||
* #133 - only delay disconnect on non-websocket transports
|
||||
* Upgrade Faye to 0.8.0
|
||||
|
||||
0.3.10
|
||||
======
|
||||
|
||||
* #168 - Add CORS headers for eventsource
|
||||
* #158 - schedule heartbeat timer even if send_buffer is not empty
|
||||
* #96 - remove rbytes dependency
|
||||
* #83 - update documentation for prefix
|
||||
* #163 - add protection to JSON for SWF exploit
|
||||
* #104 - delete unused parameters in code
|
||||
* #106 - update CDN urls
|
||||
* #79 - Don't remove stream listeners until after end so 'close' event is heard
|
||||
* Get rid of need for _sockjs_onload global variable
|
||||
* Use Faye for websocket request validation
|
||||
* Upgrade Faye to 0.7.3
|
||||
* Upgrade node-uuid to 1.4.1
|
||||
|
||||
0.3.9
|
||||
=====
|
||||
|
||||
* #130 - Set Vary: Origin on CORS requests
|
||||
* Upgrade Faye to 0.7.2 from 0.7.0
|
||||
|
||||
|
||||
0.3.8
|
||||
=====
|
||||
|
||||
* #118 - Allow servers to specify a base URL in /info
|
||||
* #131 - Don't look up session id undefined
|
||||
* #124 - Small grammar updates for ReadMe
|
||||
* Upgrade Faye to 0.7.0 from 0.4.0
|
||||
|
||||
0.3.7
|
||||
=====
|
||||
|
||||
* Expose "protocol" on raw websocket connection instance, correctly
|
||||
|
||||
0.3.6
|
||||
=====
|
||||
|
||||
* When the server closes a connection, make sure the send buffer still
|
||||
gets flushed.
|
||||
* Expose "protocol" on raw websocket connection instance
|
||||
* #105, #109, #113 - expose 'host', 'user-agent', and 'accept-language'
|
||||
headers
|
||||
* Serve SockJS over https CDN by default
|
||||
* Upgrade Faye to 0.4.4 from 0.4.0
|
||||
|
||||
0.3.5
|
||||
=====
|
||||
|
||||
* #103 - connection.protocol might have been empty on some rare
|
||||
occasions.
|
||||
* #99 - faye-websocket was leaking sockets in "closed" state
|
||||
when dealing with rfc websockets
|
||||
|
||||
|
||||
0.3.4
|
||||
=====
|
||||
|
||||
* #73 - apparently 'package' is a reserved keyword (use 'pkg' instead)
|
||||
* #93 - Coffescript can leak a variable when the same name is used
|
||||
in catch statement. Let's always use 'x' as the variable in catch.
|
||||
* #76 - decorateConnection could throw an error if remote connection
|
||||
was closed before setup was complete
|
||||
* #90 - Fix "TypeError: 'addListener'" exception (via @pl).
|
||||
* remove 'optionalDependencies' section from package.json,
|
||||
'rbytes' was always optional.
|
||||
* #91 - Fix rare null exception.
|
||||
|
||||
|
||||
0.3.3
|
||||
=====
|
||||
|
||||
* sockjs/sockjs-protocol#56, #88 Fix for iOS 6 caching POSTs
|
||||
|
||||
|
||||
0.3.1
|
||||
=====
|
||||
|
||||
* #58 - websocket transport emitted an array instead of a string
|
||||
during onmessage event.
|
||||
* Running under node.js 0.7 caused infinite recursion (Stephan Kochen)
|
||||
* #59 - restrict characters allowed in callback parameter
|
||||
* Updated readme - rbytes package is optional
|
||||
* Updated readme WRT deployments on heroku
|
||||
* Add minimalistic license block to every source file.
|
||||
|
||||
|
||||
0.3.0
|
||||
=====
|
||||
|
||||
* Sending JSESSIONID cookie is now *disabled* by default.
|
||||
* sockjs/sockjs-protocol#46 - introduce new service
|
||||
required for protocol tests "/cookie_needed_echo"
|
||||
* Initial work towards better integration with
|
||||
"connect" (Stephan Kochen). See discusion:
|
||||
https://github.com/senchalabs/connect/pull/506
|
||||
* More documentation about the Cookie and Origin headers.
|
||||
* #51 - expose "readyState" on connection instance
|
||||
* #53 - expose "protocol" on connection instance
|
||||
* #52 - Some protocols may not emit 'close' event with IE.
|
||||
* sockjs/sockjs-client#49 - Support 'null' origin - aka: allow SockJS
|
||||
client to be served from file:// paths.
|
||||
|
||||
|
||||
0.2.1
|
||||
=====
|
||||
|
||||
* Bumped "faye-websocket" dependency to 0.4. Updated
|
||||
code to take advantage of introduced changes.
|
||||
* Pinned "node-static" and bumped "node-uuid" dependencies.
|
||||
* Removed "Origin" header list of headers exposed to the user.
|
||||
This header is not really meaningful in sockjs context.
|
||||
* Header "Access-Control-Allow-Methods" was misspelled.
|
||||
|
||||
|
||||
0.2.0
|
||||
=====
|
||||
|
||||
* #36, #3 - Replace a custom WebSocket server implementation
|
||||
with faye-websocket-node.
|
||||
* Multiple changes to support SockJS-protocol 0.2.
|
||||
* The session is now closed on network errors immediately
|
||||
(instead of waiting 5 seconds)
|
||||
* Raw websocket interface available - to make it easier
|
||||
to write command line SockJS clients.
|
||||
* Support '/info' url.
|
||||
* The test server got moved from SockJS-client to SockJS-node.
|
||||
* Dropped deprecated Server API (use createServer method instead).
|
||||
* Option `websocket` is now used instead of `disabled_transports`.
|
||||
|
||||
|
||||
0.1.2
|
||||
=====
|
||||
|
||||
* #27 - Allow all unicode characters to be send over SockJS.
|
||||
* #14 - Make it possible to customize JSESSIONID cookie logic.
|
||||
|
||||
|
||||
0.1.1
|
||||
=====
|
||||
|
||||
* #32 Expose various request headers on connection.
|
||||
* #30 Expose request path on connection.
|
||||
|
||||
|
||||
0.1.0
|
||||
=====
|
||||
|
||||
* The API changed, there is now an idiomatic API, modelled on node.js
|
||||
Stream API. The old API is deprecated and there is a dummy wrapper
|
||||
that emulates it. Please do upgrade to the new idiomatic API.
|
||||
* #22 Initial support for hybi13 (stephank)
|
||||
* New options accepted by the `Server` constructor: `log`,
|
||||
`heartbeat_delay` and `disconnect_delay`.
|
||||
* SockJS is now not able to send rich data structures - all data
|
||||
passed to `write` is converted to a string.
|
||||
* #23 `Connection.remoteAddress` property introduced (Stéphan Kochen)
|
||||
* Loads of small changes in order to adhere to protocol spec.
|
||||
|
||||
|
||||
0.0.5
|
||||
=====
|
||||
|
||||
* #20: `npm submodule sockjs` didn't work due to outdated github
|
||||
path.
|
||||
|
||||
|
||||
0.0.4
|
||||
=====
|
||||
|
||||
* Support for htmlfile transport, used by IE in a deployment
|
||||
dependent on cookies.
|
||||
* Added /chunking_test API, used to detect support for HTTP chunking
|
||||
on client side.
|
||||
* Unified code logic for all the chunking transports - the same code
|
||||
is reused for polling versions.
|
||||
* All the chunking transports are closed by the server after 128K was
|
||||
send, in order to force client to GC and reconnect.
|
||||
* Don't distribute source coffeescript with npm.
|
||||
* Minor fixes in websocket code.
|
||||
* Dropped jQuery dependency.
|
||||
* Unicode encoding could been garbled during XHR upload.
|
||||
* Other minor fixes.
|
||||
|
||||
|
||||
0.0.3
|
||||
======
|
||||
|
||||
* EventSource transport didn't emit 'close' event.
|
||||
|
||||
|
||||
0.0.2
|
||||
=====
|
||||
|
||||
* By default set JSESSIONID cookie, useful for load balancing.
|
||||
|
||||
|
||||
0.0.1
|
||||
=====
|
||||
|
||||
* Initial release.
|
||||
21
receipeServer/frontend_old/node_modules/sockjs/LICENSE
generated
vendored
Normal file
21
receipeServer/frontend_old/node_modules/sockjs/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (C) 2011 VMware, 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.
|
||||
450
receipeServer/frontend_old/node_modules/sockjs/README.md
generated
vendored
Normal file
450
receipeServer/frontend_old/node_modules/sockjs/README.md
generated
vendored
Normal file
@@ -0,0 +1,450 @@
|
||||
[](http://badge.fury.io/js/sockjs)
|
||||
|
||||
SockJS family:
|
||||
|
||||
* [SockJS-client](https://github.com/sockjs/sockjs-client) JavaScript client library
|
||||
* [SockJS-node](https://github.com/sockjs/sockjs-node) Node.js server
|
||||
* [SockJS-erlang](https://github.com/sockjs/sockjs-erlang) Erlang server
|
||||
* [SockJS-tornado](https://github.com/MrJoes/sockjs-tornado) Python/Tornado server
|
||||
* [vert.x](https://github.com/eclipse/vert.x) Java/vert.x server
|
||||
|
||||
Work in progress:
|
||||
|
||||
* [SockJS-ruby](https://github.com/nyarly/sockjs-ruby)
|
||||
* [SockJS-netty](https://github.com/cgbystrom/sockjs-netty)
|
||||
* [SockJS-gevent](https://github.com/sdiehl/sockjs-gevent) ([and a fork](https://github.com/njoyce/sockjs-gevent))
|
||||
* [pyramid-SockJS](https://github.com/fafhrd91/pyramid_sockjs)
|
||||
* [wildcloud-websockets](https://github.com/wildcloud/wildcloud-websockets)
|
||||
* [SockJS-cyclone](https://github.com/flaviogrossi/sockjs-cyclone)
|
||||
* [SockJS-twisted](https://github.com/Fugiman/sockjs-twisted/)
|
||||
* [wai-SockJS](https://github.com/Palmik/wai-sockjs)
|
||||
* [SockJS-perl](https://github.com/vti/sockjs-perl)
|
||||
* [SockJS-go](https://github.com/igm/sockjs-go/)
|
||||
|
||||
What is SockJS?
|
||||
===============
|
||||
|
||||
SockJS is a JavaScript library (for browsers) that provides a WebSocket-like
|
||||
object. SockJS gives you a coherent, cross-browser, Javascript API
|
||||
which creates a low latency, full duplex, cross-domain communication
|
||||
channel between the browser and the web server, with WebSockets or without.
|
||||
This necessitates the use of a server, which this is one version of, for Node.js.
|
||||
|
||||
|
||||
SockJS-node server
|
||||
==================
|
||||
|
||||
SockJS-node is a Node.js server side counterpart of
|
||||
[SockJS-client browser library](https://github.com/sockjs/sockjs-client)
|
||||
written in CoffeeScript.
|
||||
|
||||
To install `sockjs-node` run:
|
||||
|
||||
npm install sockjs
|
||||
|
||||
A simplified echo SockJS server could look more or less like:
|
||||
|
||||
```javascript
|
||||
var http = require('http');
|
||||
var sockjs = require('sockjs');
|
||||
|
||||
var echo = sockjs.createServer();
|
||||
echo.on('connection', function(conn) {
|
||||
conn.on('data', function(message) {
|
||||
conn.write(message);
|
||||
});
|
||||
conn.on('close', function() {});
|
||||
});
|
||||
|
||||
var server = http.createServer();
|
||||
echo.installHandlers(server, {prefix:'/echo'});
|
||||
server.listen(9999, '0.0.0.0');
|
||||
```
|
||||
|
||||
(Take look at
|
||||
[examples](https://github.com/sockjs/sockjs-node/tree/master/examples/echo)
|
||||
directory for a complete version.)
|
||||
|
||||
Subscribe to
|
||||
[SockJS mailing list](https://groups.google.com/forum/#!forum/sockjs) for
|
||||
discussions and support.
|
||||
|
||||
|
||||
SockJS-node API
|
||||
---------------
|
||||
|
||||
The API design is based on common Node APIs like the
|
||||
[Streams API](http://nodejs.org/docs/v0.5.8/api/streams.html) or the
|
||||
[Http.Server API](http://nodejs.org/docs/v0.5.8/api/http.html#http.Server).
|
||||
|
||||
### Server class
|
||||
|
||||
SockJS module is generating a `Server` class, similar to
|
||||
[Node.js http.createServer](http://nodejs.org/docs/v0.5.8/api/http.html#http.createServer)
|
||||
module.
|
||||
|
||||
```javascript
|
||||
var sockjs_server = sockjs.createServer(options);
|
||||
```
|
||||
|
||||
Where `options` is a hash which can contain:
|
||||
|
||||
<dl>
|
||||
<dt>sockjs_url (string)</dt>
|
||||
<dd>Transports which don't support cross-domain communication natively
|
||||
('eventsource' to name one) use an iframe trick. A simple page is
|
||||
served from the SockJS server (using its foreign domain) and is
|
||||
placed in an invisible iframe. Code run from this iframe doesn't
|
||||
need to worry about cross-domain issues, as it's being run from
|
||||
domain local to the SockJS server. This iframe also does need to
|
||||
load SockJS javascript client library, and this option lets you specify
|
||||
its url (if you're unsure, point it to
|
||||
<a href="https://cdn.jsdelivr.net/npm/sockjs-client@1/dist/sockjs.min.js">
|
||||
the latest minified SockJS client release</a>, this is the default).
|
||||
You must explicitly specify this url on the server side for security
|
||||
reasons - we don't want the possibility of running any foreign
|
||||
javascript within the SockJS domain (aka cross site scripting attack).
|
||||
Also, sockjs javascript library is probably already cached by the
|
||||
browser - it makes sense to reuse the sockjs url you're using in
|
||||
normally.</dd>
|
||||
|
||||
<dt>prefix (string regex)</dt>
|
||||
<dd>A url prefix for the server. All http requests which paths begins
|
||||
with selected prefix will be handled by SockJS. All other requests
|
||||
will be passed through, to previously registered handlers.</dd>
|
||||
|
||||
<dt>response_limit (integer)</dt>
|
||||
<dd>Most streaming transports save responses on the client side and
|
||||
don't free memory used by delivered messages. Such transports need
|
||||
to be garbage-collected once in a while. `response_limit` sets
|
||||
a minimum number of bytes that can be send over a single http streaming
|
||||
request before it will be closed. After that client needs to open
|
||||
new request. Setting this value to one effectively disables
|
||||
streaming and will make streaming transports to behave like polling
|
||||
transports. The default value is 128K.</dd>
|
||||
|
||||
<dt>websocket (boolean)</dt>
|
||||
<dd>Some load balancers don't support websockets. This option can be used
|
||||
to disable websockets support by the server. By default websockets are
|
||||
enabled.</dd>
|
||||
|
||||
<dt>jsessionid (boolean or function)</dt>
|
||||
<dd>Some hosting providers enable sticky sessions only to requests that
|
||||
have JSESSIONID cookie set. This setting controls if the server should
|
||||
set this cookie to a dummy value. By default setting JSESSIONID cookie
|
||||
is disabled. More sophisticated behaviour can be achieved by supplying
|
||||
a function.</dd>
|
||||
|
||||
<dt>log (function(severity, message))</dt>
|
||||
<dd>It's quite useful, especially for debugging, to see some messages
|
||||
printed by a SockJS-node library. This is done using this `log`
|
||||
function, which is by default set to `console.log`. If this
|
||||
behaviour annoys you for some reason, override `log` setting with a
|
||||
custom handler. The following `severities` are used: `debug`
|
||||
(miscellaneous logs), `info` (requests logs), `error` (serious
|
||||
errors, consider filing an issue).</dd>
|
||||
|
||||
<dt>heartbeat_delay (milliseconds)</dt>
|
||||
<dd>In order to keep proxies and load balancers from closing long
|
||||
running http requests we need to pretend that the connection is
|
||||
active and send a heartbeat packet once in a while. This setting
|
||||
controls how often this is done. By default a heartbeat packet is
|
||||
sent every 25 seconds. </dd>
|
||||
|
||||
<dt>disconnect_delay (milliseconds)</dt>
|
||||
<dd>The server sends a `close` event when a client receiving
|
||||
connection have not been seen for a while. This delay is configured
|
||||
by this setting. By default the `close` event will be emitted when a
|
||||
receiving connection wasn't seen for 5 seconds. </dd>
|
||||
|
||||
<dt>disable_cors (boolean)</dt>
|
||||
<dd>Enabling this option will prevent
|
||||
<a href="https://en.wikipedia.org/wiki/Cross-origin_resource_sharing">CORS</a>
|
||||
headers from being included in the HTTP response. Can be used when the
|
||||
sockjs client is known to be connecting from the same origin as the
|
||||
sockjs server.</dd>
|
||||
</dl>
|
||||
|
||||
|
||||
### Server instance
|
||||
|
||||
Once you have create `Server` instance you can hook it to the
|
||||
[http.Server instance](http://nodejs.org/docs/v0.5.8/api/http.html#http.createServer).
|
||||
|
||||
```javascript
|
||||
var http_server = http.createServer();
|
||||
sockjs_server.installHandlers(http_server, options);
|
||||
http_server.listen(...);
|
||||
```
|
||||
|
||||
Where `options` can overshadow options given when creating `Server`
|
||||
instance.
|
||||
|
||||
`Server` instance is an
|
||||
[EventEmitter](http://nodejs.org/docs/v0.4.10/api/events.html#events.EventEmitter),
|
||||
and emits following event:
|
||||
|
||||
<dl>
|
||||
<dt>Event: connection (connection)</dt>
|
||||
<dd>A new connection has been successfully opened.</dd>
|
||||
</dl>
|
||||
|
||||
All http requests that don't go under the path selected by `prefix`
|
||||
will remain unanswered and will be passed to previously registered
|
||||
handlers. You must install your custom http handlers before calling
|
||||
`installHandlers`.
|
||||
|
||||
### Connection instance
|
||||
|
||||
A `Connection` instance supports
|
||||
[Node Stream API](http://nodejs.org/docs/v0.5.8/api/streams.html) and
|
||||
has following methods and properties:
|
||||
|
||||
<dl>
|
||||
<dt>Property: readable (boolean)</dt>
|
||||
<dd>Is the stream readable?</dd>
|
||||
|
||||
<dt>Property: writable (boolean)</dt>
|
||||
<dd>Is the stream writable?</dd>
|
||||
|
||||
<dt>Property: remoteAddress (string)</dt>
|
||||
<dd>Last known IP address of the client.</dd>
|
||||
|
||||
<dt>Property: remotePort (number)</dt>
|
||||
<dd>Last known port number of the client.</dd>
|
||||
|
||||
<dt>Property: address (object)</dt>
|
||||
<dd>Hash with 'address' and 'port' fields.</dd>
|
||||
|
||||
<dt>Property: headers (object)</dt>
|
||||
<dd>Hash containing various headers copied from last receiving request
|
||||
on that connection. Exposed headers include: `origin`, `referer`
|
||||
and `x-forwarded-for` (and friends). We explicitly do not grant
|
||||
access to `cookie` header, as using it may easily lead to security
|
||||
issues (for details read the section "Authorisation").</dd>
|
||||
|
||||
<dt>Property: url (string)</dt>
|
||||
<dd><a href="http://nodejs.org/docs/v0.4.10/api/http.html#request.url">Url</a>
|
||||
property copied from last request.</dd>
|
||||
|
||||
<dt>Property: pathname (string)</dt>
|
||||
<dd>`pathname` from parsed url, for convenience.</dd>
|
||||
|
||||
<dt>Property: prefix (string)</dt>
|
||||
<dd>Prefix of the url on which the request was handled.</dd>
|
||||
|
||||
<dt>Property: protocol (string)</dt>
|
||||
<dd>Protocol used by the connection. Keep in mind that some protocols
|
||||
are indistinguishable - for example "xhr-polling" and "xdr-polling".</dd>
|
||||
|
||||
<dt>Property: readyState (integer)</dt>
|
||||
<dd>Current state of the connection:
|
||||
0-connecting, 1-open, 2-closing, 3-closed.</dd>
|
||||
|
||||
<dt>write(message)</dt>
|
||||
<dd>Sends a message over opened connection. A message must be a
|
||||
non-empty string. It's illegal to send a message after the connection was
|
||||
closed (either after 'close' or 'end' method or 'close' event).</dd>
|
||||
|
||||
<dt>close([code], [reason])</dt>
|
||||
<dd>Asks the remote client to disconnect. 'code' and 'reason'
|
||||
parameters are optional and can be used to share the reason of
|
||||
disconnection.</dd>
|
||||
|
||||
<dt>end()</dt>
|
||||
<dd>Asks the remote client to disconnect with default 'code' and
|
||||
'reason' values.</dd>
|
||||
|
||||
</dl>
|
||||
|
||||
A `Connection` instance emits the following events:
|
||||
|
||||
<dl>
|
||||
<dt>Event: data (message)</dt>
|
||||
<dd>A message arrived on the connection. Message is a unicode
|
||||
string.</dd>
|
||||
|
||||
<dt>Event: close ()</dt>
|
||||
<dd>Connection was closed. This event is triggered exactly once for
|
||||
every connection.</dd>
|
||||
</dl>
|
||||
|
||||
For example:
|
||||
|
||||
```javascript
|
||||
sockjs_server.on('connection', function(conn) {
|
||||
console.log('connection' + conn);
|
||||
conn.on('close', function() {
|
||||
console.log('close ' + conn);
|
||||
});
|
||||
conn.on('data', function(message) {
|
||||
console.log('message ' + conn,
|
||||
message);
|
||||
});
|
||||
});
|
||||
```
|
||||
|
||||
### Footnote
|
||||
|
||||
A fully working echo server does need a bit more boilerplate (to
|
||||
handle requests unanswered by SockJS), see the
|
||||
[`echo` example](https://github.com/sockjs/sockjs-node/tree/master/examples/echo)
|
||||
for a complete code.
|
||||
|
||||
### Examples
|
||||
|
||||
If you want to see samples of running code, take a look at:
|
||||
|
||||
* [./examples/echo](https://github.com/sockjs/sockjs-node/tree/master/examples/echo)
|
||||
directory, which contains a full example of a echo server.
|
||||
* [./examples/test_server](https://github.com/sockjs/sockjs-node/tree/master/examples/test_server) a standard SockJS test server.
|
||||
|
||||
|
||||
Connecting to SockJS-node without the client
|
||||
--------------------------------------------
|
||||
|
||||
Although the main point of SockJS it to enable browser-to-server
|
||||
connectivity, it is possible to connect to SockJS from an external
|
||||
application. Any SockJS server complying with 0.3 protocol does
|
||||
support a raw WebSocket url. The raw WebSocket url for the test server
|
||||
looks like:
|
||||
|
||||
* ws://localhost:8081/echo/websocket
|
||||
|
||||
You can connect any WebSocket RFC 6455 compliant WebSocket client to
|
||||
this url. This can be a command line client, external application,
|
||||
third party code or even a browser (though I don't know why you would
|
||||
want to do so).
|
||||
|
||||
Note: This endpoint will *not send any heartbeat packets*.
|
||||
|
||||
|
||||
Deployment and load balancing
|
||||
-----------------------------
|
||||
|
||||
There are two issues that need to be considered when planning a
|
||||
non-trivial SockJS-node deployment: WebSocket-compatible load balancer
|
||||
and sticky sessions (aka session affinity).
|
||||
|
||||
### WebSocket compatible load balancer
|
||||
|
||||
Often WebSockets don't play nicely with proxies and load balancers.
|
||||
Deploying a SockJS server behind Nginx or Apache could be painful.
|
||||
|
||||
Fortunately recent versions of an excellent load balancer
|
||||
[HAProxy](http://haproxy.1wt.eu/) are able to proxy WebSocket
|
||||
connections. We propose to put HAProxy as a front line load balancer
|
||||
and use it to split SockJS traffic from normal HTTP data. Take a look
|
||||
at the sample
|
||||
[SockJS HAProxy configuration](https://github.com/sockjs/sockjs-node/blob/master/examples/haproxy.cfg).
|
||||
|
||||
The config also shows how to use HAproxy balancing to split traffic
|
||||
between multiple Node.js servers. You can also do balancing using dns
|
||||
names.
|
||||
|
||||
### Sticky sessions
|
||||
|
||||
If you plan deploying more than one SockJS server, you must make sure
|
||||
that all HTTP requests for a single session will hit the same server.
|
||||
SockJS has two mechanisms that can be useful to achieve that:
|
||||
|
||||
* Urls are prefixed with server and session id numbers, like:
|
||||
`/resource/<server_number>/<session_id>/transport`. This is
|
||||
useful for load balancers that support prefix-based affinity
|
||||
(HAProxy does).
|
||||
* `JSESSIONID` cookie is being set by SockJS-node. Many load
|
||||
balancers turn on sticky sessions if that cookie is set. This
|
||||
technique is derived from Java applications, where sticky sessions
|
||||
are often necessary. HAProxy does support this method, as well as
|
||||
some hosting providers, for example CloudFoundry. In order to
|
||||
enable this method on the client side, please supply a
|
||||
`cookie:true` option to SockJS constructor.
|
||||
|
||||
|
||||
Development and testing
|
||||
-----------------------
|
||||
|
||||
If you want to work on SockJS-node source code, you need to clone the
|
||||
git repo and follow these steps. First you need to install
|
||||
dependencies:
|
||||
|
||||
cd sockjs-node
|
||||
npm install
|
||||
npm install --dev
|
||||
ln -s .. node_modules/sockjs
|
||||
|
||||
You're ready to compile CoffeeScript:
|
||||
|
||||
make build
|
||||
|
||||
If compilation succeeds you may want to test if your changes pass all
|
||||
the tests. Currently, there are two separate test suites. For both of
|
||||
them you need to start a SockJS-node test server (by default listening
|
||||
on port 8081):
|
||||
|
||||
make test_server
|
||||
|
||||
### SockJS-protocol Python tests
|
||||
|
||||
To run it run something like:
|
||||
|
||||
cd sockjs-protocol
|
||||
make test_deps
|
||||
./venv/bin/python sockjs-protocol.py
|
||||
|
||||
For details see
|
||||
[SockJS-protocol README](https://github.com/sockjs/sockjs-protocol#readme).
|
||||
|
||||
### SockJS-client QUnit tests
|
||||
|
||||
You need to start a second web server (by default listening on 8080)
|
||||
that is serving various static html and javascript files:
|
||||
|
||||
cd sockjs-client
|
||||
make test
|
||||
|
||||
At that point you should have two web servers running: sockjs-node on
|
||||
8081 and sockjs-client on 8080. When you open the browser on
|
||||
[http://localhost:8080/](http://localhost:8080/) you should be able
|
||||
run the QUnit tests against your sockjs-node server.
|
||||
|
||||
For details see
|
||||
[SockJS-client README](https://github.com/sockjs/sockjs-client#readme).
|
||||
|
||||
Additionally, if you're doing more serious development consider using
|
||||
`make serve`, which will automatically the server when you modify the
|
||||
source code.
|
||||
|
||||
|
||||
Various issues and design considerations
|
||||
----------------------------------------
|
||||
|
||||
### Authorisation
|
||||
|
||||
SockJS-node does not expose cookies to the application. This is done
|
||||
deliberately as using cookie-based authorisation with SockJS simply
|
||||
doesn't make sense and will lead to security issues.
|
||||
|
||||
Cookies are a contract between a browser and an http server, and are
|
||||
identified by a domain name. If a browser has a cookie set for
|
||||
particular domain, it will pass it as a part of all http requests to
|
||||
the host. But to get various transports working, SockJS uses a middleman
|
||||
- an iframe hosted from target SockJS domain. That means the server
|
||||
will receive requests from the iframe, and not from the real
|
||||
domain. The domain of an iframe is the same as the SockJS domain. The
|
||||
problem is that any website can embed the iframe and communicate with
|
||||
it - and request establishing SockJS connection. Using cookies for
|
||||
authorisation in this scenario will result in granting full access to
|
||||
SockJS communication with your website from any website. This is a
|
||||
classic CSRF attack.
|
||||
|
||||
Basically - cookies are not suited for SockJS model. If you want to
|
||||
authorise a session - provide a unique token on a page, send it as a
|
||||
first thing over SockJS connection and validate it on the server
|
||||
side. In essence, this is how cookies work.
|
||||
|
||||
|
||||
### Deploying SockJS on Heroku
|
||||
|
||||
Long polling is known to cause problems on Heroku, but
|
||||
[workaround for SockJS is available](https://github.com/sockjs/sockjs-node/issues/57#issuecomment-5242187).
|
||||
1
receipeServer/frontend_old/node_modules/sockjs/index.js
generated
vendored
Normal file
1
receipeServer/frontend_old/node_modules/sockjs/index.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
module.exports = require('./lib/sockjs');
|
||||
43
receipeServer/frontend_old/node_modules/sockjs/package.json
generated
vendored
Normal file
43
receipeServer/frontend_old/node_modules/sockjs/package.json
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
{
|
||||
"name": "sockjs",
|
||||
"description": "SockJS-node is a server counterpart of SockJS-client a JavaScript library that provides a WebSocket-like object in the browser. SockJS gives you a coherent, cross-browser, Javascript API which creates a low latency, full duplex, cross-domain communication channel between the browser and the web server.",
|
||||
"version": "0.3.24",
|
||||
"author": "Marek Majkowski",
|
||||
"bugs": {
|
||||
"url": "https://github.com/sockjs/sockjs-node/issues"
|
||||
},
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Bryce Kahle",
|
||||
"email": "bkahle@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Marek Majkowski",
|
||||
"email": "deadbeef@popcount.org"
|
||||
}
|
||||
],
|
||||
"dependencies": {
|
||||
"faye-websocket": "^0.11.3",
|
||||
"uuid": "^8.3.2",
|
||||
"websocket-driver": "^0.7.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"coffeescript": "^1.12.7"
|
||||
},
|
||||
"homepage": "https://github.com/sockjs/sockjs-node",
|
||||
"keywords": [
|
||||
"websockets",
|
||||
"websocket"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "index",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sockjs/sockjs-node.git"
|
||||
},
|
||||
"scripts": {
|
||||
"version": "make build && git add Changelog",
|
||||
"postversion": "npm publish",
|
||||
"postpublish": "git push origin --all && git push origin --tags"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user