
Security News
Axios Maintainer Confirms Social Engineering Attack Behind npm Compromise
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.
@hetrodo/webrocket
Advanced tools
WebRocket is a framework for WebSockets that create an abstraction on top of WebSockets just like http servers are on top of TCP/IP servers.
WebRocket is a framework for WebSockets, its purpose is to create an abstraction on top of WebSockets just like http servers are on top of TCP/IP servers.
WebRocket simplify WebSockets usage by creating a rest api like interface.
yarn add @hetrodo/webrocket
const WebRocket = require('@hetrodo/webrocket/lib/WebRocket');
const WebRocketMethod = require('@hetrodo/webrocket/lib/WebRocketMethod');
const WebSocketAdapter = require('@hetrodo/webrocket/lib/WebSocketAdapter');
//First we connect to the WebSocket server
const ws = new WebSocket('ws://127.0.0.1:8080');
//We wait for the connection to open
ws.onopen = () => {
//With the connection open we instantiate the WebRocket class
const clientAdapter = new WebSocketAdapter(ws);
const webRocket = new WebRocket(clientAdapter);
//Now we can register the client-side endpoints that we want using GET, POST, PUT, DELETE methods.
webRocket.on(WebRocketMethod.get, 'v1/client-entity', (request, respond) => {
respond({
msg: 'Ok'
});
});
webRocket.on(WebRocketMethod.post, 'v1/client-entity', (request, respond) => {
respond({
msg: 'Ok'
});
});
webRocket.on(WebRocketMethod.put, 'v1/client-entity', (request, respond) => {
respond({
msg: 'Ok'
});
});
webRocket.on(WebRocketMethod.delete, 'v1/client-entity', (request, respond) => {
respond({
msg: 'Ok'
});
});
//And using the WebRocket's class instance we can make requests to the server-side defined endpoints
webRocket.get('v1/server-entity').then(console.log).catch(console.error);
webRocket.post('v1/server-entity', {}).then(console.log).catch(console.error);
webRocket.put('v1/server-entity', {}).then(console.log).catch(console.error);
webRocket.delete('v1/server-entity').then(console.log).catch(console.error);
//You can use query params too
webRocket.get('v1/server-entity?key=value').then(console.log).catch(console.error);
};
yarn add express ws @hetrodo/webrocket
const express = require('express');
const { createServer } = require('http');
const { WebSocketServer } = require('ws');
const WebRocket = require('@hetrodo/webrocket');
const WebRocketMethod = require('@hetrodo/webrocket/lib/WebRocketMethod');
const WebSocketAdapter = require('@hetrodo/webrocket/lib/WebSocketAdapter');
//Create your WebSocket server
const app = express();
const server = createServer(app);
const wss = new WebSocketServer({ server });
wss.on('connection', function (ws) {
//When a connection established we can instantiate a new WebRocket.
const webRocket = new WebRocket(new WebSocketAdapter(ws));
//Now we can register the server-side endpoints that we want using GET, POST, PUT, DELETE methods.
webRocket.on(WebRocketMethod.get, 'v1/server-entity', (request, respond) => {
respond({
msg: 'Ok'
});
});
webRocket.on(WebRocketMethod.post, 'v1/server-entity', (request, respond) => {
respond({
msg: 'Ok'
});
});
webRocket.on(WebRocketMethod.put, 'v1/server-entity', (request, respond) => {
respond({
msg: 'Ok'
});
});
webRocket.on(WebRocketMethod.delete, 'v1/server-entity', (request, respond) => {
respond({
msg: 'Ok'
});
});
//And using the WebRocket's class instance we can make requests to the client-side defined endpoints
webRocket.get('v1/client-entity').then(console.log).catch(console.error);
webRocket.post('v1/client-entity', {}).then(console.log).catch(console.error);
webRocket.put('v1/client-entity', {}).then(console.log).catch(console.error);
webRocket.delete('v1/client-entity').then(console.log).catch(console.error);
//Just like in the client side you can use query params too
webRocket.get('v1/client-entity?key=value').then(console.log).catch(console.error);
});
server.listen(8080, function () {
console.log('Listening on http://localhost:8080');
});
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
FAQs
WebRocket is a framework for WebSockets that create an abstraction on top of WebSockets just like http servers are on top of TCP/IP servers.
We found that @hetrodo/webrocket demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.