From d2ac99d4fc4c47668ccec451b47b27fbbc9d1807 Mon Sep 17 00:00:00 2001 From: Alexander Trofimov Date: Thu, 4 Aug 2016 15:21:24 +0300 Subject: [PATCH 01/26] Pass some custom header. Pass some custom header. --- src/transport.coffee | 1 + 1 file changed, 1 insertion(+) diff --git a/src/transport.coffee b/src/transport.coffee index e64f38bc..47f85402 100644 --- a/src/transport.coffee +++ b/src/transport.coffee @@ -131,6 +131,7 @@ class Session headers = {} for key in ['referer', 'x-client-ip', 'x-forwarded-for', \ + 'x-forwarded-host', 'x-forwarded-port', \ 'x-cluster-client-ip', 'via', 'x-real-ip', \ 'x-forwarded-proto', 'x-ssl', \ 'host', 'user-agent', 'accept-language'] From c14d401febad2c70463b35459bb40918935ce901 Mon Sep 17 00:00:00 2001 From: Mitar Date: Sun, 21 Aug 2016 12:19:28 -0700 Subject: [PATCH 02/26] Added do-not-track header to whitelisted list of headers. Fixes: #211 --- src/transport.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/transport.coffee b/src/transport.coffee index e64f38bc..40e4d435 100644 --- a/src/transport.coffee +++ b/src/transport.coffee @@ -132,7 +132,7 @@ class Session headers = {} for key in ['referer', 'x-client-ip', 'x-forwarded-for', \ 'x-cluster-client-ip', 'via', 'x-real-ip', \ - 'x-forwarded-proto', 'x-ssl', \ + 'x-forwarded-proto', 'x-ssl', 'DNT', \ 'host', 'user-agent', 'accept-language'] headers[key] = req.headers[key] if req.headers[key] if headers From 2fcd0d33d908b4afafd99497ce060fd6b6897313 Mon Sep 17 00:00:00 2001 From: codisredding Date: Mon, 31 Oct 2016 19:14:06 -0500 Subject: [PATCH 03/26] update Hapi example (several deprecated functions) --- examples/hapi/package.json | 13 +++++++------ examples/hapi/server.js | 31 ++++++++++++++++++++----------- 2 files changed, 27 insertions(+), 17 deletions(-) diff --git a/examples/hapi/package.json b/examples/hapi/package.json index 9121c5b0..e0bd262e 100644 --- a/examples/hapi/package.json +++ b/examples/hapi/package.json @@ -1,8 +1,9 @@ { - "name": "sockjs-hapi", - "version": "0.0.0-unreleasable", - "dependencies": { - "hapi": "*", - "sockjs": "*" - } + "name": "sockjs-hapi", + "version": "0.0.0-unreleasable", + "dependencies": { + "hapi": "*", + "inert": "*", + "sockjs": "*" + } } diff --git a/examples/hapi/server.js b/examples/hapi/server.js index 454bc942..239ba1d4 100644 --- a/examples/hapi/server.js +++ b/examples/hapi/server.js @@ -6,7 +6,9 @@ var sockjs = require('sockjs'); var Hapi = require('hapi'); // 1. Echo sockjs server -var sockjs_opts = {sockjs_url: "http://cdn.jsdelivr.net/sockjs/1.0.1/sockjs.min.js"}; +var sockjs_opts = { + sockjs_url: "http://cdn.jsdelivr.net/sockjs/1.0.1/sockjs.min.js" +}; var sockjs_echo = sockjs.createServer(sockjs_opts); sockjs_echo.on('connection', function(conn) { @@ -15,19 +17,26 @@ sockjs_echo.on('connection', function(conn) { }); }); -// Create a server with a host and port -var hapi_server = Hapi.createServer('0.0.0.0', 9999); +// Create a server and set port (default host 0.0.0.0) +var hapi_server = new Hapi.Server(); +hapi_server.connection({ + port: 9999 +}); -hapi_server.route({ - method: 'GET', - path: '/{path*}', - handler: { - directory: { path: './html', listing: false, index: true } - } +hapi_server.register(require('inert'), (err) => { + hapi_server.route({ + method: 'GET', + path: '/{path*}', + handler: function(request, reply) { + reply.file('./html/index.html'); + } + }); }); //hapi_server.listener is the http listener hapi uses -sockjs_echo.installHandlers(hapi_server.listener, {prefix:'/echo'}); +sockjs_echo.installHandlers(hapi_server.listener, { + prefix: '/echo' +}); -console.log(' [*] Listening on 0.0.0.0:9999' ); +console.log(' [*] Listening on 0.0.0.0:9999'); hapi_server.start(); From 45a0216407be72b126a820afbf53d04fd7fdc8ae Mon Sep 17 00:00:00 2001 From: codisredding Date: Wed, 2 Nov 2016 12:11:54 -0500 Subject: [PATCH 04/26] be explicit about hapi and inert version --- examples/hapi/package.json | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/examples/hapi/package.json b/examples/hapi/package.json index e0bd262e..0e669d90 100644 --- a/examples/hapi/package.json +++ b/examples/hapi/package.json @@ -1,9 +1,9 @@ { - "name": "sockjs-hapi", - "version": "0.0.0-unreleasable", - "dependencies": { - "hapi": "*", - "inert": "*", - "sockjs": "*" - } + "name": "sockjs-hapi", + "version": "0.0.0-unreleasable", + "dependencies": { + "hapi": "15.x.x", + "inert": "4.x.x", + "sockjs": "*" + } } From 347746f8895029ac48ae2eb02a627d3edc40c85c Mon Sep 17 00:00:00 2001 From: Brian Shamblen Date: Mon, 7 Nov 2016 10:08:37 -0800 Subject: [PATCH 05/26] Add option to disable CORS headers --- src/chunking-test.coffee | 2 +- src/trans-xhr.coffee | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/chunking-test.coffee b/src/chunking-test.coffee index 7bb202a7..724b6635 100644 --- a/src/chunking-test.coffee +++ b/src/chunking-test.coffee @@ -33,7 +33,7 @@ exports.app = info: (req, res, _) -> info = { websocket: @options.websocket, - origins: ['*:*'], + origins: ['*:*'] unless @options.disable_cors, cookie_needed: not not @options.jsessionid, entropy: utils.random32(), } diff --git a/src/trans-xhr.coffee b/src/trans-xhr.coffee index 5b0ddcac..04c4c06b 100644 --- a/src/trans-xhr.coffee +++ b/src/trans-xhr.coffee @@ -57,6 +57,9 @@ exports.app = return true xhr_cors: (req, res, content) -> + if @options.disable_cors + return + if !req.headers['origin'] origin = '*' else From 9830979695a3814b30959223f94eb0ecb900d346 Mon Sep 17 00:00:00 2001 From: Brian Shamblen Date: Mon, 7 Nov 2016 10:27:18 -0800 Subject: [PATCH 06/26] Update README to include disable_cors option --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index 7442c93c..29870c96 100644 --- a/README.md +++ b/README.md @@ -156,6 +156,13 @@ Where `options` is a hash which can contain: 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. + +
disable_cors (boolean)
+
Enabling this option will prevent + CORS + headers from being included in the HTTP response. Can be used when the + sockjs client is know to be connecting from the same domain as the + sockjs server.
From 99fb0f6c1ab942ca2d70bb8074846c4ba5c52be6 Mon Sep 17 00:00:00 2001 From: Mitar Date: Thu, 17 Nov 2016 10:41:47 -0800 Subject: [PATCH 07/26] Correct case. --- src/transport.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/transport.coffee b/src/transport.coffee index 40e4d435..a8ffbcf6 100644 --- a/src/transport.coffee +++ b/src/transport.coffee @@ -132,7 +132,7 @@ class Session headers = {} for key in ['referer', 'x-client-ip', 'x-forwarded-for', \ 'x-cluster-client-ip', 'via', 'x-real-ip', \ - 'x-forwarded-proto', 'x-ssl', 'DNT', \ + 'x-forwarded-proto', 'x-ssl', 'dnt', \ 'host', 'user-agent', 'accept-language'] headers[key] = req.headers[key] if req.headers[key] if headers From 054fec1148115f5ee902c68f131cb21dfae6baaa Mon Sep 17 00:00:00 2001 From: Brian Shamblen Date: Tue, 22 Nov 2016 08:46:46 -0800 Subject: [PATCH 08/26] Return content when disable_cors is set --- src/trans-xhr.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/trans-xhr.coffee b/src/trans-xhr.coffee index 04c4c06b..bb3745c0 100644 --- a/src/trans-xhr.coffee +++ b/src/trans-xhr.coffee @@ -58,7 +58,7 @@ exports.app = xhr_cors: (req, res, content) -> if @options.disable_cors - return + return content if !req.headers['origin'] origin = '*' From b62f029087deee4b68ee3f3ccc47df48a2e7ffef Mon Sep 17 00:00:00 2001 From: Alex Jordan Date: Sun, 4 Dec 2016 15:17:14 -0800 Subject: [PATCH 09/26] Fix some grammar problems in README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7442c93c..9c63233f 100644 --- a/README.md +++ b/README.md @@ -73,8 +73,8 @@ discussions and support. SockJS-node API --------------- -The API design is based on the common Node API's like -[Streams API](http://nodejs.org/docs/v0.5.8/api/streams.html) or +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 From e6eeb42949f7f780daad872f4a34ad62b2ffa6a7 Mon Sep 17 00:00:00 2001 From: Matthew Holloway Date: Sat, 17 Dec 2016 10:57:47 +1300 Subject: [PATCH 10/26] Updating sockjs-client CDN URL --- src/sockjs.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sockjs.coffee b/src/sockjs.coffee index bad21f45..83942406 100644 --- a/src/sockjs.coffee +++ b/src/sockjs.coffee @@ -143,7 +143,7 @@ class Server extends events.EventEmitter heartbeat_delay: 25000 disconnect_delay: 5000 log: (severity, line) -> console.log(line) - sockjs_url: 'https://cdn.jsdelivr.net/sockjs/1.0.1/sockjs.min.js' + sockjs_url: 'https://cdn.jsdelivr.net/sockjs/1/sockjs.min.js' if user_options utils.objectExtend(@options, user_options) From f6f088db8d4f6dc287c24a5578dcabd380e823e7 Mon Sep 17 00:00:00 2001 From: wtgtybhertgeghgtwtg Date: Mon, 19 Dec 2016 19:07:17 -0700 Subject: [PATCH 11/26] Bump `uuid`; --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6041b592..09e4d450 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ ], "dependencies": { "faye-websocket": "^0.10.0", - "uuid": "^2.0.2" + "uuid": "^3.0.1" }, "devDependencies": { "coffee-script": "^1.8.0" From ac3893fb92e5a8482586eeea693e0adee6218ac9 Mon Sep 17 00:00:00 2001 From: Brian Shamblen Date: Fri, 20 Jan 2017 08:55:36 -0800 Subject: [PATCH 12/26] Documentation modifications --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7a9b30c3..c6cc4f0b 100644 --- a/README.md +++ b/README.md @@ -159,9 +159,9 @@ Where `options` is a hash which can contain:
disable_cors (boolean)
Enabling this option will prevent - CORS + CORS headers from being included in the HTTP response. Can be used when the - sockjs client is know to be connecting from the same domain as the + sockjs client is know to be connecting from the same origin as the sockjs server.
From 81b56831def3c8eabd1a9a9a657aa551792941b7 Mon Sep 17 00:00:00 2001 From: Brian Shamblen Date: Mon, 13 Feb 2017 14:36:10 -0800 Subject: [PATCH 13/26] Fix type-o --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c6cc4f0b..018588ca 100644 --- a/README.md +++ b/README.md @@ -161,7 +161,7 @@ Where `options` is a hash which can contain:
Enabling this option will prevent CORS headers from being included in the HTTP response. Can be used when the - sockjs client is know to be connecting from the same origin as the + sockjs client is known to be connecting from the same origin as the sockjs server.
From 02c4dcd6ff7112834cad50fae236335fb407208f Mon Sep 17 00:00:00 2001 From: Bryce Kahle Date: Thu, 12 Oct 2017 11:59:49 -0400 Subject: [PATCH 14/26] Use new uuid require format --- src/transport.coffee | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/transport.coffee b/src/transport.coffee index c9976f30..3d370ca8 100644 --- a/src/transport.coffee +++ b/src/transport.coffee @@ -5,7 +5,7 @@ # ***** END LICENSE BLOCK ***** stream = require('stream') -uuid = require('uuid') +uuidv4 = require('uuid/v4') utils = require('./utils') class Transport @@ -21,7 +21,7 @@ closeFrame = (status, reason) -> class SockJSConnection extends stream.Stream constructor: (@_session) -> - @id = uuid.v4() + @id = uuidv4() @headers = {} @prefix = @_session.prefix From 9bd48d786a2d3b5142f178d4d761fad14adf9cce Mon Sep 17 00:00:00 2001 From: Bryce Kahle Date: Thu, 12 Oct 2017 12:15:43 -0400 Subject: [PATCH 15/26] Update release process --- .gitignore | 1 + Makefile | 16 ---------------- VERSION-GEN | 17 ----------------- package.json | 5 +++++ 4 files changed, 6 insertions(+), 33 deletions(-) delete mode 100755 VERSION-GEN diff --git a/.gitignore b/.gitignore index 5a16f43b..39187338 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ node_modules lib/*.js *~ +package-lock.json diff --git a/Makefile b/Makefile index 7d39a949..d9afd788 100644 --- a/Makefile +++ b/Makefile @@ -37,19 +37,3 @@ serve: rm -f .pidfile.pid; \ sleep 0.1; \ done - -#### Release process -# 1) commit everything -# 2) amend version in package.json -# 3) run 'make tag' and run suggested 'git push' variants -# 4) run 'npm publish' - -RVER:=$(shell grep "version" package.json|tr '\t"' ' \t'|cut -f 4) -VER:=$(shell ./VERSION-GEN) - -.PHONY: tag -tag: all - git commit $(TAG_OPTS) package.json Changelog -m "Release $(RVER)" - git tag v$(RVER) -m "Release $(RVER)" - @echo ' [*] Now run' - @echo 'git push; git push --tag' diff --git a/VERSION-GEN b/VERSION-GEN deleted file mode 100755 index 16532031..00000000 --- a/VERSION-GEN +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/sh - -LF=' -' - -VN=$(git describe --match "v[0-9]*" --abbrev=4 HEAD 2>/dev/null) -case "$VN" in - *$LF*) (exit 1) ;; -v[0-9]*) - git update-index -q --refresh - test -z "$(git diff-index --name-only HEAD --)" || - VN="$VN-dirty" ;; -esac -VN=$(echo "$VN" | sed -e 's/-/./g'); -VN=$(expr "$VN" : v*'\(.*\)') - -echo "$VN" diff --git a/package.json b/package.json index 09e4d450..c07c2508 100644 --- a/package.json +++ b/package.json @@ -33,5 +33,10 @@ "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" } } From 14a5c3cf097126bde74436d001816c53a0593d43 Mon Sep 17 00:00:00 2001 From: Bryce Kahle Date: Thu, 12 Oct 2017 12:23:55 -0400 Subject: [PATCH 16/26] 0.3.19 --- Changelog | 10 ++++++++++ package.json | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Changelog b/Changelog index 363f960e..a24453ee 100644 --- a/Changelog +++ b/Changelog @@ -1,3 +1,13 @@ +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 ====== diff --git a/package.json b/package.json index c07c2508..64162bd4 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "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.18", + "version": "0.3.19", "author": "Marek Majkowski", "bugs": { "url": "https://github.com/sockjs/sockjs-node/issues" From 3e975c69cce21092c2ac9aa7a2f9dc40446f5ccd Mon Sep 17 00:00:00 2001 From: Kannan Goundan Date: Tue, 3 Dec 2019 20:28:40 -0800 Subject: [PATCH 17/26] writeHead: Don't end() response Backport of #265 --- src/webjs.coffee | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/webjs.coffee b/src/webjs.coffee index 42361c52..41cc5c87 100644 --- a/src/webjs.coffee +++ b/src/webjs.coffee @@ -45,9 +45,6 @@ fake_response = (req, res) -> try res.write(r.join('\r\n')) catch x - try - res.end() - catch x res.setHeader = (k, v) -> headers[k] = v From e3e78223b17dd631833ac49ae6d251d0d67bd347 Mon Sep 17 00:00:00 2001 From: Daniel Seitz Date: Fri, 6 Mar 2020 12:02:01 +0100 Subject: [PATCH 18/26] Use jsDelivr for jquery in examples --- examples/echo/index.html | 2 +- examples/express-3.x/index.html | 2 +- examples/express/index.html | 2 +- examples/hapi/html/index.html | 2 +- examples/koa/index.html | 2 +- examples/multiplex/index.html | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/echo/index.html b/examples/echo/index.html index 41734548..4d739131 100644 --- a/examples/echo/index.html +++ b/examples/echo/index.html @@ -1,6 +1,6 @@ - +