Skip to content

Commit c48053b

Browse files
authored
Switch to ws from websocket for determining polkadot genesis hash, update common dependencies (#2931)
* Switch to ws from websocket for determining polkadot genesis hash, update common dependencies * Update changelog
1 parent 77030a2 commit c48053b

File tree

4 files changed

+2838
-1280
lines changed

4 files changed

+2838
-1280
lines changed

packages/cli/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

77
## [Unreleased]
8+
### Changed
9+
- Swap `websocket` for `ws` dependency to fix CVEs (#2931)
810

911
## [6.4.1] - 2025-09-26
1012
### Added

packages/cli/package.json

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
"update-notifier": "^5.1.0",
4545
"webpack": "^5.101.3",
4646
"webpack-merge": "^6.0.1",
47-
"websocket": "^1.0.35",
47+
"ws": "^8.18.0",
4848
"yaml": "^2.8.1",
4949
"zod": "^3.25.67"
5050
},
@@ -56,21 +56,22 @@
5656
"@graphql-codegen/typescript": "^4.1.6",
5757
"@graphql-codegen/typescript-document-nodes": "^4.0.16",
5858
"@graphql-codegen/typescript-operations": "^4.6.1",
59-
"@subql/common-algorand": "^4.3.1",
59+
"@subql/common-algorand": "^4.4.3",
6060
"@subql/common-concordium": "^4.0.1",
61-
"@subql/common-cosmos": "^5.2.0",
62-
"@subql/common-ethereum": "^4.9.0",
63-
"@subql/common-near": "^4.2.1",
64-
"@subql/common-solana": "^0.0.0-2",
65-
"@subql/common-stellar": "^4.2.2",
61+
"@subql/common-cosmos": "^5.5.0",
62+
"@subql/common-ethereum": "^4.9.3",
63+
"@subql/common-near": "^4.3.4",
64+
"@subql/common-solana": "^1.2.0",
65+
"@subql/common-starknet": "^1.3.0",
66+
"@subql/common-stellar": "^4.5.0",
6667
"@subql/common-substrate": "workspace:~",
6768
"@types/ejs": "^3.1.5",
6869
"@types/express": "^4.17.21",
6970
"@types/node": "^18.19.42",
7071
"@types/qrcode-terminal": "^0.12.2",
7172
"@types/semver": "^7.5.8",
7273
"@types/update-notifier": "^6",
73-
"@types/websocket": "^1",
74+
"@types/ws": "^8.5.13",
7475
"eslint": "^8.8.0",
7576
"eslint-config-oclif": "^4.0.0",
7677
"eslint-config-oclif-typescript": "^1.0.3",

packages/cli/src/jsonrpc/client/ws.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright 2020-2025 SubQuery Pte Ltd authors & contributors
22
// SPDX-License-Identifier: GPL-3.0
33

4-
import {ICloseEvent, IMessageEvent, w3cwebsocket as WebSocket} from 'websocket';
4+
import WebSocket from 'ws';
55
import {Request, ResponseSuccessType} from './types';
66

77
let id = 0;
@@ -30,11 +30,11 @@ export class WsJsonRpcClient {
3030
this._ws = new WebSocket(this.address);
3131

3232
this.isReady = new Promise((resolve) => {
33-
this._ws.onopen = () => resolve(this);
33+
this._ws.on('open', () => resolve(this));
3434
});
3535

36-
this._ws.onclose = this.onSocketClose;
37-
this._ws.onmessage = this.onSocketMessage;
36+
this._ws.on('close', this.onSocketClose);
37+
this._ws.on('message', this.onSocketMessage);
3838
} catch (error) {
3939
console.error(error);
4040
}
@@ -54,18 +54,18 @@ export class WsJsonRpcClient {
5454
this._ws.close();
5555
}
5656

57-
private onSocketClose = (event: ICloseEvent): void => {
57+
private onSocketClose = (code: number, reason: Buffer): void => {
5858
if (this.isDestroyed) return;
5959

60-
console.error(`disconnected from ${this.address} code: '${event.code}' reason: '${event.reason}'`);
60+
console.error(`disconnected from ${this.address} code: '${code}' reason: '${reason.toString()}'`);
6161
setTimeout((): void => {
6262
this.connect();
6363
}, 1000);
6464
};
6565

66-
private onSocketMessage = ({data: dataStr}: IMessageEvent) => {
66+
private onSocketMessage = (dataStr: WebSocket.Data) => {
6767
try {
68-
const data = JSON.parse(String(dataStr));
68+
const data = JSON.parse(dataStr.toString());
6969
if (data.id !== undefined && data.id !== null && this.handlers[data.id]) {
7070
const [resolve, reject] = this.handlers[data.id];
7171
delete this.handlers[data.id];

0 commit comments

Comments
 (0)