
Product
Introducing Tier 1 Reachability: Precision CVE Triage for Enterprise Teams
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
@qrvey/websocket-client
Advanced tools

The @qrvey/websocket-client
package provides a unified interface to work with websocket as any client. Works from Backend and Frontend.
This package is based on the WebSocket services that use Socket.io
npm install @qrvey/websocket-client
Or with yarn:
yarn add @qrvey/websocket-client
DOMAIN; // The BASE Qrvey domain. If not set, could be pass in the constructor of WebSocketClient class
new WebSocketClient(auth, options)
Creates an instance of WebSocketClient
.
auth
(Object): Authentication details.
userId
(string, optional): User identifier.clientId
(string, optional): Client identifier.token
(string, optional): Authentication token.apiKey
(string, optional): API key.options
(Object): Additional options.
domain
(string, optional): Domain to stablish connection with the socket. If not set, try to find the domain in process.env.DOMAIN
isAutoPingPongEnable
(boolean, optional, default=true): Enables or disables the auto ping-pong mechanism.publish({ eventName, data, isPublic = false }: { eventName: string; data: Record<string, any>; isPublic?: boolean; }): void
Publishes an event with the specified data.
eventName
(string): The name of the event to publish.data
(any): The data to send with the event.isPublic
(boolean, optional, default=false): Whether the event is public or not.subscribe(eventName: string, callback: (message: any) => void): void
Subscribes to an event and provides a callback to handle the messages.
Parameters:
eventName
(string): The name of the event to subscribe to.callback
(function): A callback function to handle the messages. The function receives one argument:
message
(any): The message received from the event.Returns: this (the instance of WebSocketClient)
onError(callback: (message: any) => void): void
Sets a callback function to handle error messages.
callback
(function): A callback function to handle error messages. The function receives one argument:
message
(any): The error message.status(): SOCKET_STATUS
Returns the current status of the WebSocket connection.
connect(): void
Establishes the WebSocket connection if needed. After create the instances, the connection and reconnection is done by default.
disconnect(): void
Disconnects the WebSocket client.
The SOCKET_STATUS
enum defines the possible states of a WebSocket connection.
Enum Values:
CONNECTED
: Indicates that the WebSocket connection has been successfully established.ACTIVE
: Indicates that the WebSocket connection is active and currently transmitting or receiving data.RECOVERED
: Indicates that the WebSocket connection was lost but has been successfully re-established.DISCONNECTED
: Indicates that the WebSocket connection has been intentionally or unintentionally closed.UNDEFINED
: Indicates that the WebSocket connection status is undefined or has not yet been determined.const { WebSocketClient, SOCKET_STATUS } = require('@qrvey/websocket-client');
const socket = new WebSocketClient({ userId: '', token: '' });
socket.publish({
eventName: 'from:example',
data: { body: 'example message' }
})
socket.subscribe('example', (message) => {
console.log('Recibed: ', message);
})
if (socket.status() === SOCKET_STATUS.DISCONNECTED) console.log('Socket disconnected!')
FAQs

We found that @qrvey/websocket-client demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
Research
/Security News
Ongoing npm supply chain attack spreads to DuckDB: multiple packages compromised with the same wallet-drainer malware.
Security News
The MCP Steering Committee has launched the official MCP Registry in preview, a central hub for discovering and publishing MCP servers.