Socket
Socket
Sign inDemoInstall

chrome-net

Package Overview
Dependencies
1
Maintainers
2
Versions
42
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.2.0 to 3.3.0

81

index.js

@@ -145,3 +145,3 @@ /*global chrome */

this.on('connection', connectionListener)
} else {
} else if (options == null || typeof options === 'object') {
options = options || {}

@@ -152,2 +152,4 @@

}
} else {
throw new TypeError('options must be an object')
}

@@ -167,3 +169,3 @@

this.id = null // a number > 0
this._connecting = false
this.connecting = false

@@ -260,5 +262,3 @@ this.allowHalfOpen = options.allowHalfOpen || false

// If port is invalid or undefined, bind to a random port.
if (typeof port !== 'undefined' && !isLegalPort(port)) {
throw new RangeError('"port" option should be >= 0 and < 65536: ' + port)
}
assertPort(port)
this._port = port | 0

@@ -275,6 +275,6 @@

this._connecting = true
this.connecting = true
chrome.sockets.tcpServer.create((createInfo) => {
if (!this._connecting || this.id) {
if (!this.connecting || this.id) {
ignoreLastError()

@@ -316,3 +316,3 @@ chrome.sockets.tcpServer.close(createInfo.socketId)

Server.prototype._onListen = function (result) {
this._connecting = false
this.connecting = false

@@ -341,5 +341,7 @@ if (result === 0) {

this.emit('error', exceptionWithHostPort(result, 'listen', this._host, this._port))
chrome.sockets.tcpServer.close(this.id)
delete servers[this.id]
this.id = null
if (this.id) {
chrome.sockets.tcpServer.close(this.id)
delete servers[this.id]
this.id = null
}
}

@@ -395,3 +397,3 @@ }

this._address = null
this._connecting = false
this.connecting = false

@@ -404,3 +406,3 @@ this._emitCloseIfDrained()

Server.prototype._emitCloseIfDrained = function () {
if (this.id || this._connecting || this._connections) {
if (this.id || this.connecting || this._connections) {
return

@@ -413,3 +415,3 @@ }

function emitCloseNT (self) {
if (self.id || self._connecting || self._connections) {
if (self.id || self.connecting || self._connections) {
return

@@ -575,3 +577,3 @@ }

// For incoming sockets (from server), it's already connected.
this._connecting = true
this.connecting = true
this.writable = true

@@ -601,3 +603,3 @@ this._onConnect()

this.readable = this.writable = false
this._connecting = false
this.connecting = false
}

@@ -658,3 +660,3 @@

this._connecting = true
this.connecting = true
this.writable = true

@@ -684,3 +686,3 @@

chrome.sockets.tcp.create((createInfo) => {
if (!this._connecting || this.id) {
if (!this.connecting || this.id) {
ignoreLastError()

@@ -738,3 +740,3 @@ chrome.sockets.tcp.close(createInfo.socketId)

this._connecting = false
this.connecting = false
this.readable = true

@@ -771,3 +773,3 @@

if (this._connecting) {
if (this.connecting) {
this._pendingData = chunk

@@ -809,3 +811,3 @@ this.once('connect', () => this._write(chunk, encoding, callback))

Socket.prototype._read = function (bufferSize) {
if (this._connecting || !this.id) {
if (this.connecting || !this.id) {
this.once('connect', () => this._read(bufferSize))

@@ -830,3 +832,3 @@ return

Socket.prototype._onReceive = function (data) {
var buffer = new Buffer(data)
var buffer = Buffer.from(data)
var offset = this.bytesRead

@@ -859,2 +861,10 @@

function protoGetter (name, callback) {
Object.defineProperty(Socket.prototype, name, {
configurable: false,
enumerable: true,
get: callback
})
}
/**

@@ -864,6 +874,4 @@ * The amount of bytes sent.

*/
Object.defineProperty(Socket.prototype, 'bytesWritten', {
get: function () {
if (this.id) return this._bytesDispatched + this.bufferSize
}
protoGetter('bytesWritten', function bytesWritten () {
if (this.id) return this._bytesDispatched + this.bufferSize
})

@@ -1035,5 +1043,11 @@

Object.defineProperty(Socket.prototype, '_connecting', {
get: function () {
return this.connecting
}
})
Object.defineProperty(Socket.prototype, 'readyState', {
get: function () {
if (this._connecting) {
if (this.connecting) {
return 'opening'

@@ -1109,6 +1123,15 @@ } else if (this.readable && this.writable) {

function isLegalPort (port) {
if (typeof port === 'string' && port.trim() === '') return false
return +port === (port >>> 0) && port >= 0 && port <= 0xFFFF
if ((typeof port !== 'number' && typeof port !== 'string') ||
(typeof port === 'string' && port.trim().length === 0)) {
return false
}
return +port === (+port >>> 0) && port <= 0xFFFF
}
function assertPort (port) {
if (typeof port !== 'undefined' && !isLegalPort(port)) {
throw new RangeError('"port" argument must be >= 0 and < 65536')
}
}
// This prevents "Unchecked runtime.lastError" errors

@@ -1115,0 +1138,0 @@ function ignoreLastError () {

{
"name": "chrome-net",
"description": "Use the Node `net` API in Chrome Apps",
"version": "3.2.0",
"version": "3.3.0",
"author": "Feross Aboukhadijeh <feross@feross.org> (http://feross.org/)",

@@ -22,4 +22,4 @@ "bugs": {

"portfinder": "^1.0.2",
"run-auto": "^1.1.3",
"standard": "^6.0.8",
"run-auto": "^2.0.0",
"standard": "^7.1.2",
"tape": "^4.0.0",

@@ -26,0 +26,0 @@ "through": "2.x"

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc