Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
The @types/ws package provides TypeScript type definitions for the ws (WebSocket) library, enabling developers to use ws in TypeScript projects with type checking and IntelliSense support. It doesn't add any functionality on its own but allows for a better development experience when working with WebSockets in TypeScript.
Creating a WebSocket server
This code sample demonstrates how to create a WebSocket server that listens on port 8080. It handles new connections and messages from clients, and sends a message to clients upon connection.
import * as WebSocket from 'ws';
const wss = new WebSocket.Server({ port: 8080 });
wss.on('connection', function connection(ws) {
ws.on('message', function incoming(message) {
console.log('received: %s', message);
});
ws.send('something');
});
Connecting to a WebSocket server
This example shows how to connect to a WebSocket server and interact with it by sending a message upon opening the connection and logging messages received from the server.
import * as WebSocket from 'ws';
const ws = new WebSocket('ws://www.host.com/path');
ws.on('open', function open() {
ws.send('something');
});
ws.on('message', function incoming(data) {
console.log(data);
});
Socket.IO is a library that enables real-time, bidirectional and event-based communication between web clients and servers. It's more feature-rich than ws, providing built-in support for broadcasting, rooms, and namespaces, but it's also heavier and requires its client library for full functionality.
Faye is a WebSocket (and EventSource) library that is designed to be simple to use. It's similar to ws in its basic functionality but also includes support for WebSocket client functionality in both Node.js and browsers, making it a more versatile option for some projects.
npm install --save @types/ws
This package contains type definitions for ws (https://github.com/websockets/ws).
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/ws
Additional Details
These definitions were written by Paul Loyd https://github.com/loyd, Matt Silverlock https://github.com/elithrar, Margus Lamp https://github.com/mlamp, Philippe D'Alva https://github.com/TitaneBoy, Orblazer https://github.com/orblazer.
FAQs
TypeScript definitions for ws
The npm package @types/ws receives a total of 10,542,270 weekly downloads. As such, @types/ws popularity was classified as popular.
We found that @types/ws demonstrated a healthy version release cadence and project activity because the last version was released less than 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
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.