
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.
@soketi/impl
Advanced tools
TypeScript boilerplate to use on your WebSocket implementations. Made with ❤️ at Soketi.
The 🇷🇺 Russian invasion of 🇺🇦 Ukraine breaches any law, including the UN Charter. #StandWithUkraine
Open-source is not about political views, but rather humanitar views. It's code by the people for the people. Unprovoked, unjustifiable and despicable action that is killing civilians is not tolerated. The Renoki Co. subsidiaries (including Soketi) has taken action to move away from Russian software and dependencies and block any access from Russia within their projects.
Soketi Implementation is a TypeScript boilerplate to use on your WebSocket implementations. This represents a customizable single point of entry for your server, no matter what framework you are using.
The package comes with default implementations for the usual WebSocket operations, but as well as specific ones, like Pusher.
This is not providing a WebSocket server, but rather a way to implement your own WebSocket server, no matter what framework you are using.
In the examples, we will assume a pseudo-WebSocket server (not tied to any real use case).
This implementation provides a tracking of connections for the server:
import { Connections, Connection } from '@soketi/impl';
const conns = new Connections();
server.on('new-connection', async originalConnection => {
// Generate a unique ID for the connection.
const uniqueId = Math.random() * 1e5;
// If possible, associate the unique ID with the original connection.
// This can be used later to get the connection.
originalConnection.id = uniqueId;
// Create a new connection instance, binding
// the send and close methods to the underlying WebSocket.
const connection = new Connection(uniqueId, {
id: uniqueId,
send: (message) => originalConnection.send(message),
close: (...args) => originalConnection.close(...args),
});
// Add the connection to the connections tracker.
await conns.newConnection(connection);
});
This way, you can track connections and send messages to them:
for (const conn of conns.connections) {
// .send will call the send method of the underlying WebSocket.
await conn.send('Hello!');
}
To undo and remove a connection from the tracker, you can use removeConnection:
await conns.removeConnection(connection);
The package provides a way to handle WebSocket events at the general level, so that you don't have to implement them yourself. You will be defining both the handlers, as well as the calls to them, in a static way.
import { Router as WsRouter } from '@soketi/impl';
import { Connections, Connection } from '@soketi/impl';
const conns = new Connections();
WsRouter.onNewConnection(async conn => {
// As explained earlier in the connections, you can use it to add it to a tracker.
await conns.newConnection(conn);
await conn.send('Hello!');
});
server.on('new-connection', async originalConnection => {
const connection = new Connection(...);
// Handle the connection via the router.
// This will call the handler defined above.
await WsRouter.handleNewConnection(connection);
});
The router provides handlers for the following events:
onNewConnection(async (conn, ...args?) => {}) with handleNewConnection(connection, ...args?)onConnectionClosed(async (conn, code, msg, ...args?) => {}) with handleConnectionClosed(connection, code, msg, ...args?)onMessage(async (conn, message, ...args?) => {}) with handleMessage(connection, message, ...args?)onError(async (conn, error, ...args?) => {}) with handleError(connection, error, ...args?)You can also register your own handlers:
import { Router as WsRouter } from '@soketi/impl';
// Register a ping handler.
WsRouter.registerHandler('onPing', async conn => {
await conn.send('Pong!');
});
server.on('ping', async originalConnection => {
// Get the existing connection on a ping or message.
if (conns.connections.get(originalConnection.id)) {
await WsRouter.handle('onPing', connection);
}
});
See more: Pusher Channels
FAQs
TypeScript boilerplate to use on your WebSocket implementations. Made with ❤️ at Soketi.
We found that @soketi/impl 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.