web3-providers-ws
Advanced tools
Comparing version 1.0.0-beta.34 to 1.0.0-beta.35
{ | ||
"name": "web3-providers-ws", | ||
"namespace": "ethereum", | ||
"version": "1.0.0-beta.34", | ||
"version": "1.0.0-beta.35", | ||
"description": "Module to handle web3 RPC connections over WebSockets.", | ||
@@ -11,5 +11,5 @@ "repository": "https://github.com/ethereum/web3.js/tree/master/packages/web3-providers-ws", | ||
"underscore": "1.8.3", | ||
"web3-core-helpers": "1.0.0-beta.34", | ||
"web3-core-helpers": "1.0.0-beta.35", | ||
"websocket": "git://github.com/frozeman/WebSocket-Node.git#browserifyCompatible" | ||
} | ||
} |
@@ -31,3 +31,3 @@ /* | ||
var parseURL = null; | ||
if (typeof window !== 'undefined') { | ||
if (typeof window !== 'undefined' && typeof window.WebSocket !== 'undefined') { | ||
Ws = window.WebSocket; | ||
@@ -43,4 +43,14 @@ _btoa = btoa; | ||
}; | ||
// Web3 supports Node.js 5, so we need to use the legacy URL API | ||
parseURL = require('url').parse; | ||
var url = require('url'); | ||
if (url.URL) { | ||
// Use the new Node 6+ API for parsing URLs that supports username/password | ||
var newURL = url.URL; | ||
parseURL = function(url) { | ||
return new newURL(url); | ||
}; | ||
} | ||
else { | ||
// Web3 supports Node.js 5, so fall back to the legacy URL API if necessary | ||
parseURL = require('url').parse; | ||
} | ||
} | ||
@@ -65,2 +75,3 @@ // Default connection ws://localhost:8546 | ||
var headers = options.headers || {}; | ||
var protocol = options.protocol || undefined; | ||
if (parsedURL.username && parsedURL.password) { | ||
@@ -70,3 +81,3 @@ headers.authorization = 'Basic ' + _btoa(parsedURL.username + ':' + parsedURL.password); | ||
this.connection = new Ws(url, undefined, undefined, headers); | ||
this.connection = new Ws(url, protocol, undefined, headers); | ||
@@ -109,2 +120,10 @@ this.addDefaultEvents(); | ||
}; | ||
// make property `connected` which will return the current connection status | ||
Object.defineProperty(this, 'connected', { | ||
get: function () { | ||
return this.connection && this.connection.readyState === this.connection.OPEN; | ||
}, | ||
enumerable: true, | ||
}); | ||
}; | ||
@@ -111,0 +130,0 @@ |
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
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
12025
3
304
+ Addedweb3-core-helpers@1.0.0-beta.35(transitive)
+ Addedweb3-eth-iban@1.0.0-beta.35(transitive)
+ Addedweb3-utils@1.0.0-beta.35(transitive)
- Removedweb3-core-helpers@1.0.0-beta.34(transitive)
- Removedweb3-eth-iban@1.0.0-beta.34(transitive)
- Removedweb3-utils@1.0.0-beta.34(transitive)