Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

configurapi-handler-ws

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

configurapi-handler-ws - npm Package Compare versions

Comparing version
1.2.0
to
1.3.0
+1
-1
package.json
{
"name": "configurapi-handler-ws",
"version": "1.2.0",
"version": "1.3.0",
"main": "src/index",

@@ -5,0 +5,0 @@ "files": [

@@ -38,6 +38,8 @@ # configurapi-handler-ws

* To pass data (such as a protocol or authentication token) when establishing the WebSocket connection, provide it as the second parameter to the constructor.
* If a connection could not be made (e.g. the on_connect route returns 400+ status code), an error will be sent to onPush().
* The client has a default timeout of 27 seconds. To increase the wait time for results, set the `replyTimeoutMs` parameter in the constructor's second argument.
```
const { WebSocketClient } = require("configurapi-handler-ws");
let client = new WebSocketClient(WEBSOCKET_BASE_URL, {onPush: (data:IResponse)=>console.log(data)});
let client = new WebSocketClient(WEBSOCKET_BASE_URL, {replyTimeoutMs: 300000, onPush: (data:IResponse)=>console.log(data)});
```

@@ -12,2 +12,3 @@ export interface ClientOptions

body: any;
error: string;
statusCode: number;

@@ -14,0 +15,0 @@ headers: Record<string, string>;

@@ -202,3 +202,3 @@ const MessageIdHeaderName = 'message-id';

const id = this.getHeaderCaseInsensitive(msg.headers, MessageIdHeaderName);
if (msg?.statusCode && msg.statusCode !== 202 && id && this.inflight.has(id))

@@ -226,10 +226,21 @@ {

{
//no inflight ws connections.
if(msg?.statusCode > 299)
{
const error = new Error(`${msg.message} - (${msg.statusCode})`)
throw error;
const error = new Error(`${msg.message} - (${msg.statusCode})`);
if(this.onPush)
{
this.onPush(msg)
}
else
{
throw error;
}
}
// No id or unknown id. Treat as push/unsolicited.
if (this.onPush) this.onPush(msg);
else
{
// No id or unknown id. Treat as push/unsolicited.
if (this.onPush) this.onPush(msg);
}
}

@@ -236,0 +247,0 @@ }