diff --git a/lib/firefly.ts b/lib/firefly.ts index 7a80359..552f58a 100644 --- a/lib/firefly.ts +++ b/lib/firefly.ts @@ -1,5 +1,7 @@ import { Stream, Readable } from 'stream'; +import * as http from 'http'; import * as FormData from 'form-data'; +import * as WebSocket from 'ws'; import { FireFlyStatusResponse, FireFlyPrivateSendOptions, @@ -549,6 +551,7 @@ export default class FireFly extends HttpBase { listen( subscriptions: string | string[] | FireFlySubscriptionBase, callback: FireFlyWebSocketCallback, + socketOptions?: WebSocket.ClientOptions | http.ClientRequestArgs, ): FireFlyWebSocket { const options: FireFlyWebSocketOptions = { host: this.options.websocket.host, @@ -559,6 +562,7 @@ export default class FireFly extends HttpBase { autoack: false, reconnectDelay: this.options.websocket.reconnectDelay, heartbeatInterval: this.options.websocket.heartbeatInterval, + socketOptions: socketOptions, }; const handler: FireFlyWebSocketCallback = (socket, event) => { diff --git a/lib/interfaces.ts b/lib/interfaces.ts index ae68ceb..80b003a 100644 --- a/lib/interfaces.ts +++ b/lib/interfaces.ts @@ -1,4 +1,6 @@ +import * as http from 'http'; import { AxiosRequestConfig } from 'axios'; +import * as WebSocket from 'ws'; import { operations } from './schema'; /** @@ -61,6 +63,7 @@ export interface FireFlyWebSocketOptions { autoack: boolean; reconnectDelay: number; heartbeatInterval: number; + socketOptions?: WebSocket.ClientOptions | http.ClientRequestArgs; } // Namespace diff --git a/lib/websocket.ts b/lib/websocket.ts index bb1c3c3..e3c8ed8 100644 --- a/lib/websocket.ts +++ b/lib/websocket.ts @@ -57,6 +57,7 @@ export class FireFlyWebSocket { ? `${this.options.username}:${this.options.password}` : undefined; const socket = (this.socket = new WebSocket(url, { + ...this.options.socketOptions, auth, handshakeTimeout: this.options.heartbeatInterval, })); diff --git a/package-lock.json b/package-lock.json index 407c77e..4d7988c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@hyperledger/firefly-sdk", - "version": "1.2.1", + "version": "1.2.4", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@hyperledger/firefly-sdk", - "version": "1.2.1", + "version": "1.2.4", "license": "Apache-2.0", "dependencies": { "axios": "^0.26.1", diff --git a/package.json b/package.json index a85316d..e36a11c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@hyperledger/firefly-sdk", - "version": "1.2.3", + "version": "1.2.4", "description": "Client SDK for Hyperledger FireFly", "main": "dist/index.js", "types": "dist/index.d.ts",