configurapi-handler-ws
Advanced tools
+1
-1
| { | ||
| "name": "configurapi-handler-ws", | ||
| "version": "1.2.0", | ||
| "version": "1.3.0", | ||
| "main": "src/index", | ||
@@ -5,0 +5,0 @@ "files": [ |
+3
-1
@@ -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 @@ } |
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
21511
2.84%498
2.47%44
4.76%