Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
lts/erbium
lts/hydrogen
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
This means you cannot use the same SockJS server installed at multiple prefixes.
In practice this was confusing and not common.
* `websocket` option is deprecated, but still respected. Please use the new `transports` option.
* Node.js `>= 6.5.0` is required.
* Node.js `>= 18.0.0` is required.

## Other Fixes/Changes
* Convert from coffeescript to ES6.
Expand All @@ -19,7 +19,7 @@
* Added `detach(server)` function to remove SockJS from a HTTP server instance.
* Update dependencies.
* Examples have been updated to use latest versions of libraries.

* Remove the internal UUID helper and use Node.js `crypto.randomUUID()` directly.

0.3.19
======
Expand Down
4 changes: 2 additions & 2 deletions lib/sockjs-connection.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
'use strict';

const crypto = require('crypto');
const debug = require('debug')('sockjs:connection');
const stream = require('stream');
const { uuid } = require('./utils');

class SockJSConnection extends stream.Duplex {
constructor(session) {
super({ decodeStrings: false, encoding: 'utf8', readableObjectMode: true });
this._session = session;
this.id = uuid();
this.id = crypto.randomUUID();
this.headers = {};
this.prefix = this._session.prefix;
debug('new connection', this.id, this.prefix);
Expand Down
30 changes: 0 additions & 30 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,6 @@
const crypto = require('crypto');
const http = require('http');

module.exports.uuid = function uuid() {
// only available on Node v16.7+
if (typeof crypto.randomUUID === 'function') {
return crypto.randomUUID();
}

const bytes = crypto.randomBytes(16);

// Per RFC 4122 §4.4:
// Set version to 4 => xxxx -> 0100
bytes[6] = (bytes[6] & 0x0f) | 0x40;

// Set variant to RFC 4122 => 10xxxxxx
bytes[8] = (bytes[8] & 0x3f) | 0x80;

const hex = bytes.toString('hex');

return (
hex.slice(0, 8) +
'-' +
hex.slice(8, 12) +
'-' +
hex.slice(12, 16) +
'-' +
hex.slice(16, 20) +
'-' +
hex.slice(20)
);
};

// used in case of 'upgrade' requests where res is
// net.Socket instead of http.ServerResponse
module.exports.fake_response = function fake_response(req, res) {
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@
"postpublish": "git push origin --all && git push origin --tags"
},
"engines": {
"node": ">=6.5.0"
"node": ">=18.0.0"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jdufresne is this suggestion legit? can you cross check

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. I fixed both identified issues in:

Update nvmrc and package-lock.json

}
}
Loading