0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-02-01 12:16:11 -05:00

fix(ext/node): npm:mqtt compatibility (#27792)

This commit is contained in:
Yoshiya Hinosawa 2025-01-27 11:47:32 +09:00 committed by GitHub
parent be080784dd
commit 2511458ac1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 283 additions and 0 deletions

View file

@ -158,6 +158,7 @@ export class TLSSocket extends net.Socket {
// onSocket handler of ClientRequest object.
tlssock.emit("secure");
tlssock.removeListener("end", onConnectEnd);
return;
}
try {

View file

@ -414,6 +414,11 @@ class ClientRequest extends OutgoingMessage {
oncreate,
);
if (newSocket) {
// If socket is created by createConnection option
// we apply sock-init-workaround
// This covers npm:ws and npm:mqtt
// https://github.com/denoland/deno/issues/27694
newSocket._needsSockInitWorkaround = true;
oncreate(null, newSocket);
}
} catch (err) {

Binary file not shown.

View file

@ -0,0 +1,73 @@
{
"name": "bufferutil",
"dist-tags": {
"latest": "4.0.9"
},
"versions": {
"4.0.9": {
"name": "bufferutil",
"version": "4.0.9",
"description": "WebSocket buffer utils",
"main": "index.js",
"engines": {
"node": ">=6.14.2"
},
"scripts": {
"install": "node-gyp-build",
"prebuild": "prebuildify --napi --strip --target=8.11.2",
"prebuild-darwin-x64+arm64": "prebuildify --arch x64+arm64 --napi --strip --target=8.11.2",
"test": "mocha"
},
"repository": {
"type": "git",
"url": "git+https://github.com/websockets/bufferutil.git"
},
"author": {
"name": "Einar Otto Stangvik",
"email": "einaros@gmail.com",
"url": "http://2x.io"
},
"license": "MIT",
"bugs": {
"url": "https://github.com/websockets/bufferutil/issues"
},
"dependencies": {
"node-gyp-build": "^4.3.0"
},
"devDependencies": {
"mocha": "^11.0.1",
"node-gyp": "^11.0.0",
"prebuildify": "^6.0.0"
},
"_id": "bufferutil@4.0.9",
"gitHead": "35e2eb6a14a8d58b87bc1f9ff2ddff67e2f1fa97",
"_nodeVersion": "23.5.0",
"_npmVersion": "10.9.2",
"dist": {
"integrity": "sha512-WDtdLmJvAuNNPzByAYpRo2rF1Mmradw6gvWsQKf63476DDXmomT9zUiGypLcG4ibIM67vhAj8jJRdbmEws2Aqw==",
"shasum": "6e81739ad48a95cad45a279588e13e95e24a800a",
"tarball": "http://localhost:4260/bufferutil/bufferutil-4.0.9.tgz",
"fileCount": 11,
"unpackedSize": 371859
},
"directories": {},
"_hasShrinkwrap": false
}
},
"bugs": {
"url": "https://github.com/websockets/bufferutil/issues"
},
"author": {
"name": "Einar Otto Stangvik",
"email": "einaros@gmail.com",
"url": "http://2x.io"
},
"license": "MIT",
"homepage": "https://github.com/websockets/bufferutil",
"repository": {
"type": "git",
"url": "git+https://github.com/websockets/bufferutil.git"
},
"description": "WebSocket buffer utils",
"readmeFilename": "README.md"
}

View file

@ -0,0 +1,75 @@
{
"name": "utf-8-validate",
"dist-tags": {
"latest": "6.0.5"
},
"versions": {
"6.0.5": {
"name": "utf-8-validate",
"version": "6.0.5",
"description": "Check if a buffer contains valid UTF-8",
"main": "index.js",
"engines": {
"node": ">=6.14.2"
},
"scripts": {
"install": "node-gyp-build",
"prebuild": "prebuildify --napi --strip --target=8.11.2",
"prebuild-linux-musl-x64": "prebuildify-cross --image alpine --napi --strip --target=8.11.2",
"prebuild-darwin-x64+arm64": "prebuildify --arch x64+arm64 --napi --strip --target=8.11.2",
"test": "mocha"
},
"repository": {
"type": "git",
"url": "git+https://github.com/websockets/utf-8-validate.git"
},
"author": {
"name": "Einar Otto Stangvik",
"email": "einaros@gmail.com",
"url": "http://2x.io"
},
"license": "MIT",
"bugs": {
"url": "https://github.com/websockets/utf-8-validate/issues"
},
"dependencies": {
"node-gyp-build": "^4.3.0"
},
"devDependencies": {
"mocha": "^10.0.0",
"node-gyp": "^10.0.1",
"prebuildify": "^6.0.0",
"prebuildify-cross": "^5.0.0"
},
"_id": "utf-8-validate@6.0.5",
"gitHead": "4a9a05728641674620818c6a78b01fce38e6f222",
"_nodeVersion": "22.10.0",
"_npmVersion": "10.9.0",
"dist": {
"integrity": "sha512-EYZR+OpIXp9Y1eG1iueg8KRsY8TuT8VNgnanZ0uA3STqhHQTLwbl+WX76/9X5OY12yQubymBpaBSmMPkSTQcKA==",
"shasum": "8087d39902be2cc15bdb21a426697ff256d65aab",
"tarball": "http://localhost:4260/utf-8-validate/utf-8-validate-6.0.5.tgz",
"fileCount": 15,
"unpackedSize": 717511
},
"directories": {},
"_hasShrinkwrap": false
}
},
"bugs": {
"url": "https://github.com/websockets/utf-8-validate/issues"
},
"author": {
"name": "Einar Otto Stangvik",
"email": "einaros@gmail.com",
"url": "http://2x.io"
},
"license": "MIT",
"homepage": "https://github.com/websockets/utf-8-validate",
"repository": {
"type": "git",
"url": "git+https://github.com/websockets/utf-8-validate.git"
},
"description": "Check if a buffer contains valid UTF-8",
"readmeFilename": "README.md"
}

View file

@ -0,0 +1,97 @@
{
"name": "ws",
"description": "Simple to use, blazing fast and thoroughly tested websocket client and server for Node.js",
"dist-tags": {
"latest": "8.18.0"
},
"versions": {
"8.18.0": {
"name": "ws",
"version": "8.18.0",
"description": "Simple to use, blazing fast and thoroughly tested websocket client and server for Node.js",
"bugs": {
"url": "https://github.com/websockets/ws/issues"
},
"repository": {
"type": "git",
"url": "git+https://github.com/websockets/ws.git"
},
"author": {
"name": "Einar Otto Stangvik",
"email": "einaros@gmail.com",
"url": "http://2x.io"
},
"license": "MIT",
"main": "index.js",
"exports": {
".": {
"browser": "./browser.js",
"import": "./wrapper.mjs",
"require": "./index.js"
},
"./package.json": "./package.json"
},
"browser": "browser.js",
"engines": {
"node": ">=10.0.0"
},
"scripts": {
"test": "nyc --reporter=lcov --reporter=text mocha --throw-deprecation test/*.test.js",
"integration": "mocha --throw-deprecation test/*.integration.js",
"lint": "eslint . && prettier --check --ignore-path .gitignore \"**/*.{json,md,yaml,yml}\""
},
"peerDependencies": {
"bufferutil": "^4.0.1",
"utf-8-validate": ">=5.0.2"
},
"peerDependenciesMeta": {
"bufferutil": {
"optional": true
},
"utf-8-validate": {
"optional": true
}
},
"devDependencies": {
"benchmark": "^2.1.4",
"bufferutil": "^4.0.1",
"eslint": "^9.0.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-prettier": "^5.0.0",
"globals": "^15.0.0",
"mocha": "^8.4.0",
"nyc": "^15.0.0",
"prettier": "^3.0.0",
"utf-8-validate": "^6.0.0"
},
"_id": "ws@8.18.0",
"gitHead": "976c53c4065c49ede73bfba824caf5a6e0f290cb",
"_nodeVersion": "22.4.0",
"_npmVersion": "10.8.1",
"dist": {
"integrity": "sha512-8VbfWfHLbbwu3+N6OKsOMpBdT4kXPDDB9cJk2bJ6mh9ucxdlnNvH1e+roYkKmN9Nxw2yjz7VzeO9oOz2zJ04Pw==",
"shasum": "0d7505a6eafe2b0e712d232b42279f53bc289bbc",
"tarball": "http://localhost:4260/ws/ws-8.18.0.tgz",
"fileCount": 19,
"unpackedSize": 146647
},
"directories": {},
"_hasShrinkwrap": false
}
},
"author": {
"name": "Einar Otto Stangvik",
"email": "einaros@gmail.com",
"url": "http://2x.io"
},
"repository": {
"type": "git",
"url": "git+https://github.com/websockets/ws.git"
},
"license": "MIT",
"homepage": "https://github.com/websockets/ws",
"bugs": {
"url": "https://github.com/websockets/ws/issues"
},
"readmeFilename": "README.md"
}

Binary file not shown.

View file

@ -0,0 +1,4 @@
{
"args": "run -A --cert=../../../testdata/tls/RootCA.pem main.ts",
"output": "main.out"
}

View file

@ -0,0 +1,4 @@
[WILDCARD]
open on server
open on client
message on server

View file

@ -0,0 +1,24 @@
import WebSocket from "npm:ws@8.18.0";
const key = Deno.readTextFileSync("../../../testdata/tls/localhost.key");
const cert = Deno.readTextFileSync("../../../testdata/tls/localhost.crt");
Deno.serve({ key, cert, port: 0, onListen }, (req) => {
const { socket, response } = Deno.upgradeWebSocket(req);
socket.addEventListener("open", () => {
console.log("open on server");
});
socket.addEventListener("message", () => {
console.log("message on server");
Deno.exit(0);
});
return response;
});
function onListen({ port }) {
const socket = new WebSocket(`wss://localhost:${port}`);
socket.on("open", () => {
console.log("open on client");
socket.send("hi");
});
}