From 0285ce593ab4406b8ced03d02439b4208b19a431 Mon Sep 17 00:00:00 2001 From: Jon Dufresne Date: Fri, 1 May 2026 08:26:22 -0700 Subject: [PATCH 1/3] Require Node.js 18 and use crypto.randomUUID() --- CHANGELOG.md | 4 ++-- lib/sockjs-connection.js | 4 ++-- lib/utils.js | 30 ------------------------------ package.json | 2 +- 4 files changed, 5 insertions(+), 35 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 330054da..f570350c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. @@ -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 `uuid` dependency, replaced with Node.js `crypto.randomUUID()`. 0.3.19 ====== diff --git a/lib/sockjs-connection.js b/lib/sockjs-connection.js index 696c645d..c78b0e0b 100644 --- a/lib/sockjs-connection.js +++ b/lib/sockjs-connection.js @@ -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); diff --git a/lib/utils.js b/lib/utils.js index 479d9532..53e0c490 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -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) { diff --git a/package.json b/package.json index 6b21f842..460e31b2 100644 --- a/package.json +++ b/package.json @@ -45,6 +45,6 @@ "postpublish": "git push origin --all && git push origin --tags" }, "engines": { - "node": ">=6.5.0" + "node": ">=18.0.0" } } From 00a017df8d485b5b4a9380cbb4e68a181ecf6874 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Asif=20Saif=20Uddin=20=7B=22Auvi=22=3A=22=E0=A6=85?= =?UTF-8?q?=E0=A6=AD=E0=A6=BF=22=7D?= Date: Sat, 2 May 2026 10:21:30 +0600 Subject: [PATCH 2/3] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f570350c..95906280 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 `uuid` dependency, replaced with Node.js `crypto.randomUUID()`. + * Remove the internal UUID helper and use Node.js `crypto.randomUUID()` directly. 0.3.19 ====== From 18bca90267efe4309d05dddd8373b73081745a3b Mon Sep 17 00:00:00 2001 From: Jon Dufresne Date: Sun, 3 May 2026 11:50:44 -0700 Subject: [PATCH 3/3] Update nvmrc and package-lock.json --- .nvmrc | 2 +- package-lock.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.nvmrc b/.nvmrc index e1fcd1ea..a77793ec 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -lts/erbium +lts/hydrogen diff --git a/package-lock.json b/package-lock.json index adf70a3d..a91ccf09 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,7 +19,7 @@ "prettier": "^2.0.5" }, "engines": { - "node": ">=6.5.0" + "node": ">=18.0.0" } }, "node_modules/@babel/code-frame": {