web3-providers-ws
Advanced tools
Comparing version 1.2.0 to 1.2.1
{ | ||
"name": "web3-providers-ws", | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"description": "Module to handle web3 RPC connections over WebSockets.", | ||
@@ -8,13 +8,10 @@ "repository": "https://github.com/ethereum/web3.js/tree/1.x/packages/web3-providers-ws", | ||
"engines": { | ||
"node": ">=8.0.0 <=11.15.0" | ||
"node": ">=8.0.0" | ||
}, | ||
"main": "src/index.js", | ||
"scripts": { | ||
"preinstall": "rm -rf node_modules/websocket/.git" | ||
}, | ||
"dependencies": { | ||
"underscore": "1.9.1", | ||
"web3-core-helpers": "1.2.0", | ||
"websocket": "github:frozeman/WebSocket-Node#browserifyCompatible" | ||
"web3-core-helpers": "1.2.1", | ||
"websocket": "github:web3-js/WebSocket-Node#polyfill/globalThis" | ||
} | ||
} |
@@ -27,18 +27,11 @@ /* | ||
var errors = require('web3-core-helpers').errors; | ||
var Ws = require('websocket').w3cwebsocket; | ||
var Ws = null; | ||
var isNode = Object.prototype.toString.call(typeof process !== 'undefined' ? process : 0) === '[object process]'; | ||
var _btoa = null; | ||
var parseURL = null; | ||
if (typeof window !== 'undefined' && typeof window.WebSocket !== 'undefined') { | ||
Ws = function(url, protocols) { | ||
return new window.WebSocket(url, protocols); | ||
}; | ||
_btoa = btoa; | ||
parseURL = function(url) { | ||
return new URL(url); | ||
}; | ||
} else { | ||
Ws = require('websocket').w3cwebsocket; | ||
if (isNode) { | ||
_btoa = function(str) { | ||
return Buffer.from(str).toString('base64'); | ||
return Buffer.from(str).toString('base64'); | ||
}; | ||
@@ -57,2 +50,7 @@ var url = require('url'); | ||
} | ||
} else { | ||
_btoa = btoa; | ||
parseURL = function(url) { | ||
return new URL(url); | ||
}; | ||
} | ||
@@ -65,2 +63,6 @@ // Default connection ws://localhost:8546 | ||
var WebsocketProvider = function WebsocketProvider(url, options) { | ||
if (!Ws) { | ||
throw new Error('websocket is not available'); | ||
} | ||
var _this = this; | ||
@@ -85,2 +87,6 @@ this.responseCallbacks = {}; | ||
var clientConfig = options.clientConfig || undefined; | ||
// Allow a custom request options | ||
// https://github.com/theturtle32/WebSocket-Node/blob/master/docs/WebSocketClient.md#connectrequesturl-requestedprotocols-origin-headers-requestoptions | ||
var requestOptions = options.requestOptions || undefined; | ||
@@ -92,3 +98,3 @@ // When all node core implementations that do not have the | ||
} | ||
this.connection = new Ws(url, protocol, undefined, headers, undefined, clientConfig); | ||
this.connection = new Ws(url, protocol, undefined, headers, requestOptions, clientConfig); | ||
@@ -95,0 +101,0 @@ this.addDefaultEvents(); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
GitHub dependency
Supply chain riskContains a dependency which resolves to a GitHub URL. Dependencies fetched from GitHub specifiers are not immutable can be used to inject untrusted code or reduce the likelihood of a reproducible install.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
GitHub dependency
Supply chain riskContains a dependency which resolves to a GitHub URL. Dependencies fetched from GitHub specifiers are not immutable can be used to inject untrusted code or reduce the likelihood of a reproducible install.
Found 1 instance in 1 package
Install scripts
Supply chain riskInstall scripts are run when the package is installed. The majority of malware in npm is hidden in install scripts.
Found 1 instance in 1 package
12888
321
1
+ Addedweb3-core-helpers@1.2.1(transitive)
+ Addedweb3-eth-iban@1.2.1(transitive)
+ Addedweb3-utils@1.2.1(transitive)
- Removedweb3-core-helpers@1.2.0(transitive)
- Removedweb3-eth-iban@1.2.0(transitive)
- Removedweb3-utils@1.2.0(transitive)
Updatedweb3-core-helpers@1.2.1
Updatedwebsocket@github:web3-js/WebSocket-Node#polyfill/globalThis