From 111b48b2492cbeb40be6da7886296b3baf15bc18 Mon Sep 17 00:00:00 2001 From: Alessandro Vergani Date: Tue, 26 Jan 2016 17:03:11 +0100 Subject: [PATCH 001/114] Add optional params for scans and connections --- lib/hci-socket/bindings.js | 15 ++++++++++----- lib/hci-socket/gap.js | 4 ++++ lib/hci-socket/hci.js | 24 ++++++++++++++++-------- lib/noble.js | 8 ++++++-- 4 files changed, 36 insertions(+), 15 deletions(-) diff --git a/lib/hci-socket/bindings.js b/lib/hci-socket/bindings.js index fb809ca2a..6255e2fb4 100644 --- a/lib/hci-socket/bindings.js +++ b/lib/hci-socket/bindings.js @@ -30,6 +30,10 @@ var NobleBindings = function() { util.inherits(NobleBindings, events.EventEmitter); +NobleBindings.prototype.setScanParameters = function(interval, window) { + this._gap.setScanParameters(interval, window); +} + NobleBindings.prototype.startScanning = function(serviceUuids, allowDuplicates) { this._scanServiceUuids = serviceUuids || []; @@ -40,16 +44,16 @@ NobleBindings.prototype.stopScanning = function() { this._gap.stopScanning(); }; -NobleBindings.prototype.connect = function(peripheralUuid) { +NobleBindings.prototype.connect = function(peripheralUuid, parameters) { var address = this._addresses[peripheralUuid]; var addressType = this._addresseTypes[peripheralUuid]; if (!this._pendingConnectionUuid) { this._pendingConnectionUuid = peripheralUuid; - this._hci.createLeConn(address, addressType); + this._hci.createLeConn(address, addressType, parameters); } else { - this._connectionQueue.push(peripheralUuid); + this._connectionQueue.push({ id: peripheralUuid, params: parameters }); } }; @@ -212,14 +216,15 @@ NobleBindings.prototype.onLeConnComplete = function(status, handle, role, addres this.emit('connect', uuid, error); if (this._connectionQueue.length > 0) { - var peripheralUuid = this._connectionQueue.shift(); + var queueItem = this._connectionQueue.shift(); + var peripheralUuid = queueItem.id; address = this._addresses[peripheralUuid]; addressType = this._addresseTypes[peripheralUuid]; this._pendingConnectionUuid = peripheralUuid; - this._hci.createLeConn(address, addressType); + this._hci.createLeConn(address, addressType, queueItem.params); } else { this._pendingConnectionUuid = null; } diff --git a/lib/hci-socket/gap.js b/lib/hci-socket/gap.js index adb7c318c..646c48217 100644 --- a/lib/hci-socket/gap.js +++ b/lib/hci-socket/gap.js @@ -17,6 +17,10 @@ var Gap = function(hci) { util.inherits(Gap, events.EventEmitter); +Gap.prototype.setScanParameters = function (interval, window) { + this._hci.setScanParameters(interval, window); +} + Gap.prototype.startScanning = function(allowDuplicates) { this._scanState = 'starting'; diff --git a/lib/hci-socket/hci.js b/lib/hci-socket/hci.js index 5ec0c3b07..dce0e1a59 100644 --- a/lib/hci-socket/hci.js +++ b/lib/hci-socket/hci.js @@ -224,7 +224,10 @@ Hci.prototype.writeLeHostSupported = function() { this._socket.write(cmd); }; -Hci.prototype.setScanParameters = function() { +Hci.prototype.setScanParameters = function (interval, window) { + interval = interval || 0x0010; + window = window || 0x0010; + var cmd = new Buffer(11); // header @@ -236,8 +239,8 @@ Hci.prototype.setScanParameters = function() { // data cmd.writeUInt8(0x01, 4); // type: 0 -> passive, 1 -> active - cmd.writeUInt16LE(0x0010, 5); // internal, ms * 1.6 - cmd.writeUInt16LE(0x0010, 7); // window, ms * 1.6 + cmd.writeUInt16LE(interval, 5); // interval, ms * 1.6 + cmd.writeUInt16LE(window, 7); // window, ms * 1.6 cmd.writeUInt8(0x00, 9); // own address type: 0 -> public, 1 -> random cmd.writeUInt8(0x00, 10); // filter: 0 -> all event types @@ -263,7 +266,12 @@ Hci.prototype.setScanEnabled = function(enabled, filterDuplicates) { this._socket.write(cmd); }; -Hci.prototype.createLeConn = function(address, addressType) { +Hci.prototype.createLeConn = function(address, addressType, parameters) { + var minInterval = parameters && parameters.minInterval || 0x0006; + var maxInterval = parameters && parameters.maxInterval || 0x000c; + var latency = parameters && parameters.latency || 0x0000; + var timeout = parameters && parameters.timeout || 0x00c8; + var cmd = new Buffer(29); // header @@ -283,10 +291,10 @@ Hci.prototype.createLeConn = function(address, addressType) { cmd.writeUInt8(0x00, 16); // own address type - cmd.writeUInt16LE(0x0006, 17); // min interval - cmd.writeUInt16LE(0x000c, 19); // max interval - cmd.writeUInt16LE(0x0000, 21); // latency - cmd.writeUInt16LE(0x00c8, 23); // supervision timeout + cmd.writeUInt16LE(minInterval, 17); // min interval + cmd.writeUInt16LE(maxInterval, 19); // max interval + cmd.writeUInt16LE(latency, 21); // latency + cmd.writeUInt16LE(timeout, 23); // supervision timeout cmd.writeUInt16LE(0x0004, 25); // min ce length cmd.writeUInt16LE(0x0006, 27); // max ce length diff --git a/lib/noble.js b/lib/noble.js index 282131187..6bd290fe7 100644 --- a/lib/noble.js +++ b/lib/noble.js @@ -83,6 +83,10 @@ Noble.prototype.onAddressChange = function(address) { this.address = address; }; +Noble.prototype.setScanParameters = function(interval, window) { + this._bindings.setScanParameters(interval, window); +} + Noble.prototype.startScanning = function(serviceUuids, allowDuplicates, callback) { if (this.state !== 'poweredOn') { var error = new Error('Could not start scanning, state is ' + this.state + ' (not poweredOn)'); @@ -153,8 +157,8 @@ Noble.prototype.onDiscover = function(uuid, address, addressType, connectable, a } }; -Noble.prototype.connect = function(peripheralUuid) { - this._bindings.connect(peripheralUuid); +Noble.prototype.connect = function(peripheralUuid, parameters) { + this._bindings.connect(peripheralUuid, parameters); }; Noble.prototype.onConnect = function(peripheralUuid, error) { From 9378c107efcf32ce619c7d930bb1204f69975290 Mon Sep 17 00:00:00 2001 From: Alessandro Vergani Date: Tue, 26 Jan 2016 17:12:55 +0100 Subject: [PATCH 002/114] Add callback for setScanParameters --- lib/hci-socket/bindings.js | 5 +++++ lib/hci-socket/gap.js | 2 +- lib/noble.js | 11 ++++++++++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/lib/hci-socket/bindings.js b/lib/hci-socket/bindings.js index 6255e2fb4..4c239985e 100644 --- a/lib/hci-socket/bindings.js +++ b/lib/hci-socket/bindings.js @@ -71,6 +71,7 @@ NobleBindings.prototype.init = function() { process.on('SIGINT', this.onSigIntBinded); process.on('exit', this.onExit.bind(this)); + this._gap.on('scanParametersSet', this.onScanParametersSet.bind(this)); this._gap.on('scanStart', this.onScanStart.bind(this)); this._gap.on('scanStop', this.onScanStop.bind(this)); this._gap.on('discover', this.onDiscover.bind(this)); @@ -129,6 +130,10 @@ NobleBindings.prototype.onAddressChange = function(address) { this.emit('addressChange', address); }; +NobleBindings.prototype.onScanParametersSet = function() { + this.emit('scanParametersSet'); +}; + NobleBindings.prototype.onScanStart = function() { this.emit('scanStart'); }; diff --git a/lib/hci-socket/gap.js b/lib/hci-socket/gap.js index 646c48217..970589e15 100644 --- a/lib/hci-socket/gap.js +++ b/lib/hci-socket/gap.js @@ -38,7 +38,7 @@ Gap.prototype.onHciError = function(error) { }; Gap.prototype.onHciLeScanParametersSet = function() { - + this.emit('scanParametersSet'); }; Gap.prototype.onHciLeScanEnableSet = function() { diff --git a/lib/noble.js b/lib/noble.js index 6bd290fe7..7ffbd2b71 100644 --- a/lib/noble.js +++ b/lib/noble.js @@ -38,6 +38,7 @@ function Noble() { this._bindings.on('stateChange', this.onStateChange.bind(this)); this._bindings.on('addressChange', this.onAddressChange.bind(this)); + this._bindings.on('scanParametersSet', this.onScanParametersSet.bind(this)); this._bindings.on('scanStart', this.onScanStart.bind(this)); this._bindings.on('scanStop', this.onScanStop.bind(this)); this._bindings.on('discover', this.onDiscover.bind(this)); @@ -83,10 +84,18 @@ Noble.prototype.onAddressChange = function(address) { this.address = address; }; -Noble.prototype.setScanParameters = function(interval, window) { +Noble.prototype.setScanParameters = function(interval, window, callback) { + if (callback) { + this.once('scanParametersSet', callback); + } this._bindings.setScanParameters(interval, window); } +Noble.prototype.onScanParametersSet = function() { + debug('scanParametersSet'); + this.emit('scanParametersSet'); +}; + Noble.prototype.startScanning = function(serviceUuids, allowDuplicates, callback) { if (this.state !== 'poweredOn') { var error = new Error('Could not start scanning, state is ' + this.state + ' (not poweredOn)'); From 4859dd0cf8e886b123c5a5f57b6eebe3501e8741 Mon Sep 17 00:00:00 2001 From: Alessandro Vergani Date: Tue, 26 Jan 2016 17:31:06 +0100 Subject: [PATCH 003/114] Add params to peripheral connect --- lib/peripheral.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/peripheral.js b/lib/peripheral.js index 48e7b12c3..b582f7124 100644 --- a/lib/peripheral.js +++ b/lib/peripheral.js @@ -32,7 +32,11 @@ Peripheral.prototype.toString = function() { }); }; -Peripheral.prototype.connect = function(callback) { +Peripheral.prototype.connect = function (options, callback) { + if (typeof options === 'function') { + callback = options; + options = undefined; + } if (callback) { this.once('connect', function(error) { callback(error); @@ -43,7 +47,7 @@ Peripheral.prototype.connect = function(callback) { this.emit('connect', new Error('Peripheral already connected')); } else { this.state = 'connecting'; - this._noble.connect(this.id); + this._noble.connect(this.id, options); } }; From 2628750b05b803c976959bd23bf7dd6f373b6585 Mon Sep 17 00:00:00 2001 From: Jan Schmidle Date: Mon, 27 Mar 2017 14:39:56 +0200 Subject: [PATCH 004/114] allow constructor parameters for hci socket --- lib/hci-socket/hci.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/lib/hci-socket/hci.js b/lib/hci-socket/hci.js index b0cbc2e2d..445e33672 100644 --- a/lib/hci-socket/hci.js +++ b/lib/hci-socket/hci.js @@ -71,14 +71,18 @@ var HCI_OE_USER_ENDED_CONNECTION = 0x13; var STATUS_MAPPER = require('./hci-status'); -var Hci = function() { +var Hci = function(options) { this._socket = new BluetoothHciSocket(); this._isDevUp = null; this._state = null; - this._deviceId = null; this._handleBuffers = {}; + this._deviceId = options.deviceId || + process.env.NOBLE_HCI_DEVICE_ID ? parseInt(process.env.NOBLE_HCI_DEVICE_ID, 10) : undefined; + + this._userChannel = typeof options.userChannel === 'undefined' && process.env.HCI_CHANNEL_USER || options.userChannel; + this.on('stateChange', this.onStateChange.bind(this)); }; @@ -86,19 +90,17 @@ util.inherits(Hci, events.EventEmitter); Hci.STATUS_MAPPER = STATUS_MAPPER; -Hci.prototype.init = function() { +Hci.prototype.init = function(options) { this._socket.on('data', this.onSocketData.bind(this)); this._socket.on('error', this.onSocketError.bind(this)); - var deviceId = process.env.NOBLE_HCI_DEVICE_ID ? parseInt(process.env.NOBLE_HCI_DEVICE_ID, 10) : undefined; - - if (process.env.HCI_CHANNEL_USER) { - this._deviceId = this._socket.bindUser(deviceId); + if (this._userChannel) { + this._socket.bindUser(this._deviceId); this._socket.start(); this.reset(); } else { - this._deviceId = this._socket.bindRaw(deviceId); + this._socket.bindRaw(this._deviceId); this._socket.start(); this.pollIsDevUp(); From a53e848c8d73822da9bc0ddd50c13e58b28a812e Mon Sep 17 00:00:00 2001 From: Jan Schmidle Date: Wed, 29 Mar 2017 05:15:32 +0200 Subject: [PATCH 005/114] fixed uninitialized options --- lib/hci-socket/hci.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/hci-socket/hci.js b/lib/hci-socket/hci.js index 445e33672..15dfee3bc 100644 --- a/lib/hci-socket/hci.js +++ b/lib/hci-socket/hci.js @@ -72,6 +72,7 @@ var HCI_OE_USER_ENDED_CONNECTION = 0x13; var STATUS_MAPPER = require('./hci-status'); var Hci = function(options) { + options = options || {}; this._socket = new BluetoothHciSocket(); this._isDevUp = null; this._state = null; From edb5366ae47740f12c816f1146e1d43b000965c4 Mon Sep 17 00:00:00 2001 From: Jan Schmidle Date: Mon, 27 Mar 2017 14:40:06 +0200 Subject: [PATCH 006/114] cleanup --- lib/hci-socket/hci.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/hci-socket/hci.js b/lib/hci-socket/hci.js index 15dfee3bc..2dcf1db4f 100644 --- a/lib/hci-socket/hci.js +++ b/lib/hci-socket/hci.js @@ -168,7 +168,7 @@ Hci.prototype.reset = function() { // header cmd.writeUInt8(HCI_COMMAND_PKT, 0); - cmd.writeUInt16LE(OCF_RESET | OGF_HOST_CTL << 10, 1); + cmd.writeUInt16LE(RESET_CMD, 1); // length cmd.writeUInt8(0x00, 3); From 67da99907d7402c13ba55fb85cb1945cf88edf31 Mon Sep 17 00:00:00 2001 From: Jan Schmidle Date: Fri, 31 Mar 2017 12:23:03 +0200 Subject: [PATCH 007/114] options for bindings (breaks mac support for now) --- lib/distributed/bindings.js | 2 +- lib/hci-socket/bindings.js | 6 +++--- lib/resolve-bindings.js | 10 +++++----- lib/webbluetooth/bindings.js | 4 +--- lib/websocket/bindings.js | 2 +- 5 files changed, 11 insertions(+), 13 deletions(-) diff --git a/lib/distributed/bindings.js b/lib/distributed/bindings.js index 39f07a1a4..ece737b6e 100644 --- a/lib/distributed/bindings.js +++ b/lib/distributed/bindings.js @@ -322,4 +322,4 @@ NobleBindings.prototype.writeHandle = function(deviceUuid, handle, data, without }); }; -module.exports = new NobleBindings(); +module.exports = NobleBindings; diff --git a/lib/hci-socket/bindings.js b/lib/hci-socket/bindings.js index c4436a440..073d91fe7 100644 --- a/lib/hci-socket/bindings.js +++ b/lib/hci-socket/bindings.js @@ -10,7 +10,7 @@ var Hci = require('./hci'); var Signaling = require('./signaling'); -var NobleBindings = function() { +var NobleBindings = function(options) { this._state = null; this._addresses = {}; @@ -25,7 +25,7 @@ var NobleBindings = function() { this._aclStreams = {}; this._signalings = {}; - this._hci = new Hci(); + this._hci = new Hci(options); this._gap = new Gap(this._hci); }; @@ -508,4 +508,4 @@ NobleBindings.prototype.onConnectionParameterUpdateRequest = function(handle, mi this._hci.connUpdateLe(handle, minInterval, maxInterval, latency, supervisionTimeout); }; -module.exports = new NobleBindings(); +module.exports = NobleBindings; diff --git a/lib/resolve-bindings.js b/lib/resolve-bindings.js index 36752fa85..84ffc68b3 100644 --- a/lib/resolve-bindings.js +++ b/lib/resolve-bindings.js @@ -1,16 +1,16 @@ var os = require('os'); -module.exports = function() { +module.exports = function(options) { var platform = os.platform(); if (process.env.NOBLE_WEBSOCKET) { - return require('./websocket/bindings'); + return new require('./websocket/bindings')(options); } else if (process.env.NOBLE_DISTRIBUTED) { - return require('./distributed/bindings'); + return new require('./distributed/bindings')(options); } else if (platform === 'darwin') { - return require('./mac/bindings'); + return new require('./mac/bindings')(options); } else if (platform === 'linux' || platform === 'freebsd' || platform === 'win32') { - return require('./hci-socket/bindings'); + return new require('./hci-socket/bindings')(options); } else { throw new Error('Unsupported platform'); } diff --git a/lib/webbluetooth/bindings.js b/lib/webbluetooth/bindings.js index 1032fcd7f..a66118d64 100644 --- a/lib/webbluetooth/bindings.js +++ b/lib/webbluetooth/bindings.js @@ -399,6 +399,4 @@ NobleBindings.prototype.writeHandle = function(deviceUuid, handle, data, without //this.emit('handleWrite', deviceUuid, handle); }; -var nobleBindings = new NobleBindings(); - -module.exports = nobleBindings; +module.exports = NobleBindings; diff --git a/lib/websocket/bindings.js b/lib/websocket/bindings.js index 8ec7a6157..4063a049a 100644 --- a/lib/websocket/bindings.js +++ b/lib/websocket/bindings.js @@ -311,4 +311,4 @@ NobleBindings.prototype.writeHandle = function(deviceUuid, handle, data, without }); }; -module.exports = new NobleBindings(); +module.exports = NobleBindings; From 0bca1d1d635eb2fc836aeb1850fd3c3293bc9e43 Mon Sep 17 00:00:00 2001 From: Jan Schmidle Date: Mon, 17 Jul 2017 20:47:29 +0200 Subject: [PATCH 008/114] update README --- README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/README.md b/README.md index 64be70aa9..10f6f2c09 100644 --- a/README.md +++ b/README.md @@ -467,6 +467,20 @@ Example, specify ```hci1```: sudo NOBLE_HCI_DEVICE_ID=1 node .js ``` +If you are using multiple HCI devices in one setup you can run two instances of noble with different binding configurations by initializing them seperatly in code: + +``` +const HCIBindings = require('noble/lib/hci-socket/bindings'); +const Noble = require('noble/lib/noble'); + +const params = { + deviceId: 0, + userChannel: true +}; + +const noble = new Noble(new HCIBindings(params)); +``` + ### Reporting all HCI events By default noble waits for both the advertisement data and scan response data for each Bluetooth address. If your device does not use scan response the following environment variable can be used to bypass it. From b3bac2f6b4783a295fbdb3b8cde01ad49b4c0dcb Mon Sep 17 00:00:00 2001 From: Jan Schmidle Date: Wed, 29 Mar 2017 21:28:07 +0200 Subject: [PATCH 009/114] added connection canceling to hci lib --- lib/hci-socket/hci.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/hci-socket/hci.js b/lib/hci-socket/hci.js index b0cbc2e2d..4dce3e113 100644 --- a/lib/hci-socket/hci.js +++ b/lib/hci-socket/hci.js @@ -45,6 +45,7 @@ var OCF_LE_SET_EVENT_MASK = 0x0001; var OCF_LE_SET_SCAN_PARAMETERS = 0x000b; var OCF_LE_SET_SCAN_ENABLE = 0x000c; var OCF_LE_CREATE_CONN = 0x000d; +var OCF_LE_CANCEL_CONN = 0x000e; var OCF_LE_CONN_UPDATE = 0x0013; var OCF_LE_START_ENCRYPTION = 0x0019; @@ -65,6 +66,7 @@ var LE_SET_SCAN_PARAMETERS_CMD = OCF_LE_SET_SCAN_PARAMETERS | OGF_LE_CTL << 10; var LE_SET_SCAN_ENABLE_CMD = OCF_LE_SET_SCAN_ENABLE | OGF_LE_CTL << 10; var LE_CREATE_CONN_CMD = OCF_LE_CREATE_CONN | OGF_LE_CTL << 10; var LE_CONN_UPDATE_CMD = OCF_LE_CONN_UPDATE | OGF_LE_CTL << 10; +var LE_CANCEL_CONN_CMD = OCF_LE_CANCEL_CONN | OGF_LE_CTL << 10; var LE_START_ENCRYPTION_CMD = OCF_LE_START_ENCRYPTION | OGF_LE_CTL << 10; var HCI_OE_USER_ENDED_CONNECTION = 0x13; @@ -345,6 +347,20 @@ Hci.prototype.connUpdateLe = function(handle, minInterval, maxInterval, latency, this._socket.write(cmd); }; +Hci.prototype.cancelConnect = function() { + var cmd = new Buffer(4); + + // header + cmd.writeUInt8(HCI_COMMAND_PKT, 0); + cmd.writeUInt16LE(LE_CANCEL_CONN_CMD, 1); + + // length + cmd.writeUInt8(0x0, 3); + + debug('cancel le conn - writing: ' + cmd.toString('hex')); + this._socket.write(cmd); +}; + Hci.prototype.startLeEncryption = function(handle, random, diversifier, key) { var cmd = new Buffer(32); From a84ed2724a13eff01a8c0eb1826e651db48cb4d4 Mon Sep 17 00:00:00 2001 From: Jan Schmidle Date: Sun, 2 Apr 2017 20:05:39 +0200 Subject: [PATCH 010/114] added 5.0 error messages --- lib/hci-socket/hci-status.json | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/hci-socket/hci-status.json b/lib/hci-socket/hci-status.json index 3cef0e762..00f96eeeb 100644 --- a/lib/hci-socket/hci-status.json +++ b/lib/hci-socket/hci-status.json @@ -63,5 +63,9 @@ "Connection Terminated due to MIC Failure", "Connection Failed to be Established", "MAC Connection Failed", - "Coarse Clock Adjustment Rejected but Will Try to Adjust Using Clock Dragging" + "Coarse Clock Adjustment Rejected but Will Try to Adjust Using Clock Dragging", + "Type0 Submap Not Defined", + "Unknown Advertising Identifier", + "Limit Reached", + "Operation Cancelled by Host" ] \ No newline at end of file From b11a438aed51a8b9f33fcf78ceedb3467471f3e0 Mon Sep 17 00:00:00 2001 From: Jan Schmidle Date: Mon, 17 Jul 2017 21:18:05 +0200 Subject: [PATCH 011/114] added CI --- .gitlab-ci.yml | 12 ++++++++++++ package.json | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 .gitlab-ci.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 000000000..57adbe795 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,12 @@ +npmpublish: + image: node:8 + script: + - npm install -g npm-cli-login + - npm-cli-login -u ${NPM_USER} -p ${NPM_PASS} -e ci@gitlab.io-labs.de -r https://npm.essentim.cloud -s @essentim --quotes + - npm publish + only: + - production + - staging + - master + tags: + - amd64 diff --git a/package.json b/package.json index dc35711e7..32d3234f7 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "author": "Sandeep Mistry ", "license": "MIT", - "name": "noble", + "name": "@cospired/github/noble", "description": "A Node.js BLE (Bluetooth Low Energy) central library.", "version": "1.8.1", "repository": { From e3a0530bb0a6fdaaf460c53fa2dfd8819c974db3 Mon Sep 17 00:00:00 2001 From: Jan Schmidle Date: Mon, 17 Jul 2017 22:35:20 +0200 Subject: [PATCH 012/114] fixed package name --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 32d3234f7..b3ff11084 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "author": "Sandeep Mistry ", "license": "MIT", - "name": "@cospired/github/noble", + "name": "@cospired/noble", "description": "A Node.js BLE (Bluetooth Low Energy) central library.", "version": "1.8.1", "repository": { From 0ac3c0f8649af86d283aadfb4c2b08effd7dc8da Mon Sep 17 00:00:00 2001 From: Jan Schmidle Date: Mon, 17 Jul 2017 22:44:36 +0200 Subject: [PATCH 013/114] fix name again --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b3ff11084..dc35711e7 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "author": "Sandeep Mistry ", "license": "MIT", - "name": "@cospired/noble", + "name": "noble", "description": "A Node.js BLE (Bluetooth Low Energy) central library.", "version": "1.8.1", "repository": { From 3bd30650fe791e9d17a6a641312d79087d851aaf Mon Sep 17 00:00:00 2001 From: Jan Schmidle Date: Thu, 17 May 2018 23:11:20 +0200 Subject: [PATCH 014/114] read descriptors longer then mtu size --- lib/hci-socket/gatt.js | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/lib/hci-socket/gatt.js b/lib/hci-socket/gatt.js index 6c2624ef5..c07975707 100644 --- a/lib/hci-socket/gatt.js +++ b/lib/hci-socket/gatt.js @@ -696,13 +696,26 @@ Gatt.prototype.discoverDescriptors = function(serviceUuid, characteristicUuid) { Gatt.prototype.readValue = function(serviceUuid, characteristicUuid, descriptorUuid) { var descriptor = this._descriptors[serviceUuid][characteristicUuid][descriptorUuid]; - this._queueCommand(this.readRequest(descriptor.handle), function(data) { + var readData = new Buffer(0); + + var callback = function(data) { var opcode = data[0]; - if (opcode === ATT_OP_READ_RESP) { - this.emit('valueRead', this._address, serviceUuid, characteristicUuid, descriptorUuid, data.slice(1)); + if (opcode === ATT_OP_READ_RESP || opcode === ATT_OP_READ_BLOB_RESP) { + var totalLength = readData.length + data.length - 1; + readData = Buffer.concat([readData, data.slice(1)], totalLength); + + if (data.length === this._mtu) { + this._queueCommand(this.readBlobRequest(descriptor.handle, readData.length), callback); + } else { + this.emit('valueRead', this._address, serviceUuid, characteristicUuid, descriptorUuid, readData); + } + } else { + this.emit('valueRead', this._address, serviceUuid, characteristicUuid, descriptorUuid, readData); } - }.bind(this)); + }.bind(this); + + this._queueCommand(this.readRequest(descriptor.handle), callback); }; Gatt.prototype.writeValue = function(serviceUuid, characteristicUuid, descriptorUuid, data) { From a97ed2a4e8cd0ee7ea9ed1f098c07dee13312743 Mon Sep 17 00:00:00 2001 From: Jan Schmidle Date: Fri, 18 May 2018 14:30:02 +0200 Subject: [PATCH 015/114] fix descriptor descovery --- lib/hci-socket/gatt.js | 41 +++++++++++++++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 8 deletions(-) diff --git a/lib/hci-socket/gatt.js b/lib/hci-socket/gatt.js index c07975707..3178d5012 100644 --- a/lib/hci-socket/gatt.js +++ b/lib/hci-socket/gatt.js @@ -655,6 +655,17 @@ Gatt.prototype.notify = function(serviceUuid, characteristicUuid, notify) { }.bind(this)); }; +function reverse (src) { + var buffer = new Buffer(src.length) + + for (var i = 0, j = src.length - 1; i <= j; ++i, --j) { + buffer[i] = src[j] + buffer[j] = src[i] + } + + return buffer +} + Gatt.prototype.discoverDescriptors = function(serviceUuid, characteristicUuid) { var characteristic = this._characteristics[serviceUuid][characteristicUuid]; var descriptors = []; @@ -663,16 +674,30 @@ Gatt.prototype.discoverDescriptors = function(serviceUuid, characteristicUuid) { var callback = function(data) { var opcode = data[0]; - var i = 0; if (opcode === ATT_OP_FIND_INFO_RESP) { - var num = data[1]; - - for (i = 0; i < num; i++) { - descriptors.push({ - handle: data.readUInt16LE(2 + i * 4 + 0), - uuid: data.readUInt16LE(2 + i * 4 + 2).toString(16) - }); + var format = data[1]; + var pos = 2; // skip first 2 bytes (opcode, format) + + while( data.length > pos ) { + + switch(format) { + case 1: + descriptors.push({ + handle: data.readUInt16LE(pos), + uuid: data.readUInt16LE(pos + 2).toString(16) + }); + pos = pos + 4; + break; + + case 2: + descriptors.push({ + handle: data.readUInt16LE(pos), + uuid: reverse(data.slice(pos + 2, pos + 2 + 16)).toString('hex') + }); + pos = pos + 18; + break; + } } } From 4fcf07bc51fc74639cadcb4d88ea3773257915b3 Mon Sep 17 00:00:00 2001 From: Jan Schmidle Date: Tue, 12 Jun 2018 12:16:13 +0200 Subject: [PATCH 016/114] on cancel connect at peripheral --- lib/hci-socket/bindings.js | 6 ++++++ lib/noble.js | 4 ++++ lib/peripheral.js | 20 ++++++++++++++++++++ 3 files changed, 30 insertions(+) diff --git a/lib/hci-socket/bindings.js b/lib/hci-socket/bindings.js index 321354969..fde079cc7 100644 --- a/lib/hci-socket/bindings.js +++ b/lib/hci-socket/bindings.js @@ -59,6 +59,12 @@ NobleBindings.prototype.connect = function(peripheralUuid, parameters) { } }; +NobleBindings.prototype.cancelConnect = function(peripheralUuid) { + // TODO: check if it was not in the queue and only then issue cancel on hci + this._connectionQueue = this._connectionQueue.filter( c => c.id !== peripheralUuid ); + this._hci.cancelConnect(this._handles[peripheralUuid]); +}; + NobleBindings.prototype.disconnect = function(peripheralUuid) { this._hci.disconnect(this._handles[peripheralUuid]); }; diff --git a/lib/noble.js b/lib/noble.js index 3d689e65a..08bd10589 100644 --- a/lib/noble.js +++ b/lib/noble.js @@ -203,6 +203,10 @@ Noble.prototype.onConnect = function(peripheralUuid, error) { } }; +Noble.prototype.cancelConnect = function(peripheralUuid, parameters) { + this._bindings.cancelConnect(peripheralUuid, parameters); +}; + Noble.prototype.disconnect = function(peripheralUuid) { this._bindings.disconnect(peripheralUuid); }; diff --git a/lib/peripheral.js b/lib/peripheral.js index b582f7124..a22661aa8 100644 --- a/lib/peripheral.js +++ b/lib/peripheral.js @@ -51,6 +51,26 @@ Peripheral.prototype.connect = function (options, callback) { } }; +Peripheral.prototype.cancelConnect = function (options, callback) { + if (typeof options === 'function') { + callback = options; + options = undefined; + } + // if (callback) { + // this.once('cancelConnect', function(error) { + // callback(error); + // }); + // } + + if (this.state !== 'connecting') { + // this.emit('cancelConnect', new Error('Peripheral currently not connecting')); + } else { + // this.state = 'connecting'; + this.emit('connect', new Error('connection canceled!')); + this._noble.cancelConnect(this.id, options); + } +}; + Peripheral.prototype.disconnect = function(callback) { if (callback) { this.once('disconnect', function() { From 7e35d97580198d0c76a30d02ee4c7894528d7c31 Mon Sep 17 00:00:00 2001 From: broon Date: Fri, 26 Oct 2018 16:42:15 +0200 Subject: [PATCH 017/114] Update hci.js allow ```option.deviceId``` to be int 0. previous check returned false and falled back to ENV configuration --- lib/hci-socket/hci.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/hci-socket/hci.js b/lib/hci-socket/hci.js index e7f025901..3427e3b02 100644 --- a/lib/hci-socket/hci.js +++ b/lib/hci-socket/hci.js @@ -81,8 +81,9 @@ var Hci = function(options) { this._handleBuffers = {}; - this._deviceId = options.deviceId || - process.env.NOBLE_HCI_DEVICE_ID ? parseInt(process.env.NOBLE_HCI_DEVICE_ID, 10) : undefined; + this._deviceId = options.deviceId != null ? parseInt(options.deviceId, 10) : + process.env.NOBLE_HCI_DEVICE_ID ? parseInt(process.env.NOBLE_HCI_DEVICE_ID, 10) : + undefined; this._userChannel = typeof options.userChannel === 'undefined' && process.env.HCI_CHANNEL_USER || options.userChannel; From 90333d1ac288ae7d36a469daca7df2686e6d7abf Mon Sep 17 00:00:00 2001 From: Philippe Coval Date: Tue, 18 Dec 2018 19:32:55 +0100 Subject: [PATCH 018/114] npm: Pin versions for node-8 Node-10 to be then supported Origin: https://github.com/noble/noble/pull/851/commits/e2c476ec0c44d457dca22abf698f03787509c7ed Forwarded: https://github.com/noble/noble/pull/851 Change-Id: I3c20732e71456cbe2b33509ccf2e0b72ca75442f Signed-off-by: Philippe Coval --- package-lock.json | 859 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 859 insertions(+) create mode 100644 package-lock.json diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 000000000..8896a98b9 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,859 @@ +{ + "name": "noble", + "version": "1.9.1", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "abbrev": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", + "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==", + "optional": true + }, + "ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=" + }, + "aproba": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/aproba/-/aproba-1.2.0.tgz", + "integrity": "sha512-Y9J6ZjXtoYh8RnXVCMOU/ttDmk1aBjunq9vO0ta5x85WDQiQfUF9sIPBITdbiiIVcBo03Hi3jMxigBtsddlXRw==", + "optional": true + }, + "are-we-there-yet": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-1.1.5.tgz", + "integrity": "sha512-5hYdAkZlcG8tOLujVDTgCT+uPX0VnpAH28gWsLfzpXYm7wP6mp5Q/gYyR7YQ0cKVJcXJnl3j2kpBan13PtQf6w==", + "optional": true, + "requires": { + "delegates": "^1.0.0", + "readable-stream": "^2.0.6" + } + }, + "async": { + "version": "0.2.10", + "resolved": "http://registry.npmjs.org/async/-/async-0.2.10.tgz", + "integrity": "sha1-trvgsGdLnXGXCMo43owjfLUmw9E=", + "dev": true + }, + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" + }, + "bluetooth-hci-socket": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/bluetooth-hci-socket/-/bluetooth-hci-socket-0.5.1.tgz", + "integrity": "sha1-774hUk/Bz10/rl1RNl1WHUq77Qs=", + "optional": true, + "requires": { + "debug": "^2.2.0", + "nan": "^2.0.5", + "usb": "^1.1.0" + } + }, + "bplist-parser": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/bplist-parser/-/bplist-parser-0.0.6.tgz", + "integrity": "sha1-ONo0cYF9+dRKs4kuJ3B7u9daEbk=", + "optional": true + }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "buster-core": { + "version": "0.6.4", + "resolved": "https://registry.npmjs.org/buster-core/-/buster-core-0.6.4.tgz", + "integrity": "sha1-J79rrWdCROpyDzEdkAoMoct4YFA=", + "dev": true + }, + "buster-format": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/buster-format/-/buster-format-0.5.6.tgz", + "integrity": "sha1-K4bDIuz14bCubm55Bev884fSq5U=", + "dev": true, + "requires": { + "buster-core": "=0.6.4" + } + }, + "chownr": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.1.tgz", + "integrity": "sha512-j38EvO5+LHX84jlo6h4UzmOwi0UgW61WRyPtJz4qaadK5eY3BTS5TY/S1Stc3Uk2lIM6TPevAlULiEJwie860g==", + "optional": true + }, + "cli": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/cli/-/cli-1.0.1.tgz", + "integrity": "sha1-IoF1NPJL+klQw01TLUjsvGIbjBQ=", + "dev": true, + "requires": { + "exit": "0.1.2", + "glob": "^7.1.1" + } + }, + "code-point-at": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", + "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=" + }, + "commander": { + "version": "0.6.1", + "resolved": "http://registry.npmjs.org/commander/-/commander-0.6.1.tgz", + "integrity": "sha1-+mihT2qUXVTbvlDYzbMyDp47GgY=", + "dev": true + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" + }, + "console-browserify": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/console-browserify/-/console-browserify-1.1.0.tgz", + "integrity": "sha1-8CQcRXMKn8YyOyBtvzjtx0HQuxA=", + "dev": true, + "requires": { + "date-now": "^0.1.4" + } + }, + "console-control-strings": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", + "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=" + }, + "core-util-is": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" + }, + "date-now": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/date-now/-/date-now-0.1.4.tgz", + "integrity": "sha1-6vQ5/U1ISK105cx9vvIAZyueNFs=", + "dev": true + }, + "debug": { + "version": "2.2.0", + "resolved": "http://registry.npmjs.org/debug/-/debug-2.2.0.tgz", + "integrity": "sha1-+HBX6ZWxofauaklgZkE3vFbwOdo=", + "requires": { + "ms": "0.7.1" + } + }, + "deep-extend": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.6.0.tgz", + "integrity": "sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==", + "optional": true + }, + "delegates": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz", + "integrity": "sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o=", + "optional": true + }, + "detect-libc": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-1.0.3.tgz", + "integrity": "sha1-+hN8S9aY7fVc1c0CrFWfkaTEups=", + "optional": true + }, + "diff": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/diff/-/diff-1.0.2.tgz", + "integrity": "sha1-Suc/Gu6Nb89ITxoc53zmUdm38Mk=", + "dev": true + }, + "dom-serializer": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-0.1.0.tgz", + "integrity": "sha1-BzxpdUbOB4DOI75KKOKT5AvDDII=", + "dev": true, + "requires": { + "domelementtype": "~1.1.1", + "entities": "~1.1.1" + }, + "dependencies": { + "domelementtype": { + "version": "1.1.3", + "resolved": "http://registry.npmjs.org/domelementtype/-/domelementtype-1.1.3.tgz", + "integrity": "sha1-vSh3PiZCiBrsUVRJJCmcXNgiGFs=", + "dev": true + }, + "entities": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/entities/-/entities-1.1.2.tgz", + "integrity": "sha512-f2LZMYl1Fzu7YSBKg+RoROelpOaNrcGmE9AZubeDfrCEia483oW4MI4VyFd5VNHIgQ/7qm1I0wUHK1eJnn2y2w==", + "dev": true + } + } + }, + "domelementtype": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-1.3.1.tgz", + "integrity": "sha512-BSKB+TSpMpFI/HOxCNr1O8aMOTZ8hT3pM3GQ0w/mWRmkhEDSFJkkyzz4XQsBV44BChwGkrDfMyjVD0eA2aFV3w==", + "dev": true + }, + "domhandler": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-2.3.0.tgz", + "integrity": "sha1-LeWaCCLVAn+r/28DLCsloqir5zg=", + "dev": true, + "requires": { + "domelementtype": "1" + } + }, + "domutils": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/domutils/-/domutils-1.5.1.tgz", + "integrity": "sha1-3NhIiib1Y9YQeeSMn3t+Mjc2gs8=", + "dev": true, + "requires": { + "dom-serializer": "0", + "domelementtype": "1" + } + }, + "entities": { + "version": "1.0.0", + "resolved": "http://registry.npmjs.org/entities/-/entities-1.0.0.tgz", + "integrity": "sha1-sph6o4ITR/zeZCsk/fyeT7cSvyY=", + "dev": true + }, + "exit": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/exit/-/exit-0.1.2.tgz", + "integrity": "sha1-BjJjj42HfMghB9MKD/8aF8uhzQw=", + "dev": true + }, + "fs-minipass": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-1.2.5.tgz", + "integrity": "sha512-JhBl0skXjUPCFH7x6x61gQxrKyXsxB5gcgePLZCwfyCGGsTISMoIeObbrvVeP6Xmyaudw4TT43qV2Gz+iyd2oQ==", + "optional": true, + "requires": { + "minipass": "^2.2.1" + } + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" + }, + "gauge": { + "version": "2.7.4", + "resolved": "https://registry.npmjs.org/gauge/-/gauge-2.7.4.tgz", + "integrity": "sha1-LANAXHU4w51+s3sxcCLjJfsBi/c=", + "optional": true, + "requires": { + "aproba": "^1.0.3", + "console-control-strings": "^1.0.0", + "has-unicode": "^2.0.0", + "object-assign": "^4.1.0", + "signal-exit": "^3.0.0", + "string-width": "^1.0.1", + "strip-ansi": "^3.0.1", + "wide-align": "^1.1.0" + } + }, + "glob": { + "version": "7.1.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.3.tgz", + "integrity": "sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ==", + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "growl": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/growl/-/growl-1.7.0.tgz", + "integrity": "sha1-3i1mE20ALhErpw8/EMMc98NQsto=", + "dev": true + }, + "has-unicode": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/has-unicode/-/has-unicode-2.0.1.tgz", + "integrity": "sha1-4Ob+aijPUROIVeCG0Wkedx3iqLk=", + "optional": true + }, + "htmlparser2": { + "version": "3.8.3", + "resolved": "http://registry.npmjs.org/htmlparser2/-/htmlparser2-3.8.3.tgz", + "integrity": "sha1-mWwosZFRaovoZQGn15dX5ccMEGg=", + "dev": true, + "requires": { + "domelementtype": "1", + "domhandler": "2.3", + "domutils": "1.5", + "entities": "1.0", + "readable-stream": "1.1" + }, + "dependencies": { + "isarray": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", + "dev": true + }, + "readable-stream": { + "version": "1.1.14", + "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", + "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", + "dev": true, + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.1", + "isarray": "0.0.1", + "string_decoder": "~0.10.x" + } + }, + "string_decoder": { + "version": "0.10.31", + "resolved": "http://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", + "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", + "dev": true + } + } + }, + "iconv-lite": { + "version": "0.4.24", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "optional": true, + "requires": { + "safer-buffer": ">= 2.1.2 < 3" + } + }, + "ignore-walk": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/ignore-walk/-/ignore-walk-3.0.1.tgz", + "integrity": "sha512-DTVlMx3IYPe0/JJcYP7Gxg7ttZZu3IInhuEhbchuqneY9wWe5Ojy2mXLBaQFUQmo0AW2r3qG7m1mg86js+gnlQ==", + "optional": true, + "requires": { + "minimatch": "^3.0.4" + } + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" + }, + "ini": { + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", + "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==", + "optional": true + }, + "is-fullwidth-code-point": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", + "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", + "requires": { + "number-is-nan": "^1.0.0" + } + }, + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", + "optional": true + }, + "jade": { + "version": "0.26.3", + "resolved": "https://registry.npmjs.org/jade/-/jade-0.26.3.tgz", + "integrity": "sha1-jxDXl32NefL2/4YqgbBRPMslaGw=", + "dev": true, + "requires": { + "commander": "0.6.1", + "mkdirp": "0.3.0" + }, + "dependencies": { + "mkdirp": { + "version": "0.3.0", + "resolved": "http://registry.npmjs.org/mkdirp/-/mkdirp-0.3.0.tgz", + "integrity": "sha1-G79asbqCevI1dRQ0kEJkVfSB/h4=", + "dev": true + } + } + }, + "jshint": { + "version": "2.9.7", + "resolved": "https://registry.npmjs.org/jshint/-/jshint-2.9.7.tgz", + "integrity": "sha512-Q8XN38hGsVQhdlM+4gd1Xl7OB1VieSuCJf+fEJjpo59JH99bVJhXRXAh26qQ15wfdd1VPMuDWNeSWoNl53T4YA==", + "dev": true, + "requires": { + "cli": "~1.0.0", + "console-browserify": "1.1.x", + "exit": "0.1.x", + "htmlparser2": "3.8.x", + "lodash": "~4.17.10", + "minimatch": "~3.0.2", + "shelljs": "0.3.x", + "strip-json-comments": "1.0.x" + }, + "dependencies": { + "strip-json-comments": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-1.0.4.tgz", + "integrity": "sha1-HhX7ysl9Pumb8tc7TGVrCCu6+5E=", + "dev": true + } + } + }, + "lodash": { + "version": "4.17.11", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", + "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==", + "dev": true + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "minimist": { + "version": "0.0.8", + "resolved": "http://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" + }, + "minipass": { + "version": "2.3.5", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-2.3.5.tgz", + "integrity": "sha512-Gi1W4k059gyRbyVUZQ4mEqLm0YIUiGYfvxhF6SIlk3ui1WVxMTGfGdQ2SInh3PDrRTVvPKgULkpJtT4RH10+VA==", + "requires": { + "safe-buffer": "^5.1.2", + "yallist": "^3.0.0" + } + }, + "minizlib": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-1.2.1.tgz", + "integrity": "sha512-7+4oTUOWKg7AuL3vloEWekXY2/D20cevzsrNT2kGWm+39J9hGTCBv8VI5Pm5lXZ/o3/mdR4f8rflAPhnQb8mPA==", + "optional": true, + "requires": { + "minipass": "^2.2.1" + } + }, + "mkdirp": { + "version": "0.5.1", + "resolved": "http://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "requires": { + "minimist": "0.0.8" + } + }, + "mocha": { + "version": "1.8.2", + "resolved": "http://registry.npmjs.org/mocha/-/mocha-1.8.2.tgz", + "integrity": "sha1-+2sdB9mPLrpBhUaETDvgcx9145A=", + "dev": true, + "requires": { + "commander": "0.6.1", + "debug": "*", + "diff": "1.0.2", + "growl": "1.7.x", + "jade": "0.26.3", + "mkdirp": "0.3.3", + "ms": "0.3.0" + }, + "dependencies": { + "mkdirp": { + "version": "0.3.3", + "resolved": "http://registry.npmjs.org/mkdirp/-/mkdirp-0.3.3.tgz", + "integrity": "sha1-WV4lHBNww6aLqyE20ONIuBBa3xM=", + "dev": true + }, + "ms": { + "version": "0.3.0", + "resolved": "http://registry.npmjs.org/ms/-/ms-0.3.0.tgz", + "integrity": "sha1-A+3DSNYT5mpWSGz9rFO8vomcvWE=", + "dev": true + } + } + }, + "ms": { + "version": "0.7.1", + "resolved": "http://registry.npmjs.org/ms/-/ms-0.7.1.tgz", + "integrity": "sha1-nNE8A62/8ltl7/3nzoZO6VIBcJg=" + }, + "nan": { + "version": "2.12.0", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.12.0.tgz", + "integrity": "sha512-zT5nC0JhbljmyEf+Z456nvm7iO7XgRV2hYxoBtPpnyp+0Q4aCoP6uWNn76v/I6k2kCYNLWqWbwBWQcjsNI/bjw==", + "optional": true + }, + "needle": { + "version": "2.2.4", + "resolved": "https://registry.npmjs.org/needle/-/needle-2.2.4.tgz", + "integrity": "sha512-HyoqEb4wr/rsoaIDfTH2aVL9nWtQqba2/HvMv+++m8u0dz808MaagKILxtfeSN7QU7nvbQ79zk3vYOJp9zsNEA==", + "optional": true, + "requires": { + "debug": "^2.1.2", + "iconv-lite": "^0.4.4", + "sax": "^1.2.4" + } + }, + "node-pre-gyp": { + "version": "0.11.0", + "resolved": "https://registry.npmjs.org/node-pre-gyp/-/node-pre-gyp-0.11.0.tgz", + "integrity": "sha512-TwWAOZb0j7e9eGaf9esRx3ZcLaE5tQ2lvYy1pb5IAaG1a2e2Kv5Lms1Y4hpj+ciXJRofIxxlt5haeQ/2ANeE0Q==", + "optional": true, + "requires": { + "detect-libc": "^1.0.2", + "mkdirp": "^0.5.1", + "needle": "^2.2.1", + "nopt": "^4.0.1", + "npm-packlist": "^1.1.6", + "npmlog": "^4.0.2", + "rc": "^1.2.7", + "rimraf": "^2.6.1", + "semver": "^5.3.0", + "tar": "^4" + } + }, + "nopt": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/nopt/-/nopt-4.0.1.tgz", + "integrity": "sha1-0NRoWv1UFRk8jHUFYC0NF81kR00=", + "optional": true, + "requires": { + "abbrev": "1", + "osenv": "^0.1.4" + } + }, + "npm-bundled": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/npm-bundled/-/npm-bundled-1.0.5.tgz", + "integrity": "sha512-m/e6jgWu8/v5niCUKQi9qQl8QdeEduFA96xHDDzFGqly0OOjI7c+60KM/2sppfnUU9JJagf+zs+yGhqSOFj71g==", + "optional": true + }, + "npm-packlist": { + "version": "1.1.12", + "resolved": "https://registry.npmjs.org/npm-packlist/-/npm-packlist-1.1.12.tgz", + "integrity": "sha512-WJKFOVMeAlsU/pjXuqVdzU0WfgtIBCupkEVwn+1Y0ERAbUfWw8R4GjgVbaKnUjRoD2FoQbHOCbOyT5Mbs9Lw4g==", + "optional": true, + "requires": { + "ignore-walk": "^3.0.1", + "npm-bundled": "^1.0.1" + } + }, + "npmlog": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-4.1.2.tgz", + "integrity": "sha512-2uUqazuKlTaSI/dC8AzicUck7+IrEaOnN/e0jd3Xtt1KcGpwx30v50mL7oPyr/h9bL3E4aZccVwpwP+5W9Vjkg==", + "optional": true, + "requires": { + "are-we-there-yet": "~1.1.2", + "console-control-strings": "~1.1.0", + "gauge": "~2.7.3", + "set-blocking": "~2.0.0" + } + }, + "number-is-nan": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", + "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=" + }, + "object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", + "optional": true + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "requires": { + "wrappy": "1" + } + }, + "options": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/options/-/options-0.0.6.tgz", + "integrity": "sha1-7CLTEoBrtT5zF3Pnza788cZDEo8=", + "dev": true + }, + "os-homedir": { + "version": "1.0.2", + "resolved": "http://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz", + "integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=", + "optional": true + }, + "os-tmpdir": { + "version": "1.0.2", + "resolved": "http://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", + "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=", + "optional": true + }, + "osenv": { + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/osenv/-/osenv-0.1.5.tgz", + "integrity": "sha512-0CWcCECdMVc2Rw3U5w9ZjqX6ga6ubk1xDVKxtBQPK7wis/0F2r9T6k4ydGYhecl7YUBxBVxhL5oisPsNxAPe2g==", + "optional": true, + "requires": { + "os-homedir": "^1.0.0", + "os-tmpdir": "^1.0.0" + } + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "http://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" + }, + "process-nextick-args": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", + "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==", + "optional": true + }, + "rc": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/rc/-/rc-1.2.8.tgz", + "integrity": "sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw==", + "optional": true, + "requires": { + "deep-extend": "^0.6.0", + "ini": "~1.3.0", + "minimist": "^1.2.0", + "strip-json-comments": "~2.0.1" + }, + "dependencies": { + "minimist": { + "version": "1.2.0", + "resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", + "optional": true + } + } + }, + "readable-stream": { + "version": "2.3.6", + "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", + "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", + "optional": true, + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "rimraf": { + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", + "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", + "optional": true, + "requires": { + "glob": "^7.0.5" + } + }, + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + }, + "safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", + "optional": true + }, + "sax": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz", + "integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==", + "optional": true + }, + "semver": { + "version": "5.6.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.6.0.tgz", + "integrity": "sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg==", + "optional": true + }, + "set-blocking": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", + "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=", + "optional": true + }, + "shelljs": { + "version": "0.3.0", + "resolved": "http://registry.npmjs.org/shelljs/-/shelljs-0.3.0.tgz", + "integrity": "sha1-NZbmMHp4FUT1kfN9phg2DzHbV7E=", + "dev": true + }, + "should": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/should/-/should-1.2.2.tgz", + "integrity": "sha1-DwP3dQZtnqJjJpDJF7EoJPzB1YI=", + "dev": true + }, + "signal-exit": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", + "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=", + "optional": true + }, + "sinon": { + "version": "1.6.0", + "resolved": "http://registry.npmjs.org/sinon/-/sinon-1.6.0.tgz", + "integrity": "sha1-V3sBfYaUO4xCU31awuhjcw9YzJs=", + "dev": true, + "requires": { + "buster-format": "~0.5" + } + }, + "string-width": { + "version": "1.0.2", + "resolved": "http://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", + "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", + "requires": { + "code-point-at": "^1.0.0", + "is-fullwidth-code-point": "^1.0.0", + "strip-ansi": "^3.0.0" + } + }, + "string_decoder": { + "version": "1.1.1", + "resolved": "http://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "optional": true, + "requires": { + "safe-buffer": "~5.1.0" + } + }, + "strip-ansi": { + "version": "3.0.1", + "resolved": "http://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "requires": { + "ansi-regex": "^2.0.0" + } + }, + "strip-json-comments": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", + "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=", + "optional": true + }, + "tar": { + "version": "4.4.8", + "resolved": "https://registry.npmjs.org/tar/-/tar-4.4.8.tgz", + "integrity": "sha512-LzHF64s5chPQQS0IYBn9IN5h3i98c12bo4NCO7e0sGM2llXQ3p2FGC5sdENN4cTW48O915Sh+x+EXx7XW96xYQ==", + "optional": true, + "requires": { + "chownr": "^1.1.1", + "fs-minipass": "^1.2.5", + "minipass": "^2.3.4", + "minizlib": "^1.1.1", + "mkdirp": "^0.5.0", + "safe-buffer": "^5.1.2", + "yallist": "^3.0.2" + } + }, + "tinycolor": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/tinycolor/-/tinycolor-0.0.1.tgz", + "integrity": "sha1-MgtaUtg6u1l42Bo+iH1K77FaYWQ=", + "dev": true + }, + "usb": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/usb/-/usb-1.5.0.tgz", + "integrity": "sha512-/0stiQEmweuO2BKv2avzQQ8ypDUjo4Osz5sSEi+d0F4Rc+ddX1xED3uf4Tkelc1eADlfn0JQZYHP0bI7CNDA0Q==", + "optional": true, + "requires": { + "nan": "^2.8.0", + "node-pre-gyp": "^0.11.0" + } + }, + "util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", + "optional": true + }, + "wide-align": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.3.tgz", + "integrity": "sha512-QGkOQc8XL6Bt5PwnsExKBPuMKBxnGxWWW3fU55Xt4feHozMUhdUMaBCk290qpm/wG5u/RSKzwdAC4i51YigihA==", + "optional": true, + "requires": { + "string-width": "^1.0.2 || 2" + } + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" + }, + "ws": { + "version": "0.4.32", + "resolved": "http://registry.npmjs.org/ws/-/ws-0.4.32.tgz", + "integrity": "sha1-eHphVEFPPJntg8V3IVOyD+sM7DI=", + "dev": true, + "requires": { + "commander": "~2.1.0", + "nan": "~1.0.0", + "options": ">=0.0.5", + "tinycolor": "0.x" + }, + "dependencies": { + "commander": { + "version": "2.1.0", + "resolved": "http://registry.npmjs.org/commander/-/commander-2.1.0.tgz", + "integrity": "sha1-0SG7roYNmZKj1Re6lvVliOR8Z4E=", + "dev": true + }, + "nan": { + "version": "1.0.0", + "resolved": "http://registry.npmjs.org/nan/-/nan-1.0.0.tgz", + "integrity": "sha1-riT4hQgY1mL8q1rPfzuVv6oszzg=", + "dev": true + } + } + }, + "xpc-connection": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/xpc-connection/-/xpc-connection-0.1.4.tgz", + "integrity": "sha1-3Nf6oq7Gt6bhjMXdrQQvejTHcVY=", + "optional": true, + "requires": { + "nan": "^2.0.5" + } + }, + "yallist": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.3.tgz", + "integrity": "sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A==" + } + } +} From 6ccb172d86e4b69733143f9bcc3bca38b7e5c30d Mon Sep 17 00:00:00 2001 From: Philippe Coval Date: Wed, 19 Dec 2018 14:44:53 +0100 Subject: [PATCH 019/114] travis: Prevent SSL issue on node 0.8 Change-Id: I84415cf2fe5f450fd6aab3429ea14c4cb816cb91 Origin: https://github.com/abandonware/noble/pull/1 Forwarded: https://github.com/noble/noble/pull/851 Signed-off-by: Philippe Coval --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index bb9bd07e3..7957a42db 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,6 +20,7 @@ before_install: export CC="g++-4.8"; fi - if [ $NODE_VERSION == "0.8" ]; then + npm config set strict-ssl false npm install -g npm@2; fi install: From c47da26aa29c283ad654fde15348076ce79dcdf9 Mon Sep 17 00:00:00 2001 From: Philippe Coval Date: Wed, 19 Dec 2018 15:08:12 +0100 Subject: [PATCH 020/114] travis: Drop support of node-0.8 Might be obsolete and it does not worth to keep maintaining it Relate-To: https://travis-ci.org/abandonware/noble/jobs/470026600 Change-Id: I04be1fa73626402bb81775b056cabde32ced0960 Origin: https://github.com/abandonware/noble/pull/1 Forwarded: https://github.com/noble/noble/pull/851 Signed-off-by: Philippe Coval --- .travis.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7957a42db..7b6054a23 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,6 @@ os: - osx language: cpp env: - - NODE_VERSION="0.8" - NODE_VERSION="0.10" - NODE_VERSION="0.12" - NODE_VERSION="4" @@ -19,10 +18,6 @@ before_install: - if [ $TRAVIS_OS_NAME == "linux" ]; then export CC="g++-4.8"; fi - - if [ $NODE_VERSION == "0.8" ]; then - npm config set strict-ssl false - npm install -g npm@2; - fi install: - npm install script: From c3b6d06594ce6074b4797dfd6ae287655bbcc5a0 Mon Sep 17 00:00:00 2001 From: Philippe Coval Date: Wed, 19 Dec 2018 15:46:49 +0100 Subject: [PATCH 021/114] npm: Set 0.10 as minimal engine Change-Id: I661e9105c313179526fe43585b78cf1156e1f0d9 Origin: https://github.com/abandonware/noble/pull/1 Forwarded: https://github.com/noble/noble/pull/851 Signed-off-by: Philippe Coval --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 905bc5fbf..73f01ef99 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ ], "main": "./index.js", "engines": { - "node": ">=0.8" + "node": ">=0.10" }, "os": [ "darwin", From 43a1019798a4f51d84fae7549add6b488cdca77e Mon Sep 17 00:00:00 2001 From: Philippe Coval Date: Tue, 18 Dec 2018 19:26:10 +0100 Subject: [PATCH 022/114] npm: Fork package for support node-10 Abandonware namespace was used Update bluetooth-hci-socket for node-10 Relate-to: https://github.com/noble/node-bluetooth-hci-socket/issues/84 Origin: https://github.com/abandonware/noble/pull/1 Change-Id: Ib32f0c00bb0e7dcb9a125261cd9db0d11c440c21 Signed-off-by: Philippe Coval --- README.md | 2 +- package-lock.json | 923 +++++++++++++++++++++++++++++++++++++++++++++- package.json | 4 +- 3 files changed, 914 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index b6d90565d..be85a5de4 100644 --- a/README.md +++ b/README.md @@ -100,7 +100,7 @@ You need to stop scanning before trying to connect in order to solve this issue. ## Install ```sh -npm install noble +npm install @abandonware/noble ``` ## Usage diff --git a/package-lock.json b/package-lock.json index 8896a98b9..6334be1dc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,9 +1,919 @@ { - "name": "noble", + "name": "@abandonware/noble", "version": "1.9.1", "lockfileVersion": 1, "requires": true, "dependencies": { + "@abandonware/bluetooth-hci-socket": { + "version": "0.5.3-0", + "resolved": "https://registry.npmjs.org/@abandonware/bluetooth-hci-socket/-/bluetooth-hci-socket-0.5.3-0.tgz", + "integrity": "sha512-TdGNGIQfcMdsBW4A70ONnvySLnooPhQJ57hXPQZn5Q1axLoDDKQ4nVTVNUjgyOUrKvy8PDMTd/iMIz6MV/PFtg==", + "optional": true, + "requires": { + "debug": "^2.2.0", + "nan": "^2.10.0", + "node-pre-gyp": "^0.6.39", + "usb": "^1.1.0" + }, + "dependencies": { + "abbrev": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", + "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==", + "optional": true + }, + "ajv": { + "version": "4.11.8", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-4.11.8.tgz", + "integrity": "sha1-gv+wKynmYq5TvcIK8VlHcGc5xTY=", + "optional": true, + "requires": { + "co": "^4.6.0", + "json-stable-stringify": "^1.0.1" + } + }, + "ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=" + }, + "aproba": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/aproba/-/aproba-1.2.0.tgz", + "integrity": "sha512-Y9J6ZjXtoYh8RnXVCMOU/ttDmk1aBjunq9vO0ta5x85WDQiQfUF9sIPBITdbiiIVcBo03Hi3jMxigBtsddlXRw==", + "optional": true + }, + "are-we-there-yet": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-1.1.5.tgz", + "integrity": "sha512-5hYdAkZlcG8tOLujVDTgCT+uPX0VnpAH28gWsLfzpXYm7wP6mp5Q/gYyR7YQ0cKVJcXJnl3j2kpBan13PtQf6w==", + "optional": true, + "requires": { + "delegates": "^1.0.0", + "readable-stream": "^2.0.6" + } + }, + "asn1": { + "version": "0.2.4", + "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.4.tgz", + "integrity": "sha512-jxwzQpLQjSmWXgwaCZE9Nz+glAG01yF1QnWgbhGwHI5A6FRIEY6IVqtHhIepHqI7/kyEyQEagBC5mBEFlIYvdg==", + "optional": true, + "requires": { + "safer-buffer": "~2.1.0" + } + }, + "assert-plus": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-0.2.0.tgz", + "integrity": "sha1-104bh+ev/A24qttwIfP+SBAasjQ=", + "optional": true + }, + "asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=", + "optional": true + }, + "aws-sign2": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.6.0.tgz", + "integrity": "sha1-FDQt0428yU0OW4fXY81jYSwOeU8=", + "optional": true + }, + "aws4": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.8.0.tgz", + "integrity": "sha512-ReZxvNHIOv88FlT7rxcXIIC0fPt4KZqZbOlivyWtXLt8ESx84zd3kMC6iK5jVeS2qt+g7ftS7ye4fi06X5rtRQ==", + "optional": true + }, + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" + }, + "bcrypt-pbkdf": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz", + "integrity": "sha1-pDAdOJtqQ/m2f/PKEaP2Y342Dp4=", + "optional": true, + "requires": { + "tweetnacl": "^0.14.3" + } + }, + "block-stream": { + "version": "0.0.9", + "resolved": "https://registry.npmjs.org/block-stream/-/block-stream-0.0.9.tgz", + "integrity": "sha1-E+v+d4oDIFz+A3UUgeu0szAMEmo=", + "requires": { + "inherits": "~2.0.0" + } + }, + "boom": { + "version": "2.10.1", + "resolved": "http://registry.npmjs.org/boom/-/boom-2.10.1.tgz", + "integrity": "sha1-OciRjO/1eZ+D+UkqhI9iWt0Mdm8=", + "requires": { + "hoek": "2.x.x" + } + }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "caseless": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", + "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=", + "optional": true + }, + "co": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", + "integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=", + "optional": true + }, + "code-point-at": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", + "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=" + }, + "combined-stream": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.7.tgz", + "integrity": "sha512-brWl9y6vOB1xYPZcpZde3N9zDByXTosAeMDo4p1wzo6UMOX4vumB+TP1RZ76sfE6Md68Q0NJSrE/gbezd4Ul+w==", + "requires": { + "delayed-stream": "~1.0.0" + } + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" + }, + "console-control-strings": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", + "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=" + }, + "core-util-is": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" + }, + "cryptiles": { + "version": "2.0.5", + "resolved": "http://registry.npmjs.org/cryptiles/-/cryptiles-2.0.5.tgz", + "integrity": "sha1-O9/s3GCBR8HGcgL6KR59ylnqo7g=", + "requires": { + "boom": "2.x.x" + } + }, + "dashdash": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", + "integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=", + "optional": true, + "requires": { + "assert-plus": "^1.0.0" + }, + "dependencies": { + "assert-plus": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", + "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=", + "optional": true + } + } + }, + "deep-extend": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.6.0.tgz", + "integrity": "sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==", + "optional": true + }, + "delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" + }, + "delegates": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz", + "integrity": "sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o=", + "optional": true + }, + "detect-libc": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-1.0.3.tgz", + "integrity": "sha1-+hN8S9aY7fVc1c0CrFWfkaTEups=", + "optional": true + }, + "ecc-jsbn": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz", + "integrity": "sha1-OoOpBOVDUyh4dMVkt1SThoSamMk=", + "optional": true, + "requires": { + "jsbn": "~0.1.0", + "safer-buffer": "^2.1.0" + } + }, + "extend": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", + "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==", + "optional": true + }, + "extsprintf": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz", + "integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=" + }, + "forever-agent": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", + "integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=", + "optional": true + }, + "form-data": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.1.4.tgz", + "integrity": "sha1-M8GDrPGTJ27KqYFDpp6Uv+4XUNE=", + "optional": true, + "requires": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.5", + "mime-types": "^2.1.12" + } + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" + }, + "fstream": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/fstream/-/fstream-1.0.11.tgz", + "integrity": "sha1-XB+x8RdHcRTwYyoOtLcbPLD9MXE=", + "requires": { + "graceful-fs": "^4.1.2", + "inherits": "~2.0.0", + "mkdirp": ">=0.5 0", + "rimraf": "2" + } + }, + "fstream-ignore": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/fstream-ignore/-/fstream-ignore-1.0.5.tgz", + "integrity": "sha1-nDHa40dnAY/h0kmyTa2mfQktoQU=", + "optional": true, + "requires": { + "fstream": "^1.0.0", + "inherits": "2", + "minimatch": "^3.0.0" + } + }, + "gauge": { + "version": "2.7.4", + "resolved": "https://registry.npmjs.org/gauge/-/gauge-2.7.4.tgz", + "integrity": "sha1-LANAXHU4w51+s3sxcCLjJfsBi/c=", + "optional": true, + "requires": { + "aproba": "^1.0.3", + "console-control-strings": "^1.0.0", + "has-unicode": "^2.0.0", + "object-assign": "^4.1.0", + "signal-exit": "^3.0.0", + "string-width": "^1.0.1", + "strip-ansi": "^3.0.1", + "wide-align": "^1.1.0" + } + }, + "getpass": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", + "integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=", + "optional": true, + "requires": { + "assert-plus": "^1.0.0" + }, + "dependencies": { + "assert-plus": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", + "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=", + "optional": true + } + } + }, + "glob": { + "version": "7.1.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.3.tgz", + "integrity": "sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ==", + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "graceful-fs": { + "version": "4.1.15", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.15.tgz", + "integrity": "sha512-6uHUhOPEBgQ24HM+r6b/QwWfZq+yiFcipKFrOFiBEnWdy5sdzYoi+pJeQaPI5qOLRFqWmAXUPQNsielzdLoecA==" + }, + "har-schema": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-1.0.5.tgz", + "integrity": "sha1-0mMTX0MwfALGAq/I/pWXDAFRNp4=", + "optional": true + }, + "har-validator": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-4.2.1.tgz", + "integrity": "sha1-M0gdDxu/9gDdID11gSpqX7oALio=", + "optional": true, + "requires": { + "ajv": "^4.9.1", + "har-schema": "^1.0.5" + } + }, + "has-unicode": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/has-unicode/-/has-unicode-2.0.1.tgz", + "integrity": "sha1-4Ob+aijPUROIVeCG0Wkedx3iqLk=", + "optional": true + }, + "hawk": { + "version": "3.1.3", + "resolved": "http://registry.npmjs.org/hawk/-/hawk-3.1.3.tgz", + "integrity": "sha1-B4REvXwWQLD+VA0sm3PVlnjo4cQ=", + "requires": { + "boom": "2.x.x", + "cryptiles": "2.x.x", + "hoek": "2.x.x", + "sntp": "1.x.x" + } + }, + "hoek": { + "version": "2.16.3", + "resolved": "http://registry.npmjs.org/hoek/-/hoek-2.16.3.tgz", + "integrity": "sha1-ILt0A9POo5jpHcRxCo/xuCdKJe0=" + }, + "http-signature": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.1.1.tgz", + "integrity": "sha1-33LiZwZs0Kxn+3at+OE0qPvPkb8=", + "optional": true, + "requires": { + "assert-plus": "^0.2.0", + "jsprim": "^1.2.2", + "sshpk": "^1.7.0" + } + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" + }, + "ini": { + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", + "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==", + "optional": true + }, + "is-fullwidth-code-point": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", + "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", + "requires": { + "number-is-nan": "^1.0.0" + } + }, + "is-typedarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", + "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=", + "optional": true + }, + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" + }, + "isstream": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", + "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=", + "optional": true + }, + "jsbn": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", + "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=" + }, + "json-schema": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz", + "integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM=", + "optional": true + }, + "json-stable-stringify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz", + "integrity": "sha1-mnWdOcXy/1A/1TAGRu1EX4jE+a8=", + "optional": true, + "requires": { + "jsonify": "~0.0.0" + } + }, + "json-stringify-safe": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", + "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=", + "optional": true + }, + "jsonify": { + "version": "0.0.0", + "resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz", + "integrity": "sha1-LHS27kHZPKUbe1qu6PUDYx0lKnM=", + "optional": true + }, + "jsprim": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz", + "integrity": "sha1-MT5mvB5cwG5Di8G3SZwuXFastqI=", + "optional": true, + "requires": { + "assert-plus": "1.0.0", + "extsprintf": "1.3.0", + "json-schema": "0.2.3", + "verror": "1.10.0" + }, + "dependencies": { + "assert-plus": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", + "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=", + "optional": true + } + } + }, + "mime-db": { + "version": "1.37.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.37.0.tgz", + "integrity": "sha512-R3C4db6bgQhlIhPU48fUtdVmKnflq+hRdad7IyKhtFj06VPNVdk2RhiYL3UjQIlso8L+YxAtFkobT0VK+S/ybg==" + }, + "mime-types": { + "version": "2.1.21", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.21.tgz", + "integrity": "sha512-3iL6DbwpyLzjR3xHSFNFeb9Nz/M8WDkX33t1GFQnFOllWk8pOrh/LSrB5OXlnlW5P9LH73X6loW/eogc+F5lJg==", + "requires": { + "mime-db": "~1.37.0" + } + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "minimist": { + "version": "0.0.8", + "resolved": "http://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" + }, + "mkdirp": { + "version": "0.5.1", + "resolved": "http://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "requires": { + "minimist": "0.0.8" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "optional": true + }, + "node-pre-gyp": { + "version": "0.6.39", + "resolved": "https://registry.npmjs.org/node-pre-gyp/-/node-pre-gyp-0.6.39.tgz", + "integrity": "sha512-OsJV74qxnvz/AMGgcfZoDaeDXKD3oY3QVIbBmwszTFkRisTSXbMQyn4UWzUMOtA5SVhrBZOTp0wcoSBgfMfMmQ==", + "optional": true, + "requires": { + "detect-libc": "^1.0.2", + "hawk": "3.1.3", + "mkdirp": "^0.5.1", + "nopt": "^4.0.1", + "npmlog": "^4.0.2", + "rc": "^1.1.7", + "request": "2.81.0", + "rimraf": "^2.6.1", + "semver": "^5.3.0", + "tar": "^2.2.1", + "tar-pack": "^3.4.0" + } + }, + "nopt": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/nopt/-/nopt-4.0.1.tgz", + "integrity": "sha1-0NRoWv1UFRk8jHUFYC0NF81kR00=", + "optional": true, + "requires": { + "abbrev": "1", + "osenv": "^0.1.4" + } + }, + "npmlog": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-4.1.2.tgz", + "integrity": "sha512-2uUqazuKlTaSI/dC8AzicUck7+IrEaOnN/e0jd3Xtt1KcGpwx30v50mL7oPyr/h9bL3E4aZccVwpwP+5W9Vjkg==", + "optional": true, + "requires": { + "are-we-there-yet": "~1.1.2", + "console-control-strings": "~1.1.0", + "gauge": "~2.7.3", + "set-blocking": "~2.0.0" + } + }, + "number-is-nan": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", + "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=" + }, + "oauth-sign": { + "version": "0.8.2", + "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.8.2.tgz", + "integrity": "sha1-Rqarfwrq2N6unsBWV4C31O/rnUM=", + "optional": true + }, + "object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", + "optional": true + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "requires": { + "wrappy": "1" + } + }, + "os-homedir": { + "version": "1.0.2", + "resolved": "http://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz", + "integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=", + "optional": true + }, + "os-tmpdir": { + "version": "1.0.2", + "resolved": "http://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", + "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=", + "optional": true + }, + "osenv": { + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/osenv/-/osenv-0.1.5.tgz", + "integrity": "sha512-0CWcCECdMVc2Rw3U5w9ZjqX6ga6ubk1xDVKxtBQPK7wis/0F2r9T6k4ydGYhecl7YUBxBVxhL5oisPsNxAPe2g==", + "optional": true, + "requires": { + "os-homedir": "^1.0.0", + "os-tmpdir": "^1.0.0" + } + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "http://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" + }, + "performance-now": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-0.2.0.tgz", + "integrity": "sha1-M+8wxcd9TqIcWlOGnZG1bY8lVeU=", + "optional": true + }, + "process-nextick-args": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", + "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==" + }, + "punycode": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", + "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=", + "optional": true + }, + "qs": { + "version": "6.4.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.4.0.tgz", + "integrity": "sha1-E+JtKK1rD/qpExLNO/cI7TUecjM=", + "optional": true + }, + "rc": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/rc/-/rc-1.2.8.tgz", + "integrity": "sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw==", + "optional": true, + "requires": { + "deep-extend": "^0.6.0", + "ini": "~1.3.0", + "minimist": "^1.2.0", + "strip-json-comments": "~2.0.1" + }, + "dependencies": { + "minimist": { + "version": "1.2.0", + "resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", + "optional": true + } + } + }, + "readable-stream": { + "version": "2.3.6", + "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", + "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "request": { + "version": "2.81.0", + "resolved": "https://registry.npmjs.org/request/-/request-2.81.0.tgz", + "integrity": "sha1-xpKJRqDgbF+Nb4qTM0af/aRimKA=", + "optional": true, + "requires": { + "aws-sign2": "~0.6.0", + "aws4": "^1.2.1", + "caseless": "~0.12.0", + "combined-stream": "~1.0.5", + "extend": "~3.0.0", + "forever-agent": "~0.6.1", + "form-data": "~2.1.1", + "har-validator": "~4.2.1", + "hawk": "~3.1.3", + "http-signature": "~1.1.0", + "is-typedarray": "~1.0.0", + "isstream": "~0.1.2", + "json-stringify-safe": "~5.0.1", + "mime-types": "~2.1.7", + "oauth-sign": "~0.8.1", + "performance-now": "^0.2.0", + "qs": "~6.4.0", + "safe-buffer": "^5.0.1", + "stringstream": "~0.0.4", + "tough-cookie": "~2.3.0", + "tunnel-agent": "^0.6.0", + "uuid": "^3.0.0" + } + }, + "rimraf": { + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", + "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", + "requires": { + "glob": "^7.0.5" + } + }, + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + }, + "safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" + }, + "semver": { + "version": "5.6.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.6.0.tgz", + "integrity": "sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg==", + "optional": true + }, + "set-blocking": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", + "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=", + "optional": true + }, + "signal-exit": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", + "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=", + "optional": true + }, + "sntp": { + "version": "1.0.9", + "resolved": "http://registry.npmjs.org/sntp/-/sntp-1.0.9.tgz", + "integrity": "sha1-ZUEYTMkK7qbG57NeJlkIJEPGYZg=", + "requires": { + "hoek": "2.x.x" + } + }, + "sshpk": { + "version": "1.15.2", + "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.15.2.tgz", + "integrity": "sha512-Ra/OXQtuh0/enyl4ETZAfTaeksa6BXks5ZcjpSUNrjBr0DvrJKX+1fsKDPpT9TBXgHAFsa4510aNVgI8g/+SzA==", + "optional": true, + "requires": { + "asn1": "~0.2.3", + "assert-plus": "^1.0.0", + "bcrypt-pbkdf": "^1.0.0", + "dashdash": "^1.12.0", + "ecc-jsbn": "~0.1.1", + "getpass": "^0.1.1", + "jsbn": "~0.1.0", + "safer-buffer": "^2.0.2", + "tweetnacl": "~0.14.0" + }, + "dependencies": { + "assert-plus": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", + "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=", + "optional": true + } + } + }, + "string-width": { + "version": "1.0.2", + "resolved": "http://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", + "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", + "requires": { + "code-point-at": "^1.0.0", + "is-fullwidth-code-point": "^1.0.0", + "strip-ansi": "^3.0.0" + } + }, + "string_decoder": { + "version": "1.1.1", + "resolved": "http://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "requires": { + "safe-buffer": "~5.1.0" + } + }, + "stringstream": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/stringstream/-/stringstream-0.0.6.tgz", + "integrity": "sha512-87GEBAkegbBcweToUrdzf3eLhWNg06FJTebl4BVJz/JgWy8CvEr9dRtX5qWphiynMSQlxxi+QqN0z5T32SLlhA==", + "optional": true + }, + "strip-ansi": { + "version": "3.0.1", + "resolved": "http://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "requires": { + "ansi-regex": "^2.0.0" + } + }, + "strip-json-comments": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", + "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=", + "optional": true + }, + "tar": { + "version": "2.2.1", + "resolved": "http://registry.npmjs.org/tar/-/tar-2.2.1.tgz", + "integrity": "sha1-jk0qJWwOIYXGsYrWlK7JaLg8sdE=", + "requires": { + "block-stream": "*", + "fstream": "^1.0.2", + "inherits": "2" + } + }, + "tar-pack": { + "version": "3.4.1", + "resolved": "https://registry.npmjs.org/tar-pack/-/tar-pack-3.4.1.tgz", + "integrity": "sha512-PPRybI9+jM5tjtCbN2cxmmRU7YmqT3Zv/UDy48tAh2XRkLa9bAORtSWLkVc13+GJF+cdTh1yEnHEk3cpTaL5Kg==", + "optional": true, + "requires": { + "debug": "^2.2.0", + "fstream": "^1.0.10", + "fstream-ignore": "^1.0.5", + "once": "^1.3.3", + "readable-stream": "^2.1.4", + "rimraf": "^2.5.1", + "tar": "^2.2.1", + "uid-number": "^0.0.6" + }, + "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "optional": true, + "requires": { + "ms": "2.0.0" + } + } + } + }, + "tough-cookie": { + "version": "2.3.4", + "resolved": "http://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.4.tgz", + "integrity": "sha512-TZ6TTfI5NtZnuyy/Kecv+CnoROnyXn2DN97LontgQpCwsX2XyLYCC0ENhYkehSOwAp8rTQKc/NUIF7BkQ5rKLA==", + "optional": true, + "requires": { + "punycode": "^1.4.1" + } + }, + "tunnel-agent": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", + "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=", + "optional": true, + "requires": { + "safe-buffer": "^5.0.1" + } + }, + "tweetnacl": { + "version": "0.14.5", + "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", + "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=" + }, + "uid-number": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/uid-number/-/uid-number-0.0.6.tgz", + "integrity": "sha1-DqEOgDXo61uOREnwbaHHMGY7qoE=", + "optional": true + }, + "util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" + }, + "uuid": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz", + "integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==", + "optional": true + }, + "verror": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz", + "integrity": "sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA=", + "optional": true, + "requires": { + "assert-plus": "^1.0.0", + "core-util-is": "1.0.2", + "extsprintf": "^1.2.0" + }, + "dependencies": { + "assert-plus": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", + "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=", + "optional": true + } + } + }, + "wide-align": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.3.tgz", + "integrity": "sha512-QGkOQc8XL6Bt5PwnsExKBPuMKBxnGxWWW3fU55Xt4feHozMUhdUMaBCk290qpm/wG5u/RSKzwdAC4i51YigihA==", + "optional": true, + "requires": { + "string-width": "^1.0.2 || 2" + } + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" + } + } + }, "abbrev": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", @@ -42,17 +952,6 @@ "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" }, - "bluetooth-hci-socket": { - "version": "0.5.1", - "resolved": "https://registry.npmjs.org/bluetooth-hci-socket/-/bluetooth-hci-socket-0.5.1.tgz", - "integrity": "sha1-774hUk/Bz10/rl1RNl1WHUq77Qs=", - "optional": true, - "requires": { - "debug": "^2.2.0", - "nan": "^2.0.5", - "usb": "^1.1.0" - } - }, "bplist-parser": { "version": "0.0.6", "resolved": "https://registry.npmjs.org/bplist-parser/-/bplist-parser-0.0.6.tgz", diff --git a/package.json b/package.json index 73f01ef99..6394e4f9a 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "Luis Montes" ], "license": "MIT", - "name": "noble", + "name": "@abandonware/noble", "description": "A Node.js BLE (Bluetooth Low Energy) central library.", "version": "1.9.1", "repository": { @@ -36,7 +36,7 @@ "debug": "~2.2.0" }, "optionalDependencies": { - "bluetooth-hci-socket": "^0.5.1", + "@abandonware/bluetooth-hci-socket": "^0.5.3-0", "bplist-parser": "0.0.6", "xpc-connection": "~0.1.4" }, From fdf263a0ffa536a95ba17a200b7d0788a5c1cd2d Mon Sep 17 00:00:00 2001 From: Philippe Coval Date: Wed, 19 Dec 2018 14:52:56 +0100 Subject: [PATCH 023/114] travis: Add node-10 remove 0.8 Change-Id: I96b7572a1872691dab80af70f1ebc811a50438fb Origin: https://github.com/abandonware/noble/pull/1 Signed-off-by: Philippe Coval --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 7b6054a23..4447778c4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,6 +8,7 @@ env: - NODE_VERSION="4" - NODE_VERSION="6" - NODE_VERSION="8" + - NODE_VERSION="10" matrix: fast_finish: true before_install: From bebaf499aa2500435774bb1d9540db9dce3cc9ce Mon Sep 17 00:00:00 2001 From: Philippe Coval Date: Wed, 19 Dec 2018 15:45:04 +0100 Subject: [PATCH 024/114] travis: Drop node-4 and earlier Origin: https://github.com/abandonware/noble/pull/1 Change-Id: I8eb04badb5ee427dab37e314fb43114f805f8064 Signed-off-by: Philippe Coval --- .travis.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4447778c4..4f14aeef0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,9 +3,6 @@ os: - osx language: cpp env: - - NODE_VERSION="0.10" - - NODE_VERSION="0.12" - - NODE_VERSION="4" - NODE_VERSION="6" - NODE_VERSION="8" - NODE_VERSION="10" From ff3e353f4eb94adc49ef0901bc2630bb9233da07 Mon Sep 17 00:00:00 2001 From: Philippe Coval Date: Wed, 19 Dec 2018 15:46:23 +0100 Subject: [PATCH 025/114] npm: Drop node-4 and earlier Origin: https://github.com/abandonware/noble/pull/1 Change-Id: Iab54f45109bb4a11e172f9d9de784a0d9d436766 Signed-off-by: Philippe Coval --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6394e4f9a..333834b77 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ ], "main": "./index.js", "engines": { - "node": ">=0.10" + "node": ">=6" }, "os": [ "darwin", From 2fc9ea7c9361255da69c0195814a9373cb44cdfb Mon Sep 17 00:00:00 2001 From: Philippe Coval Date: Wed, 19 Dec 2018 15:24:58 +0100 Subject: [PATCH 026/114] npm: Update vulnerable packages Then regen lock files. Origin: https://github.com/abandonware/noble/pull/1 Change-Id: I402476a21c76a2f51ee024830647afbcd2cdb36b Signed-off-by: Philippe Coval --- package-lock.json | 214 +++++++++++++++++++++++++++------------------- package.json | 8 +- 2 files changed, 130 insertions(+), 92 deletions(-) diff --git a/package-lock.json b/package-lock.json index 6334be1dc..8b03fcb1d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,7 +12,7 @@ "requires": { "debug": "^2.2.0", "nan": "^2.10.0", - "node-pre-gyp": "^0.6.39", + "node-pre-gyp": "0.6.x", "usb": "^1.1.0" }, "dependencies": { @@ -190,6 +190,15 @@ } } }, + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "optional": true, + "requires": { + "ms": "2.0.0" + } + }, "deep-extend": { "version": "0.6.0", "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.6.0.tgz", @@ -512,8 +521,7 @@ "ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", - "optional": true + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" }, "node-pre-gyp": { "version": "0.6.39", @@ -947,6 +955,12 @@ "integrity": "sha1-trvgsGdLnXGXCMo43owjfLUmw9E=", "dev": true }, + "async-limiter": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.0.tgz", + "integrity": "sha512-jp/uFnooOiO+L211eZOoSyzpOITMXx1rBITauYykG3BRYPu8h0UcxsPNB04RR5vo4Tyz3+ay17tR6JVf9qzYWg==", + "dev": true + }, "balanced-match": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", @@ -967,6 +981,12 @@ "concat-map": "0.0.1" } }, + "browser-stdout": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", + "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", + "dev": true + }, "buster-core": { "version": "0.6.4", "resolved": "https://registry.npmjs.org/buster-core/-/buster-core-0.6.4.tgz", @@ -1004,9 +1024,9 @@ "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=" }, "commander": { - "version": "0.6.1", - "resolved": "http://registry.npmjs.org/commander/-/commander-0.6.1.tgz", - "integrity": "sha1-+mihT2qUXVTbvlDYzbMyDp47GgY=", + "version": "2.15.1", + "resolved": "http://registry.npmjs.org/commander/-/commander-2.15.1.tgz", + "integrity": "sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag==", "dev": true }, "concat-map": { @@ -1040,11 +1060,11 @@ "dev": true }, "debug": { - "version": "2.2.0", - "resolved": "http://registry.npmjs.org/debug/-/debug-2.2.0.tgz", - "integrity": "sha1-+HBX6ZWxofauaklgZkE3vFbwOdo=", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.0.tgz", + "integrity": "sha512-heNPJUJIqC+xB6ayLAMHaIrmN9HKa7aQO8MGqKpvCA+uJYVcvR6l5kgdrhRuwPFHU7P5/A1w0BjByPHwpfTDKg==", "requires": { - "ms": "0.7.1" + "ms": "^2.1.1" } }, "deep-extend": { @@ -1066,9 +1086,9 @@ "optional": true }, "diff": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/diff/-/diff-1.0.2.tgz", - "integrity": "sha1-Suc/Gu6Nb89ITxoc53zmUdm38Mk=", + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", + "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==", "dev": true }, "dom-serializer": { @@ -1126,6 +1146,12 @@ "integrity": "sha1-sph6o4ITR/zeZCsk/fyeT7cSvyY=", "dev": true }, + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", + "dev": true + }, "exit": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/exit/-/exit-0.1.2.tgz", @@ -1176,9 +1202,15 @@ } }, "growl": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/growl/-/growl-1.7.0.tgz", - "integrity": "sha1-3i1mE20ALhErpw8/EMMc98NQsto=", + "version": "1.10.5", + "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz", + "integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==", + "dev": true + }, + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", "dev": true }, "has-unicode": { @@ -1187,6 +1219,12 @@ "integrity": "sha1-4Ob+aijPUROIVeCG0Wkedx3iqLk=", "optional": true }, + "he": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz", + "integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0=", + "dev": true + }, "htmlparser2": { "version": "3.8.3", "resolved": "http://registry.npmjs.org/htmlparser2/-/htmlparser2-3.8.3.tgz", @@ -1278,24 +1316,6 @@ "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", "optional": true }, - "jade": { - "version": "0.26.3", - "resolved": "https://registry.npmjs.org/jade/-/jade-0.26.3.tgz", - "integrity": "sha1-jxDXl32NefL2/4YqgbBRPMslaGw=", - "dev": true, - "requires": { - "commander": "0.6.1", - "mkdirp": "0.3.0" - }, - "dependencies": { - "mkdirp": { - "version": "0.3.0", - "resolved": "http://registry.npmjs.org/mkdirp/-/mkdirp-0.3.0.tgz", - "integrity": "sha1-G79asbqCevI1dRQ0kEJkVfSB/h4=", - "dev": true - } - } - }, "jshint": { "version": "2.9.7", "resolved": "https://registry.npmjs.org/jshint/-/jshint-2.9.7.tgz", @@ -1366,38 +1386,59 @@ } }, "mocha": { - "version": "1.8.2", - "resolved": "http://registry.npmjs.org/mocha/-/mocha-1.8.2.tgz", - "integrity": "sha1-+2sdB9mPLrpBhUaETDvgcx9145A=", + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-5.2.0.tgz", + "integrity": "sha512-2IUgKDhc3J7Uug+FxMXuqIyYzH7gJjXECKe/w43IGgQHTSj3InJi+yAA7T24L9bQMRKiUEHxEX37G5JpVUGLcQ==", "dev": true, "requires": { - "commander": "0.6.1", - "debug": "*", - "diff": "1.0.2", - "growl": "1.7.x", - "jade": "0.26.3", - "mkdirp": "0.3.3", - "ms": "0.3.0" + "browser-stdout": "1.3.1", + "commander": "2.15.1", + "debug": "3.1.0", + "diff": "3.5.0", + "escape-string-regexp": "1.0.5", + "glob": "7.1.2", + "growl": "1.10.5", + "he": "1.1.1", + "minimatch": "3.0.4", + "mkdirp": "0.5.1", + "supports-color": "5.4.0" }, "dependencies": { - "mkdirp": { - "version": "0.3.3", - "resolved": "http://registry.npmjs.org/mkdirp/-/mkdirp-0.3.3.tgz", - "integrity": "sha1-WV4lHBNww6aLqyE20ONIuBBa3xM=", - "dev": true + "debug": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "dev": true, + "requires": { + "ms": "2.0.0" + } + }, + "glob": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } }, "ms": { - "version": "0.3.0", - "resolved": "http://registry.npmjs.org/ms/-/ms-0.3.0.tgz", - "integrity": "sha1-A+3DSNYT5mpWSGz9rFO8vomcvWE=", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", "dev": true } } }, "ms": { - "version": "0.7.1", - "resolved": "http://registry.npmjs.org/ms/-/ms-0.7.1.tgz", - "integrity": "sha1-nNE8A62/8ltl7/3nzoZO6VIBcJg=" + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", + "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==" }, "nan": { "version": "2.12.0", @@ -1414,6 +1455,23 @@ "debug": "^2.1.2", "iconv-lite": "^0.4.4", "sax": "^1.2.4" + }, + "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "optional": true, + "requires": { + "ms": "2.0.0" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "optional": true + } } }, "node-pre-gyp": { @@ -1491,12 +1549,6 @@ "wrappy": "1" } }, - "options": { - "version": "0.0.6", - "resolved": "https://registry.npmjs.org/options/-/options-0.0.6.tgz", - "integrity": "sha1-7CLTEoBrtT5zF3Pnza788cZDEo8=", - "dev": true - }, "os-homedir": { "version": "1.0.2", "resolved": "http://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz", @@ -1663,6 +1715,15 @@ "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=", "optional": true }, + "supports-color": { + "version": "5.4.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.4.0.tgz", + "integrity": "sha512-zjaXglF5nnWpsq470jSv6P9DwPvgLkuapYmfDm3JWOm0vkNTVF2tI4UrN2r6jH1qM/uc/WtxYY1hYoA2dOKj5w==", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } + }, "tar": { "version": "4.4.8", "resolved": "https://registry.npmjs.org/tar/-/tar-4.4.8.tgz", @@ -1678,12 +1739,6 @@ "yallist": "^3.0.2" } }, - "tinycolor": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/tinycolor/-/tinycolor-0.0.1.tgz", - "integrity": "sha1-MgtaUtg6u1l42Bo+iH1K77FaYWQ=", - "dev": true - }, "usb": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/usb/-/usb-1.5.0.tgz", @@ -1715,29 +1770,12 @@ "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" }, "ws": { - "version": "0.4.32", - "resolved": "http://registry.npmjs.org/ws/-/ws-0.4.32.tgz", - "integrity": "sha1-eHphVEFPPJntg8V3IVOyD+sM7DI=", + "version": "6.1.2", + "resolved": "https://registry.npmjs.org/ws/-/ws-6.1.2.tgz", + "integrity": "sha512-rfUqzvz0WxmSXtJpPMX2EeASXabOrSMk1ruMOV3JBTBjo4ac2lDjGGsbQSyxj8Odhw5fBib8ZKEjDNvgouNKYw==", "dev": true, "requires": { - "commander": "~2.1.0", - "nan": "~1.0.0", - "options": ">=0.0.5", - "tinycolor": "0.x" - }, - "dependencies": { - "commander": { - "version": "2.1.0", - "resolved": "http://registry.npmjs.org/commander/-/commander-2.1.0.tgz", - "integrity": "sha1-0SG7roYNmZKj1Re6lvVliOR8Z4E=", - "dev": true - }, - "nan": { - "version": "1.0.0", - "resolved": "http://registry.npmjs.org/nan/-/nan-1.0.0.tgz", - "integrity": "sha1-riT4hQgY1mL8q1rPfzuVv6oszzg=", - "dev": true - } + "async-limiter": "~1.0.0" } }, "xpc-connection": { diff --git a/package.json b/package.json index 333834b77..04028acaf 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "win32" ], "dependencies": { - "debug": "~2.2.0" + "debug": "^4.1.0" }, "optionalDependencies": { "@abandonware/bluetooth-hci-socket": "^0.5.3-0", @@ -41,12 +41,12 @@ "xpc-connection": "~0.1.4" }, "devDependencies": { + "async": "~0.2.9", "jshint": "latest", - "mocha": "~1.8.2", + "mocha": "^5.2.0", "should": "~1.2.2", "sinon": "~1.6.0", - "async": "~0.2.9", - "ws": "~0.4.31" + "ws": "^6.1.2" }, "scripts": { "pretest": "jshint *.js lib/. test/.", From f85e5d1c295dec5bc879ff2d2e2e6c8b6503ef66 Mon Sep 17 00:00:00 2001 From: Philippe Coval Date: Wed, 19 Dec 2018 16:34:03 +0100 Subject: [PATCH 027/114] 1.9.2-0 Change-Id: Ib5299652916f982787b6f4ff2b0a1665cb14fc77 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 8b03fcb1d..ae2accfab 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@abandonware/noble", - "version": "1.9.1", + "version": "1.9.2-0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 04028acaf..a6f242b93 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "license": "MIT", "name": "@abandonware/noble", "description": "A Node.js BLE (Bluetooth Low Energy) central library.", - "version": "1.9.1", + "version": "1.9.2-0", "repository": { "type": "git", "url": "https://github.com/sandeepmistry/noble.git" From a262bb7c09b3ccbd1c82cee927f62a6bd20a8167 Mon Sep 17 00:00:00 2001 From: Michael Stegeman Date: Wed, 19 Dec 2018 11:46:43 -0700 Subject: [PATCH 028/114] Fix bluetooth-hci-socket require statement. --- lib/hci-socket/hci.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/hci-socket/hci.js b/lib/hci-socket/hci.js index 3427e3b02..aac52dba4 100644 --- a/lib/hci-socket/hci.js +++ b/lib/hci-socket/hci.js @@ -3,7 +3,7 @@ var debug = require('debug')('hci'); var events = require('events'); var util = require('util'); -var BluetoothHciSocket = require('bluetooth-hci-socket'); +var BluetoothHciSocket = require('@abandonware/bluetooth-hci-socket'); var HCI_COMMAND_PKT = 0x01; var HCI_ACLDATA_PKT = 0x02; From 0789e0586fcffa44ef032027f8ac1b347ee63ec1 Mon Sep 17 00:00:00 2001 From: Philippe Coval Date: Wed, 19 Dec 2018 23:24:07 +0100 Subject: [PATCH 029/114] npm: Update bluetooth-hci-socket To prevent build failure Change-Id: Ie63bbd99814a578a97fceb107689cae561428ee7 Signed-off-by: Philippe Coval --- package-lock.json | 942 ++-------------------------------------------- package.json | 2 +- 2 files changed, 29 insertions(+), 915 deletions(-) diff --git a/package-lock.json b/package-lock.json index ae2accfab..561df0ef2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,921 +5,15 @@ "requires": true, "dependencies": { "@abandonware/bluetooth-hci-socket": { - "version": "0.5.3-0", - "resolved": "https://registry.npmjs.org/@abandonware/bluetooth-hci-socket/-/bluetooth-hci-socket-0.5.3-0.tgz", - "integrity": "sha512-TdGNGIQfcMdsBW4A70ONnvySLnooPhQJ57hXPQZn5Q1axLoDDKQ4nVTVNUjgyOUrKvy8PDMTd/iMIz6MV/PFtg==", + "version": "0.5.3-1", + "resolved": "https://registry.npmjs.org/@abandonware/bluetooth-hci-socket/-/bluetooth-hci-socket-0.5.3-1.tgz", + "integrity": "sha512-NzLRq7mjAmvLDRA0E5hvCRtsuV0tq5fbUFxLxSmakRu9K4VM6u7P+3PvAkcylX3CEq0BY9Wwe3KXiMrQBjbMhg==", "optional": true, "requires": { - "debug": "^2.2.0", + "debug": "^4.1.0", "nan": "^2.10.0", - "node-pre-gyp": "0.6.x", + "node-pre-gyp": "^0.12.0", "usb": "^1.1.0" - }, - "dependencies": { - "abbrev": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", - "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==", - "optional": true - }, - "ajv": { - "version": "4.11.8", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-4.11.8.tgz", - "integrity": "sha1-gv+wKynmYq5TvcIK8VlHcGc5xTY=", - "optional": true, - "requires": { - "co": "^4.6.0", - "json-stable-stringify": "^1.0.1" - } - }, - "ansi-regex": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", - "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=" - }, - "aproba": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/aproba/-/aproba-1.2.0.tgz", - "integrity": "sha512-Y9J6ZjXtoYh8RnXVCMOU/ttDmk1aBjunq9vO0ta5x85WDQiQfUF9sIPBITdbiiIVcBo03Hi3jMxigBtsddlXRw==", - "optional": true - }, - "are-we-there-yet": { - "version": "1.1.5", - "resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-1.1.5.tgz", - "integrity": "sha512-5hYdAkZlcG8tOLujVDTgCT+uPX0VnpAH28gWsLfzpXYm7wP6mp5Q/gYyR7YQ0cKVJcXJnl3j2kpBan13PtQf6w==", - "optional": true, - "requires": { - "delegates": "^1.0.0", - "readable-stream": "^2.0.6" - } - }, - "asn1": { - "version": "0.2.4", - "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.4.tgz", - "integrity": "sha512-jxwzQpLQjSmWXgwaCZE9Nz+glAG01yF1QnWgbhGwHI5A6FRIEY6IVqtHhIepHqI7/kyEyQEagBC5mBEFlIYvdg==", - "optional": true, - "requires": { - "safer-buffer": "~2.1.0" - } - }, - "assert-plus": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-0.2.0.tgz", - "integrity": "sha1-104bh+ev/A24qttwIfP+SBAasjQ=", - "optional": true - }, - "asynckit": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", - "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=", - "optional": true - }, - "aws-sign2": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.6.0.tgz", - "integrity": "sha1-FDQt0428yU0OW4fXY81jYSwOeU8=", - "optional": true - }, - "aws4": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.8.0.tgz", - "integrity": "sha512-ReZxvNHIOv88FlT7rxcXIIC0fPt4KZqZbOlivyWtXLt8ESx84zd3kMC6iK5jVeS2qt+g7ftS7ye4fi06X5rtRQ==", - "optional": true - }, - "balanced-match": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", - "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" - }, - "bcrypt-pbkdf": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz", - "integrity": "sha1-pDAdOJtqQ/m2f/PKEaP2Y342Dp4=", - "optional": true, - "requires": { - "tweetnacl": "^0.14.3" - } - }, - "block-stream": { - "version": "0.0.9", - "resolved": "https://registry.npmjs.org/block-stream/-/block-stream-0.0.9.tgz", - "integrity": "sha1-E+v+d4oDIFz+A3UUgeu0szAMEmo=", - "requires": { - "inherits": "~2.0.0" - } - }, - "boom": { - "version": "2.10.1", - "resolved": "http://registry.npmjs.org/boom/-/boom-2.10.1.tgz", - "integrity": "sha1-OciRjO/1eZ+D+UkqhI9iWt0Mdm8=", - "requires": { - "hoek": "2.x.x" - } - }, - "brace-expansion": { - "version": "1.1.11", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", - "requires": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } - }, - "caseless": { - "version": "0.12.0", - "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", - "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=", - "optional": true - }, - "co": { - "version": "4.6.0", - "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", - "integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=", - "optional": true - }, - "code-point-at": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", - "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=" - }, - "combined-stream": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.7.tgz", - "integrity": "sha512-brWl9y6vOB1xYPZcpZde3N9zDByXTosAeMDo4p1wzo6UMOX4vumB+TP1RZ76sfE6Md68Q0NJSrE/gbezd4Ul+w==", - "requires": { - "delayed-stream": "~1.0.0" - } - }, - "concat-map": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" - }, - "console-control-strings": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", - "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=" - }, - "core-util-is": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" - }, - "cryptiles": { - "version": "2.0.5", - "resolved": "http://registry.npmjs.org/cryptiles/-/cryptiles-2.0.5.tgz", - "integrity": "sha1-O9/s3GCBR8HGcgL6KR59ylnqo7g=", - "requires": { - "boom": "2.x.x" - } - }, - "dashdash": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", - "integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=", - "optional": true, - "requires": { - "assert-plus": "^1.0.0" - }, - "dependencies": { - "assert-plus": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", - "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=", - "optional": true - } - } - }, - "debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "optional": true, - "requires": { - "ms": "2.0.0" - } - }, - "deep-extend": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.6.0.tgz", - "integrity": "sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==", - "optional": true - }, - "delayed-stream": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", - "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" - }, - "delegates": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz", - "integrity": "sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o=", - "optional": true - }, - "detect-libc": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-1.0.3.tgz", - "integrity": "sha1-+hN8S9aY7fVc1c0CrFWfkaTEups=", - "optional": true - }, - "ecc-jsbn": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz", - "integrity": "sha1-OoOpBOVDUyh4dMVkt1SThoSamMk=", - "optional": true, - "requires": { - "jsbn": "~0.1.0", - "safer-buffer": "^2.1.0" - } - }, - "extend": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", - "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==", - "optional": true - }, - "extsprintf": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz", - "integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=" - }, - "forever-agent": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", - "integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=", - "optional": true - }, - "form-data": { - "version": "2.1.4", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.1.4.tgz", - "integrity": "sha1-M8GDrPGTJ27KqYFDpp6Uv+4XUNE=", - "optional": true, - "requires": { - "asynckit": "^0.4.0", - "combined-stream": "^1.0.5", - "mime-types": "^2.1.12" - } - }, - "fs.realpath": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" - }, - "fstream": { - "version": "1.0.11", - "resolved": "https://registry.npmjs.org/fstream/-/fstream-1.0.11.tgz", - "integrity": "sha1-XB+x8RdHcRTwYyoOtLcbPLD9MXE=", - "requires": { - "graceful-fs": "^4.1.2", - "inherits": "~2.0.0", - "mkdirp": ">=0.5 0", - "rimraf": "2" - } - }, - "fstream-ignore": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/fstream-ignore/-/fstream-ignore-1.0.5.tgz", - "integrity": "sha1-nDHa40dnAY/h0kmyTa2mfQktoQU=", - "optional": true, - "requires": { - "fstream": "^1.0.0", - "inherits": "2", - "minimatch": "^3.0.0" - } - }, - "gauge": { - "version": "2.7.4", - "resolved": "https://registry.npmjs.org/gauge/-/gauge-2.7.4.tgz", - "integrity": "sha1-LANAXHU4w51+s3sxcCLjJfsBi/c=", - "optional": true, - "requires": { - "aproba": "^1.0.3", - "console-control-strings": "^1.0.0", - "has-unicode": "^2.0.0", - "object-assign": "^4.1.0", - "signal-exit": "^3.0.0", - "string-width": "^1.0.1", - "strip-ansi": "^3.0.1", - "wide-align": "^1.1.0" - } - }, - "getpass": { - "version": "0.1.7", - "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", - "integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=", - "optional": true, - "requires": { - "assert-plus": "^1.0.0" - }, - "dependencies": { - "assert-plus": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", - "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=", - "optional": true - } - } - }, - "glob": { - "version": "7.1.3", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.3.tgz", - "integrity": "sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ==", - "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - } - }, - "graceful-fs": { - "version": "4.1.15", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.15.tgz", - "integrity": "sha512-6uHUhOPEBgQ24HM+r6b/QwWfZq+yiFcipKFrOFiBEnWdy5sdzYoi+pJeQaPI5qOLRFqWmAXUPQNsielzdLoecA==" - }, - "har-schema": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-1.0.5.tgz", - "integrity": "sha1-0mMTX0MwfALGAq/I/pWXDAFRNp4=", - "optional": true - }, - "har-validator": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-4.2.1.tgz", - "integrity": "sha1-M0gdDxu/9gDdID11gSpqX7oALio=", - "optional": true, - "requires": { - "ajv": "^4.9.1", - "har-schema": "^1.0.5" - } - }, - "has-unicode": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/has-unicode/-/has-unicode-2.0.1.tgz", - "integrity": "sha1-4Ob+aijPUROIVeCG0Wkedx3iqLk=", - "optional": true - }, - "hawk": { - "version": "3.1.3", - "resolved": "http://registry.npmjs.org/hawk/-/hawk-3.1.3.tgz", - "integrity": "sha1-B4REvXwWQLD+VA0sm3PVlnjo4cQ=", - "requires": { - "boom": "2.x.x", - "cryptiles": "2.x.x", - "hoek": "2.x.x", - "sntp": "1.x.x" - } - }, - "hoek": { - "version": "2.16.3", - "resolved": "http://registry.npmjs.org/hoek/-/hoek-2.16.3.tgz", - "integrity": "sha1-ILt0A9POo5jpHcRxCo/xuCdKJe0=" - }, - "http-signature": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.1.1.tgz", - "integrity": "sha1-33LiZwZs0Kxn+3at+OE0qPvPkb8=", - "optional": true, - "requires": { - "assert-plus": "^0.2.0", - "jsprim": "^1.2.2", - "sshpk": "^1.7.0" - } - }, - "inflight": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", - "requires": { - "once": "^1.3.0", - "wrappy": "1" - } - }, - "inherits": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" - }, - "ini": { - "version": "1.3.5", - "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", - "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==", - "optional": true - }, - "is-fullwidth-code-point": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", - "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", - "requires": { - "number-is-nan": "^1.0.0" - } - }, - "is-typedarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", - "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=", - "optional": true - }, - "isarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" - }, - "isstream": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", - "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=", - "optional": true - }, - "jsbn": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", - "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=" - }, - "json-schema": { - "version": "0.2.3", - "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz", - "integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM=", - "optional": true - }, - "json-stable-stringify": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz", - "integrity": "sha1-mnWdOcXy/1A/1TAGRu1EX4jE+a8=", - "optional": true, - "requires": { - "jsonify": "~0.0.0" - } - }, - "json-stringify-safe": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", - "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=", - "optional": true - }, - "jsonify": { - "version": "0.0.0", - "resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz", - "integrity": "sha1-LHS27kHZPKUbe1qu6PUDYx0lKnM=", - "optional": true - }, - "jsprim": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz", - "integrity": "sha1-MT5mvB5cwG5Di8G3SZwuXFastqI=", - "optional": true, - "requires": { - "assert-plus": "1.0.0", - "extsprintf": "1.3.0", - "json-schema": "0.2.3", - "verror": "1.10.0" - }, - "dependencies": { - "assert-plus": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", - "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=", - "optional": true - } - } - }, - "mime-db": { - "version": "1.37.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.37.0.tgz", - "integrity": "sha512-R3C4db6bgQhlIhPU48fUtdVmKnflq+hRdad7IyKhtFj06VPNVdk2RhiYL3UjQIlso8L+YxAtFkobT0VK+S/ybg==" - }, - "mime-types": { - "version": "2.1.21", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.21.tgz", - "integrity": "sha512-3iL6DbwpyLzjR3xHSFNFeb9Nz/M8WDkX33t1GFQnFOllWk8pOrh/LSrB5OXlnlW5P9LH73X6loW/eogc+F5lJg==", - "requires": { - "mime-db": "~1.37.0" - } - }, - "minimatch": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", - "requires": { - "brace-expansion": "^1.1.7" - } - }, - "minimist": { - "version": "0.0.8", - "resolved": "http://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", - "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" - }, - "mkdirp": { - "version": "0.5.1", - "resolved": "http://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", - "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", - "requires": { - "minimist": "0.0.8" - } - }, - "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" - }, - "node-pre-gyp": { - "version": "0.6.39", - "resolved": "https://registry.npmjs.org/node-pre-gyp/-/node-pre-gyp-0.6.39.tgz", - "integrity": "sha512-OsJV74qxnvz/AMGgcfZoDaeDXKD3oY3QVIbBmwszTFkRisTSXbMQyn4UWzUMOtA5SVhrBZOTp0wcoSBgfMfMmQ==", - "optional": true, - "requires": { - "detect-libc": "^1.0.2", - "hawk": "3.1.3", - "mkdirp": "^0.5.1", - "nopt": "^4.0.1", - "npmlog": "^4.0.2", - "rc": "^1.1.7", - "request": "2.81.0", - "rimraf": "^2.6.1", - "semver": "^5.3.0", - "tar": "^2.2.1", - "tar-pack": "^3.4.0" - } - }, - "nopt": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/nopt/-/nopt-4.0.1.tgz", - "integrity": "sha1-0NRoWv1UFRk8jHUFYC0NF81kR00=", - "optional": true, - "requires": { - "abbrev": "1", - "osenv": "^0.1.4" - } - }, - "npmlog": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-4.1.2.tgz", - "integrity": "sha512-2uUqazuKlTaSI/dC8AzicUck7+IrEaOnN/e0jd3Xtt1KcGpwx30v50mL7oPyr/h9bL3E4aZccVwpwP+5W9Vjkg==", - "optional": true, - "requires": { - "are-we-there-yet": "~1.1.2", - "console-control-strings": "~1.1.0", - "gauge": "~2.7.3", - "set-blocking": "~2.0.0" - } - }, - "number-is-nan": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", - "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=" - }, - "oauth-sign": { - "version": "0.8.2", - "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.8.2.tgz", - "integrity": "sha1-Rqarfwrq2N6unsBWV4C31O/rnUM=", - "optional": true - }, - "object-assign": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", - "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", - "optional": true - }, - "once": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", - "requires": { - "wrappy": "1" - } - }, - "os-homedir": { - "version": "1.0.2", - "resolved": "http://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz", - "integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=", - "optional": true - }, - "os-tmpdir": { - "version": "1.0.2", - "resolved": "http://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", - "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=", - "optional": true - }, - "osenv": { - "version": "0.1.5", - "resolved": "https://registry.npmjs.org/osenv/-/osenv-0.1.5.tgz", - "integrity": "sha512-0CWcCECdMVc2Rw3U5w9ZjqX6ga6ubk1xDVKxtBQPK7wis/0F2r9T6k4ydGYhecl7YUBxBVxhL5oisPsNxAPe2g==", - "optional": true, - "requires": { - "os-homedir": "^1.0.0", - "os-tmpdir": "^1.0.0" - } - }, - "path-is-absolute": { - "version": "1.0.1", - "resolved": "http://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" - }, - "performance-now": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-0.2.0.tgz", - "integrity": "sha1-M+8wxcd9TqIcWlOGnZG1bY8lVeU=", - "optional": true - }, - "process-nextick-args": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", - "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==" - }, - "punycode": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", - "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=", - "optional": true - }, - "qs": { - "version": "6.4.0", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.4.0.tgz", - "integrity": "sha1-E+JtKK1rD/qpExLNO/cI7TUecjM=", - "optional": true - }, - "rc": { - "version": "1.2.8", - "resolved": "https://registry.npmjs.org/rc/-/rc-1.2.8.tgz", - "integrity": "sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw==", - "optional": true, - "requires": { - "deep-extend": "^0.6.0", - "ini": "~1.3.0", - "minimist": "^1.2.0", - "strip-json-comments": "~2.0.1" - }, - "dependencies": { - "minimist": { - "version": "1.2.0", - "resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", - "optional": true - } - } - }, - "readable-stream": { - "version": "2.3.6", - "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", - "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.1.1", - "util-deprecate": "~1.0.1" - } - }, - "request": { - "version": "2.81.0", - "resolved": "https://registry.npmjs.org/request/-/request-2.81.0.tgz", - "integrity": "sha1-xpKJRqDgbF+Nb4qTM0af/aRimKA=", - "optional": true, - "requires": { - "aws-sign2": "~0.6.0", - "aws4": "^1.2.1", - "caseless": "~0.12.0", - "combined-stream": "~1.0.5", - "extend": "~3.0.0", - "forever-agent": "~0.6.1", - "form-data": "~2.1.1", - "har-validator": "~4.2.1", - "hawk": "~3.1.3", - "http-signature": "~1.1.0", - "is-typedarray": "~1.0.0", - "isstream": "~0.1.2", - "json-stringify-safe": "~5.0.1", - "mime-types": "~2.1.7", - "oauth-sign": "~0.8.1", - "performance-now": "^0.2.0", - "qs": "~6.4.0", - "safe-buffer": "^5.0.1", - "stringstream": "~0.0.4", - "tough-cookie": "~2.3.0", - "tunnel-agent": "^0.6.0", - "uuid": "^3.0.0" - } - }, - "rimraf": { - "version": "2.6.2", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", - "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", - "requires": { - "glob": "^7.0.5" - } - }, - "safe-buffer": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" - }, - "safer-buffer": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", - "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" - }, - "semver": { - "version": "5.6.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.6.0.tgz", - "integrity": "sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg==", - "optional": true - }, - "set-blocking": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", - "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=", - "optional": true - }, - "signal-exit": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", - "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=", - "optional": true - }, - "sntp": { - "version": "1.0.9", - "resolved": "http://registry.npmjs.org/sntp/-/sntp-1.0.9.tgz", - "integrity": "sha1-ZUEYTMkK7qbG57NeJlkIJEPGYZg=", - "requires": { - "hoek": "2.x.x" - } - }, - "sshpk": { - "version": "1.15.2", - "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.15.2.tgz", - "integrity": "sha512-Ra/OXQtuh0/enyl4ETZAfTaeksa6BXks5ZcjpSUNrjBr0DvrJKX+1fsKDPpT9TBXgHAFsa4510aNVgI8g/+SzA==", - "optional": true, - "requires": { - "asn1": "~0.2.3", - "assert-plus": "^1.0.0", - "bcrypt-pbkdf": "^1.0.0", - "dashdash": "^1.12.0", - "ecc-jsbn": "~0.1.1", - "getpass": "^0.1.1", - "jsbn": "~0.1.0", - "safer-buffer": "^2.0.2", - "tweetnacl": "~0.14.0" - }, - "dependencies": { - "assert-plus": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", - "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=", - "optional": true - } - } - }, - "string-width": { - "version": "1.0.2", - "resolved": "http://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", - "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", - "requires": { - "code-point-at": "^1.0.0", - "is-fullwidth-code-point": "^1.0.0", - "strip-ansi": "^3.0.0" - } - }, - "string_decoder": { - "version": "1.1.1", - "resolved": "http://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", - "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "requires": { - "safe-buffer": "~5.1.0" - } - }, - "stringstream": { - "version": "0.0.6", - "resolved": "https://registry.npmjs.org/stringstream/-/stringstream-0.0.6.tgz", - "integrity": "sha512-87GEBAkegbBcweToUrdzf3eLhWNg06FJTebl4BVJz/JgWy8CvEr9dRtX5qWphiynMSQlxxi+QqN0z5T32SLlhA==", - "optional": true - }, - "strip-ansi": { - "version": "3.0.1", - "resolved": "http://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", - "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", - "requires": { - "ansi-regex": "^2.0.0" - } - }, - "strip-json-comments": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", - "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=", - "optional": true - }, - "tar": { - "version": "2.2.1", - "resolved": "http://registry.npmjs.org/tar/-/tar-2.2.1.tgz", - "integrity": "sha1-jk0qJWwOIYXGsYrWlK7JaLg8sdE=", - "requires": { - "block-stream": "*", - "fstream": "^1.0.2", - "inherits": "2" - } - }, - "tar-pack": { - "version": "3.4.1", - "resolved": "https://registry.npmjs.org/tar-pack/-/tar-pack-3.4.1.tgz", - "integrity": "sha512-PPRybI9+jM5tjtCbN2cxmmRU7YmqT3Zv/UDy48tAh2XRkLa9bAORtSWLkVc13+GJF+cdTh1yEnHEk3cpTaL5Kg==", - "optional": true, - "requires": { - "debug": "^2.2.0", - "fstream": "^1.0.10", - "fstream-ignore": "^1.0.5", - "once": "^1.3.3", - "readable-stream": "^2.1.4", - "rimraf": "^2.5.1", - "tar": "^2.2.1", - "uid-number": "^0.0.6" - }, - "dependencies": { - "debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "optional": true, - "requires": { - "ms": "2.0.0" - } - } - } - }, - "tough-cookie": { - "version": "2.3.4", - "resolved": "http://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.4.tgz", - "integrity": "sha512-TZ6TTfI5NtZnuyy/Kecv+CnoROnyXn2DN97LontgQpCwsX2XyLYCC0ENhYkehSOwAp8rTQKc/NUIF7BkQ5rKLA==", - "optional": true, - "requires": { - "punycode": "^1.4.1" - } - }, - "tunnel-agent": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", - "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=", - "optional": true, - "requires": { - "safe-buffer": "^5.0.1" - } - }, - "tweetnacl": { - "version": "0.14.5", - "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", - "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=" - }, - "uid-number": { - "version": "0.0.6", - "resolved": "https://registry.npmjs.org/uid-number/-/uid-number-0.0.6.tgz", - "integrity": "sha1-DqEOgDXo61uOREnwbaHHMGY7qoE=", - "optional": true - }, - "util-deprecate": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" - }, - "uuid": { - "version": "3.3.2", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz", - "integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==", - "optional": true - }, - "verror": { - "version": "1.10.0", - "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz", - "integrity": "sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA=", - "optional": true, - "requires": { - "assert-plus": "^1.0.0", - "core-util-is": "1.0.2", - "extsprintf": "^1.2.0" - }, - "dependencies": { - "assert-plus": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", - "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=", - "optional": true - } - } - }, - "wide-align": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.3.tgz", - "integrity": "sha512-QGkOQc8XL6Bt5PwnsExKBPuMKBxnGxWWW3fU55Xt4feHozMUhdUMaBCk290qpm/wG5u/RSKzwdAC4i51YigihA==", - "optional": true, - "requires": { - "string-width": "^1.0.2 || 2" - } - }, - "wrappy": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" - } } }, "abbrev": { @@ -1475,9 +569,9 @@ } }, "node-pre-gyp": { - "version": "0.11.0", - "resolved": "https://registry.npmjs.org/node-pre-gyp/-/node-pre-gyp-0.11.0.tgz", - "integrity": "sha512-TwWAOZb0j7e9eGaf9esRx3ZcLaE5tQ2lvYy1pb5IAaG1a2e2Kv5Lms1Y4hpj+ciXJRofIxxlt5haeQ/2ANeE0Q==", + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/node-pre-gyp/-/node-pre-gyp-0.12.0.tgz", + "integrity": "sha512-4KghwV8vH5k+g2ylT+sLTjy5wmUOb9vPhnM8NHvRf9dHmnW/CndrFXy2aRPaPST6dugXSdHXfeaHQm77PIz/1A==", "optional": true, "requires": { "detect-libc": "^1.0.2", @@ -1747,6 +841,26 @@ "requires": { "nan": "^2.8.0", "node-pre-gyp": "^0.11.0" + }, + "dependencies": { + "node-pre-gyp": { + "version": "0.11.0", + "resolved": "https://registry.npmjs.org/node-pre-gyp/-/node-pre-gyp-0.11.0.tgz", + "integrity": "sha512-TwWAOZb0j7e9eGaf9esRx3ZcLaE5tQ2lvYy1pb5IAaG1a2e2Kv5Lms1Y4hpj+ciXJRofIxxlt5haeQ/2ANeE0Q==", + "optional": true, + "requires": { + "detect-libc": "^1.0.2", + "mkdirp": "^0.5.1", + "needle": "^2.2.1", + "nopt": "^4.0.1", + "npm-packlist": "^1.1.6", + "npmlog": "^4.0.2", + "rc": "^1.2.7", + "rimraf": "^2.6.1", + "semver": "^5.3.0", + "tar": "^4" + } + } } }, "util-deprecate": { diff --git a/package.json b/package.json index a6f242b93..ba25c8eee 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "debug": "^4.1.0" }, "optionalDependencies": { - "@abandonware/bluetooth-hci-socket": "^0.5.3-0", + "@abandonware/bluetooth-hci-socket": "^0.5.3-1", "bplist-parser": "0.0.6", "xpc-connection": "~0.1.4" }, From b32472c6e19e05c41085f2be1cd02e9750694f9e Mon Sep 17 00:00:00 2001 From: Philippe Coval Date: Thu, 20 Dec 2018 15:39:19 +0100 Subject: [PATCH 030/114] npm: Update deps It was tested using: ``` sudo modprobe -v btusb sudo $(which node) examples/advertisement-discovery.js ``` Origin: https://github.com/abandonware/noble Forwarded: TODO Change-Id: Ieea26e599e7d4fd3f398d6d893a099c93e572701 Signed-off-by: Philippe Coval --- package-lock.json | 763 +++++++++++++++++++++++++++++++++++++++++++--- package.json | 8 +- 2 files changed, 719 insertions(+), 52 deletions(-) diff --git a/package-lock.json b/package-lock.json index 561df0ef2..8bc958b57 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,6 +14,555 @@ "nan": "^2.10.0", "node-pre-gyp": "^0.12.0", "usb": "^1.1.0" + }, + "dependencies": { + "abbrev": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", + "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==", + "optional": true + }, + "ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=" + }, + "aproba": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/aproba/-/aproba-1.2.0.tgz", + "integrity": "sha512-Y9J6ZjXtoYh8RnXVCMOU/ttDmk1aBjunq9vO0ta5x85WDQiQfUF9sIPBITdbiiIVcBo03Hi3jMxigBtsddlXRw==", + "optional": true + }, + "are-we-there-yet": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-1.1.5.tgz", + "integrity": "sha512-5hYdAkZlcG8tOLujVDTgCT+uPX0VnpAH28gWsLfzpXYm7wP6mp5Q/gYyR7YQ0cKVJcXJnl3j2kpBan13PtQf6w==", + "optional": true, + "requires": { + "delegates": "^1.0.0", + "readable-stream": "^2.0.6" + } + }, + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" + }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "chownr": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.1.tgz", + "integrity": "sha512-j38EvO5+LHX84jlo6h4UzmOwi0UgW61WRyPtJz4qaadK5eY3BTS5TY/S1Stc3Uk2lIM6TPevAlULiEJwie860g==", + "optional": true + }, + "code-point-at": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", + "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=" + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" + }, + "console-control-strings": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", + "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=" + }, + "core-util-is": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", + "optional": true + }, + "deep-extend": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.6.0.tgz", + "integrity": "sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==", + "optional": true + }, + "delegates": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz", + "integrity": "sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o=", + "optional": true + }, + "detect-libc": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-1.0.3.tgz", + "integrity": "sha1-+hN8S9aY7fVc1c0CrFWfkaTEups=", + "optional": true + }, + "fs-minipass": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-1.2.5.tgz", + "integrity": "sha512-JhBl0skXjUPCFH7x6x61gQxrKyXsxB5gcgePLZCwfyCGGsTISMoIeObbrvVeP6Xmyaudw4TT43qV2Gz+iyd2oQ==", + "optional": true, + "requires": { + "minipass": "^2.2.1" + } + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", + "optional": true + }, + "gauge": { + "version": "2.7.4", + "resolved": "https://registry.npmjs.org/gauge/-/gauge-2.7.4.tgz", + "integrity": "sha1-LANAXHU4w51+s3sxcCLjJfsBi/c=", + "optional": true, + "requires": { + "aproba": "^1.0.3", + "console-control-strings": "^1.0.0", + "has-unicode": "^2.0.0", + "object-assign": "^4.1.0", + "signal-exit": "^3.0.0", + "string-width": "^1.0.1", + "strip-ansi": "^3.0.1", + "wide-align": "^1.1.0" + } + }, + "glob": { + "version": "7.1.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.3.tgz", + "integrity": "sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ==", + "optional": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "has-unicode": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/has-unicode/-/has-unicode-2.0.1.tgz", + "integrity": "sha1-4Ob+aijPUROIVeCG0Wkedx3iqLk=", + "optional": true + }, + "iconv-lite": { + "version": "0.4.24", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "optional": true, + "requires": { + "safer-buffer": ">= 2.1.2 < 3" + } + }, + "ignore-walk": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/ignore-walk/-/ignore-walk-3.0.1.tgz", + "integrity": "sha512-DTVlMx3IYPe0/JJcYP7Gxg7ttZZu3IInhuEhbchuqneY9wWe5Ojy2mXLBaQFUQmo0AW2r3qG7m1mg86js+gnlQ==", + "optional": true, + "requires": { + "minimatch": "^3.0.4" + } + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "optional": true, + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" + }, + "ini": { + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", + "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==", + "optional": true + }, + "is-fullwidth-code-point": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", + "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", + "requires": { + "number-is-nan": "^1.0.0" + } + }, + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", + "optional": true + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "minimist": { + "version": "0.0.8", + "resolved": "http://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" + }, + "minipass": { + "version": "2.3.5", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-2.3.5.tgz", + "integrity": "sha512-Gi1W4k059gyRbyVUZQ4mEqLm0YIUiGYfvxhF6SIlk3ui1WVxMTGfGdQ2SInh3PDrRTVvPKgULkpJtT4RH10+VA==", + "requires": { + "safe-buffer": "^5.1.2", + "yallist": "^3.0.0" + } + }, + "minizlib": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-1.2.1.tgz", + "integrity": "sha512-7+4oTUOWKg7AuL3vloEWekXY2/D20cevzsrNT2kGWm+39J9hGTCBv8VI5Pm5lXZ/o3/mdR4f8rflAPhnQb8mPA==", + "optional": true, + "requires": { + "minipass": "^2.2.1" + } + }, + "mkdirp": { + "version": "0.5.1", + "resolved": "http://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "requires": { + "minimist": "0.0.8" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "optional": true + }, + "needle": { + "version": "2.2.4", + "resolved": "https://registry.npmjs.org/needle/-/needle-2.2.4.tgz", + "integrity": "sha512-HyoqEb4wr/rsoaIDfTH2aVL9nWtQqba2/HvMv+++m8u0dz808MaagKILxtfeSN7QU7nvbQ79zk3vYOJp9zsNEA==", + "optional": true, + "requires": { + "debug": "^2.1.2", + "iconv-lite": "^0.4.4", + "sax": "^1.2.4" + }, + "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "optional": true, + "requires": { + "ms": "2.0.0" + } + } + } + }, + "node-pre-gyp": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/node-pre-gyp/-/node-pre-gyp-0.12.0.tgz", + "integrity": "sha512-4KghwV8vH5k+g2ylT+sLTjy5wmUOb9vPhnM8NHvRf9dHmnW/CndrFXy2aRPaPST6dugXSdHXfeaHQm77PIz/1A==", + "optional": true, + "requires": { + "detect-libc": "^1.0.2", + "mkdirp": "^0.5.1", + "needle": "^2.2.1", + "nopt": "^4.0.1", + "npm-packlist": "^1.1.6", + "npmlog": "^4.0.2", + "rc": "^1.2.7", + "rimraf": "^2.6.1", + "semver": "^5.3.0", + "tar": "^4" + } + }, + "nopt": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/nopt/-/nopt-4.0.1.tgz", + "integrity": "sha1-0NRoWv1UFRk8jHUFYC0NF81kR00=", + "optional": true, + "requires": { + "abbrev": "1", + "osenv": "^0.1.4" + } + }, + "npm-bundled": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/npm-bundled/-/npm-bundled-1.0.5.tgz", + "integrity": "sha512-m/e6jgWu8/v5niCUKQi9qQl8QdeEduFA96xHDDzFGqly0OOjI7c+60KM/2sppfnUU9JJagf+zs+yGhqSOFj71g==", + "optional": true + }, + "npm-packlist": { + "version": "1.1.12", + "resolved": "https://registry.npmjs.org/npm-packlist/-/npm-packlist-1.1.12.tgz", + "integrity": "sha512-WJKFOVMeAlsU/pjXuqVdzU0WfgtIBCupkEVwn+1Y0ERAbUfWw8R4GjgVbaKnUjRoD2FoQbHOCbOyT5Mbs9Lw4g==", + "optional": true, + "requires": { + "ignore-walk": "^3.0.1", + "npm-bundled": "^1.0.1" + } + }, + "npmlog": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-4.1.2.tgz", + "integrity": "sha512-2uUqazuKlTaSI/dC8AzicUck7+IrEaOnN/e0jd3Xtt1KcGpwx30v50mL7oPyr/h9bL3E4aZccVwpwP+5W9Vjkg==", + "optional": true, + "requires": { + "are-we-there-yet": "~1.1.2", + "console-control-strings": "~1.1.0", + "gauge": "~2.7.3", + "set-blocking": "~2.0.0" + } + }, + "number-is-nan": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", + "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=" + }, + "object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", + "optional": true + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "requires": { + "wrappy": "1" + } + }, + "os-homedir": { + "version": "1.0.2", + "resolved": "http://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz", + "integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=", + "optional": true + }, + "os-tmpdir": { + "version": "1.0.2", + "resolved": "http://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", + "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=", + "optional": true + }, + "osenv": { + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/osenv/-/osenv-0.1.5.tgz", + "integrity": "sha512-0CWcCECdMVc2Rw3U5w9ZjqX6ga6ubk1xDVKxtBQPK7wis/0F2r9T6k4ydGYhecl7YUBxBVxhL5oisPsNxAPe2g==", + "optional": true, + "requires": { + "os-homedir": "^1.0.0", + "os-tmpdir": "^1.0.0" + } + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "http://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "optional": true + }, + "process-nextick-args": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", + "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==", + "optional": true + }, + "rc": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/rc/-/rc-1.2.8.tgz", + "integrity": "sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw==", + "optional": true, + "requires": { + "deep-extend": "^0.6.0", + "ini": "~1.3.0", + "minimist": "^1.2.0", + "strip-json-comments": "~2.0.1" + }, + "dependencies": { + "minimist": { + "version": "1.2.0", + "resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", + "optional": true + } + } + }, + "readable-stream": { + "version": "2.3.6", + "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", + "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", + "optional": true, + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "rimraf": { + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", + "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", + "optional": true, + "requires": { + "glob": "^7.0.5" + } + }, + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + }, + "safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", + "optional": true + }, + "sax": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz", + "integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==", + "optional": true + }, + "semver": { + "version": "5.6.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.6.0.tgz", + "integrity": "sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg==", + "optional": true + }, + "set-blocking": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", + "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=", + "optional": true + }, + "signal-exit": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", + "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=", + "optional": true + }, + "string-width": { + "version": "1.0.2", + "resolved": "http://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", + "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", + "requires": { + "code-point-at": "^1.0.0", + "is-fullwidth-code-point": "^1.0.0", + "strip-ansi": "^3.0.0" + } + }, + "string_decoder": { + "version": "1.1.1", + "resolved": "http://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "optional": true, + "requires": { + "safe-buffer": "~5.1.0" + } + }, + "strip-ansi": { + "version": "3.0.1", + "resolved": "http://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "requires": { + "ansi-regex": "^2.0.0" + } + }, + "strip-json-comments": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", + "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=", + "optional": true + }, + "tar": { + "version": "4.4.8", + "resolved": "https://registry.npmjs.org/tar/-/tar-4.4.8.tgz", + "integrity": "sha512-LzHF64s5chPQQS0IYBn9IN5h3i98c12bo4NCO7e0sGM2llXQ3p2FGC5sdENN4cTW48O915Sh+x+EXx7XW96xYQ==", + "optional": true, + "requires": { + "chownr": "^1.1.1", + "fs-minipass": "^1.2.5", + "minipass": "^2.3.4", + "minizlib": "^1.1.1", + "mkdirp": "^0.5.0", + "safe-buffer": "^5.1.2", + "yallist": "^3.0.2" + } + }, + "util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", + "optional": true + }, + "wide-align": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.3.tgz", + "integrity": "sha512-QGkOQc8XL6Bt5PwnsExKBPuMKBxnGxWWW3fU55Xt4feHozMUhdUMaBCk290qpm/wG5u/RSKzwdAC4i51YigihA==", + "optional": true, + "requires": { + "string-width": "^1.0.2 || 2" + } + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" + }, + "yallist": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.3.tgz", + "integrity": "sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A==" + } + } + }, + "@sinonjs/commons": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-1.3.0.tgz", + "integrity": "sha512-j4ZwhaHmwsCb4DlDOIWnI5YyKDNMoNThsmwEpfHx6a1EpsGZ9qYLxP++LMlmBRjtGptGHFsGItJ768snllFWpA==", + "dev": true, + "requires": { + "type-detect": "4.0.8" + } + }, + "@sinonjs/formatio": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@sinonjs/formatio/-/formatio-3.1.0.tgz", + "integrity": "sha512-ZAR2bPHOl4Xg6eklUGpsdiIJ4+J1SNag1DHHrG/73Uz/nVwXqjgUtRPLoS+aVyieN9cSbc0E4LsU984tWcDyNg==", + "dev": true, + "requires": { + "@sinonjs/samsam": "^2 || ^3" + } + }, + "@sinonjs/samsam": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/@sinonjs/samsam/-/samsam-3.0.2.tgz", + "integrity": "sha512-m08g4CS3J6lwRQk1pj1EO+KEVWbrbXsmi9Pw0ySmrIbcVxVaedoFgLvFsV8wHLwh01EpROVz3KvVcD1Jmks9FQ==", + "dev": true, + "requires": { + "@sinonjs/commons": "^1.0.2", + "array-from": "^2.1.1", + "lodash.get": "^4.4.2" } }, "abbrev": { @@ -43,12 +592,21 @@ "readable-stream": "^2.0.6" } }, - "async": { - "version": "0.2.10", - "resolved": "http://registry.npmjs.org/async/-/async-0.2.10.tgz", - "integrity": "sha1-trvgsGdLnXGXCMo43owjfLUmw9E=", + "array-from": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/array-from/-/array-from-2.1.1.tgz", + "integrity": "sha1-z+nYwmYoudxa7MYqn12PHzUsEZU=", "dev": true }, + "async": { + "version": "2.6.1", + "resolved": "https://registry.npmjs.org/async/-/async-2.6.1.tgz", + "integrity": "sha512-fNEiL2+AZt6AlAw/29Cr0UDe4sRAHCpEHh54WMz+Bb7QfNcFw4h3loofyJpLeQs4Yx7yuqu/2dLgM5hKOs6HlQ==", + "dev": true, + "requires": { + "lodash": "^4.17.10" + } + }, "async-limiter": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.0.tgz", @@ -60,12 +618,21 @@ "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" }, - "bplist-parser": { - "version": "0.0.6", - "resolved": "https://registry.npmjs.org/bplist-parser/-/bplist-parser-0.0.6.tgz", - "integrity": "sha1-ONo0cYF9+dRKs4kuJ3B7u9daEbk=", + "big-integer": { + "version": "1.6.40", + "resolved": "https://registry.npmjs.org/big-integer/-/big-integer-1.6.40.tgz", + "integrity": "sha512-CjhtJp0BViLzP1ZkEnoywjgtFQXS2pomKjAJtIISTCnuHILkLcAXLdFLG/nxsHc4s9kJfc+82Xpg8WNyhfACzQ==", "optional": true }, + "bplist-parser": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/bplist-parser/-/bplist-parser-0.1.1.tgz", + "integrity": "sha1-1g1dzCDLptx+HymbNdPh+V2vuuY=", + "optional": true, + "requires": { + "big-integer": "^1.6.7" + } + }, "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", @@ -81,21 +648,6 @@ "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", "dev": true }, - "buster-core": { - "version": "0.6.4", - "resolved": "https://registry.npmjs.org/buster-core/-/buster-core-0.6.4.tgz", - "integrity": "sha1-J79rrWdCROpyDzEdkAoMoct4YFA=", - "dev": true - }, - "buster-format": { - "version": "0.5.6", - "resolved": "https://registry.npmjs.org/buster-format/-/buster-format-0.5.6.tgz", - "integrity": "sha1-K4bDIuz14bCubm55Bev884fSq5U=", - "dev": true, - "requires": { - "buster-core": "=0.6.4" - } - }, "chownr": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.1.tgz", @@ -434,12 +986,30 @@ } } }, + "just-extend": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/just-extend/-/just-extend-4.0.2.tgz", + "integrity": "sha512-FrLwOgm+iXrPV+5zDU6Jqu4gCRXbWEQg2O3SKONsWE4w7AXFRkryS53bpWdaL9cNol+AmR3AEYz6kn+o0fCPnw==", + "dev": true + }, "lodash": { "version": "4.17.11", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==", "dev": true }, + "lodash.get": { + "version": "4.4.2", + "resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz", + "integrity": "sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk=", + "dev": true + }, + "lolex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/lolex/-/lolex-3.0.0.tgz", + "integrity": "sha512-hcnW80h3j2lbUfFdMArd5UPA/vxZJ+G8vobd+wg3nVEQA0EigStbYcrG030FJxL6xiDDPEkoMatV9xIh5OecQQ==", + "dev": true + }, "minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", @@ -535,9 +1105,9 @@ "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==" }, "nan": { - "version": "2.12.0", - "resolved": "https://registry.npmjs.org/nan/-/nan-2.12.0.tgz", - "integrity": "sha512-zT5nC0JhbljmyEf+Z456nvm7iO7XgRV2hYxoBtPpnyp+0Q4aCoP6uWNn76v/I6k2kCYNLWqWbwBWQcjsNI/bjw==", + "version": "2.12.1", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.12.1.tgz", + "integrity": "sha512-JY7V6lRkStKcKTvHO5NVSQRv+RV+FIL5pvDoLiAtSL9pKlC5x9PKQcZDsq7m4FO4d57mkhC6Z+QhAh3Jdk5JFw==", "optional": true }, "needle": { @@ -568,22 +1138,25 @@ } } }, - "node-pre-gyp": { - "version": "0.12.0", - "resolved": "https://registry.npmjs.org/node-pre-gyp/-/node-pre-gyp-0.12.0.tgz", - "integrity": "sha512-4KghwV8vH5k+g2ylT+sLTjy5wmUOb9vPhnM8NHvRf9dHmnW/CndrFXy2aRPaPST6dugXSdHXfeaHQm77PIz/1A==", - "optional": true, + "nise": { + "version": "1.4.8", + "resolved": "https://registry.npmjs.org/nise/-/nise-1.4.8.tgz", + "integrity": "sha512-kGASVhuL4tlAV0tvA34yJYZIVihrUt/5bDwpp4tTluigxUr2bBlJeDXmivb6NuEdFkqvdv/Ybb9dm16PSKUhtw==", + "dev": true, "requires": { - "detect-libc": "^1.0.2", - "mkdirp": "^0.5.1", - "needle": "^2.2.1", - "nopt": "^4.0.1", - "npm-packlist": "^1.1.6", - "npmlog": "^4.0.2", - "rc": "^1.2.7", - "rimraf": "^2.6.1", - "semver": "^5.3.0", - "tar": "^4" + "@sinonjs/formatio": "^3.1.0", + "just-extend": "^4.0.2", + "lolex": "^2.3.2", + "path-to-regexp": "^1.7.0", + "text-encoding": "^0.6.4" + }, + "dependencies": { + "lolex": { + "version": "2.7.5", + "resolved": "https://registry.npmjs.org/lolex/-/lolex-2.7.5.tgz", + "integrity": "sha512-l9x0+1offnKKIzYVjyXU2SiwhXDLekRzKyhnbyldPHvC7BvLPVpdNUNR2KeMAiCN2D/kLNttZgQD5WjSxuBx3Q==", + "dev": true + } } }, "nopt": { @@ -670,6 +1243,23 @@ "resolved": "http://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" }, + "path-to-regexp": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-1.7.0.tgz", + "integrity": "sha1-Wf3g9DW62suhA6hOnTvGTpa5k30=", + "dev": true, + "requires": { + "isarray": "0.0.1" + }, + "dependencies": { + "isarray": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", + "dev": true + } + } + }, "process-nextick-args": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", @@ -756,9 +1346,57 @@ "dev": true }, "should": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/should/-/should-1.2.2.tgz", - "integrity": "sha1-DwP3dQZtnqJjJpDJF7EoJPzB1YI=", + "version": "13.2.3", + "resolved": "https://registry.npmjs.org/should/-/should-13.2.3.tgz", + "integrity": "sha512-ggLesLtu2xp+ZxI+ysJTmNjh2U0TsC+rQ/pfED9bUZZ4DKefP27D+7YJVVTvKsmjLpIi9jAa7itwDGkDDmt1GQ==", + "dev": true, + "requires": { + "should-equal": "^2.0.0", + "should-format": "^3.0.3", + "should-type": "^1.4.0", + "should-type-adaptors": "^1.0.1", + "should-util": "^1.0.0" + } + }, + "should-equal": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/should-equal/-/should-equal-2.0.0.tgz", + "integrity": "sha512-ZP36TMrK9euEuWQYBig9W55WPC7uo37qzAEmbjHz4gfyuXrEUgF8cUvQVO+w+d3OMfPvSRQJ22lSm8MQJ43LTA==", + "dev": true, + "requires": { + "should-type": "^1.4.0" + } + }, + "should-format": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/should-format/-/should-format-3.0.3.tgz", + "integrity": "sha1-m/yPdPo5IFxT04w01xcwPidxJPE=", + "dev": true, + "requires": { + "should-type": "^1.3.0", + "should-type-adaptors": "^1.0.1" + } + }, + "should-type": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/should-type/-/should-type-1.4.0.tgz", + "integrity": "sha1-B1bYzoRt/QmEOmlHcZ36DUz/XPM=", + "dev": true + }, + "should-type-adaptors": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/should-type-adaptors/-/should-type-adaptors-1.1.0.tgz", + "integrity": "sha512-JA4hdoLnN+kebEp2Vs8eBe9g7uy0zbRo+RMcU0EsNy+R+k049Ki+N5tT5Jagst2g7EAja+euFuoXFCa8vIklfA==", + "dev": true, + "requires": { + "should-type": "^1.3.0", + "should-util": "^1.0.0" + } + }, + "should-util": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/should-util/-/should-util-1.0.0.tgz", + "integrity": "sha1-yYzaN0qmsZDfi6h8mInCtNtiAGM=", "dev": true }, "signal-exit": { @@ -768,12 +1406,29 @@ "optional": true }, "sinon": { - "version": "1.6.0", - "resolved": "http://registry.npmjs.org/sinon/-/sinon-1.6.0.tgz", - "integrity": "sha1-V3sBfYaUO4xCU31awuhjcw9YzJs=", + "version": "7.2.2", + "resolved": "https://registry.npmjs.org/sinon/-/sinon-7.2.2.tgz", + "integrity": "sha512-WLagdMHiEsrRmee3jr6IIDntOF4kbI6N2pfbi8wkv50qaUQcBglkzkjtoOEbeJ2vf1EsrHhLI+5Ny8//WHdMoA==", "dev": true, "requires": { - "buster-format": "~0.5" + "@sinonjs/commons": "^1.2.0", + "@sinonjs/formatio": "^3.1.0", + "@sinonjs/samsam": "^3.0.2", + "diff": "^3.5.0", + "lolex": "^3.0.0", + "nise": "^1.4.7", + "supports-color": "^5.5.0" + }, + "dependencies": { + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } + } } }, "string-width": { @@ -833,6 +1488,18 @@ "yallist": "^3.0.2" } }, + "text-encoding": { + "version": "0.6.4", + "resolved": "http://registry.npmjs.org/text-encoding/-/text-encoding-0.6.4.tgz", + "integrity": "sha1-45mpgiV6J22uQou5KEXLcb3CbRk=", + "dev": true + }, + "type-detect": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", + "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", + "dev": true + }, "usb": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/usb/-/usb-1.5.0.tgz", diff --git a/package.json b/package.json index ba25c8eee..6d8f27307 100644 --- a/package.json +++ b/package.json @@ -37,15 +37,15 @@ }, "optionalDependencies": { "@abandonware/bluetooth-hci-socket": "^0.5.3-1", - "bplist-parser": "0.0.6", + "bplist-parser": "0.1.1", "xpc-connection": "~0.1.4" }, "devDependencies": { - "async": "~0.2.9", + "async": "~2.6.1", "jshint": "latest", "mocha": "^5.2.0", - "should": "~1.2.2", - "sinon": "~1.6.0", + "should": "~13.2.3", + "sinon": "~7.2.2", "ws": "^6.1.2" }, "scripts": { From 210662c3eca8ec64db4c2f42d8e099857726b439 Mon Sep 17 00:00:00 2001 From: Philippe Coval Date: Thu, 20 Dec 2018 15:45:38 +0100 Subject: [PATCH 031/114] 1.9.2-1 Change-Id: I3c76ceb90f97accd5c4f169a39bd8e69d7a4c2bb --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 8bc958b57..2b62e98df 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@abandonware/noble", - "version": "1.9.2-0", + "version": "1.9.2-1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 6d8f27307..8f4aa9493 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "license": "MIT", "name": "@abandonware/noble", "description": "A Node.js BLE (Bluetooth Low Energy) central library.", - "version": "1.9.2-0", + "version": "1.9.2-1", "repository": { "type": "git", "url": "https://github.com/sandeepmistry/noble.git" From 93b4dcf3923a92cc743ec46aad4314b8498777ca Mon Sep 17 00:00:00 2001 From: Andrei Date: Mon, 4 Feb 2019 21:17:25 +0100 Subject: [PATCH 032/114] usage update --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index be85a5de4..5fb749a7a 100644 --- a/README.md +++ b/README.md @@ -106,7 +106,7 @@ npm install @abandonware/noble ## Usage ```javascript -var noble = require('noble'); +var noble = require('@abandonware/noble'); ``` ### Actions From e22136210cdb286345e23372af20e6ea4dc66edd Mon Sep 17 00:00:00 2001 From: Georg Vienna Date: Tue, 23 Oct 2018 11:06:00 +0200 Subject: [PATCH 033/114] remove js mac bindings --- lib/mac/bindings.js | 12 - lib/mac/highsierra.js | 840 ----------------------------------- lib/mac/legacy.js | 629 --------------------------- lib/mac/local-address.js | 18 - lib/mac/mavericks.js | 603 -------------------------- lib/mac/uuid-to-address.js | 24 - lib/mac/yosemite.js | 865 ------------------------------------- package.json | 4 +- 8 files changed, 1 insertion(+), 2994 deletions(-) delete mode 100644 lib/mac/bindings.js delete mode 100644 lib/mac/highsierra.js delete mode 100644 lib/mac/legacy.js delete mode 100644 lib/mac/local-address.js delete mode 100644 lib/mac/mavericks.js delete mode 100644 lib/mac/uuid-to-address.js delete mode 100644 lib/mac/yosemite.js diff --git a/lib/mac/bindings.js b/lib/mac/bindings.js deleted file mode 100644 index 92e1d049c..000000000 --- a/lib/mac/bindings.js +++ /dev/null @@ -1,12 +0,0 @@ -var os = require('os'); -var osRelease = parseFloat(os.release()); - -if (osRelease < 13 ) { - module.exports = require('./legacy'); -} else if (osRelease < 14) { - module.exports = require('./mavericks'); -} else if (osRelease < 17) { - module.exports = require('./yosemite'); -} else { - module.exports = require('./highsierra'); -} diff --git a/lib/mac/highsierra.js b/lib/mac/highsierra.js deleted file mode 100644 index e9c4bd84f..000000000 --- a/lib/mac/highsierra.js +++ /dev/null @@ -1,840 +0,0 @@ -var events = require('events'); -var os = require('os'); -var util = require('util'); - -var debug = require('debug')('highsierra-bindings'); - -var XpcConnection = require('xpc-connection'); - -var localAddress = require('./local-address'); -var uuidToAddress = require('./uuid-to-address'); - -/** - * NobleBindings for mac - */ -var NobleBindings = function() { - this._peripherals = {}; - - this._xpcConnection = new XpcConnection('com.apple.bluetoothd'); - this._xpcConnection.on('error', function(message) {this.emit('xpcError', message);}.bind(this)); - this._xpcConnection.on('event', function(event) {this.emit('xpcEvent', event); }.bind(this)); -}; - -util.inherits(NobleBindings, events.EventEmitter); - -NobleBindings.prototype.sendXpcMessage = function(message) { - this._xpcConnection.sendMessage(message); -}; - -var nobleBindings = new NobleBindings(); - -// General xpc message handling -nobleBindings.on('xpcEvent', function(event) { - debug('xpcEvent: ' + JSON.stringify(event, undefined, 2)); - - var kCBMsgId = event.kCBMsgId; - var kCBMsgArgs = event.kCBMsgArgs; - this.emit('kCBMsgId' + kCBMsgId, kCBMsgArgs); -}); - -nobleBindings.on('xpcError', function(message) { - console.error('xpcError: ' + message); -}); - -nobleBindings.sendCBMsg = function(id, args) { - debug('sendCBMsg: ' + id + ', ' + JSON.stringify(args, undefined, 2)); - this.sendXpcMessage({kCBMsgId: id,kCBMsgArgs: args}); -}; - - - - -/** - * Init xpc connection to bluetoothd - * - * @discussion tested - */ -nobleBindings.init = function() { - this._xpcConnection.setup(); - - localAddress(function(address) { - if (address) { - this.emit('addressChange', address); - } - - this.sendCBMsg(1, { - kCBMsgArgName: 'node-' + (new Date()).getTime(), - kCBMsgArgOptions: { - kCBInitOptionShowPowerAlert: 0 - }, - kCBMsgArgType: 0 - }); - }.bind(this)); -}; - -nobleBindings.on('kCBMsgId4', function(args) { - var state = ['unknown', 'resetting', 'unsupported', 'unauthorized', 'poweredOff', 'poweredOn'][args.kCBMsgArgState]; - debug('state change ' + state); - this.emit('stateChange', state); -}); - - - -/** - * Start scanning - * @param {Array} serviceUuids Scan for these UUIDs, if undefined then scan for all - * @param {Bool} allowDuplicates Scan can return duplicates - * - * @discussion tested - */ -nobleBindings.startScanning = function(serviceUuids, allowDuplicates) { - var args = { - kCBMsgArgOptions: {}, - kCBMsgArgUUIDs: [] - }; - - if (serviceUuids) { - for(var i = 0; i < serviceUuids.length; i++) { - args.kCBMsgArgUUIDs[i] = new Buffer(serviceUuids[i], 'hex'); - } - } - - if (allowDuplicates) { - args.kCBMsgArgOptions.kCBScanOptionAllowDuplicates = 1; - } - - this.sendCBMsg(44, args); - this.emit('scanStart'); -}; - -/** - * Response message to start scanning - * - * @example - * // For `TI Sensortag` the message lookes like this: - * handleMsg: 37, { - * kCBMsgArgAdvertisementData = { - * kCBAdvDataIsConnectable = 1; - * kCBAdvDataLocalName = SensorTag; - * kCBAdvDataTxPowerLevel = 0; - * }; - * kCBMsgArgDeviceUUID = "<__NSConcreteUUID 0x6180000208e0> 53486C7A-DED2-4AA6-8913-387CD22F25D8"; - * kCBMsgArgName = SensorTag; - * kCBMsgArgRssi = "-68"; - * } - * - * @discussion tested - */ -nobleBindings.on('kCBMsgId48', function(args) { - if (Object.keys(args.kCBMsgArgAdvertisementData).length === 0 || - (args.kCBMsgArgAdvertisementData.kCBAdvDataIsConnectable !== undefined && - Object.keys(args.kCBMsgArgAdvertisementData).length === 1)) { - return; - } - - var deviceUuid = args.kCBMsgArgDeviceUUID.toString('hex'); - var advertisement = { - localName: args.kCBMsgArgAdvertisementData.kCBAdvDataLocalName || args.kCBMsgArgName, - txPowerLevel: args.kCBMsgArgAdvertisementData.kCBAdvDataTxPowerLevel, - manufacturerData: args.kCBMsgArgAdvertisementData.kCBAdvDataManufacturerData, - serviceData: [], - serviceUuids: [] - }; - var connectable = args.kCBMsgArgAdvertisementData.kCBAdvDataIsConnectable ? true : false; - var rssi = args.kCBMsgArgRssi; - var i; - - if (args.kCBMsgArgAdvertisementData.kCBAdvDataServiceUUIDs) { - for(i = 0; i < args.kCBMsgArgAdvertisementData.kCBAdvDataServiceUUIDs.length; i++) { - advertisement.serviceUuids.push(args.kCBMsgArgAdvertisementData.kCBAdvDataServiceUUIDs[i].toString('hex')); - } - } - - var serviceData = args.kCBMsgArgAdvertisementData.kCBAdvDataServiceData; - if (serviceData) { - for (i = 0; i < serviceData.length; i += 2) { - var serviceDataUuid = serviceData[i].toString('hex'); - var data = serviceData[i + 1]; - - advertisement.serviceData.push({ - uuid: serviceDataUuid, - data: data - }); - } - } - - debug('peripheral ' + deviceUuid + ' discovered'); - - var uuid = new Buffer(deviceUuid, 'hex'); - uuid.isUuid = true; - - if (!this._peripherals[deviceUuid]) { - this._peripherals[deviceUuid] = {}; - } - - this._peripherals[deviceUuid].uuid = uuid; - this._peripherals[deviceUuid].connectable = connectable; - this._peripherals[deviceUuid].advertisement = advertisement; - this._peripherals[deviceUuid].rssi = rssi; - - (function(deviceUuid, advertisement, rssi) { - uuidToAddress(deviceUuid, function(error, address, addressType) { - address = address || 'unknown'; - addressType = addressType || 'unknown'; - - this._peripherals[deviceUuid].address = address; - this._peripherals[deviceUuid].addressType = addressType; - - this.emit('discover', deviceUuid, address, addressType, connectable, advertisement, rssi); - }.bind(this)); - }.bind(this))(deviceUuid, advertisement, rssi); -}); - - -/** - * Stop scanning - * - * @discussion tested - */ -nobleBindings.stopScanning = function() { - this.sendCBMsg(45, null); - this.emit('scanStop'); -}; - - - -/** - * Connect to peripheral - * @param {String} deviceUuid Peripheral uuid to connect to - * - * @discussion tested - */ -nobleBindings.connect = function(deviceUuid) { - this.sendCBMsg(46, { - kCBMsgArgOptions: { - kCBConnectOptionNotifyOnDisconnection: 1 - }, - kCBMsgArgDeviceUUID: this._peripherals[deviceUuid].uuid - }); -}; - -nobleBindings.on('kCBMsgId49', function(args) { - var deviceUuid = args.kCBMsgArgDeviceUUID.toString('hex'); - - debug('peripheral ' + deviceUuid + ' connected'); - - this.emit('connect', deviceUuid); -}); - - - -/** - * Disconnect - * - * @param {String} deviceUuid Peripheral uuid to disconnect - * - * @discussion tested - */ -nobleBindings.disconnect = function(deviceUuid) { - this.sendCBMsg(47, { - kCBMsgArgDeviceUUID: this._peripherals[deviceUuid].uuid - }); -}; - -/** - * Response to disconnect - * - * @discussion tested - */ -nobleBindings.on('kCBMsgId50', function(args) { - var deviceUuid = args.kCBMsgArgDeviceUUID.toString('hex'); - - debug('peripheral ' + deviceUuid + ' disconnected'); - - this.emit('disconnect', deviceUuid); -}); - - - -/** - * Update RSSI - * - * @discussion tested - */ -nobleBindings.updateRssi = function(deviceUuid) { - this.sendCBMsg(61, { - kCBMsgArgDeviceUUID: this._peripherals[deviceUuid].uuid - }); -}; - -/** - * Response to RSSI update - * - * @discussion tested - */ -nobleBindings.on('kCBMsgId71', function(args) { - var deviceUuid = args.kCBMsgArgDeviceUUID.toString('hex'); - var rssi = args.kCBMsgArgData; - - this._peripherals[deviceUuid].rssi = rssi; - - debug('peripheral ' + deviceUuid + ' RSSI update ' + rssi); - - this.emit('rssiUpdate', deviceUuid, rssi); -}); - - - -/** - * Discover services - * - * @param {String} deviceUuid Device UUID - * @param {Array} uuids Services to discover, if undefined then all - * - * @discussion tested - */ -nobleBindings.discoverServices = function(deviceUuid, uuids) { - var args = { - kCBMsgArgDeviceUUID: this._peripherals[deviceUuid].uuid, - kCBMsgArgUUIDs: [] - }; - - if (uuids) { - for(var i = 0; i < uuids.length; i++) { - args.kCBMsgArgUUIDs[i] = new Buffer(uuids[i], 'hex'); - } - } - - this.sendCBMsg(62, args); -}; - -/** - * Response to discover service - * - * @discussion tested - */ -nobleBindings.on('kCBMsgId72', function(args) { - var deviceUuid = args.kCBMsgArgDeviceUUID.toString('hex'); - var serviceUuids = []; - - this._peripherals[deviceUuid].services = this._peripherals[deviceUuid].services || {}; - - if (args.kCBMsgArgServices) { - for(var i = 0; i < args.kCBMsgArgServices.length; i++) { - var service = { - uuid: args.kCBMsgArgServices[i].kCBMsgArgUUID.toString('hex'), - startHandle: args.kCBMsgArgServices[i].kCBMsgArgServiceStartHandle, - endHandle: args.kCBMsgArgServices[i].kCBMsgArgServiceEndHandle - }; - - if (!this._peripherals[deviceUuid].services[service.uuid] ) { - this._peripherals[deviceUuid].services[service.uuid] = this._peripherals[deviceUuid].services[service.startHandle] = service; - } - - serviceUuids.push(service.uuid); - } - } - // TODO: result 24 => device not connected - - this.emit('servicesDiscover', deviceUuid, serviceUuids); -}); - - - -/** - * [discoverIncludedServices description] - * - * @param {String} deviceUuid - * @param {String} serviceUuid - * @param {String} serviceUuids - * - * @dicussion tested - */ -nobleBindings.discoverIncludedServices = function(deviceUuid, serviceUuid, serviceUuids) { - var args = { - kCBMsgArgDeviceUUID: this._peripherals[deviceUuid].uuid, - kCBMsgArgServiceStartHandle: this._peripherals[deviceUuid].services[serviceUuid].startHandle, - kCBMsgArgServiceEndHandle: this._peripherals[deviceUuid].services[serviceUuid].endHandle, - kCBMsgArgUUIDs: [] - }; - - if (serviceUuids) { - for(var i = 0; i < serviceUuids.length; i++) { - args.kCBMsgArgUUIDs[i] = new Buffer(serviceUuids[i], 'hex'); - } - } - - this.sendCBMsg(74, args); -}; - -/** - * Response to dicover included services - * - * @dicussion tested - */ -nobleBindings.on('kCBMsgId76', function(args) { - var deviceUuid = args.kCBMsgArgDeviceUUID.toString('hex'); - var serviceStartHandle = args.kCBMsgArgServiceStartHandle; - var serviceUuid = this._peripherals[deviceUuid].services[serviceStartHandle].uuid; - var result = args.kCBMsgArgResult; - var includedServiceUuids = []; - - this._peripherals[deviceUuid].services[serviceStartHandle].includedServices = - this._peripherals[deviceUuid].services[serviceStartHandle].includedServices || {}; - - for(var i = 0; i < args.kCBMsgArgServices.length; i++) { - var includedService = { - uuid: args.kCBMsgArgServices[i].kCBMsgArgUUID.toString('hex'), - startHandle: args.kCBMsgArgServices[i].kCBMsgArgServiceStartHandle, - endHandle: args.kCBMsgArgServices[i].kCBMsgArgServiceEndHandle - }; - - if (! this._peripherals[deviceUuid].services[serviceStartHandle].includedServices[includedServices.uuid]) { - this._peripherals[deviceUuid].services[serviceStartHandle].includedServices[includedServices.uuid] = - this._peripherals[deviceUuid].services[serviceStartHandle].includedServices[includedServices.startHandle] = includedService; - } - - includedServiceUuids.push(includedService.uuid); - } - - this.emit('includedServicesDiscover', deviceUuid, serviceUuid, includedServiceUuids); -}); - - - -/** - * Discover characteristic - * - * @param {String} deviceUuid Peripheral UUID - * @param {String} serviceUuid Service UUID - * @param {Array} characteristicUuids Characteristics to discover, all if empty - * - * @discussion tested - */ -nobleBindings.discoverCharacteristics = function(deviceUuid, serviceUuid, characteristicUuids) { - var args = { - kCBMsgArgDeviceUUID: this._peripherals[deviceUuid].uuid, - kCBMsgArgServiceStartHandle: this._peripherals[deviceUuid].services[serviceUuid].startHandle, - kCBMsgArgServiceEndHandle: this._peripherals[deviceUuid].services[serviceUuid].endHandle, - kCBMsgArgUUIDs: [] - }; - - if (characteristicUuids) { - for(var i = 0; i < characteristicUuids.length; i++) { - args.kCBMsgArgUUIDs[i] = new Buffer(characteristicUuids[i], 'hex'); - } - } - - this.sendCBMsg(75, args); -}; - -/** - * Response to characteristic discovery - * - * @discussion tested - */ -nobleBindings.on('kCBMsgId77', function(args) { - var deviceUuid = args.kCBMsgArgDeviceUUID.toString('hex'); - var serviceStartHandle = args.kCBMsgArgServiceStartHandle; - var serviceUuid = this._peripherals[deviceUuid].services[serviceStartHandle].uuid; - var result = args.kCBMsgArgResult; - var characteristics = []; - - this._peripherals[deviceUuid].services[serviceStartHandle].characteristics = - this._peripherals[deviceUuid].services[serviceStartHandle].characteristics || {}; - - for(var i = 0; i < args.kCBMsgArgCharacteristics.length; i++) { - var properties = args.kCBMsgArgCharacteristics[i].kCBMsgArgCharacteristicProperties; - - var characteristic = { - uuid: args.kCBMsgArgCharacteristics[i].kCBMsgArgUUID.toString('hex'), - handle: args.kCBMsgArgCharacteristics[i].kCBMsgArgCharacteristicHandle, - valueHandle: args.kCBMsgArgCharacteristics[i].kCBMsgArgCharacteristicValueHandle, - properties: [] - }; - - if (properties & 0x01) { - characteristic.properties.push('broadcast'); - } - - if (properties & 0x02) { - characteristic.properties.push('read'); - } - - if (properties & 0x04) { - characteristic.properties.push('writeWithoutResponse'); - } - - if (properties & 0x08) { - characteristic.properties.push('write'); - } - - if (properties & 0x10) { - characteristic.properties.push('notify'); - } - - if (properties & 0x20) { - characteristic.properties.push('indicate'); - } - - if (properties & 0x40) { - characteristic.properties.push('authenticatedSignedWrites'); - } - - if (properties & 0x80) { - characteristic.properties.push('extendedProperties'); - } - - this._peripherals[deviceUuid].services[serviceStartHandle].characteristics[characteristic.uuid] = - this._peripherals[deviceUuid].services[serviceStartHandle].characteristics[characteristic.handle] = - this._peripherals[deviceUuid].services[serviceStartHandle].characteristics[characteristic.valueHandle] = characteristic; - - characteristics.push({ - uuid: characteristic.uuid, - properties: characteristic.properties - }); - } - - this.emit('characteristicsDiscover', deviceUuid, serviceUuid, characteristics); -}); - - - -/** - * Read value - * - * @param {[type]} deviceUuid [description] - * @param {[type]} serviceUuid [description] - * @param {[type]} characteristicUuid [description] - * - * @discussion tested - */ -nobleBindings.read = function(deviceUuid, serviceUuid, characteristicUuid) { - this.sendCBMsg(78 , { - kCBMsgArgDeviceUUID: this._peripherals[deviceUuid].uuid, - kCBMsgArgCharacteristicHandle: this._peripherals[deviceUuid].services[serviceUuid].characteristics[characteristicUuid].handle, - kCBMsgArgCharacteristicValueHandle: this._peripherals[deviceUuid].services[serviceUuid].characteristics[characteristicUuid].valueHandle - }); -}; - -/** - * Response to read value - * - * @discussion tested - */ -nobleBindings.on('kCBMsgId83', function(args) { - var deviceUuid = args.kCBMsgArgDeviceUUID.toString('hex'); - var characteristicHandle = args.kCBMsgArgCharacteristicHandle; - var isNotification = args.kCBMsgArgIsNotification ? true : false; - var data = args.kCBMsgArgData; - - var peripheral = this._peripherals[deviceUuid]; - - if (peripheral) { - for(var i in peripheral.services) { - if (peripheral.services[i].characteristics && - peripheral.services[i].characteristics[characteristicHandle]) { - - this.emit('read', deviceUuid, peripheral.services[i].uuid, - peripheral.services[i].characteristics[characteristicHandle].uuid, data, isNotification); - break; - } - } - } else { - console.warn('noble (highsierra): received read event from unknown peripheral: ' + deviceUuid + ' !'); - } -}); - - - -/** - * Write value - * @param {String} deviceUuid - * @param {String} serviceUuid - * @param {String} characteristicUuid - * @param {[Type]} data - * @param {Bool} withoutResponse - * - * @discussion tested - */ -nobleBindings.write = function(deviceUuid, serviceUuid, characteristicUuid, data, withoutResponse) { - this.sendCBMsg(79, { - kCBMsgArgDeviceUUID: this._peripherals[deviceUuid].uuid, - kCBMsgArgCharacteristicHandle: this._peripherals[deviceUuid].services[serviceUuid].characteristics[characteristicUuid].handle, - kCBMsgArgCharacteristicValueHandle: this._peripherals[deviceUuid].services[serviceUuid].characteristics[characteristicUuid].valueHandle, - kCBMsgArgData: data, - kCBMsgArgType: (withoutResponse ? 1 : 0) - }); - - if (withoutResponse) { - this.emit('write', deviceUuid, serviceUuid, characteristicUuid); - } -}; - -/** - * Response to write - * - * @discussion tested - */ -nobleBindings.on('kCBMsgId84', function(args) { - var deviceUuid = args.kCBMsgArgDeviceUUID.toString('hex'); - var characteristicHandle = args.kCBMsgArgCharacteristicHandle; - var result = args.kCBMsgArgResult; - - for(var i in this._peripherals[deviceUuid].services) { - if (this._peripherals[deviceUuid].services[i].characteristics && - this._peripherals[deviceUuid].services[i].characteristics[characteristicHandle]) { - this.emit('write', deviceUuid, this._peripherals[deviceUuid].services[i].uuid, - this._peripherals[deviceUuid].services[i].characteristics[characteristicHandle].uuid); - break; - } - } -}); - - - -/** - * Broadcast - * - * @param {[type]} deviceUuid [description] - * @param {[type]} serviceUuid [description] - * @param {[type]} characteristicUuid [description] - * @param {[type]} broadcast [description] - * @return {[type]} [description] - * - * @discussion The ids were incemented but there seems to be no CoreBluetooth function to call/verify this. - */ -nobleBindings.broadcast = function(deviceUuid, serviceUuid, characteristicUuid, broadcast) { - throw new Error('This OS does not support broadcast.'); -}; - - -/** - * Register notification hanlder - * - * @param {String} deviceUuid Peripheral UUID - * @param {String} serviceUuid Service UUID - * @param {String} characteristicUuid Charactereistic UUID - * @param {Bool} notify If want to get notification - * - * @discussion tested - */ -nobleBindings.notify = function(deviceUuid, serviceUuid, characteristicUuid, notify) { - this.sendCBMsg(81, { - kCBMsgArgDeviceUUID: this._peripherals[deviceUuid].uuid, - kCBMsgArgCharacteristicHandle: this._peripherals[deviceUuid].services[serviceUuid].characteristics[characteristicUuid].handle, - kCBMsgArgCharacteristicValueHandle: this._peripherals[deviceUuid].services[serviceUuid].characteristics[characteristicUuid].valueHandle, - kCBMsgArgState: (notify ? 1 : 0) - }); -}; - -/** - * Response notification - * - * @discussion tested - */ -nobleBindings.on('kCBMsgId86', function(args) { - var deviceUuid = args.kCBMsgArgDeviceUUID.toString('hex'); - var characteristicHandle = args.kCBMsgArgCharacteristicHandle; - var result = args.kCBMsgArgResult; - var state = args.kCBMsgArgState ? true : false; - - for(var i in this._peripherals[deviceUuid].services) { - if (this._peripherals[deviceUuid].services[i].characteristics && - this._peripherals[deviceUuid].services[i].characteristics[characteristicHandle]) { - this.emit('notify', deviceUuid, this._peripherals[deviceUuid].services[i].uuid, - this._peripherals[deviceUuid].services[i].characteristics[characteristicHandle].uuid, state); - break; - } - } -}); - - - -/** - * Discover service descriptors - * - * @param {String} deviceUuid - * @param {String} serviceUuid - * @param {String} characteristicUuid - * - * @discussion tested - */ -nobleBindings.discoverDescriptors = function(deviceUuid, serviceUuid, characteristicUuid) { - this.sendCBMsg(82, { - kCBMsgArgDeviceUUID: this._peripherals[deviceUuid].uuid, - kCBMsgArgCharacteristicHandle: this._peripherals[deviceUuid].services[serviceUuid].characteristics[characteristicUuid].handle, - kCBMsgArgCharacteristicValueHandle: this._peripherals[deviceUuid].services[serviceUuid].characteristics[characteristicUuid].valueHandle - }); -}; - -/** - * Response to descriptor discovery - * - * @discussion tested - */ -nobleBindings.on('kCBMsgId87', function(args) { - var deviceUuid = args.kCBMsgArgDeviceUUID.toString('hex'); - var characteristicHandle = args.kCBMsgArgCharacteristicHandle; - var result = args.kCBMsgArgResult; - var descriptors = []; //args.kCBMsgArgDescriptors; - - for(var i in this._peripherals[deviceUuid].services) { - if (this._peripherals[deviceUuid].services[i].characteristics && - this._peripherals[deviceUuid].services[i].characteristics[characteristicHandle]) { - - this._peripherals[deviceUuid].services[i].characteristics[characteristicHandle].descriptors = {}; - - for(var j = 0; j < args.kCBMsgArgDescriptors.length; j++) { - var descriptor = { - uuid: args.kCBMsgArgDescriptors[j].kCBMsgArgUUID.toString('hex'), - handle: args.kCBMsgArgDescriptors[j].kCBMsgArgDescriptorHandle - }; - - this._peripherals[deviceUuid].services[i].characteristics[characteristicHandle].descriptors[descriptor.uuid] = - this._peripherals[deviceUuid].services[i].characteristics[characteristicHandle].descriptors[descriptor.handle] = descriptor; - - descriptors.push(descriptor.uuid); - } - - this.emit('descriptorsDiscover', deviceUuid, this._peripherals[deviceUuid].services[i].uuid, - this._peripherals[deviceUuid].services[i].characteristics[characteristicHandle].uuid, descriptors); - break; - } - } -}); - - - -/** - * Read value - * - * @param {[type]} deviceUuid [description] - * @param {[type]} serviceUuid [description] - * @param {[type]} characteristicUuid [description] - * @param {[type]} descriptorUuid [description] - * - * @discussion tested - */ -nobleBindings.readValue = function(deviceUuid, serviceUuid, characteristicUuid, descriptorUuid) { - this.sendCBMsg(88, { - kCBMsgArgDeviceUUID: this._peripherals[deviceUuid].uuid, - kCBMsgArgDescriptorHandle: this._peripherals[deviceUuid].services[serviceUuid].characteristics[characteristicUuid].descriptors[descriptorUuid].handle - }); -}; - -/** - * Response to read value - * - * @discussion tested - */ -nobleBindings.on('kCBMsgId90', function(args) { - var deviceUuid = args.kCBMsgArgDeviceUUID.toString('hex'); - var descriptorHandle = args.kCBMsgArgDescriptorHandle; - var result = args.kCBMsgArgResult; - var data = args.kCBMsgArgData; - - this.emit('handleRead', deviceUuid, descriptorHandle, data); - - for(var i in this._peripherals[deviceUuid].services) { - for(var j in this._peripherals[deviceUuid].services[i].characteristics) { - if (this._peripherals[deviceUuid].services[i].characteristics[j].descriptors && - this._peripherals[deviceUuid].services[i].characteristics[j].descriptors[descriptorHandle]) { - - this.emit('valueRead', deviceUuid, this._peripherals[deviceUuid].services[i].uuid, - this._peripherals[deviceUuid].services[i].characteristics[j].uuid, - this._peripherals[deviceUuid].services[i].characteristics[j].descriptors[descriptorHandle].uuid, data); - return; // break; - } - } - } -}); - - - -/** - * Write value - * - * @param {[type]} deviceUuid [description] - * @param {[type]} serviceUuid [description] - * @param {[type]} characteristicUuid [description] - * @param {[type]} descriptorUuid [description] - * @param {[type]} data [description] - * - * @discussion tested - */ -nobleBindings.writeValue = function(deviceUuid, serviceUuid, characteristicUuid, descriptorUuid, data) { - this.sendCBMsg(89, { - kCBMsgArgDeviceUUID: this._peripherals[deviceUuid].uuid, - kCBMsgArgDescriptorHandle: this._peripherals[deviceUuid].services[serviceUuid].characteristics[characteristicUuid].descriptors[descriptorUuid].handle, - kCBMsgArgData: data - }); -}; - -/** - * Response to write value - * - * @discussion tested - */ -nobleBindings.on('kCBMsgId91', function(args) { - var deviceUuid = args.kCBMsgArgDeviceUUID.toString('hex'); - var descriptorHandle = args.kCBMsgArgDescriptorHandle; - var result = args.kCBMsgArgResult; - - this.emit('handleWrite', deviceUuid, descriptorHandle); - - for(var i in this._peripherals[deviceUuid].services) { - for(var j in this._peripherals[deviceUuid].services[i].characteristics) { - if (this._peripherals[deviceUuid].services[i].characteristics[j].descriptors && - this._peripherals[deviceUuid].services[i].characteristics[j].descriptors[descriptorHandle]) { - - this.emit('valueWrite', deviceUuid, this._peripherals[deviceUuid].services[i].uuid, - this._peripherals[deviceUuid].services[i].characteristics[j].uuid, - this._peripherals[deviceUuid].services[i].characteristics[j].descriptors[descriptorHandle].uuid); - return; // break; - } - } - } -}); - - - -/** - * Reade value directly from handle - * - * @param {[type]} deviceUuid [description] - * @param {[type]} handle [description] - * - * @discussion tested - */ -nobleBindings.readHandle = function(deviceUuid, handle) { - this.sendCBMsg(88, { - kCBMsgArgDeviceUUID: this._peripherals[deviceUuid].uuid, - kCBMsgArgDescriptorHandle: handle - }); -}; - - - -/** - * Write value directly to handle - * - * @param {[type]} deviceUuid [description] - * @param {[type]} handle [description] - * @param {[type]} data [description] - * @param {[type]} withoutResponse [description] - * - * @discussion tested - */ -nobleBindings.writeHandle = function(deviceUuid, handle, data, withoutResponse) { - // TODO: use without response - this.sendCBMsg(89, { - kCBMsgArgDeviceUUID: this._peripherals[deviceUuid].uuid, - kCBMsgArgDescriptorHandle: handle, - kCBMsgArgData: data - }); -}; - - -// Exports -module.exports = nobleBindings; diff --git a/lib/mac/legacy.js b/lib/mac/legacy.js deleted file mode 100644 index 76854efcc..000000000 --- a/lib/mac/legacy.js +++ /dev/null @@ -1,629 +0,0 @@ -var events = require('events'); -var os = require('os'); -var util = require('util'); - -var debug = require('debug')('legacy-bindings'); - -var osRelease = os.release(); -var isLessThan10_8_5 = (parseFloat(osRelease) < 12.5); - -var localAddress = require('./local-address'); -var uuidToAddress = require('./uuid-to-address'); - -var XpcConnection = require('xpc-connection'); - -var NobleBindings = function() { - this._peripherals = {}; - - this._xpcConnection = new XpcConnection('com.apple.blued'); - - this._xpcConnection.on('error', function(message) { - this.emit('xpcError', message); - }.bind(this)); - - this._xpcConnection.on('event', function(event) { - this.emit('xpcEvent', event); - }.bind(this)); -}; - -util.inherits(NobleBindings, events.EventEmitter); - -NobleBindings.prototype.sendXpcMessage = function(message) { - this._xpcConnection.sendMessage(message); -}; - -var nobleBindings = new NobleBindings(); - -nobleBindings.on('xpcEvent', function(event) { - var kCBMsgId = event.kCBMsgId; - var kCBMsgArgs = event.kCBMsgArgs; - - debug('xpcEvent: ' + JSON.stringify(event, undefined, 2)); - - this.emit('kCBMsgId' + kCBMsgId, kCBMsgArgs); -}); - -/* - Result codes ... - - CBErrorUnknown, - - CBATTErrorInvalidHandle = 0x01, - CBATTErrorReadNotPermitted = 0x02, - CBATTErrorWriteNotPermitted = 0x03, - CBATTErrorInvalidPdu = 0x04, - CBATTErrorInsufficientAuthentication = 0x05, - CBATTErrorRequestNotSupported = 0x06, - CBATTErrorInvalidOffset = 0x07, - CBATTErrorInsufficientAuthorization = 0x08, - CBATTErrorPrepareQueueFull = 0x09, - CBATTErrorAttributeNotFound = 0x0A, - CBATTErrorAttributeNotLong = 0x0B, - CBATTErrorInsufficientEncryptionKeySize = 0x0C, - CBATTErrorInvalidAttributeValueLength = 0x0D, - CBATTErrorUnlikelyError = 0x0E, - CBATTErrorInsufficientEncryption = 0x0F, - CBATTErrorUnsupportedGroupType = 0x10, - CBATTErrorInsufficientResources = 0x11, -*/ - -nobleBindings.on('xpcError', function(message) { - console.error('xpcError: ' + message); -}); - -nobleBindings.sendCBMsg = function(id, args) { - debug('sendCBMsg: ' + id + ', ' + JSON.stringify(args, undefined, 2)); - this.sendXpcMessage({ - kCBMsgId: id, - kCBMsgArgs: args - }); -}; - -nobleBindings.init = function() { - this._xpcConnection.setup(); - - localAddress(function(address) { - if (address) { - this.emit('addressChange', address); - } - - this.sendCBMsg(1, { - kCBMsgArgAlert: 1, - kCBMsgArgName: 'node-' + (new Date()).getTime() - }); - }.bind(this)); -}; - -nobleBindings.on('kCBMsgId4', function(args) { - var state = ['unknown', 'resetting', 'unsupported', 'unauthorized', 'poweredOff', 'poweredOn'][args.kCBMsgArgState]; - debug('state change ' + state); - this.emit('stateChange', state); -}); - -nobleBindings.startScanning = function(serviceUuids, allowDuplicates) { - var args = { - kCBMsgArgOptions: {}, - kCBMsgArgUUIDs: [] - }; - - if (serviceUuids) { - for(var i = 0; i < serviceUuids.length; i++) { - args.kCBMsgArgUUIDs[i] = new Buffer(serviceUuids[i], 'hex'); - } - } - - if (allowDuplicates) { - args.kCBMsgArgOptions.kCBScanOptionAllowDuplicates = 1; - } - - this.sendCBMsg(isLessThan10_8_5 ? 7 : 23, args); - - this.emit('scanStart'); -}; - -nobleBindings.stopScanning = function() { - this.sendCBMsg(isLessThan10_8_5 ? 8 : 24, null); - - this.emit('scanStop'); -}; - -nobleBindings.on(isLessThan10_8_5 ? 'kCBMsgId13' : 'kCBMsgId31', function(args) { - var peripheralUuid = args.kCBMsgArgPeripheral.kCBMsgArgUUID.toString('hex'); - var peripheralHandle = args.kCBMsgArgPeripheral.kCBMsgArgPeripheralHandle; - var advertisement = { - localName: args.kCBMsgArgAdvertisementData.kCBAdvDataLocalName, - txPowerLevel: args.kCBMsgArgAdvertisementData.kCBAdvDataTxPowerLevel, - manufacturerData: args.kCBMsgArgAdvertisementData.kCBAdvDataManufacturerData, - serviceData: [], - serviceUuids: [] - }; - var rssi = args.kCBMsgArgRssi; - var i; - - if (args.kCBMsgArgAdvertisementData.kCBAdvDataServiceUUIDs) { - for(i = 0; i < args.kCBMsgArgAdvertisementData.kCBAdvDataServiceUUIDs.length; i++) { - advertisement.serviceUuids.push(args.kCBMsgArgAdvertisementData.kCBAdvDataServiceUUIDs[i].toString('hex')); - } - } - - var serviceData = args.kCBMsgArgAdvertisementData.kCBAdvDataServiceData; - if (serviceData) { - for (i = 0; i < serviceData.length; i += 2) { - var serviceDataUuid = serviceData[i].toString('hex'); - var data = serviceData[i + 1]; - - advertisement.serviceData.push({ - uuid: serviceDataUuid, - data: data - }); - } - } - - debug('peripheral ' + peripheralUuid + ' discovered'); - - this._peripherals[peripheralUuid] = this._peripherals[peripheralHandle] = { - uuid: peripheralUuid, - address: undefined, - addressType: undefined, - handle: peripheralHandle, - advertisement: advertisement, - rssi: rssi - }; - - (function(peripheralUuid, peripheralHandle, advertisement, rssi) { - uuidToAddress(peripheralUuid, function(error, address, addressType) { - address = address || 'unknown'; - addressType = addressType || 'unknown'; - - this._peripherals[peripheralUuid].address = this._peripherals[peripheralHandle].address = address; - this._peripherals[peripheralUuid].addressType = this._peripherals[peripheralHandle].addressType = addressType; - - this.emit('discover', peripheralUuid, address, addressType, undefined, advertisement, rssi); - }.bind(this)); - }.bind(this))(peripheralUuid, peripheralHandle, advertisement, rssi); -}); - -nobleBindings.connect = function(peripheralUuid) { - this.sendCBMsg(isLessThan10_8_5 ? 9 : 25, { - kCBMsgArgOptions: { - kCBConnectOptionNotifyOnDisconnection: 1 - }, - kCBMsgArgPeripheralHandle: this._peripherals[peripheralUuid].handle - }); -}; - -nobleBindings.on(isLessThan10_8_5 ? 'kCBMsgId14' : 'kCBMsgId32', function(args) { - var peripheralUuid = args.kCBMsgArgUUID.toString('hex'); - // var peripheralHandle = args.kCBMsgArgPeripheralHandle; - - debug('peripheral ' + peripheralUuid + ' connected'); - - this.emit('connect', peripheralUuid); -}); - -nobleBindings.disconnect = function(peripheralUuid) { - this.sendCBMsg(isLessThan10_8_5 ? 10 : 26, { - kCBMsgArgPeripheralHandle: this._peripherals[peripheralUuid].handle - }); -}; - -nobleBindings.on(isLessThan10_8_5 ? 'kCBMsgId15' : 'kCBMsgId33', function(args) { - var peripheralUuid = args.kCBMsgArgUUID.toString('hex'); - // var peripheralHandle = args.kCBMsgArgPeripheralHandle; - - debug('peripheral ' + peripheralUuid + ' disconnected'); - - this.emit('disconnect', peripheralUuid); -}); - -nobleBindings.updateRssi = function(peripheralUuid) { - this.sendCBMsg(isLessThan10_8_5 ? 16 : 35, { - kCBMsgArgPeripheralHandle: this._peripherals[peripheralUuid].handle - }); -}; - -nobleBindings.on(isLessThan10_8_5 ? 'kCBMsgId20' : 'kCBMsgId41', function(args) { - var peripheralHandle = args.kCBMsgArgPeripheralHandle; - var peripheralUuid = this._peripherals[peripheralHandle].uuid; - var rssi = args.kCBMsgArgData; - - this._peripherals[peripheralHandle].rssi = rssi; - - debug('peripheral ' + peripheralUuid + ' RSSI update ' + rssi); - - this.emit('rssiUpdate', peripheralUuid, rssi); -}); - -nobleBindings.discoverServices = function(peripheralUuid, uuids) { - var args = { - kCBMsgArgPeripheralHandle: this._peripherals[peripheralUuid].handle, - kCBMsgArgUUIDs: [] - }; - - if (uuids) { - for(var i = 0; i < uuids.length; i++) { - args.kCBMsgArgUUIDs[i] = new Buffer(uuids[i], 'hex'); - } - } - - this.sendCBMsg(isLessThan10_8_5 ? 17 : 36, args); -}; - -nobleBindings.on(isLessThan10_8_5 ? 'kCBMsgId21' : 'kCBMsgId42', function(args) { - var peripheralHandle = args.kCBMsgArgPeripheralHandle; - var peripheralUuid = this._peripherals[peripheralHandle].uuid; - var serviceUuids = []; - - this._peripherals[peripheralHandle].services = {}; - - for(var i = 0; i < args.kCBMsgArgServices.length; i++) { - var service = { - uuid: args.kCBMsgArgServices[i].kCBMsgArgUUID.toString('hex'), - startHandle: args.kCBMsgArgServices[i].kCBMsgArgServiceStartHandle, - endHandle: args.kCBMsgArgServices[i].kCBMsgArgServiceEndHandle - }; - - this._peripherals[peripheralHandle].services[service.uuid] = this._peripherals[peripheralHandle].services[service.startHandle] = service; - - serviceUuids.push(service.uuid); - } - - this.emit('servicesDiscover', peripheralUuid, serviceUuids); -}); - -nobleBindings.discoverIncludedServices = function(peripheralUuid, serviceUuid, serviceUuids) { - var args = { - kCBMsgArgPeripheralHandle: this._peripherals[peripheralUuid].handle, - kCBMsgArgServiceStartHandle: this._peripherals[peripheralUuid].services[serviceUuid].startHandle, - kCBMsgArgServiceEndHandle: this._peripherals[peripheralUuid].services[serviceUuid].endHandle, - kCBMsgArgUUIDs: [] - }; - - if (serviceUuids) { - for(var i = 0; i < serviceUuids.length; i++) { - args.kCBMsgArgUUIDs[i] = new Buffer(serviceUuids[i], 'hex'); - } - } - - this.sendCBMsg(isLessThan10_8_5 ? 25 : 46, args); -}; - -nobleBindings.on(isLessThan10_8_5 ? 'kCBMsgId27' : 'kCBMsgId48', function(args) { - var peripheralUuidHandle = args.kCBMsgArgPeripheralHandle; - var peripheralUuid = this._peripherals[peripheralUuidHandle].uuid; - var serviceStartHandle = args.kCBMsgArgServiceStartHandle; - var serviceUuid = this._peripherals[peripheralUuidHandle].services[serviceStartHandle].uuid; - var result = args.kCBMsgArgResult; - var includedServiceUuids = []; - - this._peripherals[peripheralUuidHandle].services[serviceStartHandle].includedServices = {}; - - for(var i = 0; i < args.kCBMsgArgServices.length; i++) { - var includedService = { - uuid: args.kCBMsgArgServices[i].kCBMsgArgUUID.toString('hex'), - startHandle: args.kCBMsgArgServices[i].kCBMsgArgServiceStartHandle, - endHandle: args.kCBMsgArgServices[i].kCBMsgArgServiceEndHandle - }; - - this._peripherals[peripheralUuidHandle].services[serviceStartHandle].includedServices[includedServices.uuid] = - this._peripherals[peripheralUuidHandle].services[serviceStartHandle].includedServices[includedServices.startHandle] = includedService; - - includedServiceUuids.push(includedService.uuid); - } - - this.emit('includedServicesDiscover', peripheralUuid, serviceUuid, includedServiceUuids); -}); - -nobleBindings.discoverCharacteristics = function(peripheralUuid, serviceUuid, characteristicUuids) { - var args = { - kCBMsgArgPeripheralHandle: this._peripherals[peripheralUuid].handle, - kCBMsgArgServiceStartHandle: this._peripherals[peripheralUuid].services[serviceUuid].startHandle, - kCBMsgArgServiceEndHandle: this._peripherals[peripheralUuid].services[serviceUuid].endHandle, - kCBMsgArgUUIDs: [] - }; - - if (characteristicUuids) { - for(var i = 0; i < characteristicUuids.length; i++) { - args.kCBMsgArgUUIDs[i] = new Buffer(characteristicUuids[i], 'hex'); - } - } - - this.sendCBMsg(isLessThan10_8_5 ? 26 : 47, args); -}; - -nobleBindings.on(isLessThan10_8_5 ? 'kCBMsgId28' : 'kCBMsgId49', function(args) { - var peripheralHandle = args.kCBMsgArgPeripheralHandle; - var peripheralUuid = this._peripherals[peripheralHandle].uuid; - var serviceStartHandle = args.kCBMsgArgServiceStartHandle; - var serviceUuid = this._peripherals[peripheralHandle].services[serviceStartHandle].uuid; - var result = args.kCBMsgArgResult; - var characteristics = []; - - this._peripherals[peripheralHandle].services[serviceStartHandle].characteristics = {}; - - for(var i = 0; i < args.kCBMsgArgCharacteristics.length; i++) { - var properties = args.kCBMsgArgCharacteristics[i].kCBMsgArgCharacteristicProperties; - - var characteristic = { - uuid: args.kCBMsgArgCharacteristics[i].kCBMsgArgUUID.toString('hex'), - handle: args.kCBMsgArgCharacteristics[i].kCBMsgArgCharacteristicHandle, - valueHandle: args.kCBMsgArgCharacteristics[i].kCBMsgArgCharacteristicValueHandle, - properties: [] - }; - - if (properties & 0x01) { - characteristic.properties.push('broadcast'); - } - - if (properties & 0x02) { - characteristic.properties.push('read'); - } - - if (properties & 0x04) { - characteristic.properties.push('writeWithoutResponse'); - } - - if (properties & 0x08) { - characteristic.properties.push('write'); - } - - if (properties & 0x10) { - characteristic.properties.push('notify'); - } - - if (properties & 0x20) { - characteristic.properties.push('indicate'); - } - - if (properties & 0x40) { - characteristic.properties.push('authenticatedSignedWrites'); - } - - if (properties & 0x80) { - characteristic.properties.push('extendedProperties'); - } - - this._peripherals[peripheralHandle].services[serviceStartHandle].characteristics[characteristic.uuid] = - this._peripherals[peripheralHandle].services[serviceStartHandle].characteristics[characteristic.handle] = - this._peripherals[peripheralHandle].services[serviceStartHandle].characteristics[characteristic.valueHandle] = characteristic; - - characteristics.push({ - uuid: characteristic.uuid, - properties: characteristic.properties - }); - } - - this.emit('characteristicsDiscover', peripheralUuid, serviceUuid, characteristics); -}); - -nobleBindings.read = function(peripheralUuid, serviceUuid, characteristicUuid) { - this.sendCBMsg(isLessThan10_8_5 ? 29 : 50 , { - kCBMsgArgPeripheralHandle: this._peripherals[peripheralUuid].handle, - kCBMsgArgCharacteristicHandle: this._peripherals[peripheralUuid].services[serviceUuid].characteristics[characteristicUuid].handle, - kCBMsgArgCharacteristicValueHandle: this._peripherals[peripheralUuid].services[serviceUuid].characteristics[characteristicUuid].valueHandle - }); -}; - -nobleBindings.on(isLessThan10_8_5 ? 'kCBMsgId35' : 'kCBMsgId56', function(args) { - var peripheralHandle = args.kCBMsgArgPeripheralHandle; - var peripheral = this._peripherals[peripheralHandle]; - - if (peripheral) { - var peripheralUuid = peripheral.uuid; - var characteristicHandle = args.kCBMsgArgCharacteristicHandle; - var isNotification = args.kCBMsgArgIsNotification ? true : false; - var data = args.kCBMsgArgData; - - for(var i in peripheral.services) { - if (peripheral.services[i].characteristics && - peripheral.services[i].characteristics[characteristicHandle]) { - - this.emit('read', peripheralUuid, peripheral.services[i].uuid, - peripheral.services[i].characteristics[characteristicHandle].uuid, data, isNotification); - break; - } - } - } else { - console.warn('noble (mac legacy): received read event from unknown peripheral: ' + peripheralHandle + ' !'); - } -}); - -nobleBindings.write = function(peripheralUuid, serviceUuid, characteristicUuid, data, withoutResponse) { - this.sendCBMsg(isLessThan10_8_5 ? 30 : 51, { - kCBMsgArgPeripheralHandle: this._peripherals[peripheralUuid].handle, - kCBMsgArgCharacteristicHandle: this._peripherals[peripheralUuid].services[serviceUuid].characteristics[characteristicUuid].handle, - kCBMsgArgCharacteristicValueHandle: this._peripherals[peripheralUuid].services[serviceUuid].characteristics[characteristicUuid].valueHandle, - kCBMsgArgData: data, - kCBMsgArgType: (withoutResponse ? 1 : 0) - }); - - if (withoutResponse) { - this.emit('write', peripheralUuid, serviceUuid, characteristicUuid); - } -}; - -nobleBindings.on(isLessThan10_8_5 ? 'kCBMsgId36' : 'kCBMsgId57', function(args) { - var peripheralHandle = args.kCBMsgArgPeripheralHandle; - var peripheralUuid = this._peripherals[peripheralHandle].uuid; - var characteristicHandle = args.kCBMsgArgCharacteristicHandle; - var result = args.kCBMsgArgResult; - - for(var i in this._peripherals[peripheralHandle].services) { - if (this._peripherals[peripheralHandle].services[i].characteristics && - this._peripherals[peripheralHandle].services[i].characteristics[characteristicHandle]) { - this.emit('write', peripheralUuid, this._peripherals[peripheralHandle].services[i].uuid, - this._peripherals[peripheralHandle].services[i].characteristics[characteristicHandle].uuid); - break; - } - } -}); - -nobleBindings.broadcast = function(peripheralUuid, serviceUuid, characteristicUuid, broadcast) { - this.sendCBMsg(isLessThan10_8_5 ? 31 : 52, { - kCBMsgArgPeripheralHandle: this._peripherals[peripheralUuid].handle, - kCBMsgArgCharacteristicHandle: this._peripherals[peripheralUuid].services[serviceUuid].characteristics[characteristicUuid].handle, - kCBMsgArgCharacteristicValueHandle: this._peripherals[peripheralUuid].services[serviceUuid].characteristics[characteristicUuid].valueHandle, - kCBMsgArgState: (broadcast ? 1 : 0) - }); -}; - -nobleBindings.on(isLessThan10_8_5 ? 'kCBMsgId37' : 'kCBMsgId58', function(args) { - var peripheralHandle = args.kCBMsgArgPeripheralHandle; - var peripheralUuid = this._peripherals[peripheralHandle].uuid; - var characteristicHandle = args.kCBMsgArgCharacteristicHandle; - var result = args.kCBMsgArgResult; - var state = args.kCBMsgArgState ? true : false; - - for(var i in this._peripherals[peripheralHandle].services) { - if (this._peripherals[peripheralHandle].services[i].characteristics && - this._peripherals[peripheralHandle].services[i].characteristics[characteristicHandle]) { - this.emit('broadcast', peripheralUuid, this._peripherals[peripheralHandle].services[i].uuid, - this._peripherals[peripheralHandle].services[i].characteristics[characteristicHandle].uuid, state); - break; - } - } -}); - -nobleBindings.notify = function(peripheralUuid, serviceUuid, characteristicUuid, notify) { - this.sendCBMsg(isLessThan10_8_5 ? 32 : 53, { - kCBMsgArgPeripheralHandle: this._peripherals[peripheralUuid].handle, - kCBMsgArgCharacteristicHandle: this._peripherals[peripheralUuid].services[serviceUuid].characteristics[characteristicUuid].handle, - kCBMsgArgCharacteristicValueHandle: this._peripherals[peripheralUuid].services[serviceUuid].characteristics[characteristicUuid].valueHandle, - kCBMsgArgState: (notify ? 1 : 0) - }); -}; - -nobleBindings.on(isLessThan10_8_5 ? 'kCBMsgId38' : 'kCBMsgId59', function(args) { - var peripheralHandle = args.kCBMsgArgPeripheralHandle; - var peripheralUuid = this._peripherals[peripheralHandle].uuid; - var characteristicHandle = args.kCBMsgArgCharacteristicHandle; - var result = args.kCBMsgArgResult; - var state = args.kCBMsgArgState ? true : false; - - for(var i in this._peripherals[peripheralHandle].services) { - if (this._peripherals[peripheralHandle].services[i].characteristics && - this._peripherals[peripheralHandle].services[i].characteristics[characteristicHandle]) { - this.emit('notify', peripheralUuid, this._peripherals[peripheralHandle].services[i].uuid, - this._peripherals[peripheralHandle].services[i].characteristics[characteristicHandle].uuid, state); - break; - } - } -}); - -nobleBindings.discoverDescriptors = function(peripheralUuid, serviceUuid, characteristicUuid) { - this.sendCBMsg(isLessThan10_8_5 ? 34 : 55, { - kCBMsgArgPeripheralHandle: this._peripherals[peripheralUuid].handle, - kCBMsgArgCharacteristicHandle: this._peripherals[peripheralUuid].services[serviceUuid].characteristics[characteristicUuid].handle, - kCBMsgArgCharacteristicValueHandle: this._peripherals[peripheralUuid].services[serviceUuid].characteristics[characteristicUuid].valueHandle - }); -}; - -nobleBindings.on(isLessThan10_8_5 ? 'kCBMsgId39' : 'kCBMsgId60', function(args) { - var peripheralHandle = args.kCBMsgArgPeripheralHandle; - var peripheralUuid = this._peripherals[peripheralHandle].uuid; - var characteristicHandle = args.kCBMsgArgCharacteristicHandle; - var result = args.kCBMsgArgResult; - var descriptors = []; //args.kCBMsgArgDescriptors; - - for(var i in this._peripherals[peripheralHandle].services) { - if (this._peripherals[peripheralHandle].services[i].characteristics && - this._peripherals[peripheralHandle].services[i].characteristics[characteristicHandle]) { - - this._peripherals[peripheralHandle].services[i].characteristics[characteristicHandle].descriptors = {}; - - for(var j = 0; j < args.kCBMsgArgDescriptors.length; j++) { - var descriptor = { - uuid: args.kCBMsgArgDescriptors[j].kCBMsgArgUUID.toString('hex'), - handle: args.kCBMsgArgDescriptors[j].kCBMsgArgDescriptorHandle - }; - - this._peripherals[peripheralHandle].services[i].characteristics[characteristicHandle].descriptors[descriptor.uuid] = - this._peripherals[peripheralHandle].services[i].characteristics[characteristicHandle].descriptors[descriptor.handle] = descriptor; - - descriptors.push(descriptor.uuid); - } - - this.emit('descriptorsDiscover', peripheralUuid, this._peripherals[peripheralHandle].services[i].uuid, - this._peripherals[peripheralHandle].services[i].characteristics[characteristicHandle].uuid, descriptors); - break; - } - } -}); - -nobleBindings.readValue = function(peripheralUuid, serviceUuid, characteristicUuid, descriptorUuid) { - this.sendCBMsg(isLessThan10_8_5 ? 40 : 61, { - kCBMsgArgPeripheralHandle: this._peripherals[peripheralUuid].handle, - kCBMsgArgDescriptorHandle: this._peripherals[peripheralUuid].services[serviceUuid].characteristics[characteristicUuid].descriptors[descriptorUuid].handle - }); -}; - -nobleBindings.on(isLessThan10_8_5 ? 'kCBMsgId42' : 'kCBMsgId63', function(args) { - var peripheralHandle = args.kCBMsgArgPeripheralHandle; - var peripheralUuid = this._peripherals[peripheralHandle].uuid; - var descriptorHandle = args.kCBMsgArgDescriptorHandle; - var result = args.kCBMsgArgResult; - var data = args.kCBMsgArgData; - - this.emit('handleRead', peripheralUuid, descriptorHandle, data); - - for(var i in this._peripherals[peripheralHandle].services) { - for(var j in this._peripherals[peripheralHandle].services[i].characteristics) { - if (this._peripherals[peripheralHandle].services[i].characteristics[j].descriptors && - this._peripherals[peripheralHandle].services[i].characteristics[j].descriptors[descriptorHandle]) { - - this.emit('valueRead', peripheralUuid, this._peripherals[peripheralHandle].services[i].uuid, - this._peripherals[peripheralHandle].services[i].characteristics[j].uuid, - this._peripherals[peripheralHandle].services[i].characteristics[j].descriptors[descriptorHandle].uuid, data); - return; // break; - } - } - } -}); - -nobleBindings.writeValue = function(peripheralUuid, serviceUuid, characteristicUuid, descriptorUuid, data) { - this.sendCBMsg(isLessThan10_8_5 ? 41 : 62, { - kCBMsgArgPeripheralHandle: this._peripherals[peripheralUuid].handle, - kCBMsgArgDescriptorHandle: this._peripherals[peripheralUuid].services[serviceUuid].characteristics[characteristicUuid].descriptors[descriptorUuid].handle, - kCBMsgArgData: data - }); -}; - -nobleBindings.on(isLessThan10_8_5 ? 'kCBMsgId43' : 'kCBMsgId64', function(args) { - var peripheralHandle = args.kCBMsgArgPeripheralHandle; - var peripheralUuid = this._peripherals[peripheralHandle].uuid; - var descriptorHandle = args.kCBMsgArgDescriptorHandle; - var result = args.kCBMsgArgResult; - - this.emit('handleWrite', peripheralUuid, descriptorHandle); - - for(var i in this._peripherals[peripheralHandle].services) { - for(var j in this._peripherals[peripheralHandle].services[i].characteristics) { - if (this._peripherals[peripheralHandle].services[i].characteristics[j].descriptors && - this._peripherals[peripheralHandle].services[i].characteristics[j].descriptors[descriptorHandle]) { - - this.emit('valueWrite', peripheralUuid, this._peripherals[peripheralHandle].services[i].uuid, - this._peripherals[peripheralHandle].services[i].characteristics[j].uuid, - this._peripherals[peripheralHandle].services[i].characteristics[j].descriptors[descriptorHandle].uuid); - return; // break; - } - } - } -}); - -nobleBindings.readHandle = function(peripheralUuid, handle) { - this.sendCBMsg(isLessThan10_8_5 ? 40 : 61, { - kCBMsgArgPeripheralHandle: this._peripherals[peripheralUuid].handle, - kCBMsgArgDescriptorHandle: handle - }); -}; - -nobleBindings.writeHandle = function(peripheralUuid, handle, data, withoutResponse) { - // TODO: use without response - this.sendCBMsg(isLessThan10_8_5 ? 41 : 62, { - kCBMsgArgPeripheralHandle: this._peripherals[peripheralUuid].handle, - kCBMsgArgDescriptorHandle: handle, - kCBMsgArgData: data - }); -}; - -module.exports = nobleBindings; diff --git a/lib/mac/local-address.js b/lib/mac/local-address.js deleted file mode 100644 index 2a7f3e0ed..000000000 --- a/lib/mac/local-address.js +++ /dev/null @@ -1,18 +0,0 @@ -var child_process = require('child_process'); - -function localAddress(callback) { - child_process.exec('system_profiler SPBluetoothDataType', {}, function(error, stdout, stderr) { - var address = null; - - if (!error) { - var found = stdout.match(/\s+Address: (.*)/); - if (found) { - address = found[1].toLowerCase().replace(/-/g, ':'); - } - } - - callback(address); - }); -} - -module.exports = localAddress; diff --git a/lib/mac/mavericks.js b/lib/mac/mavericks.js deleted file mode 100644 index 82d467910..000000000 --- a/lib/mac/mavericks.js +++ /dev/null @@ -1,603 +0,0 @@ -var events = require('events'); -var os = require('os'); -var util = require('util'); - -var debug = require('debug')('mavericks-bindings'); - -var XpcConnection = require('xpc-connection'); - -var localAddress = require('./local-address'); -var uuidToAddress = require('./uuid-to-address'); - -var NobleBindings = function() { - this._peripherals = {}; - - this._xpcConnection = new XpcConnection('com.apple.blued'); - - this._xpcConnection.on('error', function(message) { - this.emit('xpcError', message); - }.bind(this)); - - this._xpcConnection.on('event', function(event) { - this.emit('xpcEvent', event); - }.bind(this)); -}; - -util.inherits(NobleBindings, events.EventEmitter); - -NobleBindings.prototype.sendXpcMessage = function(message) { - this._xpcConnection.sendMessage(message); -}; - -var nobleBindings = new NobleBindings(); - -nobleBindings.on('xpcEvent', function(event) { - var kCBMsgId = event.kCBMsgId; - var kCBMsgArgs = event.kCBMsgArgs; - - debug('xpcEvent: ' + JSON.stringify(event, undefined, 2)); - - this.emit('kCBMsgId' + kCBMsgId, kCBMsgArgs); -}); - -nobleBindings.on('xpcError', function(message) { - console.error('xpcError: ' + message); -}); - -nobleBindings.sendCBMsg = function(id, args) { - debug('sendCBMsg: ' + id + ', ' + JSON.stringify(args, undefined, 2)); - this.sendXpcMessage({ - kCBMsgId: id, - kCBMsgArgs: args - }); -}; - -nobleBindings.init = function() { - this._xpcConnection.setup(); - - localAddress(function(address) { - if (address) { - this.emit('addressChange', address); - } - - this.sendCBMsg(1, { - kCBMsgArgName: 'node-' + (new Date()).getTime(), - kCBMsgArgOptions: { - kCBInitOptionShowPowerAlert: 0 - }, - kCBMsgArgType: 0 - }); - }.bind(this)); -}; - -nobleBindings.on('kCBMsgId6', function(args) { - var state = ['unknown', 'resetting', 'unsupported', 'unauthorized', 'poweredOff', 'poweredOn'][args.kCBMsgArgState]; - debug('state change ' + state); - this.emit('stateChange', state); -}); - -nobleBindings.startScanning = function(serviceUuids, allowDuplicates) { - var args = { - kCBMsgArgOptions: {}, - kCBMsgArgUUIDs: [] - }; - - if (serviceUuids) { - for(var i = 0; i < serviceUuids.length; i++) { - args.kCBMsgArgUUIDs[i] = new Buffer(serviceUuids[i], 'hex'); - } - } - - if (allowDuplicates) { - args.kCBMsgArgOptions.kCBScanOptionAllowDuplicates = 1; - } - - this.sendCBMsg(29, args); - - this.emit('scanStart'); -}; - -nobleBindings.stopScanning = function() { - this.sendCBMsg(30, null); - - this.emit('scanStop'); -}; - -nobleBindings.on('kCBMsgId37', function(args) { - if (Object.keys(args.kCBMsgArgAdvertisementData).length === 0) { - return; - } - - var deviceUuid = args.kCBMsgArgDeviceUUID.toString('hex'); - var advertisement = { - localName: args.kCBMsgArgAdvertisementData.kCBAdvDataLocalName || args.kCBMsgArgName, - txPowerLevel: args.kCBMsgArgAdvertisementData.kCBAdvDataTxPowerLevel, - manufacturerData: args.kCBMsgArgAdvertisementData.kCBAdvDataManufacturerData, - serviceData: [], - serviceUuids: [] - }; - var rssi = args.kCBMsgArgRssi; - var i; - - if (args.kCBMsgArgAdvertisementData.kCBAdvDataServiceUUIDs) { - for(i = 0; i < args.kCBMsgArgAdvertisementData.kCBAdvDataServiceUUIDs.length; i++) { - advertisement.serviceUuids.push(args.kCBMsgArgAdvertisementData.kCBAdvDataServiceUUIDs[i].toString('hex')); - } - } - - var serviceData = args.kCBMsgArgAdvertisementData.kCBAdvDataServiceData; - if (serviceData) { - for (i = 0; i < serviceData.length; i += 2) { - var serviceDataUuid = serviceData[i].toString('hex'); - var data = serviceData[i + 1]; - - advertisement.serviceData.push({ - uuid: serviceDataUuid, - data: data - }); - } - } - - debug('peripheral ' + deviceUuid + ' discovered'); - - var uuid = new Buffer(deviceUuid, 'hex'); - uuid.isUuid = true; - - if(!this._peripherals[deviceUuid]) { - this._peripherals[deviceUuid] = {}; - } - this._peripherals[deviceUuid].uuid = uuid; - this._peripherals[deviceUuid].advertisement = advertisement; - this._peripherals[deviceUuid].rssi = rssi; - - (function(deviceUuid, advertisement, rssi) { - uuidToAddress(deviceUuid, function(error, address, addressType) { - address = address || 'unknown'; - addressType = addressType || 'unknown'; - - this._peripherals[deviceUuid].address = address; - this._peripherals[deviceUuid].addressType = addressType; - - this.emit('discover', deviceUuid, address, addressType, undefined, advertisement, rssi); - }.bind(this)); - }.bind(this))(deviceUuid, advertisement, rssi); -}); - -nobleBindings.connect = function(deviceUuid) { - this.sendCBMsg(31, { - kCBMsgArgOptions: { - kCBConnectOptionNotifyOnDisconnection: 1 - }, - kCBMsgArgDeviceUUID: this._peripherals[deviceUuid].uuid - }); -}; - -nobleBindings.on('kCBMsgId38', function(args) { - var deviceUuid = args.kCBMsgArgDeviceUUID.toString('hex'); - - debug('peripheral ' + deviceUuid + ' connected'); - - this.emit('connect', deviceUuid); -}); - -nobleBindings.disconnect = function(deviceUuid) { - this.sendCBMsg(32, { - kCBMsgArgDeviceUUID: this._peripherals[deviceUuid].uuid - }); -}; - -nobleBindings.on('kCBMsgId40', function(args) { - var deviceUuid = args.kCBMsgArgDeviceUUID.toString('hex'); - - debug('peripheral ' + deviceUuid + ' disconnected'); - - this.emit('disconnect', deviceUuid); -}); - -nobleBindings.updateRssi = function(deviceUuid) { - this.sendCBMsg(43, { - kCBMsgArgDeviceUUID: this._peripherals[deviceUuid].uuid - }); -}; - -nobleBindings.on('kCBMsgId54', function(args) { - var deviceUuid = args.kCBMsgArgDeviceUUID.toString('hex'); - var rssi = args.kCBMsgArgData; - - this._peripherals[deviceUuid].rssi = rssi; - - debug('peripheral ' + deviceUuid + ' RSSI update ' + rssi); - - this.emit('rssiUpdate', deviceUuid, rssi); -}); - -nobleBindings.discoverServices = function(deviceUuid, uuids) { - var args = { - kCBMsgArgDeviceUUID: this._peripherals[deviceUuid].uuid, - kCBMsgArgUUIDs: [] - }; - - if (uuids) { - for(var i = 0; i < uuids.length; i++) { - args.kCBMsgArgUUIDs[i] = new Buffer(uuids[i], 'hex'); - } - } - - this.sendCBMsg(44, args); -}; - -nobleBindings.on('kCBMsgId55', function(args) { - var deviceUuid = args.kCBMsgArgDeviceUUID.toString('hex'); - var serviceUuids = []; - - this._peripherals[deviceUuid].services = this._peripherals[deviceUuid].services || {}; - - if (args.kCBMsgArgServices) { - for(var i = 0; i < args.kCBMsgArgServices.length; i++) { - var service = { - uuid: args.kCBMsgArgServices[i].kCBMsgArgUUID.toString('hex'), - startHandle: args.kCBMsgArgServices[i].kCBMsgArgServiceStartHandle, - endHandle: args.kCBMsgArgServices[i].kCBMsgArgServiceEndHandle - }; - - this._peripherals[deviceUuid].services[service.uuid] = this._peripherals[deviceUuid].services[service.startHandle] = service; - - serviceUuids.push(service.uuid); - } - } - // TODO: result 24 => device not connected - - this.emit('servicesDiscover', deviceUuid, serviceUuids); -}); - -nobleBindings.discoverIncludedServices = function(deviceUuid, serviceUuid, serviceUuids) { - var args = { - kCBMsgArgDeviceUUID: this._peripherals[deviceUuid].uuid, - kCBMsgArgServiceStartHandle: this._peripherals[deviceUuid].services[serviceUuid].startHandle, - kCBMsgArgServiceEndHandle: this._peripherals[deviceUuid].services[serviceUuid].endHandle, - kCBMsgArgUUIDs: [] - }; - - if (serviceUuids) { - for(var i = 0; i < serviceUuids.length; i++) { - args.kCBMsgArgUUIDs[i] = new Buffer(serviceUuids[i], 'hex'); - } - } - - this.sendCBMsg(60, args); -}; - -nobleBindings.on('kCBMsgId62', function(args) { - var deviceUuid = args.kCBMsgArgDeviceUUID.toString('hex'); - var serviceStartHandle = args.kCBMsgArgServiceStartHandle; - var serviceUuid = this._peripherals[deviceUuid].services[serviceStartHandle].uuid; - var result = args.kCBMsgArgResult; - var includedServiceUuids = []; - - this._peripherals[deviceUuid].services[serviceStartHandle].includedServices = - this._peripherals[deviceUuid].services[serviceStartHandle].includedServices || {}; - - for(var i = 0; i < args.kCBMsgArgServices.length; i++) { - var includedService = { - uuid: args.kCBMsgArgServices[i].kCBMsgArgUUID.toString('hex'), - startHandle: args.kCBMsgArgServices[i].kCBMsgArgServiceStartHandle, - endHandle: args.kCBMsgArgServices[i].kCBMsgArgServiceEndHandle - }; - - if (! this._peripherals[deviceUuid].services[serviceStartHandle].includedServices[includedServices.uuid]) { - this._peripherals[deviceUuid].services[serviceStartHandle].includedServices[includedServices.uuid] = - this._peripherals[deviceUuid].services[serviceStartHandle].includedServices[includedServices.startHandle] = includedService; - } - - includedServiceUuids.push(includedService.uuid); - } - - this.emit('includedServicesDiscover', deviceUuid, serviceUuid, includedServiceUuids); -}); - -nobleBindings.discoverCharacteristics = function(deviceUuid, serviceUuid, characteristicUuids) { - var args = { - kCBMsgArgDeviceUUID: this._peripherals[deviceUuid].uuid, - kCBMsgArgServiceStartHandle: this._peripherals[deviceUuid].services[serviceUuid].startHandle, - kCBMsgArgServiceEndHandle: this._peripherals[deviceUuid].services[serviceUuid].endHandle, - kCBMsgArgUUIDs: [] - }; - - if (characteristicUuids) { - for(var i = 0; i < characteristicUuids.length; i++) { - args.kCBMsgArgUUIDs[i] = new Buffer(characteristicUuids[i], 'hex'); - } - } - - this.sendCBMsg(61, args); -}; - -nobleBindings.on('kCBMsgId63', function(args) { - var deviceUuid = args.kCBMsgArgDeviceUUID.toString('hex'); - var serviceStartHandle = args.kCBMsgArgServiceStartHandle; - var serviceUuid = this._peripherals[deviceUuid].services[serviceStartHandle].uuid; - var result = args.kCBMsgArgResult; - var characteristics = []; - - this._peripherals[deviceUuid].services[serviceStartHandle].characteristics = - this._peripherals[deviceUuid].services[serviceStartHandle].characteristics || {}; - - for(var i = 0; i < args.kCBMsgArgCharacteristics.length; i++) { - var properties = args.kCBMsgArgCharacteristics[i].kCBMsgArgCharacteristicProperties; - - var characteristic = { - uuid: args.kCBMsgArgCharacteristics[i].kCBMsgArgUUID.toString('hex'), - handle: args.kCBMsgArgCharacteristics[i].kCBMsgArgCharacteristicHandle, - valueHandle: args.kCBMsgArgCharacteristics[i].kCBMsgArgCharacteristicValueHandle, - properties: [] - }; - - if (properties & 0x01) { - characteristic.properties.push('broadcast'); - } - - if (properties & 0x02) { - characteristic.properties.push('read'); - } - - if (properties & 0x04) { - characteristic.properties.push('writeWithoutResponse'); - } - - if (properties & 0x08) { - characteristic.properties.push('write'); - } - - if (properties & 0x10) { - characteristic.properties.push('notify'); - } - - if (properties & 0x20) { - characteristic.properties.push('indicate'); - } - - if (properties & 0x40) { - characteristic.properties.push('authenticatedSignedWrites'); - } - - if (properties & 0x80) { - characteristic.properties.push('extendedProperties'); - } - - this._peripherals[deviceUuid].services[serviceStartHandle].characteristics[characteristic.uuid] = - this._peripherals[deviceUuid].services[serviceStartHandle].characteristics[characteristic.handle] = - this._peripherals[deviceUuid].services[serviceStartHandle].characteristics[characteristic.valueHandle] = characteristic; - - characteristics.push({ - uuid: characteristic.uuid, - properties: characteristic.properties - }); - } - - this.emit('characteristicsDiscover', deviceUuid, serviceUuid, characteristics); -}); - -nobleBindings.read = function(deviceUuid, serviceUuid, characteristicUuid) { - this.sendCBMsg(64 , { - kCBMsgArgDeviceUUID: this._peripherals[deviceUuid].uuid, - kCBMsgArgCharacteristicHandle: this._peripherals[deviceUuid].services[serviceUuid].characteristics[characteristicUuid].handle, - kCBMsgArgCharacteristicValueHandle: this._peripherals[deviceUuid].services[serviceUuid].characteristics[characteristicUuid].valueHandle - }); -}; - -nobleBindings.on('kCBMsgId70', function(args) { - var deviceUuid = args.kCBMsgArgDeviceUUID.toString('hex'); - var characteristicHandle = args.kCBMsgArgCharacteristicHandle; - var isNotification = args.kCBMsgArgIsNotification ? true : false; - var data = args.kCBMsgArgData; - - var peripheral = this._peripherals[deviceUuid]; - - if (peripheral) { - for(var i in peripheral.services) { - if (peripheral.services[i].characteristics && - peripheral.services[i].characteristics[characteristicHandle]) { - - this.emit('read', deviceUuid, peripheral.services[i].uuid, - peripheral.services[i].characteristics[characteristicHandle].uuid, data, isNotification); - break; - } - } - } else { - console.warn('noble (mac mavericks): received read event from unknown peripheral: ' + deviceUuid + ' !'); - } -}); - -nobleBindings.write = function(deviceUuid, serviceUuid, characteristicUuid, data, withoutResponse) { - this.sendCBMsg(65, { - kCBMsgArgDeviceUUID: this._peripherals[deviceUuid].uuid, - kCBMsgArgCharacteristicHandle: this._peripherals[deviceUuid].services[serviceUuid].characteristics[characteristicUuid].handle, - kCBMsgArgCharacteristicValueHandle: this._peripherals[deviceUuid].services[serviceUuid].characteristics[characteristicUuid].valueHandle, - kCBMsgArgData: data, - kCBMsgArgType: (withoutResponse ? 1 : 0) - }); - - if (withoutResponse) { - this.emit('write', deviceUuid, serviceUuid, characteristicUuid); - } -}; - -nobleBindings.on('kCBMsgId71', function(args) { - var deviceUuid = args.kCBMsgArgDeviceUUID.toString('hex'); - var characteristicHandle = args.kCBMsgArgCharacteristicHandle; - var result = args.kCBMsgArgResult; - - for(var i in this._peripherals[deviceUuid].services) { - if (this._peripherals[deviceUuid].services[i].characteristics && - this._peripherals[deviceUuid].services[i].characteristics[characteristicHandle]) { - this.emit('write', deviceUuid, this._peripherals[deviceUuid].services[i].uuid, - this._peripherals[deviceUuid].services[i].characteristics[characteristicHandle].uuid); - break; - } - } -}); - -nobleBindings.broadcast = function(deviceUuid, serviceUuid, characteristicUuid, broadcast) { - this.sendCBMsg(66, { - kCBMsgArgDeviceUUID: this._peripherals[deviceUuid].uuid, - kCBMsgArgCharacteristicHandle: this._peripherals[deviceUuid].services[serviceUuid].characteristics[characteristicUuid].handle, - kCBMsgArgCharacteristicValueHandle: this._peripherals[deviceUuid].services[serviceUuid].characteristics[characteristicUuid].valueHandle, - kCBMsgArgState: (broadcast ? 1 : 0) - }); -}; - -nobleBindings.on('kCBMsgId72', function(args) { - var deviceUuid = args.kCBMsgArgDeviceUUID.toString('hex'); - var characteristicHandle = args.kCBMsgArgCharacteristicHandle; - var result = args.kCBMsgArgResult; - var state = args.kCBMsgArgState ? true : false; - - for(var i in this._peripherals[deviceUuid].services) { - if (this._peripherals[deviceUuid].services[i].characteristics && - this._peripherals[deviceUuid].services[i].characteristics[characteristicHandle]) { - this.emit('broadcast', deviceUuid, this._peripherals[deviceUuid].services[i].uuid, - this._peripherals[deviceUuid].services[i].characteristics[characteristicHandle].uuid, state); - break; - } - } -}); - -nobleBindings.notify = function(deviceUuid, serviceUuid, characteristicUuid, notify) { - this.sendCBMsg(67, { - kCBMsgArgDeviceUUID: this._peripherals[deviceUuid].uuid, - kCBMsgArgCharacteristicHandle: this._peripherals[deviceUuid].services[serviceUuid].characteristics[characteristicUuid].handle, - kCBMsgArgCharacteristicValueHandle: this._peripherals[deviceUuid].services[serviceUuid].characteristics[characteristicUuid].valueHandle, - kCBMsgArgState: (notify ? 1 : 0) - }); -}; - -nobleBindings.on('kCBMsgId73', function(args) { - var deviceUuid = args.kCBMsgArgDeviceUUID.toString('hex'); - var characteristicHandle = args.kCBMsgArgCharacteristicHandle; - var result = args.kCBMsgArgResult; - var state = args.kCBMsgArgState ? true : false; - - for(var i in this._peripherals[deviceUuid].services) { - if (this._peripherals[deviceUuid].services[i].characteristics && - this._peripherals[deviceUuid].services[i].characteristics[characteristicHandle]) { - this.emit('notify', deviceUuid, this._peripherals[deviceUuid].services[i].uuid, - this._peripherals[deviceUuid].services[i].characteristics[characteristicHandle].uuid, state); - break; - } - } -}); - -nobleBindings.discoverDescriptors = function(deviceUuid, serviceUuid, characteristicUuid) { - this.sendCBMsg(69, { - kCBMsgArgDeviceUUID: this._peripherals[deviceUuid].uuid, - kCBMsgArgCharacteristicHandle: this._peripherals[deviceUuid].services[serviceUuid].characteristics[characteristicUuid].handle, - kCBMsgArgCharacteristicValueHandle: this._peripherals[deviceUuid].services[serviceUuid].characteristics[characteristicUuid].valueHandle - }); -}; - -nobleBindings.on('kCBMsgId75', function(args) { - var deviceUuid = args.kCBMsgArgDeviceUUID.toString('hex'); - var characteristicHandle = args.kCBMsgArgCharacteristicHandle; - var result = args.kCBMsgArgResult; - var descriptors = []; //args.kCBMsgArgDescriptors; - - for(var i in this._peripherals[deviceUuid].services) { - if (this._peripherals[deviceUuid].services[i].characteristics && - this._peripherals[deviceUuid].services[i].characteristics[characteristicHandle]) { - - this._peripherals[deviceUuid].services[i].characteristics[characteristicHandle].descriptors = {}; - - for(var j = 0; j < args.kCBMsgArgDescriptors.length; j++) { - var descriptor = { - uuid: args.kCBMsgArgDescriptors[j].kCBMsgArgUUID.toString('hex'), - handle: args.kCBMsgArgDescriptors[j].kCBMsgArgDescriptorHandle - }; - - this._peripherals[deviceUuid].services[i].characteristics[characteristicHandle].descriptors[descriptor.uuid] = - this._peripherals[deviceUuid].services[i].characteristics[characteristicHandle].descriptors[descriptor.handle] = descriptor; - - descriptors.push(descriptor.uuid); - } - - this.emit('descriptorsDiscover', deviceUuid, this._peripherals[deviceUuid].services[i].uuid, - this._peripherals[deviceUuid].services[i].characteristics[characteristicHandle].uuid, descriptors); - break; - } - } -}); - -nobleBindings.readValue = function(deviceUuid, serviceUuid, characteristicUuid, descriptorUuid) { - this.sendCBMsg(76, { - kCBMsgArgDeviceUUID: this._peripherals[deviceUuid].uuid, - kCBMsgArgDescriptorHandle: this._peripherals[deviceUuid].services[serviceUuid].characteristics[characteristicUuid].descriptors[descriptorUuid].handle - }); -}; - -nobleBindings.on('kCBMsgId78', function(args) { - var deviceUuid = args.kCBMsgArgDeviceUUID.toString('hex'); - var descriptorHandle = args.kCBMsgArgDescriptorHandle; - var result = args.kCBMsgArgResult; - var data = args.kCBMsgArgData; - - this.emit('handleRead', deviceUuid, descriptorHandle, data); - - for(var i in this._peripherals[deviceUuid].services) { - for(var j in this._peripherals[deviceUuid].services[i].characteristics) { - if (this._peripherals[deviceUuid].services[i].characteristics[j].descriptors && - this._peripherals[deviceUuid].services[i].characteristics[j].descriptors[descriptorHandle]) { - - this.emit('valueRead', deviceUuid, this._peripherals[deviceUuid].services[i].uuid, - this._peripherals[deviceUuid].services[i].characteristics[j].uuid, - this._peripherals[deviceUuid].services[i].characteristics[j].descriptors[descriptorHandle].uuid, data); - return; // break; - } - } - } -}); - -nobleBindings.writeValue = function(deviceUuid, serviceUuid, characteristicUuid, descriptorUuid, data) { - this.sendCBMsg(77, { - kCBMsgArgDeviceUUID: this._peripherals[deviceUuid].uuid, - kCBMsgArgDescriptorHandle: this._peripherals[deviceUuid].services[serviceUuid].characteristics[characteristicUuid].descriptors[descriptorUuid].handle, - kCBMsgArgData: data - }); -}; - -nobleBindings.on('kCBMsgId79', function(args) { - var deviceUuid = args.kCBMsgArgDeviceUUID.toString('hex'); - var descriptorHandle = args.kCBMsgArgDescriptorHandle; - var result = args.kCBMsgArgResult; - - this.emit('handleWrite', deviceUuid, descriptorHandle); - - for(var i in this._peripherals[deviceUuid].services) { - for(var j in this._peripherals[deviceUuid].services[i].characteristics) { - if (this._peripherals[deviceUuid].services[i].characteristics[j].descriptors && - this._peripherals[deviceUuid].services[i].characteristics[j].descriptors[descriptorHandle]) { - - this.emit('valueWrite', deviceUuid, this._peripherals[deviceUuid].services[i].uuid, - this._peripherals[deviceUuid].services[i].characteristics[j].uuid, - this._peripherals[deviceUuid].services[i].characteristics[j].descriptors[descriptorHandle].uuid); - return; // break; - } - } - } -}); - -nobleBindings.readHandle = function(deviceUuid, handle) { - this.sendCBMsg(76, { - kCBMsgArgDeviceUUID: this._peripherals[deviceUuid].uuid, - kCBMsgArgDescriptorHandle: handle - }); -}; - -nobleBindings.writeHandle = function(deviceUuid, handle, data, withoutResponse) { - // TODO: use without response - this.sendCBMsg(77, { - kCBMsgArgDeviceUUID: this._peripherals[deviceUuid].uuid, - kCBMsgArgDescriptorHandle: handle, - kCBMsgArgData: data - }); -}; - -module.exports = nobleBindings; diff --git a/lib/mac/uuid-to-address.js b/lib/mac/uuid-to-address.js deleted file mode 100644 index fe4c4867a..000000000 --- a/lib/mac/uuid-to-address.js +++ /dev/null @@ -1,24 +0,0 @@ -var bplist = require('bplist-parser'); - -module.exports = function(uuid, callback) { - bplist.parseFile('/Library/Preferences/com.apple.Bluetooth.plist', function (err, obj) { - if (err) { - return callback(err); - } else if (obj[0].CoreBluetoothCache === undefined) { - return callback(new Error('Empty CoreBluetoothCache entry!')); - } - - uuid = uuid.toUpperCase(); - - var formattedUuid = uuid.substring(0, 8) + '-' + - uuid.substring(8, 12) + '-' + - uuid.substring(12, 16) + '-' + - uuid.substring(16, 20) + '-' + - uuid.substring(20); - - var coreBluetoothCacheEntry = obj[0].CoreBluetoothCache[formattedUuid]; - var address = coreBluetoothCacheEntry ? coreBluetoothCacheEntry.DeviceAddress.replace(/-/g, ':') : undefined; - - callback(null, address); - }); -}; diff --git a/lib/mac/yosemite.js b/lib/mac/yosemite.js deleted file mode 100644 index 79a4d39a0..000000000 --- a/lib/mac/yosemite.js +++ /dev/null @@ -1,865 +0,0 @@ -var events = require('events'); -var os = require('os'); -var util = require('util'); - -var debug = require('debug')('yosemite-bindings'); - -var XpcConnection = require('xpc-connection'); - -var localAddress = require('./local-address'); -var uuidToAddress = require('./uuid-to-address'); - -/** - * NobleBindings for mac - */ -var NobleBindings = function() { - this._peripherals = {}; - - this._xpcConnection = new XpcConnection('com.apple.blued'); - this._xpcConnection.on('error', function(message) {this.emit('xpcError', message);}.bind(this)); - this._xpcConnection.on('event', function(event) {this.emit('xpcEvent', event); }.bind(this)); -}; - -util.inherits(NobleBindings, events.EventEmitter); - -NobleBindings.prototype.sendXpcMessage = function(message) { - this._xpcConnection.sendMessage(message); -}; - -var nobleBindings = new NobleBindings(); - -// General xpc message handling -nobleBindings.on('xpcEvent', function(event) { - debug('xpcEvent: ' + JSON.stringify(event, undefined, 2)); - - var kCBMsgId = event.kCBMsgId; - var kCBMsgArgs = event.kCBMsgArgs; - this.emit('kCBMsgId' + kCBMsgId, kCBMsgArgs); -}); - -nobleBindings.on('xpcError', function(message) { - console.error('xpcError: ' + message); -}); - -nobleBindings.sendCBMsg = function(id, args) { - debug('sendCBMsg: ' + id + ', ' + JSON.stringify(args, undefined, 2)); - this.sendXpcMessage({kCBMsgId: id,kCBMsgArgs: args}); -}; - - - - -/** - * Init xpc connection to blued - * - * @discussion tested - */ -nobleBindings.init = function() { - this._xpcConnection.setup(); - - localAddress(function(address) { - if (address) { - this.emit('addressChange', address); - } - - this.sendCBMsg(1, { - kCBMsgArgName: 'node-' + (new Date()).getTime(), - kCBMsgArgOptions: { - kCBInitOptionShowPowerAlert: 0 - }, - kCBMsgArgType: 0 - }); - }.bind(this)); -}; - -nobleBindings.on('kCBMsgId6', function(args) { - var state = ['unknown', 'resetting', 'unsupported', 'unauthorized', 'poweredOff', 'poweredOn'][args.kCBMsgArgState]; - debug('state change ' + state); - this.emit('stateChange', state); -}); - - - -/** - * Start scanning - * @param {Array} serviceUuids Scan for these UUIDs, if undefined then scan for all - * @param {Bool} allowDuplicates Scan can return duplicates - * - * @discussion tested - */ -nobleBindings.startScanning = function(serviceUuids, allowDuplicates) { - var args = { - kCBMsgArgOptions: {}, - kCBMsgArgUUIDs: [] - }; - - if (serviceUuids) { - for(var i = 0; i < serviceUuids.length; i++) { - args.kCBMsgArgUUIDs[i] = new Buffer(serviceUuids[i], 'hex'); - } - } - - if (allowDuplicates) { - args.kCBMsgArgOptions.kCBScanOptionAllowDuplicates = 1; - } - - this.sendCBMsg(29, args); - this.emit('scanStart'); -}; - -/** - * Response message to start scanning - * - * @example - * // For `TI Sensortag` the message lookes like this: - * handleMsg: 37, { - * kCBMsgArgAdvertisementData = { - * kCBAdvDataIsConnectable = 1; - * kCBAdvDataLocalName = SensorTag; - * kCBAdvDataTxPowerLevel = 0; - * }; - * kCBMsgArgDeviceUUID = "<__NSConcreteUUID 0x6180000208e0> 53486C7A-DED2-4AA6-8913-387CD22F25D8"; - * kCBMsgArgName = SensorTag; - * kCBMsgArgRssi = "-68"; - * } - * - * @discussion tested - */ -nobleBindings.on('kCBMsgId37', function(args) { - if (Object.keys(args.kCBMsgArgAdvertisementData).length === 0 || - (args.kCBMsgArgAdvertisementData.kCBAdvDataIsConnectable !== undefined && - Object.keys(args.kCBMsgArgAdvertisementData).length === 1)) { - return; - } - - var deviceUuid = args.kCBMsgArgDeviceUUID.toString('hex'); - var advertisement = { - localName: args.kCBMsgArgAdvertisementData.kCBAdvDataLocalName || args.kCBMsgArgName, - txPowerLevel: args.kCBMsgArgAdvertisementData.kCBAdvDataTxPowerLevel, - manufacturerData: args.kCBMsgArgAdvertisementData.kCBAdvDataManufacturerData, - serviceData: [], - serviceUuids: [] - }; - var connectable = args.kCBMsgArgAdvertisementData.kCBAdvDataIsConnectable ? true : false; - var rssi = args.kCBMsgArgRssi; - var i; - - if (args.kCBMsgArgAdvertisementData.kCBAdvDataServiceUUIDs) { - for(i = 0; i < args.kCBMsgArgAdvertisementData.kCBAdvDataServiceUUIDs.length; i++) { - advertisement.serviceUuids.push(args.kCBMsgArgAdvertisementData.kCBAdvDataServiceUUIDs[i].toString('hex')); - } - } - - var serviceData = args.kCBMsgArgAdvertisementData.kCBAdvDataServiceData; - if (serviceData) { - for (i = 0; i < serviceData.length; i += 2) { - var serviceDataUuid = serviceData[i].toString('hex'); - var data = serviceData[i + 1]; - - advertisement.serviceData.push({ - uuid: serviceDataUuid, - data: data - }); - } - } - - debug('peripheral ' + deviceUuid + ' discovered'); - - var uuid = new Buffer(deviceUuid, 'hex'); - uuid.isUuid = true; - - if (!this._peripherals[deviceUuid]) { - this._peripherals[deviceUuid] = {}; - } - - this._peripherals[deviceUuid].uuid = uuid; - this._peripherals[deviceUuid].connectable = connectable; - this._peripherals[deviceUuid].advertisement = advertisement; - this._peripherals[deviceUuid].rssi = rssi; - - (function(deviceUuid, advertisement, rssi) { - uuidToAddress(deviceUuid, function(error, address, addressType) { - address = address || 'unknown'; - addressType = addressType || 'unknown'; - - this._peripherals[deviceUuid].address = address; - this._peripherals[deviceUuid].addressType = addressType; - - this.emit('discover', deviceUuid, address, addressType, connectable, advertisement, rssi); - }.bind(this)); - }.bind(this))(deviceUuid, advertisement, rssi); -}); - - -/** - * Stop scanning - * - * @discussion tested - */ -nobleBindings.stopScanning = function() { - this.sendCBMsg(30, null); - this.emit('scanStop'); -}; - - - -/** - * Connect to peripheral - * @param {String} deviceUuid Peripheral uuid to connect to - * - * @discussion tested - */ -nobleBindings.connect = function(deviceUuid) { - this.sendCBMsg(31, { - kCBMsgArgOptions: { - kCBConnectOptionNotifyOnDisconnection: 1 - }, - kCBMsgArgDeviceUUID: this._peripherals[deviceUuid].uuid - }); -}; - -nobleBindings.on('kCBMsgId38', function(args) { - var deviceUuid = args.kCBMsgArgDeviceUUID.toString('hex'); - - debug('peripheral ' + deviceUuid + ' connected'); - - this.emit('connect', deviceUuid); -}); - - - -/** - * Disconnect - * - * @param {String} deviceUuid Peripheral uuid to disconnect - * - * @discussion tested - */ -nobleBindings.disconnect = function(deviceUuid) { - this.sendCBMsg(32, { - kCBMsgArgDeviceUUID: this._peripherals[deviceUuid].uuid - }); -}; - -/** - * Response to disconnect - * - * @discussion tested - */ -nobleBindings.on('kCBMsgId40', function(args) { - var deviceUuid = args.kCBMsgArgDeviceUUID.toString('hex'); - - debug('peripheral ' + deviceUuid + ' disconnected'); - - this.emit('disconnect', deviceUuid); -}); - - - -/** - * Update RSSI - * - * @discussion tested - */ -nobleBindings.updateRssi = function(deviceUuid) { - this.sendCBMsg(44, { - kCBMsgArgDeviceUUID: this._peripherals[deviceUuid].uuid - }); -}; - -/** - * Response to RSSI update - * - * @discussion tested - */ -nobleBindings.on('kCBMsgId55', function(args) { - var deviceUuid = args.kCBMsgArgDeviceUUID.toString('hex'); - var rssi = args.kCBMsgArgData; - - this._peripherals[deviceUuid].rssi = rssi; - - debug('peripheral ' + deviceUuid + ' RSSI update ' + rssi); - - this.emit('rssiUpdate', deviceUuid, rssi); -}); - - - -/** - * Discover services - * - * @param {String} deviceUuid Device UUID - * @param {Array} uuids Services to discover, if undefined then all - * - * @discussion tested - */ -nobleBindings.discoverServices = function(deviceUuid, uuids) { - var args = { - kCBMsgArgDeviceUUID: this._peripherals[deviceUuid].uuid, - kCBMsgArgUUIDs: [] - }; - - if (uuids) { - for(var i = 0; i < uuids.length; i++) { - args.kCBMsgArgUUIDs[i] = new Buffer(uuids[i], 'hex'); - } - } - - this.sendCBMsg(45, args); -}; - -/** - * Response to discover service - * - * @discussion tested - */ -nobleBindings.on('kCBMsgId56', function(args) { - var deviceUuid = args.kCBMsgArgDeviceUUID.toString('hex'); - var serviceUuids = []; - - this._peripherals[deviceUuid].services = this._peripherals[deviceUuid].services || {}; - - if (args.kCBMsgArgServices) { - for(var i = 0; i < args.kCBMsgArgServices.length; i++) { - var service = { - uuid: args.kCBMsgArgServices[i].kCBMsgArgUUID.toString('hex'), - startHandle: args.kCBMsgArgServices[i].kCBMsgArgServiceStartHandle, - endHandle: args.kCBMsgArgServices[i].kCBMsgArgServiceEndHandle - }; - - if (typeof this._peripherals[deviceUuid].services[service.uuid] == 'undefined') { - this._peripherals[deviceUuid].services[service.uuid] = this._peripherals[deviceUuid].services[service.startHandle] = service; - } - - serviceUuids.push(service.uuid); - } - } - // TODO: result 24 => device not connected - - this.emit('servicesDiscover', deviceUuid, serviceUuids); -}); - - - -/** - * [discoverIncludedServices description] - * - * @param {String} deviceUuid - * @param {String} serviceUuid - * @param {String} serviceUuids - * - * @dicussion tested - */ -nobleBindings.discoverIncludedServices = function(deviceUuid, serviceUuid, serviceUuids) { - var args = { - kCBMsgArgDeviceUUID: this._peripherals[deviceUuid].uuid, - kCBMsgArgServiceStartHandle: this._peripherals[deviceUuid].services[serviceUuid].startHandle, - kCBMsgArgServiceEndHandle: this._peripherals[deviceUuid].services[serviceUuid].endHandle, - kCBMsgArgUUIDs: [] - }; - - if (serviceUuids) { - for(var i = 0; i < serviceUuids.length; i++) { - args.kCBMsgArgUUIDs[i] = new Buffer(serviceUuids[i], 'hex'); - } - } - - this.sendCBMsg(61, args); -}; - -/** - * Response to dicover included services - * - * @dicussion tested - */ -nobleBindings.on('kCBMsgId63', function(args) { - var deviceUuid = args.kCBMsgArgDeviceUUID.toString('hex'); - var serviceStartHandle = args.kCBMsgArgServiceStartHandle; - var serviceUuid = this._peripherals[deviceUuid].services[serviceStartHandle].uuid; - var result = args.kCBMsgArgResult; - var includedServiceUuids = []; - - this._peripherals[deviceUuid].services[serviceStartHandle].includedServices = - this._peripherals[deviceUuid].services[serviceStartHandle].includedServices || {}; - - for(var i = 0; i < args.kCBMsgArgServices.length; i++) { - var includedService = { - uuid: args.kCBMsgArgServices[i].kCBMsgArgUUID.toString('hex'), - startHandle: args.kCBMsgArgServices[i].kCBMsgArgServiceStartHandle, - endHandle: args.kCBMsgArgServices[i].kCBMsgArgServiceEndHandle - }; - - this._peripherals[deviceUuid].services[serviceStartHandle].includedServices[includedServices.uuid] = - this._peripherals[deviceUuid].services[serviceStartHandle].includedServices[includedServices.startHandle] = includedService; - - includedServiceUuids.push(includedService.uuid); - } - - this.emit('includedServicesDiscover', deviceUuid, serviceUuid, includedServiceUuids); -}); - - - -/** - * Discover characteristic - * - * @param {String} deviceUuid Peripheral UUID - * @param {String} serviceUuid Service UUID - * @param {Array} characteristicUuids Characteristics to discover, all if empty - * - * @discussion tested - */ -nobleBindings.discoverCharacteristics = function(deviceUuid, serviceUuid, characteristicUuids) { - var args = { - kCBMsgArgDeviceUUID: this._peripherals[deviceUuid].uuid, - kCBMsgArgServiceStartHandle: this._peripherals[deviceUuid].services[serviceUuid].startHandle, - kCBMsgArgServiceEndHandle: this._peripherals[deviceUuid].services[serviceUuid].endHandle, - kCBMsgArgUUIDs: [] - }; - - if (characteristicUuids) { - for(var i = 0; i < characteristicUuids.length; i++) { - args.kCBMsgArgUUIDs[i] = new Buffer(characteristicUuids[i], 'hex'); - } - } - - this.sendCBMsg(62, args); -}; - -/** - * Response to characteristic discovery - * - * @discussion tested - */ -nobleBindings.on('kCBMsgId64', function(args) { - var deviceUuid = args.kCBMsgArgDeviceUUID.toString('hex'); - var serviceStartHandle = args.kCBMsgArgServiceStartHandle; - var serviceUuid = this._peripherals[deviceUuid].services[serviceStartHandle].uuid; - var result = args.kCBMsgArgResult; - var characteristics = []; - - this._peripherals[deviceUuid].services[serviceStartHandle].characteristics = - this._peripherals[deviceUuid].services[serviceStartHandle].characteristics || {}; - - for(var i = 0; i < args.kCBMsgArgCharacteristics.length; i++) { - var properties = args.kCBMsgArgCharacteristics[i].kCBMsgArgCharacteristicProperties; - - var characteristic = { - uuid: args.kCBMsgArgCharacteristics[i].kCBMsgArgUUID.toString('hex'), - handle: args.kCBMsgArgCharacteristics[i].kCBMsgArgCharacteristicHandle, - valueHandle: args.kCBMsgArgCharacteristics[i].kCBMsgArgCharacteristicValueHandle, - properties: [] - }; - - if (properties & 0x01) { - characteristic.properties.push('broadcast'); - } - - if (properties & 0x02) { - characteristic.properties.push('read'); - } - - if (properties & 0x04) { - characteristic.properties.push('writeWithoutResponse'); - } - - if (properties & 0x08) { - characteristic.properties.push('write'); - } - - if (properties & 0x10) { - characteristic.properties.push('notify'); - } - - if (properties & 0x20) { - characteristic.properties.push('indicate'); - } - - if (properties & 0x40) { - characteristic.properties.push('authenticatedSignedWrites'); - } - - if (properties & 0x80) { - characteristic.properties.push('extendedProperties'); - } - - this._peripherals[deviceUuid].services[serviceStartHandle].characteristics[characteristic.uuid] = - this._peripherals[deviceUuid].services[serviceStartHandle].characteristics[characteristic.handle] = - this._peripherals[deviceUuid].services[serviceStartHandle].characteristics[characteristic.valueHandle] = characteristic; - - characteristics.push({ - uuid: characteristic.uuid, - properties: characteristic.properties - }); - } - - this.emit('characteristicsDiscover', deviceUuid, serviceUuid, characteristics); -}); - - - -/** - * Read value - * - * @param {[type]} deviceUuid [description] - * @param {[type]} serviceUuid [description] - * @param {[type]} characteristicUuid [description] - * - * @discussion tested - */ -nobleBindings.read = function(deviceUuid, serviceUuid, characteristicUuid) { - this.sendCBMsg(65 , { - kCBMsgArgDeviceUUID: this._peripherals[deviceUuid].uuid, - kCBMsgArgCharacteristicHandle: this._peripherals[deviceUuid].services[serviceUuid].characteristics[characteristicUuid].handle, - kCBMsgArgCharacteristicValueHandle: this._peripherals[deviceUuid].services[serviceUuid].characteristics[characteristicUuid].valueHandle - }); -}; - -/** - * Response to read value - * - * @discussion tested - */ -nobleBindings.on('kCBMsgId71', function(args) { - var deviceUuid = args.kCBMsgArgDeviceUUID.toString('hex'); - var characteristicHandle = args.kCBMsgArgCharacteristicHandle; - var isNotification = args.kCBMsgArgIsNotification ? true : false; - var data = args.kCBMsgArgData; - - var peripheral = this._peripherals[deviceUuid]; - - if (peripheral) { - for(var i in peripheral.services) { - if (peripheral.services[i].characteristics && - peripheral.services[i].characteristics[characteristicHandle]) { - - this.emit('read', deviceUuid, peripheral.services[i].uuid, - peripheral.services[i].characteristics[characteristicHandle].uuid, data, isNotification); - break; - } - } - } else { - console.warn('noble (mac yosemite): received read event from unknown peripheral: ' + deviceUuid + ' !'); - } -}); - - - -/** - * Write value - * @param {String} deviceUuid - * @param {String} serviceUuid - * @param {String} characteristicUuid - * @param {[Type]} data - * @param {Bool} withoutResponse - * - * @discussion tested - */ -nobleBindings.write = function(deviceUuid, serviceUuid, characteristicUuid, data, withoutResponse) { - this.sendCBMsg(66, { - kCBMsgArgDeviceUUID: this._peripherals[deviceUuid].uuid, - kCBMsgArgCharacteristicHandle: this._peripherals[deviceUuid].services[serviceUuid].characteristics[characteristicUuid].handle, - kCBMsgArgCharacteristicValueHandle: this._peripherals[deviceUuid].services[serviceUuid].characteristics[characteristicUuid].valueHandle, - kCBMsgArgData: data, - kCBMsgArgType: (withoutResponse ? 1 : 0) - }); - - if (withoutResponse) { - this.emit('write', deviceUuid, serviceUuid, characteristicUuid); - } -}; - -/** - * Response to write - * - * @discussion tested - */ -nobleBindings.on('kCBMsgId72', function(args) { - var deviceUuid = args.kCBMsgArgDeviceUUID.toString('hex'); - var characteristicHandle = args.kCBMsgArgCharacteristicHandle; - var result = args.kCBMsgArgResult; - - for(var i in this._peripherals[deviceUuid].services) { - if (this._peripherals[deviceUuid].services[i].characteristics && - this._peripherals[deviceUuid].services[i].characteristics[characteristicHandle]) { - this.emit('write', deviceUuid, this._peripherals[deviceUuid].services[i].uuid, - this._peripherals[deviceUuid].services[i].characteristics[characteristicHandle].uuid); - break; - } - } -}); - - - -/** - * Broadcast - * - * @param {[type]} deviceUuid [description] - * @param {[type]} serviceUuid [description] - * @param {[type]} characteristicUuid [description] - * @param {[type]} broadcast [description] - * @return {[type]} [description] - * - * @discussion The ids were incemented but there seems to be no CoreBluetooth function to call/verify this. - */ -nobleBindings.broadcast = function(deviceUuid, serviceUuid, characteristicUuid, broadcast) { - this.sendCBMsg(67, { - kCBMsgArgDeviceUUID: this._peripherals[deviceUuid].uuid, - kCBMsgArgCharacteristicHandle: this._peripherals[deviceUuid].services[serviceUuid].characteristics[characteristicUuid].handle, - kCBMsgArgCharacteristicValueHandle: this._peripherals[deviceUuid].services[serviceUuid].characteristics[characteristicUuid].valueHandle, - kCBMsgArgState: (broadcast ? 1 : 0) - }); -}; - -/** - * Response to broadcast - * - * @discussion The ids were incemented but there seems to be no CoreBluetooth function to call/verify this. - */ -nobleBindings.on('kCBMsgId73', function(args) { - var deviceUuid = args.kCBMsgArgDeviceUUID.toString('hex'); - var characteristicHandle = args.kCBMsgArgCharacteristicHandle; - var result = args.kCBMsgArgResult; - var state = args.kCBMsgArgState ? true : false; - - for(var i in this._peripherals[deviceUuid].services) { - if (this._peripherals[deviceUuid].services[i].characteristics && - this._peripherals[deviceUuid].services[i].characteristics[characteristicHandle]) { - this.emit('broadcast', deviceUuid, this._peripherals[deviceUuid].services[i].uuid, - this._peripherals[deviceUuid].services[i].characteristics[characteristicHandle].uuid, state); - break; - } - } -}); - - - -/** - * Register notification hanlder - * - * @param {String} deviceUuid Peripheral UUID - * @param {String} serviceUuid Service UUID - * @param {String} characteristicUuid Charactereistic UUID - * @param {Bool} notify If want to get notification - * - * @discussion tested - */ -nobleBindings.notify = function(deviceUuid, serviceUuid, characteristicUuid, notify) { - this.sendCBMsg(68, { - kCBMsgArgDeviceUUID: this._peripherals[deviceUuid].uuid, - kCBMsgArgCharacteristicHandle: this._peripherals[deviceUuid].services[serviceUuid].characteristics[characteristicUuid].handle, - kCBMsgArgCharacteristicValueHandle: this._peripherals[deviceUuid].services[serviceUuid].characteristics[characteristicUuid].valueHandle, - kCBMsgArgState: (notify ? 1 : 0) - }); -}; - -/** - * Response notification - * - * @discussion tested - */ -nobleBindings.on('kCBMsgId74', function(args) { - var deviceUuid = args.kCBMsgArgDeviceUUID.toString('hex'); - var characteristicHandle = args.kCBMsgArgCharacteristicHandle; - var result = args.kCBMsgArgResult; - var state = args.kCBMsgArgState ? true : false; - - for(var i in this._peripherals[deviceUuid].services) { - if (this._peripherals[deviceUuid].services[i].characteristics && - this._peripherals[deviceUuid].services[i].characteristics[characteristicHandle]) { - this.emit('notify', deviceUuid, this._peripherals[deviceUuid].services[i].uuid, - this._peripherals[deviceUuid].services[i].characteristics[characteristicHandle].uuid, state); - break; - } - } -}); - - - -/** - * Discover service descriptors - * - * @param {String} deviceUuid - * @param {String} serviceUuid - * @param {String} characteristicUuid - * - * @discussion tested - */ -nobleBindings.discoverDescriptors = function(deviceUuid, serviceUuid, characteristicUuid) { - this.sendCBMsg(70, { - kCBMsgArgDeviceUUID: this._peripherals[deviceUuid].uuid, - kCBMsgArgCharacteristicHandle: this._peripherals[deviceUuid].services[serviceUuid].characteristics[characteristicUuid].handle, - kCBMsgArgCharacteristicValueHandle: this._peripherals[deviceUuid].services[serviceUuid].characteristics[characteristicUuid].valueHandle - }); -}; - -/** - * Response to descriptor discovery - * - * @discussion tested - */ -nobleBindings.on('kCBMsgId76', function(args) { - var deviceUuid = args.kCBMsgArgDeviceUUID.toString('hex'); - var characteristicHandle = args.kCBMsgArgCharacteristicHandle; - var result = args.kCBMsgArgResult; - var descriptors = []; //args.kCBMsgArgDescriptors; - - for(var i in this._peripherals[deviceUuid].services) { - if (this._peripherals[deviceUuid].services[i].characteristics && - this._peripherals[deviceUuid].services[i].characteristics[characteristicHandle]) { - - this._peripherals[deviceUuid].services[i].characteristics[characteristicHandle].descriptors = {}; - - for(var j = 0; j < args.kCBMsgArgDescriptors.length; j++) { - var descriptor = { - uuid: args.kCBMsgArgDescriptors[j].kCBMsgArgUUID.toString('hex'), - handle: args.kCBMsgArgDescriptors[j].kCBMsgArgDescriptorHandle - }; - - this._peripherals[deviceUuid].services[i].characteristics[characteristicHandle].descriptors[descriptor.uuid] = - this._peripherals[deviceUuid].services[i].characteristics[characteristicHandle].descriptors[descriptor.handle] = descriptor; - - descriptors.push(descriptor.uuid); - } - - this.emit('descriptorsDiscover', deviceUuid, this._peripherals[deviceUuid].services[i].uuid, - this._peripherals[deviceUuid].services[i].characteristics[characteristicHandle].uuid, descriptors); - break; - } - } -}); - - - -/** - * Read value - * - * @param {[type]} deviceUuid [description] - * @param {[type]} serviceUuid [description] - * @param {[type]} characteristicUuid [description] - * @param {[type]} descriptorUuid [description] - * - * @discussion tested - */ -nobleBindings.readValue = function(deviceUuid, serviceUuid, characteristicUuid, descriptorUuid) { - this.sendCBMsg(77, { - kCBMsgArgDeviceUUID: this._peripherals[deviceUuid].uuid, - kCBMsgArgDescriptorHandle: this._peripherals[deviceUuid].services[serviceUuid].characteristics[characteristicUuid].descriptors[descriptorUuid].handle - }); -}; - -/** - * Response to read value - * - * @discussion tested - */ -nobleBindings.on('kCBMsgId79', function(args) { - var deviceUuid = args.kCBMsgArgDeviceUUID.toString('hex'); - var descriptorHandle = args.kCBMsgArgDescriptorHandle; - var result = args.kCBMsgArgResult; - var data = args.kCBMsgArgData; - - this.emit('handleRead', deviceUuid, descriptorHandle, data); - - for(var i in this._peripherals[deviceUuid].services) { - for(var j in this._peripherals[deviceUuid].services[i].characteristics) { - if (this._peripherals[deviceUuid].services[i].characteristics[j].descriptors && - this._peripherals[deviceUuid].services[i].characteristics[j].descriptors[descriptorHandle]) { - - this.emit('valueRead', deviceUuid, this._peripherals[deviceUuid].services[i].uuid, - this._peripherals[deviceUuid].services[i].characteristics[j].uuid, - this._peripherals[deviceUuid].services[i].characteristics[j].descriptors[descriptorHandle].uuid, data); - return; // break; - } - } - } -}); - - - -/** - * Write value - * - * @param {[type]} deviceUuid [description] - * @param {[type]} serviceUuid [description] - * @param {[type]} characteristicUuid [description] - * @param {[type]} descriptorUuid [description] - * @param {[type]} data [description] - * - * @discussion tested - */ -nobleBindings.writeValue = function(deviceUuid, serviceUuid, characteristicUuid, descriptorUuid, data) { - this.sendCBMsg(78, { - kCBMsgArgDeviceUUID: this._peripherals[deviceUuid].uuid, - kCBMsgArgDescriptorHandle: this._peripherals[deviceUuid].services[serviceUuid].characteristics[characteristicUuid].descriptors[descriptorUuid].handle, - kCBMsgArgData: data - }); -}; - -/** - * Response to write value - * - * @discussion tested - */ -nobleBindings.on('kCBMsgId80', function(args) { - var deviceUuid = args.kCBMsgArgDeviceUUID.toString('hex'); - var descriptorHandle = args.kCBMsgArgDescriptorHandle; - var result = args.kCBMsgArgResult; - - this.emit('handleWrite', deviceUuid, descriptorHandle); - - for(var i in this._peripherals[deviceUuid].services) { - for(var j in this._peripherals[deviceUuid].services[i].characteristics) { - if (this._peripherals[deviceUuid].services[i].characteristics[j].descriptors && - this._peripherals[deviceUuid].services[i].characteristics[j].descriptors[descriptorHandle]) { - - this.emit('valueWrite', deviceUuid, this._peripherals[deviceUuid].services[i].uuid, - this._peripherals[deviceUuid].services[i].characteristics[j].uuid, - this._peripherals[deviceUuid].services[i].characteristics[j].descriptors[descriptorHandle].uuid); - return; // break; - } - } - } -}); - - - -/** - * Reade value directly from handle - * - * @param {[type]} deviceUuid [description] - * @param {[type]} handle [description] - * - * @discussion tested - */ -nobleBindings.readHandle = function(deviceUuid, handle) { - this.sendCBMsg(77, { - kCBMsgArgDeviceUUID: this._peripherals[deviceUuid].uuid, - kCBMsgArgDescriptorHandle: handle - }); -}; - - - -/** - * Write value directly to handle - * - * @param {[type]} deviceUuid [description] - * @param {[type]} handle [description] - * @param {[type]} data [description] - * @param {[type]} withoutResponse [description] - * - * @discussion tested - */ -nobleBindings.writeHandle = function(deviceUuid, handle, data, withoutResponse) { - // TODO: use without response - this.sendCBMsg(78, { - kCBMsgArgDeviceUUID: this._peripherals[deviceUuid].uuid, - kCBMsgArgDescriptorHandle: handle, - kCBMsgArgData: data - }); -}; - - -// Exports -module.exports = nobleBindings; diff --git a/package.json b/package.json index 8f4aa9493..991c34009 100644 --- a/package.json +++ b/package.json @@ -36,9 +36,7 @@ "debug": "^4.1.0" }, "optionalDependencies": { - "@abandonware/bluetooth-hci-socket": "^0.5.3-1", - "bplist-parser": "0.1.1", - "xpc-connection": "~0.1.4" + "@abandonware/bluetooth-hci-socket": "^0.5.3-1" }, "devDependencies": { "async": "~2.6.1", From 557f5833177da73ac8b22237246e72052f4f8426 Mon Sep 17 00:00:00 2001 From: Georg Vienna Date: Tue, 23 Oct 2018 11:08:03 +0200 Subject: [PATCH 034/114] add native mac bindings --- .gitignore | 2 + binding.gyp | 14 ++ lib/mac/binding.gyp | 26 +++ lib/mac/bindings.js | 8 + lib/mac/src/ble_manager.h | 41 ++++ lib/mac/src/ble_manager.mm | 435 +++++++++++++++++++++++++++++++++++++ lib/mac/src/callbacks.cc | 224 +++++++++++++++++++ lib/mac/src/callbacks.h | 30 +++ lib/mac/src/napi_objc.h | 12 + lib/mac/src/napi_objc.mm | 50 +++++ lib/mac/src/noble_mac.h | 34 +++ lib/mac/src/noble_mac.mm | 259 ++++++++++++++++++++++ lib/mac/src/objc_cpp.h | 26 +++ lib/mac/src/objc_cpp.mm | 126 +++++++++++ lib/mac/src/peripheral.h | 23 ++ package-lock.json | 129 ++++++----- package.json | 4 +- 17 files changed, 1382 insertions(+), 61 deletions(-) create mode 100644 binding.gyp create mode 100644 lib/mac/binding.gyp create mode 100644 lib/mac/bindings.js create mode 100644 lib/mac/src/ble_manager.h create mode 100644 lib/mac/src/ble_manager.mm create mode 100644 lib/mac/src/callbacks.cc create mode 100644 lib/mac/src/callbacks.h create mode 100644 lib/mac/src/napi_objc.h create mode 100644 lib/mac/src/napi_objc.mm create mode 100644 lib/mac/src/noble_mac.h create mode 100644 lib/mac/src/noble_mac.mm create mode 100644 lib/mac/src/objc_cpp.h create mode 100644 lib/mac/src/objc_cpp.mm create mode 100644 lib/mac/src/peripheral.h diff --git a/.gitignore b/.gitignore index de01ef30d..32a7b46e7 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,5 @@ results build/ node_modules/ npm-debug.log + +lib/mac/native diff --git a/binding.gyp b/binding.gyp new file mode 100644 index 000000000..a907ff84e --- /dev/null +++ b/binding.gyp @@ -0,0 +1,14 @@ +{ + 'targets': [ + { + 'target_name': 'noble', + 'conditions': [ + ['OS=="mac"', { + 'dependencies': [ + 'lib/mac/binding.gyp:binding', + ], + }], + ], + }, + ], +} diff --git a/lib/mac/binding.gyp b/lib/mac/binding.gyp new file mode 100644 index 000000000..b740be771 --- /dev/null +++ b/lib/mac/binding.gyp @@ -0,0 +1,26 @@ +{ + 'targets': [ + { + 'target_name': 'binding', + 'sources': [ 'src/noble_mac.mm', 'src/napi_objc.mm', 'src/ble_manager.mm', 'src/objc_cpp.mm', 'src/callbacks.cc' ], + 'include_dirs': [" +#import +#include + +#include "callbacks.h" + +@interface BLEManager : NSObject { + Emit emit; + bool pendingRead; +} +@property (strong) CBCentralManager *centralManager; +@property dispatch_queue_t dispatchQueue; +@property NSMutableDictionary *peripherals; + +- (instancetype)init: (const Napi::Value&) receiver with: (const Napi::Function&) callback; +- (void)scan: (NSArray *)serviceUUIDs allowDuplicates: (BOOL)allowDuplicates; +- (void)stopScan; +- (BOOL)connect:(NSString*) uuid; +- (BOOL)disconnect:(NSString*) uuid; +- (BOOL)updateRSSI:(NSString*) uuid; +- (BOOL)discoverServices:(NSString*) uuid serviceUuids:(NSArray*) services; +- (BOOL)discoverIncludedServices:(NSString*) uuid forService:(NSString*) serviceUuid services:(NSArray*) serviceUuids; +- (BOOL)discoverCharacteristics:(NSString*) nsAddress forService:(NSString*) service characteristics:(NSArray*) characteristics; +- (BOOL)read:(NSString*) uuid service:(NSString*) serviceUuid characteristic:(NSString*) characteristicUuid; +- (BOOL)write:(NSString*) uuid service:(NSString*) serviceUuid characteristic:(NSString*) characteristicUuid data:(NSData*) data withoutResponse:(BOOL)withoutResponse; +- (BOOL)notify:(NSString*) uuid service:(NSString*) serviceUuid characteristic:(NSString*) characteristicUuid on:(BOOL)on; +- (BOOL)discoverDescriptors:(NSString*) uuid service:(NSString*) serviceUuid characteristic:(NSString*) characteristicUuid; +- (BOOL)readValue:(NSString*) uuid service:(NSString*) serviceUuid characteristic:(NSString*) characteristicUuid descriptor:(NSString*) descriptorUuid; +- (BOOL)writeValue:(NSString*) uuid service:(NSString*) serviceUuid characteristic:(NSString*) characteristicUuid descriptor:(NSString*) descriptorUuid data:(NSData*) data; +- (BOOL)readHandle:(NSString*) uuid handle:(NSNumber*) handle; +- (BOOL)writeHandle:(NSString*) uuid handle:(NSNumber*) handle data:(NSData*) data; +@end diff --git a/lib/mac/src/ble_manager.mm b/lib/mac/src/ble_manager.mm new file mode 100644 index 000000000..030fe5c50 --- /dev/null +++ b/lib/mac/src/ble_manager.mm @@ -0,0 +1,435 @@ +// +// ble_manager.mm +// noble-mac-native +// +// Created by Georg Vienna on 28.08.18. +// +#include "ble_manager.h" + +#import + +#include "objc_cpp.h" + +@implementation BLEManager +- (instancetype)init: (const Napi::Value&) receiver with: (const Napi::Function&) callback { + if (self = [super init]) { + pendingRead = false; + // wrap cb before creating the CentralManager as it may call didUpdateState immediately + self->emit.Wrap(receiver, callback); + self.dispatchQueue = dispatch_queue_create("CBqueue", 0); + self.centralManager = [[CBCentralManager alloc] initWithDelegate:self queue:self.dispatchQueue]; + self.peripherals = [NSMutableDictionary dictionaryWithCapacity:10]; + } + return self; +} + +- (void)centralManagerDidUpdateState:(CBCentralManager *)central { + auto state = stateToString(central.state); + emit.RadioState(state); +} + +- (void)scan: (NSArray *)serviceUUIDs allowDuplicates: (BOOL)allowDuplicates { + NSMutableArray* advServicesUuid = [NSMutableArray arrayWithCapacity:[serviceUUIDs count]]; + [serviceUUIDs enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { + [advServicesUuid addObject:[CBUUID UUIDWithString:obj]]; + }]; + NSDictionary *options = @{CBCentralManagerScanOptionAllowDuplicatesKey:[NSNumber numberWithBool:allowDuplicates]}; + [self.centralManager scanForPeripheralsWithServices:advServicesUuid options:options]; + emit.ScanState(true); +} + +- (void)stopScan { + [self.centralManager stopScan]; + emit.ScanState(false); +} + +- (void) centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeripheral *)peripheral advertisementData:(NSDictionary *)advertisementData RSSI:(NSNumber *)RSSI { + std::string uuid = getUuid(peripheral); + + Peripheral p; + p.address = getAddress(uuid, &p.addressType); + IF(NSNumber*, connect, [advertisementData objectForKey:CBAdvertisementDataIsConnectable]) { + p.connectable = [connect boolValue]; + } + IF(NSString*, dataLocalName, [advertisementData objectForKey:CBAdvertisementDataLocalNameKey]) { + p.name = std::make_pair([dataLocalName UTF8String], true); + } + if(!std::get<1>(p.name)) { + IF(NSString*, name, [peripheral name]) { + p.name = std::make_pair([name UTF8String], true); + } + } + IF(NSNumber*, txLevel, [advertisementData objectForKey:CBAdvertisementDataTxPowerLevelKey]) { + p.txPowerLevel = std::make_pair([txLevel intValue], true); + } + IF(NSData*, data, [advertisementData objectForKey:CBAdvertisementDataManufacturerDataKey]) { + const UInt8* bytes = (UInt8 *)[data bytes]; + std::get<0>(p.manufacturerData).assign(bytes, bytes+[data length]); + std::get<1>(p.manufacturerData) = true; + } + IF(NSDictionary*, dictionary, [advertisementData objectForKey:CBAdvertisementDataServiceDataKey]) { + for (CBUUID* key in dictionary) { + IF(NSData*, value, dictionary[key]) { + auto serviceUuid = [[key UUIDString] UTF8String]; + Data sData; + const UInt8* bytes = (UInt8 *)[value bytes]; + sData.assign(bytes, bytes+[value length]); + std::get<0>(p.serviceData).push_back(std::make_pair(serviceUuid, sData)); + } + } + std::get<1>(p.serviceData) = true; + } + IF(NSArray*, services, [advertisementData objectForKey:CBAdvertisementDataServiceUUIDsKey]) { + for (CBUUID* service in services) { + std::get<0>(p.serviceUuids).push_back([[service UUIDString] UTF8String]); + } + std::get<1>(p.serviceUuids) = true; + } + + int rssi = [RSSI intValue]; + emit.Scan(uuid, rssi, p); +} + +- (BOOL)connect:(NSString*) uuid { + CBPeripheral *peripheral = [self.peripherals objectForKey:uuid]; + if(!peripheral) { + NSArray* peripherals = [self.centralManager retrievePeripheralsWithIdentifiers:@[[[NSUUID alloc] initWithUUIDString:uuid]]]; + peripheral = [peripherals firstObject]; + if(peripheral) { + peripheral.delegate = self; + [self.peripherals setObject:peripheral forKey:uuid]; + } else { + return NO; + } + } + NSDictionary* options = @{CBConnectPeripheralOptionNotifyOnDisconnectionKey: [NSNumber numberWithBool:YES]}; + [self.centralManager connectPeripheral:peripheral options:options]; + return YES; +} + +- (void) centralManager:(CBCentralManager *)central didConnectPeripheral:(CBPeripheral *)peripheral { + std::string uuid = getUuid(peripheral); + emit.Connected(uuid, ""); +} + +- (void) centralManager:(CBCentralManager *)central didFailToConnectPeripheral:(CBPeripheral *)peripheral error:(NSError *)error { + [self.peripherals removeObjectForKey:getNSUuid(peripheral)]; + std::string uuid = getUuid(peripheral); + emit.Connected(uuid, "connection failed"); +} + +- (BOOL)disconnect:(NSString*) uuid { + IF(CBPeripheral*, peripheral, [self.peripherals objectForKey:uuid]) { + [self.centralManager cancelPeripheralConnection:peripheral]; + return YES; + } + return NO; +} + +-(void) centralManager:(CBCentralManager *)central didDisconnectPeripheral:(CBPeripheral *)peripheral error:(NSError *)error { + std::string uuid = getUuid(peripheral); + [self.peripherals removeObjectForKey:getNSUuid(peripheral)]; + emit.Disconnected(uuid); +} + +- (BOOL)updateRSSI:(NSString*) uuid { + IF(CBPeripheral*, peripheral, [self.peripherals objectForKey:uuid]) { + [peripheral readRSSI]; + return YES; + } + return NO; +} + +- (void)peripheralDidUpdateRSSI:(CBPeripheral *)peripheral error:(NSError *)error { + std::string uuid = getUuid(peripheral); + NSNumber* rssi = peripheral.RSSI; + if(!error && rssi) { + emit.RSSI(uuid, [rssi longValue]); + } +} + +#pragma mark - Services + +-(BOOL) discoverServices:(NSString*) uuid serviceUuids:(NSArray*) services { + IF(CBPeripheral*, peripheral, [self.peripherals objectForKey:uuid]) { + NSMutableArray* servicesUuid = nil; + if(services) { + servicesUuid = [NSMutableArray arrayWithCapacity:[services count]]; + [services enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { + [servicesUuid addObject:[CBUUID UUIDWithString:obj]]; + }]; + } + [peripheral discoverServices:servicesUuid]; + return YES; + } + return NO; +} + +- (void) peripheral:(CBPeripheral *)peripheral didDiscoverServices:(NSError *)error { + std::string uuid = getUuid(peripheral); + std::vector services = getServices(peripheral.services); + emit.ServicesDiscovered(uuid, services); +} + +- (BOOL)discoverIncludedServices:(NSString*) uuid forService:(NSString*) serviceUuid services:(NSArray*) serviceUuids { + IF(CBPeripheral*, peripheral, [self.peripherals objectForKey:uuid]) { + IF(CBService*, service, [self getService:peripheral service:serviceUuid]) { + NSMutableArray* includedServices = nil; + if(serviceUuids) { + includedServices = [NSMutableArray arrayWithCapacity:[serviceUuids count]]; + [serviceUuids enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { + [includedServices addObject:[CBUUID UUIDWithString:obj]]; + }]; + } + [peripheral discoverIncludedServices:includedServices forService:service]; + return YES; + } + } + return NO; +} + +- (void)peripheral:(CBPeripheral *)peripheral didDiscoverIncludedServicesForService:(CBService *)service error:(NSError *)error { + std::string uuid = getUuid(peripheral); + auto serviceUuid = [[service.UUID UUIDString] UTF8String]; + std::vector services = getServices(service.includedServices); + emit.IncludedServicesDiscovered(uuid, serviceUuid, services); +} + +#pragma mark - Characteristics + +- (BOOL)discoverCharacteristics:(NSString*) uuid forService:(NSString*) serviceUuid characteristics:(NSArray*) characteristics { + IF(CBPeripheral *, peripheral, [self.peripherals objectForKey:uuid]) { + IF(CBService*, service, [self getService:peripheral service:serviceUuid]) { + NSMutableArray* characteristicsUuid = nil; + if(characteristics) { + characteristicsUuid = [NSMutableArray arrayWithCapacity:[characteristics count]]; + [characteristics enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { + [characteristicsUuid addObject:[CBUUID UUIDWithString:obj]]; + }]; + } + [peripheral discoverCharacteristics:characteristicsUuid forService:service]; + return YES; + } + } + return NO; +} + +-(void) peripheral:(CBPeripheral *)peripheral didDiscoverCharacteristicsForService:(CBService *)service error:(NSError *)error { + std::string uuid = getUuid(peripheral); + std::string serviceUuid = std::string([service.UUID.UUIDString UTF8String]); + auto characteristics = getCharacteristics(service.characteristics); + emit.CharacteristicsDiscovered(uuid, serviceUuid, characteristics); +} + +- (BOOL)read:(NSString*) uuid service:(NSString*) serviceUuid characteristic:(NSString*) characteristicUuid { + IF(CBPeripheral *, peripheral, [self.peripherals objectForKey:uuid]) { + IF(CBCharacteristic*, characteristic, [self getCharacteristic:peripheral service:serviceUuid characteristic:characteristicUuid]) { + pendingRead = true; + [peripheral readValueForCharacteristic:characteristic]; + return YES; + } + } + return NO; +} + +- (void) peripheral:(CBPeripheral *)peripheral didUpdateValueForCharacteristic:(CBCharacteristic *)characteristic error:(NSError *)error { + std::string uuid = getUuid(peripheral); + std::string serviceUuid = [characteristic.service.UUID.UUIDString UTF8String]; + std::string characteristicUuid = [characteristic.UUID.UUIDString UTF8String]; + const UInt8* bytes = (UInt8 *)[characteristic.value bytes]; + Data data; + data.assign(bytes, bytes+[characteristic.value length]); + bool isNotification = !pendingRead && characteristic.isNotifying; + pendingRead = false; + emit.Read(uuid, serviceUuid, characteristicUuid, data, isNotification); +} + +- (BOOL)write:(NSString*) uuid service:(NSString*) serviceUuid characteristic:(NSString*) characteristicUuid data:(NSData*) data withoutResponse:(BOOL)withoutResponse { + IF(CBPeripheral *, peripheral, [self.peripherals objectForKey:uuid]) { + IF(CBCharacteristic*, characteristic, [self getCharacteristic:peripheral service:serviceUuid characteristic:characteristicUuid]) { + CBCharacteristicWriteType type = withoutResponse ? CBCharacteristicWriteWithoutResponse : CBCharacteristicWriteWithResponse; + [peripheral writeValue:data forCharacteristic:characteristic type:type]; + if (withoutResponse) { + emit.Write([uuid UTF8String], [serviceUuid UTF8String], [characteristicUuid UTF8String]); + } + return YES; + } + } + return NO; +} + +-(void) peripheral:(CBPeripheral *)peripheral didWriteValueForCharacteristic:(CBCharacteristic *)characteristic error:(NSError *)error { + std::string uuid = getUuid(peripheral); + std::string serviceUuid = [characteristic.service.UUID.UUIDString UTF8String]; + std::string characteristicUuid = [characteristic.UUID.UUIDString UTF8String]; + emit.Write(uuid, serviceUuid, characteristicUuid); +} + +- (BOOL)notify:(NSString*) uuid service:(NSString*) serviceUuid characteristic:(NSString*) characteristicUuid on:(BOOL)on { + IF(CBPeripheral *, peripheral, [self.peripherals objectForKey:uuid]) { + IF(CBCharacteristic*, characteristic, [self getCharacteristic:peripheral service:serviceUuid characteristic:characteristicUuid]) { + [peripheral setNotifyValue:on forCharacteristic:characteristic]; + return YES; + } + } + return NO; +} + +- (void)peripheral:(CBPeripheral *)peripheral didUpdateNotificationStateForCharacteristic:(CBCharacteristic *)characteristic error:(NSError *)error { + std::string uuid = getUuid(peripheral); + std::string serviceUuid = [characteristic.service.UUID.UUIDString UTF8String]; + std::string characteristicUuid = [characteristic.UUID.UUIDString UTF8String]; + emit.Notify(uuid, serviceUuid, characteristicUuid, characteristic.isNotifying); +} + +#pragma mark - Descriptors + +- (BOOL)discoverDescriptors:(NSString*) uuid service:(NSString*) serviceUuid characteristic:(NSString*) characteristicUuid { + IF(CBPeripheral *, peripheral, [self.peripherals objectForKey:uuid]) { + IF(CBCharacteristic*, characteristic, [self getCharacteristic:peripheral service:serviceUuid characteristic:characteristicUuid]) { + [peripheral discoverDescriptorsForCharacteristic:characteristic]; + return YES; + } + } + return NO; +} + +- (void)peripheral:(CBPeripheral *)peripheral didDiscoverDescriptorsForCharacteristic:(CBCharacteristic *)characteristic error:(NSError *)error { + std::string uuid = getUuid(peripheral); + std::string serviceUuid = [characteristic.service.UUID.UUIDString UTF8String]; + std::string characteristicUuid = [characteristic.UUID.UUIDString UTF8String]; + std::vector descriptors = getDescriptors(characteristic.descriptors); + emit.DescriptorsDiscovered(uuid, serviceUuid, characteristicUuid, descriptors); +} + +- (BOOL)readValue:(NSString*) uuid service:(NSString*) serviceUuid characteristic:(NSString*) characteristicUuid descriptor:(NSString*) descriptorUuid { + IF(CBPeripheral *, peripheral, [self.peripherals objectForKey:uuid]) { + IF(CBDescriptor*, descriptor, [self getDescriptor:peripheral service:serviceUuid characteristic:characteristicUuid descriptor:descriptorUuid]) { + [peripheral readValueForDescriptor:descriptor]; + return YES; + } + } + return NO; +} + +- (void)peripheral:(CBPeripheral *)peripheral didUpdateValueForDescriptor:(CBDescriptor *)descriptor error:(NSError *)error { + std::string uuid = getUuid(peripheral); + std::string serviceUuid = [descriptor.characteristic.service.UUID.UUIDString UTF8String]; + std::string characteristicUuid = [descriptor.characteristic.UUID.UUIDString UTF8String]; + std::string descriptorUuid = [descriptor.UUID.UUIDString UTF8String]; + const UInt8* bytes = (UInt8 *)[descriptor.value bytes]; + Data data; + data.assign(bytes, bytes+[descriptor.value length]); + IF(NSNumber*, handle, [self getDescriptorHandle:descriptor]) { + emit.ReadHandle(uuid, [handle intValue], data); + } + emit.ReadValue(uuid, serviceUuid, characteristicUuid, descriptorUuid, data); +} + +- (BOOL)writeValue:(NSString*) uuid service:(NSString*) serviceUuid characteristic:(NSString*) characteristicUuid descriptor:(NSString*) descriptorUuid data:(NSData*) data { + IF(CBPeripheral *, peripheral, [self.peripherals objectForKey:uuid]) { + IF(CBDescriptor*, descriptor, [self getDescriptor:peripheral service:serviceUuid characteristic:characteristicUuid descriptor:descriptorUuid]) { + [peripheral writeValue:data forDescriptor:descriptor]; + return YES; + } + } + return NO; +} + +- (void)peripheral:(CBPeripheral *)peripheral didWriteValueForDescriptor:(CBDescriptor *)descriptor error:(NSError *)error { + std::string uuid = getUuid(peripheral); + std::string serviceUuid = [descriptor.characteristic.service.UUID.UUIDString UTF8String]; + std::string characteristicUuid = [descriptor.characteristic.UUID.UUIDString UTF8String]; + std::string descriptorUuid = [descriptor.UUID.UUIDString UTF8String]; + IF(NSNumber*, handle, [self getDescriptorHandle:descriptor]) { + emit.WriteHandle(uuid, [handle intValue]); + } + emit.WriteValue(uuid, serviceUuid, characteristicUuid, descriptorUuid); +} + +- (BOOL)readHandle:(NSString*) uuid handle:(NSNumber*) handle { + IF(CBPeripheral *, peripheral, [self.peripherals objectForKey:uuid]) { + IF(CBDescriptor*, descriptor, [self getDescriptor:peripheral ByHandle:handle]) { + [peripheral readValueForDescriptor:descriptor]; + return YES; + } + } + return NO; +} + +- (BOOL)writeHandle:(NSString*) uuid handle:(NSNumber*) handle data:(NSData*) data { + IF(CBPeripheral *, peripheral, [self.peripherals objectForKey:uuid]) { + IF(CBDescriptor*, descriptor, [self getDescriptor:peripheral ByHandle:handle]) { + [peripheral writeValue:data forDescriptor:descriptor]; + return YES; + } + } + return NO; +} + +#pragma mark - Accessor + +-(CBService*)getService:(CBPeripheral*) peripheral service:(NSString*) serviceUuid { + if(peripheral && peripheral.services) { + for(CBService* service in peripheral.services) { + if([service.UUID isEqualTo:[CBUUID UUIDWithString:serviceUuid]]) { + return service; + } + } + } + return nil; +} + +-(CBCharacteristic*)getCharacteristic:(CBPeripheral*) peripheral service:(NSString*) serviceUuid characteristic:(NSString*) characteristicUuid { + CBService* service = [self getService:peripheral service:serviceUuid]; + if(service && service.characteristics) { + for(CBCharacteristic* characteristic in service.characteristics) { + if([characteristic.UUID isEqualTo:[CBUUID UUIDWithString:characteristicUuid]]) { + return characteristic; + } + } + } + return nil; +} + +-(CBDescriptor*)getDescriptor:(CBPeripheral*) peripheral service:(NSString*) serviceUuid characteristic:(NSString*) characteristicUuid descriptor:(NSString*) descriptorUuid { + CBCharacteristic* characteristic = [self getCharacteristic:peripheral service:serviceUuid characteristic:characteristicUuid]; + if(characteristic && characteristic.descriptors) { + for(CBDescriptor* descriptor in characteristic.descriptors) { + if([descriptor.UUID isEqualTo:[CBUUID UUIDWithString:descriptorUuid]]) { + return descriptor; + } + } + } + return nil; +} + +-(NSNumber*)getDescriptorHandle:(CBDescriptor*) descriptor { + // use KVC to get the private handle property + id handle = [descriptor valueForKey:@"handle"]; + if([handle isKindOfClass:[NSNumber class]]) { + return handle; + } + return nil; +} + +-(CBDescriptor*)getDescriptor:(CBPeripheral*) peripheral ByHandle:(NSNumber*) handle { + if(peripheral && peripheral.services) { + for(CBService* service in peripheral.services) { + if(service.characteristics) { + for(CBCharacteristic* characteristic in service.characteristics) { + if(characteristic.descriptors) { + for(CBDescriptor* descriptor in characteristic.descriptors) { + if([handle isEqualTo:[self getDescriptorHandle:descriptor]]) { + return descriptor; + } + } + } + } + } + } + } + return nil; +} + +@end diff --git a/lib/mac/src/callbacks.cc b/lib/mac/src/callbacks.cc new file mode 100644 index 000000000..b7e4b4731 --- /dev/null +++ b/lib/mac/src/callbacks.cc @@ -0,0 +1,224 @@ +// +// callbacks.cc +// noble-mac-native +// +// Created by Georg Vienna on 30.08.18. +// +#include "callbacks.h" + +#include + +#define _s(val) Napi::String::New(env, val) +#define _b(val) Napi::Boolean::New(env, val) +#define _n(val) Napi::Number::New(env, val) +#define _u(str) toUuid(env, str) + +Napi::String toUuid(Napi::Env& env, const std::string& uuid) { + std::string str(uuid); + str.erase(std::remove(str.begin(), str.end(), '-'), str.end()); + std::transform(str.begin(), str.end(), str.begin(), ::tolower); + return _s(str); +} + +Napi::String toAddressType(Napi::Env& env, const AddressType& type) { + if(type == PUBLIC) { + return _s("public"); + } else if (type == RANDOM) { + return _s("random"); + } + return _s("unknown"); +} + +Napi::Buffer toBuffer(Napi::Env& env, const Data& data) { + if (data.empty()) { + return Napi::Buffer::New(env, 0); + } + return Napi::Buffer::Copy(env, &data[0], data.size()); +} + +Napi::Array toUuidArray(Napi::Env& env, const std::vector& data) { + if (data.empty()) { + return Napi::Array::New(env); + } + auto arr = Napi::Array::New(env, data.size()); + for (size_t i = 0; i < data.size(); i++) { + arr.Set(i, _u(data[i])); + } + return arr; +} + +Napi::Array toArray(Napi::Env& env, const std::vector& data) { + if (data.empty()) { + return Napi::Array::New(env); + } + auto arr = Napi::Array::New(env, data.size()); + for (size_t i = 0; i < data.size(); i++) { + arr.Set(i, _s(data[i])); + } + return arr; +} + +void Emit::Wrap(const Napi::Value& receiver, const Napi::Function& callback) { + mCallback = std::make_shared(receiver, callback); +} + +void Emit::RadioState(const std::string& state) { + mCallback->call([state](Napi::Env env, std::vector& args) { + // emit('stateChange', state); + args = { _s("stateChange"), _s(state) }; + }); +} + +void Emit::ScanState(bool start) { + mCallback->call([start](Napi::Env env, std::vector& args) { + // emit('scanStart') emit('scanStop') + args = { _s(start ? "scanStart" : "scanStop") }; + }); +} + +void Emit::Scan(const std::string& uuid, int rssi, const Peripheral& peripheral) { + auto address = peripheral.address; + auto addressType = peripheral.addressType; + auto connectable = peripheral.connectable; + auto name = peripheral.name; + auto txPowerLevel = peripheral.txPowerLevel; + auto manufacturerData = peripheral.manufacturerData; + auto serviceData = peripheral.serviceData; + auto serviceUuids = peripheral.serviceUuids; + mCallback->call([uuid, rssi, address, addressType, connectable, name, txPowerLevel, manufacturerData, serviceData, serviceUuids](Napi::Env env, std::vector& args) { + Napi::Object advertisment = Napi::Object::New(env); + if (std::get<1>(name)) { + advertisment.Set(_s("localName"), _s(std::get<0>(name))); + } + + if (std::get<1>(txPowerLevel)) { + advertisment.Set(_s("txPowerLevel"), std::get<0>(txPowerLevel)); + } + + if (std::get<1>(manufacturerData)) { + advertisment.Set(_s("manufacturerData"), toBuffer(env, std::get<0>(manufacturerData))); + } + + if (std::get<1>(serviceData)) { + auto array = std::get<0>(serviceData).empty() ? Napi::Array::New(env) : Napi::Array::New(env, std::get<0>(serviceData).size()); + for (size_t i = 0; i < std::get<0>(serviceData).size(); i++) { + Napi::Object data = Napi::Object::New(env); + data.Set(_s("uuid"), _u(std::get<0>(serviceData)[i].first)); + data.Set(_s("data"), toBuffer(env, std::get<0>(serviceData)[i].second)); + array.Set(i, data); + } + advertisment.Set(_s("serviceData"), array); + } + + if (std::get<1>(serviceUuids)) { + advertisment.Set(_s("serviceUuids"), toUuidArray(env, std::get<0>(serviceUuids))); + } + // emit('discover', deviceUuid, address, addressType, connectable, advertisement, rssi); + args = { _s("discover"), _u(uuid), _s(address), toAddressType(env, addressType), _b(connectable), advertisment, _n(rssi) }; + }); +} + +void Emit::Connected(const std::string& uuid, const std::string& error) { + mCallback->call([uuid, error](Napi::Env env, std::vector& args) { + // emit('connect', deviceUuid) error added here + args = { _s("connect"), _u(uuid), error.empty() ? env.Null() : _s(error) }; + }); +} + +void Emit::Disconnected(const std::string& uuid) { + mCallback->call([uuid](Napi::Env env, std::vector& args) { + // emit('disconnect', deviceUuid); + args = { _s("disconnect"), _u(uuid) }; + }); +} + +void Emit::RSSI(const std::string & uuid, int rssi) { + mCallback->call([uuid, rssi](Napi::Env env, std::vector& args) { + // emit('rssiUpdate', deviceUuid, rssi); + args = { _s("rssiUpdate"), _u(uuid), _n(rssi) }; + }); +} + +void Emit::ServicesDiscovered(const std::string & uuid, const std::vector& serviceUuids) { + mCallback->call([uuid, serviceUuids](Napi::Env env, std::vector& args) { + // emit('servicesDiscover', deviceUuid, serviceUuids) + args = { _s("servicesDiscover"), _u(uuid), toUuidArray(env, serviceUuids) }; + }); +} + +void Emit::IncludedServicesDiscovered(const std::string & uuid, const std::string & serviceUuid, const std::vector& serviceUuids) { + mCallback->call([uuid, serviceUuid, serviceUuids](Napi::Env env, std::vector& args) { + // emit('includedServicesDiscover', deviceUuid, serviceUuid, includedServiceUuids) + args = { _s("includedServicesDiscover"), _u(uuid), _u(serviceUuid), toUuidArray(env, serviceUuids) }; + }); +} + +void Emit::CharacteristicsDiscovered(const std::string & uuid, const std::string & serviceUuid, const std::vector>>& characteristics) { + mCallback->call([uuid, serviceUuid, characteristics](Napi::Env env, std::vector& args) { + auto arr = characteristics.empty() ? Napi::Array::New(env) : Napi::Array::New(env, characteristics.size()); + for (size_t i = 0; i < characteristics.size(); i++) { + Napi::Object characteristic = Napi::Object::New(env); + characteristic.Set(_s("uuid"), _u(characteristics[i].first)); + characteristic.Set(_s("properties"), toArray(env, characteristics[i].second)); + arr.Set(i, characteristic); + } + // emit('characteristicsDiscover', deviceUuid, serviceUuid, { uuid, properties: ['broadcast', 'read', ...]}) + args = { _s("characteristicsDiscover"), _u(uuid), _u(serviceUuid), arr }; + }); +} + +void Emit::Read(const std::string & uuid, const std::string & serviceUuid, const std::string & characteristicUuid, const Data& data, bool isNotification) { + mCallback->call([uuid, serviceUuid, characteristicUuid, data, isNotification](Napi::Env env, std::vector& args) { + // emit('read', deviceUuid, serviceUuid, characteristicsUuid, data, isNotification); + args = { _s("read"), _u(uuid), _u(serviceUuid), _u(characteristicUuid), toBuffer(env, data), _b(isNotification) }; + }); +} + +void Emit::Write(const std::string & uuid, const std::string & serviceUuid, const std::string & characteristicUuid) { + mCallback->call([uuid, serviceUuid, characteristicUuid](Napi::Env env, std::vector& args) { + // emit('write', deviceUuid, servicesUuid, characteristicsUuid) + args = { _s("write"), _u(uuid), _u(serviceUuid), _u(characteristicUuid) }; + }); +} + +void Emit::Notify(const std::string & uuid, const std::string & serviceUuid, const std::string & characteristicUuid, bool state) { + mCallback->call([uuid, serviceUuid, characteristicUuid, state](Napi::Env env, std::vector& args) { + // emit('notify', deviceUuid, servicesUuid, characteristicsUuid, state) + args = { _s("notify"), _u(uuid), _u(serviceUuid), _u(characteristicUuid), _b(state) }; + }); +} + +void Emit::DescriptorsDiscovered(const std::string & uuid, const std::string & serviceUuid, const std::string & characteristicUuid, const std::vector& descriptorUuids) { + mCallback->call([uuid, serviceUuid, characteristicUuid, descriptorUuids](Napi::Env env, std::vector& args) { + // emit('descriptorsDiscover', deviceUuid, servicesUuid, characteristicsUuid, descriptors: [uuids]) + args = { _s("descriptorsDiscover"), _u(uuid), _u(serviceUuid), _u(characteristicUuid), toUuidArray(env, descriptorUuids) }; + }); +} + +void Emit::ReadValue(const std::string & uuid, const std::string & serviceUuid, const std::string & characteristicUuid, const std::string& descriptorUuid, const Data& data) { + mCallback->call([uuid, serviceUuid, characteristicUuid, descriptorUuid, data](Napi::Env env, std::vector& args) { + // emit('valueRead', deviceUuid, serviceUuid, characteristicUuid, descriptorUuid, data) + args = { _s("valueRead"), _u(uuid), _u(serviceUuid), _u(characteristicUuid), _u(descriptorUuid), toBuffer(env, data) }; + }); +} + +void Emit::WriteValue(const std::string & uuid, const std::string & serviceUuid, const std::string & characteristicUuid, const std::string& descriptorUuid) { + mCallback->call([uuid, serviceUuid, characteristicUuid, descriptorUuid](Napi::Env env, std::vector& args) { + // emit('valueWrite', deviceUuid, serviceUuid, characteristicUuid, descriptorUuid); + args = { _s("valueWrite"), _u(uuid), _u(serviceUuid), _u(characteristicUuid), _u(descriptorUuid) }; + }); +} + +void Emit::ReadHandle(const std::string & uuid, int descriptorHandle, const Data& data) { + mCallback->call([uuid, descriptorHandle, data](Napi::Env env, std::vector& args) { + // emit('handleRead', deviceUuid, descriptorHandle, data); + args = { _s("handleRead"), _u(uuid), _n(descriptorHandle), toBuffer(env, data) }; + }); +} + +void Emit::WriteHandle(const std::string & uuid, int descriptorHandle) { + mCallback->call([uuid, descriptorHandle](Napi::Env env, std::vector& args) { + // emit('handleWrite', deviceUuid, descriptorHandle); + args = { _s("handleWrite"), _u(uuid), _n(descriptorHandle) }; + }); +} diff --git a/lib/mac/src/callbacks.h b/lib/mac/src/callbacks.h new file mode 100644 index 000000000..ccf270ab9 --- /dev/null +++ b/lib/mac/src/callbacks.h @@ -0,0 +1,30 @@ +#pragma once + +#include +#include "peripheral.h" + +class ThreadSafeCallback; + +class Emit { +public: + void Wrap(const Napi::Value& receiver, const Napi::Function& callback); + void RadioState(const std::string& status); + void ScanState(bool start); + void Scan(const std::string& uuid, int rssi, const Peripheral& peripheral); + void Connected(const std::string& uuid, const std::string& error = ""); + void Disconnected(const std::string& uuid); + void RSSI(const std::string& uuid, int rssi); + void ServicesDiscovered(const std::string& uuid, const std::vector& serviceUuids); + void IncludedServicesDiscovered(const std::string& uuid, const std::string& serviceUuid, const std::vector& serviceUuids); + void CharacteristicsDiscovered(const std::string& uuid, const std::string& serviceUuid, const std::vector>>& characteristics); + void Read(const std::string& uuid, const std::string& serviceUuid, const std::string& characteristicUuid, const Data& data, bool isNotification); + void Write(const std::string& uuid, const std::string& serviceUuid, const std::string& characteristicUuid); + void Notify(const std::string& uuid, const std::string& serviceUuid, const std::string& characteristicUuid, bool state); + void DescriptorsDiscovered(const std::string& uuid, const std::string& serviceUuid, const std::string& characteristicUuid, const std::vector& descriptorUuids); + void ReadValue(const std::string& uuid, const std::string& serviceUuid, const std::string& characteristicUuid, const std::string& descriptorUuid, const Data& data); + void WriteValue(const std::string& uuid, const std::string& serviceUuid, const std::string& characteristicUuid, const std::string& descriptorUuid); + void ReadHandle(const std::string& uuid, int descriptorHandle, const std::vector& data); + void WriteHandle(const std::string& uuid, int descriptorHandle); +protected: + std::shared_ptr mCallback; +}; diff --git a/lib/mac/src/napi_objc.h b/lib/mac/src/napi_objc.h new file mode 100644 index 000000000..62fcb5e86 --- /dev/null +++ b/lib/mac/src/napi_objc.h @@ -0,0 +1,12 @@ +#pragma once + +#include +#import + +NSArray* getUuidArray(const Napi::Value& value); +BOOL getBool(const Napi::Value& value, BOOL def); + +NSString* napiToUuidString(Napi::String string); +NSArray* napiToUuidArray(Napi::Array array); +NSData* napiToData(Napi::Buffer buffer); +NSNumber* napiToNumber(Napi::Number number); diff --git a/lib/mac/src/napi_objc.mm b/lib/mac/src/napi_objc.mm new file mode 100644 index 000000000..cf1ee3695 --- /dev/null +++ b/lib/mac/src/napi_objc.mm @@ -0,0 +1,50 @@ +// +// napi_objc.mm +// noble-mac-native +// +// Created by Georg Vienna on 30.08.18. +// +#include "napi_objc.h" + +NSString* napiToUuidString(Napi::String string) { + std::string str = string.Utf8Value(); + NSMutableString * uuid = [[NSMutableString alloc] initWithCString:str.c_str() encoding:NSASCIIStringEncoding]; + if([uuid length] == 32) { + [uuid insertString: @"-" atIndex: 8]; + [uuid insertString: @"-" atIndex: 13]; + [uuid insertString: @"-" atIndex: 18]; + [uuid insertString: @"-" atIndex: 23]; + } + return [uuid uppercaseString]; +} + +NSArray* napiToUuidArray(Napi::Array array) { + NSMutableArray* serviceUuids = [NSMutableArray arrayWithCapacity:array.Length()]; + for(size_t i = 0; i < array.Length(); i++) { + Napi::Value val = array[i]; + [serviceUuids addObject:napiToUuidString(val.As())]; + } + return serviceUuids; +} + +NSData* napiToData(Napi::Buffer buffer) { + return [NSData dataWithBytes:buffer.Data() length:buffer.Length()]; +} + +NSNumber* napiToNumber(Napi::Number number) { + return [NSNumber numberWithInt:number.Int64Value()]; +} + +NSArray* getUuidArray(const Napi::Value& value) { + if (value.IsArray()) { + return napiToUuidArray(value.As()); + } + return nil; +} + +BOOL getBool(const Napi::Value& value, BOOL def) { + if (value.IsBoolean()) { + return value.As().Value(); + } + return def; +} diff --git a/lib/mac/src/noble_mac.h b/lib/mac/src/noble_mac.h new file mode 100644 index 000000000..8ec1076a8 --- /dev/null +++ b/lib/mac/src/noble_mac.h @@ -0,0 +1,34 @@ +#pragma once + +#include + +#include "ble_manager.h" + +class NobleMac : public Napi::ObjectWrap +{ +public: + NobleMac(const Napi::CallbackInfo&); + Napi::Value Init(const Napi::CallbackInfo&); + Napi::Value Scan(const Napi::CallbackInfo&); + Napi::Value StopScan(const Napi::CallbackInfo&); + Napi::Value Connect(const Napi::CallbackInfo&); + Napi::Value Disconnect(const Napi::CallbackInfo&); + Napi::Value UpdateRSSI(const Napi::CallbackInfo&); + Napi::Value DiscoverServices(const Napi::CallbackInfo&); + Napi::Value DiscoverIncludedServices(const Napi::CallbackInfo& info); + Napi::Value DiscoverCharacteristics(const Napi::CallbackInfo& info); + Napi::Value Read(const Napi::CallbackInfo& info); + Napi::Value Write(const Napi::CallbackInfo& info); + Napi::Value Notify(const Napi::CallbackInfo& info); + Napi::Value DiscoverDescriptors(const Napi::CallbackInfo& info); + Napi::Value ReadValue(const Napi::CallbackInfo& info); + Napi::Value WriteValue(const Napi::CallbackInfo& info); + Napi::Value ReadHandle(const Napi::CallbackInfo& info); + Napi::Value WriteHandle(const Napi::CallbackInfo& info); + Napi::Value Stop(const Napi::CallbackInfo&); + + static Napi::Function GetClass(Napi::Env); + +private: + BLEManager* manager; +}; diff --git a/lib/mac/src/noble_mac.mm b/lib/mac/src/noble_mac.mm new file mode 100644 index 000000000..52025759a --- /dev/null +++ b/lib/mac/src/noble_mac.mm @@ -0,0 +1,259 @@ +// +// noble_mac.mm +// noble-mac-native +// +// Created by Georg Vienna on 28.08.18. +// +#include "noble_mac.h" + +#include "napi_objc.h" + +#define THROW(msg) \ +Napi::TypeError::New(info.Env(), msg).ThrowAsJavaScriptException(); \ +return Napi::Value(); + +#define ARG1(type1) \ +if (!info[0].Is##type1()) { \ + THROW("There should be one argument: (" #type1 ")") \ +} + +#define ARG2(type1, type2) \ +if (!info[0].Is##type1() || !info[1].Is##type2()) { \ + THROW("There should be 2 arguments: (" #type1 ", " #type2 ")"); \ +} + +#define ARG3(type1, type2, type3) \ +if (!info[0].Is##type1() || !info[1].Is##type2() || !info[2].Is##type3()) { \ + THROW("There should be 3 arguments: (" #type1 ", " #type2 ", " #type3 ")"); \ +} + +#define ARG4(type1, type2, type3, type4) \ +if (!info[0].Is##type1() || !info[1].Is##type2() || !info[2].Is##type3() || !info[3].Is##type4()) { \ + THROW("There should be 4 arguments: (" #type1 ", " #type2 ", " #type3 ", " #type4 ")"); \ +} + +#define ARG5(type1, type2, type3, type4, type5) \ +if (!info[0].Is##type1() || !info[1].Is##type2() || !info[2].Is##type3() || !info[3].Is##type4() || !info[4].Is##type5()) { \ + THROW("There should be 5 arguments: (" #type1 ", " #type2 ", " #type3 ", " #type4 ", " #type5 ")"); \ +} + +#define CHECK_MANAGER() \ +if(!manager) { \ + THROW("BLEManager has already been cleaned up"); \ +} + +NobleMac::NobleMac(const Napi::CallbackInfo& info) : ObjectWrap(info) { +} + +Napi::Value NobleMac::Init(const Napi::CallbackInfo& info) { + Napi::Function emit = info.This().As().Get("emit").As(); + manager = [[BLEManager alloc] init:info.This() with:emit]; + return Napi::Value(); +} + +// startScanning(serviceUuids, allowDuplicates) +Napi::Value NobleMac::Scan(const Napi::CallbackInfo& info) { + CHECK_MANAGER() + NSArray* array = getUuidArray(info[0]); + // default value NO + auto duplicates = getBool(info[1], NO); + [manager scan:array allowDuplicates:duplicates]; + return Napi::Value(); +} + +// stopScanning() +Napi::Value NobleMac::StopScan(const Napi::CallbackInfo& info) { + CHECK_MANAGER() + [manager stopScan]; + return Napi::Value(); +} + +// connect(deviceUuid) +Napi::Value NobleMac::Connect(const Napi::CallbackInfo& info) { + CHECK_MANAGER() + ARG1(String) + auto uuid = napiToUuidString(info[0].As()); + [manager connect:uuid]; + return Napi::Value(); +} + +// disconnect(deviceUuid) +Napi::Value NobleMac::Disconnect(const Napi::CallbackInfo& info) { + CHECK_MANAGER() + ARG1(String) + auto uuid = napiToUuidString(info[0].As()); + [manager disconnect:uuid]; + return Napi::Value(); +} + +// updateRssi(deviceUuid) +Napi::Value NobleMac::UpdateRSSI(const Napi::CallbackInfo& info) { + CHECK_MANAGER() + ARG1(String) + auto uuid = napiToUuidString(info[0].As()); + [manager updateRSSI:uuid]; + return Napi::Value(); +} + +// discoverServices(deviceUuid, uuids) +Napi::Value NobleMac::DiscoverServices(const Napi::CallbackInfo& info) { + CHECK_MANAGER() + ARG1(String) + auto uuid = napiToUuidString(info[0].As()); + NSArray* array = getUuidArray(info[1]); + [manager discoverServices:uuid serviceUuids:array]; + return Napi::Value(); +} + +// discoverIncludedServices(deviceUuid, serviceUuid, serviceUuids) +Napi::Value NobleMac::DiscoverIncludedServices(const Napi::CallbackInfo& info) { + CHECK_MANAGER() + ARG2(String, String) + auto uuid = napiToUuidString(info[0].As()); + auto service = napiToUuidString(info[1].As()); + NSArray* serviceUuids = getUuidArray(info[2]); + [manager discoverIncludedServices:uuid forService:service services:serviceUuids]; + return Napi::Value(); +} + +// discoverCharacteristics(deviceUuid, serviceUuid, characteristicUuids) +Napi::Value NobleMac::DiscoverCharacteristics(const Napi::CallbackInfo& info) { + CHECK_MANAGER() + ARG2(String, String) + auto uuid = napiToUuidString(info[0].As()); + auto service = napiToUuidString(info[1].As()); + NSArray* characteristics = getUuidArray(info[2]); + [manager discoverCharacteristics:uuid forService:service characteristics:characteristics]; + return Napi::Value(); +} + +// read(deviceUuid, serviceUuid, characteristicUuid) +Napi::Value NobleMac::Read(const Napi::CallbackInfo& info) { + CHECK_MANAGER() + ARG3(String, String, String) + auto uuid = napiToUuidString(info[0].As()); + auto service = napiToUuidString(info[1].As()); + auto characteristic = napiToUuidString(info[2].As()); + [manager read:uuid service:service characteristic:characteristic]; + return Napi::Value(); +} + +// write(deviceUuid, serviceUuid, characteristicUuid, data, withoutResponse) +Napi::Value NobleMac::Write(const Napi::CallbackInfo& info) { + CHECK_MANAGER() + ARG5(String, String, String, Buffer, Boolean) + auto uuid = napiToUuidString(info[0].As()); + auto service = napiToUuidString(info[1].As()); + auto characteristic = napiToUuidString(info[2].As()); + auto data = napiToData(info[3].As>()); + auto withoutResponse = info[4].As().Value(); + [manager write:uuid service:service characteristic:characteristic data:data withoutResponse:withoutResponse]; + return Napi::Value(); +} + +// notify(deviceUuid, serviceUuid, characteristicUuid, notify) +Napi::Value NobleMac::Notify(const Napi::CallbackInfo& info) { + CHECK_MANAGER() + ARG4(String, String, String, Boolean) + auto uuid = napiToUuidString(info[0].As()); + auto service = napiToUuidString(info[1].As()); + auto characteristic = napiToUuidString(info[2].As()); + auto on = info[3].As().Value(); + [manager notify:uuid service:service characteristic:characteristic on:on]; + return Napi::Value(); +} + +// discoverDescriptors(deviceUuid, serviceUuid, characteristicUuid) +Napi::Value NobleMac::DiscoverDescriptors(const Napi::CallbackInfo& info) { + CHECK_MANAGER() + ARG3(String, String, String) + auto uuid = napiToUuidString(info[0].As()); + auto service = napiToUuidString(info[1].As()); + auto characteristic = napiToUuidString(info[2].As()); + [manager discoverDescriptors:uuid service:service characteristic:characteristic]; + return Napi::Value(); +} + +// readValue(deviceUuid, serviceUuid, characteristicUuid, descriptorUuid) +Napi::Value NobleMac::ReadValue(const Napi::CallbackInfo& info) { + CHECK_MANAGER() + ARG4(String, String, String, String) + auto uuid = napiToUuidString(info[0].As()); + auto service = napiToUuidString(info[1].As()); + auto characteristic = napiToUuidString(info[2].As()); + auto descriptor = napiToUuidString(info[3].As()); + [manager readValue:uuid service:service characteristic:characteristic descriptor:descriptor]; + return Napi::Value(); +} + +// writeValue(deviceUuid, serviceUuid, characteristicUuid, descriptorUuid, data) +Napi::Value NobleMac::WriteValue(const Napi::CallbackInfo& info) { + CHECK_MANAGER() + ARG5(String, String, String, String, Buffer) + auto uuid = napiToUuidString(info[0].As()); + auto service = napiToUuidString(info[1].As()); + auto characteristic = napiToUuidString(info[2].As()); + auto descriptor = napiToUuidString(info[3].As()); + auto data = napiToData(info[4].As>()); + [manager writeValue:uuid service:service characteristic:characteristic descriptor:descriptor data: data]; + return Napi::Value(); +} + +// readHandle(deviceUuid, handle) +Napi::Value NobleMac::ReadHandle(const Napi::CallbackInfo& info) { + CHECK_MANAGER() + ARG2(String, Number) + auto uuid = napiToUuidString(info[0].As()); + auto handle = napiToNumber(info[1].As()); + [manager readHandle:uuid handle:handle]; + return Napi::Value(); +} + +// writeHandle(deviceUuid, handle, data, (unused)withoutResponse) +Napi::Value NobleMac::WriteHandle(const Napi::CallbackInfo& info) { + CHECK_MANAGER() + ARG3(String, Number, Buffer) + auto uuid = napiToUuidString(info[0].As()); + auto handle = napiToNumber(info[1].As()); + auto data = napiToData(info[2].As>()); + [manager writeHandle:uuid handle:handle data: data]; + return Napi::Value(); +} + +Napi::Value NobleMac::Stop(const Napi::CallbackInfo& info) { + CHECK_MANAGER() + CFRelease((__bridge CFTypeRef)manager); + manager = nil; + return Napi::Value(); +} + +Napi::Function NobleMac::GetClass(Napi::Env env) { + return DefineClass(env, "NobleMac", { + NobleMac::InstanceMethod("init", &NobleMac::Init), + NobleMac::InstanceMethod("startScanning", &NobleMac::Scan), + NobleMac::InstanceMethod("stopScanning", &NobleMac::StopScan), + NobleMac::InstanceMethod("connect", &NobleMac::Connect), + NobleMac::InstanceMethod("disconnect", &NobleMac::Disconnect), + NobleMac::InstanceMethod("updateRssi", &NobleMac::UpdateRSSI), + NobleMac::InstanceMethod("discoverServices", &NobleMac::DiscoverServices), + NobleMac::InstanceMethod("discoverIncludedServices", &NobleMac::DiscoverIncludedServices), + NobleMac::InstanceMethod("discoverCharacteristics", &NobleMac::DiscoverCharacteristics), + NobleMac::InstanceMethod("read", &NobleMac::Read), + NobleMac::InstanceMethod("write", &NobleMac::Write), + NobleMac::InstanceMethod("notify", &NobleMac::Notify), + NobleMac::InstanceMethod("discoverDescriptors", &NobleMac::DiscoverDescriptors), + NobleMac::InstanceMethod("readValue", &NobleMac::ReadValue), + NobleMac::InstanceMethod("writeValue", &NobleMac::WriteValue), + NobleMac::InstanceMethod("readHandle", &NobleMac::ReadHandle), + NobleMac::InstanceMethod("writeHandle", &NobleMac::WriteHandle), + NobleMac::InstanceMethod("stop", &NobleMac::Stop), + }); +} + +Napi::Object Init(Napi::Env env, Napi::Object exports) { + Napi::String name = Napi::String::New(env, "NobleMac"); + exports.Set(name, NobleMac::GetClass(env)); + return exports; +} + +NODE_API_MODULE(addon, Init) diff --git a/lib/mac/src/objc_cpp.h b/lib/mac/src/objc_cpp.h new file mode 100644 index 000000000..e837660b2 --- /dev/null +++ b/lib/mac/src/objc_cpp.h @@ -0,0 +1,26 @@ +#pragma once + +#include +#include +#import +#import +#include "peripheral.h" + +#define IF(type, var, code) type var = code; if(var) + +#if defined(MAC_OS_X_VERSION_10_13) +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunguarded-availability" + std::string stateToString(CBManagerState state); +#pragma clang diagnostic pop +#else + std::string stateToString(CBCentralManagerState state); +#endif + + +NSString* getNSUuid(CBPeripheral* peripheral); +std::string getUuid(CBPeripheral* peripheral); +std::string getAddress(std::string uuid, AddressType* addressType); +std::vector getServices(NSArray* services); +std::vector>> getCharacteristics(NSArray* characteristics); +std::vector getDescriptors(NSArray* descriptors); diff --git a/lib/mac/src/objc_cpp.mm b/lib/mac/src/objc_cpp.mm new file mode 100644 index 000000000..17d6f9c8d --- /dev/null +++ b/lib/mac/src/objc_cpp.mm @@ -0,0 +1,126 @@ +// +// objc_cpp.mm +// noble-mac-native +// +// Created by Georg Vienna on 30.08.18. +// +#include "objc_cpp.h" + +#if defined(MAC_OS_X_VERSION_10_13) +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunguarded-availability" +std::string stateToString(CBManagerState state) +{ + switch(state) { + case CBManagerStatePoweredOff: + return "poweredOff"; + case CBManagerStatePoweredOn: + return "poweredOn"; + case CBManagerStateResetting: + return "resetting"; + case CBManagerStateUnauthorized: + return "unauthorized"; + case CBManagerStateUnknown: + return "unknown"; + case CBManagerStateUnsupported: + return "unsupported"; + } + return "unknown"; +} +#pragma clang diagnostic pop + +// In the 10.13 SDK, CBPeripheral became a subclass of CBPeer, which defines +// -[CBPeer identifier] as partially available. Pretend it still exists on +// CBPeripheral. At runtime the implementation on CBPeer will be invoked. +@interface CBPeripheral (HighSierraSDK) +@property(readonly, nonatomic) NSUUID* identifier; +@end +#else +std::string stateToString(CBCentralManagerState state) +{ + switch(state) { + case CBCentralManagerStatePoweredOff: + return "poweredOff"; + case CBCentralManagerStatePoweredOn: + return "poweredOn"; + case CBCentralManagerStateResetting: + return "resetting"; + case CBCentralManagerStateUnauthorized: + return "unauthorized"; + case CBCentralManagerStateUnknown: + return "unknown"; + case CBCentralManagerStateUnsupported: + return "unsupported"; + } + return "unknown"; +} +#endif + +NSString* getNSUuid(CBPeripheral* peripheral) { + return peripheral.identifier.UUIDString; +} + +std::string getUuid(CBPeripheral* peripheral) { + return std::string([peripheral.identifier.UUIDString UTF8String]); +} + +std::string getAddress(std::string uuid, AddressType* addressType) { + NSString* deviceUuid = [[NSString alloc] initWithCString:uuid.c_str() encoding:NSASCIIStringEncoding]; + IF(NSDictionary*, plist, [NSDictionary dictionaryWithContentsOfFile:@"/Library/Preferences/com.apple.Bluetooth.plist"]) { + IF(NSDictionary*, cache, [plist objectForKey:@"CoreBluetoothCache"]) { + IF(NSDictionary*, entry, [cache objectForKey:deviceUuid]) { + IF(NSNumber*, type, [entry objectForKey:@"DeviceAddressType"]) { + *addressType = [type boolValue] ? RANDOM : PUBLIC; + } + IF(NSString*, address, [entry objectForKey:@"DeviceAddress"]) { + return [address UTF8String]; + } + } + } + } + return ""; +} + +std::vector getServices(NSArray* services) { + std::vector result; + if(services) { + for (CBService* service in services) { + result.push_back([[service.UUID UUIDString] UTF8String]); + } + } + return result; +} + +#define TEST_PROP(type, str) if((characteristic.properties & type) == type) { properties.push_back(str); } + +std::vector>> getCharacteristics(NSArray* characteristics) { + std::vector>> result; + if(characteristics) { + for (CBCharacteristic* characteristic in characteristics) { + auto uuid = [[characteristic.UUID UUIDString] UTF8String]; + auto properties = std::vector(); + TEST_PROP(CBCharacteristicPropertyBroadcast, "broadcast"); + TEST_PROP(CBCharacteristicPropertyRead, "read"); + TEST_PROP(CBCharacteristicPropertyWriteWithoutResponse, "writeWithoutResponse"); + TEST_PROP(CBCharacteristicPropertyWrite, "write"); + TEST_PROP(CBCharacteristicPropertyNotify, "notify"); + TEST_PROP(CBCharacteristicPropertyIndicate, "indicate"); + TEST_PROP(CBCharacteristicPropertyAuthenticatedSignedWrites, "authenticatedSignedWrites"); + TEST_PROP(CBCharacteristicPropertyExtendedProperties, "extendedProperties"); + TEST_PROP(CBCharacteristicPropertyNotifyEncryptionRequired, "notifyEncryptionRequired"); + TEST_PROP(CBCharacteristicPropertyIndicateEncryptionRequired, "indicateEncryptionRequired"); + result.push_back(std::make_pair(uuid, properties)); + } + } + return result; +} + +std::vector getDescriptors(NSArray* descriptors) { + std::vector result; + if(descriptors) { + for (CBDescriptor* descriptor in descriptors) { + result.push_back([[descriptor.UUID UUIDString] UTF8String]); + } + } + return result; +} diff --git a/lib/mac/src/peripheral.h b/lib/mac/src/peripheral.h new file mode 100644 index 000000000..1b0dd069c --- /dev/null +++ b/lib/mac/src/peripheral.h @@ -0,0 +1,23 @@ +#pragma once + +using Data = std::vector; + +enum AddressType { + PUBLIC, + RANDOM, + UNKNOWN, +}; + +class Peripheral { +public: + Peripheral() : address("unknown"), addressType(UNKNOWN), connectable(false) { + } + std::string address; + AddressType addressType; + bool connectable; + std::pair name; + std::pair txPowerLevel; + std::pair manufacturerData; + std::pair>, bool> serviceData; + std::pair, bool> serviceUuids; +}; diff --git a/package-lock.json b/package-lock.json index 2b62e98df..dbf046f40 100644 --- a/package-lock.json +++ b/package-lock.json @@ -25,7 +25,8 @@ "ansi-regex": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", - "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=" + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", + "optional": true }, "aproba": { "version": "1.2.0", @@ -46,12 +47,14 @@ "balanced-match": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", - "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", + "optional": true }, "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -66,17 +69,20 @@ "code-point-at": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", - "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=" + "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", + "optional": true }, "concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", + "optional": true }, "console-control-strings": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", - "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=" + "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=", + "optional": true }, "core-util-is": { "version": "1.0.2", @@ -184,7 +190,8 @@ "inherits": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", + "optional": true }, "ini": { "version": "1.3.5", @@ -196,6 +203,7 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -210,6 +218,7 @@ "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -217,12 +226,14 @@ "minimist": { "version": "0.0.8", "resolved": "http://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", - "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", + "optional": true }, "minipass": { "version": "2.3.5", "resolved": "https://registry.npmjs.org/minipass/-/minipass-2.3.5.tgz", "integrity": "sha512-Gi1W4k059gyRbyVUZQ4mEqLm0YIUiGYfvxhF6SIlk3ui1WVxMTGfGdQ2SInh3PDrRTVvPKgULkpJtT4RH10+VA==", + "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -241,6 +252,7 @@ "version": "0.5.1", "resolved": "http://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "optional": true, "requires": { "minimist": "0.0.8" } @@ -332,7 +344,8 @@ "number-is-nan": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", - "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=" + "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", + "optional": true }, "object-assign": { "version": "4.1.1", @@ -344,6 +357,7 @@ "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "optional": true, "requires": { "wrappy": "1" } @@ -429,7 +443,8 @@ "safe-buffer": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "optional": true }, "safer-buffer": { "version": "2.1.2", @@ -465,6 +480,7 @@ "version": "1.0.2", "resolved": "http://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -484,6 +500,7 @@ "version": "3.0.1", "resolved": "http://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -527,12 +544,14 @@ "wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", + "optional": true }, "yallist": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.3.tgz", - "integrity": "sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A==" + "integrity": "sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A==", + "optional": true } } }, @@ -574,7 +593,8 @@ "ansi-regex": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", - "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=" + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", + "optional": true }, "aproba": { "version": "1.2.0", @@ -618,21 +638,6 @@ "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" }, - "big-integer": { - "version": "1.6.40", - "resolved": "https://registry.npmjs.org/big-integer/-/big-integer-1.6.40.tgz", - "integrity": "sha512-CjhtJp0BViLzP1ZkEnoywjgtFQXS2pomKjAJtIISTCnuHILkLcAXLdFLG/nxsHc4s9kJfc+82Xpg8WNyhfACzQ==", - "optional": true - }, - "bplist-parser": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/bplist-parser/-/bplist-parser-0.1.1.tgz", - "integrity": "sha1-1g1dzCDLptx+HymbNdPh+V2vuuY=", - "optional": true, - "requires": { - "big-integer": "^1.6.7" - } - }, "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", @@ -667,7 +672,8 @@ "code-point-at": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", - "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=" + "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", + "optional": true }, "commander": { "version": "2.15.1", @@ -692,7 +698,8 @@ "console-control-strings": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", - "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=" + "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=", + "optional": true }, "core-util-is": { "version": "1.0.2", @@ -738,21 +745,15 @@ "dev": true }, "dom-serializer": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-0.1.0.tgz", - "integrity": "sha1-BzxpdUbOB4DOI75KKOKT5AvDDII=", + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-0.1.1.tgz", + "integrity": "sha512-l0IU0pPzLWSHBcieZbpOKgkIn3ts3vAh7ZuFyXNwJxJXk/c4Gwj9xaTJwIDVQCXawWD0qb3IzMGH5rglQaO0XA==", "dev": true, "requires": { - "domelementtype": "~1.1.1", - "entities": "~1.1.1" + "domelementtype": "^1.3.0", + "entities": "^1.1.1" }, "dependencies": { - "domelementtype": { - "version": "1.1.3", - "resolved": "http://registry.npmjs.org/domelementtype/-/domelementtype-1.1.3.tgz", - "integrity": "sha1-vSh3PiZCiBrsUVRJJCmcXNgiGFs=", - "dev": true - }, "entities": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/entities/-/entities-1.1.2.tgz", @@ -788,7 +789,7 @@ }, "entities": { "version": "1.0.0", - "resolved": "http://registry.npmjs.org/entities/-/entities-1.0.0.tgz", + "resolved": "https://registry.npmjs.org/entities/-/entities-1.0.0.tgz", "integrity": "sha1-sph6o4ITR/zeZCsk/fyeT7cSvyY=", "dev": true }, @@ -873,7 +874,7 @@ }, "htmlparser2": { "version": "3.8.3", - "resolved": "http://registry.npmjs.org/htmlparser2/-/htmlparser2-3.8.3.tgz", + "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-3.8.3.tgz", "integrity": "sha1-mWwosZFRaovoZQGn15dX5ccMEGg=", "dev": true, "requires": { @@ -892,7 +893,7 @@ }, "readable-stream": { "version": "1.1.14", - "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", "dev": true, "requires": { @@ -904,7 +905,7 @@ }, "string_decoder": { "version": "0.10.31", - "resolved": "http://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", "dev": true } @@ -952,6 +953,7 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -963,9 +965,9 @@ "optional": true }, "jshint": { - "version": "2.9.7", - "resolved": "https://registry.npmjs.org/jshint/-/jshint-2.9.7.tgz", - "integrity": "sha512-Q8XN38hGsVQhdlM+4gd1Xl7OB1VieSuCJf+fEJjpo59JH99bVJhXRXAh26qQ15wfdd1VPMuDWNeSWoNl53T4YA==", + "version": "2.10.1", + "resolved": "https://registry.npmjs.org/jshint/-/jshint-2.10.1.tgz", + "integrity": "sha512-9GpPfKeffYBl7oBDX2lHPG16j0AM7D2bn3aLy9DaWTr6CWa0i/7UGhX8WLZ7V14QQnnr4hXbjauTLYg06F+HYw==", "dev": true, "requires": { "cli": "~1.0.0", @@ -1027,6 +1029,7 @@ "version": "2.3.5", "resolved": "https://registry.npmjs.org/minipass/-/minipass-2.3.5.tgz", "integrity": "sha512-Gi1W4k059gyRbyVUZQ4mEqLm0YIUiGYfvxhF6SIlk3ui1WVxMTGfGdQ2SInh3PDrRTVvPKgULkpJtT4RH10+VA==", + "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -1110,6 +1113,11 @@ "integrity": "sha512-JY7V6lRkStKcKTvHO5NVSQRv+RV+FIL5pvDoLiAtSL9pKlC5x9PKQcZDsq7m4FO4d57mkhC6Z+QhAh3Jdk5JFw==", "optional": true }, + "napi-thread-safe-callback": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/napi-thread-safe-callback/-/napi-thread-safe-callback-0.0.6.tgz", + "integrity": "sha512-X7uHCOCdY4u0yamDxDrv3jF2NtYc8A1nvPzBQgvpoSX+WB3jAe2cVNsY448V1ucq7Whf9Wdy02HEUoLW5rJKWg==" + }, "needle": { "version": "2.2.4", "resolved": "https://registry.npmjs.org/needle/-/needle-2.2.4.tgz", @@ -1159,6 +1167,11 @@ } } }, + "node-addon-api": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-1.6.2.tgz", + "integrity": "sha512-479Bjw9nTE5DdBSZZWprFryHGjUaQC31y1wHo19We/k0BZlrmhqQitWoUL0cD8+scljCbIUL+E58oRDEakdGGA==" + }, "nopt": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/nopt/-/nopt-4.0.1.tgz", @@ -1200,7 +1213,8 @@ "number-is-nan": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", - "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=" + "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", + "optional": true }, "object-assign": { "version": "4.1.1", @@ -1313,7 +1327,8 @@ "safe-buffer": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "optional": true }, "safer-buffer": { "version": "2.1.2", @@ -1341,7 +1356,7 @@ }, "shelljs": { "version": "0.3.0", - "resolved": "http://registry.npmjs.org/shelljs/-/shelljs-0.3.0.tgz", + "resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.3.0.tgz", "integrity": "sha1-NZbmMHp4FUT1kfN9phg2DzHbV7E=", "dev": true }, @@ -1435,6 +1450,7 @@ "version": "1.0.2", "resolved": "http://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -1454,6 +1470,7 @@ "version": "3.0.1", "resolved": "http://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -1559,19 +1576,11 @@ "async-limiter": "~1.0.0" } }, - "xpc-connection": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/xpc-connection/-/xpc-connection-0.1.4.tgz", - "integrity": "sha1-3Nf6oq7Gt6bhjMXdrQQvejTHcVY=", - "optional": true, - "requires": { - "nan": "^2.0.5" - } - }, "yallist": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.3.tgz", - "integrity": "sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A==" + "integrity": "sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A==", + "optional": true } } } diff --git a/package.json b/package.json index 991c34009..6b50be989 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,9 @@ "win32" ], "dependencies": { - "debug": "^4.1.0" + "debug": "^4.1.0", + "napi-thread-safe-callback": "0.0.6", + "node-addon-api": "^1.1.0" }, "optionalDependencies": { "@abandonware/bluetooth-hci-socket": "^0.5.3-1" From 13b269c6ab71f9a8829b834c7ede66dc9269017f Mon Sep 17 00:00:00 2001 From: Philippe Coval Date: Thu, 28 Feb 2019 10:01:13 +0100 Subject: [PATCH 035/114] meta: Add MAINTAINERS file and list myself in I certify that I will work on this project to satisfy community interest and not intend to do any malicious changes. Some references of my OSS contributions and profiles: * https://www.openhub.net/accounts/rzr * https://qa.debian.org/developer.php?login=rzr@users.sf.net * https://launchpad.net/~rzr * https://github.com/rzr/ * https://www.npmjs.com/~rzr --- MAINTAINERS.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 MAINTAINERS.md diff --git a/MAINTAINERS.md b/MAINTAINERS.md new file mode 100644 index 000000000..71eff4088 --- /dev/null +++ b/MAINTAINERS.md @@ -0,0 +1 @@ +* Philippe Coval (https://www.npmjs.com/~rzr) From 1d45d13887eaf566a4b28349990686fb0a1d35d8 Mon Sep 17 00:00:00 2001 From: Alexey Mozzhakov <5459149+alexmozzhakov@users.noreply.github.com> Date: Sun, 22 Jul 2018 21:41:49 +0300 Subject: [PATCH 036/114] Typo fix Change-Id: Ice06fce18ced8cea9ed8fb87721f9de2c9c50c83 Forwarded: https://github.com/noble/noble/pull/818 --- examples/enter-exit.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/enter-exit.js b/examples/enter-exit.js index a48178b70..1b12c683e 100644 --- a/examples/enter-exit.js +++ b/examples/enter-exit.js @@ -1,5 +1,5 @@ /* - Continously scans for peripherals and prints out message when they enter/exit + Continuously scans for peripherals and prints out message when they enter/exit In range criteria: RSSI < threshold Out of range criteria: lastSeen > grace period From 9e2d6392a50d861bc25abd98b3dba6f3990360b6 Mon Sep 17 00:00:00 2001 From: Philippe Coval Date: Mon, 15 Apr 2019 16:38:53 +0200 Subject: [PATCH 037/114] npm: Update dependencies to latest: mocha, sinon Change-Id: I9c7c3c9fa706a6db38e1289295addf802ea1be8b Signed-off-by: Philippe Coval --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 6b50be989..2161447dd 100644 --- a/package.json +++ b/package.json @@ -43,9 +43,9 @@ "devDependencies": { "async": "~2.6.1", "jshint": "latest", - "mocha": "^5.2.0", + "mocha": "^6.1.3", "should": "~13.2.3", - "sinon": "~7.2.2", + "sinon": "~7.3.1", "ws": "^6.1.2" }, "scripts": { From c48bca86d1c62da95da54f0fb495b68d98a25ca1 Mon Sep 17 00:00:00 2001 From: Philippe Coval Date: Mon, 15 Apr 2019 17:43:03 +0200 Subject: [PATCH 038/114] 1.9.2-2 Change-Id: Ib519488db6b17778e8088a1fda7b02f1e50f4eff --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2161447dd..64efa4568 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "license": "MIT", "name": "@abandonware/noble", "description": "A Node.js BLE (Bluetooth Low Energy) central library.", - "version": "1.9.2-1", + "version": "1.9.2-2", "repository": { "type": "git", "url": "https://github.com/sandeepmistry/noble.git" From 5477f2f086e4bff7b5b2f84cffc91b39fd095379 Mon Sep 17 00:00:00 2001 From: Mark Elphinstone-Hoadley Date: Thu, 27 Jun 2019 16:02:05 +0100 Subject: [PATCH 039/114] Change repo in package.json to match repo location (#17) * Changed repo addresses on package.json * Fixed typo --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 64efa4568..89598f267 100644 --- a/package.json +++ b/package.json @@ -10,10 +10,10 @@ "version": "1.9.2-2", "repository": { "type": "git", - "url": "https://github.com/sandeepmistry/noble.git" + "url": "https://github.com/abandonware/noble.git" }, "bugs": { - "url": "https://github.com/sandeepmistry/noble/issues" + "url": "https://github.com/abandonware/noble/issues" }, "keywords": [ "bluetooth", From 64e6e87a1d056851b205839da2afc1c478e3240d Mon Sep 17 00:00:00 2001 From: Jannis R Date: Mon, 22 Jul 2019 20:39:53 +0200 Subject: [PATCH 040/114] async@3, minor dependency upgrades --- package-lock.json | 950 +++++++++++++++++++++++++++++++++++++++------- package.json | 2 +- 2 files changed, 822 insertions(+), 130 deletions(-) diff --git a/package-lock.json b/package-lock.json index dbf046f40..203e08d5b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@abandonware/noble", - "version": "1.9.2-1", + "version": "1.9.2-2", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -556,45 +556,66 @@ } }, "@sinonjs/commons": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-1.3.0.tgz", - "integrity": "sha512-j4ZwhaHmwsCb4DlDOIWnI5YyKDNMoNThsmwEpfHx6a1EpsGZ9qYLxP++LMlmBRjtGptGHFsGItJ768snllFWpA==", + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-1.4.0.tgz", + "integrity": "sha512-9jHK3YF/8HtJ9wCAbG+j8cD0i0+ATS9A7gXFqS36TblLPNy6rEEc+SB0imo91eCboGaBYGV/MT1/br/J+EE7Tw==", "dev": true, "requires": { "type-detect": "4.0.8" } }, "@sinonjs/formatio": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/@sinonjs/formatio/-/formatio-3.1.0.tgz", - "integrity": "sha512-ZAR2bPHOl4Xg6eklUGpsdiIJ4+J1SNag1DHHrG/73Uz/nVwXqjgUtRPLoS+aVyieN9cSbc0E4LsU984tWcDyNg==", + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/@sinonjs/formatio/-/formatio-3.2.1.tgz", + "integrity": "sha512-tsHvOB24rvyvV2+zKMmPkZ7dXX6LSLKZ7aOtXY6Edklp0uRcgGpOsQTTGTcWViFyx4uhWc6GV8QdnALbIbIdeQ==", "dev": true, "requires": { - "@sinonjs/samsam": "^2 || ^3" + "@sinonjs/commons": "^1", + "@sinonjs/samsam": "^3.1.0" } }, "@sinonjs/samsam": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/@sinonjs/samsam/-/samsam-3.0.2.tgz", - "integrity": "sha512-m08g4CS3J6lwRQk1pj1EO+KEVWbrbXsmi9Pw0ySmrIbcVxVaedoFgLvFsV8wHLwh01EpROVz3KvVcD1Jmks9FQ==", + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/@sinonjs/samsam/-/samsam-3.3.2.tgz", + "integrity": "sha512-ILO/rR8LfAb60Y1Yfp9vxfYAASK43NFC2mLzpvLUbCQY/Qu8YwReboseu8aheCEkyElZF2L2T9mHcR2bgdvZyA==", "dev": true, "requires": { "@sinonjs/commons": "^1.0.2", "array-from": "^2.1.1", - "lodash.get": "^4.4.2" + "lodash": "^4.17.11" } }, + "@sinonjs/text-encoding": { + "version": "0.7.1", + "resolved": "https://registry.npmjs.org/@sinonjs/text-encoding/-/text-encoding-0.7.1.tgz", + "integrity": "sha512-+iTbntw2IZPb/anVDbypzfQa+ay64MW0Zo8aJ8gZPWMMK6/OubMVb6lUPMagqjOPnmtauXnFCACVl3O7ogjeqQ==", + "dev": true + }, "abbrev": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==", "optional": true }, + "ansi-colors": { + "version": "3.2.3", + "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-3.2.3.tgz", + "integrity": "sha512-LEHHyuhlPY3TmuUYMh2oz89lTShfvgbmzaBcxve9t/9Wuy7Dwf4yoAKcND7KFT1HAQfqZ12qtc+DUrBMeKF9nw==", + "dev": true + }, "ansi-regex": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", - "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", - "optional": true + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=" + }, + "ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, + "requires": { + "color-convert": "^1.9.0" + } }, "aproba": { "version": "1.2.0", @@ -612,6 +633,15 @@ "readable-stream": "^2.0.6" } }, + "argparse": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "dev": true, + "requires": { + "sprintf-js": "~1.0.2" + } + }, "array-from": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/array-from/-/array-from-2.1.1.tgz", @@ -619,13 +649,10 @@ "dev": true }, "async": { - "version": "2.6.1", - "resolved": "https://registry.npmjs.org/async/-/async-2.6.1.tgz", - "integrity": "sha512-fNEiL2+AZt6AlAw/29Cr0UDe4sRAHCpEHh54WMz+Bb7QfNcFw4h3loofyJpLeQs4Yx7yuqu/2dLgM5hKOs6HlQ==", - "dev": true, - "requires": { - "lodash": "^4.17.10" - } + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/async/-/async-3.1.0.tgz", + "integrity": "sha512-4vx/aaY6j/j3Lw3fbCHNWP0pPaTCew3F6F3hYyl/tHs/ndmV1q7NW9T5yuJ2XAGwdQrP+6Wu20x06U4APo/iQQ==", + "dev": true }, "async-limiter": { "version": "1.0.0", @@ -653,6 +680,34 @@ "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", "dev": true }, + "camelcase": { + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", + "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", + "dev": true + }, + "chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "dev": true, + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + }, + "dependencies": { + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } + } + } + }, "chownr": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.1.tgz", @@ -669,16 +724,68 @@ "glob": "^7.1.1" } }, + "cliui": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-4.1.0.tgz", + "integrity": "sha512-4FG+RSG9DL7uEwRUZXZn3SS34DiDPfzP0VOiEwtUWlE+AR2EIg+hSyvrIgUUfhdgR/UkAeW2QHgeP+hWrXs7jQ==", + "dev": true, + "requires": { + "string-width": "^2.1.1", + "strip-ansi": "^4.0.0", + "wrap-ansi": "^2.0.0" + }, + "dependencies": { + "ansi-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", + "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", + "dev": true + }, + "is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "dev": true + }, + "string-width": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", + "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", + "dev": true, + "requires": { + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^4.0.0" + } + }, + "strip-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", + "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "dev": true, + "requires": { + "ansi-regex": "^3.0.0" + } + } + } + }, "code-point-at": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", - "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", - "optional": true + "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=" + }, + "color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "dev": true, + "requires": { + "color-name": "1.1.3" + } }, - "commander": { - "version": "2.15.1", - "resolved": "http://registry.npmjs.org/commander/-/commander-2.15.1.tgz", - "integrity": "sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag==", + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", "dev": true }, "concat-map": { @@ -706,6 +813,19 @@ "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" }, + "cross-spawn": { + "version": "6.0.5", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz", + "integrity": "sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==", + "dev": true, + "requires": { + "nice-try": "^1.0.4", + "path-key": "^2.0.1", + "semver": "^5.5.0", + "shebang-command": "^1.2.0", + "which": "^1.2.9" + } + }, "date-now": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/date-now/-/date-now-0.1.4.tgz", @@ -713,19 +833,34 @@ "dev": true }, "debug": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.0.tgz", - "integrity": "sha512-heNPJUJIqC+xB6ayLAMHaIrmN9HKa7aQO8MGqKpvCA+uJYVcvR6l5kgdrhRuwPFHU7P5/A1w0BjByPHwpfTDKg==", + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", + "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", "requires": { "ms": "^2.1.1" } }, + "decamelize": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", + "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=", + "dev": true + }, "deep-extend": { "version": "0.6.0", "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.6.0.tgz", "integrity": "sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==", "optional": true }, + "define-properties": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz", + "integrity": "sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ==", + "dev": true, + "requires": { + "object-keys": "^1.0.12" + } + }, "delegates": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz", @@ -787,24 +922,103 @@ "domelementtype": "1" } }, + "emoji-regex": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz", + "integrity": "sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA==", + "dev": true + }, + "end-of-stream": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.1.tgz", + "integrity": "sha512-1MkrZNvWTKCaigbn+W15elq2BB/L22nqrSY5DKlo3X6+vclJm8Bb5djXJBmEX6fS3+zCh/F4VBK5Z2KxJt4s2Q==", + "dev": true, + "requires": { + "once": "^1.4.0" + } + }, "entities": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/entities/-/entities-1.0.0.tgz", "integrity": "sha1-sph6o4ITR/zeZCsk/fyeT7cSvyY=", "dev": true }, + "es-abstract": { + "version": "1.13.0", + "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.13.0.tgz", + "integrity": "sha512-vDZfg/ykNxQVwup/8E1BZhVzFfBxs9NqMzGcvIJrqg5k2/5Za2bWo40dK2J1pgLngZ7c+Shh8lwYtLGyrwPutg==", + "dev": true, + "requires": { + "es-to-primitive": "^1.2.0", + "function-bind": "^1.1.1", + "has": "^1.0.3", + "is-callable": "^1.1.4", + "is-regex": "^1.0.4", + "object-keys": "^1.0.12" + } + }, + "es-to-primitive": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.0.tgz", + "integrity": "sha512-qZryBOJjV//LaxLTV6UC//WewneB3LcXOL9NP++ozKVXsIIIpm/2c13UDiD9Jp2eThsecw9m3jPqDwTyobcdbg==", + "dev": true, + "requires": { + "is-callable": "^1.1.4", + "is-date-object": "^1.0.1", + "is-symbol": "^1.0.2" + } + }, "escape-string-regexp": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", "dev": true }, + "esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", + "dev": true + }, + "execa": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/execa/-/execa-1.0.0.tgz", + "integrity": "sha512-adbxcyWV46qiHyvSp50TKt05tB4tK3HcmF7/nxfAdhnox83seTDbwnaqKO4sXRy7roHAIFqJP/Rw/AuEbX61LA==", + "dev": true, + "requires": { + "cross-spawn": "^6.0.0", + "get-stream": "^4.0.0", + "is-stream": "^1.1.0", + "npm-run-path": "^2.0.0", + "p-finally": "^1.0.0", + "signal-exit": "^3.0.0", + "strip-eof": "^1.0.0" + } + }, "exit": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/exit/-/exit-0.1.2.tgz", "integrity": "sha1-BjJjj42HfMghB9MKD/8aF8uhzQw=", "dev": true }, + "find-up": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", + "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==", + "dev": true, + "requires": { + "locate-path": "^3.0.0" + } + }, + "flat": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/flat/-/flat-4.1.0.tgz", + "integrity": "sha512-Px/TiLIznH7gEDlPXcUD4KnBusa6kR6ayRUVcnEAbreRIuhkqow/mun59BuRXwoYk7ZQOLW1ZM05ilIvK38hFw==", + "dev": true, + "requires": { + "is-buffer": "~2.0.3" + } + }, "fs-minipass": { "version": "1.2.5", "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-1.2.5.tgz", @@ -819,6 +1033,12 @@ "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" }, + "function-bind": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", + "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", + "dev": true + }, "gauge": { "version": "2.7.4", "resolved": "https://registry.npmjs.org/gauge/-/gauge-2.7.4.tgz", @@ -835,6 +1055,21 @@ "wide-align": "^1.1.0" } }, + "get-caller-file": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", + "dev": true + }, + "get-stream": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-4.1.0.tgz", + "integrity": "sha512-GMat4EJ5161kIy2HevLlr4luNjBgvmj413KaQA7jt4V8B4RDsfpHk7WQ9GVqfYyyx8OS/L66Kox+rJRNklLK7w==", + "dev": true, + "requires": { + "pump": "^3.0.0" + } + }, "glob": { "version": "7.1.3", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.3.tgz", @@ -854,12 +1089,27 @@ "integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==", "dev": true }, + "has": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", + "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", + "dev": true, + "requires": { + "function-bind": "^1.1.1" + } + }, "has-flag": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", "dev": true }, + "has-symbols": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.0.tgz", + "integrity": "sha1-uhqPGvKg/DllD1yFA2dwQSIGO0Q=", + "dev": true + }, "has-unicode": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/has-unicode/-/has-unicode-2.0.1.tgz", @@ -867,9 +1117,9 @@ "optional": true }, "he": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz", - "integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0=", + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", + "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==", "dev": true }, "htmlparser2": { @@ -949,32 +1199,95 @@ "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==", "optional": true }, + "invert-kv": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/invert-kv/-/invert-kv-2.0.0.tgz", + "integrity": "sha512-wPVv/y/QQ/Uiirj/vh3oP+1Ww+AWehmi1g5fFWGPF6IpCBCDVrhgHRMvrLfdYcwDh3QJbGXDW4JAuzxElLSqKA==", + "dev": true + }, + "is-buffer": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.3.tgz", + "integrity": "sha512-U15Q7MXTuZlrbymiz95PJpZxu8IlipAp4dtS3wOdgPXx3mqBnslrWU14kxfHB+Py/+2PVKSr37dMAgM2A4uArw==", + "dev": true + }, + "is-callable": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.1.4.tgz", + "integrity": "sha512-r5p9sxJjYnArLjObpjA4xu5EKI3CuKHkJXMhT7kwbpUyIFD1n5PMAsoPvWnvtZiNz7LjkYDRZhd7FlI0eMijEA==", + "dev": true + }, + "is-date-object": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.1.tgz", + "integrity": "sha1-mqIOtq7rv/d/vTPnTKAbM1gdOhY=", + "dev": true + }, "is-fullwidth-code-point": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", - "optional": true, "requires": { "number-is-nan": "^1.0.0" } }, + "is-regex": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.0.4.tgz", + "integrity": "sha1-VRdIm1RwkbCTDglWVM7SXul+lJE=", + "dev": true, + "requires": { + "has": "^1.0.1" + } + }, + "is-stream": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", + "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=", + "dev": true + }, + "is-symbol": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.2.tgz", + "integrity": "sha512-HS8bZ9ox60yCJLH9snBpIwv9pYUAkcuLhSA1oero1UB5y9aiQpRA8y2ex945AOtCZL1lJDeIk3G5LthswI46Lw==", + "dev": true, + "requires": { + "has-symbols": "^1.0.0" + } + }, "isarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", "optional": true }, + "isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", + "dev": true + }, + "js-yaml": { + "version": "3.13.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", + "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", + "dev": true, + "requires": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + } + }, "jshint": { - "version": "2.10.1", - "resolved": "https://registry.npmjs.org/jshint/-/jshint-2.10.1.tgz", - "integrity": "sha512-9GpPfKeffYBl7oBDX2lHPG16j0AM7D2bn3aLy9DaWTr6CWa0i/7UGhX8WLZ7V14QQnnr4hXbjauTLYg06F+HYw==", + "version": "2.10.2", + "resolved": "https://registry.npmjs.org/jshint/-/jshint-2.10.2.tgz", + "integrity": "sha512-e7KZgCSXMJxznE/4WULzybCMNXNAd/bf5TSrvVEq78Q/K8ZwFpmBqQeDtNiHc3l49nV4E/+YeHU/JZjSUIrLAA==", "dev": true, "requires": { "cli": "~1.0.0", "console-browserify": "1.1.x", "exit": "0.1.x", "htmlparser2": "3.8.x", - "lodash": "~4.17.10", + "lodash": "~4.17.11", "minimatch": "~3.0.2", "shelljs": "0.3.x", "strip-json-comments": "1.0.x" @@ -994,22 +1307,70 @@ "integrity": "sha512-FrLwOgm+iXrPV+5zDU6Jqu4gCRXbWEQg2O3SKONsWE4w7AXFRkryS53bpWdaL9cNol+AmR3AEYz6kn+o0fCPnw==", "dev": true }, + "lcid": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/lcid/-/lcid-2.0.0.tgz", + "integrity": "sha512-avPEb8P8EGnwXKClwsNUgryVjllcRqtMYa49NTsbQagYuT1DcXnl1915oxWjoyGrXR6zH/Y0Zc96xWsPcoDKeA==", + "dev": true, + "requires": { + "invert-kv": "^2.0.0" + } + }, + "locate-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", + "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==", + "dev": true, + "requires": { + "p-locate": "^3.0.0", + "path-exists": "^3.0.0" + } + }, "lodash": { - "version": "4.17.11", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", - "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==", + "version": "4.17.15", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", + "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==", "dev": true }, - "lodash.get": { - "version": "4.4.2", - "resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz", - "integrity": "sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk=", - "dev": true + "log-symbols": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-2.2.0.tgz", + "integrity": "sha512-VeIAFslyIerEJLXHziedo2basKbMKtTw3vfn5IzG0XTjhAVEJyNHnL2p7vc+wBDSdQuUpNw3M2u6xb9QsAY5Eg==", + "dev": true, + "requires": { + "chalk": "^2.0.1" + } }, "lolex": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/lolex/-/lolex-3.0.0.tgz", - "integrity": "sha512-hcnW80h3j2lbUfFdMArd5UPA/vxZJ+G8vobd+wg3nVEQA0EigStbYcrG030FJxL6xiDDPEkoMatV9xIh5OecQQ==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/lolex/-/lolex-4.1.0.tgz", + "integrity": "sha512-BYxIEXiVq5lGIXeVHnsFzqa1TxN5acnKnPCdlZSpzm8viNEOhiigupA4vTQ9HEFQ6nLTQ9wQOgBknJgzUYQ9Aw==", + "dev": true + }, + "map-age-cleaner": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/map-age-cleaner/-/map-age-cleaner-0.1.3.tgz", + "integrity": "sha512-bJzx6nMoP6PDLPBFmg7+xRKeFZvFboMrGlxmNj9ClvX53KrmvM5bXFXEWjbz4cz1AFn+jWJ9z/DJSz7hrs0w3w==", + "dev": true, + "requires": { + "p-defer": "^1.0.0" + } + }, + "mem": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/mem/-/mem-4.3.0.tgz", + "integrity": "sha512-qX2bG48pTqYRVmDB37rn/6PT7LcR8T7oAX3bf99u1Tt1nzxYfxkgqDwUwolPlXweM0XzBOBFzSx4kfp7KP1s/w==", + "dev": true, + "requires": { + "map-age-cleaner": "^0.1.1", + "mimic-fn": "^2.0.0", + "p-is-promise": "^2.0.0" + } + }, + "mimic-fn": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", + "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==", "dev": true }, "minimatch": { @@ -1053,59 +1414,57 @@ } }, "mocha": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-5.2.0.tgz", - "integrity": "sha512-2IUgKDhc3J7Uug+FxMXuqIyYzH7gJjXECKe/w43IGgQHTSj3InJi+yAA7T24L9bQMRKiUEHxEX37G5JpVUGLcQ==", + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-6.2.0.tgz", + "integrity": "sha512-qwfFgY+7EKAAUAdv7VYMZQknI7YJSGesxHyhn6qD52DV8UcSZs5XwCifcZGMVIE4a5fbmhvbotxC0DLQ0oKohQ==", "dev": true, "requires": { + "ansi-colors": "3.2.3", "browser-stdout": "1.3.1", - "commander": "2.15.1", - "debug": "3.1.0", + "debug": "3.2.6", "diff": "3.5.0", "escape-string-regexp": "1.0.5", - "glob": "7.1.2", + "find-up": "3.0.0", + "glob": "7.1.3", "growl": "1.10.5", - "he": "1.1.1", + "he": "1.2.0", + "js-yaml": "3.13.1", + "log-symbols": "2.2.0", "minimatch": "3.0.4", "mkdirp": "0.5.1", - "supports-color": "5.4.0" + "ms": "2.1.1", + "node-environment-flags": "1.0.5", + "object.assign": "4.1.0", + "strip-json-comments": "2.0.1", + "supports-color": "6.0.0", + "which": "1.3.1", + "wide-align": "1.1.3", + "yargs": "13.2.2", + "yargs-parser": "13.0.0", + "yargs-unparser": "1.5.0" }, "dependencies": { "debug": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", - "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", - "dev": true, - "requires": { - "ms": "2.0.0" - } - }, - "glob": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", - "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", + "version": "3.2.6", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz", + "integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==", "dev": true, "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" + "ms": "^2.1.1" } }, "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", + "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==", "dev": true } } }, "ms": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", - "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==" + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" }, "nan": { "version": "2.12.1", @@ -1146,32 +1505,48 @@ } } }, + "nice-try": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/nice-try/-/nice-try-1.0.5.tgz", + "integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==", + "dev": true + }, "nise": { - "version": "1.4.8", - "resolved": "https://registry.npmjs.org/nise/-/nise-1.4.8.tgz", - "integrity": "sha512-kGASVhuL4tlAV0tvA34yJYZIVihrUt/5bDwpp4tTluigxUr2bBlJeDXmivb6NuEdFkqvdv/Ybb9dm16PSKUhtw==", + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/nise/-/nise-1.5.0.tgz", + "integrity": "sha512-Z3sfYEkLFzFmL8KY6xnSJLRxwQwYBjOXi/24lb62ZnZiGA0JUzGGTI6TBIgfCSMIDl9Jlu8SRmHNACLTemDHww==", "dev": true, "requires": { "@sinonjs/formatio": "^3.1.0", + "@sinonjs/text-encoding": "^0.7.1", "just-extend": "^4.0.2", - "lolex": "^2.3.2", - "path-to-regexp": "^1.7.0", - "text-encoding": "^0.6.4" + "lolex": "^4.1.0", + "path-to-regexp": "^1.7.0" + } + }, + "node-addon-api": { + "version": "1.6.3", + "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-1.6.3.tgz", + "integrity": "sha512-FXWH6mqjWgU8ewuahp4spec8LkroFZK2NicOv6bNwZC3kcwZUI8LeZdG80UzTSLLhK4T7MsgNwlYDVRlDdfTDg==" + }, + "node-environment-flags": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/node-environment-flags/-/node-environment-flags-1.0.5.tgz", + "integrity": "sha512-VNYPRfGfmZLx0Ye20jWzHUjyTW/c+6Wq+iLhDzUI4XmhrDd9l/FozXV3F2xOaXjvp0co0+v1YSR3CMP6g+VvLQ==", + "dev": true, + "requires": { + "object.getownpropertydescriptors": "^2.0.3", + "semver": "^5.7.0" }, "dependencies": { - "lolex": { - "version": "2.7.5", - "resolved": "https://registry.npmjs.org/lolex/-/lolex-2.7.5.tgz", - "integrity": "sha512-l9x0+1offnKKIzYVjyXU2SiwhXDLekRzKyhnbyldPHvC7BvLPVpdNUNR2KeMAiCN2D/kLNttZgQD5WjSxuBx3Q==", + "semver": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.0.tgz", + "integrity": "sha512-Ya52jSX2u7QKghxeoFGpLwCtGlt7j0oY9DYb5apt9nPlJ42ID+ulTXESnt/qAQcoSERyZ5sl3LDIOw0nAn/5DA==", "dev": true } } }, - "node-addon-api": { - "version": "1.6.2", - "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-1.6.2.tgz", - "integrity": "sha512-479Bjw9nTE5DdBSZZWprFryHGjUaQC31y1wHo19We/k0BZlrmhqQitWoUL0cD8+scljCbIUL+E58oRDEakdGGA==" - }, "nopt": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/nopt/-/nopt-4.0.1.tgz", @@ -1198,6 +1573,15 @@ "npm-bundled": "^1.0.1" } }, + "npm-run-path": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-2.0.2.tgz", + "integrity": "sha1-NakjLfo11wZ7TLLd8jV7GHFTbF8=", + "dev": true, + "requires": { + "path-key": "^2.0.0" + } + }, "npmlog": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-4.1.2.tgz", @@ -1213,8 +1597,7 @@ "number-is-nan": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", - "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", - "optional": true + "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=" }, "object-assign": { "version": "4.1.1", @@ -1222,6 +1605,34 @@ "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", "optional": true }, + "object-keys": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", + "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==", + "dev": true + }, + "object.assign": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.0.tgz", + "integrity": "sha512-exHJeq6kBKj58mqGyTQ9DFvrZC/eR6OwxzoM9YRoGBqrXYonaFyGiFMuc9VZrXf7DarreEwMpurG3dd+CNyW5w==", + "dev": true, + "requires": { + "define-properties": "^1.1.2", + "function-bind": "^1.1.1", + "has-symbols": "^1.0.0", + "object-keys": "^1.0.11" + } + }, + "object.getownpropertydescriptors": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/object.getownpropertydescriptors/-/object.getownpropertydescriptors-2.0.3.tgz", + "integrity": "sha1-h1jIRvW0B62rDyNuCYbxSwUcqhY=", + "dev": true, + "requires": { + "define-properties": "^1.1.2", + "es-abstract": "^1.5.1" + } + }, "once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", @@ -1236,6 +1647,17 @@ "integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=", "optional": true }, + "os-locale": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/os-locale/-/os-locale-3.1.0.tgz", + "integrity": "sha512-Z8l3R4wYWM40/52Z+S265okfFj8Kt2cC2MKY+xNi3kFs+XGI7WXu/I309QQQYbRW4ijiZ+yxs9pqEhJh0DqW3Q==", + "dev": true, + "requires": { + "execa": "^1.0.0", + "lcid": "^2.0.0", + "mem": "^4.0.0" + } + }, "os-tmpdir": { "version": "1.0.2", "resolved": "http://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", @@ -1252,11 +1674,65 @@ "os-tmpdir": "^1.0.0" } }, + "p-defer": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/p-defer/-/p-defer-1.0.0.tgz", + "integrity": "sha1-n26xgvbJqozXQwBKfU+WsZaw+ww=", + "dev": true + }, + "p-finally": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/p-finally/-/p-finally-1.0.0.tgz", + "integrity": "sha1-P7z7FbiZpEEjs0ttzBi3JDNqLK4=", + "dev": true + }, + "p-is-promise": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/p-is-promise/-/p-is-promise-2.1.0.tgz", + "integrity": "sha512-Y3W0wlRPK8ZMRbNq97l4M5otioeA5lm1z7bkNkxCka8HSPjR0xRWmpCmc9utiaLP9Jb1eD8BgeIxTW4AIF45Pg==", + "dev": true + }, + "p-limit": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.2.0.tgz", + "integrity": "sha512-pZbTJpoUsCzV48Mc9Nh51VbwO0X9cuPFE8gYwx9BTCt9SF8/b7Zljd2fVgOxhIF/HDTKgpVzs+GPhyKfjLLFRQ==", + "dev": true, + "requires": { + "p-try": "^2.0.0" + } + }, + "p-locate": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz", + "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==", + "dev": true, + "requires": { + "p-limit": "^2.0.0" + } + }, + "p-try": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", + "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", + "dev": true + }, + "path-exists": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", + "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=", + "dev": true + }, "path-is-absolute": { "version": "1.0.1", "resolved": "http://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" }, + "path-key": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz", + "integrity": "sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A=", + "dev": true + }, "path-to-regexp": { "version": "1.7.0", "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-1.7.0.tgz", @@ -1280,6 +1756,16 @@ "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==", "optional": true }, + "pump": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz", + "integrity": "sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==", + "dev": true, + "requires": { + "end-of-stream": "^1.1.0", + "once": "^1.3.1" + } + }, "rc": { "version": "1.2.8", "resolved": "https://registry.npmjs.org/rc/-/rc-1.2.8.tgz", @@ -1315,6 +1801,18 @@ "util-deprecate": "~1.0.1" } }, + "require-directory": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=", + "dev": true + }, + "require-main-filename": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz", + "integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==", + "dev": true + }, "rimraf": { "version": "2.6.2", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", @@ -1345,14 +1843,27 @@ "semver": { "version": "5.6.0", "resolved": "https://registry.npmjs.org/semver/-/semver-5.6.0.tgz", - "integrity": "sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg==", - "optional": true + "integrity": "sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg==" }, "set-blocking": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", - "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=", - "optional": true + "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=" + }, + "shebang-command": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz", + "integrity": "sha1-RKrGW2lbAzmJaMOfNj/uXer98eo=", + "dev": true, + "requires": { + "shebang-regex": "^1.0.0" + } + }, + "shebang-regex": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz", + "integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=", + "dev": true }, "shelljs": { "version": "0.3.0", @@ -1417,21 +1928,20 @@ "signal-exit": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", - "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=", - "optional": true + "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=" }, "sinon": { - "version": "7.2.2", - "resolved": "https://registry.npmjs.org/sinon/-/sinon-7.2.2.tgz", - "integrity": "sha512-WLagdMHiEsrRmee3jr6IIDntOF4kbI6N2pfbi8wkv50qaUQcBglkzkjtoOEbeJ2vf1EsrHhLI+5Ny8//WHdMoA==", + "version": "7.3.2", + "resolved": "https://registry.npmjs.org/sinon/-/sinon-7.3.2.tgz", + "integrity": "sha512-thErC1z64BeyGiPvF8aoSg0LEnptSaWE7YhdWWbWXgelOyThent7uKOnnEh9zBxDbKixtr5dEko+ws1sZMuFMA==", "dev": true, "requires": { - "@sinonjs/commons": "^1.2.0", - "@sinonjs/formatio": "^3.1.0", - "@sinonjs/samsam": "^3.0.2", + "@sinonjs/commons": "^1.4.0", + "@sinonjs/formatio": "^3.2.1", + "@sinonjs/samsam": "^3.3.1", "diff": "^3.5.0", - "lolex": "^3.0.0", - "nise": "^1.4.7", + "lolex": "^4.0.1", + "nise": "^1.4.10", "supports-color": "^5.5.0" }, "dependencies": { @@ -1446,11 +1956,16 @@ } } }, + "sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", + "dev": true + }, "string-width": { "version": "1.0.2", "resolved": "http://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", - "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -1470,21 +1985,25 @@ "version": "3.0.1", "resolved": "http://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", - "optional": true, "requires": { "ansi-regex": "^2.0.0" } }, + "strip-eof": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz", + "integrity": "sha1-u0P/VZim6wXYm1n80SnJgzE2Br8=", + "dev": true + }, "strip-json-comments": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", - "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=", - "optional": true + "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=" }, "supports-color": { - "version": "5.4.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.4.0.tgz", - "integrity": "sha512-zjaXglF5nnWpsq470jSv6P9DwPvgLkuapYmfDm3JWOm0vkNTVF2tI4UrN2r6jH1qM/uc/WtxYY1hYoA2dOKj5w==", + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-6.0.0.tgz", + "integrity": "sha512-on9Kwidc1IUQo+bQdhi8+Tijpo0e1SS6RoGo2guUwn5vdaxw8RXOF9Vb2ws+ihWOmh4JnCJOvaziZWP1VABaLg==", "dev": true, "requires": { "has-flag": "^3.0.0" @@ -1505,12 +2024,6 @@ "yallist": "^3.0.2" } }, - "text-encoding": { - "version": "0.6.4", - "resolved": "http://registry.npmjs.org/text-encoding/-/text-encoding-0.6.4.tgz", - "integrity": "sha1-45mpgiV6J22uQou5KEXLcb3CbRk=", - "dev": true - }, "type-detect": { "version": "4.0.8", "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", @@ -1553,34 +2066,213 @@ "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", "optional": true }, + "which": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", + "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", + "dev": true, + "requires": { + "isexe": "^2.0.0" + } + }, + "which-module": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz", + "integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=", + "dev": true + }, "wide-align": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.3.tgz", "integrity": "sha512-QGkOQc8XL6Bt5PwnsExKBPuMKBxnGxWWW3fU55Xt4feHozMUhdUMaBCk290qpm/wG5u/RSKzwdAC4i51YigihA==", - "optional": true, "requires": { "string-width": "^1.0.2 || 2" } }, + "wrap-ansi": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz", + "integrity": "sha1-2Pw9KE3QV5T+hJc8rs3Rz4JP3YU=", + "dev": true, + "requires": { + "string-width": "^1.0.1", + "strip-ansi": "^3.0.1" + } + }, "wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" }, "ws": { - "version": "6.1.2", - "resolved": "https://registry.npmjs.org/ws/-/ws-6.1.2.tgz", - "integrity": "sha512-rfUqzvz0WxmSXtJpPMX2EeASXabOrSMk1ruMOV3JBTBjo4ac2lDjGGsbQSyxj8Odhw5fBib8ZKEjDNvgouNKYw==", + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/ws/-/ws-6.2.1.tgz", + "integrity": "sha512-GIyAXC2cB7LjvpgMt9EKS2ldqr0MTrORaleiOno6TweZ6r3TKtoFQWay/2PceJ3RuBasOHzXNn5Lrw1X0bEjqA==", "dev": true, "requires": { "async-limiter": "~1.0.0" } }, + "y18n": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.0.tgz", + "integrity": "sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w==", + "dev": true + }, "yallist": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.3.tgz", "integrity": "sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A==", "optional": true + }, + "yargs": { + "version": "13.2.2", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-13.2.2.tgz", + "integrity": "sha512-WyEoxgyTD3w5XRpAQNYUB9ycVH/PQrToaTXdYXRdOXvEy1l19br+VJsc0vcO8PTGg5ro/l/GY7F/JMEBmI0BxA==", + "dev": true, + "requires": { + "cliui": "^4.0.0", + "find-up": "^3.0.0", + "get-caller-file": "^2.0.1", + "os-locale": "^3.1.0", + "require-directory": "^2.1.1", + "require-main-filename": "^2.0.0", + "set-blocking": "^2.0.0", + "string-width": "^3.0.0", + "which-module": "^2.0.0", + "y18n": "^4.0.0", + "yargs-parser": "^13.0.0" + }, + "dependencies": { + "ansi-regex": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", + "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", + "dev": true + }, + "is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "dev": true + }, + "string-width": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", + "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", + "dev": true, + "requires": { + "emoji-regex": "^7.0.1", + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^5.1.0" + } + }, + "strip-ansi": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", + "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", + "dev": true, + "requires": { + "ansi-regex": "^4.1.0" + } + } + } + }, + "yargs-parser": { + "version": "13.0.0", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-13.0.0.tgz", + "integrity": "sha512-w2LXjoL8oRdRQN+hOyppuXs+V/fVAYtpcrRxZuF7Kt/Oc+Jr2uAcVntaUTNT6w5ihoWfFDpNY8CPx1QskxZ/pw==", + "dev": true, + "requires": { + "camelcase": "^5.0.0", + "decamelize": "^1.2.0" + } + }, + "yargs-unparser": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/yargs-unparser/-/yargs-unparser-1.5.0.tgz", + "integrity": "sha512-HK25qidFTCVuj/D1VfNiEndpLIeJN78aqgR23nL3y4N0U/91cOAzqfHlF8n2BvoNDcZmJKin3ddNSvOxSr8flw==", + "dev": true, + "requires": { + "flat": "^4.1.0", + "lodash": "^4.17.11", + "yargs": "^12.0.5" + }, + "dependencies": { + "ansi-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", + "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", + "dev": true + }, + "get-caller-file": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-1.0.3.tgz", + "integrity": "sha512-3t6rVToeoZfYSGd8YoLFR2DJkiQrIiUrGcjvFX2mDw3bn6k2OtwHN0TNCLbBO+w8qTvimhDkv+LSscbJY1vE6w==", + "dev": true + }, + "is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "dev": true + }, + "require-main-filename": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-1.0.1.tgz", + "integrity": "sha1-l/cXtp1IeE9fUmpsWqj/3aBVpNE=", + "dev": true + }, + "string-width": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", + "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", + "dev": true, + "requires": { + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^4.0.0" + } + }, + "strip-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", + "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "dev": true, + "requires": { + "ansi-regex": "^3.0.0" + } + }, + "yargs": { + "version": "12.0.5", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-12.0.5.tgz", + "integrity": "sha512-Lhz8TLaYnxq/2ObqHDql8dX8CJi97oHxrjUcYtzKbbykPtVW9WB+poxI+NM2UIzsMgNCZTIf0AQwsjK5yMAqZw==", + "dev": true, + "requires": { + "cliui": "^4.0.0", + "decamelize": "^1.2.0", + "find-up": "^3.0.0", + "get-caller-file": "^1.0.1", + "os-locale": "^3.0.0", + "require-directory": "^2.1.1", + "require-main-filename": "^1.0.1", + "set-blocking": "^2.0.0", + "string-width": "^2.0.0", + "which-module": "^2.0.0", + "y18n": "^3.2.1 || ^4.0.0", + "yargs-parser": "^11.1.1" + } + }, + "yargs-parser": { + "version": "11.1.1", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-11.1.1.tgz", + "integrity": "sha512-C6kB/WJDiaxONLJQnF8ccx9SEeoTTLek8RVbaOIsrAUS8VrBEXfmeSnCZxygc+XC2sNMBIwOOnfcxiynjHsVSQ==", + "dev": true, + "requires": { + "camelcase": "^5.0.0", + "decamelize": "^1.2.0" + } + } + } } } } diff --git a/package.json b/package.json index 89598f267..256b6a5ec 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "@abandonware/bluetooth-hci-socket": "^0.5.3-1" }, "devDependencies": { - "async": "~2.6.1", + "async": "^3.1.0", "jshint": "latest", "mocha": "^6.1.3", "should": "~13.2.3", From d92296bf1a1668498499233eee319282837ac1c8 Mon Sep 17 00:00:00 2001 From: Jannis R Date: Mon, 22 Jul 2019 20:40:43 +0200 Subject: [PATCH 041/114] add node-gyp dev dependency --- package-lock.json | 465 ++++++++++++++++++++++++++++++++++++++++++---- package.json | 1 + 2 files changed, 430 insertions(+), 36 deletions(-) diff --git a/package-lock.json b/package-lock.json index 203e08d5b..ae800d98b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -594,8 +594,19 @@ "abbrev": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", - "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==", - "optional": true + "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==" + }, + "ajv": { + "version": "6.10.2", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.10.2.tgz", + "integrity": "sha512-TXtUUEYHuaTEbLZWIKUr5pmBuhDLy+8KYtPYdcV8qC+pOZL+NKqYwvWSRrVXHn+ZmRRAu8vJTAznH7Oag6RVRw==", + "dev": true, + "requires": { + "fast-deep-equal": "^2.0.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + } }, "ansi-colors": { "version": "3.2.3", @@ -620,14 +631,12 @@ "aproba": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/aproba/-/aproba-1.2.0.tgz", - "integrity": "sha512-Y9J6ZjXtoYh8RnXVCMOU/ttDmk1aBjunq9vO0ta5x85WDQiQfUF9sIPBITdbiiIVcBo03Hi3jMxigBtsddlXRw==", - "optional": true + "integrity": "sha512-Y9J6ZjXtoYh8RnXVCMOU/ttDmk1aBjunq9vO0ta5x85WDQiQfUF9sIPBITdbiiIVcBo03Hi3jMxigBtsddlXRw==" }, "are-we-there-yet": { "version": "1.1.5", "resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-1.1.5.tgz", "integrity": "sha512-5hYdAkZlcG8tOLujVDTgCT+uPX0VnpAH28gWsLfzpXYm7wP6mp5Q/gYyR7YQ0cKVJcXJnl3j2kpBan13PtQf6w==", - "optional": true, "requires": { "delegates": "^1.0.0", "readable-stream": "^2.0.6" @@ -648,6 +657,21 @@ "integrity": "sha1-z+nYwmYoudxa7MYqn12PHzUsEZU=", "dev": true }, + "asn1": { + "version": "0.2.4", + "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.4.tgz", + "integrity": "sha512-jxwzQpLQjSmWXgwaCZE9Nz+glAG01yF1QnWgbhGwHI5A6FRIEY6IVqtHhIepHqI7/kyEyQEagBC5mBEFlIYvdg==", + "dev": true, + "requires": { + "safer-buffer": "~2.1.0" + } + }, + "assert-plus": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", + "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=", + "dev": true + }, "async": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/async/-/async-3.1.0.tgz", @@ -660,11 +684,38 @@ "integrity": "sha512-jp/uFnooOiO+L211eZOoSyzpOITMXx1rBITauYykG3BRYPu8h0UcxsPNB04RR5vo4Tyz3+ay17tR6JVf9qzYWg==", "dev": true }, + "asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=", + "dev": true + }, + "aws-sign2": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz", + "integrity": "sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg=", + "dev": true + }, + "aws4": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.8.0.tgz", + "integrity": "sha512-ReZxvNHIOv88FlT7rxcXIIC0fPt4KZqZbOlivyWtXLt8ESx84zd3kMC6iK5jVeS2qt+g7ftS7ye4fi06X5rtRQ==", + "dev": true + }, "balanced-match": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" }, + "bcrypt-pbkdf": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz", + "integrity": "sha1-pDAdOJtqQ/m2f/PKEaP2Y342Dp4=", + "dev": true, + "requires": { + "tweetnacl": "^0.14.3" + } + }, "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", @@ -686,6 +737,12 @@ "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", "dev": true }, + "caseless": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", + "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=", + "dev": true + }, "chalk": { "version": "2.4.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", @@ -711,8 +768,7 @@ "chownr": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.1.tgz", - "integrity": "sha512-j38EvO5+LHX84jlo6h4UzmOwi0UgW61WRyPtJz4qaadK5eY3BTS5TY/S1Stc3Uk2lIM6TPevAlULiEJwie860g==", - "optional": true + "integrity": "sha512-j38EvO5+LHX84jlo6h4UzmOwi0UgW61WRyPtJz4qaadK5eY3BTS5TY/S1Stc3Uk2lIM6TPevAlULiEJwie860g==" }, "cli": { "version": "1.0.1", @@ -788,6 +844,15 @@ "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", "dev": true }, + "combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "dev": true, + "requires": { + "delayed-stream": "~1.0.0" + } + }, "concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", @@ -805,8 +870,7 @@ "console-control-strings": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", - "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=", - "optional": true + "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=" }, "core-util-is": { "version": "1.0.2", @@ -826,6 +890,15 @@ "which": "^1.2.9" } }, + "dashdash": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", + "integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=", + "dev": true, + "requires": { + "assert-plus": "^1.0.0" + } + }, "date-now": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/date-now/-/date-now-0.1.4.tgz", @@ -861,11 +934,16 @@ "object-keys": "^1.0.12" } }, + "delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=", + "dev": true + }, "delegates": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz", - "integrity": "sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o=", - "optional": true + "integrity": "sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o=" }, "detect-libc": { "version": "1.0.3", @@ -922,6 +1000,16 @@ "domelementtype": "1" } }, + "ecc-jsbn": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz", + "integrity": "sha1-OoOpBOVDUyh4dMVkt1SThoSamMk=", + "dev": true, + "requires": { + "jsbn": "~0.1.0", + "safer-buffer": "^2.1.0" + } + }, "emoji-regex": { "version": "7.0.3", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz", @@ -943,6 +1031,12 @@ "integrity": "sha1-sph6o4ITR/zeZCsk/fyeT7cSvyY=", "dev": true }, + "env-paths": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/env-paths/-/env-paths-1.0.0.tgz", + "integrity": "sha1-QWgTO0K7BcOKNbGuQ5fIKYqzaeA=", + "dev": true + }, "es-abstract": { "version": "1.13.0", "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.13.0.tgz", @@ -1001,6 +1095,30 @@ "integrity": "sha1-BjJjj42HfMghB9MKD/8aF8uhzQw=", "dev": true }, + "extend": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", + "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==", + "dev": true + }, + "extsprintf": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz", + "integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=", + "dev": true + }, + "fast-deep-equal": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz", + "integrity": "sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk=", + "dev": true + }, + "fast-json-stable-stringify": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz", + "integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I=", + "dev": true + }, "find-up": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", @@ -1019,11 +1137,27 @@ "is-buffer": "~2.0.3" } }, + "forever-agent": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", + "integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=", + "dev": true + }, + "form-data": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.3.tgz", + "integrity": "sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ==", + "dev": true, + "requires": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.6", + "mime-types": "^2.1.12" + } + }, "fs-minipass": { "version": "1.2.5", "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-1.2.5.tgz", "integrity": "sha512-JhBl0skXjUPCFH7x6x61gQxrKyXsxB5gcgePLZCwfyCGGsTISMoIeObbrvVeP6Xmyaudw4TT43qV2Gz+iyd2oQ==", - "optional": true, "requires": { "minipass": "^2.2.1" } @@ -1043,7 +1177,6 @@ "version": "2.7.4", "resolved": "https://registry.npmjs.org/gauge/-/gauge-2.7.4.tgz", "integrity": "sha1-LANAXHU4w51+s3sxcCLjJfsBi/c=", - "optional": true, "requires": { "aproba": "^1.0.3", "console-control-strings": "^1.0.0", @@ -1070,6 +1203,15 @@ "pump": "^3.0.0" } }, + "getpass": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", + "integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=", + "dev": true, + "requires": { + "assert-plus": "^1.0.0" + } + }, "glob": { "version": "7.1.3", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.3.tgz", @@ -1083,12 +1225,34 @@ "path-is-absolute": "^1.0.0" } }, + "graceful-fs": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.0.tgz", + "integrity": "sha512-jpSvDPV4Cq/bgtpndIWbI5hmYxhQGHPC4d4cqBPb4DLniCfhJokdXhwhaDuLBGLQdvvRum/UiX6ECVIPvDXqdg==", + "dev": true + }, "growl": { "version": "1.10.5", "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz", "integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==", "dev": true }, + "har-schema": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz", + "integrity": "sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI=", + "dev": true + }, + "har-validator": { + "version": "5.1.3", + "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.1.3.tgz", + "integrity": "sha512-sNvOCzEQNr/qrvJgc3UG/kD4QtlHycrzwS+6mfTrrSq97BvaYcPZZI1ZSqGSPR73Cxn4LKTD4PttRwfU7jWq5g==", + "dev": true, + "requires": { + "ajv": "^6.5.5", + "har-schema": "^2.0.0" + } + }, "has": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", @@ -1113,8 +1277,7 @@ "has-unicode": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/has-unicode/-/has-unicode-2.0.1.tgz", - "integrity": "sha1-4Ob+aijPUROIVeCG0Wkedx3iqLk=", - "optional": true + "integrity": "sha1-4Ob+aijPUROIVeCG0Wkedx3iqLk=" }, "he": { "version": "1.2.0", @@ -1161,6 +1324,17 @@ } } }, + "http-signature": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz", + "integrity": "sha1-muzZJRFHcvPZW2WmCruPfBj7rOE=", + "dev": true, + "requires": { + "assert-plus": "^1.0.0", + "jsprim": "^1.2.2", + "sshpk": "^1.7.0" + } + }, "iconv-lite": { "version": "0.4.24", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", @@ -1255,11 +1429,16 @@ "has-symbols": "^1.0.0" } }, + "is-typedarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", + "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=", + "dev": true + }, "isarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", - "optional": true + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" }, "isexe": { "version": "2.0.0", @@ -1267,6 +1446,12 @@ "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", "dev": true }, + "isstream": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", + "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=", + "dev": true + }, "js-yaml": { "version": "3.13.1", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", @@ -1277,6 +1462,12 @@ "esprima": "^4.0.0" } }, + "jsbn": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", + "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=", + "dev": true + }, "jshint": { "version": "2.10.2", "resolved": "https://registry.npmjs.org/jshint/-/jshint-2.10.2.tgz", @@ -1301,6 +1492,36 @@ } } }, + "json-schema": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz", + "integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM=", + "dev": true + }, + "json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", + "dev": true + }, + "json-stringify-safe": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", + "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=", + "dev": true + }, + "jsprim": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz", + "integrity": "sha1-MT5mvB5cwG5Di8G3SZwuXFastqI=", + "dev": true, + "requires": { + "assert-plus": "1.0.0", + "extsprintf": "1.3.0", + "json-schema": "0.2.3", + "verror": "1.10.0" + } + }, "just-extend": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/just-extend/-/just-extend-4.0.2.tgz", @@ -1367,6 +1588,21 @@ "p-is-promise": "^2.0.0" } }, + "mime-db": { + "version": "1.40.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.40.0.tgz", + "integrity": "sha512-jYdeOMPy9vnxEqFRRo6ZvTZ8d9oPb+k18PKoYNYUe2stVEBPPwsln/qWzdbmaIvnhZ9v2P+CuecK+fpUfsV2mA==", + "dev": true + }, + "mime-types": { + "version": "2.1.24", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.24.tgz", + "integrity": "sha512-WaFHS3MCl5fapm3oLxU4eYDw77IQM2ACcxQ9RIxfaC3ooc6PFuBMGZZsYpvoXS5D5QTWPieo1jjLdAm3TBP3cQ==", + "dev": true, + "requires": { + "mime-db": "1.40.0" + } + }, "mimic-fn": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", @@ -1390,7 +1626,6 @@ "version": "2.3.5", "resolved": "https://registry.npmjs.org/minipass/-/minipass-2.3.5.tgz", "integrity": "sha512-Gi1W4k059gyRbyVUZQ4mEqLm0YIUiGYfvxhF6SIlk3ui1WVxMTGfGdQ2SInh3PDrRTVvPKgULkpJtT4RH10+VA==", - "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -1400,7 +1635,6 @@ "version": "1.2.1", "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-1.2.1.tgz", "integrity": "sha512-7+4oTUOWKg7AuL3vloEWekXY2/D20cevzsrNT2kGWm+39J9hGTCBv8VI5Pm5lXZ/o3/mdR4f8rflAPhnQb8mPA==", - "optional": true, "requires": { "minipass": "^2.2.1" } @@ -1547,6 +1781,42 @@ } } }, + "node-gyp": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/node-gyp/-/node-gyp-5.0.3.tgz", + "integrity": "sha512-z/JdtkFGUm0QaQUusvloyYuGDub3nUbOo5de1Fz57cM++osBTvQatBUSTlF1k/w8vFHPxxXW6zxGvkxXSpaBkQ==", + "dev": true, + "requires": { + "env-paths": "^1.0.0", + "glob": "^7.0.3", + "graceful-fs": "^4.1.2", + "mkdirp": "^0.5.0", + "nopt": "2 || 3", + "npmlog": "0 || 1 || 2 || 3 || 4", + "request": "^2.87.0", + "rimraf": "2", + "semver": "~5.3.0", + "tar": "^4.4.8", + "which": "1" + }, + "dependencies": { + "nopt": { + "version": "3.0.6", + "resolved": "https://registry.npmjs.org/nopt/-/nopt-3.0.6.tgz", + "integrity": "sha1-xkZdvwirzU2zWTF/eaxopkayj/k=", + "dev": true, + "requires": { + "abbrev": "1" + } + }, + "semver": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.3.0.tgz", + "integrity": "sha1-myzl094C0XxgEq0yaqa00M9U+U8=", + "dev": true + } + } + }, "nopt": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/nopt/-/nopt-4.0.1.tgz", @@ -1586,7 +1856,6 @@ "version": "4.1.2", "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-4.1.2.tgz", "integrity": "sha512-2uUqazuKlTaSI/dC8AzicUck7+IrEaOnN/e0jd3Xtt1KcGpwx30v50mL7oPyr/h9bL3E4aZccVwpwP+5W9Vjkg==", - "optional": true, "requires": { "are-we-there-yet": "~1.1.2", "console-control-strings": "~1.1.0", @@ -1599,11 +1868,16 @@ "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=" }, + "oauth-sign": { + "version": "0.9.0", + "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz", + "integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==", + "dev": true + }, "object-assign": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", - "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", - "optional": true + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=" }, "object-keys": { "version": "1.1.1", @@ -1750,11 +2024,22 @@ } } }, + "performance-now": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", + "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=", + "dev": true + }, "process-nextick-args": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", - "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==", - "optional": true + "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==" + }, + "psl": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/psl/-/psl-1.2.0.tgz", + "integrity": "sha512-GEn74ZffufCmkDDLNcl3uuyF/aSD6exEyh1v/ZSdAomB82t6G9hzJVRx0jBmLDW+VfZqks3aScmMw9DszwUalA==", + "dev": true }, "pump": { "version": "3.0.0", @@ -1766,6 +2051,18 @@ "once": "^1.3.1" } }, + "punycode": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", + "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==", + "dev": true + }, + "qs": { + "version": "6.5.2", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz", + "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==", + "dev": true + }, "rc": { "version": "1.2.8", "resolved": "https://registry.npmjs.org/rc/-/rc-1.2.8.tgz", @@ -1790,7 +2087,6 @@ "version": "2.3.6", "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", - "optional": true, "requires": { "core-util-is": "~1.0.0", "inherits": "~2.0.3", @@ -1801,6 +2097,34 @@ "util-deprecate": "~1.0.1" } }, + "request": { + "version": "2.88.0", + "resolved": "https://registry.npmjs.org/request/-/request-2.88.0.tgz", + "integrity": "sha512-NAqBSrijGLZdM0WZNsInLJpkJokL72XYjUpnB0iwsRgxh7dB6COrHnTBNwN0E+lHDAJzu7kLAkDeY08z2/A0hg==", + "dev": true, + "requires": { + "aws-sign2": "~0.7.0", + "aws4": "^1.8.0", + "caseless": "~0.12.0", + "combined-stream": "~1.0.6", + "extend": "~3.0.2", + "forever-agent": "~0.6.1", + "form-data": "~2.3.2", + "har-validator": "~5.1.0", + "http-signature": "~1.2.0", + "is-typedarray": "~1.0.0", + "isstream": "~0.1.2", + "json-stringify-safe": "~5.0.1", + "mime-types": "~2.1.19", + "oauth-sign": "~0.9.0", + "performance-now": "^2.1.0", + "qs": "~6.5.2", + "safe-buffer": "^5.1.2", + "tough-cookie": "~2.4.3", + "tunnel-agent": "^0.6.0", + "uuid": "^3.3.2" + } + }, "require-directory": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", @@ -1817,7 +2141,6 @@ "version": "2.6.2", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", - "optional": true, "requires": { "glob": "^7.0.5" } @@ -1825,14 +2148,12 @@ "safe-buffer": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", - "optional": true + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" }, "safer-buffer": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", - "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", - "optional": true + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" }, "sax": { "version": "1.2.4", @@ -1962,6 +2283,23 @@ "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", "dev": true }, + "sshpk": { + "version": "1.16.1", + "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.16.1.tgz", + "integrity": "sha512-HXXqVUq7+pcKeLqqZj6mHFUMvXtOJt1uoUx09pFW6011inTMxqI8BA8PM95myrIyyKwdnzjdFjLiE6KBPVtJIg==", + "dev": true, + "requires": { + "asn1": "~0.2.3", + "assert-plus": "^1.0.0", + "bcrypt-pbkdf": "^1.0.0", + "dashdash": "^1.12.0", + "ecc-jsbn": "~0.1.1", + "getpass": "^0.1.1", + "jsbn": "~0.1.0", + "safer-buffer": "^2.0.2", + "tweetnacl": "~0.14.0" + } + }, "string-width": { "version": "1.0.2", "resolved": "http://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", @@ -1976,7 +2314,6 @@ "version": "1.1.1", "resolved": "http://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "optional": true, "requires": { "safe-buffer": "~5.1.0" } @@ -2013,7 +2350,6 @@ "version": "4.4.8", "resolved": "https://registry.npmjs.org/tar/-/tar-4.4.8.tgz", "integrity": "sha512-LzHF64s5chPQQS0IYBn9IN5h3i98c12bo4NCO7e0sGM2llXQ3p2FGC5sdENN4cTW48O915Sh+x+EXx7XW96xYQ==", - "optional": true, "requires": { "chownr": "^1.1.1", "fs-minipass": "^1.2.5", @@ -2024,12 +2360,54 @@ "yallist": "^3.0.2" } }, + "tough-cookie": { + "version": "2.4.3", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.4.3.tgz", + "integrity": "sha512-Q5srk/4vDM54WJsJio3XNn6K2sCG+CQ8G5Wz6bZhRZoAe/+TxjWB/GlFAnYEbkYVlON9FMk/fE3h2RLpPXo4lQ==", + "dev": true, + "requires": { + "psl": "^1.1.24", + "punycode": "^1.4.1" + }, + "dependencies": { + "punycode": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", + "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=", + "dev": true + } + } + }, + "tunnel-agent": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", + "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=", + "dev": true, + "requires": { + "safe-buffer": "^5.0.1" + } + }, + "tweetnacl": { + "version": "0.14.5", + "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", + "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=", + "dev": true + }, "type-detect": { "version": "4.0.8", "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", "dev": true }, + "uri-js": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.2.2.tgz", + "integrity": "sha512-KY9Frmirql91X2Qgjry0Wd4Y+YTdrdZheS8TFwvkbLWf/G5KNJDCh6pKL5OZctEW4+0Baa5idK2ZQuELRwPznQ==", + "dev": true, + "requires": { + "punycode": "^2.1.0" + } + }, "usb": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/usb/-/usb-1.5.0.tgz", @@ -2063,8 +2441,24 @@ "util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", - "optional": true + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" + }, + "uuid": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz", + "integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==", + "dev": true + }, + "verror": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz", + "integrity": "sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA=", + "dev": true, + "requires": { + "assert-plus": "^1.0.0", + "core-util-is": "1.0.2", + "extsprintf": "^1.2.0" + } }, "which": { "version": "1.3.1", @@ -2122,8 +2516,7 @@ "yallist": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.3.tgz", - "integrity": "sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A==", - "optional": true + "integrity": "sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A==" }, "yargs": { "version": "13.2.2", diff --git a/package.json b/package.json index 256b6a5ec..4b94bc0c5 100644 --- a/package.json +++ b/package.json @@ -44,6 +44,7 @@ "async": "^3.1.0", "jshint": "latest", "mocha": "^6.1.3", + "node-gyp": "^5.0.3", "should": "~13.2.3", "sinon": "~7.3.1", "ws": "^6.1.2" From 908e5594e60779eb7fced82c4976dda184346e5c Mon Sep 17 00:00:00 2001 From: Philippe Coval Date: Tue, 23 Jul 2019 10:00:54 +0200 Subject: [PATCH 042/114] abandonware: Update travis link in readme Change-Id: I097a53b5c0c374db4d86d9e502a1a970764efeb5 Signed-off-by: Philippe Coval --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5fb749a7a..4ae26f858 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # ![noble](assets/noble-logo.png) -[![Build Status](https://travis-ci.org/noble/noble.svg?branch=master)](https://travis-ci.org/noble/noble) +[![Build Status](https://travis-ci.org/abandonware/noble.svg?branch=master)](https://travis-ci.org/abandonware/noble) [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/sandeepmistry/noble?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![OpenCollective](https://opencollective.com/noble/backers/badge.svg)](#backers) [![OpenCollective](https://opencollective.com/noble/sponsors/badge.svg)](#sponsors) From 7abd1a018aa3d82d8a59e6172ec4806fb04dd632 Mon Sep 17 00:00:00 2001 From: Philippe Coval Date: Tue, 23 Jul 2019 10:03:14 +0200 Subject: [PATCH 043/114] abandonware: Replace sandeepmistry org to aw Change-Id: Ib09cacb298b692187c5c4a57da8a545c3bcce31b Signed-off-by: Philippe Coval --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 4ae26f858..27d038165 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,13 @@ # ![noble](assets/noble-logo.png) [![Build Status](https://travis-ci.org/abandonware/noble.svg?branch=master)](https://travis-ci.org/abandonware/noble) -[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/sandeepmistry/noble?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![OpenCollective](https://opencollective.com/noble/backers/badge.svg)](#backers) +[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/abandonware/noble?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![OpenCollective](https://opencollective.com/noble/backers/badge.svg)](#backers) [![OpenCollective](https://opencollective.com/noble/sponsors/badge.svg)](#sponsors) A Node.js BLE (Bluetooth Low Energy) central module. -Want to implement a peripheral? Checkout [bleno](https://github.com/sandeepmistry/bleno) +Want to implement a peripheral? Checkout [bleno](https://github.com/abandonware/bleno) __Note:__ macOS / Mac OS X, Linux, FreeBSD and Windows are currently the only supported OSes. Other platforms may be developed later on. @@ -70,7 +70,7 @@ Install the required tools and configurations using Microsoft's [windows-build-t npm install --global --production windows-build-tools ``` -[node-bluetooth-hci-socket prerequisites](https://github.com/sandeepmistry/node-bluetooth-hci-socket#windows) +[node-bluetooth-hci-socket prerequisites](https://github.com/abandonware/node-bluetooth-hci-socket#windows) * Compatible Bluetooth 4.0 USB adapter * [WinUSB](https://msdn.microsoft.com/en-ca/library/windows/hardware/ff540196(v=vs.85).aspx) driver setup for Bluetooth 4.0 USB adapter, using [Zadig tool](http://zadig.akeo.ie/) From 0a483c78dda227e3cf38c04988ec3b00c5202a10 Mon Sep 17 00:00:00 2001 From: Philippe Coval Date: Tue, 23 Jul 2019 10:08:35 +0200 Subject: [PATCH 044/114] 1.9.2-3 Change-Id: I8a97f29b04f63239eff87ff1c2c2389543e2a0c7 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index ae800d98b..11319d63f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@abandonware/noble", - "version": "1.9.2-2", + "version": "1.9.2-3", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 4b94bc0c5..94738cb32 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "license": "MIT", "name": "@abandonware/noble", "description": "A Node.js BLE (Bluetooth Low Energy) central library.", - "version": "1.9.2-2", + "version": "1.9.2-3", "repository": { "type": "git", "url": "https://github.com/abandonware/noble.git" From 5c6ecf2709c1647658518a32317a92e544d6cec1 Mon Sep 17 00:00:00 2001 From: Michael Stegeman Date: Wed, 18 Sep 2019 14:22:05 -0800 Subject: [PATCH 045/114] Update dependencies for Node 12. Fixes #21 --- .travis.yml | 1 + package-lock.json | 1100 ++++++++++++++++----------------------------- package.json | 12 +- 3 files changed, 399 insertions(+), 714 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4f14aeef0..a668f9c3c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,6 +6,7 @@ env: - NODE_VERSION="6" - NODE_VERSION="8" - NODE_VERSION="10" + - NODE_VERSION="12" matrix: fast_finish: true before_install: diff --git a/package-lock.json b/package-lock.json index 11319d63f..46a915d44 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,564 +1,25 @@ { "name": "@abandonware/noble", - "version": "1.9.2-3", + "version": "1.9.2-4", "lockfileVersion": 1, "requires": true, "dependencies": { "@abandonware/bluetooth-hci-socket": { - "version": "0.5.3-1", - "resolved": "https://registry.npmjs.org/@abandonware/bluetooth-hci-socket/-/bluetooth-hci-socket-0.5.3-1.tgz", - "integrity": "sha512-NzLRq7mjAmvLDRA0E5hvCRtsuV0tq5fbUFxLxSmakRu9K4VM6u7P+3PvAkcylX3CEq0BY9Wwe3KXiMrQBjbMhg==", + "version": "0.5.3-3", + "resolved": "https://registry.npmjs.org/@abandonware/bluetooth-hci-socket/-/bluetooth-hci-socket-0.5.3-3.tgz", + "integrity": "sha512-SkT5yVoaceiWOK1eWW/QCgAaPph/Y+EkOVBvETmhsD1hhKa83+EmVRMjubO68k54uoIzviqcNhxZI/LuIU2PHA==", "optional": true, "requires": { "debug": "^4.1.0", - "nan": "^2.10.0", - "node-pre-gyp": "^0.12.0", - "usb": "^1.1.0" - }, - "dependencies": { - "abbrev": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", - "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==", - "optional": true - }, - "ansi-regex": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", - "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", - "optional": true - }, - "aproba": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/aproba/-/aproba-1.2.0.tgz", - "integrity": "sha512-Y9J6ZjXtoYh8RnXVCMOU/ttDmk1aBjunq9vO0ta5x85WDQiQfUF9sIPBITdbiiIVcBo03Hi3jMxigBtsddlXRw==", - "optional": true - }, - "are-we-there-yet": { - "version": "1.1.5", - "resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-1.1.5.tgz", - "integrity": "sha512-5hYdAkZlcG8tOLujVDTgCT+uPX0VnpAH28gWsLfzpXYm7wP6mp5Q/gYyR7YQ0cKVJcXJnl3j2kpBan13PtQf6w==", - "optional": true, - "requires": { - "delegates": "^1.0.0", - "readable-stream": "^2.0.6" - } - }, - "balanced-match": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", - "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", - "optional": true - }, - "brace-expansion": { - "version": "1.1.11", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", - "optional": true, - "requires": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } - }, - "chownr": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.1.tgz", - "integrity": "sha512-j38EvO5+LHX84jlo6h4UzmOwi0UgW61WRyPtJz4qaadK5eY3BTS5TY/S1Stc3Uk2lIM6TPevAlULiEJwie860g==", - "optional": true - }, - "code-point-at": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", - "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", - "optional": true - }, - "concat-map": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", - "optional": true - }, - "console-control-strings": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", - "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=", - "optional": true - }, - "core-util-is": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", - "optional": true - }, - "deep-extend": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.6.0.tgz", - "integrity": "sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==", - "optional": true - }, - "delegates": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz", - "integrity": "sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o=", - "optional": true - }, - "detect-libc": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-1.0.3.tgz", - "integrity": "sha1-+hN8S9aY7fVc1c0CrFWfkaTEups=", - "optional": true - }, - "fs-minipass": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-1.2.5.tgz", - "integrity": "sha512-JhBl0skXjUPCFH7x6x61gQxrKyXsxB5gcgePLZCwfyCGGsTISMoIeObbrvVeP6Xmyaudw4TT43qV2Gz+iyd2oQ==", - "optional": true, - "requires": { - "minipass": "^2.2.1" - } - }, - "fs.realpath": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", - "optional": true - }, - "gauge": { - "version": "2.7.4", - "resolved": "https://registry.npmjs.org/gauge/-/gauge-2.7.4.tgz", - "integrity": "sha1-LANAXHU4w51+s3sxcCLjJfsBi/c=", - "optional": true, - "requires": { - "aproba": "^1.0.3", - "console-control-strings": "^1.0.0", - "has-unicode": "^2.0.0", - "object-assign": "^4.1.0", - "signal-exit": "^3.0.0", - "string-width": "^1.0.1", - "strip-ansi": "^3.0.1", - "wide-align": "^1.1.0" - } - }, - "glob": { - "version": "7.1.3", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.3.tgz", - "integrity": "sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ==", - "optional": true, - "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - } - }, - "has-unicode": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/has-unicode/-/has-unicode-2.0.1.tgz", - "integrity": "sha1-4Ob+aijPUROIVeCG0Wkedx3iqLk=", - "optional": true - }, - "iconv-lite": { - "version": "0.4.24", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", - "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", - "optional": true, - "requires": { - "safer-buffer": ">= 2.1.2 < 3" - } - }, - "ignore-walk": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/ignore-walk/-/ignore-walk-3.0.1.tgz", - "integrity": "sha512-DTVlMx3IYPe0/JJcYP7Gxg7ttZZu3IInhuEhbchuqneY9wWe5Ojy2mXLBaQFUQmo0AW2r3qG7m1mg86js+gnlQ==", - "optional": true, - "requires": { - "minimatch": "^3.0.4" - } - }, - "inflight": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", - "optional": true, - "requires": { - "once": "^1.3.0", - "wrappy": "1" - } - }, - "inherits": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", - "optional": true - }, - "ini": { - "version": "1.3.5", - "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", - "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==", - "optional": true - }, - "is-fullwidth-code-point": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", - "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", - "optional": true, - "requires": { - "number-is-nan": "^1.0.0" - } - }, - "isarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", - "optional": true - }, - "minimatch": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", - "optional": true, - "requires": { - "brace-expansion": "^1.1.7" - } - }, - "minimist": { - "version": "0.0.8", - "resolved": "http://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", - "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", - "optional": true - }, - "minipass": { - "version": "2.3.5", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-2.3.5.tgz", - "integrity": "sha512-Gi1W4k059gyRbyVUZQ4mEqLm0YIUiGYfvxhF6SIlk3ui1WVxMTGfGdQ2SInh3PDrRTVvPKgULkpJtT4RH10+VA==", - "optional": true, - "requires": { - "safe-buffer": "^5.1.2", - "yallist": "^3.0.0" - } - }, - "minizlib": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-1.2.1.tgz", - "integrity": "sha512-7+4oTUOWKg7AuL3vloEWekXY2/D20cevzsrNT2kGWm+39J9hGTCBv8VI5Pm5lXZ/o3/mdR4f8rflAPhnQb8mPA==", - "optional": true, - "requires": { - "minipass": "^2.2.1" - } - }, - "mkdirp": { - "version": "0.5.1", - "resolved": "http://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", - "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", - "optional": true, - "requires": { - "minimist": "0.0.8" - } - }, - "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", - "optional": true - }, - "needle": { - "version": "2.2.4", - "resolved": "https://registry.npmjs.org/needle/-/needle-2.2.4.tgz", - "integrity": "sha512-HyoqEb4wr/rsoaIDfTH2aVL9nWtQqba2/HvMv+++m8u0dz808MaagKILxtfeSN7QU7nvbQ79zk3vYOJp9zsNEA==", - "optional": true, - "requires": { - "debug": "^2.1.2", - "iconv-lite": "^0.4.4", - "sax": "^1.2.4" - }, - "dependencies": { - "debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "optional": true, - "requires": { - "ms": "2.0.0" - } - } - } - }, - "node-pre-gyp": { - "version": "0.12.0", - "resolved": "https://registry.npmjs.org/node-pre-gyp/-/node-pre-gyp-0.12.0.tgz", - "integrity": "sha512-4KghwV8vH5k+g2ylT+sLTjy5wmUOb9vPhnM8NHvRf9dHmnW/CndrFXy2aRPaPST6dugXSdHXfeaHQm77PIz/1A==", - "optional": true, - "requires": { - "detect-libc": "^1.0.2", - "mkdirp": "^0.5.1", - "needle": "^2.2.1", - "nopt": "^4.0.1", - "npm-packlist": "^1.1.6", - "npmlog": "^4.0.2", - "rc": "^1.2.7", - "rimraf": "^2.6.1", - "semver": "^5.3.0", - "tar": "^4" - } - }, - "nopt": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/nopt/-/nopt-4.0.1.tgz", - "integrity": "sha1-0NRoWv1UFRk8jHUFYC0NF81kR00=", - "optional": true, - "requires": { - "abbrev": "1", - "osenv": "^0.1.4" - } - }, - "npm-bundled": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/npm-bundled/-/npm-bundled-1.0.5.tgz", - "integrity": "sha512-m/e6jgWu8/v5niCUKQi9qQl8QdeEduFA96xHDDzFGqly0OOjI7c+60KM/2sppfnUU9JJagf+zs+yGhqSOFj71g==", - "optional": true - }, - "npm-packlist": { - "version": "1.1.12", - "resolved": "https://registry.npmjs.org/npm-packlist/-/npm-packlist-1.1.12.tgz", - "integrity": "sha512-WJKFOVMeAlsU/pjXuqVdzU0WfgtIBCupkEVwn+1Y0ERAbUfWw8R4GjgVbaKnUjRoD2FoQbHOCbOyT5Mbs9Lw4g==", - "optional": true, - "requires": { - "ignore-walk": "^3.0.1", - "npm-bundled": "^1.0.1" - } - }, - "npmlog": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-4.1.2.tgz", - "integrity": "sha512-2uUqazuKlTaSI/dC8AzicUck7+IrEaOnN/e0jd3Xtt1KcGpwx30v50mL7oPyr/h9bL3E4aZccVwpwP+5W9Vjkg==", - "optional": true, - "requires": { - "are-we-there-yet": "~1.1.2", - "console-control-strings": "~1.1.0", - "gauge": "~2.7.3", - "set-blocking": "~2.0.0" - } - }, - "number-is-nan": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", - "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", - "optional": true - }, - "object-assign": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", - "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", - "optional": true - }, - "once": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", - "optional": true, - "requires": { - "wrappy": "1" - } - }, - "os-homedir": { - "version": "1.0.2", - "resolved": "http://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz", - "integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=", - "optional": true - }, - "os-tmpdir": { - "version": "1.0.2", - "resolved": "http://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", - "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=", - "optional": true - }, - "osenv": { - "version": "0.1.5", - "resolved": "https://registry.npmjs.org/osenv/-/osenv-0.1.5.tgz", - "integrity": "sha512-0CWcCECdMVc2Rw3U5w9ZjqX6ga6ubk1xDVKxtBQPK7wis/0F2r9T6k4ydGYhecl7YUBxBVxhL5oisPsNxAPe2g==", - "optional": true, - "requires": { - "os-homedir": "^1.0.0", - "os-tmpdir": "^1.0.0" - } - }, - "path-is-absolute": { - "version": "1.0.1", - "resolved": "http://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", - "optional": true - }, - "process-nextick-args": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", - "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==", - "optional": true - }, - "rc": { - "version": "1.2.8", - "resolved": "https://registry.npmjs.org/rc/-/rc-1.2.8.tgz", - "integrity": "sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw==", - "optional": true, - "requires": { - "deep-extend": "^0.6.0", - "ini": "~1.3.0", - "minimist": "^1.2.0", - "strip-json-comments": "~2.0.1" - }, - "dependencies": { - "minimist": { - "version": "1.2.0", - "resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", - "optional": true - } - } - }, - "readable-stream": { - "version": "2.3.6", - "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", - "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", - "optional": true, - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.1.1", - "util-deprecate": "~1.0.1" - } - }, - "rimraf": { - "version": "2.6.2", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", - "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", - "optional": true, - "requires": { - "glob": "^7.0.5" - } - }, - "safe-buffer": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", - "optional": true - }, - "safer-buffer": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", - "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", - "optional": true - }, - "sax": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz", - "integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==", - "optional": true - }, - "semver": { - "version": "5.6.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.6.0.tgz", - "integrity": "sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg==", - "optional": true - }, - "set-blocking": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", - "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=", - "optional": true - }, - "signal-exit": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", - "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=", - "optional": true - }, - "string-width": { - "version": "1.0.2", - "resolved": "http://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", - "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", - "optional": true, - "requires": { - "code-point-at": "^1.0.0", - "is-fullwidth-code-point": "^1.0.0", - "strip-ansi": "^3.0.0" - } - }, - "string_decoder": { - "version": "1.1.1", - "resolved": "http://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", - "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "optional": true, - "requires": { - "safe-buffer": "~5.1.0" - } - }, - "strip-ansi": { - "version": "3.0.1", - "resolved": "http://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", - "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", - "optional": true, - "requires": { - "ansi-regex": "^2.0.0" - } - }, - "strip-json-comments": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", - "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=", - "optional": true - }, - "tar": { - "version": "4.4.8", - "resolved": "https://registry.npmjs.org/tar/-/tar-4.4.8.tgz", - "integrity": "sha512-LzHF64s5chPQQS0IYBn9IN5h3i98c12bo4NCO7e0sGM2llXQ3p2FGC5sdENN4cTW48O915Sh+x+EXx7XW96xYQ==", - "optional": true, - "requires": { - "chownr": "^1.1.1", - "fs-minipass": "^1.2.5", - "minipass": "^2.3.4", - "minizlib": "^1.1.1", - "mkdirp": "^0.5.0", - "safe-buffer": "^5.1.2", - "yallist": "^3.0.2" - } - }, - "util-deprecate": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", - "optional": true - }, - "wide-align": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.3.tgz", - "integrity": "sha512-QGkOQc8XL6Bt5PwnsExKBPuMKBxnGxWWW3fU55Xt4feHozMUhdUMaBCk290qpm/wG5u/RSKzwdAC4i51YigihA==", - "optional": true, - "requires": { - "string-width": "^1.0.2 || 2" - } - }, - "wrappy": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", - "optional": true - }, - "yallist": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.3.tgz", - "integrity": "sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A==", - "optional": true - } + "nan": "^2.14.0", + "node-pre-gyp": "^0.13.0", + "usb": "^1.6.0" } }, "@sinonjs/commons": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-1.4.0.tgz", - "integrity": "sha512-9jHK3YF/8HtJ9wCAbG+j8cD0i0+ATS9A7gXFqS36TblLPNy6rEEc+SB0imo91eCboGaBYGV/MT1/br/J+EE7Tw==", + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-1.6.0.tgz", + "integrity": "sha512-w4/WHG7C4WWFyE5geCieFJF6MZkbW4VAriol5KlmQXpAQdxvV0p26sqNZOW6Qyw6Y0l9K4g+cHvvczR2sEEpqg==", "dev": true, "requires": { "type-detect": "4.0.8" @@ -575,14 +36,14 @@ } }, "@sinonjs/samsam": { - "version": "3.3.2", - "resolved": "https://registry.npmjs.org/@sinonjs/samsam/-/samsam-3.3.2.tgz", - "integrity": "sha512-ILO/rR8LfAb60Y1Yfp9vxfYAASK43NFC2mLzpvLUbCQY/Qu8YwReboseu8aheCEkyElZF2L2T9mHcR2bgdvZyA==", + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/@sinonjs/samsam/-/samsam-3.3.3.tgz", + "integrity": "sha512-bKCMKZvWIjYD0BLGnNrxVuw4dkWCYsLqFOUWw8VgKF/+5Y+mE7LfHWPIYoDXowH+3a9LsWDMo0uAP8YDosPvHQ==", "dev": true, "requires": { - "@sinonjs/commons": "^1.0.2", + "@sinonjs/commons": "^1.3.0", "array-from": "^2.1.1", - "lodash": "^4.17.11" + "lodash": "^4.17.15" } }, "@sinonjs/text-encoding": { @@ -679,9 +140,9 @@ "dev": true }, "async-limiter": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.0.tgz", - "integrity": "sha512-jp/uFnooOiO+L211eZOoSyzpOITMXx1rBITauYykG3BRYPu8h0UcxsPNB04RR5vo4Tyz3+ay17tR6JVf9qzYWg==", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.1.tgz", + "integrity": "sha512-csOlWGAcRFJaI6m+F2WKdnMKr4HhdhFVBk0H/QbJFMCr+uO2kwohwXQPxw/9OCxp05r5ghVBFSyioixx3gfkNQ==", "dev": true }, "asynckit": { @@ -716,6 +177,37 @@ "tweetnacl": "^0.14.3" } }, + "bindings": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz", + "integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==", + "optional": true, + "requires": { + "file-uri-to-path": "1.0.0" + } + }, + "bl": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/bl/-/bl-3.0.0.tgz", + "integrity": "sha512-EUAyP5UHU5hxF8BPT0LKW8gjYLhq1DQIcneOX/pL/m2Alo+OYDQAJlHq+yseMP50Os2nHXOSic6Ss3vSQeyf4A==", + "optional": true, + "requires": { + "readable-stream": "^3.0.1" + }, + "dependencies": { + "readable-stream": { + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.4.0.tgz", + "integrity": "sha512-jItXPLmrSR8jmTRmRWJXCnGJsfy85mB3Wd/uINMXA65yrnFo0cPClFIUWzo2najVNSl+mx7/4W8ttlLWJe99pQ==", + "optional": true, + "requires": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + } + } + } + }, "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", @@ -766,9 +258,9 @@ } }, "chownr": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.1.tgz", - "integrity": "sha512-j38EvO5+LHX84jlo6h4UzmOwi0UgW61WRyPtJz4qaadK5eY3BTS5TY/S1Stc3Uk2lIM6TPevAlULiEJwie860g==" + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.2.tgz", + "integrity": "sha512-GkfeAQh+QNy3wquu9oIZr6SS5x7wGdSgNQvD10X3r+AZr1Oys22HW8kAmDMvNg2+Dm0TeGaEuO8gFwdBXxwO8A==" }, "cli": { "version": "1.0.1", @@ -919,6 +411,15 @@ "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=", "dev": true }, + "decompress-response": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-4.2.1.tgz", + "integrity": "sha512-jOSne2qbyE+/r8G1VU+G/82LBs2Fs4LAsTiLSHOCOMZQl2OKZ6i8i4IyHemTe+/yIXOtTcRQMzPcgyhoFlqPkw==", + "optional": true, + "requires": { + "mimic-response": "^2.0.0" + } + }, "deep-extend": { "version": "0.6.0", "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.6.0.tgz", @@ -958,19 +459,25 @@ "dev": true }, "dom-serializer": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-0.1.1.tgz", - "integrity": "sha512-l0IU0pPzLWSHBcieZbpOKgkIn3ts3vAh7ZuFyXNwJxJXk/c4Gwj9xaTJwIDVQCXawWD0qb3IzMGH5rglQaO0XA==", + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-0.2.1.tgz", + "integrity": "sha512-sK3ujri04WyjwQXVoK4PU3y8ula1stq10GJZpqHIUgoGZdsGzAGu65BnU3d08aTVSvO7mGPZUc0wTEDL+qGE0Q==", "dev": true, "requires": { - "domelementtype": "^1.3.0", - "entities": "^1.1.1" + "domelementtype": "^2.0.1", + "entities": "^2.0.0" }, "dependencies": { + "domelementtype": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.0.1.tgz", + "integrity": "sha512-5HOHUDsYZWV8FGWN0Njbr/Rn7f/eWSQi1v7+HsUVwXgn8nWWlL64zKDkS0n8ZmQ3mlWOMuXOnR+7Nx/5tMO5AQ==", + "dev": true + }, "entities": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/entities/-/entities-1.1.2.tgz", - "integrity": "sha512-f2LZMYl1Fzu7YSBKg+RoROelpOaNrcGmE9AZubeDfrCEia483oW4MI4VyFd5VNHIgQ/7qm1I0wUHK1eJnn2y2w==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/entities/-/entities-2.0.0.tgz", + "integrity": "sha512-D9f7V0JSRwIxlRI2mjMqufDrRDnx8p+eEOz7aUM9SuvF8gsBzra0/6tbjl1m8eQHrZlYj6PxqE00hZ1SAIKPLw==", "dev": true } } @@ -1020,7 +527,6 @@ "version": "1.4.1", "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.1.tgz", "integrity": "sha512-1MkrZNvWTKCaigbn+W15elq2BB/L22nqrSY5DKlo3X6+vclJm8Bb5djXJBmEX6fS3+zCh/F4VBK5Z2KxJt4s2Q==", - "dev": true, "requires": { "once": "^1.4.0" } @@ -1038,17 +544,21 @@ "dev": true }, "es-abstract": { - "version": "1.13.0", - "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.13.0.tgz", - "integrity": "sha512-vDZfg/ykNxQVwup/8E1BZhVzFfBxs9NqMzGcvIJrqg5k2/5Za2bWo40dK2J1pgLngZ7c+Shh8lwYtLGyrwPutg==", + "version": "1.14.2", + "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.14.2.tgz", + "integrity": "sha512-DgoQmbpFNOofkjJtKwr87Ma5EW4Dc8fWhD0R+ndq7Oc456ivUfGOOP6oAZTTKl5/CcNMP+EN+e3/iUzgE0veZg==", "dev": true, "requires": { "es-to-primitive": "^1.2.0", "function-bind": "^1.1.1", "has": "^1.0.3", + "has-symbols": "^1.0.0", "is-callable": "^1.1.4", "is-regex": "^1.0.4", - "object-keys": "^1.0.12" + "object-inspect": "^1.6.0", + "object-keys": "^1.1.1", + "string.prototype.trimleft": "^2.0.0", + "string.prototype.trimright": "^2.0.0" } }, "es-to-primitive": { @@ -1095,6 +605,12 @@ "integrity": "sha1-BjJjj42HfMghB9MKD/8aF8uhzQw=", "dev": true }, + "expand-template": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/expand-template/-/expand-template-2.0.3.tgz", + "integrity": "sha512-XYfuKMvj4O35f/pOXLObndIRvyQ+/+6AhODh+OKWj9S9498pHHn/IMszH+gt0fBCRWMNfk1ZSp5x3AifmnI2vg==", + "optional": true + }, "extend": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", @@ -1119,6 +635,12 @@ "integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I=", "dev": true }, + "file-uri-to-path": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", + "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==", + "optional": true + }, "find-up": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", @@ -1154,12 +676,18 @@ "mime-types": "^2.1.12" } }, + "fs-constants": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz", + "integrity": "sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==", + "optional": true + }, "fs-minipass": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-1.2.5.tgz", - "integrity": "sha512-JhBl0skXjUPCFH7x6x61gQxrKyXsxB5gcgePLZCwfyCGGsTISMoIeObbrvVeP6Xmyaudw4TT43qV2Gz+iyd2oQ==", + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-1.2.7.tgz", + "integrity": "sha512-GWSSJGFy4e9GUeCcbIkED+bgAoFyj7XF1mV8rma3QW4NIqX9Kyx79N/PF61H5udOV3aY1IaMLs6pGbH71nlCTA==", "requires": { - "minipass": "^2.2.1" + "minipass": "^2.6.0" } }, "fs.realpath": { @@ -1212,10 +740,16 @@ "assert-plus": "^1.0.0" } }, + "github-from-package": { + "version": "0.0.0", + "resolved": "https://registry.npmjs.org/github-from-package/-/github-from-package-0.0.0.tgz", + "integrity": "sha1-l/tdlr/eiXMxPyDoKI75oWf6ZM4=", + "optional": true + }, "glob": { - "version": "7.1.3", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.3.tgz", - "integrity": "sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ==", + "version": "7.1.4", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz", + "integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==", "requires": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", @@ -1226,9 +760,9 @@ } }, "graceful-fs": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.0.tgz", - "integrity": "sha512-jpSvDPV4Cq/bgtpndIWbI5hmYxhQGHPC4d4cqBPb4DLniCfhJokdXhwhaDuLBGLQdvvRum/UiX6ECVIPvDXqdg==", + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.2.tgz", + "integrity": "sha512-IItsdsea19BoLC7ELy13q1iJFNmd7ofZH5+X/pJr90/nRoPEX0DJo1dHDbgtYWOhJhcCgMDTOw84RZ72q6lB+Q==", "dev": true }, "growl": { @@ -1345,9 +879,9 @@ } }, "ignore-walk": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/ignore-walk/-/ignore-walk-3.0.1.tgz", - "integrity": "sha512-DTVlMx3IYPe0/JJcYP7Gxg7ttZZu3IInhuEhbchuqneY9wWe5Ojy2mXLBaQFUQmo0AW2r3qG7m1mg86js+gnlQ==", + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/ignore-walk/-/ignore-walk-3.0.2.tgz", + "integrity": "sha512-EXyErtpHbn75ZTsOADsfx6J/FPo6/5cjev46PXrcTpd8z3BoRkXgYu9/JVqrI7tusjmwCZutGeRJeU0Wo1e4Cw==", "optional": true, "requires": { "minimatch": "^3.0.4" @@ -1363,9 +897,9 @@ } }, "inherits": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" }, "ini": { "version": "1.3.5", @@ -1563,9 +1097,9 @@ } }, "lolex": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/lolex/-/lolex-4.1.0.tgz", - "integrity": "sha512-BYxIEXiVq5lGIXeVHnsFzqa1TxN5acnKnPCdlZSpzm8viNEOhiigupA4vTQ9HEFQ6nLTQ9wQOgBknJgzUYQ9Aw==", + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/lolex/-/lolex-4.2.0.tgz", + "integrity": "sha512-gKO5uExCXvSm6zbF562EvM+rd1kQDnB9AZBbiQVzf1ZmdDpxUSvpnAaVOP83N/31mRK8Ml8/VE8DMvsAZQ+7wg==", "dev": true }, "map-age-cleaner": { @@ -1609,6 +1143,12 @@ "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==", "dev": true }, + "mimic-response": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-2.0.0.tgz", + "integrity": "sha512-8ilDoEapqA4uQ3TwS0jakGONKXVJqpy+RpM+3b7pLdOjghCrEiGp9SRkFbUHAmZW9vdnrENWHjaweIoTIJExSQ==", + "optional": true + }, "minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", @@ -1619,29 +1159,29 @@ }, "minimist": { "version": "0.0.8", - "resolved": "http://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" }, "minipass": { - "version": "2.3.5", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-2.3.5.tgz", - "integrity": "sha512-Gi1W4k059gyRbyVUZQ4mEqLm0YIUiGYfvxhF6SIlk3ui1WVxMTGfGdQ2SInh3PDrRTVvPKgULkpJtT4RH10+VA==", + "version": "2.6.5", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-2.6.5.tgz", + "integrity": "sha512-ewSKOPFH9blOLXx0YSE+mbrNMBFPS+11a2b03QZ+P4LVrUHW/GAlqeYC7DBknDyMWkHzrzTpDhUvy7MUxqyrPA==", "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" } }, "minizlib": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-1.2.1.tgz", - "integrity": "sha512-7+4oTUOWKg7AuL3vloEWekXY2/D20cevzsrNT2kGWm+39J9hGTCBv8VI5Pm5lXZ/o3/mdR4f8rflAPhnQb8mPA==", + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-1.2.2.tgz", + "integrity": "sha512-hR3At21uSrsjjDTWrbu0IMLTpnkpv8IIMFDFaoz43Tmu4LkmAXfH44vNNzpTnf+OAQQCHrb91y/wc2J4x5XgSQ==", "requires": { "minipass": "^2.2.1" } }, "mkdirp": { "version": "0.5.1", - "resolved": "http://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", "requires": { "minimist": "0.0.8" @@ -1687,6 +1227,20 @@ "ms": "^2.1.1" } }, + "glob": { + "version": "7.1.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.3.tgz", + "integrity": "sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, "ms": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", @@ -1701,9 +1255,15 @@ "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" }, "nan": { - "version": "2.12.1", - "resolved": "https://registry.npmjs.org/nan/-/nan-2.12.1.tgz", - "integrity": "sha512-JY7V6lRkStKcKTvHO5NVSQRv+RV+FIL5pvDoLiAtSL9pKlC5x9PKQcZDsq7m4FO4d57mkhC6Z+QhAh3Jdk5JFw==", + "version": "2.14.0", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.14.0.tgz", + "integrity": "sha512-INOFj37C7k3AfaNTtX8RhsTw7qRy7eLET14cROi9+5HAVbbHuIWUHEauBv5qT4Av2tWasiTY1Jw6puUNqRJXQg==", + "optional": true + }, + "napi-build-utils": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/napi-build-utils/-/napi-build-utils-1.0.1.tgz", + "integrity": "sha512-boQj1WFgQH3v4clhu3mTNfP+vOBxorDlE8EKiMjUlLG3C4qAESnn9AxIOkFgTR2c9LtzNjPrjS60cT27ZKBhaA==", "optional": true }, "napi-thread-safe-callback": { @@ -1712,30 +1272,24 @@ "integrity": "sha512-X7uHCOCdY4u0yamDxDrv3jF2NtYc8A1nvPzBQgvpoSX+WB3jAe2cVNsY448V1ucq7Whf9Wdy02HEUoLW5rJKWg==" }, "needle": { - "version": "2.2.4", - "resolved": "https://registry.npmjs.org/needle/-/needle-2.2.4.tgz", - "integrity": "sha512-HyoqEb4wr/rsoaIDfTH2aVL9nWtQqba2/HvMv+++m8u0dz808MaagKILxtfeSN7QU7nvbQ79zk3vYOJp9zsNEA==", + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/needle/-/needle-2.4.0.tgz", + "integrity": "sha512-4Hnwzr3mi5L97hMYeNl8wRW/Onhy4nUKR/lVemJ8gJedxxUyBLm9kkrDColJvoSfwi0jCNhD+xCdOtiGDQiRZg==", "optional": true, "requires": { - "debug": "^2.1.2", + "debug": "^3.2.6", "iconv-lite": "^0.4.4", "sax": "^1.2.4" }, "dependencies": { "debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "version": "3.2.6", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz", + "integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==", "optional": true, "requires": { - "ms": "2.0.0" + "ms": "^2.1.1" } - }, - "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", - "optional": true } } }, @@ -1746,22 +1300,31 @@ "dev": true }, "nise": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/nise/-/nise-1.5.0.tgz", - "integrity": "sha512-Z3sfYEkLFzFmL8KY6xnSJLRxwQwYBjOXi/24lb62ZnZiGA0JUzGGTI6TBIgfCSMIDl9Jlu8SRmHNACLTemDHww==", + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/nise/-/nise-1.5.2.tgz", + "integrity": "sha512-/6RhOUlicRCbE9s+94qCUsyE+pKlVJ5AhIv+jEE7ESKwnbXqulKZ1FYU+XAtHHWE9TinYvAxDUJAb912PwPoWA==", "dev": true, "requires": { - "@sinonjs/formatio": "^3.1.0", + "@sinonjs/formatio": "^3.2.1", "@sinonjs/text-encoding": "^0.7.1", "just-extend": "^4.0.2", "lolex": "^4.1.0", "path-to-regexp": "^1.7.0" } }, + "node-abi": { + "version": "2.11.0", + "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-2.11.0.tgz", + "integrity": "sha512-kuy/aEg75u40v378WRllQ4ZexaXJiCvB68D2scDXclp/I4cRq6togpbOoKhmN07tns9Zldu51NNERo0wehfX9g==", + "optional": true, + "requires": { + "semver": "^5.4.1" + } + }, "node-addon-api": { - "version": "1.6.3", - "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-1.6.3.tgz", - "integrity": "sha512-FXWH6mqjWgU8ewuahp4spec8LkroFZK2NicOv6bNwZC3kcwZUI8LeZdG80UzTSLLhK4T7MsgNwlYDVRlDdfTDg==" + "version": "1.7.1", + "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-1.7.1.tgz", + "integrity": "sha512-2+DuKodWvwRTrCfKOeR24KIc5unKjOh8mz17NCzVnHWfjAdDqbfbjqh7gUT+BkXBRQM52+xCHciKWonJ3CbJMQ==" }, "node-environment-flags": { "version": "1.0.5", @@ -1771,14 +1334,6 @@ "requires": { "object.getownpropertydescriptors": "^2.0.3", "semver": "^5.7.0" - }, - "dependencies": { - "semver": { - "version": "5.7.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.0.tgz", - "integrity": "sha512-Ya52jSX2u7QKghxeoFGpLwCtGlt7j0oY9DYb5apt9nPlJ42ID+ulTXESnt/qAQcoSERyZ5sl3LDIOw0nAn/5DA==", - "dev": true - } } }, "node-gyp": { @@ -1817,6 +1372,30 @@ } } }, + "node-pre-gyp": { + "version": "0.13.0", + "resolved": "https://registry.npmjs.org/node-pre-gyp/-/node-pre-gyp-0.13.0.tgz", + "integrity": "sha512-Md1D3xnEne8b/HGVQkZZwV27WUi1ZRuZBij24TNaZwUPU3ZAFtvT6xxJGaUVillfmMKnn5oD1HoGsp2Ftik7SQ==", + "optional": true, + "requires": { + "detect-libc": "^1.0.2", + "mkdirp": "^0.5.1", + "needle": "^2.2.1", + "nopt": "^4.0.1", + "npm-packlist": "^1.1.6", + "npmlog": "^4.0.2", + "rc": "^1.2.7", + "rimraf": "^2.6.1", + "semver": "^5.3.0", + "tar": "^4" + } + }, + "noop-logger": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/noop-logger/-/noop-logger-0.1.1.tgz", + "integrity": "sha1-lKKxYzxPExdVMAfYlm/Q6EG2pMI=", + "optional": true + }, "nopt": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/nopt/-/nopt-4.0.1.tgz", @@ -1828,15 +1407,15 @@ } }, "npm-bundled": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/npm-bundled/-/npm-bundled-1.0.5.tgz", - "integrity": "sha512-m/e6jgWu8/v5niCUKQi9qQl8QdeEduFA96xHDDzFGqly0OOjI7c+60KM/2sppfnUU9JJagf+zs+yGhqSOFj71g==", + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/npm-bundled/-/npm-bundled-1.0.6.tgz", + "integrity": "sha512-8/JCaftHwbd//k6y2rEWp6k1wxVfpFzB6t1p825+cUb7Ym2XQfhwIC5KwhrvzZRJu+LtDE585zVaS32+CGtf0g==", "optional": true }, "npm-packlist": { - "version": "1.1.12", - "resolved": "https://registry.npmjs.org/npm-packlist/-/npm-packlist-1.1.12.tgz", - "integrity": "sha512-WJKFOVMeAlsU/pjXuqVdzU0WfgtIBCupkEVwn+1Y0ERAbUfWw8R4GjgVbaKnUjRoD2FoQbHOCbOyT5Mbs9Lw4g==", + "version": "1.4.4", + "resolved": "https://registry.npmjs.org/npm-packlist/-/npm-packlist-1.4.4.tgz", + "integrity": "sha512-zTLo8UcVYtDU3gdeaFu2Xu0n0EvelfHDGuqtNIn5RO7yQj4H1TqNdBc/yZjxnWA0PVB8D3Woyp0i5B43JwQ6Vw==", "optional": true, "requires": { "ignore-walk": "^3.0.1", @@ -1879,6 +1458,12 @@ "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=" }, + "object-inspect": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.6.0.tgz", + "integrity": "sha512-GJzfBZ6DgDAmnuaM3104jR4s1Myxr3Y3zfIyN4z3UdqN69oSRacNK8UhnobDdC+7J2AHCjGwxQubNJfE70SXXQ==", + "dev": true + }, "object-keys": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", @@ -1917,7 +1502,7 @@ }, "os-homedir": { "version": "1.0.2", - "resolved": "http://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz", + "resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz", "integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=", "optional": true }, @@ -1934,7 +1519,7 @@ }, "os-tmpdir": { "version": "1.0.2", - "resolved": "http://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", + "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=", "optional": true }, @@ -1967,9 +1552,9 @@ "dev": true }, "p-limit": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.2.0.tgz", - "integrity": "sha512-pZbTJpoUsCzV48Mc9Nh51VbwO0X9cuPFE8gYwx9BTCt9SF8/b7Zljd2fVgOxhIF/HDTKgpVzs+GPhyKfjLLFRQ==", + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.2.1.tgz", + "integrity": "sha512-85Tk+90UCVWvbDavCLKPOLC9vvY8OwEX/RtKF+/1OADJMVlFfEHOiMTPVyxg7mk/dKa+ipdHm0OUkTvCpMTuwg==", "dev": true, "requires": { "p-try": "^2.0.0" @@ -1998,7 +1583,7 @@ }, "path-is-absolute": { "version": "1.0.1", - "resolved": "http://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" }, "path-key": { @@ -2030,22 +1615,52 @@ "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=", "dev": true }, + "prebuild-install": { + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/prebuild-install/-/prebuild-install-5.3.2.tgz", + "integrity": "sha512-INDfXzTPnhT+WYQemqnAXlP7SvfiFMopMozSgXCZ+RDLb279gKfIuLk4o7PgEawLp3WrMgIYGBpkxpraROHsSA==", + "optional": true, + "requires": { + "detect-libc": "^1.0.3", + "expand-template": "^2.0.3", + "github-from-package": "0.0.0", + "minimist": "^1.2.0", + "mkdirp": "^0.5.1", + "napi-build-utils": "^1.0.1", + "node-abi": "^2.7.0", + "noop-logger": "^0.1.1", + "npmlog": "^4.0.1", + "pump": "^3.0.0", + "rc": "^1.2.7", + "simple-get": "^3.0.3", + "tar-fs": "^2.0.0", + "tunnel-agent": "^0.6.0", + "which-pm-runs": "^1.0.0" + }, + "dependencies": { + "minimist": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", + "optional": true + } + } + }, "process-nextick-args": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", - "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==" + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", + "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==" }, "psl": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/psl/-/psl-1.2.0.tgz", - "integrity": "sha512-GEn74ZffufCmkDDLNcl3uuyF/aSD6exEyh1v/ZSdAomB82t6G9hzJVRx0jBmLDW+VfZqks3aScmMw9DszwUalA==", + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/psl/-/psl-1.4.0.tgz", + "integrity": "sha512-HZzqCGPecFLyoRj5HLfuDSKYTJkAfB5thKBIkRHtGjWwY7p1dAyveIbXIq4tO0KYfDF2tHqPUgY9SDnGm00uFw==", "dev": true }, "pump": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz", "integrity": "sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==", - "dev": true, "requires": { "end-of-stream": "^1.1.0", "once": "^1.3.1" @@ -2077,7 +1692,7 @@ "dependencies": { "minimist": { "version": "1.2.0", - "resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", "optional": true } @@ -2085,7 +1700,7 @@ }, "readable-stream": { "version": "2.3.6", - "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", "requires": { "core-util-is": "~1.0.0", @@ -2138,11 +1753,11 @@ "dev": true }, "rimraf": { - "version": "2.6.2", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", - "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", + "version": "2.7.1", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz", + "integrity": "sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==", "requires": { - "glob": "^7.0.5" + "glob": "^7.1.3" } }, "safe-buffer": { @@ -2162,9 +1777,9 @@ "optional": true }, "semver": { - "version": "5.6.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.6.0.tgz", - "integrity": "sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg==" + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==" }, "set-blocking": { "version": "2.0.0", @@ -2241,9 +1856,9 @@ } }, "should-util": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/should-util/-/should-util-1.0.0.tgz", - "integrity": "sha1-yYzaN0qmsZDfi6h8mInCtNtiAGM=", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/should-util/-/should-util-1.0.1.tgz", + "integrity": "sha512-oXF8tfxx5cDk8r2kYqlkUJzZpDBqVY/II2WhvU0n9Y3XYvAYRmeaf1PvvIvTgPnv4KJ+ES5M0PyDq5Jp+Ygy2g==", "dev": true }, "signal-exit": { @@ -2251,18 +1866,35 @@ "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=" }, + "simple-concat": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/simple-concat/-/simple-concat-1.0.0.tgz", + "integrity": "sha1-c0TLuLbib7J9ZrL8hvn21Zl1IcY=", + "optional": true + }, + "simple-get": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/simple-get/-/simple-get-3.1.0.tgz", + "integrity": "sha512-bCR6cP+aTdScaQCnQKbPKtJOKDp/hj9EDLJo3Nw4y1QksqaovlW/bnptB6/c1e+qmNIDHRK+oXFDdEqBT8WzUA==", + "optional": true, + "requires": { + "decompress-response": "^4.2.0", + "once": "^1.3.1", + "simple-concat": "^1.0.0" + } + }, "sinon": { - "version": "7.3.2", - "resolved": "https://registry.npmjs.org/sinon/-/sinon-7.3.2.tgz", - "integrity": "sha512-thErC1z64BeyGiPvF8aoSg0LEnptSaWE7YhdWWbWXgelOyThent7uKOnnEh9zBxDbKixtr5dEko+ws1sZMuFMA==", + "version": "7.4.2", + "resolved": "https://registry.npmjs.org/sinon/-/sinon-7.4.2.tgz", + "integrity": "sha512-pY5RY99DKelU3pjNxcWo6XqeB1S118GBcVIIdDi6V+h6hevn1izcg2xv1hTHW/sViRXU7sUOxt4wTUJ3gsW2CQ==", "dev": true, "requires": { "@sinonjs/commons": "^1.4.0", "@sinonjs/formatio": "^3.2.1", - "@sinonjs/samsam": "^3.3.1", + "@sinonjs/samsam": "^3.3.3", "diff": "^3.5.0", - "lolex": "^4.0.1", - "nise": "^1.4.10", + "lolex": "^4.2.0", + "nise": "^1.5.2", "supports-color": "^5.5.0" }, "dependencies": { @@ -2302,7 +1934,7 @@ }, "string-width": { "version": "1.0.2", - "resolved": "http://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", "requires": { "code-point-at": "^1.0.0", @@ -2310,9 +1942,29 @@ "strip-ansi": "^3.0.0" } }, + "string.prototype.trimleft": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/string.prototype.trimleft/-/string.prototype.trimleft-2.1.0.tgz", + "integrity": "sha512-FJ6b7EgdKxxbDxc79cOlok6Afd++TTs5szo+zJTUyow3ycrRfJVE2pq3vcN53XexvKZu/DJMDfeI/qMiZTrjTw==", + "dev": true, + "requires": { + "define-properties": "^1.1.3", + "function-bind": "^1.1.1" + } + }, + "string.prototype.trimright": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/string.prototype.trimright/-/string.prototype.trimright-2.1.0.tgz", + "integrity": "sha512-fXZTSV55dNBwv16uw+hh5jkghxSnc5oHq+5K/gXgizHwAvMetdAJlHqqoFC1FSDVPYWLkAKl2cxpUT41sV7nSg==", + "dev": true, + "requires": { + "define-properties": "^1.1.3", + "function-bind": "^1.1.1" + } + }, "string_decoder": { "version": "1.1.1", - "resolved": "http://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", "requires": { "safe-buffer": "~5.1.0" @@ -2320,7 +1972,7 @@ }, "strip-ansi": { "version": "3.0.1", - "resolved": "http://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "requires": { "ansi-regex": "^2.0.0" @@ -2347,17 +1999,55 @@ } }, "tar": { - "version": "4.4.8", - "resolved": "https://registry.npmjs.org/tar/-/tar-4.4.8.tgz", - "integrity": "sha512-LzHF64s5chPQQS0IYBn9IN5h3i98c12bo4NCO7e0sGM2llXQ3p2FGC5sdENN4cTW48O915Sh+x+EXx7XW96xYQ==", + "version": "4.4.11", + "resolved": "https://registry.npmjs.org/tar/-/tar-4.4.11.tgz", + "integrity": "sha512-iI4zh3ktLJKaDNZKZc+fUONiQrSn9HkCFzamtb7k8FFmVilHVob7QsLX/VySAW8lAviMzMbFw4QtFb4errwgYA==", "requires": { "chownr": "^1.1.1", "fs-minipass": "^1.2.5", - "minipass": "^2.3.4", - "minizlib": "^1.1.1", + "minipass": "^2.6.4", + "minizlib": "^1.2.1", "mkdirp": "^0.5.0", "safe-buffer": "^5.1.2", - "yallist": "^3.0.2" + "yallist": "^3.0.3" + } + }, + "tar-fs": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-2.0.0.tgz", + "integrity": "sha512-vaY0obB6Om/fso8a8vakQBzwholQ7v5+uy+tF3Ozvxv1KNezmVQAiWtcNmMHFSFPqL3dJA8ha6gdtFbfX9mcxA==", + "optional": true, + "requires": { + "chownr": "^1.1.1", + "mkdirp": "^0.5.1", + "pump": "^3.0.0", + "tar-stream": "^2.0.0" + } + }, + "tar-stream": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-2.1.0.tgz", + "integrity": "sha512-+DAn4Nb4+gz6WZigRzKEZl1QuJVOLtAwwF+WUxy1fJ6X63CaGaUAxJRD2KEn1OMfcbCjySTYpNC6WmfQoIEOdw==", + "optional": true, + "requires": { + "bl": "^3.0.0", + "end-of-stream": "^1.4.1", + "fs-constants": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^3.1.1" + }, + "dependencies": { + "readable-stream": { + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.4.0.tgz", + "integrity": "sha512-jItXPLmrSR8jmTRmRWJXCnGJsfy85mB3Wd/uINMXA65yrnFo0cPClFIUWzo2najVNSl+mx7/4W8ttlLWJe99pQ==", + "optional": true, + "requires": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + } + } } }, "tough-cookie": { @@ -2382,7 +2072,6 @@ "version": "0.6.0", "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=", - "dev": true, "requires": { "safe-buffer": "^5.0.1" } @@ -2409,32 +2098,21 @@ } }, "usb": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/usb/-/usb-1.5.0.tgz", - "integrity": "sha512-/0stiQEmweuO2BKv2avzQQ8ypDUjo4Osz5sSEi+d0F4Rc+ddX1xED3uf4Tkelc1eADlfn0JQZYHP0bI7CNDA0Q==", + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/usb/-/usb-1.6.0.tgz", + "integrity": "sha512-52DyWlCk9K+iw3LnvY95WXSnpHjxJoI++aGkV8HiMNPc4zmvDQlYvWAzrkbJ2JH3oUcx26XfU5sZcG4RAcVkMg==", "optional": true, "requires": { - "nan": "^2.8.0", - "node-pre-gyp": "^0.11.0" + "bindings": "^1.4.0", + "nan": "2.13.2", + "prebuild-install": "^5.2.4" }, "dependencies": { - "node-pre-gyp": { - "version": "0.11.0", - "resolved": "https://registry.npmjs.org/node-pre-gyp/-/node-pre-gyp-0.11.0.tgz", - "integrity": "sha512-TwWAOZb0j7e9eGaf9esRx3ZcLaE5tQ2lvYy1pb5IAaG1a2e2Kv5Lms1Y4hpj+ciXJRofIxxlt5haeQ/2ANeE0Q==", - "optional": true, - "requires": { - "detect-libc": "^1.0.2", - "mkdirp": "^0.5.1", - "needle": "^2.2.1", - "nopt": "^4.0.1", - "npm-packlist": "^1.1.6", - "npmlog": "^4.0.2", - "rc": "^1.2.7", - "rimraf": "^2.6.1", - "semver": "^5.3.0", - "tar": "^4" - } + "nan": { + "version": "2.13.2", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.13.2.tgz", + "integrity": "sha512-TghvYc72wlMGMVMluVo9WRJc0mB8KxxF/gZ4YYFy7V2ZQX9l7rgbPg7vjS9mt6U5HXODVFVI2bOduCzwOMv/lw==", + "optional": true } } }, @@ -2444,9 +2122,9 @@ "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" }, "uuid": { - "version": "3.3.2", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz", - "integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==", + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.3.tgz", + "integrity": "sha512-pW0No1RGHgzlpHJO1nsVrHKpOEIxkGg1xB+v0ZmdNH5OAeAwzAVrCnI2/6Mtx+Uys6iaylxa+D3g4j63IKKjSQ==", "dev": true }, "verror": { @@ -2475,6 +2153,12 @@ "integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=", "dev": true }, + "which-pm-runs": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/which-pm-runs/-/which-pm-runs-1.0.0.tgz", + "integrity": "sha1-Zws6+8VS4LVd9rd4DKdGFfI60cs=", + "optional": true + }, "wide-align": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.3.tgz", @@ -2499,12 +2183,12 @@ "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" }, "ws": { - "version": "6.2.1", - "resolved": "https://registry.npmjs.org/ws/-/ws-6.2.1.tgz", - "integrity": "sha512-GIyAXC2cB7LjvpgMt9EKS2ldqr0MTrORaleiOno6TweZ6r3TKtoFQWay/2PceJ3RuBasOHzXNn5Lrw1X0bEjqA==", + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.1.2.tgz", + "integrity": "sha512-gftXq3XI81cJCgkUiAVixA0raD9IVmXqsylCrjRygw4+UOOGzPoxnQ6r/CnVL9i+mDncJo94tSkyrtuuQVBmrg==", "dev": true, "requires": { - "async-limiter": "~1.0.0" + "async-limiter": "^1.0.0" } }, "y18n": { diff --git a/package.json b/package.json index 94738cb32..17b500d7f 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "license": "MIT", "name": "@abandonware/noble", "description": "A Node.js BLE (Bluetooth Low Energy) central library.", - "version": "1.9.2-3", + "version": "1.9.2-4", "repository": { "type": "git", "url": "https://github.com/abandonware/noble.git" @@ -33,21 +33,21 @@ "win32" ], "dependencies": { - "debug": "^4.1.0", + "debug": "^4.1.1", "napi-thread-safe-callback": "0.0.6", "node-addon-api": "^1.1.0" }, "optionalDependencies": { - "@abandonware/bluetooth-hci-socket": "^0.5.3-1" + "@abandonware/bluetooth-hci-socket": "^0.5.3-3" }, "devDependencies": { "async": "^3.1.0", "jshint": "latest", - "mocha": "^6.1.3", + "mocha": "^6.2.0", "node-gyp": "^5.0.3", "should": "~13.2.3", - "sinon": "~7.3.1", - "ws": "^6.1.2" + "sinon": "~7.4.2", + "ws": "^7.1.2" }, "scripts": { "pretest": "jshint *.js lib/. test/.", From f67d807d380c43f87c3adb9a71e7a7c2ecb10251 Mon Sep 17 00:00:00 2001 From: RzR Date: Thu, 19 Sep 2019 04:47:27 +0200 Subject: [PATCH 046/114] 1.9.2-5 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 46a915d44..86474d636 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@abandonware/noble", - "version": "1.9.2-4", + "version": "1.9.2-5", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 17b500d7f..5a040ade3 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "license": "MIT", "name": "@abandonware/noble", "description": "A Node.js BLE (Bluetooth Low Energy) central library.", - "version": "1.9.2-4", + "version": "1.9.2-5", "repository": { "type": "git", "url": "https://github.com/abandonware/noble.git" From c24800552fd34085cac31ae4b6ce8be0ff454a6a Mon Sep 17 00:00:00 2001 From: Rob Moran Date: Tue, 5 Nov 2019 20:53:23 +0000 Subject: [PATCH 047/114] Add types from DefinitelyTyped --- index.d.ts | 130 +++++++++++++++++++++++++++++++++++++++++++++++++++ package.json | 1 + 2 files changed, 131 insertions(+) create mode 100644 index.d.ts diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 000000000..acaa39f13 --- /dev/null +++ b/index.d.ts @@ -0,0 +1,130 @@ +// Type definitions for noble +// Project: https://github.com/sandeepmistry/noble +// Definitions by: Seon-Wook Park +// Shantanu Bhadoria +// Luke Libraro +// Dan Chao +// Michal Lower +// Rob Moran +// Clayton Kucera +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +import events = require("events"); + +export declare function startScanning(callback?: (error?: Error) => void): void; +export declare function startScanning(serviceUUIDs: string[], callback?: (error?: Error) => void): void; +export declare function startScanning(serviceUUIDs: string[], allowDuplicates: boolean, callback?: (error?: Error) => void): void; +export declare function stopScanning(callback?: () => void): void; + +export declare function on(event: "stateChange", listener: (state: string) => void): events.EventEmitter; +export declare function on(event: "scanStart", listener: () => void): events.EventEmitter; +export declare function on(event: "scanStop", listener: () => void): events.EventEmitter; +export declare function on(event: "discover", listener: (peripheral: Peripheral) => void): events.EventEmitter; +export declare function on(event: string, listener: Function): events.EventEmitter; + +export declare function removeListener(event: "stateChange", listener: (state: string) => void): events.EventEmitter; +export declare function removeListener(event: "scanStart", listener: () => void): events.EventEmitter; +export declare function removeListener(event: "scanStop", listener: () => void): events.EventEmitter; +export declare function removeListener(event: "discover", listener: (peripheral: Peripheral) => void): events.EventEmitter; +export declare function removeListener(event: string, listener: Function): events.EventEmitter; + +export declare function removeAllListeners(event?: string): events.EventEmitter; + +export declare var state: string; + +export declare class Peripheral extends events.EventEmitter { + id: string; + uuid: string; + address: string; + addressType: string; + connectable: boolean; + advertisement: Advertisement; + rssi: number; + services: Service[]; + state: 'error' | 'connecting' | 'connected' | 'disconnecting' | 'disconnected'; + + connect(callback?: (error: string) => void): void; + disconnect(callback?: () => void): void; + updateRssi(callback?: (error: string, rssi: number) => void): void; + discoverServices(serviceUUIDs: string[], callback?: (error: string, services: Service[]) => void): void; + discoverAllServicesAndCharacteristics(callback?: (error: string, services: Service[], characteristics: Characteristic[]) => void): void; + discoverSomeServicesAndCharacteristics(serviceUUIDs: string[], characteristicUUIDs: string[], callback?: (error: string, services: Service[], characteristics: Characteristic[]) => void): void; + + readHandle(handle: Buffer, callback: (error: string, data: Buffer) => void): void; + writeHandle(handle: Buffer, data: Buffer, withoutResponse: boolean, callback: (error: string) => void): void; + toString(): string; + + on(event: "connect", listener: (error: string) => void): this; + on(event: "disconnect", listener: (error: string) => void): this; + on(event: "rssiUpdate", listener: (rssi: number) => void): this; + on(event: "servicesDiscover", listener: (services: Service[]) => void): this; + on(event: string, listener: Function): this; +} + +export interface Advertisement { + localName: string; + serviceData: Array<{ + uuid: string, + data: Buffer + }>; + txPowerLevel: number; + manufacturerData: Buffer; + serviceUuids: string[]; +} + +export declare class Service extends events.EventEmitter { + uuid: string; + name: string; + type: string; + includedServiceUuids: string[]; + characteristics: Characteristic[]; + + discoverIncludedServices(serviceUUIDs: string[], callback?: (error: string, includedServiceUuids: string[]) => void): void; + discoverCharacteristics(characteristicUUIDs: string[], callback?: (error: string, characteristics: Characteristic[]) => void): void; + toString(): string; + + on(event: "includedServicesDiscover", listener: (includedServiceUuids: string[]) => void): this; + on(event: "characteristicsDiscover", listener: (characteristics: Characteristic[]) => void): this; + on(event: string, listener: Function): this; +} + +export declare class Characteristic extends events.EventEmitter { + uuid: string; + name: string; + type: string; + properties: string[]; + descriptors: Descriptor[]; + + read(callback?: (error: string, data: Buffer) => void): void; + write(data: Buffer, notify: boolean, callback?: (error: string) => void): void; + broadcast(broadcast: boolean, callback?: (error: string) => void): void; + notify(notify: boolean, callback?: (error: string) => void): void; + discoverDescriptors(callback?: (error: string, descriptors: Descriptor[]) => void): void; + toString(): string; + subscribe(callback?: (error: string) => void): void; + unsubscribe(callback?: (error: string) => void): void; + + on(event: "read", listener: (data: Buffer, isNotification: boolean) => void): this; + on(event: "write", withoutResponse: boolean, listener: (error: string) => void): this; + on(event: "broadcast", listener: (state: string) => void): this; + on(event: "notify", listener: (state: string) => void): this; + on(event: "descriptorsDiscover", listener: (descriptors: Descriptor[]) => void): this; + on(event: string, listener: Function): this; + on(event: string, option: boolean, listener: Function): this; +} + +export declare class Descriptor extends events.EventEmitter { + uuid: string; + name: string; + type: string; + + readValue(callback?: (error: string, data: Buffer) => void): void; + writeValue(data: Buffer, callback?: (error: string) => void): void; + toString(): string; + + on(event: "valueRead", listener: (error: string, data: Buffer) => void): this; + on(event: "valueWrite", listener: (error: string) => void): this; + on(event: string, listener: Function): this; +} diff --git a/package.json b/package.json index 5a040ade3..b13e226fc 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,7 @@ "central" ], "main": "./index.js", + "types": "./index.d.ts", "engines": { "node": ">=6" }, From a7a33e1f8c2f71eefca4a782225e501b2e3358ca Mon Sep 17 00:00:00 2001 From: Michael Stegeman Date: Thu, 16 Jan 2020 23:04:27 -0900 Subject: [PATCH 048/114] Switch from Travis CI to GitHub actions. --- .github/workflows/nodepackage.yml | 48 +++++++++++++++++++++++++++++++ .travis.yml | 29 ------------------- 2 files changed, 48 insertions(+), 29 deletions(-) create mode 100644 .github/workflows/nodepackage.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/nodepackage.yml b/.github/workflows/nodepackage.yml new file mode 100644 index 000000000..8932c86fd --- /dev/null +++ b/.github/workflows/nodepackage.yml @@ -0,0 +1,48 @@ +name: Node.js package + +on: + pull_request: + branches: + - master + push: + branches: + - master + +jobs: + build: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ + ubuntu-latest, + macos-latest, + ] + node: [ + 6, + 8, + 10, + 12, + ] + steps: + - uses: actions/checkout@v1 + - uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node }} + - name: Install dependencies + run: | + if [ ${{ matrix.os }} = ubuntu-latest ]; then + sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test + sudo apt -qq update + sudo apt install -y g++-4.8 + fi + - name: Run integration tests + run: | + if [ ${{ matrix.os }} = macos-latest -a ${{ matrix.node }} = 6 ]; then + # Mac bindings will currently not build on Node 6 + exit 0 + fi + if [ ${{ matrix.os }} = ubuntu-latest ]; then + export CC="g++-4.8" + fi + npm install + npm test diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index a668f9c3c..000000000 --- a/.travis.yml +++ /dev/null @@ -1,29 +0,0 @@ -os: - - linux - - osx -language: cpp -env: - - NODE_VERSION="6" - - NODE_VERSION="8" - - NODE_VERSION="10" - - NODE_VERSION="12" -matrix: - fast_finish: true -before_install: - - git clone https://github.com/creationix/nvm.git /tmp/.nvm; - - source /tmp/.nvm/nvm.sh; - - nvm install $NODE_VERSION; - - nvm use --delete-prefix $NODE_VERSION; - - if [ $TRAVIS_OS_NAME == "linux" ]; then - export CC="g++-4.8"; - fi -install: - - npm install -script: - - npm test -addons: - apt: - sources: - - ubuntu-toolchain-r-test - packages: - - g++-4.8 From 57f4bbced40b1571c9688eef03f452b6b17a253e Mon Sep 17 00:00:00 2001 From: Simon Vogl Date: Tue, 17 Dec 2019 08:57:27 +0100 Subject: [PATCH 049/114] add try/catch around region affected by buffer overflow if eirLength fields are corrupted. This happens on some firmwares that send out multiple advertisements but do not fix the length fields (which eventually causes kernel panics as well). Change-Id: Ia88ca5a3ae583afa06ffdd11cefc86938163a36e Relate-to: https://github.com/abandonware/noble/pull/28 --- lib/hci-socket/hci.js | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/lib/hci-socket/hci.js b/lib/hci-socket/hci.js index aac52dba4..0e1c5a1a0 100644 --- a/lib/hci-socket/hci.js +++ b/lib/hci-socket/hci.js @@ -662,23 +662,27 @@ Hci.prototype.processLeConnComplete = function(status, data) { }; Hci.prototype.processLeAdvertisingReport = function(count, data) { - for (var i = 0; i < count; i++) { - var type = data.readUInt8(0); - var addressType = data.readUInt8(1) === 0x01 ? 'random' : 'public'; - var address = data.slice(2, 8).toString('hex').match(/.{1,2}/g).reverse().join(':'); - var eirLength = data.readUInt8(8); - var eir = data.slice(9, eirLength + 9); - var rssi = data.readInt8(eirLength + 9); - - debug('\t\t\ttype = ' + type); - debug('\t\t\taddress = ' + address); - debug('\t\t\taddress type = ' + addressType); - debug('\t\t\teir = ' + eir.toString('hex')); - debug('\t\t\trssi = ' + rssi); - - this.emit('leAdvertisingReport', 0, type, address, addressType, eir, rssi); - - data = data.slice(eirLength + 10); + try { + for (var i = 0; i < count; i++) { + var type = data.readUInt8(0); + var addressType = data.readUInt8(1) === 0x01 ? 'random' : 'public'; + var address = data.slice(2, 8).toString('hex').match(/.{1,2}/g).reverse().join(':'); + var eirLength = data.readUInt8(8); + var eir = data.slice(9, eirLength + 9); + var rssi = data.readInt8(eirLength + 9); + + debug('\t\t\ttype = ' + type); + debug('\t\t\taddress = ' + address); + debug('\t\t\taddress type = ' + addressType); + debug('\t\t\teir = ' + eir.toString('hex')); + debug('\t\t\trssi = ' + rssi); + + this.emit('leAdvertisingReport', 0, type, address, addressType, eir, rssi); + + data = data.slice(eirLength + 10); + } + } catch (e) { + console.warn('processLeAdvertisingReport: Caught illegal packet (buffer overflow): ' + e); } }; From 26c809b6308f928d55872c42649c4ae6205ed7c4 Mon Sep 17 00:00:00 2001 From: Simon Vogl Date: Tue, 17 Dec 2019 08:48:11 +0100 Subject: [PATCH 050/114] added events for service and characteristics discovery (serviceDiscovered, characteristicsDiscovered) that enables caching of gatt information. The cached objects can be used to initialize a device via addServices() and addCharacteristics(), which return an array of Noble objects ready for connecting in the usual way. examples/cache-gatt-discovery.js provides an example for collecting GATT data and persisting the information, examples/cache-gatt-reconnect.js uses the data to connect to the device using the cached data. Author: Simon Vogl Relate-to: https://github.com/abandonware/noble/pull/29 Change-Id: I68bc5208529f872e5f60d7c0315a6346d24df2fb --- examples/cache-gatt-discovery.js | 162 +++++++++++++++++++++++++++++++ examples/cache-gatt-reconnect.js | 146 ++++++++++++++++++++++++++++ lib/hci-socket/bindings.js | 35 +++++++ lib/hci-socket/gatt.js | 21 ++++ lib/noble.js | 81 ++++++++++++++++ 5 files changed, 445 insertions(+) create mode 100644 examples/cache-gatt-discovery.js create mode 100644 examples/cache-gatt-reconnect.js diff --git a/examples/cache-gatt-discovery.js b/examples/cache-gatt-discovery.js new file mode 100644 index 000000000..72a300b17 --- /dev/null +++ b/examples/cache-gatt-discovery.js @@ -0,0 +1,162 @@ +/** discover a device (here, the first one where the name was resolved), + * for the first device discover all services and characteristics, + * store the collected GATT information into a meta-data object and write to disk. + * Finds a temperature characteristic and registers for data. + * Prints timing information from discovered to connected to reading states. + */ + +var noble = require('../index'); +const fs = require('fs'); + +// the sensor value to scan for, number of bits and factor for displaying it +const CHANNEL = process.env['CHANNEL'] ? process.env['CHANNEL'] : 'Temperature' +const BITS = process.env['BITS'] ? 1 * process.env['BITS'] : 16 +const FACTOR = process.env['FACTOR'] ? 1. * process.env['FACTOR'] : .1 + +const EXT='.dump' + +noble.on('stateChange', function(state) { + if (state === 'poweredOn') { + noble.startScanning(); + } else { + noble.stopScanning(); + } +}); + +let tDisco=0; // time when device was discovered +let tConn =0; // time when connection to device was established +let tRead =0; // time when reading data starts. + +// collect device meta-data into this object: +let meta = { + services: [], // stores an array of GATT service data objects + characteristics: {} // a map with key service-UUID, stores the array of characteristics +} + +noble.on('discover', function(peripheral) { + console.log('peripheral discovered (' + peripheral.id + + ' with address <' + peripheral.address + ', ' + peripheral.addressType + '>,' + + ' connectable ' + peripheral.connectable + ',' + + ' RSSI ' + peripheral.rssi + ':'); + console.log('\thello my local name is:'); + console.log('\t\t' + peripheral.advertisement.localName); + console.log(); + + // connect to the first device with a valid name + if (peripheral.advertisement.localName) { + console.log('Connecting to ' + peripheral.address + ' ' + peripheral.advertisement.localName) + + tDisco = Date.now() + + connectToDevice(peripheral) + } +}); + +let connectToDevice = function (peripheral) { + // BLE cannot scan and connect in parallel, so we stop scanning here: + noble.stopScanning() + + peripheral.connect((error) => { + // noble.startScanning([], true) + if (error) { + console.log('Connect error: ' + error) + noble.startScanning([], true) + return + } + tConn = Date.now() + console.log('Connected!') + + findServices(noble, peripheral) + }) +} + + +let servicesToRead = 0; + +let findServices = function (noble, peripheral) { + meta.uuid = peripheral.uuid + meta.address = peripheral.address + meta.name = peripheral.advertisement.localName // not needed but nice to have + + meta.characteristics = {} + + // callback triggers with GATT-relevant data + peripheral.on('servicesDiscovered', (peripheral, services) => { + + console.log('servicesDiscovered: Found '+ services.length + ' services! ') + meta.services = services + for (let i in services) { + const service = services[i] + console.log('\tservice ' + i + ' : ' + JSON.stringify(service)) + //meta.services[ service.uuid ] = service + } + }) + + peripheral.discoverServices([], (error, services) => { + + let sensorCharacteristic + + servicesToRead = services.length + // we found the list of services, now trigger characteristics lookup for each of them: + + for (let i = 0; i < services.length; i++) { + let service = services[i] + + service.on('characteristicsDiscovered', (characteristics) => { + // store the list of characteristics per service + meta.characteristics[service.uuid] = characteristics + + console.log('SRV\t' + service.uuid + ' characteristic GATT data: ') + for (let i = 0; i < characteristics.length; i++) { + console.log('\t' + service.uuid + ' chara.\t ' + ' ' + i + ' ' + JSON.stringify(characteristics[i])) + } + }) + + service.discoverCharacteristics([], function (error, characteristics) { + console.log('SRV\t' + service.uuid + ' characteristic decoded data: ' ) + for (let j = 0; j< characteristics.length; j++) { + let ch = characteristics[j] + console.log('\t' + service.uuid + ' chara.\t ' + ' ' + j + ' ' + ch) + + if ( ch.name === CHANNEL) { + console.log('found ' + CHANNEL + ' characteristic!') + sensorCharacteristic = ch + } + } + + servicesToRead-- + if (!servicesToRead) { + console.log('----------------- FINISHED') + console.log(JSON.stringify(meta, null, 4)) + // write to file + fs.writeFile(meta.uuid + EXT, JSON.stringify(meta,null,2), function(err) { + if(err) { + return console.log(err); + } + console.log("The data was saved to " , meta.uuid + EXT); + }); + + if (sensorCharacteristic) { + console.log('Listening for temperature data...') + + tRead = Date.now() + + sensorCharacteristic.on('data', (data) => { + if (BITS === 16 ) { + console.log(' new ' + CHANNEL + ' ' + (data.readUInt16LE() * FACTOR) ) + } else if (BITS === 32) { + console.log(' new ' + CHANNEL + ' ' + (data.readUInt32LE() * FACTOR) ) + } else { + console.log(' Cannot cope with BITS value '+ BITS) + } + }) + sensorCharacteristic.read() + } + + console.log('Timespan from discovery to connected: ' + (tConn -tDisco) + ' ms') + console.log('Timespan from connected to reading : ' + (tRead -tConn) + ' ms') + } + }) + } + }) +} diff --git a/examples/cache-gatt-reconnect.js b/examples/cache-gatt-reconnect.js new file mode 100644 index 000000000..7ca8d0736 --- /dev/null +++ b/examples/cache-gatt-reconnect.js @@ -0,0 +1,146 @@ +/** reconnect to a device that has been discovered earlier on using cache-gatt-discovery: + * If a device is discovered and a dump file exists, load it and connect to it, re-initializing service + * and characteristic objects in the noble stack. + * Finds a temperature characteristic and registers for data. + * Prints timing information from discovered to connected to reading states. + */ + +var noble = require('../index'); +const fs = require('fs'); + +// the sensor value to scan for, number of bits and factor for displaying it +const CHANNEL = process.env['CHANNEL'] ? process.env['CHANNEL'] : 'Temperature' +const BITS = process.env['BITS'] ? 1 * process.env['BITS'] : 16 +const FACTOR = process.env['FACTOR'] ? 1. * process.env['FACTOR'] : .1 + +const EXT='.dump' + +noble.on('stateChange', function(state) { + if (state === 'poweredOn') { + noble.startScanning(); + } else { + noble.stopScanning(); + } +}); + +let tDisco=0; // time when device was discovered +let tConn =0; // time when connection to device was established +let tRead =0; // time when reading data starts. + +// collect device meta-data into this object: +let meta = { + services: {}, // a map indexted by service-UUID -> contains service data + characteristics: {} // an map with key service-UUID, stores the array of characteristics +} + +noble.on('discover', function(peripheral) { + console.log('peripheral discovered (' + peripheral.id + + ' with address <' + peripheral.address + ', ' + peripheral.addressType + '>,' + + ' connectable ' + peripheral.connectable + ',' + + ' RSSI ' + peripheral.rssi + ':'); + console.log('\thello my local name is:'); + console.log('\t\t' + peripheral.advertisement.localName); + console.log(); + + + // Check if a dump exists in the current directory. + fs.access(peripheral.uuid + EXT, fs.constants.F_OK, (err) => { + if (!err) { + console.log('found dump file for ' + peripheral.uuid ) + + tDisco=Date.now() + + quickConnect(peripheral) + } + }); +}); + + +let quickConnect = function (peripheral) { + // BLE cannot scan and connect in parallel, so we stop scanning here: + noble.stopScanning() + + + peripheral.connect((error) => { + if (error) { + console.log('Connect error: ' + error) + noble.startScanning([], true) + return + } + tConn = Date.now() + console.log('Connected!') + + // load stored data. This needs to be done when connected, as we need a handle at GATT level + meta = loadData(peripheral) + + // initialize the service and charateristics objects in Noble; return a temperature characteristic, if found + let sensorCharacteristic = setData(peripheral, meta) + + if (!sensorCharacteristic) { + console.log('Warning - no temperature characteristic found.') + } else { + console.log('Listening for temperature data...') + + tRead = Date.now() + + sensorCharacteristic.on('data', (data) => { + if (BITS === 16 ) { + console.log(' new ' + CHANNEL + ' ' + (data.readUInt16LE() * FACTOR) ) + } else if (BITS === 32) { + console.log(' new ' + CHANNEL + ' ' + (data.readUInt32LE() * FACTOR) ) + } else { + console.log(' Cannot cope with BITS value '+ BITS) + } + }) + sensorCharacteristic.read() + + console.log('Timespan from discovery to connected: ' + (tConn -tDisco) + ' ms') + console.log('Timespan from connected to reading : ' + (tRead -tConn) + ' ms') + } + }) +} + +let loadData = function(peripheral) { + const dump = fs.readFileSync(peripheral.uuid + EXT) + const data = JSON.parse(dump) + + // verify data: console.log(JSON.stringify(data,null,2)) + return data +} + +let setData = function(peripheral, meta) { + // first, create the service objects: + console.log('initializing services... ') + + // addServices returns an array of initialized service objects + let services = noble.addServices(peripheral.uuid, meta.services) + + console.log('initialized services: ') + for (let i in services) { + const service = services[i] + console.log('\tservice ' + i + ' ' + service) + } + console.log() + + let sensorCharacteristic + + console.log('initializing characteristics... ') + // now, for each service, set the characteristics: + for (let i in services) { + const service = services[i] + const charas = meta.characteristics[service.uuid] + console.log('\tservice ' + i + ' ' + service + ' ' + JSON.stringify(charas)) + + let characteristics = noble.addCharacteristics(peripheral.uuid, service.uuid, charas) + + for (let j in characteristics) { + let characteristic = characteristics[j] + console.log('\t\tcharac ' + service.uuid + ' ' + j + ' ' + characteristic + ' ' + characteristic.rawProps) + if (characteristic.name === CHANNEL) { + console.log('\t\t\t-->found ' + CHANNEL + ' characteristic!') + sensorCharacteristic = characteristic + } + } + } + return sensorCharacteristic +} diff --git a/lib/hci-socket/bindings.js b/lib/hci-socket/bindings.js index fde079cc7..b3daa33be 100644 --- a/lib/hci-socket/bindings.js +++ b/lib/hci-socket/bindings.js @@ -210,8 +210,10 @@ NobleBindings.prototype.onLeConnComplete = function(status, handle, role, addres this._gatts[handle].on('mtu', this.onMtu.bind(this)); this._gatts[handle].on('servicesDiscover', this.onServicesDiscovered.bind(this)); + this._gatts[handle].on('servicesDiscovered', this.onServicesDiscoveredEX.bind(this)); this._gatts[handle].on('includedServicesDiscover', this.onIncludedServicesDiscovered.bind(this)); this._gatts[handle].on('characteristicsDiscover', this.onCharacteristicsDiscovered.bind(this)); + this._gatts[handle].on('characteristicsDiscovered', this.onCharacteristicsDiscoveredEX.bind(this)); this._gatts[handle].on('read', this.onRead.bind(this)); this._gatts[handle].on('write', this.onWrite.bind(this)); this._gatts[handle].on('broadcast', this.onBroadcast.bind(this)); @@ -303,6 +305,16 @@ NobleBindings.prototype.onAclDataPkt = function(handle, cid, data) { } }; +NobleBindings.prototype.addService = function(peripheralUuid, service) { + var handle = this._handles[peripheralUuid]; + var gatt = this._gatts[handle]; + + if (gatt) { + gatt.addService(service); + } else { + console.warn('noble warning: unknown peripheral ' + peripheralUuid); + } +}; NobleBindings.prototype.discoverServices = function(peripheralUuid, uuids) { var handle = this._handles[peripheralUuid]; @@ -321,6 +333,12 @@ NobleBindings.prototype.onServicesDiscovered = function(address, serviceUuids) { this.emit('servicesDiscover', uuid, serviceUuids); }; +NobleBindings.prototype.onServicesDiscoveredEX = function(address, services) { + var uuid = address.split(':').join('').toLowerCase(); + + this.emit('servicesDiscovered', uuid, services); +}; + NobleBindings.prototype.discoverIncludedServices = function(peripheralUuid, serviceUuid, serviceUuids) { var handle = this._handles[peripheralUuid]; var gatt = this._gatts[handle]; @@ -338,6 +356,17 @@ NobleBindings.prototype.onIncludedServicesDiscovered = function(address, service this.emit('includedServicesDiscover', uuid, serviceUuid, includedServiceUuids); }; +NobleBindings.prototype.addCharacteristics = function(peripheralUuid, serviceUuid, characteristics) { + var handle = this._handles[peripheralUuid]; + var gatt = this._gatts[handle]; + + if (gatt) { + gatt.addCharacteristics(serviceUuid, characteristics); + } else { + console.warn('noble warning: unknown peripheral ' + peripheralUuid); + } +}; + NobleBindings.prototype.discoverCharacteristics = function(peripheralUuid, serviceUuid, characteristicUuids) { var handle = this._handles[peripheralUuid]; var gatt = this._gatts[handle]; @@ -355,6 +384,12 @@ NobleBindings.prototype.onCharacteristicsDiscovered = function(address, serviceU this.emit('characteristicsDiscover', uuid, serviceUuid, characteristics); }; +NobleBindings.prototype.onCharacteristicsDiscoveredEX = function(address, serviceUuid, characteristics) { + var uuid = address.split(':').join('').toLowerCase(); + + this.emit('characteristicsDiscovered', uuid, serviceUuid, characteristics); +}; + NobleBindings.prototype.read = function(peripheralUuid, serviceUuid, characteristicUuid) { var handle = this._handles[peripheralUuid]; var gatt = this._gatts[handle]; diff --git a/lib/hci-socket/gatt.js b/lib/hci-socket/gatt.js index 17338d208..fcaaa9ec0 100644 --- a/lib/hci-socket/gatt.js +++ b/lib/hci-socket/gatt.js @@ -329,6 +329,10 @@ Gatt.prototype.exchangeMtu = function(mtu) { }.bind(this)); }; +Gatt.prototype.addService = function(service) { + this._services[service.uuid] = service; +}; + Gatt.prototype.discoverServices = function(uuids) { var services = []; @@ -358,6 +362,7 @@ Gatt.prototype.discoverServices = function(uuids) { this._services[services[i].uuid] = services[i]; } + this.emit('servicesDiscovered', this._address, JSON.parse(JSON.stringify(services)) /*services*/); this.emit('servicesDiscover', this._address, serviceUuids); } else { this._queueCommand(this.readByGroupRequest(services[services.length - 1].endHandle + 1, 0xffff, GATT_PRIM_SVC_UUID), callback); @@ -406,6 +411,17 @@ Gatt.prototype.discoverIncludedServices = function(serviceUuid, uuids) { this._queueCommand(this.readByTypeRequest(service.startHandle, service.endHandle, GATT_INCLUDE_UUID), callback); }; +Gatt.prototype.addCharacteristics = function (serviceUuid, characteristics) { + var service = this._services[serviceUuid]; + this._characteristics[serviceUuid] = this._characteristics[serviceUuid] || {}; + this._descriptors[serviceUuid] = this._descriptors[serviceUuid] || {}; + + + for (i = 0; i < characteristics.length; i++) { + this._characteristics[serviceUuid][characteristics[i].uuid] = characteristics[i]; + } +}; + Gatt.prototype.discoverCharacteristics = function(serviceUuid, characteristicUuids) { var service = this._services[serviceUuid]; var characteristics = []; @@ -442,6 +458,10 @@ Gatt.prototype.discoverCharacteristics = function(serviceUuid, characteristicUui uuid: characteristics[i].uuid }; + // work around name-clash of numeric vs. string-array properties field: + characteristics[i].propsDecoded = characteristic.properties; + characteristics[i].rawProps = properties; + if (i !== 0) { characteristics[i - 1].endHandle = characteristics[i].startHandle - 1; } @@ -489,6 +509,7 @@ Gatt.prototype.discoverCharacteristics = function(serviceUuid, characteristicUui } } + this.emit('characteristicsDiscovered', this._address, serviceUuid, characteristics); this.emit('characteristicsDiscover', this._address, serviceUuid, characteristicsDiscovered); } else { this._queueCommand(this.readByTypeRequest(characteristics[characteristics.length - 1].valueHandle + 1, service.endHandle, GATT_CHARAC_UUID), callback); diff --git a/lib/noble.js b/lib/noble.js index bb668a329..69e482eb1 100644 --- a/lib/noble.js +++ b/lib/noble.js @@ -30,8 +30,10 @@ function Noble(bindings) { this._bindings.on('disconnect', this.onDisconnect.bind(this)); this._bindings.on('rssiUpdate', this.onRssiUpdate.bind(this)); this._bindings.on('servicesDiscover', this.onServicesDiscover.bind(this)); + this._bindings.on('servicesDiscovered', this.onServicesDiscovered.bind(this)); this._bindings.on('includedServicesDiscover', this.onIncludedServicesDiscover.bind(this)); this._bindings.on('characteristicsDiscover', this.onCharacteristicsDiscover.bind(this)); + this._bindings.on('characteristicsDiscovered', this.onCharacteristicsDiscovered.bind(this)); this._bindings.on('read', this.onRead.bind(this)); this._bindings.on('write', this.onWrite.bind(this)); this._bindings.on('broadcast', this.onBroadcast.bind(this)); @@ -242,6 +244,47 @@ Noble.prototype.onRssiUpdate = function(peripheralUuid, rssi) { } }; +/// add an array of service objects (as retrieved via the servicesDiscovered event) +Noble.prototype.addServices = function (peripheralUuid, services) { + var servObjs = []; + + for (var i = 0; i < services.length; i++) { + var o = this.addService(peripheralUuid, services[i]); + servObjs.push(o); + } + return servObjs; +}; + +/// service is a ServiceObject { uuid, startHandle, endHandle,..} +Noble.prototype.addService = function (peripheralUuid, service) { + var peripheral = this._peripherals[peripheralUuid]; + + // pass on to lower layers (gatt) + this._bindings.addService(peripheralUuid, service); + + if (!peripheral.services) { + peripheral.services = []; + } + // allocate internal service object and return + var serv = new Service(this, peripheralUuid, service.uuid); + + this._services[peripheralUuid][service.uuid] = serv; + this._characteristics[peripheralUuid][service.uuid] = {}; + this._descriptors[peripheralUuid][service.uuid] = {}; + + peripheral.services.push(serv); + + return serv; +}; + +/// callback receiving a list of service objects from the gatt layer +Noble.prototype.onServicesDiscovered = function (peripheralUuid, services) { + var peripheral = this._peripherals[peripheralUuid]; + + if (peripheral) + peripheral.emit('servicesDiscovered', peripheral, services); // pass on to higher layers +}; + Noble.prototype.discoverServices = function(peripheralUuid, uuids) { this._bindings.discoverServices(peripheralUuid, uuids); }; @@ -287,6 +330,44 @@ Noble.prototype.onIncludedServicesDiscover = function(peripheralUuid, serviceUui } }; +/// add characteristics to the peripheral; returns an array of initialized Characteristics objects +Noble.prototype.addCharacteristics = function (peripheralUuid, serviceUuid, characteristics) { + // first, initialize gatt layer: + this._bindings.addCharacteristics(peripheralUuid, serviceUuid, characteristics); + + var service = this._services[peripheralUuid][serviceUuid]; + if (!service) { + this.emit('warning', 'unknown service ' + peripheralUuid + ', ' + serviceUuid + ' characteristics discover!'); + return; + } + + var characteristics_ = []; + for (var i = 0; i < characteristics.length; i++) { + var characteristicUuid = characteristics[i].uuid; + + var characteristic = new Characteristic( + this, + peripheralUuid, + serviceUuid, + characteristicUuid, + characteristics[i].properties + ); + + this._characteristics[peripheralUuid][serviceUuid][characteristicUuid] = characteristic; + this._descriptors[peripheralUuid][serviceUuid][characteristicUuid] = {}; + + characteristics_.push(characteristic); + } + service.characteristics = characteristics_; + return characteristics_; +}; + +Noble.prototype.onCharacteristicsDiscovered = function (peripheralUuid, serviceUuid, characteristics) { + var service = this._services[peripheralUuid][serviceUuid]; + + service.emit('characteristicsDiscovered', characteristics); +}; + Noble.prototype.discoverCharacteristics = function(peripheralUuid, serviceUuid, characteristicUuids) { this._bindings.discoverCharacteristics(peripheralUuid, serviceUuid, characteristicUuids); }; From e2a1905a2efb3b1c8082a0301de5d74c4e803a9e Mon Sep 17 00:00:00 2001 From: Michel Wohlert Date: Wed, 12 Feb 2020 03:46:46 -0800 Subject: [PATCH 051/114] Added MTU value to peripheral on successful handshake Authored by: EricDobyns --- README.md | 3 ++- lib/hci-socket/bindings.js | 2 ++ lib/noble.js | 6 ++++++ lib/peripheral.js | 2 ++ test/test-peripheral.js | 2 +- 5 files changed, 13 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 27d038165..06b4d3e3a 100644 --- a/README.md +++ b/README.md @@ -320,7 +320,8 @@ peripheral = { ... ] }, - rssi: + rssi: , + mtu: // MTU will be null, until device is connected and hci-socket is used }; noble.on('discover', callback(peripheral)); diff --git a/lib/hci-socket/bindings.js b/lib/hci-socket/bindings.js index b3daa33be..e9af56672 100644 --- a/lib/hci-socket/bindings.js +++ b/lib/hci-socket/bindings.js @@ -289,7 +289,9 @@ NobleBindings.prototype.onEncryptChange = function(handle, encrypt) { }; NobleBindings.prototype.onMtu = function(address, mtu) { + var uuid = address.split(':').join('').toLowerCase(); + this.emit('onMtu', uuid, mtu); }; NobleBindings.prototype.onRssiRead = function(handle, rssi) { diff --git a/lib/noble.js b/lib/noble.js index 69e482eb1..277f0b38c 100644 --- a/lib/noble.js +++ b/lib/noble.js @@ -44,6 +44,7 @@ function Noble(bindings) { this._bindings.on('handleRead', this.onHandleRead.bind(this)); this._bindings.on('handleWrite', this.onHandleWrite.bind(this)); this._bindings.on('handleNotify', this.onHandleNotify.bind(this)); + this._bindings.on('onMtu', this.onMtu.bind(this)); this.on('warning', function(message) { if (this.listeners('warning').length === 1) { @@ -561,4 +562,9 @@ Noble.prototype.onHandleNotify = function(peripheralUuid, handle, data) { } }; +Noble.prototype.onMtu = function(peripheralUuid, mtu) { + var peripheral = this._peripherals[peripheralUuid]; + peripheral.mtu = mtu; +}; + module.exports = Noble; diff --git a/lib/peripheral.js b/lib/peripheral.js index a22661aa8..91b28a6f3 100644 --- a/lib/peripheral.js +++ b/lib/peripheral.js @@ -15,6 +15,7 @@ function Peripheral(noble, id, address, addressType, connectable, advertisement, this.advertisement = advertisement; this.rssi = rssi; this.services = null; + this.mtu = null; this.state = 'disconnected'; } @@ -28,6 +29,7 @@ Peripheral.prototype.toString = function() { connectable: this.connectable, advertisement: this.advertisement, rssi: this.rssi, + mtu: this.mtu, state: this.state }); }; diff --git a/test/test-peripheral.js b/test/test-peripheral.js index 23cd79685..86aa14e0c 100644 --- a/test/test-peripheral.js +++ b/test/test-peripheral.js @@ -59,7 +59,7 @@ describe('Peripheral', function() { describe('toString', function() { it('should be id, address, address type, connectable, advertisement, rssi, state', function() { - peripheral.toString().should.equal('{"id":"mock-id","address":"mock-address","addressType":"mock-address-type","connectable":"mock-connectable","advertisement":"mock-advertisement","rssi":"mock-rssi","state":"disconnected"}'); + peripheral.toString().should.equal('{"id":"mock-id","address":"mock-address","addressType":"mock-address-type","connectable":"mock-connectable","advertisement":"mock-advertisement","rssi":"mock-rssi","mtu":null,"state":"disconnected"}'); }); }); From 47e04262377a2249bdcf1e4f2badfa6531e4859c Mon Sep 17 00:00:00 2001 From: Aarni Koskela Date: Sat, 25 Jan 2020 13:24:25 +0200 Subject: [PATCH 052/114] Replace JSHint with Eslint --- .eslintrc.js | 19 + .jshintrc | 10 - examples/cache-gatt-discovery.js | 50 +- package-lock.json | 834 +++++++++++++++++++++++++------ package.json | 6 +- 5 files changed, 732 insertions(+), 187 deletions(-) create mode 100644 .eslintrc.js delete mode 100644 .jshintrc diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 000000000..14b57ee3a --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,19 @@ +module.exports = { + root: true, + extends: ["eslint:recommended"], + parserOptions: { + ecmaVersion: 2017 + }, + env: { + browser: true, + mocha: true, + node: true + }, + globals: { + Promise: true + }, + rules: { + "no-unused-vars": 0, + "no-undef": 0 + } +}; diff --git a/.jshintrc b/.jshintrc deleted file mode 100644 index 821afef4e..000000000 --- a/.jshintrc +++ /dev/null @@ -1,10 +0,0 @@ -{ - "browser": true, - "node": true, - "mocha": true, - "unused": false, //enable after cleanup - "undef": false, //enable after cleanup - "globals": { - "Promise": true - } -} diff --git a/examples/cache-gatt-discovery.js b/examples/cache-gatt-discovery.js index 72a300b17..750bf6b51 100644 --- a/examples/cache-gatt-discovery.js +++ b/examples/cache-gatt-discovery.js @@ -103,7 +103,7 @@ let findServices = function (noble, peripheral) { let service = services[i] service.on('characteristicsDiscovered', (characteristics) => { - // store the list of characteristics per service + // store the list of characteristics per service meta.characteristics[service.uuid] = characteristics console.log('SRV\t' + service.uuid + ' characteristic GATT data: ') @@ -118,30 +118,30 @@ let findServices = function (noble, peripheral) { let ch = characteristics[j] console.log('\t' + service.uuid + ' chara.\t ' + ' ' + j + ' ' + ch) - if ( ch.name === CHANNEL) { - console.log('found ' + CHANNEL + ' characteristic!') - sensorCharacteristic = ch - } + if ( ch.name === CHANNEL) { + console.log('found ' + CHANNEL + ' characteristic!') + sensorCharacteristic = ch + } } - servicesToRead-- - if (!servicesToRead) { - console.log('----------------- FINISHED') - console.log(JSON.stringify(meta, null, 4)) - // write to file - fs.writeFile(meta.uuid + EXT, JSON.stringify(meta,null,2), function(err) { - if(err) { + servicesToRead-- + if (!servicesToRead) { + console.log('----------------- FINISHED') + console.log(JSON.stringify(meta, null, 4)) + // write to file + fs.writeFile(meta.uuid + EXT, JSON.stringify(meta,null,2), function(err) { + if(err) { return console.log(err); - } - console.log("The data was saved to " , meta.uuid + EXT); - }); + } + console.log("The data was saved to " , meta.uuid + EXT); + }); - if (sensorCharacteristic) { - console.log('Listening for temperature data...') + if (sensorCharacteristic) { + console.log('Listening for temperature data...') - tRead = Date.now() + tRead = Date.now() - sensorCharacteristic.on('data', (data) => { + sensorCharacteristic.on('data', (data) => { if (BITS === 16 ) { console.log(' new ' + CHANNEL + ' ' + (data.readUInt16LE() * FACTOR) ) } else if (BITS === 32) { @@ -149,13 +149,13 @@ let findServices = function (noble, peripheral) { } else { console.log(' Cannot cope with BITS value '+ BITS) } - }) - sensorCharacteristic.read() - } + }) + sensorCharacteristic.read() + } - console.log('Timespan from discovery to connected: ' + (tConn -tDisco) + ' ms') - console.log('Timespan from connected to reading : ' + (tRead -tConn) + ' ms') - } + console.log('Timespan from discovery to connected: ' + (tConn -tDisco) + ' ms') + console.log('Timespan from connected to reading : ' + (tRead -tConn) + ' ms') + } }) } }) diff --git a/package-lock.json b/package-lock.json index 86474d636..c17ea30a2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,6 +16,26 @@ "usb": "^1.6.0" } }, + "@babel/code-frame": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.8.3.tgz", + "integrity": "sha512-a9gxpmdXtZEInkCSHUJDLHZVBgb1QS0jhss4cPP93EW7s+uC5bikET2twEF3KV+7rDblJcmNvTR7VJejqd2C2g==", + "dev": true, + "requires": { + "@babel/highlight": "^7.8.3" + } + }, + "@babel/highlight": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.8.3.tgz", + "integrity": "sha512-PX4y5xQUvy0fnEVHrYOarRPXVWafSjTW9T0Hab8gVIawpl2Sj0ORyrygANq+KjcNlSSTw0YCLSNA8OyZ1I4yEg==", + "dev": true, + "requires": { + "chalk": "^2.0.0", + "esutils": "^2.0.2", + "js-tokens": "^4.0.0" + } + }, "@sinonjs/commons": { "version": "1.6.0", "resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-1.6.0.tgz", @@ -57,6 +77,18 @@ "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==" }, + "acorn": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.1.0.tgz", + "integrity": "sha512-kL5CuoXA/dgxlBbVrflsflzQ3PAas7RYZB52NOm/6839iVYJgKMJ3cQJD+t2i5+qFa8h3MDpEOJiS64E8JLnSQ==", + "dev": true + }, + "acorn-jsx": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.1.0.tgz", + "integrity": "sha512-tMUqwBWfLFbJbizRmEcWSLw6HnFzfdJs2sOJEOwwtVPMoH/0Ay+E703oZz78VSXZiiDcZrQ5XKjPIUQixhmgVw==", + "dev": true + }, "ajv": { "version": "6.10.2", "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.10.2.tgz", @@ -75,6 +107,15 @@ "integrity": "sha512-LEHHyuhlPY3TmuUYMh2oz89lTShfvgbmzaBcxve9t/9Wuy7Dwf4yoAKcND7KFT1HAQfqZ12qtc+DUrBMeKF9nw==", "dev": true }, + "ansi-escapes": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-4.3.0.tgz", + "integrity": "sha512-EiYhwo0v255HUL6eDyuLrXEkTi7WwVCLAw+SeOQ7M7qdun1z1pum4DEm/nuqIVbPvi9RPPc9k9LbyBv6H0DwVg==", + "dev": true, + "requires": { + "type-fest": "^0.8.1" + } + }, "ansi-regex": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", @@ -133,6 +174,12 @@ "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=", "dev": true }, + "astral-regex": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/astral-regex/-/astral-regex-1.0.0.tgz", + "integrity": "sha512-+Ryf6g3BKoRc7jfp7ad8tM4TtMiaWvbF/1/sQcZPkkS7ag3D5nMBCe2UfOTONtAkaG0tO0ij3C5Lwmf1EiyjHg==", + "dev": true + }, "async": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/async/-/async-3.1.0.tgz", @@ -223,6 +270,12 @@ "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", "dev": true }, + "callsites": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", + "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", + "dev": true + }, "camelcase": { "version": "5.3.1", "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", @@ -257,21 +310,32 @@ } } }, + "chardet": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/chardet/-/chardet-0.7.0.tgz", + "integrity": "sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==", + "dev": true + }, "chownr": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.2.tgz", "integrity": "sha512-GkfeAQh+QNy3wquu9oIZr6SS5x7wGdSgNQvD10X3r+AZr1Oys22HW8kAmDMvNg2+Dm0TeGaEuO8gFwdBXxwO8A==" }, - "cli": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/cli/-/cli-1.0.1.tgz", - "integrity": "sha1-IoF1NPJL+klQw01TLUjsvGIbjBQ=", + "cli-cursor": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-3.1.0.tgz", + "integrity": "sha512-I/zHAwsKf9FqGoXM4WWRACob9+SNukZTd94DWF57E4toouRulbCxcUh6RKUEOQlYTHJnzkPMySvPNaaSLNfLZw==", "dev": true, "requires": { - "exit": "0.1.2", - "glob": "^7.1.1" + "restore-cursor": "^3.1.0" } }, + "cli-width": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-2.2.0.tgz", + "integrity": "sha1-/xnt6Kml5XkyQUewwR8PvLq+1jk=", + "dev": true + }, "cliui": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/cliui/-/cliui-4.1.0.tgz", @@ -350,15 +414,6 @@ "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" }, - "console-browserify": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/console-browserify/-/console-browserify-1.1.0.tgz", - "integrity": "sha1-8CQcRXMKn8YyOyBtvzjtx0HQuxA=", - "dev": true, - "requires": { - "date-now": "^0.1.4" - } - }, "console-control-strings": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", @@ -391,12 +446,6 @@ "assert-plus": "^1.0.0" } }, - "date-now": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/date-now/-/date-now-0.1.4.tgz", - "integrity": "sha1-6vQ5/U1ISK105cx9vvIAZyueNFs=", - "dev": true - }, "debug": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", @@ -426,6 +475,12 @@ "integrity": "sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==", "optional": true }, + "deep-is": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz", + "integrity": "sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=", + "dev": true + }, "define-properties": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz", @@ -458,53 +513,13 @@ "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==", "dev": true }, - "dom-serializer": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-0.2.1.tgz", - "integrity": "sha512-sK3ujri04WyjwQXVoK4PU3y8ula1stq10GJZpqHIUgoGZdsGzAGu65BnU3d08aTVSvO7mGPZUc0wTEDL+qGE0Q==", - "dev": true, - "requires": { - "domelementtype": "^2.0.1", - "entities": "^2.0.0" - }, - "dependencies": { - "domelementtype": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.0.1.tgz", - "integrity": "sha512-5HOHUDsYZWV8FGWN0Njbr/Rn7f/eWSQi1v7+HsUVwXgn8nWWlL64zKDkS0n8ZmQ3mlWOMuXOnR+7Nx/5tMO5AQ==", - "dev": true - }, - "entities": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/entities/-/entities-2.0.0.tgz", - "integrity": "sha512-D9f7V0JSRwIxlRI2mjMqufDrRDnx8p+eEOz7aUM9SuvF8gsBzra0/6tbjl1m8eQHrZlYj6PxqE00hZ1SAIKPLw==", - "dev": true - } - } - }, - "domelementtype": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-1.3.1.tgz", - "integrity": "sha512-BSKB+TSpMpFI/HOxCNr1O8aMOTZ8hT3pM3GQ0w/mWRmkhEDSFJkkyzz4XQsBV44BChwGkrDfMyjVD0eA2aFV3w==", - "dev": true - }, - "domhandler": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-2.3.0.tgz", - "integrity": "sha1-LeWaCCLVAn+r/28DLCsloqir5zg=", - "dev": true, - "requires": { - "domelementtype": "1" - } - }, - "domutils": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/domutils/-/domutils-1.5.1.tgz", - "integrity": "sha1-3NhIiib1Y9YQeeSMn3t+Mjc2gs8=", + "doctrine": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", + "integrity": "sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==", "dev": true, "requires": { - "dom-serializer": "0", - "domelementtype": "1" + "esutils": "^2.0.2" } }, "ecc-jsbn": { @@ -531,12 +546,6 @@ "once": "^1.4.0" } }, - "entities": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/entities/-/entities-1.0.0.tgz", - "integrity": "sha1-sph6o4ITR/zeZCsk/fyeT7cSvyY=", - "dev": true - }, "env-paths": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/env-paths/-/env-paths-1.0.0.tgz", @@ -578,12 +587,152 @@ "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", "dev": true }, + "eslint": { + "version": "6.8.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-6.8.0.tgz", + "integrity": "sha512-K+Iayyo2LtyYhDSYwz5D5QdWw0hCacNzyq1Y821Xna2xSJj7cijoLLYmLxTQgcgZ9mC61nryMy9S7GRbYpI5Ig==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.0.0", + "ajv": "^6.10.0", + "chalk": "^2.1.0", + "cross-spawn": "^6.0.5", + "debug": "^4.0.1", + "doctrine": "^3.0.0", + "eslint-scope": "^5.0.0", + "eslint-utils": "^1.4.3", + "eslint-visitor-keys": "^1.1.0", + "espree": "^6.1.2", + "esquery": "^1.0.1", + "esutils": "^2.0.2", + "file-entry-cache": "^5.0.1", + "functional-red-black-tree": "^1.0.1", + "glob-parent": "^5.0.0", + "globals": "^12.1.0", + "ignore": "^4.0.6", + "import-fresh": "^3.0.0", + "imurmurhash": "^0.1.4", + "inquirer": "^7.0.0", + "is-glob": "^4.0.0", + "js-yaml": "^3.13.1", + "json-stable-stringify-without-jsonify": "^1.0.1", + "levn": "^0.3.0", + "lodash": "^4.17.14", + "minimatch": "^3.0.4", + "mkdirp": "^0.5.1", + "natural-compare": "^1.4.0", + "optionator": "^0.8.3", + "progress": "^2.0.0", + "regexpp": "^2.0.1", + "semver": "^6.1.2", + "strip-ansi": "^5.2.0", + "strip-json-comments": "^3.0.1", + "table": "^5.2.3", + "text-table": "^0.2.0", + "v8-compile-cache": "^2.0.3" + }, + "dependencies": { + "ansi-regex": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", + "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", + "dev": true + }, + "semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "dev": true + }, + "strip-ansi": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", + "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", + "dev": true, + "requires": { + "ansi-regex": "^4.1.0" + } + }, + "strip-json-comments": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.0.1.tgz", + "integrity": "sha512-VTyMAUfdm047mwKl+u79WIdrZxtFtn+nBxHeb844XBQ9uMNTuTHdx2hc5RiAJYqwTj3wc/xe5HLSdJSkJ+WfZw==", + "dev": true + } + } + }, + "eslint-scope": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.0.0.tgz", + "integrity": "sha512-oYrhJW7S0bxAFDvWqzvMPRm6pcgcnWc4QnofCAqRTRfQC0JcwenzGglTtsLyIuuWFfkqDG9vz67cnttSd53djw==", + "dev": true, + "requires": { + "esrecurse": "^4.1.0", + "estraverse": "^4.1.1" + } + }, + "eslint-utils": { + "version": "1.4.3", + "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-1.4.3.tgz", + "integrity": "sha512-fbBN5W2xdY45KulGXmLHZ3c3FHfVYmKg0IrAKGOkT/464PQsx2UeIzfz1RmEci+KLm1bBaAzZAh8+/E+XAeZ8Q==", + "dev": true, + "requires": { + "eslint-visitor-keys": "^1.1.0" + } + }, + "eslint-visitor-keys": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.1.0.tgz", + "integrity": "sha512-8y9YjtM1JBJU/A9Kc+SbaOV4y29sSWckBwMHa+FGtVj5gN/sbnKDf6xJUl+8g7FAij9LVaP8C24DUiH/f/2Z9A==", + "dev": true + }, + "espree": { + "version": "6.1.2", + "resolved": "https://registry.npmjs.org/espree/-/espree-6.1.2.tgz", + "integrity": "sha512-2iUPuuPP+yW1PZaMSDM9eyVf8D5P0Hi8h83YtZ5bPc/zHYjII5khoixIUTMO794NOY8F/ThF1Bo8ncZILarUTA==", + "dev": true, + "requires": { + "acorn": "^7.1.0", + "acorn-jsx": "^5.1.0", + "eslint-visitor-keys": "^1.1.0" + } + }, "esprima": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", "dev": true }, + "esquery": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.0.1.tgz", + "integrity": "sha512-SmiyZ5zIWH9VM+SRUReLS5Q8a7GxtRdxEBVZpm98rJM7Sb+A9DVCndXfkeFUd3byderg+EbDkfnevfCwynWaNA==", + "dev": true, + "requires": { + "estraverse": "^4.0.0" + } + }, + "esrecurse": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.2.1.tgz", + "integrity": "sha512-64RBB++fIOAXPw3P9cy89qfMlvZEXZkqqJkjqqXIvzP5ezRZjW+lPWjw35UX/3EhUPFYbg5ER4JYgDw4007/DQ==", + "dev": true, + "requires": { + "estraverse": "^4.1.0" + } + }, + "estraverse": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", + "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", + "dev": true + }, + "esutils": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", + "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", + "dev": true + }, "execa": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/execa/-/execa-1.0.0.tgz", @@ -599,12 +748,6 @@ "strip-eof": "^1.0.0" } }, - "exit": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/exit/-/exit-0.1.2.tgz", - "integrity": "sha1-BjJjj42HfMghB9MKD/8aF8uhzQw=", - "dev": true - }, "expand-template": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/expand-template/-/expand-template-2.0.3.tgz", @@ -617,6 +760,17 @@ "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==", "dev": true }, + "external-editor": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/external-editor/-/external-editor-3.1.0.tgz", + "integrity": "sha512-hMQ4CX1p1izmuLYyZqLMO/qGNw10wSv9QDCPfzXfyFrOaCSSoRfqE1Kf1s5an66J5JZC62NewG+mK49jOCtQew==", + "dev": true, + "requires": { + "chardet": "^0.7.0", + "iconv-lite": "^0.4.24", + "tmp": "^0.0.33" + } + }, "extsprintf": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz", @@ -635,6 +789,30 @@ "integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I=", "dev": true }, + "fast-levenshtein": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", + "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", + "dev": true + }, + "figures": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/figures/-/figures-3.1.0.tgz", + "integrity": "sha512-ravh8VRXqHuMvZt/d8GblBeqDMkdJMBdv/2KntFH+ra5MXkO7nxNKpzQ3n6QD/2da1kH0aWmNISdvhM7gl2gVg==", + "dev": true, + "requires": { + "escape-string-regexp": "^1.0.5" + } + }, + "file-entry-cache": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-5.0.1.tgz", + "integrity": "sha512-bCg29ictuBaKUwwArK4ouCaqDgLZcysCFLmM/Yn/FDoqndh/9vNuQfXRDvTuXKLxfD/JtZQGKFT8MGcJBK644g==", + "dev": true, + "requires": { + "flat-cache": "^2.0.1" + } + }, "file-uri-to-path": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", @@ -659,6 +837,34 @@ "is-buffer": "~2.0.3" } }, + "flat-cache": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-2.0.1.tgz", + "integrity": "sha512-LoQe6yDuUMDzQAEH8sgmh4Md6oZnc/7PjtwjNFSzveXqSHt6ka9fPBuso7IGf9Rz4uqnSnWiFH2B/zj24a5ReA==", + "dev": true, + "requires": { + "flatted": "^2.0.0", + "rimraf": "2.6.3", + "write": "1.0.3" + }, + "dependencies": { + "rimraf": { + "version": "2.6.3", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz", + "integrity": "sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==", + "dev": true, + "requires": { + "glob": "^7.1.3" + } + } + } + }, + "flatted": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/flatted/-/flatted-2.0.1.tgz", + "integrity": "sha512-a1hQMktqW9Nmqr5aktAux3JMNqaucxGcjtjWnZLHX7yyPCmlSV3M54nGYbqT8K+0GhF3NBgmJCc3ma+WOgX8Jg==", + "dev": true + }, "forever-agent": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", @@ -701,6 +907,12 @@ "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", "dev": true }, + "functional-red-black-tree": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz", + "integrity": "sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=", + "dev": true + }, "gauge": { "version": "2.7.4", "resolved": "https://registry.npmjs.org/gauge/-/gauge-2.7.4.tgz", @@ -759,6 +971,24 @@ "path-is-absolute": "^1.0.0" } }, + "glob-parent": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.0.tgz", + "integrity": "sha512-qjtRgnIVmOfnKUE3NJAQEdk+lKrxfw8t5ke7SXtfMTHcjsBfOfWXCQfdb30zfDoZQ2IRSIiidmjtbHZPZ++Ihw==", + "dev": true, + "requires": { + "is-glob": "^4.0.1" + } + }, + "globals": { + "version": "12.3.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-12.3.0.tgz", + "integrity": "sha512-wAfjdLgFsPZsklLJvOBUBmzYE8/CwhEqSBEMRXA3qxIiNtyqvjYurAtIfDh6chlEPUfmTY3MnZh5Hfh4q0UlIw==", + "dev": true, + "requires": { + "type-fest": "^0.8.1" + } + }, "graceful-fs": { "version": "4.2.2", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.2.tgz", @@ -819,45 +1049,6 @@ "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==", "dev": true }, - "htmlparser2": { - "version": "3.8.3", - "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-3.8.3.tgz", - "integrity": "sha1-mWwosZFRaovoZQGn15dX5ccMEGg=", - "dev": true, - "requires": { - "domelementtype": "1", - "domhandler": "2.3", - "domutils": "1.5", - "entities": "1.0", - "readable-stream": "1.1" - }, - "dependencies": { - "isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", - "dev": true - }, - "readable-stream": { - "version": "1.1.14", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", - "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", - "dev": true, - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.1", - "isarray": "0.0.1", - "string_decoder": "~0.10.x" - } - }, - "string_decoder": { - "version": "0.10.31", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", - "dev": true - } - } - }, "http-signature": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz", @@ -873,11 +1064,16 @@ "version": "0.4.24", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", - "optional": true, "requires": { "safer-buffer": ">= 2.1.2 < 3" } }, + "ignore": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz", + "integrity": "sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==", + "dev": true + }, "ignore-walk": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/ignore-walk/-/ignore-walk-3.0.2.tgz", @@ -887,6 +1083,22 @@ "minimatch": "^3.0.4" } }, + "import-fresh": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.2.1.tgz", + "integrity": "sha512-6e1q1cnWP2RXD9/keSkxHScg508CdXqXWgWBaETNhyuBFz+kUZlKboh+ISK+bU++DmbHimVBrOz/zzPe0sZ3sQ==", + "dev": true, + "requires": { + "parent-module": "^1.0.0", + "resolve-from": "^4.0.0" + } + }, + "imurmurhash": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", + "integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=", + "dev": true + }, "inflight": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", @@ -907,6 +1119,86 @@ "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==", "optional": true }, + "inquirer": { + "version": "7.0.4", + "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-7.0.4.tgz", + "integrity": "sha512-Bu5Td5+j11sCkqfqmUTiwv+tWisMtP0L7Q8WrqA2C/BbBhy1YTdFrvjjlrKq8oagA/tLQBski2Gcx/Sqyi2qSQ==", + "dev": true, + "requires": { + "ansi-escapes": "^4.2.1", + "chalk": "^2.4.2", + "cli-cursor": "^3.1.0", + "cli-width": "^2.0.0", + "external-editor": "^3.0.3", + "figures": "^3.0.0", + "lodash": "^4.17.15", + "mute-stream": "0.0.8", + "run-async": "^2.2.0", + "rxjs": "^6.5.3", + "string-width": "^4.1.0", + "strip-ansi": "^5.1.0", + "through": "^2.3.6" + }, + "dependencies": { + "ansi-regex": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz", + "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==", + "dev": true + }, + "emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true + }, + "is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "dev": true + }, + "string-width": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.0.tgz", + "integrity": "sha512-zUz5JD+tgqtuDjMhwIg5uFVV3dtqZ9yQJlZVfq4I01/K5Paj5UHj7VyrQOJvzawSVlKpObApbfD0Ed6yJc+1eg==", + "dev": true, + "requires": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.0" + }, + "dependencies": { + "strip-ansi": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", + "integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==", + "dev": true, + "requires": { + "ansi-regex": "^5.0.0" + } + } + } + }, + "strip-ansi": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", + "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", + "dev": true, + "requires": { + "ansi-regex": "^4.1.0" + }, + "dependencies": { + "ansi-regex": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", + "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", + "dev": true + } + } + } + } + }, "invert-kv": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/invert-kv/-/invert-kv-2.0.0.tgz", @@ -931,6 +1223,12 @@ "integrity": "sha1-mqIOtq7rv/d/vTPnTKAbM1gdOhY=", "dev": true }, + "is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", + "dev": true + }, "is-fullwidth-code-point": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", @@ -939,6 +1237,21 @@ "number-is-nan": "^1.0.0" } }, + "is-glob": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.1.tgz", + "integrity": "sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg==", + "dev": true, + "requires": { + "is-extglob": "^2.1.1" + } + }, + "is-promise": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.1.0.tgz", + "integrity": "sha1-eaKp7OfwlugPNtKy87wWwf9L8/o=", + "dev": true + }, "is-regex": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.0.4.tgz", @@ -986,6 +1299,12 @@ "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=", "dev": true }, + "js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", + "dev": true + }, "js-yaml": { "version": "3.13.1", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", @@ -1002,30 +1321,6 @@ "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=", "dev": true }, - "jshint": { - "version": "2.10.2", - "resolved": "https://registry.npmjs.org/jshint/-/jshint-2.10.2.tgz", - "integrity": "sha512-e7KZgCSXMJxznE/4WULzybCMNXNAd/bf5TSrvVEq78Q/K8ZwFpmBqQeDtNiHc3l49nV4E/+YeHU/JZjSUIrLAA==", - "dev": true, - "requires": { - "cli": "~1.0.0", - "console-browserify": "1.1.x", - "exit": "0.1.x", - "htmlparser2": "3.8.x", - "lodash": "~4.17.11", - "minimatch": "~3.0.2", - "shelljs": "0.3.x", - "strip-json-comments": "1.0.x" - }, - "dependencies": { - "strip-json-comments": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-1.0.4.tgz", - "integrity": "sha1-HhX7ysl9Pumb8tc7TGVrCCu6+5E=", - "dev": true - } - } - }, "json-schema": { "version": "0.2.3", "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz", @@ -1038,6 +1333,12 @@ "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", "dev": true }, + "json-stable-stringify-without-jsonify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", + "integrity": "sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=", + "dev": true + }, "json-stringify-safe": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", @@ -1071,6 +1372,16 @@ "invert-kv": "^2.0.0" } }, + "levn": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", + "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=", + "dev": true, + "requires": { + "prelude-ls": "~1.1.2", + "type-check": "~0.3.2" + } + }, "locate-path": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", @@ -1254,6 +1565,12 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" }, + "mute-stream": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.8.tgz", + "integrity": "sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA==", + "dev": true + }, "nan": { "version": "2.14.0", "resolved": "https://registry.npmjs.org/nan/-/nan-2.14.0.tgz", @@ -1271,6 +1588,12 @@ "resolved": "https://registry.npmjs.org/napi-thread-safe-callback/-/napi-thread-safe-callback-0.0.6.tgz", "integrity": "sha512-X7uHCOCdY4u0yamDxDrv3jF2NtYc8A1nvPzBQgvpoSX+WB3jAe2cVNsY448V1ucq7Whf9Wdy02HEUoLW5rJKWg==" }, + "natural-compare": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", + "integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=", + "dev": true + }, "needle": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/needle/-/needle-2.4.0.tgz", @@ -1500,6 +1823,29 @@ "wrappy": "1" } }, + "onetime": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.0.tgz", + "integrity": "sha512-5NcSkPHhwTVFIQN+TUqXoS5+dlElHXdpAWu9I0HP20YOtIi+aZ0Ct82jdlILDxjLEAWwvm+qj1m6aEtsDVmm6Q==", + "dev": true, + "requires": { + "mimic-fn": "^2.1.0" + } + }, + "optionator": { + "version": "0.8.3", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.3.tgz", + "integrity": "sha512-+IW9pACdk3XWmmTXG8m3upGUJst5XRGzxMRjXzAuJ1XnIFNvfhjjIuYkDvysnPQ7qzqVzLt78BCruntqRhWQbA==", + "dev": true, + "requires": { + "deep-is": "~0.1.3", + "fast-levenshtein": "~2.0.6", + "levn": "~0.3.0", + "prelude-ls": "~1.1.2", + "type-check": "~0.3.2", + "word-wrap": "~1.2.3" + } + }, "os-homedir": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz", @@ -1520,8 +1866,7 @@ "os-tmpdir": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", - "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=", - "optional": true + "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=" }, "osenv": { "version": "0.1.5", @@ -1575,6 +1920,15 @@ "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", "dev": true }, + "parent-module": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", + "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", + "dev": true, + "requires": { + "callsites": "^3.0.0" + } + }, "path-exists": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", @@ -1646,11 +2000,29 @@ } } }, + "prelude-ls": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", + "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=", + "dev": true + }, + "prettier": { + "version": "1.19.1", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-1.19.1.tgz", + "integrity": "sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew==", + "dev": true + }, "process-nextick-args": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==" }, + "progress": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz", + "integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==", + "dev": true + }, "psl": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/psl/-/psl-1.4.0.tgz", @@ -1712,6 +2084,12 @@ "util-deprecate": "~1.0.1" } }, + "regexpp": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-2.0.1.tgz", + "integrity": "sha512-lv0M6+TkDVniA3aD1Eg0DVpfU/booSu7Eev3TDO/mZKHBfVjgCGTV4t4buppESEYDtkArYFOxTJWv6S5C+iaNw==", + "dev": true + }, "request": { "version": "2.88.0", "resolved": "https://registry.npmjs.org/request/-/request-2.88.0.tgz", @@ -1752,6 +2130,22 @@ "integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==", "dev": true }, + "resolve-from": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", + "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", + "dev": true + }, + "restore-cursor": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-3.1.0.tgz", + "integrity": "sha512-l+sSefzHpj5qimhFSE5a8nufZYAM3sBSVMAPtYkmC+4EH2anSGaEMXSD0izRQbu9nfyQ9y5JrVmp7E8oZrUjvA==", + "dev": true, + "requires": { + "onetime": "^5.1.0", + "signal-exit": "^3.0.2" + } + }, "rimraf": { "version": "2.7.1", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz", @@ -1760,6 +2154,24 @@ "glob": "^7.1.3" } }, + "run-async": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/run-async/-/run-async-2.3.0.tgz", + "integrity": "sha1-A3GrSuC91yDUFm19/aZP96RFpsA=", + "dev": true, + "requires": { + "is-promise": "^2.1.0" + } + }, + "rxjs": { + "version": "6.5.4", + "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.5.4.tgz", + "integrity": "sha512-naMQXcgEo3csAEGvw/NydRA0fuS2nDZJiw1YUWFKU7aPPAPGZEsD4Iimit96qwCieH6y614MCLYwdkrWx7z/7Q==", + "dev": true, + "requires": { + "tslib": "^1.9.0" + } + }, "safe-buffer": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", @@ -1801,12 +2213,6 @@ "integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=", "dev": true }, - "shelljs": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.3.0.tgz", - "integrity": "sha1-NZbmMHp4FUT1kfN9phg2DzHbV7E=", - "dev": true - }, "should": { "version": "13.2.3", "resolved": "https://registry.npmjs.org/should/-/should-13.2.3.tgz", @@ -1909,6 +2315,25 @@ } } }, + "slice-ansi": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-2.1.0.tgz", + "integrity": "sha512-Qu+VC3EwYLldKa1fCxuuvULvSJOKEgk9pi8dZeCVK7TqBfUNTH4sFkk4joj8afVSfAYgJoSOetjx9QWOJ5mYoQ==", + "dev": true, + "requires": { + "ansi-styles": "^3.2.0", + "astral-regex": "^1.0.0", + "is-fullwidth-code-point": "^2.0.0" + }, + "dependencies": { + "is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "dev": true + } + } + }, "sprintf-js": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", @@ -1998,6 +2423,52 @@ "has-flag": "^3.0.0" } }, + "table": { + "version": "5.4.6", + "resolved": "https://registry.npmjs.org/table/-/table-5.4.6.tgz", + "integrity": "sha512-wmEc8m4fjnob4gt5riFRtTu/6+4rSe12TpAELNSqHMfF3IqnA+CH37USM6/YR3qRZv7e56kAEAtd6nKZaxe0Ug==", + "dev": true, + "requires": { + "ajv": "^6.10.2", + "lodash": "^4.17.14", + "slice-ansi": "^2.1.0", + "string-width": "^3.0.0" + }, + "dependencies": { + "ansi-regex": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", + "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", + "dev": true + }, + "is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "dev": true + }, + "string-width": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", + "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", + "dev": true, + "requires": { + "emoji-regex": "^7.0.1", + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^5.1.0" + } + }, + "strip-ansi": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", + "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", + "dev": true, + "requires": { + "ansi-regex": "^4.1.0" + } + } + } + }, "tar": { "version": "4.4.11", "resolved": "https://registry.npmjs.org/tar/-/tar-4.4.11.tgz", @@ -2050,6 +2521,27 @@ } } }, + "text-table": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", + "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=", + "dev": true + }, + "through": { + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", + "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=", + "dev": true + }, + "tmp": { + "version": "0.0.33", + "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz", + "integrity": "sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==", + "dev": true, + "requires": { + "os-tmpdir": "~1.0.2" + } + }, "tough-cookie": { "version": "2.4.3", "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.4.3.tgz", @@ -2068,6 +2560,12 @@ } } }, + "tslib": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.10.0.tgz", + "integrity": "sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==", + "dev": true + }, "tunnel-agent": { "version": "0.6.0", "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", @@ -2082,12 +2580,27 @@ "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=", "dev": true }, + "type-check": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", + "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=", + "dev": true, + "requires": { + "prelude-ls": "~1.1.2" + } + }, "type-detect": { "version": "4.0.8", "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", "dev": true }, + "type-fest": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.8.1.tgz", + "integrity": "sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA==", + "dev": true + }, "uri-js": { "version": "4.2.2", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.2.2.tgz", @@ -2127,6 +2640,12 @@ "integrity": "sha512-pW0No1RGHgzlpHJO1nsVrHKpOEIxkGg1xB+v0ZmdNH5OAeAwzAVrCnI2/6Mtx+Uys6iaylxa+D3g4j63IKKjSQ==", "dev": true }, + "v8-compile-cache": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.1.0.tgz", + "integrity": "sha512-usZBT3PW+LOjM25wbqIlZwPeJV+3OSz3M1k1Ws8snlW39dZyYL9lOGC5FgPVHfk0jKmjiDV8Z0mIbVQPiwFs7g==", + "dev": true + }, "verror": { "version": "1.10.0", "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz", @@ -2167,6 +2686,12 @@ "string-width": "^1.0.2 || 2" } }, + "word-wrap": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", + "integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==", + "dev": true + }, "wrap-ansi": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz", @@ -2182,6 +2707,15 @@ "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" }, + "write": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/write/-/write-1.0.3.tgz", + "integrity": "sha512-/lg70HAjtkUgWPVZhZcm+T4hkL8Zbtp1nFNOn3lRrxnlv50SRBv7cR7RqR+GMsd3hUXy9hWBo4CHTbFTcOYwig==", + "dev": true, + "requires": { + "mkdirp": "^0.5.1" + } + }, "ws": { "version": "7.1.2", "resolved": "https://registry.npmjs.org/ws/-/ws-7.1.2.tgz", diff --git a/package.json b/package.json index b13e226fc..fb70ee134 100644 --- a/package.json +++ b/package.json @@ -43,15 +43,17 @@ }, "devDependencies": { "async": "^3.1.0", - "jshint": "latest", + "eslint": "^6.8.0", "mocha": "^6.2.0", "node-gyp": "^5.0.3", + "prettier": "^1.19.1", "should": "~13.2.3", "sinon": "~7.4.2", "ws": "^7.1.2" }, "scripts": { - "pretest": "jshint *.js lib/. test/.", + "lint": "eslint '**/*.js'", + "pretest": "npm run lint", "test": "mocha -R spec test/*.js" }, "browser": { From bc61c30a26ed7881da07ce4d40affae412c6d78b Mon Sep 17 00:00:00 2001 From: Aarni Koskela Date: Sat, 25 Jan 2020 13:36:19 +0200 Subject: [PATCH 053/114] Get rid of unused variables --- .eslintrc.js | 7 ++++++- examples/pizza/central.js | 1 - lib/characteristic.js | 2 -- lib/descriptor.js | 2 -- lib/distributed/bindings.js | 1 - lib/hci-socket/acl-stream.js | 2 -- lib/hci-socket/bindings.js | 2 -- lib/hci-socket/gatt.js | 11 +++++------ lib/hci-socket/smp.js | 2 -- lib/peripheral.js | 3 --- lib/service.js | 2 -- lib/webbluetooth/bindings.js | 26 ++++++++------------------ lib/websocket/bindings.js | 1 - test/test-characteristic.js | 2 +- test/test-descriptor.js | 4 ++-- test/test-peripheral.js | 4 ++-- test/test-service.js | 4 ++-- ws-slave.js | 5 +---- 18 files changed, 27 insertions(+), 54 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 14b57ee3a..f3c55ec16 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -13,7 +13,12 @@ module.exports = { Promise: true }, rules: { - "no-unused-vars": 0, + "no-unused-vars": [ + "error", + { + args: "none" + } + ], "no-undef": 0 } }; diff --git a/examples/pizza/central.js b/examples/pizza/central.js index 4e4620a1e..7f75d0466 100644 --- a/examples/pizza/central.js +++ b/examples/pizza/central.js @@ -22,7 +22,6 @@ noble.on('stateChange', function(state) { } }) -var pizzaService = null; var pizzaCrustCharacteristic = null; var pizzaToppingsCharacteristic = null; var pizzaBakeCharacteristic = null; diff --git a/lib/characteristic.js b/lib/characteristic.js index 088073ee4..ed1e72fa4 100644 --- a/lib/characteristic.js +++ b/lib/characteristic.js @@ -1,5 +1,3 @@ -var debug = require('debug')('characteristic'); - var events = require('events'); var util = require('util'); diff --git a/lib/descriptor.js b/lib/descriptor.js index 3ad0248d7..434b3a67e 100644 --- a/lib/descriptor.js +++ b/lib/descriptor.js @@ -1,5 +1,3 @@ -var debug = require('debug')('descriptor'); - var events = require('events'); var util = require('util'); diff --git a/lib/distributed/bindings.js b/lib/distributed/bindings.js index ece737b6e..bcb73e45b 100644 --- a/lib/distributed/bindings.js +++ b/lib/distributed/bindings.js @@ -1,7 +1,6 @@ var events = require('events'); var util = require('util'); -var debug = require('debug')('bindings'); var WebSocketServer = require('ws').Server; var NobleBindings = function() { diff --git a/lib/hci-socket/acl-stream.js b/lib/hci-socket/acl-stream.js index b086e2ea6..6720f832f 100644 --- a/lib/hci-socket/acl-stream.js +++ b/lib/hci-socket/acl-stream.js @@ -1,5 +1,3 @@ -var debug = require('debug')('acl-att-stream'); - var events = require('events'); var util = require('util'); diff --git a/lib/hci-socket/bindings.js b/lib/hci-socket/bindings.js index e9af56672..e361b20f7 100644 --- a/lib/hci-socket/bindings.js +++ b/lib/hci-socket/bindings.js @@ -1,5 +1,3 @@ -var debug = require('debug')('bindings'); - var events = require('events'); var util = require('util'); diff --git a/lib/hci-socket/gatt.js b/lib/hci-socket/gatt.js index fcaaa9ec0..9697c3da0 100644 --- a/lib/hci-socket/gatt.js +++ b/lib/hci-socket/gatt.js @@ -3,6 +3,7 @@ var debug = require('debug')('att'); var events = require('events'); var util = require('util'); +/* eslint-disable no-unused-vars */ var ATT_OP_ERROR = 0x01; var ATT_OP_MTU_REQ = 0x02; var ATT_OP_MTU_RESP = 0x03; @@ -54,6 +55,7 @@ var GATT_CLIENT_CHARAC_CFG_UUID = 0x2902; var GATT_SERVER_CHARAC_CFG_UUID = 0x2903; var ATT_CID = 0x0004; +/* eslint-enable no-unused-vars */ var Gatt = function(address, aclStream) { this._address = address; @@ -332,7 +334,7 @@ Gatt.prototype.exchangeMtu = function(mtu) { Gatt.prototype.addService = function(service) { this._services[service.uuid] = service; }; - + Gatt.prototype.discoverServices = function(uuids) { var services = []; @@ -412,7 +414,6 @@ Gatt.prototype.discoverIncludedServices = function(serviceUuid, uuids) { }; Gatt.prototype.addCharacteristics = function (serviceUuid, characteristics) { - var service = this._services[serviceUuid]; this._characteristics[serviceUuid] = this._characteristics[serviceUuid] || {}; this._descriptors[serviceUuid] = this._descriptors[serviceUuid] || {}; @@ -421,7 +422,7 @@ Gatt.prototype.addCharacteristics = function (serviceUuid, characteristics) { this._characteristics[serviceUuid][characteristics[i].uuid] = characteristics[i]; } }; - + Gatt.prototype.discoverCharacteristics = function(serviceUuid, characteristicUuids) { var service = this._services[serviceUuid]; var characteristics = []; @@ -461,7 +462,7 @@ Gatt.prototype.discoverCharacteristics = function(serviceUuid, characteristicUui // work around name-clash of numeric vs. string-array properties field: characteristics[i].propsDecoded = characteristic.properties; characteristics[i].rawProps = properties; - + if (i !== 0) { characteristics[i - 1].endHandle = characteristics[i].startHandle - 1; } @@ -611,7 +612,6 @@ Gatt.prototype.broadcast = function(serviceUuid, characteristicUuid, broadcast) this._queueCommand(this.readByTypeRequest(characteristic.startHandle, characteristic.endHandle, GATT_SERVER_CHARAC_CFG_UUID), function(data) { var opcode = data[0]; if (opcode === ATT_OP_READ_BY_TYPE_RESP) { - var type = data[1]; var handle = data.readUInt16LE(2); var value = data.readUInt16LE(4); @@ -641,7 +641,6 @@ Gatt.prototype.notify = function(serviceUuid, characteristicUuid, notify) { this._queueCommand(this.readByTypeRequest(characteristic.startHandle, characteristic.endHandle, GATT_CLIENT_CHARAC_CFG_UUID), function(data) { var opcode = data[0]; if (opcode === ATT_OP_READ_BY_TYPE_RESP) { - var type = data[1]; var handle = data.readUInt16LE(2); var value = data.readUInt16LE(4); diff --git a/lib/hci-socket/smp.js b/lib/hci-socket/smp.js index 5628d9bd8..8eb8b76c5 100644 --- a/lib/hci-socket/smp.js +++ b/lib/hci-socket/smp.js @@ -1,5 +1,3 @@ -var debug = require('debug')('smp'); - var events = require('events'); var util = require('util'); diff --git a/lib/peripheral.js b/lib/peripheral.js index 91b28a6f3..469f4f690 100644 --- a/lib/peripheral.js +++ b/lib/peripheral.js @@ -1,6 +1,3 @@ -/*jshint loopfunc: true */ -var debug = require('debug')('peripheral'); - var events = require('events'); var util = require('util'); diff --git a/lib/service.js b/lib/service.js index 43c8a396f..5227fd1cf 100644 --- a/lib/service.js +++ b/lib/service.js @@ -1,5 +1,3 @@ -var debug = require('debug')('service'); - var events = require('events'); var util = require('util'); diff --git a/lib/webbluetooth/bindings.js b/lib/webbluetooth/bindings.js index 4deac3837..c55c8683a 100644 --- a/lib/webbluetooth/bindings.js +++ b/lib/webbluetooth/bindings.js @@ -31,8 +31,6 @@ var NobleBindings = function() { this._startScanCommand = null; this._peripherals = {}; - var self = this; - }; util.inherits(NobleBindings, events.EventEmitter); @@ -183,9 +181,8 @@ NobleBindings.prototype.disconnect = function(deviceUuid) { }; NobleBindings.prototype.updateRssi = function(deviceUuid) { - var peripheral = this._peripherals[deviceUuid]; - //TODO: need web api completed for this to work + // var peripheral = this._peripherals[deviceUuid]; // this.emit('rssiUpdate', deviceUuid, rssi); }; @@ -200,9 +197,8 @@ NobleBindings.prototype.discoverServices = function(deviceUuid, uuids) { }; NobleBindings.prototype.discoverIncludedServices = function(deviceUuid, serviceUuid, serviceUuids) { - var peripheral = this._peripherals[deviceUuid]; - //TODO impelment when web API has functionatility then emit response + //var peripheral = this._peripherals[deviceUuid]; //this.emit('includedServicesDiscover', deviceUuid, serviceUuid, includedServiceUuids); }; @@ -307,9 +303,8 @@ NobleBindings.prototype.write = function(deviceUuid, serviceUuid, characteristic }; NobleBindings.prototype.broadcast = function(deviceUuid, serviceUuid, characteristicUuid, broadcast) { - var peripheral = this._peripherals[deviceUuid]; - //TODO impelment when web API has functionatility then emit response + //var peripheral = this._peripherals[deviceUuid]; //this.emit('broadcast', deviceUuid, serviceUuid, characteristicUuid, state); }; @@ -372,37 +367,32 @@ NobleBindings.prototype.notify = function(deviceUuid, serviceUuid, characteristi }; NobleBindings.prototype.discoverDescriptors = function(deviceUuid, serviceUuid, characteristicUuid) { - var peripheral = this._peripherals[deviceUuid]; - //TODO impelment when web API has functionatility then emit response + //var peripheral = this._peripherals[deviceUuid]; //this.emit('descriptorsDiscover', deviceUuid, serviceUuid, characteristicUuid, descriptors); }; NobleBindings.prototype.readValue = function(deviceUuid, serviceUuid, characteristicUuid, descriptorUuid) { - var peripheral = this._peripherals[deviceUuid]; - //TODO impelment when web API has functionatility then emit response + //var peripheral = this._peripherals[deviceUuid]; //this.emit('valueRead', deviceUuid, serviceUuid, characteristicUuid, descriptorUuid, data); }; NobleBindings.prototype.writeValue = function(deviceUuid, serviceUuid, characteristicUuid, descriptorUuid, data) { - var peripheral = this._peripherals[deviceUuid]; - //TODO impelment when web API has functionatility then emit response + //var peripheral = this._peripherals[deviceUuid]; //this.emit('valueWrite', deviceUuid, serviceUuid, characteristicUuid, descriptorUuid); }; NobleBindings.prototype.readHandle = function(deviceUuid, handle) { - var peripheral = this._peripherals[deviceUuid]; - //TODO impelment when web API has functionatility then emit response + //var peripheral = this._peripherals[deviceUuid]; //this.emit('handleRead', deviceUuid, handle, data); }; NobleBindings.prototype.writeHandle = function(deviceUuid, handle, data, withoutResponse) { - var peripheral = this._peripherals[deviceUuid]; - //TODO impelment when web API has functionatility then emit response + //var peripheral = this._peripherals[deviceUuid]; //this.emit('handleWrite', deviceUuid, handle); }; diff --git a/lib/websocket/bindings.js b/lib/websocket/bindings.js index 122d6c68b..829fc2a1f 100644 --- a/lib/websocket/bindings.js +++ b/lib/websocket/bindings.js @@ -1,7 +1,6 @@ var events = require('events'); var util = require('util'); -var debug = require('debug')('bindings'); var WebSocket = require('ws'); var NobleBindings = function() { diff --git a/test/test-characteristic.js b/test/test-characteristic.js index 3636cc768..b3830d330 100644 --- a/test/test-characteristic.js +++ b/test/test-characteristic.js @@ -1,4 +1,4 @@ -var should = require('should'); +require('should'); var sinon = require('sinon'); var Characteristic = require('../lib/characteristic'); diff --git a/test/test-descriptor.js b/test/test-descriptor.js index 77664497f..890958635 100644 --- a/test/test-descriptor.js +++ b/test/test-descriptor.js @@ -1,4 +1,4 @@ -var should = require('should'); +require('should'); var sinon = require('sinon'); var Descriptor = require('../lib/descriptor'); @@ -130,4 +130,4 @@ describe('Descriptor', function() { }); }); -}); \ No newline at end of file +}); diff --git a/test/test-peripheral.js b/test/test-peripheral.js index 86aa14e0c..434be3b34 100644 --- a/test/test-peripheral.js +++ b/test/test-peripheral.js @@ -1,4 +1,4 @@ -var should = require('should'); +require('should'); var sinon = require('sinon'); var Peripheral = require('../lib/peripheral'); @@ -328,4 +328,4 @@ describe('Peripheral', function() { calledback.should.equal(true); }); }); -}); \ No newline at end of file +}); diff --git a/test/test-service.js b/test/test-service.js index e39936cb1..4c0e905cb 100644 --- a/test/test-service.js +++ b/test/test-service.js @@ -1,4 +1,4 @@ -var should = require('should'); +require('should'); var sinon = require('sinon'); var Service = require('../lib/service'); @@ -117,4 +117,4 @@ describe('service', function() { callbackCharacteristics.should.equal(mockCharacteristics); }); }); -}); \ No newline at end of file +}); diff --git a/ws-slave.js b/ws-slave.js index 874fcf9ec..fb9adaa2e 100644 --- a/ws-slave.js +++ b/ws-slave.js @@ -1,7 +1,4 @@ /* jshint loopfunc: true */ -var events = require('events'); - -var debug = require('debug')('slave'); var WebSocket = require('ws'); var noble = require('./index'); @@ -408,4 +405,4 @@ noble.on('discover', function(peripheral) { }, rssi: peripheral.rssi }); -}); \ No newline at end of file +}); From 81c447b3e0e3d452ac0111f3d74fb2ede94b92cc Mon Sep 17 00:00:00 2001 From: Aarni Koskela Date: Sat, 25 Jan 2020 13:38:30 +0200 Subject: [PATCH 054/114] Fix no-undef woes --- .eslintrc.js | 3 +-- lib/hci-socket/gatt.js | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index f3c55ec16..a54e841fb 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -18,7 +18,6 @@ module.exports = { { args: "none" } - ], - "no-undef": 0 + ] } }; diff --git a/lib/hci-socket/gatt.js b/lib/hci-socket/gatt.js index 9697c3da0..ae0857d2c 100644 --- a/lib/hci-socket/gatt.js +++ b/lib/hci-socket/gatt.js @@ -418,7 +418,7 @@ Gatt.prototype.addCharacteristics = function (serviceUuid, characteristics) { this._descriptors[serviceUuid] = this._descriptors[serviceUuid] || {}; - for (i = 0; i < characteristics.length; i++) { + for (var i = 0; i < characteristics.length; i++) { this._characteristics[serviceUuid][characteristics[i].uuid] = characteristics[i]; } }; From 5ae3f8c9ccc216e4d96ff020ced214a0b823213c Mon Sep 17 00:00:00 2001 From: Aarni Koskela Date: Sat, 25 Jan 2020 13:38:55 +0200 Subject: [PATCH 055/114] Enforce semistandard style --- .eslintrc.js | 5 +- examples/advertisement-discovery.js | 7 +- examples/cache-gatt-discovery.js | 179 ++++--- examples/cache-gatt-reconnect.js | 137 +++--- examples/echo.js | 27 +- examples/enter-exit.js | 8 +- examples/peripheral-explorer.js | 39 +- examples/pizza/central.js | 79 ++- examples/pizza/pizza.js | 48 +- lib/characteristic.js | 28 +- lib/descriptor.js | 12 +- lib/distributed/bindings.js | 52 +- lib/hci-socket/acl-stream.js | 16 +- lib/hci-socket/bindings.js | 112 +++-- lib/hci-socket/crypto.js | 12 +- lib/hci-socket/gap.js | 26 +- lib/hci-socket/gatt.js | 231 +++++---- lib/hci-socket/hci.js | 70 ++- lib/hci-socket/signaling.js | 10 +- lib/hci-socket/smp.js | 24 +- lib/noble.js | 140 +++--- lib/peripheral.js | 38 +- lib/resolve-bindings-web.js | 2 +- lib/resolve-bindings.js | 2 +- lib/service.js | 12 +- lib/webbluetooth/bindings.js | 301 ++++++------ lib/websocket/bindings.js | 62 +-- package-lock.json | 729 ++++++++++++++++++++++++++++ package.json | 7 + test.js | 47 +- test/test-characteristic.js | 92 ++-- test/test-descriptor.js | 49 +- test/test-peripheral.js | 113 +++-- test/test-service.js | 42 +- with-bindings.js | 2 +- ws-slave.js | 58 ++- 36 files changed, 1750 insertions(+), 1068 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index a54e841fb..5cea036b2 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,6 +1,6 @@ module.exports = { root: true, - extends: ["eslint:recommended"], + extends: ["eslint:recommended", "semistandard"], parserOptions: { ecmaVersion: 2017 }, @@ -18,6 +18,7 @@ module.exports = { { args: "none" } - ] + ], + "semi": "error" } }; diff --git a/examples/advertisement-discovery.js b/examples/advertisement-discovery.js index d15367b5e..2a7d2996c 100644 --- a/examples/advertisement-discovery.js +++ b/examples/advertisement-discovery.js @@ -1,6 +1,6 @@ var noble = require('../index'); -noble.on('stateChange', function(state) { +noble.on('stateChange', function (state) { if (state === 'poweredOn') { noble.startScanning(); } else { @@ -8,9 +8,9 @@ noble.on('stateChange', function(state) { } }); -noble.on('discover', function(peripheral) { +noble.on('discover', function (peripheral) { console.log('peripheral discovered (' + peripheral.id + - ' with address <' + peripheral.address + ', ' + peripheral.addressType + '>,' + + ' with address <' + peripheral.address + ', ' + peripheral.addressType + '>,' + ' connectable ' + peripheral.connectable + ',' + ' RSSI ' + peripheral.rssi + ':'); console.log('\thello my local name is:'); @@ -36,4 +36,3 @@ noble.on('discover', function(peripheral) { console.log(); }); - diff --git a/examples/cache-gatt-discovery.js b/examples/cache-gatt-discovery.js index 750bf6b51..4d1d6b558 100644 --- a/examples/cache-gatt-discovery.js +++ b/examples/cache-gatt-discovery.js @@ -1,21 +1,21 @@ -/** discover a device (here, the first one where the name was resolved), - * for the first device discover all services and characteristics, +/** discover a device (here, the first one where the name was resolved), + * for the first device discover all services and characteristics, * store the collected GATT information into a meta-data object and write to disk. - * Finds a temperature characteristic and registers for data. + * Finds a temperature characteristic and registers for data. * Prints timing information from discovered to connected to reading states. */ var noble = require('../index'); -const fs = require('fs'); +const fs = require('fs'); // the sensor value to scan for, number of bits and factor for displaying it -const CHANNEL = process.env['CHANNEL'] ? process.env['CHANNEL'] : 'Temperature' -const BITS = process.env['BITS'] ? 1 * process.env['BITS'] : 16 -const FACTOR = process.env['FACTOR'] ? 1. * process.env['FACTOR'] : .1 +const CHANNEL = process.env.CHANNEL ? process.env.CHANNEL : 'Temperature'; +const BITS = process.env.BITS ? 1 * process.env.BITS : 16; +const FACTOR = process.env.FACTOR ? 1.0 * process.env.FACTOR : 0.1; -const EXT='.dump' +const EXT = '.dump'; -noble.on('stateChange', function(state) { +noble.on('stateChange', function (state) { if (state === 'poweredOn') { noble.startScanning(); } else { @@ -23,19 +23,19 @@ noble.on('stateChange', function(state) { } }); -let tDisco=0; // time when device was discovered -let tConn =0; // time when connection to device was established -let tRead =0; // time when reading data starts. +let tDisco = 0; // time when device was discovered +let tConn = 0; // time when connection to device was established +let tRead = 0; // time when reading data starts. // collect device meta-data into this object: -let meta = { - services: [], // stores an array of GATT service data objects - characteristics: {} // a map with key service-UUID, stores the array of characteristics -} +const meta = { + services: [], // stores an array of GATT service data objects + characteristics: {} // a map with key service-UUID, stores the array of characteristics +}; -noble.on('discover', function(peripheral) { +noble.on('discover', function (peripheral) { console.log('peripheral discovered (' + peripheral.id + - ' with address <' + peripheral.address + ', ' + peripheral.addressType + '>,' + + ' with address <' + peripheral.address + ', ' + peripheral.addressType + '>,' + ' connectable ' + peripheral.connectable + ',' + ' RSSI ' + peripheral.rssi + ':'); console.log('\thello my local name is:'); @@ -44,119 +44,116 @@ noble.on('discover', function(peripheral) { // connect to the first device with a valid name if (peripheral.advertisement.localName) { - console.log('Connecting to ' + peripheral.address + ' ' + peripheral.advertisement.localName) + console.log('Connecting to ' + peripheral.address + ' ' + peripheral.advertisement.localName); - tDisco = Date.now() - - connectToDevice(peripheral) + tDisco = Date.now(); + + connectToDevice(peripheral); } }); -let connectToDevice = function (peripheral) { - // BLE cannot scan and connect in parallel, so we stop scanning here: - noble.stopScanning() - - peripheral.connect((error) => { - // noble.startScanning([], true) - if (error) { - console.log('Connect error: ' + error) - noble.startScanning([], true) - return - } - tConn = Date.now() - console.log('Connected!') +const connectToDevice = function (peripheral) { + // BLE cannot scan and connect in parallel, so we stop scanning here: + noble.stopScanning(); - findServices(noble, peripheral) - }) -} + peripheral.connect((error) => { + // noble.startScanning([], true) + if (error) { + console.log('Connect error: ' + error); + noble.startScanning([], true); + return; + } + tConn = Date.now(); + console.log('Connected!'); + findServices(noble, peripheral); + }); +}; let servicesToRead = 0; -let findServices = function (noble, peripheral) { - meta.uuid = peripheral.uuid - meta.address = peripheral.address - meta.name = peripheral.advertisement.localName // not needed but nice to have +const findServices = function (noble, peripheral) { + meta.uuid = peripheral.uuid; + meta.address = peripheral.address; + meta.name = peripheral.advertisement.localName; // not needed but nice to have - meta.characteristics = {} + meta.characteristics = {}; - // callback triggers with GATT-relevant data + // callback triggers with GATT-relevant data peripheral.on('servicesDiscovered', (peripheral, services) => { - - console.log('servicesDiscovered: Found '+ services.length + ' services! ') - meta.services = services - for (let i in services) { - const service = services[i] - console.log('\tservice ' + i + ' : ' + JSON.stringify(service)) - //meta.services[ service.uuid ] = service + console.log('servicesDiscovered: Found ' + services.length + ' services! '); + meta.services = services; + for (const i in services) { + const service = services[i]; + console.log('\tservice ' + i + ' : ' + JSON.stringify(service)); + // meta.services[ service.uuid ] = service } - }) + }); peripheral.discoverServices([], (error, services) => { + let sensorCharacteristic; - let sensorCharacteristic - - servicesToRead = services.length + servicesToRead = services.length; // we found the list of services, now trigger characteristics lookup for each of them: for (let i = 0; i < services.length; i++) { - let service = services[i] + const service = services[i]; service.on('characteristicsDiscovered', (characteristics) => { // store the list of characteristics per service - meta.characteristics[service.uuid] = characteristics + meta.characteristics[service.uuid] = characteristics; - console.log('SRV\t' + service.uuid + ' characteristic GATT data: ') + console.log('SRV\t' + service.uuid + ' characteristic GATT data: '); for (let i = 0; i < characteristics.length; i++) { - console.log('\t' + service.uuid + ' chara.\t ' + ' ' + i + ' ' + JSON.stringify(characteristics[i])) + console.log('\t' + service.uuid + ' chara.\t ' + ' ' + i + ' ' + JSON.stringify(characteristics[i])); } - }) + }); service.discoverCharacteristics([], function (error, characteristics) { - console.log('SRV\t' + service.uuid + ' characteristic decoded data: ' ) - for (let j = 0; j< characteristics.length; j++) { - let ch = characteristics[j] - console.log('\t' + service.uuid + ' chara.\t ' + ' ' + j + ' ' + ch) - - if ( ch.name === CHANNEL) { - console.log('found ' + CHANNEL + ' characteristic!') - sensorCharacteristic = ch + console.log('SRV\t' + service.uuid + ' characteristic decoded data: '); + for (let j = 0; j < characteristics.length; j++) { + const ch = characteristics[j]; + console.log('\t' + service.uuid + ' chara.\t ' + ' ' + j + ' ' + ch); + + if (ch.name === CHANNEL) { + console.log('found ' + CHANNEL + ' characteristic!'); + sensorCharacteristic = ch; } } - servicesToRead-- + servicesToRead--; if (!servicesToRead) { - console.log('----------------- FINISHED') - console.log(JSON.stringify(meta, null, 4)) + console.log('----------------- FINISHED'); + console.log(JSON.stringify(meta, null, 4)); // write to file - fs.writeFile(meta.uuid + EXT, JSON.stringify(meta,null,2), function(err) { - if(err) { + fs.writeFile(meta.uuid + EXT, JSON.stringify(meta, null, 2), function (err) { + if (err) { return console.log(err); } - console.log("The data was saved to " , meta.uuid + EXT); + console.log('The data was saved to ', meta.uuid + EXT); }); if (sensorCharacteristic) { - console.log('Listening for temperature data...') + console.log('Listening for temperature data...'); + + tRead = Date.now(); - tRead = Date.now() - sensorCharacteristic.on('data', (data) => { - if (BITS === 16 ) { - console.log(' new ' + CHANNEL + ' ' + (data.readUInt16LE() * FACTOR) ) - } else if (BITS === 32) { - console.log(' new ' + CHANNEL + ' ' + (data.readUInt32LE() * FACTOR) ) - } else { - console.log(' Cannot cope with BITS value '+ BITS) - } - }) - sensorCharacteristic.read() + if (BITS === 16) { + console.log(' new ' + CHANNEL + ' ' + (data.readUInt16LE() * FACTOR)); + } else if (BITS === 32) { + console.log(' new ' + CHANNEL + ' ' + (data.readUInt32LE() * FACTOR)); + } else { + console.log(' Cannot cope with BITS value ' + BITS); + } + }); + sensorCharacteristic.read(); } - console.log('Timespan from discovery to connected: ' + (tConn -tDisco) + ' ms') - console.log('Timespan from connected to reading : ' + (tRead -tConn) + ' ms') + console.log('Timespan from discovery to connected: ' + (tConn - tDisco) + ' ms'); + console.log('Timespan from connected to reading : ' + (tRead - tConn) + ' ms'); } - }) + }); } - }) -} + }); +}; diff --git a/examples/cache-gatt-reconnect.js b/examples/cache-gatt-reconnect.js index 7ca8d0736..68c81eadc 100644 --- a/examples/cache-gatt-reconnect.js +++ b/examples/cache-gatt-reconnect.js @@ -1,21 +1,21 @@ /** reconnect to a device that has been discovered earlier on using cache-gatt-discovery: - * If a device is discovered and a dump file exists, load it and connect to it, re-initializing service + * If a device is discovered and a dump file exists, load it and connect to it, re-initializing service * and characteristic objects in the noble stack. - * Finds a temperature characteristic and registers for data. + * Finds a temperature characteristic and registers for data. * Prints timing information from discovered to connected to reading states. */ var noble = require('../index'); -const fs = require('fs'); +const fs = require('fs'); // the sensor value to scan for, number of bits and factor for displaying it -const CHANNEL = process.env['CHANNEL'] ? process.env['CHANNEL'] : 'Temperature' -const BITS = process.env['BITS'] ? 1 * process.env['BITS'] : 16 -const FACTOR = process.env['FACTOR'] ? 1. * process.env['FACTOR'] : .1 +const CHANNEL = process.env.CHANNEL ? process.env.CHANNEL : 'Temperature'; +const BITS = process.env.BITS ? 1 * process.env.BITS : 16; +const FACTOR = process.env.FACTOR ? 1.0 * process.env.FACTOR : 0.1; -const EXT='.dump' +const EXT = '.dump'; -noble.on('stateChange', function(state) { +noble.on('stateChange', function (state) { if (state === 'poweredOn') { noble.startScanning(); } else { @@ -23,124 +23,121 @@ noble.on('stateChange', function(state) { } }); -let tDisco=0; // time when device was discovered -let tConn =0; // time when connection to device was established -let tRead =0; // time when reading data starts. +let tDisco = 0; // time when device was discovered +let tConn = 0; // time when connection to device was established +let tRead = 0; // time when reading data starts. // collect device meta-data into this object: let meta = { services: {}, // a map indexted by service-UUID -> contains service data characteristics: {} // an map with key service-UUID, stores the array of characteristics -} +}; -noble.on('discover', function(peripheral) { +noble.on('discover', function (peripheral) { console.log('peripheral discovered (' + peripheral.id + - ' with address <' + peripheral.address + ', ' + peripheral.addressType + '>,' + + ' with address <' + peripheral.address + ', ' + peripheral.addressType + '>,' + ' connectable ' + peripheral.connectable + ',' + ' RSSI ' + peripheral.rssi + ':'); console.log('\thello my local name is:'); console.log('\t\t' + peripheral.advertisement.localName); console.log(); - // Check if a dump exists in the current directory. fs.access(peripheral.uuid + EXT, fs.constants.F_OK, (err) => { if (!err) { - console.log('found dump file for ' + peripheral.uuid ) + console.log('found dump file for ' + peripheral.uuid); - tDisco=Date.now() + tDisco = Date.now(); - quickConnect(peripheral) + quickConnect(peripheral); } }); }); - -let quickConnect = function (peripheral) { +const quickConnect = function (peripheral) { // BLE cannot scan and connect in parallel, so we stop scanning here: - noble.stopScanning() - + noble.stopScanning(); peripheral.connect((error) => { if (error) { - console.log('Connect error: ' + error) - noble.startScanning([], true) - return + console.log('Connect error: ' + error); + noble.startScanning([], true); + return; } - tConn = Date.now() - console.log('Connected!') + tConn = Date.now(); + console.log('Connected!'); // load stored data. This needs to be done when connected, as we need a handle at GATT level - meta = loadData(peripheral) + meta = loadData(peripheral); // initialize the service and charateristics objects in Noble; return a temperature characteristic, if found - let sensorCharacteristic = setData(peripheral, meta) + const sensorCharacteristic = setData(peripheral, meta); if (!sensorCharacteristic) { - console.log('Warning - no temperature characteristic found.') + console.log('Warning - no temperature characteristic found.'); } else { - console.log('Listening for temperature data...') + console.log('Listening for temperature data...'); + + tRead = Date.now(); - tRead = Date.now() - sensorCharacteristic.on('data', (data) => { - if (BITS === 16 ) { - console.log(' new ' + CHANNEL + ' ' + (data.readUInt16LE() * FACTOR) ) + if (BITS === 16) { + console.log(' new ' + CHANNEL + ' ' + (data.readUInt16LE() * FACTOR)); } else if (BITS === 32) { - console.log(' new ' + CHANNEL + ' ' + (data.readUInt32LE() * FACTOR) ) + console.log(' new ' + CHANNEL + ' ' + (data.readUInt32LE() * FACTOR)); } else { - console.log(' Cannot cope with BITS value '+ BITS) + console.log(' Cannot cope with BITS value ' + BITS); } - }) - sensorCharacteristic.read() + }); + sensorCharacteristic.read(); - console.log('Timespan from discovery to connected: ' + (tConn -tDisco) + ' ms') - console.log('Timespan from connected to reading : ' + (tRead -tConn) + ' ms') + console.log('Timespan from discovery to connected: ' + (tConn - tDisco) + ' ms'); + console.log('Timespan from connected to reading : ' + (tRead - tConn) + ' ms'); } - }) -} + }); +}; -let loadData = function(peripheral) { - const dump = fs.readFileSync(peripheral.uuid + EXT) - const data = JSON.parse(dump) +const loadData = function (peripheral) { + const dump = fs.readFileSync(peripheral.uuid + EXT); + const data = JSON.parse(dump); // verify data: console.log(JSON.stringify(data,null,2)) - return data -} + return data; +}; -let setData = function(peripheral, meta) { +const setData = function (peripheral, meta) { // first, create the service objects: - console.log('initializing services... ') + console.log('initializing services... '); // addServices returns an array of initialized service objects - let services = noble.addServices(peripheral.uuid, meta.services) + const services = noble.addServices(peripheral.uuid, meta.services); - console.log('initialized services: ') - for (let i in services) { - const service = services[i] - console.log('\tservice ' + i + ' ' + service) + console.log('initialized services: '); + for (const i in services) { + const service = services[i]; + console.log('\tservice ' + i + ' ' + service); } - console.log() + console.log(); - let sensorCharacteristic + let sensorCharacteristic; - console.log('initializing characteristics... ') + console.log('initializing characteristics... '); // now, for each service, set the characteristics: - for (let i in services) { - const service = services[i] - const charas = meta.characteristics[service.uuid] - console.log('\tservice ' + i + ' ' + service + ' ' + JSON.stringify(charas)) + for (const i in services) { + const service = services[i]; + const charas = meta.characteristics[service.uuid]; + console.log('\tservice ' + i + ' ' + service + ' ' + JSON.stringify(charas)); - let characteristics = noble.addCharacteristics(peripheral.uuid, service.uuid, charas) + const characteristics = noble.addCharacteristics(peripheral.uuid, service.uuid, charas); - for (let j in characteristics) { - let characteristic = characteristics[j] - console.log('\t\tcharac ' + service.uuid + ' ' + j + ' ' + characteristic + ' ' + characteristic.rawProps) + for (const j in characteristics) { + const characteristic = characteristics[j]; + console.log('\t\tcharac ' + service.uuid + ' ' + j + ' ' + characteristic + ' ' + characteristic.rawProps); if (characteristic.name === CHANNEL) { - console.log('\t\t\t-->found ' + CHANNEL + ' characteristic!') - sensorCharacteristic = characteristic + console.log('\t\t\t-->found ' + CHANNEL + ' characteristic!'); + sensorCharacteristic = characteristic; } } } - return sensorCharacteristic -} + return sensorCharacteristic; +}; diff --git a/examples/echo.js b/examples/echo.js index 4e1466b5e..06cc067ed 100755 --- a/examples/echo.js +++ b/examples/echo.js @@ -4,7 +4,7 @@ // subscribe to be notified when the value changes // start an interval to write data to the characteristic -//const noble = require('noble'); +// const noble = require('noble'); const noble = require('..'); const ECHO_SERVICE_UUID = 'ec00'; @@ -20,15 +20,14 @@ noble.on('stateChange', state => { }); noble.on('discover', peripheral => { - // connect to the first peripheral that is scanned - noble.stopScanning(); - const name = peripheral.advertisement.localName; - console.log(`Connecting to '${name}' ${peripheral.id}`); - connectAndSetUp(peripheral); + // connect to the first peripheral that is scanned + noble.stopScanning(); + const name = peripheral.advertisement.localName; + console.log(`Connecting to '${name}' ${peripheral.id}`); + connectAndSetUp(peripheral); }); -function connectAndSetUp(peripheral) { - +function connectAndSetUp (peripheral) { peripheral.connect(error => { console.log('Connected to', peripheral.id); @@ -37,16 +36,16 @@ function connectAndSetUp(peripheral) { const characteristicUUIDs = [ECHO_CHARACTERISTIC_UUID]; peripheral.discoverSomeServicesAndCharacteristics( - serviceUUIDs, - characteristicUUIDs, - onServicesAndCharacteristicsDiscovered + serviceUUIDs, + characteristicUUIDs, + onServicesAndCharacteristicsDiscovered ); }); - + peripheral.on('disconnect', () => console.log('disconnected')); } -function onServicesAndCharacteristicsDiscovered(error, services, characteristics) { +function onServicesAndCharacteristicsDiscovered (error, services, characteristics) { console.log('Discovered services and characteristics'); const echoCharacteristic = characteristics[0]; @@ -54,7 +53,7 @@ function onServicesAndCharacteristicsDiscovered(error, services, characteristics echoCharacteristic.on('data', (data, isNotification) => { console.log('Received: "' + data + '"'); }); - + // subscribe to be notified whenever the peripheral update the characteristic echoCharacteristic.subscribe(error => { if (error) { diff --git a/examples/enter-exit.js b/examples/enter-exit.js index 1b12c683e..b64051821 100644 --- a/examples/enter-exit.js +++ b/examples/enter-exit.js @@ -8,12 +8,12 @@ */ var noble = require('../index'); -var RSSI_THRESHOLD = -90; +var RSSI_THRESHOLD = -90; var EXIT_GRACE_PERIOD = 2000; // milliseconds var inRange = []; -noble.on('discover', function(peripheral) { +noble.on('discover', function (peripheral) { if (peripheral.rssi < RSSI_THRESHOLD) { // ignore return; @@ -33,7 +33,7 @@ noble.on('discover', function(peripheral) { inRange[id].lastSeen = Date.now(); }); -setInterval(function() { +setInterval(function () { for (var id in inRange) { if (inRange[id].lastSeen < (Date.now() - EXIT_GRACE_PERIOD)) { var peripheral = inRange[id].peripheral; @@ -45,7 +45,7 @@ setInterval(function() { } }, EXIT_GRACE_PERIOD / 2); -noble.on('stateChange', function(state) { +noble.on('stateChange', function (state) { if (state === 'poweredOn') { noble.startScanning([], true); } else { diff --git a/examples/peripheral-explorer.js b/examples/peripheral-explorer.js index daf13f52c..20fb9956f 100644 --- a/examples/peripheral-explorer.js +++ b/examples/peripheral-explorer.js @@ -3,7 +3,7 @@ var noble = require('../index'); var peripheralIdOrAddress = process.argv[2].toLowerCase(); -noble.on('stateChange', function(state) { +noble.on('stateChange', function (state) { if (state === 'poweredOn') { noble.startScanning(); } else { @@ -11,7 +11,7 @@ noble.on('stateChange', function(state) { } }); -noble.on('discover', function(peripheral) { +noble.on('discover', function (peripheral) { if (peripheral.id === peripheralIdOrAddress || peripheral.address === peripheralIdOrAddress) { noble.stopScanning(); @@ -50,22 +50,22 @@ noble.on('discover', function(peripheral) { } }); -function explore(peripheral) { +function explore (peripheral) { console.log('services and characteristics:'); - peripheral.on('disconnect', function() { + peripheral.on('disconnect', function () { process.exit(0); }); - peripheral.connect(function(error) { - peripheral.discoverServices([], function(error, services) { + peripheral.connect(function (error) { + peripheral.discoverServices([], function (error, services) { var serviceIndex = 0; async.whilst( function () { return (serviceIndex < services.length); }, - function(callback) { + function (callback) { var service = services[serviceIndex]; var serviceInfo = service.uuid; @@ -74,14 +74,14 @@ function explore(peripheral) { } console.log(serviceInfo); - service.discoverCharacteristics([], function(error, characteristics) { + service.discoverCharacteristics([], function (error, characteristics) { var characteristicIndex = 0; async.whilst( function () { return (characteristicIndex < characteristics.length); }, - function(callback) { + function (callback) { var characteristic = characteristics[characteristicIndex]; var characteristicInfo = ' ' + characteristic.uuid; @@ -90,20 +90,20 @@ function explore(peripheral) { } async.series([ - function(callback) { - characteristic.discoverDescriptors(function(error, descriptors) { + function (callback) { + characteristic.discoverDescriptors(function (error, descriptors) { async.detect( descriptors, - function(descriptor, callback) { + function (descriptor, callback) { if (descriptor.uuid === '2901') { return callback(descriptor); } else { return callback(); } }, - function(userDescriptionDescriptor){ + function (userDescriptionDescriptor) { if (userDescriptionDescriptor) { - userDescriptionDescriptor.readValue(function(error, data) { + userDescriptionDescriptor.readValue(function (error, data) { if (data) { characteristicInfo += ' (' + data.toString() + ')'; } @@ -116,11 +116,11 @@ function explore(peripheral) { ); }); }, - function(callback) { - characteristicInfo += '\n properties ' + characteristic.properties.join(', '); + function (callback) { + characteristicInfo += '\n properties ' + characteristic.properties.join(', '); if (characteristic.properties.indexOf('read') !== -1) { - characteristic.read(function(error, data) { + characteristic.read(function (error, data) { if (data) { var string = data.toString('ascii'); @@ -132,14 +132,14 @@ function explore(peripheral) { callback(); } }, - function() { + function () { console.log(characteristicInfo); characteristicIndex++; callback(); } ]); }, - function(error) { + function (error) { serviceIndex++; callback(); } @@ -153,4 +153,3 @@ function explore(peripheral) { }); }); } - diff --git a/examples/pizza/central.js b/examples/pizza/central.js index 7f75d0466..c2851f369 100644 --- a/examples/pizza/central.js +++ b/examples/pizza/central.js @@ -7,7 +7,7 @@ var pizzaCrustCharacteristicUuid = '13333333333333333333333333330001'; var pizzaToppingsCharacteristicUuid = '13333333333333333333333333330002'; var pizzaBakeCharacteristicUuid = '13333333333333333333333333330003'; -noble.on('stateChange', function(state) { +noble.on('stateChange', function (state) { if (state === 'poweredOn') { // // Once the BLE radio has been powered on, it is possible @@ -16,17 +16,16 @@ noble.on('stateChange', function(state) { // console.log('scanning...'); noble.startScanning([pizzaServiceUuid], false); - } - else { + } else { noble.stopScanning(); } -}) +}); var pizzaCrustCharacteristic = null; var pizzaToppingsCharacteristic = null; var pizzaBakeCharacteristic = null; -noble.on('discover', function(peripheral) { +noble.on('discover', function (peripheral) { // we found a peripheral, stop scanning noble.stopScanning(); @@ -39,13 +38,13 @@ noble.on('discover', function(peripheral) { // // Once the peripheral has been discovered, then connect to it. // - peripheral.connect(function(err) { + peripheral.connect(function (err) { // // Once the peripheral has been connected, then discover the // services and characteristics of interest. // - peripheral.discoverServices([pizzaServiceUuid], function(err, services) { - services.forEach(function(service) { + peripheral.discoverServices([pizzaServiceUuid], function (err, services) { + services.forEach(function (service) { // // This must be the service we were looking for. // @@ -54,9 +53,8 @@ noble.on('discover', function(peripheral) { // // So, discover its characteristics. // - service.discoverCharacteristics([], function(err, characteristics) { - - characteristics.forEach(function(characteristic) { + service.discoverCharacteristics([], function (err, characteristics) { + characteristics.forEach(function (characteristic) { // // Loop through each characteristic and match them to the // UUIDs that we know about. @@ -65,14 +63,12 @@ noble.on('discover', function(peripheral) { if (pizzaCrustCharacteristicUuid == characteristic.uuid) { pizzaCrustCharacteristic = characteristic; - } - else if (pizzaToppingsCharacteristicUuid == characteristic.uuid) { + } else if (pizzaToppingsCharacteristicUuid == characteristic.uuid) { pizzaToppingsCharacteristic = characteristic; - } - else if (pizzaBakeCharacteristicUuid == characteristic.uuid) { + } else if (pizzaBakeCharacteristicUuid == characteristic.uuid) { pizzaBakeCharacteristic = characteristic; } - }) + }); // // Check to see if we found all of our characteristics. @@ -84,23 +80,22 @@ noble.on('discover', function(peripheral) { // We did, so bake a pizza! // bakePizza(); - } - else { + } else { console.log('missing characteristics'); } - }) - }) - }) - }) -}) + }); + }); + }); + }); +}); -function bakePizza() { +function bakePizza () { // // Pick the crust. // var crust = new Buffer(1); crust.writeUInt8(pizza.PizzaCrust.THIN, 0); - pizzaCrustCharacteristic.write(crust, false, function(err) { + pizzaCrustCharacteristic.write(crust, false, function (err) { if (!err) { // // Pick the toppings. @@ -112,49 +107,45 @@ function bakePizza() { pizza.PizzaToppings.PINEAPPLE, 0 ); - pizzaToppingsCharacteristic.write(toppings, false, function(err) { + pizzaToppingsCharacteristic.write(toppings, false, function (err) { if (!err) { // // Subscribe to the bake notification, so we know when // our pizza will be ready. // - pizzaBakeCharacteristic.on('read', function(data, isNotification) { + pizzaBakeCharacteristic.on('read', function (data, isNotification) { console.log('Our pizza is ready!'); if (data.length === 1) { var result = data.readUInt8(0); console.log('The result is', - result == pizza.PizzaBakeResult.HALF_BAKED ? 'half baked.' : - result == pizza.PizzaBakeResult.BAKED ? 'baked.' : - result == pizza.PizzaBakeResult.CRISPY ? 'crispy.' : - result == pizza.PizzaBakeResult.BURNT ? 'burnt.' : - result == pizza.PizzaBakeResult.ON_FIRE ? 'on fire!' : - 'unknown?'); - } - else { - console.log('result length incorrect') + result == pizza.PizzaBakeResult.HALF_BAKED ? 'half baked.' + : result == pizza.PizzaBakeResult.BAKED ? 'baked.' + : result == pizza.PizzaBakeResult.CRISPY ? 'crispy.' + : result == pizza.PizzaBakeResult.BURNT ? 'burnt.' + : result == pizza.PizzaBakeResult.ON_FIRE ? 'on fire!' + : 'unknown?'); + } else { + console.log('result length incorrect'); } }); - pizzaBakeCharacteristic.subscribe(function(err) { + pizzaBakeCharacteristic.subscribe(function (err) { // // Bake at 450 degrees! // var temperature = new Buffer(2); temperature.writeUInt16BE(450, 0); - pizzaBakeCharacteristic.write(temperature, false, function(err) { + pizzaBakeCharacteristic.write(temperature, false, function (err) { if (err) { console.log('bake error'); } }); }); - - } - else { + } else { console.log('toppings error'); } }); - } - else { + } else { console.log('crust error'); } - }) + }); } diff --git a/examples/pizza/pizza.js b/examples/pizza/pizza.js index 59fc0c562..8b964f882 100644 --- a/examples/pizza/pizza.js +++ b/examples/pizza/pizza.js @@ -2,32 +2,32 @@ var util = require('util'); var events = require('events'); var PizzaCrust = { - NORMAL: 0, + NORMAL: 0, DEEP_DISH: 1, - THIN: 2, + THIN: 2 }; var PizzaToppings = { - NONE: 0, - PEPPERONI: 1 << 0, - MUSHROOMS: 1 << 1, - EXTRA_CHEESE: 1 << 2, - BLACK_OLIVES: 1 << 3, + NONE: 0, + PEPPERONI: 1 << 0, + MUSHROOMS: 1 << 1, + EXTRA_CHEESE: 1 << 2, + BLACK_OLIVES: 1 << 3, CANADIAN_BACON: 1 << 4, - PINEAPPLE: 1 << 5, - BELL_PEPPERS: 1 << 6, - SAUSAGE: 1 << 7, + PINEAPPLE: 1 << 5, + BELL_PEPPERS: 1 << 6, + SAUSAGE: 1 << 7 }; var PizzaBakeResult = { HALF_BAKED: 0, - BAKED: 1, - CRISPY: 2, - BURNT: 3, - ON_FIRE: 4 -} + BAKED: 1, + CRISPY: 2, + BURNT: 3, + ON_FIRE: 4 +}; -function Pizza() { +function Pizza () { events.EventEmitter.call(this); this.toppings = PizzaToppings.NONE; this.crust = PizzaCrust.NORMAL; @@ -35,20 +35,20 @@ function Pizza() { util.inherits(Pizza, events.EventEmitter); -Pizza.prototype.bake = function(temperature) { +Pizza.prototype.bake = function (temperature) { var time = temperature * 10; var self = this; console.log('baking pizza at', temperature, 'degrees for', time, 'milliseconds'); - setTimeout(function() { + setTimeout(function () { var result = - (temperature < 350) ? PizzaBakeResult.HALF_BAKED: - (temperature < 450) ? PizzaBakeResult.BAKED: - (temperature < 500) ? PizzaBakeResult.CRISPY: - (temperature < 600) ? PizzaBakeResult.BURNT: - PizzaBakeResult.ON_FIRE; + (temperature < 350) ? PizzaBakeResult.HALF_BAKED + : (temperature < 450) ? PizzaBakeResult.BAKED + : (temperature < 500) ? PizzaBakeResult.CRISPY + : (temperature < 600) ? PizzaBakeResult.BURNT + : PizzaBakeResult.ON_FIRE; self.emit('ready', result); }, time); -} +}; module.exports.Pizza = Pizza; module.exports.PizzaToppings = PizzaToppings; diff --git a/lib/characteristic.js b/lib/characteristic.js index ed1e72fa4..c0b19bc46 100644 --- a/lib/characteristic.js +++ b/lib/characteristic.js @@ -3,7 +3,7 @@ var util = require('util'); var characteristics = require('./characteristics.json'); -function Characteristic(noble, peripheralId, serviceUuid, uuid, properties) { +function Characteristic (noble, peripheralId, serviceUuid, uuid, properties) { this._noble = noble; this._peripheralId = peripheralId; this._serviceUuid = serviceUuid; @@ -23,7 +23,7 @@ function Characteristic(noble, peripheralId, serviceUuid, uuid, properties) { util.inherits(Characteristic, events.EventEmitter); -Characteristic.prototype.toString = function() { +Characteristic.prototype.toString = function () { return JSON.stringify({ uuid: this.uuid, name: this.name, @@ -32,9 +32,9 @@ Characteristic.prototype.toString = function() { }); }; -Characteristic.prototype.read = function(callback) { +Characteristic.prototype.read = function (callback) { if (callback) { - var onRead = function(data, isNotificaton) { + var onRead = function (data, isNotificaton) { // only call the callback if 'read' event and non-notification // 'read' for non-notifications is only present for backwards compatbility if (!isNotificaton) { @@ -56,7 +56,7 @@ Characteristic.prototype.read = function(callback) { ); }; -Characteristic.prototype.write = function(data, withoutResponse, callback) { +Characteristic.prototype.write = function (data, withoutResponse, callback) { if (process.title !== 'browser') { if (!(data instanceof Buffer)) { throw new Error('data must be a Buffer'); @@ -64,7 +64,7 @@ Characteristic.prototype.write = function(data, withoutResponse, callback) { } if (callback) { - this.once('write', function() { + this.once('write', function () { callback(null); }); } @@ -78,9 +78,9 @@ Characteristic.prototype.write = function(data, withoutResponse, callback) { ); }; -Characteristic.prototype.broadcast = function(broadcast, callback) { +Characteristic.prototype.broadcast = function (broadcast, callback) { if (callback) { - this.once('broadcast', function() { + this.once('broadcast', function () { callback(null); }); } @@ -94,9 +94,9 @@ Characteristic.prototype.broadcast = function(broadcast, callback) { }; // deprecated in favour of subscribe/unsubscribe -Characteristic.prototype.notify = function(notify, callback) { +Characteristic.prototype.notify = function (notify, callback) { if (callback) { - this.once('notify', function() { + this.once('notify', function () { callback(null); }); } @@ -109,17 +109,17 @@ Characteristic.prototype.notify = function(notify, callback) { ); }; -Characteristic.prototype.subscribe = function(callback) { +Characteristic.prototype.subscribe = function (callback) { this.notify(true, callback); }; -Characteristic.prototype.unsubscribe = function(callback) { +Characteristic.prototype.unsubscribe = function (callback) { this.notify(false, callback); }; -Characteristic.prototype.discoverDescriptors = function(callback) { +Characteristic.prototype.discoverDescriptors = function (callback) { if (callback) { - this.once('descriptorsDiscover', function(descriptors) { + this.once('descriptorsDiscover', function (descriptors) { callback(null, descriptors); }); } diff --git a/lib/descriptor.js b/lib/descriptor.js index 434b3a67e..3778e18d4 100644 --- a/lib/descriptor.js +++ b/lib/descriptor.js @@ -3,7 +3,7 @@ var util = require('util'); var descriptors = require('./descriptors.json'); -function Descriptor(noble, peripheralId, serviceUuid, characteristicUuid, uuid) { +function Descriptor (noble, peripheralId, serviceUuid, characteristicUuid, uuid) { this._noble = noble; this._peripheralId = peripheralId; this._serviceUuid = serviceUuid; @@ -22,7 +22,7 @@ function Descriptor(noble, peripheralId, serviceUuid, characteristicUuid, uuid) util.inherits(Descriptor, events.EventEmitter); -Descriptor.prototype.toString = function() { +Descriptor.prototype.toString = function () { return JSON.stringify({ uuid: this.uuid, name: this.name, @@ -30,9 +30,9 @@ Descriptor.prototype.toString = function() { }); }; -Descriptor.prototype.readValue = function(callback) { +Descriptor.prototype.readValue = function (callback) { if (callback) { - this.once('valueRead', function(data) { + this.once('valueRead', function (data) { callback(null, data); }); } @@ -44,13 +44,13 @@ Descriptor.prototype.readValue = function(callback) { ); }; -Descriptor.prototype.writeValue = function(data, callback) { +Descriptor.prototype.writeValue = function (data, callback) { if (!(data instanceof Buffer)) { throw new Error('data must be a Buffer'); } if (callback) { - this.once('valueWrite', function() { + this.once('valueWrite', function () { callback(null); }); } diff --git a/lib/distributed/bindings.js b/lib/distributed/bindings.js index bcb73e45b..53054b3e6 100644 --- a/lib/distributed/bindings.js +++ b/lib/distributed/bindings.js @@ -3,7 +3,7 @@ var util = require('util'); var WebSocketServer = require('ws').Server; -var NobleBindings = function() { +var NobleBindings = function () { this._wss = new WebSocketServer({ port: 0xB1e }); @@ -15,18 +15,18 @@ var NobleBindings = function() { this.on('close', this._onClose.bind(this)); this.on('message', this._onMessage.bind(this)); - process.nextTick(function() { + process.nextTick(function () { this.emit('stateChange', 'poweredOff'); }.bind(this)); }; util.inherits(NobleBindings, events.EventEmitter); -NobleBindings.prototype.init = function() { +NobleBindings.prototype.init = function () { // no-op }; -NobleBindings.prototype._onConnection = function(ws) { +NobleBindings.prototype._onConnection = function (ws) { var _this = this; if (this._wss.clients.length === 1) { @@ -35,22 +35,22 @@ NobleBindings.prototype._onConnection = function(ws) { this._sendCommand(ws, this._startScanCommand); } - ws.on('close', function() { + ws.on('close', function () { _this.emit('close', ws); }); - ws.on('message', function(data) { + ws.on('message', function (data) { _this.emit('message', ws, JSON.parse(data)); }); }; -NobleBindings.prototype._onClose = function(ws) { +NobleBindings.prototype._onClose = function (ws) { if (this._wss.clients.length === 0) { this.emit('stateChange', 'poweredOff'); } }; -NobleBindings.prototype._onMessage = function(ws, event) { +NobleBindings.prototype._onMessage = function (ws, event) { var type = event.type; var peripheralUuid = event.peripheralUuid; var address = event.address; @@ -124,7 +124,7 @@ NobleBindings.prototype._onMessage = function(ws, event) { } }; -NobleBindings.prototype._sendCommand = function(ws, command) { +NobleBindings.prototype._sendCommand = function (ws, command) { var clients = ws ? [ws] : this._wss.clients; var message = JSON.stringify(command); @@ -134,7 +134,7 @@ NobleBindings.prototype._sendCommand = function(ws, command) { } }; -NobleBindings.prototype.startScanning = function(serviceUuids, allowDuplicates) { +NobleBindings.prototype.startScanning = function (serviceUuids, allowDuplicates) { this._startScanCommand = { action: 'startScanning', serviceUuids: serviceUuids, @@ -146,7 +146,7 @@ NobleBindings.prototype.startScanning = function(serviceUuids, allowDuplicates) this.emit('scanStart'); }; -NobleBindings.prototype.stopScanning = function() { +NobleBindings.prototype.stopScanning = function () { this._startScanCommand = null; this._sendCommand(null, { @@ -156,7 +156,7 @@ NobleBindings.prototype.stopScanning = function() { this.emit('scanStop'); }; -NobleBindings.prototype.connect = function(deviceUuid) { +NobleBindings.prototype.connect = function (deviceUuid) { var peripheral = this._peripherals[deviceUuid]; this._sendCommand(peripheral.ws, { @@ -165,7 +165,7 @@ NobleBindings.prototype.connect = function(deviceUuid) { }); }; -NobleBindings.prototype.disconnect = function(deviceUuid) { +NobleBindings.prototype.disconnect = function (deviceUuid) { var peripheral = this._peripherals[deviceUuid]; this._sendCommand(peripheral.ws, { @@ -174,7 +174,7 @@ NobleBindings.prototype.disconnect = function(deviceUuid) { }); }; -NobleBindings.prototype.updateRssi = function(deviceUuid) { +NobleBindings.prototype.updateRssi = function (deviceUuid) { var peripheral = this._peripherals[deviceUuid]; this._sendCommand(peripheral.ws, { @@ -183,7 +183,7 @@ NobleBindings.prototype.updateRssi = function(deviceUuid) { }); }; -NobleBindings.prototype.discoverServices = function(deviceUuid, uuids) { +NobleBindings.prototype.discoverServices = function (deviceUuid, uuids) { var peripheral = this._peripherals[deviceUuid]; this._sendCommand(peripheral.ws, { @@ -193,7 +193,7 @@ NobleBindings.prototype.discoverServices = function(deviceUuid, uuids) { }); }; -NobleBindings.prototype.discoverIncludedServices = function(deviceUuid, serviceUuid, serviceUuids) { +NobleBindings.prototype.discoverIncludedServices = function (deviceUuid, serviceUuid, serviceUuids) { var peripheral = this._peripherals[deviceUuid]; this._sendCommand(peripheral.ws, { @@ -204,7 +204,7 @@ NobleBindings.prototype.discoverIncludedServices = function(deviceUuid, serviceU }); }; -NobleBindings.prototype.discoverCharacteristics = function(deviceUuid, serviceUuid, characteristicUuids) { +NobleBindings.prototype.discoverCharacteristics = function (deviceUuid, serviceUuid, characteristicUuids) { var peripheral = this._peripherals[deviceUuid]; this._sendCommand(peripheral.ws, { @@ -215,7 +215,7 @@ NobleBindings.prototype.discoverCharacteristics = function(deviceUuid, serviceUu }); }; -NobleBindings.prototype.read = function(deviceUuid, serviceUuid, characteristicUuid) { +NobleBindings.prototype.read = function (deviceUuid, serviceUuid, characteristicUuid) { var peripheral = this._peripherals[deviceUuid]; this._sendCommand(peripheral.ws, { @@ -226,7 +226,7 @@ NobleBindings.prototype.read = function(deviceUuid, serviceUuid, characteristicU }); }; -NobleBindings.prototype.write = function(deviceUuid, serviceUuid, characteristicUuid, data, withoutResponse) { +NobleBindings.prototype.write = function (deviceUuid, serviceUuid, characteristicUuid, data, withoutResponse) { var peripheral = this._peripherals[deviceUuid]; this._sendCommand(peripheral.ws, { @@ -239,7 +239,7 @@ NobleBindings.prototype.write = function(deviceUuid, serviceUuid, characteristic }); }; -NobleBindings.prototype.broadcast = function(deviceUuid, serviceUuid, characteristicUuid, broadcast) { +NobleBindings.prototype.broadcast = function (deviceUuid, serviceUuid, characteristicUuid, broadcast) { var peripheral = this._peripherals[deviceUuid]; this._sendCommand(peripheral.ws, { @@ -251,7 +251,7 @@ NobleBindings.prototype.broadcast = function(deviceUuid, serviceUuid, characteri }); }; -NobleBindings.prototype.notify = function(deviceUuid, serviceUuid, characteristicUuid, notify) { +NobleBindings.prototype.notify = function (deviceUuid, serviceUuid, characteristicUuid, notify) { var peripheral = this._peripherals[deviceUuid]; this._sendCommand(peripheral.ws, { @@ -263,7 +263,7 @@ NobleBindings.prototype.notify = function(deviceUuid, serviceUuid, characteristi }); }; -NobleBindings.prototype.discoverDescriptors = function(deviceUuid, serviceUuid, characteristicUuid) { +NobleBindings.prototype.discoverDescriptors = function (deviceUuid, serviceUuid, characteristicUuid) { var peripheral = this._peripherals[deviceUuid]; this._sendCommand(peripheral.ws, { @@ -274,7 +274,7 @@ NobleBindings.prototype.discoverDescriptors = function(deviceUuid, serviceUuid, }); }; -NobleBindings.prototype.readValue = function(deviceUuid, serviceUuid, characteristicUuid, descriptorUuid) { +NobleBindings.prototype.readValue = function (deviceUuid, serviceUuid, characteristicUuid, descriptorUuid) { var peripheral = this._peripherals[deviceUuid]; this._sendCommand(peripheral.ws, { @@ -286,7 +286,7 @@ NobleBindings.prototype.readValue = function(deviceUuid, serviceUuid, characteri }); }; -NobleBindings.prototype.writeValue = function(deviceUuid, serviceUuid, characteristicUuid, descriptorUuid, data) { +NobleBindings.prototype.writeValue = function (deviceUuid, serviceUuid, characteristicUuid, descriptorUuid, data) { var peripheral = this._peripherals[deviceUuid]; this._sendCommand(peripheral.ws, { @@ -299,7 +299,7 @@ NobleBindings.prototype.writeValue = function(deviceUuid, serviceUuid, character }); }; -NobleBindings.prototype.readHandle = function(deviceUuid, handle) { +NobleBindings.prototype.readHandle = function (deviceUuid, handle) { var peripheral = this._peripherals[deviceUuid]; this._sendCommand(peripheral.ws, { @@ -309,7 +309,7 @@ NobleBindings.prototype.readHandle = function(deviceUuid, handle) { }); }; -NobleBindings.prototype.writeHandle = function(deviceUuid, handle, data, withoutResponse) { +NobleBindings.prototype.writeHandle = function (deviceUuid, handle, data, withoutResponse) { var peripheral = this._peripherals[deviceUuid]; this._sendCommand(peripheral.ws, { diff --git a/lib/hci-socket/acl-stream.js b/lib/hci-socket/acl-stream.js index 6720f832f..852622ef5 100644 --- a/lib/hci-socket/acl-stream.js +++ b/lib/hci-socket/acl-stream.js @@ -3,7 +3,7 @@ var util = require('util'); var Smp = require('./smp'); -var AclStream = function(hci, handle, localAddressType, localAddress, remoteAddressType, remoteAddress) { +var AclStream = function (hci, handle, localAddressType, localAddress, remoteAddressType, remoteAddress) { this._hci = hci; this._handle = handle; @@ -20,15 +20,15 @@ var AclStream = function(hci, handle, localAddressType, localAddress, remoteAddr util.inherits(AclStream, events.EventEmitter); -AclStream.prototype.encrypt = function() { +AclStream.prototype.encrypt = function () { this._smp.sendPairingRequest(); }; -AclStream.prototype.write = function(cid, data) { +AclStream.prototype.write = function (cid, data) { this._hci.writeAclDataPkt(this._handle, cid, data); }; -AclStream.prototype.push = function(cid, data) { +AclStream.prototype.push = function (cid, data) { if (data) { this.emit('data', cid, data); } else { @@ -36,22 +36,22 @@ AclStream.prototype.push = function(cid, data) { } }; -AclStream.prototype.pushEncrypt = function(encrypt) { +AclStream.prototype.pushEncrypt = function (encrypt) { this.emit('encrypt', encrypt); }; -AclStream.prototype.onSmpStk = function(stk) { +AclStream.prototype.onSmpStk = function (stk) { var random = new Buffer('0000000000000000', 'hex'); var diversifier = new Buffer('0000', 'hex'); this._hci.startLeEncryption(this._handle, random, diversifier, stk); }; -AclStream.prototype.onSmpFail = function() { +AclStream.prototype.onSmpFail = function () { this.emit('encryptFail'); }; -AclStream.prototype.onSmpEnd = function() { +AclStream.prototype.onSmpEnd = function () { this._smp.removeListener('stk', this.onSmpStkBinded); this._smp.removeListener('fail', this.onSmpFailBinded); this._smp.removeListener('end', this.onSmpEndBinded); diff --git a/lib/hci-socket/bindings.js b/lib/hci-socket/bindings.js index e361b20f7..542af9b3b 100644 --- a/lib/hci-socket/bindings.js +++ b/lib/hci-socket/bindings.js @@ -8,7 +8,7 @@ var Hci = require('./hci'); var Signaling = require('./signaling'); -var NobleBindings = function(options) { +var NobleBindings = function (options) { this._state = null; this._addresses = {}; @@ -30,21 +30,21 @@ var NobleBindings = function(options) { util.inherits(NobleBindings, events.EventEmitter); -NobleBindings.prototype.setScanParameters = function(interval, window) { +NobleBindings.prototype.setScanParameters = function (interval, window) { this._gap.setScanParameters(interval, window); } -NobleBindings.prototype.startScanning = function(serviceUuids, allowDuplicates) { +NobleBindings.prototype.startScanning = function (serviceUuids, allowDuplicates) { this._scanServiceUuids = serviceUuids || []; this._gap.startScanning(allowDuplicates); }; -NobleBindings.prototype.stopScanning = function() { +NobleBindings.prototype.stopScanning = function () { this._gap.stopScanning(); }; -NobleBindings.prototype.connect = function(peripheralUuid, parameters) { +NobleBindings.prototype.connect = function (peripheralUuid, parameters) { var address = this._addresses[peripheralUuid]; var addressType = this._addresseTypes[peripheralUuid]; @@ -57,21 +57,21 @@ NobleBindings.prototype.connect = function(peripheralUuid, parameters) { } }; -NobleBindings.prototype.cancelConnect = function(peripheralUuid) { +NobleBindings.prototype.cancelConnect = function (peripheralUuid) { // TODO: check if it was not in the queue and only then issue cancel on hci this._connectionQueue = this._connectionQueue.filter( c => c.id !== peripheralUuid ); this._hci.cancelConnect(this._handles[peripheralUuid]); }; -NobleBindings.prototype.disconnect = function(peripheralUuid) { +NobleBindings.prototype.disconnect = function (peripheralUuid) { this._hci.disconnect(this._handles[peripheralUuid]); }; -NobleBindings.prototype.updateRssi = function(peripheralUuid) { +NobleBindings.prototype.updateRssi = function (peripheralUuid) { this._hci.readRssi(this._handles[peripheralUuid]); }; -NobleBindings.prototype.init = function() { +NobleBindings.prototype.init = function () { this.onSigIntBinded = this.onSigInt.bind(this); this._gap.on('scanParametersSet', this.onScanParametersSet.bind(this)); @@ -97,7 +97,7 @@ NobleBindings.prototype.init = function() { process.on('exit', this.onExit.bind(this)); }; -NobleBindings.prototype.onSigInt = function() { +NobleBindings.prototype.onSigInt = function () { var sigIntListeners = process.listeners('SIGINT'); if (sigIntListeners[sigIntListeners.length - 1] === this.onSigIntBinded) { @@ -107,7 +107,7 @@ NobleBindings.prototype.onSigInt = function() { } }; -NobleBindings.prototype.onExit = function() { +NobleBindings.prototype.onExit = function () { this.stopScanning(); for (var handle in this._aclStreams) { @@ -115,13 +115,12 @@ NobleBindings.prototype.onExit = function() { } }; -NobleBindings.prototype.onStateChange = function(state) { +NobleBindings.prototype.onStateChange = function (state) { if (this._state === state) { return; } this._state = state; - if (state === 'unauthorized') { console.log('noble warning: adapter state unauthorized, please run as root or with sudo'); console.log(' or see README for information on running without root/sudo:'); @@ -135,23 +134,23 @@ NobleBindings.prototype.onStateChange = function(state) { this.emit('stateChange', state); }; -NobleBindings.prototype.onAddressChange = function(address) { +NobleBindings.prototype.onAddressChange = function (address) { this.emit('addressChange', address); }; -NobleBindings.prototype.onScanParametersSet = function() { +NobleBindings.prototype.onScanParametersSet = function () { this.emit('scanParametersSet'); }; -NobleBindings.prototype.onScanStart = function(filterDuplicates) { +NobleBindings.prototype.onScanStart = function (filterDuplicates) { this.emit('scanStart', filterDuplicates); }; -NobleBindings.prototype.onScanStop = function() { +NobleBindings.prototype.onScanStop = function () { this.emit('scanStop'); }; -NobleBindings.prototype.onDiscover = function(status, address, addressType, connectable, advertisement, rssi) { +NobleBindings.prototype.onDiscover = function (status, address, addressType, connectable, advertisement, rssi) { if (this._scanServiceUuids === undefined) { return; } @@ -188,7 +187,7 @@ NobleBindings.prototype.onDiscover = function(status, address, addressType, conn } }; -NobleBindings.prototype.onLeConnComplete = function(status, handle, role, addressType, address, interval, latency, supervisionTimeout, masterClockAccuracy) { +NobleBindings.prototype.onLeConnComplete = function (status, handle, role, addressType, address, interval, latency, supervisionTimeout, masterClockAccuracy) { var uuid = null; var error = null; @@ -252,11 +251,11 @@ NobleBindings.prototype.onLeConnComplete = function(status, handle, role, addres } }; -NobleBindings.prototype.onLeConnUpdateComplete = function(handle, interval, latency, supervisionTimeout) { +NobleBindings.prototype.onLeConnUpdateComplete = function (handle, interval, latency, supervisionTimeout) { // no-op }; -NobleBindings.prototype.onDisconnComplete = function(handle, reason) { +NobleBindings.prototype.onDisconnComplete = function (handle, reason) { var uuid = this._handles[handle]; if (uuid) { @@ -278,7 +277,7 @@ NobleBindings.prototype.onDisconnComplete = function(handle, reason) { } }; -NobleBindings.prototype.onEncryptChange = function(handle, encrypt) { +NobleBindings.prototype.onEncryptChange = function (handle, encrypt) { var aclStream = this._aclStreams[handle]; if (aclStream) { @@ -286,18 +285,17 @@ NobleBindings.prototype.onEncryptChange = function(handle, encrypt) { } }; -NobleBindings.prototype.onMtu = function(address, mtu) { +NobleBindings.prototype.onMtu = function (address, mtu) { var uuid = address.split(':').join('').toLowerCase(); this.emit('onMtu', uuid, mtu); }; -NobleBindings.prototype.onRssiRead = function(handle, rssi) { +NobleBindings.prototype.onRssiRead = function (handle, rssi) { this.emit('rssiUpdate', this._handles[handle], rssi); }; - -NobleBindings.prototype.onAclDataPkt = function(handle, cid, data) { +NobleBindings.prototype.onAclDataPkt = function (handle, cid, data) { var aclStream = this._aclStreams[handle]; if (aclStream) { @@ -305,7 +303,7 @@ NobleBindings.prototype.onAclDataPkt = function(handle, cid, data) { } }; -NobleBindings.prototype.addService = function(peripheralUuid, service) { +NobleBindings.prototype.addService = function (peripheralUuid, service) { var handle = this._handles[peripheralUuid]; var gatt = this._gatts[handle]; @@ -316,7 +314,7 @@ NobleBindings.prototype.addService = function(peripheralUuid, service) { } }; -NobleBindings.prototype.discoverServices = function(peripheralUuid, uuids) { +NobleBindings.prototype.discoverServices = function (peripheralUuid, uuids) { var handle = this._handles[peripheralUuid]; var gatt = this._gatts[handle]; @@ -327,19 +325,19 @@ NobleBindings.prototype.discoverServices = function(peripheralUuid, uuids) { } }; -NobleBindings.prototype.onServicesDiscovered = function(address, serviceUuids) { +NobleBindings.prototype.onServicesDiscovered = function (address, serviceUuids) { var uuid = address.split(':').join('').toLowerCase(); this.emit('servicesDiscover', uuid, serviceUuids); }; -NobleBindings.prototype.onServicesDiscoveredEX = function(address, services) { +NobleBindings.prototype.onServicesDiscoveredEX = function (address, services) { var uuid = address.split(':').join('').toLowerCase(); this.emit('servicesDiscovered', uuid, services); }; -NobleBindings.prototype.discoverIncludedServices = function(peripheralUuid, serviceUuid, serviceUuids) { +NobleBindings.prototype.discoverIncludedServices = function (peripheralUuid, serviceUuid, serviceUuids) { var handle = this._handles[peripheralUuid]; var gatt = this._gatts[handle]; @@ -350,13 +348,13 @@ NobleBindings.prototype.discoverIncludedServices = function(peripheralUuid, serv } }; -NobleBindings.prototype.onIncludedServicesDiscovered = function(address, serviceUuid, includedServiceUuids) { +NobleBindings.prototype.onIncludedServicesDiscovered = function (address, serviceUuid, includedServiceUuids) { var uuid = address.split(':').join('').toLowerCase(); this.emit('includedServicesDiscover', uuid, serviceUuid, includedServiceUuids); }; -NobleBindings.prototype.addCharacteristics = function(peripheralUuid, serviceUuid, characteristics) { +NobleBindings.prototype.addCharacteristics = function (peripheralUuid, serviceUuid, characteristics) { var handle = this._handles[peripheralUuid]; var gatt = this._gatts[handle]; @@ -367,7 +365,7 @@ NobleBindings.prototype.addCharacteristics = function(peripheralUuid, serviceUui } }; -NobleBindings.prototype.discoverCharacteristics = function(peripheralUuid, serviceUuid, characteristicUuids) { +NobleBindings.prototype.discoverCharacteristics = function (peripheralUuid, serviceUuid, characteristicUuids) { var handle = this._handles[peripheralUuid]; var gatt = this._gatts[handle]; @@ -378,19 +376,19 @@ NobleBindings.prototype.discoverCharacteristics = function(peripheralUuid, servi } }; -NobleBindings.prototype.onCharacteristicsDiscovered = function(address, serviceUuid, characteristics) { +NobleBindings.prototype.onCharacteristicsDiscovered = function (address, serviceUuid, characteristics) { var uuid = address.split(':').join('').toLowerCase(); this.emit('characteristicsDiscover', uuid, serviceUuid, characteristics); }; -NobleBindings.prototype.onCharacteristicsDiscoveredEX = function(address, serviceUuid, characteristics) { +NobleBindings.prototype.onCharacteristicsDiscoveredEX = function (address, serviceUuid, characteristics) { var uuid = address.split(':').join('').toLowerCase(); this.emit('characteristicsDiscovered', uuid, serviceUuid, characteristics); }; -NobleBindings.prototype.read = function(peripheralUuid, serviceUuid, characteristicUuid) { +NobleBindings.prototype.read = function (peripheralUuid, serviceUuid, characteristicUuid) { var handle = this._handles[peripheralUuid]; var gatt = this._gatts[handle]; @@ -401,13 +399,13 @@ NobleBindings.prototype.read = function(peripheralUuid, serviceUuid, characteris } }; -NobleBindings.prototype.onRead = function(address, serviceUuid, characteristicUuid, data) { +NobleBindings.prototype.onRead = function (address, serviceUuid, characteristicUuid, data) { var uuid = address.split(':').join('').toLowerCase(); this.emit('read', uuid, serviceUuid, characteristicUuid, data, false); }; -NobleBindings.prototype.write = function(peripheralUuid, serviceUuid, characteristicUuid, data, withoutResponse) { +NobleBindings.prototype.write = function (peripheralUuid, serviceUuid, characteristicUuid, data, withoutResponse) { var handle = this._handles[peripheralUuid]; var gatt = this._gatts[handle]; @@ -418,13 +416,13 @@ NobleBindings.prototype.write = function(peripheralUuid, serviceUuid, characteri } }; -NobleBindings.prototype.onWrite = function(address, serviceUuid, characteristicUuid) { +NobleBindings.prototype.onWrite = function (address, serviceUuid, characteristicUuid) { var uuid = address.split(':').join('').toLowerCase(); this.emit('write', uuid, serviceUuid, characteristicUuid); }; -NobleBindings.prototype.broadcast = function(peripheralUuid, serviceUuid, characteristicUuid, broadcast) { +NobleBindings.prototype.broadcast = function (peripheralUuid, serviceUuid, characteristicUuid, broadcast) { var handle = this._handles[peripheralUuid]; var gatt = this._gatts[handle]; @@ -435,13 +433,13 @@ NobleBindings.prototype.broadcast = function(peripheralUuid, serviceUuid, charac } }; -NobleBindings.prototype.onBroadcast = function(address, serviceUuid, characteristicUuid, state) { +NobleBindings.prototype.onBroadcast = function (address, serviceUuid, characteristicUuid, state) { var uuid = address.split(':').join('').toLowerCase(); this.emit('broadcast', uuid, serviceUuid, characteristicUuid, state); }; -NobleBindings.prototype.notify = function(peripheralUuid, serviceUuid, characteristicUuid, notify) { +NobleBindings.prototype.notify = function (peripheralUuid, serviceUuid, characteristicUuid, notify) { var handle = this._handles[peripheralUuid]; var gatt = this._gatts[handle]; @@ -452,19 +450,19 @@ NobleBindings.prototype.notify = function(peripheralUuid, serviceUuid, character } }; -NobleBindings.prototype.onNotify = function(address, serviceUuid, characteristicUuid, state) { +NobleBindings.prototype.onNotify = function (address, serviceUuid, characteristicUuid, state) { var uuid = address.split(':').join('').toLowerCase(); this.emit('notify', uuid, serviceUuid, characteristicUuid, state); }; -NobleBindings.prototype.onNotification = function(address, serviceUuid, characteristicUuid, data) { +NobleBindings.prototype.onNotification = function (address, serviceUuid, characteristicUuid, data) { var uuid = address.split(':').join('').toLowerCase(); this.emit('read', uuid, serviceUuid, characteristicUuid, data, true); }; -NobleBindings.prototype.discoverDescriptors = function(peripheralUuid, serviceUuid, characteristicUuid) { +NobleBindings.prototype.discoverDescriptors = function (peripheralUuid, serviceUuid, characteristicUuid) { var handle = this._handles[peripheralUuid]; var gatt = this._gatts[handle]; @@ -475,13 +473,13 @@ NobleBindings.prototype.discoverDescriptors = function(peripheralUuid, serviceUu } }; -NobleBindings.prototype.onDescriptorsDiscovered = function(address, serviceUuid, characteristicUuid, descriptorUuids) { +NobleBindings.prototype.onDescriptorsDiscovered = function (address, serviceUuid, characteristicUuid, descriptorUuids) { var uuid = address.split(':').join('').toLowerCase(); this.emit('descriptorsDiscover', uuid, serviceUuid, characteristicUuid, descriptorUuids); }; -NobleBindings.prototype.readValue = function(peripheralUuid, serviceUuid, characteristicUuid, descriptorUuid) { +NobleBindings.prototype.readValue = function (peripheralUuid, serviceUuid, characteristicUuid, descriptorUuid) { var handle = this._handles[peripheralUuid]; var gatt = this._gatts[handle]; @@ -492,13 +490,13 @@ NobleBindings.prototype.readValue = function(peripheralUuid, serviceUuid, charac } }; -NobleBindings.prototype.onValueRead = function(address, serviceUuid, characteristicUuid, descriptorUuid, data) { +NobleBindings.prototype.onValueRead = function (address, serviceUuid, characteristicUuid, descriptorUuid, data) { var uuid = address.split(':').join('').toLowerCase(); this.emit('valueRead', uuid, serviceUuid, characteristicUuid, descriptorUuid, data); }; -NobleBindings.prototype.writeValue = function(peripheralUuid, serviceUuid, characteristicUuid, descriptorUuid, data) { +NobleBindings.prototype.writeValue = function (peripheralUuid, serviceUuid, characteristicUuid, descriptorUuid, data) { var handle = this._handles[peripheralUuid]; var gatt = this._gatts[handle]; @@ -509,13 +507,13 @@ NobleBindings.prototype.writeValue = function(peripheralUuid, serviceUuid, chara } }; -NobleBindings.prototype.onValueWrite = function(address, serviceUuid, characteristicUuid, descriptorUuid) { +NobleBindings.prototype.onValueWrite = function (address, serviceUuid, characteristicUuid, descriptorUuid) { var uuid = address.split(':').join('').toLowerCase(); this.emit('valueWrite', uuid, serviceUuid, characteristicUuid, descriptorUuid); }; -NobleBindings.prototype.readHandle = function(peripheralUuid, attHandle) { +NobleBindings.prototype.readHandle = function (peripheralUuid, attHandle) { var handle = this._handles[peripheralUuid]; var gatt = this._gatts[handle]; @@ -526,13 +524,13 @@ NobleBindings.prototype.readHandle = function(peripheralUuid, attHandle) { } }; -NobleBindings.prototype.onHandleRead = function(address, handle, data) { +NobleBindings.prototype.onHandleRead = function (address, handle, data) { var uuid = address.split(':').join('').toLowerCase(); this.emit('handleRead', uuid, handle, data); }; -NobleBindings.prototype.writeHandle = function(peripheralUuid, attHandle, data, withoutResponse) { +NobleBindings.prototype.writeHandle = function (peripheralUuid, attHandle, data, withoutResponse) { var handle = this._handles[peripheralUuid]; var gatt = this._gatts[handle]; @@ -543,19 +541,19 @@ NobleBindings.prototype.writeHandle = function(peripheralUuid, attHandle, data, } }; -NobleBindings.prototype.onHandleWrite = function(address, handle) { +NobleBindings.prototype.onHandleWrite = function (address, handle) { var uuid = address.split(':').join('').toLowerCase(); this.emit('handleWrite', uuid, handle); }; -NobleBindings.prototype.onHandleNotify = function(address, handle, data) { +NobleBindings.prototype.onHandleNotify = function (address, handle, data) { var uuid = address.split(':').join('').toLowerCase(); this.emit('handleNotify', uuid, handle, data); }; -NobleBindings.prototype.onConnectionParameterUpdateRequest = function(handle, minInterval, maxInterval, latency, supervisionTimeout) { +NobleBindings.prototype.onConnectionParameterUpdateRequest = function (handle, minInterval, maxInterval, latency, supervisionTimeout) { this._hci.connUpdateLe(handle, minInterval, maxInterval, latency, supervisionTimeout); }; diff --git a/lib/hci-socket/crypto.js b/lib/hci-socket/crypto.js index 148f62d7a..071f22456 100644 --- a/lib/hci-socket/crypto.js +++ b/lib/hci-socket/crypto.js @@ -1,10 +1,10 @@ var crypto = require('crypto'); -function r() { +function r () { return crypto.randomBytes(16); } -function c1(k, r, pres, preq, iat, ia, rat, ra) { +function c1 (k, r, pres, preq, iat, ia, rat, ra) { var p1 = Buffer.concat([ iat, rat, @@ -26,14 +26,14 @@ function c1(k, r, pres, preq, iat, ia, rat, ra) { return res; } -function s1(k, r1, r2) { +function s1 (k, r1, r2) { return e(k, Buffer.concat([ r2.slice(0, 8), r1.slice(0, 8) ])); } -function e(key, data) { +function e (key, data) { key = swap(key); data = swap(data); @@ -46,7 +46,7 @@ function e(key, data) { ])); } -function xor(b1, b2) { +function xor (b1, b2) { var result = new Buffer(b1.length); for (var i = 0; i < b1.length; i++) { @@ -56,7 +56,7 @@ function xor(b1, b2) { return result; } -function swap(input) { +function swap (input) { var output = new Buffer(input.length); for (var i = 0; i < output.length; i++) { diff --git a/lib/hci-socket/gap.js b/lib/hci-socket/gap.js index c8977267f..b4626b90b 100644 --- a/lib/hci-socket/gap.js +++ b/lib/hci-socket/gap.js @@ -6,7 +6,7 @@ var util = require('util'); var isChip = (os.platform() === 'linux') && (os.release().indexOf('-ntc') !== -1); -var Gap = function(hci) { +var Gap = function (hci) { this._hci = hci; this._scanState = null; @@ -27,7 +27,7 @@ Gap.prototype.setScanParameters = function (interval, window) { this._hci.setScanParameters(interval, window); } -Gap.prototype.startScanning = function(allowDuplicates) { +Gap.prototype.startScanning = function (allowDuplicates) { this._scanState = 'starting'; this._scanFilterDuplicates = !allowDuplicates; @@ -45,22 +45,22 @@ Gap.prototype.startScanning = function(allowDuplicates) { this._hci.setScanEnabled(true, this._scanFilterDuplicates); }; -Gap.prototype.stopScanning = function() { +Gap.prototype.stopScanning = function () { this._scanState = 'stopping'; this._hci.setScanEnabled(false, true); }; -Gap.prototype.onHciError = function(error) { +Gap.prototype.onHciError = function (error) { }; -Gap.prototype.onHciLeScanParametersSet = function() { +Gap.prototype.onHciLeScanParametersSet = function () { this.emit('scanParametersSet'); }; // Called when receive an event "Command Complete" for "LE Set Scan Enable" -Gap.prototype.onHciLeScanEnableSet = function(status) { +Gap.prototype.onHciLeScanEnableSet = function (status) { // Check the status we got from the command complete function. if (status !== 0) { // If it is non-zero there was an error, and we should not change @@ -80,7 +80,7 @@ Gap.prototype.onHciLeScanEnableSet = function(status) { }; // Called when we see the actual command "LE Set Scan Enable" -Gap.prototype.onLeScanEnableSetCmd = function(enable, filterDuplicates) { +Gap.prototype.onLeScanEnableSetCmd = function (enable, filterDuplicates) { // Check to see if the new settings differ from what we expect. // If we are scanning, then a change happens if the new command stops // scanning or if duplicate filtering changes. @@ -99,9 +99,9 @@ Gap.prototype.onLeScanEnableSetCmd = function(enable, filterDuplicates) { } }; -Gap.prototype.onHciLeAdvertisingReport = function(status, type, address, addressType, eir, rssi) { +Gap.prototype.onHciLeAdvertisingReport = function (status, type, address, addressType, eir, rssi) { var previouslyDiscovered = !!this._discoveries[address]; - var advertisement = previouslyDiscovered ? this._discoveries[address].advertisement : { + var advertisement = previouslyDiscovered ? this._discoveries[address].advertisement : { localName: undefined, txPowerLevel: undefined, manufacturerData: undefined, @@ -146,7 +146,7 @@ Gap.prototype.onHciLeAdvertisingReport = function(status, type, address, address var bytes = eir.slice(i + 2).slice(0, length - 1); - switch(eirType) { + switch (eirType) { case 0x02: // Incomplete List of 16-bit Service Class UUID case 0x03: // Complete List of 16-bit Service Class UUIDs for (j = 0; j < bytes.length; j += 2) { @@ -176,7 +176,7 @@ Gap.prototype.onHciLeAdvertisingReport = function(status, type, address, address advertisement.txPowerLevel = bytes.readInt8(0); break; - case 0x14: // List of 16 bit solicitation UUIDs + case 0x14: // List of 16 bit solicitation UUIDs for (j = 0; j < bytes.length; j += 2) { serviceSolicitationUuid = bytes.readUInt16LE(j).toString(16); if (advertisement.serviceSolicitationUuids.indexOf(serviceSolicitationUuid) === -1) { @@ -185,7 +185,7 @@ Gap.prototype.onHciLeAdvertisingReport = function(status, type, address, address } break; - case 0x15: // List of 128 bit solicitation UUIDs + case 0x15: // List of 128 bit solicitation UUIDs for (j = 0; j < bytes.length; j += 16) { serviceSolicitationUuid = bytes.slice(j, j + 16).toString('hex').match(/.{1,2}/g).reverse().join(''); if (advertisement.serviceSolicitationUuids.indexOf(serviceSolicitationUuid) === -1) { @@ -224,7 +224,7 @@ Gap.prototype.onHciLeAdvertisingReport = function(status, type, address, address }); break; - case 0x1f: // List of 32 bit solicitation UUIDs + case 0x1f: // List of 32 bit solicitation UUIDs for (j = 0; j < bytes.length; j += 4) { serviceSolicitationUuid = bytes.readUInt32LE(j).toString(16); if (advertisement.serviceSolicitationUuids.indexOf(serviceSolicitationUuid) === -1) { diff --git a/lib/hci-socket/gatt.js b/lib/hci-socket/gatt.js index ae0857d2c..e93d7bcf5 100644 --- a/lib/hci-socket/gatt.js +++ b/lib/hci-socket/gatt.js @@ -4,60 +4,60 @@ var events = require('events'); var util = require('util'); /* eslint-disable no-unused-vars */ -var ATT_OP_ERROR = 0x01; -var ATT_OP_MTU_REQ = 0x02; -var ATT_OP_MTU_RESP = 0x03; -var ATT_OP_FIND_INFO_REQ = 0x04; -var ATT_OP_FIND_INFO_RESP = 0x05; -var ATT_OP_READ_BY_TYPE_REQ = 0x08; -var ATT_OP_READ_BY_TYPE_RESP = 0x09; -var ATT_OP_READ_REQ = 0x0a; -var ATT_OP_READ_RESP = 0x0b; -var ATT_OP_READ_BLOB_REQ = 0x0c; -var ATT_OP_READ_BLOB_RESP = 0x0d; -var ATT_OP_READ_BY_GROUP_REQ = 0x10; -var ATT_OP_READ_BY_GROUP_RESP = 0x11; -var ATT_OP_WRITE_REQ = 0x12; -var ATT_OP_WRITE_RESP = 0x13; -var ATT_OP_PREPARE_WRITE_REQ = 0x16; -var ATT_OP_PREPARE_WRITE_RESP = 0x17; -var ATT_OP_EXECUTE_WRITE_REQ = 0x18; -var ATT_OP_EXECUTE_WRITE_RESP = 0x19; -var ATT_OP_HANDLE_NOTIFY = 0x1b; -var ATT_OP_HANDLE_IND = 0x1d; -var ATT_OP_HANDLE_CNF = 0x1e; -var ATT_OP_WRITE_CMD = 0x52; - -var ATT_ECODE_SUCCESS = 0x00; -var ATT_ECODE_INVALID_HANDLE = 0x01; -var ATT_ECODE_READ_NOT_PERM = 0x02; -var ATT_ECODE_WRITE_NOT_PERM = 0x03; -var ATT_ECODE_INVALID_PDU = 0x04; -var ATT_ECODE_AUTHENTICATION = 0x05; -var ATT_ECODE_REQ_NOT_SUPP = 0x06; -var ATT_ECODE_INVALID_OFFSET = 0x07; -var ATT_ECODE_AUTHORIZATION = 0x08; -var ATT_ECODE_PREP_QUEUE_FULL = 0x09; -var ATT_ECODE_ATTR_NOT_FOUND = 0x0a; -var ATT_ECODE_ATTR_NOT_LONG = 0x0b; -var ATT_ECODE_INSUFF_ENCR_KEY_SIZE = 0x0c; -var ATT_ECODE_INVAL_ATTR_VALUE_LEN = 0x0d; -var ATT_ECODE_UNLIKELY = 0x0e; -var ATT_ECODE_INSUFF_ENC = 0x0f; -var ATT_ECODE_UNSUPP_GRP_TYPE = 0x10; -var ATT_ECODE_INSUFF_RESOURCES = 0x11; - -var GATT_PRIM_SVC_UUID = 0x2800; -var GATT_INCLUDE_UUID = 0x2802; -var GATT_CHARAC_UUID = 0x2803; - -var GATT_CLIENT_CHARAC_CFG_UUID = 0x2902; -var GATT_SERVER_CHARAC_CFG_UUID = 0x2903; +var ATT_OP_ERROR = 0x01; +var ATT_OP_MTU_REQ = 0x02; +var ATT_OP_MTU_RESP = 0x03; +var ATT_OP_FIND_INFO_REQ = 0x04; +var ATT_OP_FIND_INFO_RESP = 0x05; +var ATT_OP_READ_BY_TYPE_REQ = 0x08; +var ATT_OP_READ_BY_TYPE_RESP = 0x09; +var ATT_OP_READ_REQ = 0x0a; +var ATT_OP_READ_RESP = 0x0b; +var ATT_OP_READ_BLOB_REQ = 0x0c; +var ATT_OP_READ_BLOB_RESP = 0x0d; +var ATT_OP_READ_BY_GROUP_REQ = 0x10; +var ATT_OP_READ_BY_GROUP_RESP = 0x11; +var ATT_OP_WRITE_REQ = 0x12; +var ATT_OP_WRITE_RESP = 0x13; +var ATT_OP_PREPARE_WRITE_REQ = 0x16; +var ATT_OP_PREPARE_WRITE_RESP = 0x17; +var ATT_OP_EXECUTE_WRITE_REQ = 0x18; +var ATT_OP_EXECUTE_WRITE_RESP = 0x19; +var ATT_OP_HANDLE_NOTIFY = 0x1b; +var ATT_OP_HANDLE_IND = 0x1d; +var ATT_OP_HANDLE_CNF = 0x1e; +var ATT_OP_WRITE_CMD = 0x52; + +var ATT_ECODE_SUCCESS = 0x00; +var ATT_ECODE_INVALID_HANDLE = 0x01; +var ATT_ECODE_READ_NOT_PERM = 0x02; +var ATT_ECODE_WRITE_NOT_PERM = 0x03; +var ATT_ECODE_INVALID_PDU = 0x04; +var ATT_ECODE_AUTHENTICATION = 0x05; +var ATT_ECODE_REQ_NOT_SUPP = 0x06; +var ATT_ECODE_INVALID_OFFSET = 0x07; +var ATT_ECODE_AUTHORIZATION = 0x08; +var ATT_ECODE_PREP_QUEUE_FULL = 0x09; +var ATT_ECODE_ATTR_NOT_FOUND = 0x0a; +var ATT_ECODE_ATTR_NOT_LONG = 0x0b; +var ATT_ECODE_INSUFF_ENCR_KEY_SIZE = 0x0c; +var ATT_ECODE_INVAL_ATTR_VALUE_LEN = 0x0d; +var ATT_ECODE_UNLIKELY = 0x0e; +var ATT_ECODE_INSUFF_ENC = 0x0f; +var ATT_ECODE_UNSUPP_GRP_TYPE = 0x10; +var ATT_ECODE_INSUFF_RESOURCES = 0x11; + +var GATT_PRIM_SVC_UUID = 0x2800; +var GATT_INCLUDE_UUID = 0x2802; +var GATT_CHARAC_UUID = 0x2803; + +var GATT_CLIENT_CHARAC_CFG_UUID = 0x2902; +var GATT_SERVER_CHARAC_CFG_UUID = 0x2903; var ATT_CID = 0x0004; /* eslint-enable no-unused-vars */ -var Gatt = function(address, aclStream) { +var Gatt = function (address, aclStream) { this._address = address; this._aclStream = aclStream; @@ -84,7 +84,7 @@ var Gatt = function(address, aclStream) { util.inherits(Gatt, events.EventEmitter); -Gatt.prototype.onAclStreamData = function(cid, data) { +Gatt.prototype.onAclStreamData = function (cid, data) { if (cid !== ATT_CID) { return; } @@ -106,7 +106,7 @@ Gatt.prototype.onAclStreamData = function(cid, data) { this.emit('handleNotify', this._address, valueHandle, valueData); if (data[0] === ATT_OP_HANDLE_IND) { - this._queueCommand(this.handleConfirmation(), null, function() { + this._queueCommand(this.handleConfirmation(), null, function () { this.emit('handleConfirmation', this._address, valueHandle); }.bind(this)); } @@ -124,7 +124,6 @@ Gatt.prototype.onAclStreamData = function(cid, data) { if (data[0] === ATT_OP_ERROR && (data[4] === ATT_ECODE_AUTHENTICATION || data[4] === ATT_ECODE_AUTHORIZATION || data[4] === ATT_ECODE_INSUFF_ENC) && this._security !== 'medium') { - this._aclStream.encrypt(); return; } @@ -135,7 +134,7 @@ Gatt.prototype.onAclStreamData = function(cid, data) { this._currentCommand = null; - while(this._commandQueue.length) { + while (this._commandQueue.length) { this._currentCommand = this._commandQueue.shift(); this.writeAtt(this._currentCommand.buffer); @@ -151,7 +150,7 @@ Gatt.prototype.onAclStreamData = function(cid, data) { } }; -Gatt.prototype.onAclStreamEncrypt = function(encrypt) { +Gatt.prototype.onAclStreamEncrypt = function (encrypt) { if (encrypt) { this._security = 'medium'; @@ -159,35 +158,35 @@ Gatt.prototype.onAclStreamEncrypt = function(encrypt) { } }; -Gatt.prototype.onAclStreamEncryptFail = function() { +Gatt.prototype.onAclStreamEncryptFail = function () { }; -Gatt.prototype.onAclStreamEnd = function() { +Gatt.prototype.onAclStreamEnd = function () { this._aclStream.removeListener('data', this.onAclStreamDataBinded); this._aclStream.removeListener('encrypt', this.onAclStreamEncryptBinded); this._aclStream.removeListener('encryptFail', this.onAclStreamEncryptFailBinded); this._aclStream.removeListener('end', this.onAclStreamEndBinded); }; -Gatt.prototype.writeAtt = function(data) { +Gatt.prototype.writeAtt = function (data) { debug(this._address + ': write: ' + data.toString('hex')); this._aclStream.write(ATT_CID, data); }; -Gatt.prototype.errorResponse = function(opcode, handle, status) { - var buf = new Buffer(5); +Gatt.prototype.errorResponse = function (opcode, handle, status) { + var buf = new Buffer(5); - buf.writeUInt8(ATT_OP_ERROR, 0); - buf.writeUInt8(opcode, 1); - buf.writeUInt16LE(handle, 2); - buf.writeUInt8(status, 4); + buf.writeUInt8(ATT_OP_ERROR, 0); + buf.writeUInt8(opcode, 1); + buf.writeUInt16LE(handle, 2); + buf.writeUInt8(status, 4); - return buf; + return buf; }; -Gatt.prototype._queueCommand = function(buffer, callback, writeCallback) { +Gatt.prototype._queueCommand = function (buffer, callback, writeCallback) { this._commandQueue.push({ buffer: buffer, callback: callback, @@ -211,7 +210,7 @@ Gatt.prototype._queueCommand = function(buffer, callback, writeCallback) { } }; -Gatt.prototype.mtuRequest = function(mtu) { +Gatt.prototype.mtuRequest = function (mtu) { var buf = new Buffer(3); buf.writeUInt8(ATT_OP_MTU_REQ, 0); @@ -220,7 +219,7 @@ Gatt.prototype.mtuRequest = function(mtu) { return buf; }; -Gatt.prototype.readByGroupRequest = function(startHandle, endHandle, groupUuid) { +Gatt.prototype.readByGroupRequest = function (startHandle, endHandle, groupUuid) { var buf = new Buffer(7); buf.writeUInt8(ATT_OP_READ_BY_GROUP_REQ, 0); @@ -231,7 +230,7 @@ Gatt.prototype.readByGroupRequest = function(startHandle, endHandle, groupUuid) return buf; }; -Gatt.prototype.readByTypeRequest = function(startHandle, endHandle, groupUuid) { +Gatt.prototype.readByTypeRequest = function (startHandle, endHandle, groupUuid) { var buf = new Buffer(7); buf.writeUInt8(ATT_OP_READ_BY_TYPE_REQ, 0); @@ -242,7 +241,7 @@ Gatt.prototype.readByTypeRequest = function(startHandle, endHandle, groupUuid) { return buf; }; -Gatt.prototype.readRequest = function(handle) { +Gatt.prototype.readRequest = function (handle) { var buf = new Buffer(3); buf.writeUInt8(ATT_OP_READ_REQ, 0); @@ -251,7 +250,7 @@ Gatt.prototype.readRequest = function(handle) { return buf; }; -Gatt.prototype.readBlobRequest = function(handle, offset) { +Gatt.prototype.readBlobRequest = function (handle, offset) { var buf = new Buffer(5); buf.writeUInt8(ATT_OP_READ_BLOB_REQ, 0); @@ -261,7 +260,7 @@ Gatt.prototype.readBlobRequest = function(handle, offset) { return buf; }; -Gatt.prototype.findInfoRequest = function(startHandle, endHandle) { +Gatt.prototype.findInfoRequest = function (startHandle, endHandle) { var buf = new Buffer(5); buf.writeUInt8(ATT_OP_FIND_INFO_REQ, 0); @@ -271,10 +270,10 @@ Gatt.prototype.findInfoRequest = function(startHandle, endHandle) { return buf; }; -Gatt.prototype.writeRequest = function(handle, data, withoutResponse) { +Gatt.prototype.writeRequest = function (handle, data, withoutResponse) { var buf = new Buffer(3 + data.length); - buf.writeUInt8(withoutResponse ? ATT_OP_WRITE_CMD : ATT_OP_WRITE_REQ , 0); + buf.writeUInt8(withoutResponse ? ATT_OP_WRITE_CMD : ATT_OP_WRITE_REQ, 0); buf.writeUInt16LE(handle, 1); for (var i = 0; i < data.length; i++) { @@ -284,7 +283,7 @@ Gatt.prototype.writeRequest = function(handle, data, withoutResponse) { return buf; }; -Gatt.prototype.prepareWriteRequest = function(handle, offset, data) { +Gatt.prototype.prepareWriteRequest = function (handle, offset, data) { var buf = new Buffer(5 + data.length); buf.writeUInt8(ATT_OP_PREPARE_WRITE_REQ, 0); @@ -298,7 +297,7 @@ Gatt.prototype.prepareWriteRequest = function(handle, offset, data) { return buf; }; -Gatt.prototype.executeWriteRequest = function(handle, cancelPreparedWrites) { +Gatt.prototype.executeWriteRequest = function (handle, cancelPreparedWrites) { var buf = new Buffer(2); buf.writeUInt8(ATT_OP_EXECUTE_WRITE_REQ, 0); @@ -307,7 +306,7 @@ Gatt.prototype.executeWriteRequest = function(handle, cancelPreparedWrites) { return buf; }; -Gatt.prototype.handleConfirmation = function() { +Gatt.prototype.handleConfirmation = function () { var buf = new Buffer(1); buf.writeUInt8(ATT_OP_HANDLE_CNF, 0); @@ -315,8 +314,8 @@ Gatt.prototype.handleConfirmation = function() { return buf; }; -Gatt.prototype.exchangeMtu = function(mtu) { - this._queueCommand(this.mtuRequest(mtu), function(data) { +Gatt.prototype.exchangeMtu = function (mtu) { + this._queueCommand(this.mtuRequest(mtu), function (data) { var opcode = data[0]; if (opcode === ATT_OP_MTU_RESP) { @@ -331,14 +330,14 @@ Gatt.prototype.exchangeMtu = function(mtu) { }.bind(this)); }; -Gatt.prototype.addService = function(service) { +Gatt.prototype.addService = function (service) { this._services[service.uuid] = service; }; -Gatt.prototype.discoverServices = function(uuids) { +Gatt.prototype.discoverServices = function (uuids) { var services = []; - var callback = function(data) { + var callback = function (data) { var opcode = data[0]; var i = 0; @@ -364,7 +363,7 @@ Gatt.prototype.discoverServices = function(uuids) { this._services[services[i].uuid] = services[i]; } - this.emit('servicesDiscovered', this._address, JSON.parse(JSON.stringify(services)) /*services*/); + this.emit('servicesDiscovered', this._address, JSON.parse(JSON.stringify(services)) /* services */); this.emit('servicesDiscover', this._address, serviceUuids); } else { this._queueCommand(this.readByGroupRequest(services[services.length - 1].endHandle + 1, 0xffff, GATT_PRIM_SVC_UUID), callback); @@ -374,11 +373,11 @@ Gatt.prototype.discoverServices = function(uuids) { this._queueCommand(this.readByGroupRequest(0x0001, 0xffff, GATT_PRIM_SVC_UUID), callback); }; -Gatt.prototype.discoverIncludedServices = function(serviceUuid, uuids) { +Gatt.prototype.discoverIncludedServices = function (serviceUuid, uuids) { var service = this._services[serviceUuid]; var includedServices = []; - var callback = function(data) { + var callback = function (data) { var opcode = data[0]; var i = 0; @@ -417,20 +416,19 @@ Gatt.prototype.addCharacteristics = function (serviceUuid, characteristics) { this._characteristics[serviceUuid] = this._characteristics[serviceUuid] || {}; this._descriptors[serviceUuid] = this._descriptors[serviceUuid] || {}; - for (var i = 0; i < characteristics.length; i++) { this._characteristics[serviceUuid][characteristics[i].uuid] = characteristics[i]; } }; -Gatt.prototype.discoverCharacteristics = function(serviceUuid, characteristicUuids) { +Gatt.prototype.discoverCharacteristics = function (serviceUuid, characteristicUuids) { var service = this._services[serviceUuid]; var characteristics = []; this._characteristics[serviceUuid] = this._characteristics[serviceUuid] || {}; this._descriptors[serviceUuid] = this._descriptors[serviceUuid] || {}; - var callback = function(data) { + var callback = function (data) { var opcode = data[0]; var i = 0; @@ -449,7 +447,6 @@ Gatt.prototype.discoverCharacteristics = function(serviceUuid, characteristicUui } if (opcode !== ATT_OP_READ_BY_TYPE_RESP || characteristics[characteristics.length - 1].valueHandle === service.endHandle) { - var characteristicsDiscovered = []; for (i = 0; i < characteristics.length; i++) { var properties = characteristics[i].properties; @@ -520,12 +517,12 @@ Gatt.prototype.discoverCharacteristics = function(serviceUuid, characteristicUui this._queueCommand(this.readByTypeRequest(service.startHandle, service.endHandle, GATT_CHARAC_UUID), callback); }; -Gatt.prototype.read = function(serviceUuid, characteristicUuid) { +Gatt.prototype.read = function (serviceUuid, characteristicUuid) { var characteristic = this._characteristics[serviceUuid][characteristicUuid]; var readData = new Buffer(0); - var callback = function(data) { + var callback = function (data) { var opcode = data[0]; if (opcode === ATT_OP_READ_RESP || opcode === ATT_OP_READ_BLOB_RESP) { @@ -544,17 +541,17 @@ Gatt.prototype.read = function(serviceUuid, characteristicUuid) { this._queueCommand(this.readRequest(characteristic.valueHandle), callback); }; -Gatt.prototype.write = function(serviceUuid, characteristicUuid, data, withoutResponse) { +Gatt.prototype.write = function (serviceUuid, characteristicUuid, data, withoutResponse) { var characteristic = this._characteristics[serviceUuid][characteristicUuid]; if (withoutResponse) { - this._queueCommand(this.writeRequest(characteristic.valueHandle, data, true), null, function() { + this._queueCommand(this.writeRequest(characteristic.valueHandle, data, true), null, function () { this.emit('write', this._address, serviceUuid, characteristicUuid); }.bind(this)); } else if (data.length + 3 > this._mtu) { return this.longWrite(serviceUuid, characteristicUuid, data, withoutResponse); } else { - this._queueCommand(this.writeRequest(characteristic.valueHandle, data, false), function(data) { + this._queueCommand(this.writeRequest(characteristic.valueHandle, data, false), function (data) { var opcode = data[0]; if (opcode === ATT_OP_WRITE_RESP) { @@ -565,12 +562,12 @@ Gatt.prototype.write = function(serviceUuid, characteristicUuid, data, withoutRe }; /* Perform a "long write" as described Bluetooth Spec section 4.9.4 "Write Long Characteristic Values" */ -Gatt.prototype.longWrite = function(serviceUuid, characteristicUuid, data, withoutResponse) { +Gatt.prototype.longWrite = function (serviceUuid, characteristicUuid, data, withoutResponse) { var characteristic = this._characteristics[serviceUuid][characteristicUuid]; var limit = this._mtu - 5; - var prepareWriteCallback = function(data_chunk) { - return function(resp) { + var prepareWriteCallback = function (data_chunk) { + return function (resp) { var opcode = resp[0]; if (opcode != ATT_OP_PREPARE_WRITE_RESP) { @@ -590,14 +587,14 @@ Gatt.prototype.longWrite = function(serviceUuid, characteristicUuid, data, witho var offset = 0; while (offset < data.length) { - var end = offset+limit; + var end = offset + limit; var chunk = data.slice(offset, end); this._queueCommand(this.prepareWriteRequest(characteristic.valueHandle, offset, chunk), prepareWriteCallback(chunk)); offset = end; } /* queue the execute command with a callback to emit the write signal when done */ - this._queueCommand(this.executeWriteRequest(characteristic.valueHandle), function(resp) { + this._queueCommand(this.executeWriteRequest(characteristic.valueHandle), function (resp) { var opcode = resp[0]; if (opcode === ATT_OP_EXECUTE_WRITE_RESP && !withoutResponse) { @@ -606,10 +603,10 @@ Gatt.prototype.longWrite = function(serviceUuid, characteristicUuid, data, witho }.bind(this)); }; -Gatt.prototype.broadcast = function(serviceUuid, characteristicUuid, broadcast) { +Gatt.prototype.broadcast = function (serviceUuid, characteristicUuid, broadcast) { var characteristic = this._characteristics[serviceUuid][characteristicUuid]; - this._queueCommand(this.readByTypeRequest(characteristic.startHandle, characteristic.endHandle, GATT_SERVER_CHARAC_CFG_UUID), function(data) { + this._queueCommand(this.readByTypeRequest(characteristic.startHandle, characteristic.endHandle, GATT_SERVER_CHARAC_CFG_UUID), function (data) { var opcode = data[0]; if (opcode === ATT_OP_READ_BY_TYPE_RESP) { var handle = data.readUInt16LE(2); @@ -624,7 +621,7 @@ Gatt.prototype.broadcast = function(serviceUuid, characteristicUuid, broadcast) var valueBuffer = new Buffer(2); valueBuffer.writeUInt16LE(value, 0); - this._queueCommand(this.writeRequest(handle, valueBuffer, false), function(data) { + this._queueCommand(this.writeRequest(handle, valueBuffer, false), function (data) { var opcode = data[0]; if (opcode === ATT_OP_WRITE_RESP) { @@ -635,10 +632,10 @@ Gatt.prototype.broadcast = function(serviceUuid, characteristicUuid, broadcast) }.bind(this)); }; -Gatt.prototype.notify = function(serviceUuid, characteristicUuid, notify) { +Gatt.prototype.notify = function (serviceUuid, characteristicUuid, notify) { var characteristic = this._characteristics[serviceUuid][characteristicUuid]; - this._queueCommand(this.readByTypeRequest(characteristic.startHandle, characteristic.endHandle, GATT_CLIENT_CHARAC_CFG_UUID), function(data) { + this._queueCommand(this.readByTypeRequest(characteristic.startHandle, characteristic.endHandle, GATT_CLIENT_CHARAC_CFG_UUID), function (data) { var opcode = data[0]; if (opcode === ATT_OP_READ_BY_TYPE_RESP) { var handle = data.readUInt16LE(2); @@ -664,7 +661,7 @@ Gatt.prototype.notify = function(serviceUuid, characteristicUuid, notify) { var valueBuffer = new Buffer(2); valueBuffer.writeUInt16LE(value, 0); - this._queueCommand(this.writeRequest(handle, valueBuffer, false), function(data) { + this._queueCommand(this.writeRequest(handle, valueBuffer, false), function (data) { var opcode = data[0]; if (opcode === ATT_OP_WRITE_RESP) { @@ -686,13 +683,13 @@ function reverse (src) { return buffer } -Gatt.prototype.discoverDescriptors = function(serviceUuid, characteristicUuid) { +Gatt.prototype.discoverDescriptors = function (serviceUuid, characteristicUuid) { var characteristic = this._characteristics[serviceUuid][characteristicUuid]; var descriptors = []; this._descriptors[serviceUuid][characteristicUuid] = {}; - var callback = function(data) { + var callback = function (data) { var opcode = data[0]; if (opcode === ATT_OP_FIND_INFO_RESP) { @@ -738,12 +735,12 @@ Gatt.prototype.discoverDescriptors = function(serviceUuid, characteristicUuid) { this._queueCommand(this.findInfoRequest(characteristic.valueHandle + 1, characteristic.endHandle), callback); }; -Gatt.prototype.readValue = function(serviceUuid, characteristicUuid, descriptorUuid) { +Gatt.prototype.readValue = function (serviceUuid, characteristicUuid, descriptorUuid) { var descriptor = this._descriptors[serviceUuid][characteristicUuid][descriptorUuid]; var readData = new Buffer(0); - var callback = function(data) { + this._queueCommand(this.readRequest(descriptor.handle), function (data) { var opcode = data[0]; if (opcode === ATT_OP_READ_RESP || opcode === ATT_OP_READ_BLOB_RESP) { @@ -759,14 +756,12 @@ Gatt.prototype.readValue = function(serviceUuid, characteristicUuid, descriptorU this.emit('valueRead', this._address, serviceUuid, characteristicUuid, descriptorUuid, readData); } }.bind(this); - - this._queueCommand(this.readRequest(descriptor.handle), callback); }; -Gatt.prototype.writeValue = function(serviceUuid, characteristicUuid, descriptorUuid, data) { +Gatt.prototype.writeValue = function (serviceUuid, characteristicUuid, descriptorUuid, data) { var descriptor = this._descriptors[serviceUuid][characteristicUuid][descriptorUuid]; - this._queueCommand(this.writeRequest(descriptor.handle, data, false), function(data) { + this._queueCommand(this.writeRequest(descriptor.handle, data, false), function (data) { var opcode = data[0]; if (opcode === ATT_OP_WRITE_RESP) { @@ -775,8 +770,8 @@ Gatt.prototype.writeValue = function(serviceUuid, characteristicUuid, descriptor }.bind(this)); }; -Gatt.prototype.readHandle = function(handle) { - this._queueCommand(this.readRequest(handle), function(data) { +Gatt.prototype.readHandle = function (handle) { + this._queueCommand(this.readRequest(handle), function (data) { var opcode = data[0]; if (opcode === ATT_OP_READ_RESP) { @@ -785,13 +780,13 @@ Gatt.prototype.readHandle = function(handle) { }.bind(this)); }; -Gatt.prototype.writeHandle = function(handle, data, withoutResponse) { +Gatt.prototype.writeHandle = function (handle, data, withoutResponse) { if (withoutResponse) { - this._queueCommand(this.writeRequest(handle, data, true), null, function() { + this._queueCommand(this.writeRequest(handle, data, true), null, function () { this.emit('handleWrite', this._address, handle); }.bind(this)); } else { - this._queueCommand(this.writeRequest(handle, data, false), function(data) { + this._queueCommand(this.writeRequest(handle, data, false), function (data) { var opcode = data[0]; if (opcode === ATT_OP_WRITE_RESP) { diff --git a/lib/hci-socket/hci.js b/lib/hci-socket/hci.js index 0e1c5a1a0..e5e062175 100644 --- a/lib/hci-socket/hci.js +++ b/lib/hci-socket/hci.js @@ -10,7 +10,7 @@ var HCI_ACLDATA_PKT = 0x02; var HCI_EVENT_PKT = 0x04; var ACL_START_NO_FLUSH = 0x00; -var ACL_CONT = 0x01; +var ACL_CONT = 0x01; var ACL_START = 0x02; var EVT_DISCONN_COMPLETE = 0x05; @@ -32,7 +32,6 @@ var OCF_RESET = 0x0003; var OCF_READ_LE_HOST_SUPPORTED = 0x006C; var OCF_WRITE_LE_HOST_SUPPORTED = 0x006D; - var OGF_INFO_PARAM = 0x04; var OCF_READ_LOCAL_VERSION = 0x0001; var OCF_READ_BD_ADDR = 0x0009; @@ -73,7 +72,7 @@ var HCI_OE_USER_ENDED_CONNECTION = 0x13; var STATUS_MAPPER = require('./hci-status'); -var Hci = function(options) { +var Hci = function (options) { options = options || {}; this._socket = new BluetoothHciSocket(); this._isDevUp = null; @@ -82,7 +81,7 @@ var Hci = function(options) { this._handleBuffers = {}; this._deviceId = options.deviceId != null ? parseInt(options.deviceId, 10) : - process.env.NOBLE_HCI_DEVICE_ID ? parseInt(process.env.NOBLE_HCI_DEVICE_ID, 10) : + process.env.NOBLE_HCI_DEVICE_ID ? parseInt(process.env.NOBLE_HCI_DEVICE_ID, 10) : undefined; this._userChannel = typeof options.userChannel === 'undefined' && process.env.HCI_CHANNEL_USER || options.userChannel; @@ -94,7 +93,7 @@ util.inherits(Hci, events.EventEmitter); Hci.STATUS_MAPPER = STATUS_MAPPER; -Hci.prototype.init = function(options) { +Hci.prototype.init = function (options) { this._socket.on('data', this.onSocketData.bind(this)); this._socket.on('error', this.onSocketError.bind(this)); @@ -111,7 +110,7 @@ Hci.prototype.init = function(options) { } }; -Hci.prototype.pollIsDevUp = function() { +Hci.prototype.pollIsDevUp = function () { var isDevUp = this._socket.isDevUp(); if (this._isDevUp !== isDevUp) { @@ -133,7 +132,7 @@ Hci.prototype.pollIsDevUp = function() { setTimeout(this.pollIsDevUp.bind(this), 1000); }; -Hci.prototype.setSocketFilter = function() { +Hci.prototype.setSocketFilter = function () { var filter = new Buffer(14); var typeMask = (1 << HCI_COMMAND_PKT) | (1 << HCI_EVENT_PKT) | (1 << HCI_ACLDATA_PKT); var eventMask1 = (1 << EVT_DISCONN_COMPLETE) | (1 << EVT_ENCRYPT_CHANGE) | (1 << EVT_CMD_COMPLETE) | (1 << EVT_CMD_STATUS); @@ -149,7 +148,7 @@ Hci.prototype.setSocketFilter = function() { this._socket.setFilter(filter); }; -Hci.prototype.setEventMask = function() { +Hci.prototype.setEventMask = function () { var cmd = new Buffer(12); var eventMask = new Buffer('fffffbff07f8bf3d', 'hex'); @@ -166,8 +165,8 @@ Hci.prototype.setEventMask = function() { this._socket.write(cmd); }; -Hci.prototype.reset = function() { - var cmd = new Buffer(4); +Hci.prototype.reset = function () { + var cmd = new Buffer(4); // header cmd.writeUInt8(HCI_COMMAND_PKT, 0); @@ -180,8 +179,7 @@ Hci.prototype.reset = function() { this._socket.write(cmd); }; - -Hci.prototype.readLocalVersion = function() { +Hci.prototype.readLocalVersion = function () { var cmd = new Buffer(4); // header @@ -195,7 +193,7 @@ Hci.prototype.readLocalVersion = function() { this._socket.write(cmd); }; -Hci.prototype.readBdAddr = function() { +Hci.prototype.readBdAddr = function () { var cmd = new Buffer(4); // header @@ -209,7 +207,7 @@ Hci.prototype.readBdAddr = function() { this._socket.write(cmd); }; -Hci.prototype.setLeEventMask = function() { +Hci.prototype.setLeEventMask = function () { var cmd = new Buffer(12); var leEventMask = new Buffer('1f00000000000000', 'hex'); @@ -226,7 +224,7 @@ Hci.prototype.setLeEventMask = function() { this._socket.write(cmd); }; -Hci.prototype.readLeHostSupported = function() { +Hci.prototype.readLeHostSupported = function () { var cmd = new Buffer(4); // header @@ -240,7 +238,7 @@ Hci.prototype.readLeHostSupported = function() { this._socket.write(cmd); }; -Hci.prototype.writeLeHostSupported = function() { +Hci.prototype.writeLeHostSupported = function () { var cmd = new Buffer(6); // header @@ -282,7 +280,7 @@ Hci.prototype.setScanParameters = function (interval, window) { this._socket.write(cmd); }; -Hci.prototype.setScanEnabled = function(enabled, filterDuplicates) { +Hci.prototype.setScanEnabled = function (enabled, filterDuplicates) { var cmd = new Buffer(6); // header @@ -300,7 +298,7 @@ Hci.prototype.setScanEnabled = function(enabled, filterDuplicates) { this._socket.write(cmd); }; -Hci.prototype.createLeConn = function(address, addressType, parameters) { +Hci.prototype.createLeConn = function (address, addressType, parameters) { var minInterval = parameters && parameters.minInterval || 0x0006; var maxInterval = parameters && parameters.maxInterval || 0x000c; var latency = parameters && parameters.latency || 0x0000; @@ -336,7 +334,7 @@ Hci.prototype.createLeConn = function(address, addressType, parameters) { this._socket.write(cmd); }; -Hci.prototype.connUpdateLe = function(handle, minInterval, maxInterval, latency, supervisionTimeout) { +Hci.prototype.connUpdateLe = function (handle, minInterval, maxInterval, latency, supervisionTimeout) { var cmd = new Buffer(18); // header @@ -359,7 +357,7 @@ Hci.prototype.connUpdateLe = function(handle, minInterval, maxInterval, latency, this._socket.write(cmd); }; -Hci.prototype.cancelConnect = function() { +Hci.prototype.cancelConnect = function () { var cmd = new Buffer(4); // header @@ -373,7 +371,7 @@ Hci.prototype.cancelConnect = function() { this._socket.write(cmd); }; -Hci.prototype.startLeEncryption = function(handle, random, diversifier, key) { +Hci.prototype.startLeEncryption = function (handle, random, diversifier, key) { var cmd = new Buffer(32); // header @@ -393,7 +391,7 @@ Hci.prototype.startLeEncryption = function(handle, random, diversifier, key) { this._socket.write(cmd); }; -Hci.prototype.disconnect = function(handle, reason) { +Hci.prototype.disconnect = function (handle, reason) { var cmd = new Buffer(7); reason = reason || HCI_OE_USER_ENDED_CONNECTION; @@ -413,7 +411,7 @@ Hci.prototype.disconnect = function(handle, reason) { this._socket.write(cmd); }; -Hci.prototype.readRssi = function(handle) { +Hci.prototype.readRssi = function (handle) { var cmd = new Buffer(6); // header @@ -430,7 +428,7 @@ Hci.prototype.readRssi = function(handle) { this._socket.write(cmd); }; -Hci.prototype.writeAclDataPkt = function(handle, cid, data) { +Hci.prototype.writeAclDataPkt = function (handle, cid, data) { var pkt = new Buffer(9 + data.length); // header @@ -446,7 +444,7 @@ Hci.prototype.writeAclDataPkt = function(handle, cid, data) { this._socket.write(pkt); }; -Hci.prototype.onSocketData = function(data) { +Hci.prototype.onSocketData = function (data) { debug('onSocketData: ' + data.toString('hex')); var eventType = data.readUInt8(0); @@ -462,7 +460,7 @@ Hci.prototype.onSocketData = function(data) { debug('\tsub event type = ' + subEventType); if (subEventType === EVT_DISCONN_COMPLETE) { - handle = data.readUInt16LE(4); + handle = data.readUInt16LE(4); var reason = data.readUInt8(6); debug('\t\thandle = ' + handle); @@ -470,7 +468,7 @@ Hci.prototype.onSocketData = function(data) { this.emit('disconnComplete', handle, reason); } else if (subEventType === EVT_ENCRYPT_CHANGE) { - handle = data.readUInt16LE(4); + handle = data.readUInt16LE(4); var encrypt = data.readUInt8(6); debug('\t\thandle = ' + handle); @@ -566,7 +564,7 @@ Hci.prototype.onSocketData = function(data) { } }; -Hci.prototype.onSocketError = function(error) { +Hci.prototype.onSocketError = function (error) { debug('onSocketError: ' + error.message); if (error.message === 'Operation not permitted') { @@ -576,7 +574,7 @@ Hci.prototype.onSocketError = function(error) { } }; -Hci.prototype.processCmdCompleteEvent = function(cmd, status, result) { +Hci.prototype.processCmdCompleteEvent = function (cmd, status, result) { if (cmd === RESET_CMD) { this.setEventMask(); this.setLeEventMask(); @@ -629,7 +627,7 @@ Hci.prototype.processCmdCompleteEvent = function(cmd, status, result) { } }; -Hci.prototype.processLeMetaEvent = function(eventType, status, data) { +Hci.prototype.processLeMetaEvent = function (eventType, status, data) { if (eventType === EVT_LE_CONN_COMPLETE) { this.processLeConnComplete(status, data); } else if (eventType === EVT_LE_ADVERTISING_REPORT) { @@ -639,10 +637,10 @@ Hci.prototype.processLeMetaEvent = function(eventType, status, data) { } }; -Hci.prototype.processLeConnComplete = function(status, data) { +Hci.prototype.processLeConnComplete = function (status, data) { var handle = data.readUInt16LE(0); var role = data.readUInt8(2); - var addressType = data.readUInt8(3) === 0x01 ? 'random': 'public'; + var addressType = data.readUInt8(3) === 0x01 ? 'random' : 'public'; var address = data.slice(4, 10).toString('hex').match(/.{1,2}/g).reverse().join(':'); var interval = data.readUInt16LE(10) * 1.25; var latency = data.readUInt16LE(12); // TODO: multiplier? @@ -661,7 +659,7 @@ Hci.prototype.processLeConnComplete = function(status, data) { this.emit('leConnComplete', status, handle, role, addressType, address, interval, latency, supervisionTimeout, masterClockAccuracy); }; -Hci.prototype.processLeAdvertisingReport = function(count, data) { +Hci.prototype.processLeAdvertisingReport = function (count, data) { try { for (var i = 0; i < count; i++) { var type = data.readUInt8(0); @@ -686,7 +684,7 @@ Hci.prototype.processLeAdvertisingReport = function(count, data) { } }; -Hci.prototype.processLeConnUpdateComplete = function(status, data) { +Hci.prototype.processLeConnUpdateComplete = function (status, data) { var handle = data.readUInt16LE(0); var interval = data.readUInt16LE(2) * 1.25; var latency = data.readUInt16LE(4); // TODO: multiplier? @@ -700,7 +698,7 @@ Hci.prototype.processLeConnUpdateComplete = function(status, data) { this.emit('leConnUpdateComplete', status, handle, interval, latency, supervisionTimeout); }; -Hci.prototype.processCmdStatusEvent = function(cmd, status) { +Hci.prototype.processCmdStatusEvent = function (cmd, status) { if (cmd === LE_CREATE_CONN_CMD) { if (status !== 0) { this.emit('leConnComplete', status); @@ -708,7 +706,7 @@ Hci.prototype.processCmdStatusEvent = function(cmd, status) { } }; -Hci.prototype.onStateChange = function(state) { +Hci.prototype.onStateChange = function (state) { this._state = state; }; diff --git a/lib/hci-socket/signaling.js b/lib/hci-socket/signaling.js index 262d3b255..b884da52e 100644 --- a/lib/hci-socket/signaling.js +++ b/lib/hci-socket/signaling.js @@ -4,12 +4,12 @@ var events = require('events'); var os = require('os'); var util = require('util'); -var CONNECTION_PARAMETER_UPDATE_REQUEST = 0x12; +var CONNECTION_PARAMETER_UPDATE_REQUEST = 0x12; var CONNECTION_PARAMETER_UPDATE_RESPONSE = 0x13; var SIGNALING_CID = 0x0005; -var Signaling = function(handle, aclStream) { +var Signaling = function (handle, aclStream) { this._handle = handle; this._aclStream = aclStream; @@ -22,7 +22,7 @@ var Signaling = function(handle, aclStream) { util.inherits(Signaling, events.EventEmitter); -Signaling.prototype.onAclStreamData = function(cid, data) { +Signaling.prototype.onAclStreamData = function (cid, data) { if (cid !== SIGNALING_CID) { return; } @@ -43,12 +43,12 @@ Signaling.prototype.onAclStreamData = function(cid, data) { } }; -Signaling.prototype.onAclStreamEnd = function() { +Signaling.prototype.onAclStreamEnd = function () { this._aclStream.removeListener('data', this.onAclStreamDataBinded); this._aclStream.removeListener('end', this.onAclStreamEndBinded); }; -Signaling.prototype.processConnectionParameterUpdateRequest = function(identifier, data) { +Signaling.prototype.processConnectionParameterUpdateRequest = function (identifier, data) { var minInterval = data.readUInt16LE(0) * 1.25; var maxInterval = data.readUInt16LE(2) * 1.25; var latency = data.readUInt16LE(4); diff --git a/lib/hci-socket/smp.js b/lib/hci-socket/smp.js index 8eb8b76c5..fa9c4e470 100644 --- a/lib/hci-socket/smp.js +++ b/lib/hci-socket/smp.js @@ -13,7 +13,7 @@ var SMP_PAIRING_FAILED = 0x05; var SMP_ENCRYPT_INFO = 0x06; var SMP_MASTER_IDENT = 0x07; -var Smp = function(aclStream, localAddressType, localAddress, remoteAddressType, remoteAddress) { +var Smp = function (aclStream, localAddressType, localAddress, remoteAddressType, remoteAddress) { this._aclStream = aclStream; this._iat = new Buffer([(localAddressType === 'random') ? 0x01 : 0x00]); @@ -30,7 +30,7 @@ var Smp = function(aclStream, localAddressType, localAddress, remoteAddressType, util.inherits(Smp, events.EventEmitter); -Smp.prototype.sendPairingRequest = function() { +Smp.prototype.sendPairingRequest = function () { this._preq = new Buffer([ SMP_PAIRING_REQUEST, 0x03, // IO capability: NoInputNoOutput @@ -38,13 +38,13 @@ Smp.prototype.sendPairingRequest = function() { 0x01, // Authentication requirement: Bonding - No MITM 0x10, // Max encryption key size 0x00, // Initiator key distribution: - 0x01 // Responder key distribution: EncKey + 0x01 // Responder key distribution: EncKey ]); this.write(this._preq); }; -Smp.prototype.onAclStreamData = function(cid, data) { +Smp.prototype.onAclStreamData = function (cid, data) { if (cid !== SMP_CID) { return; } @@ -66,14 +66,14 @@ Smp.prototype.onAclStreamData = function(cid, data) { } }; -Smp.prototype.onAclStreamEnd = function() { +Smp.prototype.onAclStreamEnd = function () { this._aclStream.removeListener('data', this.onAclStreamDataBinded); this._aclStream.removeListener('end', this.onAclStreamEndBinded); this.emit('end'); }; -Smp.prototype.handlePairingResponse = function(data) { +Smp.prototype.handlePairingResponse = function (data) { this._pres = data; this._tk = new Buffer('00000000000000000000000000000000', 'hex'); @@ -85,7 +85,7 @@ Smp.prototype.handlePairingResponse = function(data) { ])); }; -Smp.prototype.handlePairingConfirm = function(data) { +Smp.prototype.handlePairingConfirm = function (data) { this._pcnf = data; this.write(Buffer.concat([ @@ -94,7 +94,7 @@ Smp.prototype.handlePairingConfirm = function(data) { ])); }; -Smp.prototype.handlePairingRandom = function(data) { +Smp.prototype.handlePairingRandom = function (data) { var r = data.slice(1); var pcnf = Buffer.concat([ @@ -116,24 +116,24 @@ Smp.prototype.handlePairingRandom = function(data) { } }; -Smp.prototype.handlePairingFailed = function(data) { +Smp.prototype.handlePairingFailed = function (data) { this.emit('fail'); }; -Smp.prototype.handleEncryptInfo = function(data) { +Smp.prototype.handleEncryptInfo = function (data) { var ltk = data.slice(1); this.emit('ltk', ltk); }; -Smp.prototype.handleMasterIdent = function(data) { +Smp.prototype.handleMasterIdent = function (data) { var ediv = data.slice(1, 3); var rand = data.slice(3); this.emit('masterIdent', ediv, rand); }; -Smp.prototype.write = function(data) { +Smp.prototype.write = function (data) { this._aclStream.write(SMP_CID, data); }; diff --git a/lib/noble.js b/lib/noble.js index 277f0b38c..2a3e4295d 100644 --- a/lib/noble.js +++ b/lib/noble.js @@ -8,7 +8,7 @@ var Service = require('./service'); var Characteristic = require('./characteristic'); var Descriptor = require('./descriptor'); -function Noble(bindings) { +function Noble (bindings) { this.initialized = false; this.address = 'unknown'; @@ -46,24 +46,24 @@ function Noble(bindings) { this._bindings.on('handleNotify', this.onHandleNotify.bind(this)); this._bindings.on('onMtu', this.onMtu.bind(this)); - this.on('warning', function(message) { + this.on('warning', function (message) { if (this.listeners('warning').length === 1) { console.warn('noble: ' + message); } }.bind(this)); - //lazy init bindings on first new listener, should be on stateChange - this.on('newListener', function(event) { + // lazy init bindings on first new listener, should be on stateChange + this.on('newListener', function (event) { if (event === 'stateChange' && !this.initialized) { this.initialized = true; - process.nextTick(function() { + process.nextTick(function () { this._bindings.init(); }.bind(this)); } }.bind(this)); - //or lazy init bindings if someone attempts to get state first + // or lazy init bindings if someone attempts to get state first Object.defineProperties(this, { state: { get: function () { @@ -76,12 +76,11 @@ function Noble(bindings) { } } }); - } util.inherits(Noble, events.EventEmitter); -Noble.prototype.onStateChange = function(state) { +Noble.prototype.onStateChange = function (state) { debug('stateChange ' + state); this._state = state; @@ -89,26 +88,26 @@ Noble.prototype.onStateChange = function(state) { this.emit('stateChange', state); }; -Noble.prototype.onAddressChange = function(address) { +Noble.prototype.onAddressChange = function (address) { debug('addressChange ' + address); this.address = address; }; -Noble.prototype.setScanParameters = function(interval, window, callback) { +Noble.prototype.setScanParameters = function (interval, window, callback) { if (callback) { this.once('scanParametersSet', callback); } this._bindings.setScanParameters(interval, window); } -Noble.prototype.onScanParametersSet = function() { +Noble.prototype.onScanParametersSet = function () { debug('scanParametersSet'); this.emit('scanParametersSet'); }; -Noble.prototype.startScanning = function(serviceUuids, allowDuplicates, callback) { - var scan = function(state) { +Noble.prototype.startScanning = function (serviceUuids, allowDuplicates, callback) { + var scan = function (state) { if (state !== 'poweredOn') { var error = new Error('Could not start scanning, state is ' + state + ' (not poweredOn)'); @@ -119,7 +118,7 @@ Noble.prototype.startScanning = function(serviceUuids, allowDuplicates, callback } } else { if (callback) { - this.once('scanStart', function(filterDuplicates) { + this.once('scanStart', function (filterDuplicates) { callback(null, filterDuplicates); }); } @@ -131,24 +130,24 @@ Noble.prototype.startScanning = function(serviceUuids, allowDuplicates, callback } }; - //if bindings still not init, do it now + // if bindings still not init, do it now if (!this.initialized) { this.initialized = true; this._bindings.init(); this.once('stateChange', scan.bind(this)); - }else{ + } else { scan.call(this, this._state); } }; -Noble.prototype.onScanStart = function(filterDuplicates) { +Noble.prototype.onScanStart = function (filterDuplicates) { debug('scanStart'); this.emit('scanStart', filterDuplicates); }; -Noble.prototype.stopScanning = function(callback) { +Noble.prototype.stopScanning = function (callback) { if (callback) { this.once('scanStop', callback); } @@ -157,12 +156,12 @@ Noble.prototype.stopScanning = function(callback) { } }; -Noble.prototype.onScanStop = function() { +Noble.prototype.onScanStop = function () { debug('scanStop'); this.emit('scanStop'); }; -Noble.prototype.onDiscover = function(uuid, address, addressType, connectable, advertisement, rssi) { +Noble.prototype.onDiscover = function (uuid, address, addressType, connectable, advertisement, rssi) { var peripheral = this._peripherals[uuid]; if (!peripheral) { @@ -195,11 +194,11 @@ Noble.prototype.onDiscover = function(uuid, address, addressType, connectable, a } }; -Noble.prototype.connect = function(peripheralUuid, parameters) { +Noble.prototype.connect = function (peripheralUuid, parameters) { this._bindings.connect(peripheralUuid, parameters); }; -Noble.prototype.onConnect = function(peripheralUuid, error) { +Noble.prototype.onConnect = function (peripheralUuid, error) { var peripheral = this._peripherals[peripheralUuid]; if (peripheral) { @@ -210,15 +209,15 @@ Noble.prototype.onConnect = function(peripheralUuid, error) { } }; -Noble.prototype.cancelConnect = function(peripheralUuid, parameters) { +Noble.prototype.cancelConnect = function (peripheralUuid, parameters) { this._bindings.cancelConnect(peripheralUuid, parameters); }; -Noble.prototype.disconnect = function(peripheralUuid) { +Noble.prototype.disconnect = function (peripheralUuid) { this._bindings.disconnect(peripheralUuid); }; -Noble.prototype.onDisconnect = function(peripheralUuid) { +Noble.prototype.onDisconnect = function (peripheralUuid) { var peripheral = this._peripherals[peripheralUuid]; if (peripheral) { @@ -229,11 +228,11 @@ Noble.prototype.onDisconnect = function(peripheralUuid) { } }; -Noble.prototype.updateRssi = function(peripheralUuid) { +Noble.prototype.updateRssi = function (peripheralUuid) { this._bindings.updateRssi(peripheralUuid); }; -Noble.prototype.onRssiUpdate = function(peripheralUuid, rssi) { +Noble.prototype.onRssiUpdate = function (peripheralUuid, rssi) { var peripheral = this._peripherals[peripheralUuid]; if (peripheral) { @@ -282,15 +281,14 @@ Noble.prototype.addService = function (peripheralUuid, service) { Noble.prototype.onServicesDiscovered = function (peripheralUuid, services) { var peripheral = this._peripherals[peripheralUuid]; - if (peripheral) - peripheral.emit('servicesDiscovered', peripheral, services); // pass on to higher layers + if (peripheral) { peripheral.emit('servicesDiscovered', peripheral, services); } // pass on to higher layers }; -Noble.prototype.discoverServices = function(peripheralUuid, uuids) { +Noble.prototype.discoverServices = function (peripheralUuid, uuids) { this._bindings.discoverServices(peripheralUuid, uuids); }; -Noble.prototype.onServicesDiscover = function(peripheralUuid, serviceUuids) { +Noble.prototype.onServicesDiscover = function (peripheralUuid, serviceUuids) { var peripheral = this._peripherals[peripheralUuid]; if (peripheral) { @@ -315,11 +313,11 @@ Noble.prototype.onServicesDiscover = function(peripheralUuid, serviceUuids) { } }; -Noble.prototype.discoverIncludedServices = function(peripheralUuid, serviceUuid, serviceUuids) { +Noble.prototype.discoverIncludedServices = function (peripheralUuid, serviceUuid, serviceUuids) { this._bindings.discoverIncludedServices(peripheralUuid, serviceUuid, serviceUuids); }; -Noble.prototype.onIncludedServicesDiscover = function(peripheralUuid, serviceUuid, includedServiceUuids) { +Noble.prototype.onIncludedServicesDiscover = function (peripheralUuid, serviceUuid, includedServiceUuids) { var service = this._services[peripheralUuid][serviceUuid]; if (service) { @@ -369,11 +367,11 @@ Noble.prototype.onCharacteristicsDiscovered = function (peripheralUuid, serviceU service.emit('characteristicsDiscovered', characteristics); }; -Noble.prototype.discoverCharacteristics = function(peripheralUuid, serviceUuid, characteristicUuids) { +Noble.prototype.discoverCharacteristics = function (peripheralUuid, serviceUuid, characteristicUuids) { this._bindings.discoverCharacteristics(peripheralUuid, serviceUuid, characteristicUuids); }; -Noble.prototype.onCharacteristicsDiscover = function(peripheralUuid, serviceUuid, characteristics) { +Noble.prototype.onCharacteristicsDiscover = function (peripheralUuid, serviceUuid, characteristics) { var service = this._services[peripheralUuid][serviceUuid]; if (service) { @@ -383,12 +381,12 @@ Noble.prototype.onCharacteristicsDiscover = function(peripheralUuid, serviceUuid var characteristicUuid = characteristics[i].uuid; var characteristic = new Characteristic( - this, - peripheralUuid, - serviceUuid, - characteristicUuid, - characteristics[i].properties - ); + this, + peripheralUuid, + serviceUuid, + characteristicUuid, + characteristics[i].properties + ); this._characteristics[peripheralUuid][serviceUuid][characteristicUuid] = characteristic; this._descriptors[peripheralUuid][serviceUuid][characteristicUuid] = {}; @@ -404,11 +402,11 @@ Noble.prototype.onCharacteristicsDiscover = function(peripheralUuid, serviceUuid } }; -Noble.prototype.read = function(peripheralUuid, serviceUuid, characteristicUuid) { - this._bindings.read(peripheralUuid, serviceUuid, characteristicUuid); +Noble.prototype.read = function (peripheralUuid, serviceUuid, characteristicUuid) { + this._bindings.read(peripheralUuid, serviceUuid, characteristicUuid); }; -Noble.prototype.onRead = function(peripheralUuid, serviceUuid, characteristicUuid, data, isNotification) { +Noble.prototype.onRead = function (peripheralUuid, serviceUuid, characteristicUuid, data, isNotification) { var characteristic = this._characteristics[peripheralUuid][serviceUuid][characteristicUuid]; if (characteristic) { @@ -420,11 +418,11 @@ Noble.prototype.onRead = function(peripheralUuid, serviceUuid, characteristicUui } }; -Noble.prototype.write = function(peripheralUuid, serviceUuid, characteristicUuid, data, withoutResponse) { - this._bindings.write(peripheralUuid, serviceUuid, characteristicUuid, data, withoutResponse); +Noble.prototype.write = function (peripheralUuid, serviceUuid, characteristicUuid, data, withoutResponse) { + this._bindings.write(peripheralUuid, serviceUuid, characteristicUuid, data, withoutResponse); }; -Noble.prototype.onWrite = function(peripheralUuid, serviceUuid, characteristicUuid) { +Noble.prototype.onWrite = function (peripheralUuid, serviceUuid, characteristicUuid) { var characteristic = this._characteristics[peripheralUuid][serviceUuid][characteristicUuid]; if (characteristic) { @@ -434,11 +432,11 @@ Noble.prototype.onWrite = function(peripheralUuid, serviceUuid, characteristicUu } }; -Noble.prototype.broadcast = function(peripheralUuid, serviceUuid, characteristicUuid, broadcast) { - this._bindings.broadcast(peripheralUuid, serviceUuid, characteristicUuid, broadcast); +Noble.prototype.broadcast = function (peripheralUuid, serviceUuid, characteristicUuid, broadcast) { + this._bindings.broadcast(peripheralUuid, serviceUuid, characteristicUuid, broadcast); }; -Noble.prototype.onBroadcast = function(peripheralUuid, serviceUuid, characteristicUuid, state) { +Noble.prototype.onBroadcast = function (peripheralUuid, serviceUuid, characteristicUuid, state) { var characteristic = this._characteristics[peripheralUuid][serviceUuid][characteristicUuid]; if (characteristic) { @@ -448,11 +446,11 @@ Noble.prototype.onBroadcast = function(peripheralUuid, serviceUuid, characterist } }; -Noble.prototype.notify = function(peripheralUuid, serviceUuid, characteristicUuid, notify) { - this._bindings.notify(peripheralUuid, serviceUuid, characteristicUuid, notify); +Noble.prototype.notify = function (peripheralUuid, serviceUuid, characteristicUuid, notify) { + this._bindings.notify(peripheralUuid, serviceUuid, characteristicUuid, notify); }; -Noble.prototype.onNotify = function(peripheralUuid, serviceUuid, characteristicUuid, state) { +Noble.prototype.onNotify = function (peripheralUuid, serviceUuid, characteristicUuid, state) { var characteristic = this._characteristics[peripheralUuid][serviceUuid][characteristicUuid]; if (characteristic) { @@ -462,11 +460,11 @@ Noble.prototype.onNotify = function(peripheralUuid, serviceUuid, characteristicU } }; -Noble.prototype.discoverDescriptors = function(peripheralUuid, serviceUuid, characteristicUuid) { +Noble.prototype.discoverDescriptors = function (peripheralUuid, serviceUuid, characteristicUuid) { this._bindings.discoverDescriptors(peripheralUuid, serviceUuid, characteristicUuid); }; -Noble.prototype.onDescriptorsDiscover = function(peripheralUuid, serviceUuid, characteristicUuid, descriptors) { +Noble.prototype.onDescriptorsDiscover = function (peripheralUuid, serviceUuid, characteristicUuid, descriptors) { var characteristic = this._characteristics[peripheralUuid][serviceUuid][characteristicUuid]; if (characteristic) { @@ -476,12 +474,12 @@ Noble.prototype.onDescriptorsDiscover = function(peripheralUuid, serviceUuid, ch var descriptorUuid = descriptors[i]; var descriptor = new Descriptor( - this, - peripheralUuid, - serviceUuid, - characteristicUuid, - descriptorUuid - ); + this, + peripheralUuid, + serviceUuid, + characteristicUuid, + descriptorUuid + ); this._descriptors[peripheralUuid][serviceUuid][characteristicUuid][descriptorUuid] = descriptor; @@ -496,11 +494,11 @@ Noble.prototype.onDescriptorsDiscover = function(peripheralUuid, serviceUuid, ch } }; -Noble.prototype.readValue = function(peripheralUuid, serviceUuid, characteristicUuid, descriptorUuid) { +Noble.prototype.readValue = function (peripheralUuid, serviceUuid, characteristicUuid, descriptorUuid) { this._bindings.readValue(peripheralUuid, serviceUuid, characteristicUuid, descriptorUuid); }; -Noble.prototype.onValueRead = function(peripheralUuid, serviceUuid, characteristicUuid, descriptorUuid, data) { +Noble.prototype.onValueRead = function (peripheralUuid, serviceUuid, characteristicUuid, descriptorUuid, data) { var descriptor = this._descriptors[peripheralUuid][serviceUuid][characteristicUuid][descriptorUuid]; if (descriptor) { @@ -510,11 +508,11 @@ Noble.prototype.onValueRead = function(peripheralUuid, serviceUuid, characterist } }; -Noble.prototype.writeValue = function(peripheralUuid, serviceUuid, characteristicUuid, descriptorUuid, data) { +Noble.prototype.writeValue = function (peripheralUuid, serviceUuid, characteristicUuid, descriptorUuid, data) { this._bindings.writeValue(peripheralUuid, serviceUuid, characteristicUuid, descriptorUuid, data); }; -Noble.prototype.onValueWrite = function(peripheralUuid, serviceUuid, characteristicUuid, descriptorUuid) { +Noble.prototype.onValueWrite = function (peripheralUuid, serviceUuid, characteristicUuid, descriptorUuid) { var descriptor = this._descriptors[peripheralUuid][serviceUuid][characteristicUuid][descriptorUuid]; if (descriptor) { @@ -524,11 +522,11 @@ Noble.prototype.onValueWrite = function(peripheralUuid, serviceUuid, characteris } }; -Noble.prototype.readHandle = function(peripheralUuid, handle) { +Noble.prototype.readHandle = function (peripheralUuid, handle) { this._bindings.readHandle(peripheralUuid, handle); }; -Noble.prototype.onHandleRead = function(peripheralUuid, handle, data) { +Noble.prototype.onHandleRead = function (peripheralUuid, handle, data) { var peripheral = this._peripherals[peripheralUuid]; if (peripheral) { @@ -538,11 +536,11 @@ Noble.prototype.onHandleRead = function(peripheralUuid, handle, data) { } }; -Noble.prototype.writeHandle = function(peripheralUuid, handle, data, withoutResponse) { +Noble.prototype.writeHandle = function (peripheralUuid, handle, data, withoutResponse) { this._bindings.writeHandle(peripheralUuid, handle, data, withoutResponse); }; -Noble.prototype.onHandleWrite = function(peripheralUuid, handle) { +Noble.prototype.onHandleWrite = function (peripheralUuid, handle) { var peripheral = this._peripherals[peripheralUuid]; if (peripheral) { @@ -552,7 +550,7 @@ Noble.prototype.onHandleWrite = function(peripheralUuid, handle) { } }; -Noble.prototype.onHandleNotify = function(peripheralUuid, handle, data) { +Noble.prototype.onHandleNotify = function (peripheralUuid, handle, data) { var peripheral = this._peripherals[peripheralUuid]; if (peripheral) { @@ -562,7 +560,7 @@ Noble.prototype.onHandleNotify = function(peripheralUuid, handle, data) { } }; -Noble.prototype.onMtu = function(peripheralUuid, mtu) { +Noble.prototype.onMtu = function (peripheralUuid, mtu) { var peripheral = this._peripherals[peripheralUuid]; peripheral.mtu = mtu; }; diff --git a/lib/peripheral.js b/lib/peripheral.js index 469f4f690..7db3727a2 100644 --- a/lib/peripheral.js +++ b/lib/peripheral.js @@ -1,7 +1,7 @@ var events = require('events'); var util = require('util'); -function Peripheral(noble, id, address, addressType, connectable, advertisement, rssi) { +function Peripheral (noble, id, address, addressType, connectable, advertisement, rssi) { this._noble = noble; this.id = id; @@ -18,7 +18,7 @@ function Peripheral(noble, id, address, addressType, connectable, advertisement, util.inherits(Peripheral, events.EventEmitter); -Peripheral.prototype.toString = function() { +Peripheral.prototype.toString = function () { return JSON.stringify({ id: this.id, address: this.address, @@ -37,7 +37,7 @@ Peripheral.prototype.connect = function (options, callback) { options = undefined; } if (callback) { - this.once('connect', function(error) { + this.once('connect', function (error) { callback(error); }); } @@ -70,9 +70,9 @@ Peripheral.prototype.cancelConnect = function (options, callback) { } }; -Peripheral.prototype.disconnect = function(callback) { +Peripheral.prototype.disconnect = function (callback) { if (callback) { - this.once('disconnect', function() { + this.once('disconnect', function () { callback(null); }); } @@ -80,9 +80,9 @@ Peripheral.prototype.disconnect = function(callback) { this._noble.disconnect(this.id); }; -Peripheral.prototype.updateRssi = function(callback) { +Peripheral.prototype.updateRssi = function (callback) { if (callback) { - this.once('rssiUpdate', function(rssi) { + this.once('rssiUpdate', function (rssi) { callback(null, rssi); }); } @@ -90,9 +90,9 @@ Peripheral.prototype.updateRssi = function(callback) { this._noble.updateRssi(this.id); }; -Peripheral.prototype.discoverServices = function(uuids, callback) { +Peripheral.prototype.discoverServices = function (uuids, callback) { if (callback) { - this.once('servicesDiscover', function(services) { + this.once('servicesDiscover', function (services) { callback(null, services); }); } @@ -100,15 +100,15 @@ Peripheral.prototype.discoverServices = function(uuids, callback) { this._noble.discoverServices(this.id, uuids); }; -Peripheral.prototype.discoverSomeServicesAndCharacteristics = function(serviceUuids, characteristicsUuids, callback) { - this.discoverServices(serviceUuids, function(err, services) { +Peripheral.prototype.discoverSomeServicesAndCharacteristics = function (serviceUuids, characteristicsUuids, callback) { + this.discoverServices(serviceUuids, function (err, services) { var numDiscovered = 0; var allCharacteristics = []; for (var i in services) { var service = services[i]; - service.discoverCharacteristics(characteristicsUuids, function(error, characteristics) { + service.discoverCharacteristics(characteristicsUuids, function (error, characteristics) { numDiscovered++; if (error === null) { @@ -124,18 +124,18 @@ Peripheral.prototype.discoverSomeServicesAndCharacteristics = function(serviceUu callback(null, services, allCharacteristics); } } - }.bind(this)); + }); } - }.bind(this)); + }); }; -Peripheral.prototype.discoverAllServicesAndCharacteristics = function(callback) { +Peripheral.prototype.discoverAllServicesAndCharacteristics = function (callback) { this.discoverSomeServicesAndCharacteristics([], [], callback); }; -Peripheral.prototype.readHandle = function(handle, callback) { +Peripheral.prototype.readHandle = function (handle, callback) { if (callback) { - this.once('handleRead' + handle, function(data) { + this.once('handleRead' + handle, function (data) { callback(null, data); }); } @@ -143,13 +143,13 @@ Peripheral.prototype.readHandle = function(handle, callback) { this._noble.readHandle(this.id, handle); }; -Peripheral.prototype.writeHandle = function(handle, data, withoutResponse, callback) { +Peripheral.prototype.writeHandle = function (handle, data, withoutResponse, callback) { if (!(data instanceof Buffer)) { throw new Error('data must be a Buffer'); } if (callback) { - this.once('handleWrite' + handle, function() { + this.once('handleWrite' + handle, function () { callback(null); }); } diff --git a/lib/resolve-bindings-web.js b/lib/resolve-bindings-web.js index 4e69f8409..8670a1f6f 100644 --- a/lib/resolve-bindings-web.js +++ b/lib/resolve-bindings-web.js @@ -1,4 +1,4 @@ -function resolveBindings(){ +function resolveBindings () { if (navigator.bluetooth && !process.env.NOBLE_WEBSOCKET) { return require('./webbluetooth/bindings'); } diff --git a/lib/resolve-bindings.js b/lib/resolve-bindings.js index 84ffc68b3..1218c282a 100644 --- a/lib/resolve-bindings.js +++ b/lib/resolve-bindings.js @@ -1,6 +1,6 @@ var os = require('os'); -module.exports = function(options) { +module.exports = function (options) { var platform = os.platform(); if (process.env.NOBLE_WEBSOCKET) { diff --git a/lib/service.js b/lib/service.js index 5227fd1cf..0cfd6487c 100644 --- a/lib/service.js +++ b/lib/service.js @@ -3,7 +3,7 @@ var util = require('util'); var services = require('./services.json'); -function Service(noble, peripheralId, uuid) { +function Service (noble, peripheralId, uuid) { this._noble = noble; this._peripheralId = peripheralId; @@ -22,7 +22,7 @@ function Service(noble, peripheralId, uuid) { util.inherits(Service, events.EventEmitter); -Service.prototype.toString = function() { +Service.prototype.toString = function () { return JSON.stringify({ uuid: this.uuid, name: this.name, @@ -31,9 +31,9 @@ Service.prototype.toString = function() { }); }; -Service.prototype.discoverIncludedServices = function(serviceUuids, callback) { +Service.prototype.discoverIncludedServices = function (serviceUuids, callback) { if (callback) { - this.once('includedServicesDiscover', function(includedServiceUuids) { + this.once('includedServicesDiscover', function (includedServiceUuids) { callback(null, includedServiceUuids); }); } @@ -45,9 +45,9 @@ Service.prototype.discoverIncludedServices = function(serviceUuids, callback) { ); }; -Service.prototype.discoverCharacteristics = function(characteristicUuids, callback) { +Service.prototype.discoverCharacteristics = function (characteristicUuids, callback) { if (callback) { - this.once('characteristicsDiscover', function(characteristics) { + this.once('characteristicsDiscover', function (characteristics) { callback(null, characteristics); }); } diff --git a/lib/webbluetooth/bindings.js b/lib/webbluetooth/bindings.js index c55c8683a..3ade3e473 100644 --- a/lib/webbluetooth/bindings.js +++ b/lib/webbluetooth/bindings.js @@ -3,49 +3,45 @@ var events = require('events'); var debug = require('debug')('webble-bindings'); -function makeList(uuid){ - return {services:[ uuid ]}; +function makeList (uuid) { + return { services: [uuid] }; } -function addDashes(uuid){ - if(!uuid || typeof uuid !== 'string'){ +function addDashes (uuid) { + if (!uuid || typeof uuid !== 'string') { return uuid; } - if(uuid && uuid.length === 32){ - uuid = uuid.substring(0,8) + '-' + uuid.substring(8,12) + '-' + uuid.substring(12,16) + '-' + uuid.substring(16,20) + '-' + uuid.substring(20); + if (uuid && uuid.length === 32) { + uuid = uuid.substring(0, 8) + '-' + uuid.substring(8, 12) + '-' + uuid.substring(12, 16) + '-' + uuid.substring(16, 20) + '-' + uuid.substring(20); } return uuid.toLowerCase(); } -function stripDashes(uuid){ - if(typeof uuid === 'string'){ +function stripDashes (uuid) { + if (typeof uuid === 'string') { uuid = uuid.split('-').join(''); } return uuid; } - -var NobleBindings = function() { - +var NobleBindings = function () { this._ble = null; this._startScanCommand = null; this._peripherals = {}; - }; util.inherits(NobleBindings, events.EventEmitter); -NobleBindings.prototype.init = function(ble) { - - if(ble) { +NobleBindings.prototype.init = function (ble) { + if (ble) { this._ble = ble; - }else { + } else { this._ble = navigator.bluetooth; } var self = this; - process.nextTick(function(){ + process.nextTick(function () { debug('initing'); - if(!self._ble){ + if (!self._ble) { return self.emit('error', new Error('This browser does not support WebBluetooth.')); } debug('emit powered on'); @@ -53,38 +49,36 @@ NobleBindings.prototype.init = function(ble) { }); }; - -NobleBindings.prototype.onOpen = function() { +NobleBindings.prototype.onOpen = function () { debug('on -> open'); }; -NobleBindings.prototype.onClose = function() { +NobleBindings.prototype.onClose = function () { debug('on -> close'); this.emit('stateChange', 'poweredOff'); }; -NobleBindings.prototype.startScanning = function(options, allowDuplicates) { +NobleBindings.prototype.startScanning = function (options, allowDuplicates) { var self = this; - if(Array.isArray(options)){ - options = {services: options}; + if (Array.isArray(options)) { + options = { services: options }; } - if(typeof options !== 'object'){ - options = {services: options}; + if (typeof options !== 'object') { + options = { services: options }; } - if(!Array.isArray(options.services)){ + if (!Array.isArray(options.services)) { options.services = [options.services]; } - options.services = options.services.map(function(service){ - //web bluetooth requires 4 char hex service names to be passed in as integers - if(typeof service === 'string' && service.length === 4){ + options.services = options.services.map(function (service) { + // web bluetooth requires 4 char hex service names to be passed in as integers + if (typeof service === 'string' && service.length === 4) { service = parseInt('0x' + service); - } - else if(typeof service === 'string' && service.length === 6 && service.indexOf('0x') === 0){ + } else if (typeof service === 'string' && service.length === 6 && service.indexOf('0x') === 0) { service = parseInt(service); } return service; @@ -93,44 +87,43 @@ NobleBindings.prototype.startScanning = function(options, allowDuplicates) { var dashedUuids = options.services.map(addDashes); var filterList = dashedUuids.map(makeList); - if(options.name){ - filterList.push({name: options.name}); + if (options.name) { + filterList.push({ name: options.name }); } - if(options.namePrefix){ - filterList.push({namePrefix: options.namePrefix}); + if (options.namePrefix) { + filterList.push({ namePrefix: options.namePrefix }); } - var request = {filters: filterList}; + var request = { filters: filterList }; debug('startScanning', request, allowDuplicates); this._ble.requestDevice(request) - .then(function(device){ + .then(function (device) { debug('scan finished', device); self.emit('scanStop', {}); - if(device){ - + if (device) { var address = device.id; - //TODO use device.adData when api is ready - //rssi = device.adData.rssi; + // TODO use device.adData when api is ready + // rssi = device.adData.rssi; self._peripherals[address] = { uuid: address, address: address, - advertisement: {localName:device.name}, //advertisement, + advertisement: { localName: device.name }, // advertisement, device: device, cachedServices: {}, localName: device.name, serviceUuids: options.services }; - if(device.adData){ + if (device.adData) { self._peripherals[address].rssi = device.adData.rssi; } self.emit('discover', device.id, device.id, device.addressType, !device.paired, self._peripherals[address].advertisement, self._peripherals[address].rssi); } }) - .catch(function(err){ + .catch(function (err) { debug('err scanning', err); self.emit('scanStop', {}); self.emit('error', err); @@ -139,96 +132,93 @@ NobleBindings.prototype.startScanning = function(options, allowDuplicates) { this.emit('scanStart'); }; -NobleBindings.prototype.stopScanning = function() { +NobleBindings.prototype.stopScanning = function () { this._startScanCommand = null; - //TODO: need web api completed for this to work'= + // TODO: need web api completed for this to work'= this.emit('scanStop'); }; -NobleBindings.prototype.connect = function(deviceUuid) { +NobleBindings.prototype.connect = function (deviceUuid) { var self = this; debug('connect', deviceUuid); var peripheral = this._peripherals[deviceUuid]; - //clear any cached services in case this is a reconnect + // clear any cached services in case this is a reconnect peripheral.cachedServices = {}; // Attempts to connect to remote GATT Server. peripheral.device.gatt.connect() - .then(function(gattServer){ + .then(function (gattServer) { debug('peripheral connected', gattServer); - var onDisconnected = function(event){ + var onDisconnected = function (event) { debug('disconnected', peripheral.uuid); self.emit('disconnect', peripheral.uuid); }; - peripheral.device.addEventListener('gattserverdisconnected', onDisconnected, {once: true}); + peripheral.device.addEventListener('gattserverdisconnected', onDisconnected, { once: true }); self.emit('connect', deviceUuid); - }, function(err){ + }, function (err) { debug('err connecting', err); self.emit('connect', deviceUuid, err); }); - }; -NobleBindings.prototype.disconnect = function(deviceUuid) { +NobleBindings.prototype.disconnect = function (deviceUuid) { var peripheral = this._peripherals[deviceUuid]; - if(peripheral.device.gatt){ + if (peripheral.device.gatt) { peripheral.device.gatt.disconnect(); this.emit('disconnect', deviceUuid); } }; -NobleBindings.prototype.updateRssi = function(deviceUuid) { - //TODO: need web api completed for this to work +NobleBindings.prototype.updateRssi = function (deviceUuid) { + // TODO: need web api completed for this to work // var peripheral = this._peripherals[deviceUuid]; // this.emit('rssiUpdate', deviceUuid, rssi); }; -NobleBindings.prototype.discoverServices = function(deviceUuid, uuids) { +NobleBindings.prototype.discoverServices = function (deviceUuid, uuids) { var peripheral = this._peripherals[deviceUuid]; - //TODO: need web api completed for this to work - if(peripheral){ + // TODO: need web api completed for this to work + if (peripheral) { this.emit('servicesDiscover', deviceUuid, peripheral.serviceUuids); } - }; -NobleBindings.prototype.discoverIncludedServices = function(deviceUuid, serviceUuid, serviceUuids) { - //TODO impelment when web API has functionatility then emit response - //var peripheral = this._peripherals[deviceUuid]; - //this.emit('includedServicesDiscover', deviceUuid, serviceUuid, includedServiceUuids); +NobleBindings.prototype.discoverIncludedServices = function (deviceUuid, serviceUuid, serviceUuids) { + // TODO impelment when web API has functionatility then emit response + // var peripheral = this._peripherals[deviceUuid]; + // this.emit('includedServicesDiscover', deviceUuid, serviceUuid, includedServiceUuids); }; -NobleBindings.prototype.discoverCharacteristics = function(deviceUuid, serviceUuid, characteristicUuids) { +NobleBindings.prototype.discoverCharacteristics = function (deviceUuid, serviceUuid, characteristicUuids) { var self = this; var peripheral = self._peripherals[deviceUuid]; - if(peripheral){ - + if (peripheral) { self.getPrimaryService(peripheral, serviceUuid) - .then(function(service){ + .then(function (service) { return service.getCharacteristics(); }) - .then(function(characteristics) { - var discoveredCharacteristics = characteristics.map(function(char){ - var charInfo = {uuid: stripDashes(char.uuid), properties: []}; + .then(function (characteristics) { + var discoveredCharacteristics = characteristics.map(function (char) { + var charInfo = { uuid: stripDashes(char.uuid), properties: [] }; - if(char.properties.writeWithoutResponse){ + if (char.properties.writeWithoutResponse) { charInfo.properties.push('writeWithoutResponse'); } - if(char.properties.write){ + if (char.properties.write) { charInfo.properties.push('write'); } - if(char.properties.read){ + if (char.properties.read) { charInfo.properties.push('read'); } - if(char.properties.notify){ + if (char.properties.notify) { charInfo.properties.push('notify'); } @@ -237,163 +227,158 @@ NobleBindings.prototype.discoverCharacteristics = function(deviceUuid, serviceUu debug('discoverCharacteristics', deviceUuid, serviceUuid, discoveredCharacteristics); self.emit('characteristicsDiscover', deviceUuid, serviceUuid, discoveredCharacteristics); - }); } - }; -NobleBindings.prototype.getPrimaryService = function(peripheral, serviceUuid){ +NobleBindings.prototype.getPrimaryService = function (peripheral, serviceUuid) { serviceUuid = addDashes(serviceUuid); - if(peripheral.cachedServices[serviceUuid]){ - return new Promise(function(resolve, reject){ + if (peripheral.cachedServices[serviceUuid]) { + return new Promise(function (resolve, reject) { resolve(peripheral.cachedServices[serviceUuid]); }); } return peripheral.device.gatt.getPrimaryService(serviceUuid) - .then(function(service){ + .then(function (service) { peripheral.cachedServices[serviceUuid] = service; return service; }); }; -NobleBindings.prototype.read = function(deviceUuid, serviceUuid, characteristicUuid) { +NobleBindings.prototype.read = function (deviceUuid, serviceUuid, characteristicUuid) { var self = this; var peripheral = this._peripherals[deviceUuid]; debug('read', deviceUuid, serviceUuid, characteristicUuid); self.getPrimaryService(peripheral, serviceUuid) - .then(function(service){ + .then(function (service) { return service.getCharacteristic(addDashes(characteristicUuid)); }) - .then(function(characteristic) { + .then(function (characteristic) { return characteristic.readValue(); }) - .then(function(data){ + .then(function (data) { self.emit('read', peripheral.uuid, serviceUuid, characteristicUuid, new Buffer(data.buffer), false); }) - .catch(function(err) { + .catch(function (err) { debug('error reading characteristic', err); self.emit('error', err); }); }; -NobleBindings.prototype.write = function(deviceUuid, serviceUuid, characteristicUuid, data, withoutResponse) { +NobleBindings.prototype.write = function (deviceUuid, serviceUuid, characteristicUuid, data, withoutResponse) { var self = this; var peripheral = this._peripherals[deviceUuid]; debug('write', deviceUuid, serviceUuid, characteristicUuid, data, withoutResponse); self.getPrimaryService(peripheral, serviceUuid) - .then(function(service){ + .then(function (service) { return service.getCharacteristic(addDashes(characteristicUuid)); }) - .then(function(characteristic) { + .then(function (characteristic) { return characteristic.writeValue(data); }) - .then(function(){ + .then(function () { debug('value written'); self.emit('write', peripheral.uuid, serviceUuid, characteristicUuid); }) - .catch(function(err) { + .catch(function (err) { debug('error writing to characteristic', serviceUuid, characteristicUuid, err); }); - }; -NobleBindings.prototype.broadcast = function(deviceUuid, serviceUuid, characteristicUuid, broadcast) { - //TODO impelment when web API has functionatility then emit response - //var peripheral = this._peripherals[deviceUuid]; - //this.emit('broadcast', deviceUuid, serviceUuid, characteristicUuid, state); +NobleBindings.prototype.broadcast = function (deviceUuid, serviceUuid, characteristicUuid, broadcast) { + // TODO impelment when web API has functionatility then emit response + // var peripheral = this._peripherals[deviceUuid]; + // this.emit('broadcast', deviceUuid, serviceUuid, characteristicUuid, state); }; -NobleBindings.prototype.notify = function(deviceUuid, serviceUuid, characteristicUuid, notify) { +NobleBindings.prototype.notify = function (deviceUuid, serviceUuid, characteristicUuid, notify) { var self = this; var peripheral = this._peripherals[deviceUuid]; var charPromise = self.getPrimaryService(peripheral, serviceUuid) - .then(function(service){ + .then(function (service) { return service.getCharacteristic(addDashes(characteristicUuid)); }); peripheral.notifcationListeners = peripheral.notifcationListeners || {}; - if(notify){ - charPromise.then(function(characteristic) { + if (notify) { + charPromise.then(function (characteristic) { return characteristic.startNotifications(); }) - .then(function(characteristic){ - debug('notifications started', characteristicUuid); - peripheral.notifcationListeners[serviceUuid + '__' + characteristicUuid] = function(evt){ - debug('oncharacteristicvaluechanged', evt, new Buffer(evt.target.value.buffer)); - self.emit('read', deviceUuid, serviceUuid, characteristicUuid, new Buffer(evt.target.value.buffer), true); - }; - characteristic.addEventListener('characteristicvaluechanged', peripheral.notifcationListeners[serviceUuid + '__' + characteristicUuid]); + .then(function (characteristic) { + debug('notifications started', characteristicUuid); + peripheral.notifcationListeners[serviceUuid + '__' + characteristicUuid] = function (evt) { + debug('oncharacteristicvaluechanged', evt, new Buffer(evt.target.value.buffer)); + self.emit('read', deviceUuid, serviceUuid, characteristicUuid, new Buffer(evt.target.value.buffer), true); + }; + characteristic.addEventListener('characteristicvaluechanged', peripheral.notifcationListeners[serviceUuid + '__' + characteristicUuid]); - var onDisconnected = function(){ - characteristic.removeEventListener('characteristicvaluechanged', peripheral.notifcationListeners[serviceUuid + '__' + characteristicUuid]); - delete peripheral.notifcationListeners[serviceUuid + '__' + characteristicUuid]; - }; - peripheral.device.addEventListener('gattserverdisconnected', onDisconnected, {once: true}); + var onDisconnected = function () { + characteristic.removeEventListener('characteristicvaluechanged', peripheral.notifcationListeners[serviceUuid + '__' + characteristicUuid]); + delete peripheral.notifcationListeners[serviceUuid + '__' + characteristicUuid]; + }; + peripheral.device.addEventListener('gattserverdisconnected', onDisconnected, { once: true }); - self.emit('notify', deviceUuid, serviceUuid, characteristicUuid, true); - return characteristic; - }) - .catch(function(err) { - debug('error enabling notifications on characteristic', err); - self.emit('error', err); - }); - } - else{ - charPromise.then(function(characteristic) { + self.emit('notify', deviceUuid, serviceUuid, characteristicUuid, true); + return characteristic; + }) + .catch(function (err) { + debug('error enabling notifications on characteristic', err); + self.emit('error', err); + }); + } else { + charPromise.then(function (characteristic) { return characteristic.stopNotifications(); }) - .then(function(characteristic){ - debug('notifications stopped', characteristic); - if(peripheral.notifcationListeners[serviceUuid + '__' + characteristicUuid]){ - characteristic.removeEventListener('characteristicvaluechanged', peripheral.notifcationListeners[serviceUuid + '__' + characteristicUuid]); - delete peripheral.notifcationListeners[serviceUuid + '__' + characteristicUuid]; - } - self.emit('notify', deviceUuid, serviceUuid, characteristicUuid, false); - return characteristic; - }) - .catch(function(err) { - debug('error disabling notifications on characteristic', err); - self.emit('error', err); - }); + .then(function (characteristic) { + debug('notifications stopped', characteristic); + if (peripheral.notifcationListeners[serviceUuid + '__' + characteristicUuid]) { + characteristic.removeEventListener('characteristicvaluechanged', peripheral.notifcationListeners[serviceUuid + '__' + characteristicUuid]); + delete peripheral.notifcationListeners[serviceUuid + '__' + characteristicUuid]; + } + self.emit('notify', deviceUuid, serviceUuid, characteristicUuid, false); + return characteristic; + }) + .catch(function (err) { + debug('error disabling notifications on characteristic', err); + self.emit('error', err); + }); } - }; -NobleBindings.prototype.discoverDescriptors = function(deviceUuid, serviceUuid, characteristicUuid) { - //TODO impelment when web API has functionatility then emit response - //var peripheral = this._peripherals[deviceUuid]; - //this.emit('descriptorsDiscover', deviceUuid, serviceUuid, characteristicUuid, descriptors); +NobleBindings.prototype.discoverDescriptors = function (deviceUuid, serviceUuid, characteristicUuid) { + // TODO impelment when web API has functionatility then emit response + // var peripheral = this._peripherals[deviceUuid]; + // this.emit('descriptorsDiscover', deviceUuid, serviceUuid, characteristicUuid, descriptors); }; -NobleBindings.prototype.readValue = function(deviceUuid, serviceUuid, characteristicUuid, descriptorUuid) { - //TODO impelment when web API has functionatility then emit response - //var peripheral = this._peripherals[deviceUuid]; - //this.emit('valueRead', deviceUuid, serviceUuid, characteristicUuid, descriptorUuid, data); +NobleBindings.prototype.readValue = function (deviceUuid, serviceUuid, characteristicUuid, descriptorUuid) { + // TODO impelment when web API has functionatility then emit response + // var peripheral = this._peripherals[deviceUuid]; + // this.emit('valueRead', deviceUuid, serviceUuid, characteristicUuid, descriptorUuid, data); }; -NobleBindings.prototype.writeValue = function(deviceUuid, serviceUuid, characteristicUuid, descriptorUuid, data) { - //TODO impelment when web API has functionatility then emit response - //var peripheral = this._peripherals[deviceUuid]; - //this.emit('valueWrite', deviceUuid, serviceUuid, characteristicUuid, descriptorUuid); +NobleBindings.prototype.writeValue = function (deviceUuid, serviceUuid, characteristicUuid, descriptorUuid, data) { + // TODO impelment when web API has functionatility then emit response + // var peripheral = this._peripherals[deviceUuid]; + // this.emit('valueWrite', deviceUuid, serviceUuid, characteristicUuid, descriptorUuid); }; -NobleBindings.prototype.readHandle = function(deviceUuid, handle) { - //TODO impelment when web API has functionatility then emit response - //var peripheral = this._peripherals[deviceUuid]; - //this.emit('handleRead', deviceUuid, handle, data); +NobleBindings.prototype.readHandle = function (deviceUuid, handle) { + // TODO impelment when web API has functionatility then emit response + // var peripheral = this._peripherals[deviceUuid]; + // this.emit('handleRead', deviceUuid, handle, data); }; -NobleBindings.prototype.writeHandle = function(deviceUuid, handle, data, withoutResponse) { - //TODO impelment when web API has functionatility then emit response - //var peripheral = this._peripherals[deviceUuid]; - //this.emit('handleWrite', deviceUuid, handle); +NobleBindings.prototype.writeHandle = function (deviceUuid, handle, data, withoutResponse) { + // TODO impelment when web API has functionatility then emit response + // var peripheral = this._peripherals[deviceUuid]; + // this.emit('handleWrite', deviceUuid, handle); }; module.exports = NobleBindings; diff --git a/lib/websocket/bindings.js b/lib/websocket/bindings.js index 829fc2a1f..9d9e67271 100644 --- a/lib/websocket/bindings.js +++ b/lib/websocket/bindings.js @@ -3,7 +3,7 @@ var util = require('util'); var WebSocket = require('ws'); -var NobleBindings = function() { +var NobleBindings = function () { var port = 0xB1e; this._ws = new WebSocket('ws://localhost:' + port); @@ -21,7 +21,7 @@ var NobleBindings = function() { this._ws.on('error', this._onClose.bind(this)); var _this = this; - this._ws.on('message', function(event) { + this._ws.on('message', function (event) { var data = (process.title === 'browser') ? event.data : event; _this.emit('message', JSON.parse(data)); @@ -30,20 +30,20 @@ var NobleBindings = function() { util.inherits(NobleBindings, events.EventEmitter); -NobleBindings.prototype.init = function() { +NobleBindings.prototype.init = function () { // no-op }; -NobleBindings.prototype._onOpen = function() { +NobleBindings.prototype._onOpen = function () { console.log('on -> open'); }; -NobleBindings.prototype._onClose = function() { +NobleBindings.prototype._onClose = function () { console.log('on -> close'); this.emit('stateChange', 'poweredOff'); }; -NobleBindings.prototype._onMessage = function(event) { +NobleBindings.prototype._onMessage = function (event) { var type = event.type; var peripheralUuid = event.peripheralUuid; var address = event.address; @@ -118,19 +118,19 @@ NobleBindings.prototype._onMessage = function(event) { } }; -NobleBindings.prototype._sendCommand = function(command, errorCallback) { +NobleBindings.prototype._sendCommand = function (command, errorCallback) { var message = JSON.stringify(command); - this._ws.send(message, function(error) { - if (error != null) { - console.warn("could not send command", command, error); - if (typeof errorCallback === "function") { - errorCallback(error); - } + this._ws.send(message, function (error) { + if (error != null) { + console.warn('could not send command', command, error); + if (typeof errorCallback === 'function') { + errorCallback(error); } - }); + } + }); }; -NobleBindings.prototype.startScanning = function(serviceUuids, allowDuplicates) { +NobleBindings.prototype.startScanning = function (serviceUuids, allowDuplicates) { this._startScanCommand = { action: 'startScanning', serviceUuids: serviceUuids, @@ -141,7 +141,7 @@ NobleBindings.prototype.startScanning = function(serviceUuids, allowDuplicates) this.emit('scanStart'); }; -NobleBindings.prototype.stopScanning = function() { +NobleBindings.prototype.stopScanning = function () { this._startScanCommand = null; this._sendCommand({ @@ -151,7 +151,7 @@ NobleBindings.prototype.stopScanning = function() { this.emit('scanStop'); }; -NobleBindings.prototype.connect = function(deviceUuid) { +NobleBindings.prototype.connect = function (deviceUuid) { var peripheral = this._peripherals[deviceUuid]; this._sendCommand({ @@ -160,7 +160,7 @@ NobleBindings.prototype.connect = function(deviceUuid) { }); }; -NobleBindings.prototype.disconnect = function(deviceUuid) { +NobleBindings.prototype.disconnect = function (deviceUuid) { var peripheral = this._peripherals[deviceUuid]; this._sendCommand({ @@ -169,7 +169,7 @@ NobleBindings.prototype.disconnect = function(deviceUuid) { }); }; -NobleBindings.prototype.updateRssi = function(deviceUuid) { +NobleBindings.prototype.updateRssi = function (deviceUuid) { var peripheral = this._peripherals[deviceUuid]; this._sendCommand({ @@ -178,7 +178,7 @@ NobleBindings.prototype.updateRssi = function(deviceUuid) { }); }; -NobleBindings.prototype.discoverServices = function(deviceUuid, uuids) { +NobleBindings.prototype.discoverServices = function (deviceUuid, uuids) { var peripheral = this._peripherals[deviceUuid]; this._sendCommand({ @@ -188,7 +188,7 @@ NobleBindings.prototype.discoverServices = function(deviceUuid, uuids) { }); }; -NobleBindings.prototype.discoverIncludedServices = function(deviceUuid, serviceUuid, serviceUuids) { +NobleBindings.prototype.discoverIncludedServices = function (deviceUuid, serviceUuid, serviceUuids) { var peripheral = this._peripherals[deviceUuid]; this._sendCommand({ @@ -199,7 +199,7 @@ NobleBindings.prototype.discoverIncludedServices = function(deviceUuid, serviceU }); }; -NobleBindings.prototype.discoverCharacteristics = function(deviceUuid, serviceUuid, characteristicUuids) { +NobleBindings.prototype.discoverCharacteristics = function (deviceUuid, serviceUuid, characteristicUuids) { var peripheral = this._peripherals[deviceUuid]; this._sendCommand({ @@ -210,7 +210,7 @@ NobleBindings.prototype.discoverCharacteristics = function(deviceUuid, serviceUu }); }; -NobleBindings.prototype.read = function(deviceUuid, serviceUuid, characteristicUuid) { +NobleBindings.prototype.read = function (deviceUuid, serviceUuid, characteristicUuid) { var peripheral = this._peripherals[deviceUuid]; this._sendCommand({ @@ -221,7 +221,7 @@ NobleBindings.prototype.read = function(deviceUuid, serviceUuid, characteristicU }); }; -NobleBindings.prototype.write = function(deviceUuid, serviceUuid, characteristicUuid, data, withoutResponse) { +NobleBindings.prototype.write = function (deviceUuid, serviceUuid, characteristicUuid, data, withoutResponse) { var peripheral = this._peripherals[deviceUuid]; this._sendCommand({ @@ -234,7 +234,7 @@ NobleBindings.prototype.write = function(deviceUuid, serviceUuid, characteristic }); }; -NobleBindings.prototype.broadcast = function(deviceUuid, serviceUuid, characteristicUuid, broadcast) { +NobleBindings.prototype.broadcast = function (deviceUuid, serviceUuid, characteristicUuid, broadcast) { var peripheral = this._peripherals[deviceUuid]; this._sendCommand({ @@ -246,7 +246,7 @@ NobleBindings.prototype.broadcast = function(deviceUuid, serviceUuid, characteri }); }; -NobleBindings.prototype.notify = function(deviceUuid, serviceUuid, characteristicUuid, notify) { +NobleBindings.prototype.notify = function (deviceUuid, serviceUuid, characteristicUuid, notify) { var peripheral = this._peripherals[deviceUuid]; this._sendCommand({ @@ -258,7 +258,7 @@ NobleBindings.prototype.notify = function(deviceUuid, serviceUuid, characteristi }); }; -NobleBindings.prototype.discoverDescriptors = function(deviceUuid, serviceUuid, characteristicUuid) { +NobleBindings.prototype.discoverDescriptors = function (deviceUuid, serviceUuid, characteristicUuid) { var peripheral = this._peripherals[deviceUuid]; this._sendCommand({ @@ -269,7 +269,7 @@ NobleBindings.prototype.discoverDescriptors = function(deviceUuid, serviceUuid, }); }; -NobleBindings.prototype.readValue = function(deviceUuid, serviceUuid, characteristicUuid, descriptorUuid) { +NobleBindings.prototype.readValue = function (deviceUuid, serviceUuid, characteristicUuid, descriptorUuid) { var peripheral = this._peripherals[deviceUuid]; this._sendCommand({ @@ -281,7 +281,7 @@ NobleBindings.prototype.readValue = function(deviceUuid, serviceUuid, characteri }); }; -NobleBindings.prototype.writeValue = function(deviceUuid, serviceUuid, characteristicUuid, descriptorUuid, data) { +NobleBindings.prototype.writeValue = function (deviceUuid, serviceUuid, characteristicUuid, descriptorUuid, data) { var peripheral = this._peripherals[deviceUuid]; this._sendCommand({ @@ -294,7 +294,7 @@ NobleBindings.prototype.writeValue = function(deviceUuid, serviceUuid, character }); }; -NobleBindings.prototype.readHandle = function(deviceUuid, handle) { +NobleBindings.prototype.readHandle = function (deviceUuid, handle) { var peripheral = this._peripherals[deviceUuid]; this._sendCommand({ @@ -304,7 +304,7 @@ NobleBindings.prototype.readHandle = function(deviceUuid, handle) { }); }; -NobleBindings.prototype.writeHandle = function(deviceUuid, handle, data, withoutResponse) { +NobleBindings.prototype.writeHandle = function (deviceUuid, handle, data, withoutResponse) { var peripheral = this._peripherals[deviceUuid]; this._sendCommand({ diff --git a/package-lock.json b/package-lock.json index c17ea30a2..409bdc2ef 100644 --- a/package-lock.json +++ b/package-lock.json @@ -159,6 +159,185 @@ "integrity": "sha1-z+nYwmYoudxa7MYqn12PHzUsEZU=", "dev": true }, + "array-includes": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/array-includes/-/array-includes-3.1.1.tgz", + "integrity": "sha512-c2VXaCHl7zPsvpkFsw4nxvFie4fh1ur9bpcgsVkIjqn0H/Xwdg+7fv3n2r/isyS8EBj5b06M9kHyZuIr4El6WQ==", + "dev": true, + "requires": { + "define-properties": "^1.1.3", + "es-abstract": "^1.17.0", + "is-string": "^1.0.5" + }, + "dependencies": { + "es-abstract": { + "version": "1.17.4", + "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.17.4.tgz", + "integrity": "sha512-Ae3um/gb8F0mui/jPL+QiqmglkUsaQf7FwBEHYIFkztkneosu9imhqHpBzQ3h1vit8t5iQ74t6PEVvphBZiuiQ==", + "dev": true, + "requires": { + "es-to-primitive": "^1.2.1", + "function-bind": "^1.1.1", + "has": "^1.0.3", + "has-symbols": "^1.0.1", + "is-callable": "^1.1.5", + "is-regex": "^1.0.5", + "object-inspect": "^1.7.0", + "object-keys": "^1.1.1", + "object.assign": "^4.1.0", + "string.prototype.trimleft": "^2.1.1", + "string.prototype.trimright": "^2.1.1" + } + }, + "es-to-primitive": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.1.tgz", + "integrity": "sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA==", + "dev": true, + "requires": { + "is-callable": "^1.1.4", + "is-date-object": "^1.0.1", + "is-symbol": "^1.0.2" + } + }, + "has-symbols": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.1.tgz", + "integrity": "sha512-PLcsoqu++dmEIZB+6totNFKq/7Do+Z0u4oT0zKOJNl3lYK6vGwwu2hjHs+68OEZbTjiUE9bgOABXbP/GvrS0Kg==", + "dev": true + }, + "is-callable": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.1.5.tgz", + "integrity": "sha512-ESKv5sMCJB2jnHTWZ3O5itG+O128Hsus4K4Qh1h2/cgn2vbgnLSVqfV46AeJA9D5EeeLa9w81KUXMtn34zhX+Q==", + "dev": true + }, + "is-regex": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.0.5.tgz", + "integrity": "sha512-vlKW17SNq44owv5AQR3Cq0bQPEb8+kF3UKZ2fiZNOWtztYE5i0CzCZxFDwO58qAOWtxdBRVO/V5Qin1wjCqFYQ==", + "dev": true, + "requires": { + "has": "^1.0.3" + } + }, + "object-inspect": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.7.0.tgz", + "integrity": "sha512-a7pEHdh1xKIAgTySUGgLMx/xwDZskN1Ud6egYYN3EdRW4ZMPNEDUTF+hwy2LUC+Bl+SyLXANnwz/jyh/qutKUw==", + "dev": true + }, + "string.prototype.trimleft": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/string.prototype.trimleft/-/string.prototype.trimleft-2.1.1.tgz", + "integrity": "sha512-iu2AGd3PuP5Rp7x2kEZCrB2Nf41ehzh+goo8TV7z8/XDBbsvc6HQIlUl9RjkZ4oyrW1XM5UwlGl1oVEaDjg6Ag==", + "dev": true, + "requires": { + "define-properties": "^1.1.3", + "function-bind": "^1.1.1" + } + }, + "string.prototype.trimright": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/string.prototype.trimright/-/string.prototype.trimright-2.1.1.tgz", + "integrity": "sha512-qFvWL3/+QIgZXVmJBfpHmxLB7xsUXz6HsUmP8+5dRaC3Q7oKUv9Vo6aMCRZC1smrtyECFsIT30PqBJ1gTjAs+g==", + "dev": true, + "requires": { + "define-properties": "^1.1.3", + "function-bind": "^1.1.1" + } + } + } + }, + "array.prototype.flat": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/array.prototype.flat/-/array.prototype.flat-1.2.3.tgz", + "integrity": "sha512-gBlRZV0VSmfPIeWfuuy56XZMvbVfbEUnOXUvt3F/eUUUSyzlgLxhEX4YAEpxNAogRGehPSnfXyPtYyKAhkzQhQ==", + "dev": true, + "requires": { + "define-properties": "^1.1.3", + "es-abstract": "^1.17.0-next.1" + }, + "dependencies": { + "es-abstract": { + "version": "1.17.4", + "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.17.4.tgz", + "integrity": "sha512-Ae3um/gb8F0mui/jPL+QiqmglkUsaQf7FwBEHYIFkztkneosu9imhqHpBzQ3h1vit8t5iQ74t6PEVvphBZiuiQ==", + "dev": true, + "requires": { + "es-to-primitive": "^1.2.1", + "function-bind": "^1.1.1", + "has": "^1.0.3", + "has-symbols": "^1.0.1", + "is-callable": "^1.1.5", + "is-regex": "^1.0.5", + "object-inspect": "^1.7.0", + "object-keys": "^1.1.1", + "object.assign": "^4.1.0", + "string.prototype.trimleft": "^2.1.1", + "string.prototype.trimright": "^2.1.1" + } + }, + "es-to-primitive": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.1.tgz", + "integrity": "sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA==", + "dev": true, + "requires": { + "is-callable": "^1.1.4", + "is-date-object": "^1.0.1", + "is-symbol": "^1.0.2" + } + }, + "has-symbols": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.1.tgz", + "integrity": "sha512-PLcsoqu++dmEIZB+6totNFKq/7Do+Z0u4oT0zKOJNl3lYK6vGwwu2hjHs+68OEZbTjiUE9bgOABXbP/GvrS0Kg==", + "dev": true + }, + "is-callable": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.1.5.tgz", + "integrity": "sha512-ESKv5sMCJB2jnHTWZ3O5itG+O128Hsus4K4Qh1h2/cgn2vbgnLSVqfV46AeJA9D5EeeLa9w81KUXMtn34zhX+Q==", + "dev": true + }, + "is-regex": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.0.5.tgz", + "integrity": "sha512-vlKW17SNq44owv5AQR3Cq0bQPEb8+kF3UKZ2fiZNOWtztYE5i0CzCZxFDwO58qAOWtxdBRVO/V5Qin1wjCqFYQ==", + "dev": true, + "requires": { + "has": "^1.0.3" + } + }, + "object-inspect": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.7.0.tgz", + "integrity": "sha512-a7pEHdh1xKIAgTySUGgLMx/xwDZskN1Ud6egYYN3EdRW4ZMPNEDUTF+hwy2LUC+Bl+SyLXANnwz/jyh/qutKUw==", + "dev": true + }, + "string.prototype.trimleft": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/string.prototype.trimleft/-/string.prototype.trimleft-2.1.1.tgz", + "integrity": "sha512-iu2AGd3PuP5Rp7x2kEZCrB2Nf41ehzh+goo8TV7z8/XDBbsvc6HQIlUl9RjkZ4oyrW1XM5UwlGl1oVEaDjg6Ag==", + "dev": true, + "requires": { + "define-properties": "^1.1.3", + "function-bind": "^1.1.1" + } + }, + "string.prototype.trimright": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/string.prototype.trimright/-/string.prototype.trimright-2.1.1.tgz", + "integrity": "sha512-qFvWL3/+QIgZXVmJBfpHmxLB7xsUXz6HsUmP8+5dRaC3Q7oKUv9Vo6aMCRZC1smrtyECFsIT30PqBJ1gTjAs+g==", + "dev": true, + "requires": { + "define-properties": "^1.1.3", + "function-bind": "^1.1.1" + } + } + } + }, "asn1": { "version": "0.2.4", "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.4.tgz", @@ -419,6 +598,12 @@ "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=" }, + "contains-path": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/contains-path/-/contains-path-0.1.0.tgz", + "integrity": "sha1-/ozxhP9mcLa67wGp1IYaXL7EEgo=", + "dev": true + }, "core-util-is": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", @@ -552,6 +737,15 @@ "integrity": "sha1-QWgTO0K7BcOKNbGuQ5fIKYqzaeA=", "dev": true }, + "error-ex": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", + "integrity": "sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==", + "dev": true, + "requires": { + "is-arrayish": "^0.2.1" + } + }, "es-abstract": { "version": "1.14.2", "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.14.2.tgz", @@ -661,6 +855,195 @@ } } }, + "eslint-config-semistandard": { + "version": "15.0.0", + "resolved": "https://registry.npmjs.org/eslint-config-semistandard/-/eslint-config-semistandard-15.0.0.tgz", + "integrity": "sha512-volIMnosUvzyxGkYUA5QvwkahZZLeUx7wcS0+7QumPn+MMEBbV6P7BY1yukamMst0w3Et3QZlCjQEwQ8tQ6nug==", + "dev": true + }, + "eslint-config-standard": { + "version": "14.1.0", + "resolved": "https://registry.npmjs.org/eslint-config-standard/-/eslint-config-standard-14.1.0.tgz", + "integrity": "sha512-EF6XkrrGVbvv8hL/kYa/m6vnvmUT+K82pJJc4JJVMM6+Qgqh0pnwprSxdduDLB9p/7bIxD+YV5O0wfb8lmcPbA==", + "dev": true + }, + "eslint-import-resolver-node": { + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.3.tgz", + "integrity": "sha512-b8crLDo0M5RSe5YG8Pu2DYBj71tSB6OvXkfzwbJU2w7y8P4/yo0MyF8jU26IEuEuHF2K5/gcAJE3LhQGqBBbVg==", + "dev": true, + "requires": { + "debug": "^2.6.9", + "resolve": "^1.13.1" + }, + "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dev": true, + "requires": { + "ms": "2.0.0" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "dev": true + } + } + }, + "eslint-module-utils": { + "version": "2.5.2", + "resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.5.2.tgz", + "integrity": "sha512-LGScZ/JSlqGKiT8OC+cYRxseMjyqt6QO54nl281CK93unD89ijSeRV6An8Ci/2nvWVKe8K/Tqdm75RQoIOCr+Q==", + "dev": true, + "requires": { + "debug": "^2.6.9", + "pkg-dir": "^2.0.0" + }, + "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dev": true, + "requires": { + "ms": "2.0.0" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "dev": true + } + } + }, + "eslint-plugin-es": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-es/-/eslint-plugin-es-3.0.0.tgz", + "integrity": "sha512-6/Jb/J/ZvSebydwbBJO1R9E5ky7YeElfK56Veh7e4QGFHCXoIXGH9HhVz+ibJLM3XJ1XjP+T7rKBLUa/Y7eIng==", + "dev": true, + "requires": { + "eslint-utils": "^2.0.0", + "regexpp": "^3.0.0" + }, + "dependencies": { + "eslint-utils": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-2.0.0.tgz", + "integrity": "sha512-0HCPuJv+7Wv1bACm8y5/ECVfYdfsAm9xmVb7saeFlxjPYALefjhbYoCkBjPdPzGH8wWyTpAez82Fh3VKYEZ8OA==", + "dev": true, + "requires": { + "eslint-visitor-keys": "^1.1.0" + } + }, + "regexpp": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-3.0.0.tgz", + "integrity": "sha512-Z+hNr7RAVWxznLPuA7DIh8UNX1j9CDrUQxskw9IrBE1Dxue2lyXT+shqEIeLUjrokxIP8CMy1WkjgG3rTsd5/g==", + "dev": true + } + } + }, + "eslint-plugin-import": { + "version": "2.20.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.20.0.tgz", + "integrity": "sha512-NK42oA0mUc8Ngn4kONOPsPB1XhbUvNHqF+g307dPV28aknPoiNnKLFd9em4nkswwepdF5ouieqv5Th/63U7YJQ==", + "dev": true, + "requires": { + "array-includes": "^3.0.3", + "array.prototype.flat": "^1.2.1", + "contains-path": "^0.1.0", + "debug": "^2.6.9", + "doctrine": "1.5.0", + "eslint-import-resolver-node": "^0.3.2", + "eslint-module-utils": "^2.4.1", + "has": "^1.0.3", + "minimatch": "^3.0.4", + "object.values": "^1.1.0", + "read-pkg-up": "^2.0.0", + "resolve": "^1.12.0" + }, + "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dev": true, + "requires": { + "ms": "2.0.0" + } + }, + "doctrine": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-1.5.0.tgz", + "integrity": "sha1-N53Ocw9hZvds76TmcHoVmwLFpvo=", + "dev": true, + "requires": { + "esutils": "^2.0.2", + "isarray": "^1.0.0" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "dev": true + } + } + }, + "eslint-plugin-node": { + "version": "11.0.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-node/-/eslint-plugin-node-11.0.0.tgz", + "integrity": "sha512-chUs/NVID+sknFiJzxoN9lM7uKSOEta8GC8365hw1nDfwIPIjjpRSwwPvQanWv8dt/pDe9EV4anmVSwdiSndNg==", + "dev": true, + "requires": { + "eslint-plugin-es": "^3.0.0", + "eslint-utils": "^2.0.0", + "ignore": "^5.1.1", + "minimatch": "^3.0.4", + "resolve": "^1.10.1", + "semver": "^6.1.0" + }, + "dependencies": { + "eslint-utils": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-2.0.0.tgz", + "integrity": "sha512-0HCPuJv+7Wv1bACm8y5/ECVfYdfsAm9xmVb7saeFlxjPYALefjhbYoCkBjPdPzGH8wWyTpAez82Fh3VKYEZ8OA==", + "dev": true, + "requires": { + "eslint-visitor-keys": "^1.1.0" + } + }, + "ignore": { + "version": "5.1.4", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.1.4.tgz", + "integrity": "sha512-MzbUSahkTW1u7JpKKjY7LCARd1fU5W2rLdxlM4kdkayuCwZImjkpluF9CM1aLewYJguPDqewLam18Y6AU69A8A==", + "dev": true + }, + "semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "dev": true + } + } + }, + "eslint-plugin-promise": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-promise/-/eslint-plugin-promise-4.2.1.tgz", + "integrity": "sha512-VoM09vT7bfA7D+upt+FjeBO5eHIJQBUWki1aPvB+vbNiHS3+oGIJGIeyBtKQTME6UPXXy3vV07OL1tHd3ANuDw==", + "dev": true + }, + "eslint-plugin-standard": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-standard/-/eslint-plugin-standard-4.0.1.tgz", + "integrity": "sha512-v/KBnfyaOMPmZc/dmc6ozOdWqekGp7bBGq4jLAecEfPGmfKiWS4sA8sC0LqiV9w5qmXAtXVn4M3p1jSyhY85SQ==", + "dev": true + }, "eslint-scope": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.0.0.tgz", @@ -1049,6 +1432,12 @@ "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==", "dev": true }, + "hosted-git-info": { + "version": "2.8.5", + "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.5.tgz", + "integrity": "sha512-kssjab8CvdXfcXMXVcvsXum4Hwdq9XGtRD3TteMEvEbq0LXyiNQr6AprqKqfeaDXze7SxWvRxdpwE6ku7ikLkg==", + "dev": true + }, "http-signature": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz", @@ -1199,12 +1588,24 @@ } } }, + "install": { + "version": "0.13.0", + "resolved": "https://registry.npmjs.org/install/-/install-0.13.0.tgz", + "integrity": "sha512-zDml/jzr2PKU9I8J/xyZBQn8rPCAY//UOYNmR01XwNwyfhEWObo2SWfSl1+0tm1u6PhxLwDnfsT/6jB7OUxqFA==", + "dev": true + }, "invert-kv": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/invert-kv/-/invert-kv-2.0.0.tgz", "integrity": "sha512-wPVv/y/QQ/Uiirj/vh3oP+1Ww+AWehmi1g5fFWGPF6IpCBCDVrhgHRMvrLfdYcwDh3QJbGXDW4JAuzxElLSqKA==", "dev": true }, + "is-arrayish": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", + "integrity": "sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0=", + "dev": true + }, "is-buffer": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.3.tgz", @@ -1267,6 +1668,12 @@ "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=", "dev": true }, + "is-string": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/is-string/-/is-string-1.0.5.tgz", + "integrity": "sha512-buY6VNRjhQMiF1qWDouloZlQbRhDPCebwxSjxMjxgemYT46YMd2NR0/H+fBhEfWX4A/w9TBJ+ol+okqJKFE6vQ==", + "dev": true + }, "is-symbol": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.2.tgz", @@ -1382,6 +1789,18 @@ "type-check": "~0.3.2" } }, + "load-json-file": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-2.0.0.tgz", + "integrity": "sha1-eUfkIUmvgNaWy/eXvKq8/h/inKg=", + "dev": true, + "requires": { + "graceful-fs": "^4.1.2", + "parse-json": "^2.2.0", + "pify": "^2.0.0", + "strip-bom": "^3.0.0" + } + }, "locate-path": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", @@ -1729,6 +2148,18 @@ "osenv": "^0.1.4" } }, + "normalize-package-data": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz", + "integrity": "sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==", + "dev": true, + "requires": { + "hosted-git-info": "^2.1.4", + "resolve": "^1.10.0", + "semver": "2 || 3 || 4 || 5", + "validate-npm-package-license": "^3.0.1" + } + }, "npm-bundled": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/npm-bundled/-/npm-bundled-1.0.6.tgz", @@ -1815,6 +2246,97 @@ "es-abstract": "^1.5.1" } }, + "object.values": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/object.values/-/object.values-1.1.1.tgz", + "integrity": "sha512-WTa54g2K8iu0kmS/us18jEmdv1a4Wi//BZ/DTVYEcH0XhLM5NYdpDHja3gt57VrZLcNAO2WGA+KpWsDBaHt6eA==", + "dev": true, + "requires": { + "define-properties": "^1.1.3", + "es-abstract": "^1.17.0-next.1", + "function-bind": "^1.1.1", + "has": "^1.0.3" + }, + "dependencies": { + "es-abstract": { + "version": "1.17.4", + "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.17.4.tgz", + "integrity": "sha512-Ae3um/gb8F0mui/jPL+QiqmglkUsaQf7FwBEHYIFkztkneosu9imhqHpBzQ3h1vit8t5iQ74t6PEVvphBZiuiQ==", + "dev": true, + "requires": { + "es-to-primitive": "^1.2.1", + "function-bind": "^1.1.1", + "has": "^1.0.3", + "has-symbols": "^1.0.1", + "is-callable": "^1.1.5", + "is-regex": "^1.0.5", + "object-inspect": "^1.7.0", + "object-keys": "^1.1.1", + "object.assign": "^4.1.0", + "string.prototype.trimleft": "^2.1.1", + "string.prototype.trimright": "^2.1.1" + } + }, + "es-to-primitive": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.1.tgz", + "integrity": "sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA==", + "dev": true, + "requires": { + "is-callable": "^1.1.4", + "is-date-object": "^1.0.1", + "is-symbol": "^1.0.2" + } + }, + "has-symbols": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.1.tgz", + "integrity": "sha512-PLcsoqu++dmEIZB+6totNFKq/7Do+Z0u4oT0zKOJNl3lYK6vGwwu2hjHs+68OEZbTjiUE9bgOABXbP/GvrS0Kg==", + "dev": true + }, + "is-callable": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.1.5.tgz", + "integrity": "sha512-ESKv5sMCJB2jnHTWZ3O5itG+O128Hsus4K4Qh1h2/cgn2vbgnLSVqfV46AeJA9D5EeeLa9w81KUXMtn34zhX+Q==", + "dev": true + }, + "is-regex": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.0.5.tgz", + "integrity": "sha512-vlKW17SNq44owv5AQR3Cq0bQPEb8+kF3UKZ2fiZNOWtztYE5i0CzCZxFDwO58qAOWtxdBRVO/V5Qin1wjCqFYQ==", + "dev": true, + "requires": { + "has": "^1.0.3" + } + }, + "object-inspect": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.7.0.tgz", + "integrity": "sha512-a7pEHdh1xKIAgTySUGgLMx/xwDZskN1Ud6egYYN3EdRW4ZMPNEDUTF+hwy2LUC+Bl+SyLXANnwz/jyh/qutKUw==", + "dev": true + }, + "string.prototype.trimleft": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/string.prototype.trimleft/-/string.prototype.trimleft-2.1.1.tgz", + "integrity": "sha512-iu2AGd3PuP5Rp7x2kEZCrB2Nf41ehzh+goo8TV7z8/XDBbsvc6HQIlUl9RjkZ4oyrW1XM5UwlGl1oVEaDjg6Ag==", + "dev": true, + "requires": { + "define-properties": "^1.1.3", + "function-bind": "^1.1.1" + } + }, + "string.prototype.trimright": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/string.prototype.trimright/-/string.prototype.trimright-2.1.1.tgz", + "integrity": "sha512-qFvWL3/+QIgZXVmJBfpHmxLB7xsUXz6HsUmP8+5dRaC3Q7oKUv9Vo6aMCRZC1smrtyECFsIT30PqBJ1gTjAs+g==", + "dev": true, + "requires": { + "define-properties": "^1.1.3", + "function-bind": "^1.1.1" + } + } + } + }, "once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", @@ -1929,6 +2451,15 @@ "callsites": "^3.0.0" } }, + "parse-json": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-2.2.0.tgz", + "integrity": "sha1-9ID0BDTvgHQfhGkJn43qGPVaTck=", + "dev": true, + "requires": { + "error-ex": "^1.2.0" + } + }, "path-exists": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", @@ -1946,6 +2477,12 @@ "integrity": "sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A=", "dev": true }, + "path-parse": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", + "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==", + "dev": true + }, "path-to-regexp": { "version": "1.7.0", "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-1.7.0.tgz", @@ -1963,12 +2500,81 @@ } } }, + "path-type": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/path-type/-/path-type-2.0.0.tgz", + "integrity": "sha1-8BLMuEFbcJb8LaoQVMPXI4lZTHM=", + "dev": true, + "requires": { + "pify": "^2.0.0" + } + }, "performance-now": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=", "dev": true }, + "pify": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", + "dev": true + }, + "pkg-dir": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-2.0.0.tgz", + "integrity": "sha1-9tXREJ4Z1j7fQo4L1X4Sd3YVM0s=", + "dev": true, + "requires": { + "find-up": "^2.1.0" + }, + "dependencies": { + "find-up": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-2.1.0.tgz", + "integrity": "sha1-RdG35QbHF93UgndaK3eSCjwMV6c=", + "dev": true, + "requires": { + "locate-path": "^2.0.0" + } + }, + "locate-path": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-2.0.0.tgz", + "integrity": "sha1-K1aLJl7slExtnA3pw9u7ygNUzY4=", + "dev": true, + "requires": { + "p-locate": "^2.0.0", + "path-exists": "^3.0.0" + } + }, + "p-limit": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-1.3.0.tgz", + "integrity": "sha512-vvcXsLAJ9Dr5rQOPk7toZQZJApBl2K4J6dANSsEuh6QI41JYcsS/qhTGa9ErIUUgK3WNQoJYvylxvjqmiqEA9Q==", + "dev": true, + "requires": { + "p-try": "^1.0.0" + } + }, + "p-locate": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-2.0.0.tgz", + "integrity": "sha1-IKAQOyIqcMj9OcwuWAaA893l7EM=", + "dev": true, + "requires": { + "p-limit": "^1.1.0" + } + }, + "p-try": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-1.0.0.tgz", + "integrity": "sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M=", + "dev": true + } + } + }, "prebuild-install": { "version": "5.3.2", "resolved": "https://registry.npmjs.org/prebuild-install/-/prebuild-install-5.3.2.tgz", @@ -2070,6 +2676,72 @@ } } }, + "read-pkg": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-2.0.0.tgz", + "integrity": "sha1-jvHAYjxqbbDcZxPEv6xGMysjaPg=", + "dev": true, + "requires": { + "load-json-file": "^2.0.0", + "normalize-package-data": "^2.3.2", + "path-type": "^2.0.0" + } + }, + "read-pkg-up": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-2.0.0.tgz", + "integrity": "sha1-a3KoBImE4MQeeVEP1en6mbO1Sb4=", + "dev": true, + "requires": { + "find-up": "^2.0.0", + "read-pkg": "^2.0.0" + }, + "dependencies": { + "find-up": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-2.1.0.tgz", + "integrity": "sha1-RdG35QbHF93UgndaK3eSCjwMV6c=", + "dev": true, + "requires": { + "locate-path": "^2.0.0" + } + }, + "locate-path": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-2.0.0.tgz", + "integrity": "sha1-K1aLJl7slExtnA3pw9u7ygNUzY4=", + "dev": true, + "requires": { + "p-locate": "^2.0.0", + "path-exists": "^3.0.0" + } + }, + "p-limit": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-1.3.0.tgz", + "integrity": "sha512-vvcXsLAJ9Dr5rQOPk7toZQZJApBl2K4J6dANSsEuh6QI41JYcsS/qhTGa9ErIUUgK3WNQoJYvylxvjqmiqEA9Q==", + "dev": true, + "requires": { + "p-try": "^1.0.0" + } + }, + "p-locate": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-2.0.0.tgz", + "integrity": "sha1-IKAQOyIqcMj9OcwuWAaA893l7EM=", + "dev": true, + "requires": { + "p-limit": "^1.1.0" + } + }, + "p-try": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-1.0.0.tgz", + "integrity": "sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M=", + "dev": true + } + } + }, "readable-stream": { "version": "2.3.6", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", @@ -2130,6 +2802,15 @@ "integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==", "dev": true }, + "resolve": { + "version": "1.15.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.15.0.tgz", + "integrity": "sha512-+hTmAldEGE80U2wJJDC1lebb5jWqvTYAfm3YZ1ckk1gBr0MnCqUKlwK1e+anaFljIl+F5tR5IoZcm4ZDA1zMQw==", + "dev": true, + "requires": { + "path-parse": "^1.0.6" + } + }, "resolve-from": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", @@ -2334,6 +3015,38 @@ } } }, + "spdx-correct": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.1.0.tgz", + "integrity": "sha512-lr2EZCctC2BNR7j7WzJ2FpDznxky1sjfxvvYEyzxNyb6lZXHODmEoJeFu4JupYlkfha1KZpJyoqiJ7pgA1qq8Q==", + "dev": true, + "requires": { + "spdx-expression-parse": "^3.0.0", + "spdx-license-ids": "^3.0.0" + } + }, + "spdx-exceptions": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.2.0.tgz", + "integrity": "sha512-2XQACfElKi9SlVb1CYadKDXvoajPgBVPn/gOQLrTvHdElaVhr7ZEbqJaRnJLVNeaI4cMEAgVCeBMKF6MWRDCRA==", + "dev": true + }, + "spdx-expression-parse": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.0.tgz", + "integrity": "sha512-Yg6D3XpRD4kkOmTpdgbUiEJFKghJH03fiC1OPll5h/0sO6neh2jqRDVHOQ4o/LMea0tgCkbMgea5ip/e+MkWyg==", + "dev": true, + "requires": { + "spdx-exceptions": "^2.1.0", + "spdx-license-ids": "^3.0.0" + } + }, + "spdx-license-ids": { + "version": "3.0.5", + "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.5.tgz", + "integrity": "sha512-J+FWzZoynJEXGphVIS+XEh3kFSjZX/1i9gFBaWQcB+/tmpe2qUsSBABpcxqxnAxFdiUFEgAX1bjYGQvIZmoz9Q==", + "dev": true + }, "sprintf-js": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", @@ -2403,6 +3116,12 @@ "ansi-regex": "^2.0.0" } }, + "strip-bom": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", + "integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=", + "dev": true + }, "strip-eof": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz", @@ -2646,6 +3365,16 @@ "integrity": "sha512-usZBT3PW+LOjM25wbqIlZwPeJV+3OSz3M1k1Ws8snlW39dZyYL9lOGC5FgPVHfk0jKmjiDV8Z0mIbVQPiwFs7g==", "dev": true }, + "validate-npm-package-license": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz", + "integrity": "sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew==", + "dev": true, + "requires": { + "spdx-correct": "^3.0.0", + "spdx-expression-parse": "^3.0.0" + } + }, "verror": { "version": "1.10.0", "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz", diff --git a/package.json b/package.json index fb70ee134..b3e933244 100644 --- a/package.json +++ b/package.json @@ -44,6 +44,13 @@ "devDependencies": { "async": "^3.1.0", "eslint": "^6.8.0", + "eslint-config-semistandard": "^15.0.0", + "eslint-config-standard": "^14.1.0", + "eslint-plugin-import": "^2.20.0", + "eslint-plugin-node": "^11.0.0", + "eslint-plugin-promise": "^4.2.1", + "eslint-plugin-standard": "^4.0.1", + "install": "^0.13.0", "mocha": "^6.2.0", "node-gyp": "^5.0.3", "prettier": "^1.19.1", diff --git a/test.js b/test.js index 5f30d1f5a..b60e39e55 100644 --- a/test.js +++ b/test.js @@ -2,7 +2,7 @@ var noble = require('./index'); console.log('noble'); -noble.on('stateChange', function(state) { +noble.on('stateChange', function (state) { console.log('on -> stateChange: ' + state); if (state === 'poweredOn') { @@ -12,107 +12,102 @@ noble.on('stateChange', function(state) { } }); -noble.on('scanStart', function() { +noble.on('scanStart', function () { console.log('on -> scanStart'); }); -noble.on('scanStop', function() { +noble.on('scanStop', function () { console.log('on -> scanStop'); }); - - -noble.on('discover', function(peripheral) { +noble.on('discover', function (peripheral) { console.log('on -> discover: ' + peripheral); noble.stopScanning(); - peripheral.on('connect', function() { + peripheral.on('connect', function () { console.log('on -> connect'); this.updateRssi(); }); - peripheral.on('disconnect', function() { + peripheral.on('disconnect', function () { console.log('on -> disconnect'); }); - peripheral.on('rssiUpdate', function(rssi) { + peripheral.on('rssiUpdate', function (rssi) { console.log('on -> RSSI update ' + rssi); this.discoverServices(); }); - peripheral.on('servicesDiscover', function(services) { + peripheral.on('servicesDiscover', function (services) { console.log('on -> peripheral services discovered ' + services); var serviceIndex = 0; - services[serviceIndex].on('includedServicesDiscover', function(includedServiceUuids) { + services[serviceIndex].on('includedServicesDiscover', function (includedServiceUuids) { console.log('on -> service included services discovered ' + includedServiceUuids); this.discoverCharacteristics(); }); - services[serviceIndex].on('characteristicsDiscover', function(characteristics) { + services[serviceIndex].on('characteristicsDiscover', function (characteristics) { console.log('on -> service characteristics discovered ' + characteristics); var characteristicIndex = 0; - characteristics[characteristicIndex].on('read', function(data, isNotification) { + characteristics[characteristicIndex].on('read', function (data, isNotification) { console.log('on -> characteristic read ' + data + ' ' + isNotification); console.log(data); peripheral.disconnect(); }); - characteristics[characteristicIndex].on('write', function() { + characteristics[characteristicIndex].on('write', function () { console.log('on -> characteristic write '); peripheral.disconnect(); }); - characteristics[characteristicIndex].on('broadcast', function(state) { + characteristics[characteristicIndex].on('broadcast', function (state) { console.log('on -> characteristic broadcast ' + state); peripheral.disconnect(); }); - characteristics[characteristicIndex].on('notify', function(state) { + characteristics[characteristicIndex].on('notify', function (state) { console.log('on -> characteristic notify ' + state); peripheral.disconnect(); }); - characteristics[characteristicIndex].on('descriptorsDiscover', function(descriptors) { + characteristics[characteristicIndex].on('descriptorsDiscover', function (descriptors) { console.log('on -> descriptors discover ' + descriptors); var descriptorIndex = 0; - descriptors[descriptorIndex].on('valueRead', function(data) { + descriptors[descriptorIndex].on('valueRead', function (data) { console.log('on -> descriptor value read ' + data); console.log(data); peripheral.disconnect(); }); - descriptors[descriptorIndex].on('valueWrite', function() { + descriptors[descriptorIndex].on('valueWrite', function () { console.log('on -> descriptor value write '); peripheral.disconnect(); }); descriptors[descriptorIndex].readValue(); - //descriptors[descriptorIndex].writeValue(new Buffer([0])); + // descriptors[descriptorIndex].writeValue(new Buffer([0])); }); - characteristics[characteristicIndex].read(); - //characteristics[characteristicIndex].write(new Buffer('hello')); - //characteristics[characteristicIndex].broadcast(true); - //characteristics[characteristicIndex].notify(true); + // characteristics[characteristicIndex].write(new Buffer('hello')); + // characteristics[characteristicIndex].broadcast(true); + // characteristics[characteristicIndex].notify(true); // characteristics[characteristicIndex].discoverDescriptors(); }); - services[serviceIndex].discoverIncludedServices(); }); peripheral.connect(); }); - diff --git a/test/test-characteristic.js b/test/test-characteristic.js index b3830d330..ab18cddfb 100644 --- a/test/test-characteristic.js +++ b/test/test-characteristic.js @@ -3,7 +3,7 @@ var sinon = require('sinon'); var Characteristic = require('../lib/characteristic'); -describe('Characteristic', function() { +describe('Characteristic', function () { var mockNoble = null; var mockPeripheralId = 'mock-peripheral-id'; var mockServiceUuid = 'mock-service-uuid'; @@ -12,7 +12,7 @@ describe('Characteristic', function() { var characteristic = null; - beforeEach(function() { + beforeEach(function () { mockNoble = { read: sinon.spy(), write: sinon.spy(), @@ -24,42 +24,42 @@ describe('Characteristic', function() { characteristic = new Characteristic(mockNoble, mockPeripheralId, mockServiceUuid, mockUuid, mockProperties); }); - afterEach(function() { + afterEach(function () { characteristic = null; }); - it('should have a uuid', function() { + it('should have a uuid', function () { characteristic.uuid.should.equal(mockUuid); }); - it('should lookup name and type by uuid', function() { + it('should lookup name and type by uuid', function () { characteristic = new Characteristic(mockNoble, mockPeripheralId, mockServiceUuid, '2a00', mockProperties); characteristic.name.should.equal('Device Name'); characteristic.type.should.equal('org.bluetooth.characteristic.gap.device_name'); }); - it('should have properties', function() { + it('should have properties', function () { characteristic.properties.should.equal(mockProperties); }); - describe('toString', function() { - it('should be uuid, name, type, properties', function() { + describe('toString', function () { + it('should be uuid, name, type, properties', function () { characteristic.toString().should.equal('{"uuid":"mock-uuid","name":null,"type":null,"properties":["mock-property-1","mock-property-2"]}'); }); }); - describe('read', function() { - it('should delegate to noble', function() { + describe('read', function () { + it('should delegate to noble', function () { characteristic.read(); mockNoble.read.calledWithExactly(mockPeripheralId, mockServiceUuid, mockUuid).should.equal(true); }); - it('should callback', function() { + it('should callback', function () { var calledback = false; - characteristic.read(function() { + characteristic.read(function () { calledback = true; }); characteristic.emit('read'); @@ -67,11 +67,11 @@ describe('Characteristic', function() { calledback.should.equal(true); }); - it('should callback with data', function() { + it('should callback with data', function () { var mockData = new Buffer(0); var callbackData = null; - characteristic.read(function(error, data) { + characteristic.read(function (error, data) { callbackData = data; }); characteristic.emit('read', mockData); @@ -80,37 +80,37 @@ describe('Characteristic', function() { }); }); - describe('write', function() { + describe('write', function () { var mockData = null; - beforeEach(function() { + beforeEach(function () { mockData = new Buffer(0); }); - it('should only accept data as a buffer', function() { + it('should only accept data as a buffer', function () { mockData = {}; - (function(){ + (function () { characteristic.write(mockData); }).should.throwError('data must be a Buffer'); }); - it('should delegate to noble, withoutResponse false', function() { + it('should delegate to noble, withoutResponse false', function () { characteristic.write(mockData, false); mockNoble.write.calledWithExactly(mockPeripheralId, mockServiceUuid, mockUuid, mockData, false).should.equal(true); }); - it('should delegate to noble, withoutResponse true', function() { + it('should delegate to noble, withoutResponse true', function () { characteristic.write(mockData, true); mockNoble.write.calledWithExactly(mockPeripheralId, mockServiceUuid, mockUuid, mockData, true).should.equal(true); }); - it('should callback', function() { + it('should callback', function () { var calledback = false; - characteristic.write(mockData, true, function() { + characteristic.write(mockData, true, function () { calledback = true; }); characteristic.emit('write'); @@ -119,23 +119,23 @@ describe('Characteristic', function() { }); }); - describe('broadcast', function() { - it('should delegate to noble, true', function() { + describe('broadcast', function () { + it('should delegate to noble, true', function () { characteristic.broadcast(true); mockNoble.broadcast.calledWithExactly(mockPeripheralId, mockServiceUuid, mockUuid, true).should.equal(true); }); - it('should delegate to noble, false', function() { + it('should delegate to noble, false', function () { characteristic.broadcast(false); mockNoble.broadcast.calledWithExactly(mockPeripheralId, mockServiceUuid, mockUuid, false).should.equal(true); }); - it('should callback', function() { + it('should callback', function () { var calledback = false; - characteristic.broadcast(true, function() { + characteristic.broadcast(true, function () { calledback = true; }); characteristic.emit('broadcast'); @@ -144,23 +144,23 @@ describe('Characteristic', function() { }); }); - describe('notify', function() { - it('should delegate to noble, true', function() { + describe('notify', function () { + it('should delegate to noble, true', function () { characteristic.notify(true); mockNoble.notify.calledWithExactly(mockPeripheralId, mockServiceUuid, mockUuid, true).should.equal(true); }); - it('should delegate to noble, false', function() { + it('should delegate to noble, false', function () { characteristic.notify(false); mockNoble.notify.calledWithExactly(mockPeripheralId, mockServiceUuid, mockUuid, false).should.equal(true); }); - it('should callback', function() { + it('should callback', function () { var calledback = false; - characteristic.notify(true, function() { + characteristic.notify(true, function () { calledback = true; }); characteristic.emit('notify'); @@ -169,17 +169,17 @@ describe('Characteristic', function() { }); }); - describe('subscribe', function() { - it('should delegate to noble notify, true', function() { + describe('subscribe', function () { + it('should delegate to noble notify, true', function () { characteristic.subscribe(); mockNoble.notify.calledWithExactly(mockPeripheralId, mockServiceUuid, mockUuid, true).should.equal(true); }); - it('should callback', function() { + it('should callback', function () { var calledback = false; - characteristic.subscribe(function() { + characteristic.subscribe(function () { calledback = true; }); characteristic.emit('notify'); @@ -188,17 +188,17 @@ describe('Characteristic', function() { }); }); - describe('unsubscribe', function() { - it('should delegate to noble notify, false', function() { + describe('unsubscribe', function () { + it('should delegate to noble notify, false', function () { characteristic.unsubscribe(); mockNoble.notify.calledWithExactly(mockPeripheralId, mockServiceUuid, mockUuid, false).should.equal(true); }); - it('should callback', function() { + it('should callback', function () { var calledback = false; - characteristic.unsubscribe(function() { + characteristic.unsubscribe(function () { calledback = true; }); characteristic.emit('notify'); @@ -207,17 +207,17 @@ describe('Characteristic', function() { }); }); - describe('discoverDescriptors', function() { - it('should delegate to noble', function() { + describe('discoverDescriptors', function () { + it('should delegate to noble', function () { characteristic.discoverDescriptors(); mockNoble.discoverDescriptors.calledWithExactly(mockPeripheralId, mockServiceUuid, mockUuid).should.equal(true); }); - it('should callback', function() { + it('should callback', function () { var calledback = false; - characteristic.discoverDescriptors(function() { + characteristic.discoverDescriptors(function () { calledback = true; }); characteristic.emit('descriptorsDiscover'); @@ -225,11 +225,11 @@ describe('Characteristic', function() { calledback.should.equal(true); }); - it('should callback with descriptors', function() { + it('should callback with descriptors', function () { var mockDescriptors = []; var callbackDescriptors = null; - characteristic.discoverDescriptors(function(error, descriptors) { + characteristic.discoverDescriptors(function (error, descriptors) { callbackDescriptors = descriptors; }); characteristic.emit('descriptorsDiscover', mockDescriptors); diff --git a/test/test-descriptor.js b/test/test-descriptor.js index 890958635..cdd2e852f 100644 --- a/test/test-descriptor.js +++ b/test/test-descriptor.js @@ -3,7 +3,7 @@ var sinon = require('sinon'); var Descriptor = require('../lib/descriptor'); -describe('Descriptor', function() { +describe('Descriptor', function () { var mockNoble = null; var mockPeripheralId = 'mock-peripheral-id'; var mockServiceUuid = 'mock-service-uuid'; @@ -12,7 +12,7 @@ describe('Descriptor', function() { var descriptor = null; - beforeEach(function() { + beforeEach(function () { mockNoble = { readValue: sinon.spy(), writeValue: sinon.spy() @@ -21,38 +21,38 @@ describe('Descriptor', function() { descriptor = new Descriptor(mockNoble, mockPeripheralId, mockServiceUuid, mockCharacteristicUuid, mockUuid); }); - afterEach(function() { + afterEach(function () { descriptor = null; }); - it('should have a uuid', function() { + it('should have a uuid', function () { descriptor.uuid.should.equal(mockUuid); }); - it('should lookup name and type by uuid', function() { + it('should lookup name and type by uuid', function () { descriptor = new Descriptor(mockNoble, mockPeripheralId, mockServiceUuid, mockCharacteristicUuid, '2900'); descriptor.name.should.equal('Characteristic Extended Properties'); descriptor.type.should.equal('org.bluetooth.descriptor.gatt.characteristic_extended_properties'); }); - describe('toString', function() { - it('should be uuid, name, type', function() { + describe('toString', function () { + it('should be uuid, name, type', function () { descriptor.toString().should.equal('{"uuid":"mock-uuid","name":null,"type":null}'); }); }); - describe('readValue', function() { - it('should delegate to noble', function() { + describe('readValue', function () { + it('should delegate to noble', function () { descriptor.readValue(); mockNoble.readValue.calledWithExactly(mockPeripheralId, mockServiceUuid, mockCharacteristicUuid, mockUuid).should.equal(true); }); - it('should callback', function() { + it('should callback', function () { var calledback = false; - descriptor.readValue(function() { + descriptor.readValue(function () { calledback = true; }); descriptor.emit('valueRead'); @@ -60,10 +60,10 @@ describe('Descriptor', function() { calledback.should.equal(true); }); - it('should not call callback twice', function() { + it('should not call callback twice', function () { var calledback = 0; - descriptor.readValue(function() { + descriptor.readValue(function () { calledback += 1; }); descriptor.emit('valueRead'); @@ -72,11 +72,11 @@ describe('Descriptor', function() { calledback.should.equal(1); }); - it('should callback with error, data', function() { + it('should callback with error, data', function () { var mockData = new Buffer(0); var callbackData = null; - descriptor.readValue(function(error, data) { + descriptor.readValue(function (error, data) { callbackData = data; }); descriptor.emit('valueRead', mockData); @@ -85,31 +85,31 @@ describe('Descriptor', function() { }); }); - describe('writeValue', function() { + describe('writeValue', function () { var mockData = null; - beforeEach(function() { + beforeEach(function () { mockData = new Buffer(0); }); - it('should only accept data as a buffer', function() { + it('should only accept data as a buffer', function () { mockData = {}; - (function(){ + (function () { descriptor.writeValue(mockData); }).should.throwError('data must be a Buffer'); }); - it('should delegate to noble', function() { + it('should delegate to noble', function () { descriptor.writeValue(mockData); mockNoble.writeValue.calledWithExactly(mockPeripheralId, mockServiceUuid, mockCharacteristicUuid, mockUuid, mockData).should.equal(true); }); - it('should callback', function() { + it('should callback', function () { var calledback = false; - descriptor.writeValue(mockData, function() { + descriptor.writeValue(mockData, function () { calledback = true; }); descriptor.emit('valueWrite'); @@ -117,10 +117,10 @@ describe('Descriptor', function() { calledback.should.equal(true); }); - it('should not call callback twice', function() { + it('should not call callback twice', function () { var calledback = 0; - descriptor.writeValue(mockData, function() { + descriptor.writeValue(mockData, function () { calledback += 1; }); descriptor.emit('valueWrite'); @@ -128,6 +128,5 @@ describe('Descriptor', function() { calledback.should.equal(1); }); - }); }); diff --git a/test/test-peripheral.js b/test/test-peripheral.js index 434be3b34..6a7e4c9a5 100644 --- a/test/test-peripheral.js +++ b/test/test-peripheral.js @@ -3,7 +3,7 @@ var sinon = require('sinon'); var Peripheral = require('../lib/peripheral'); -describe('Peripheral', function() { +describe('Peripheral', function () { var mockNoble = null; var mockId = 'mock-id'; var mockAddress = 'mock-address'; @@ -16,7 +16,7 @@ describe('Peripheral', function() { var peripheral = null; - beforeEach(function() { + beforeEach(function () { mockNoble = { connect: sinon.spy(), disconnect: sinon.spy(), @@ -29,51 +29,51 @@ describe('Peripheral', function() { peripheral = new Peripheral(mockNoble, mockId, mockAddress, mockAddressType, mockConnectable, mockAdvertisement, mockRssi); }); - afterEach(function() { + afterEach(function () { peripheral = null; }); - it('should have a id', function() { + it('should have a id', function () { peripheral.id.should.equal(mockId); }); - it('should have an address', function() { + it('should have an address', function () { peripheral.address.should.equal(mockAddress); }); - it('should have an address type', function() { + it('should have an address type', function () { peripheral.addressType.should.equal(mockAddressType); }); - it('should have connectable', function() { + it('should have connectable', function () { peripheral.connectable.should.equal(mockConnectable); }); - it('should have advertisement', function() { + it('should have advertisement', function () { peripheral.advertisement.should.equal(mockAdvertisement); }); - it('should have rssi', function() { + it('should have rssi', function () { peripheral.rssi.should.equal(mockRssi); }); - describe('toString', function() { - it('should be id, address, address type, connectable, advertisement, rssi, state', function() { + describe('toString', function () { + it('should be id, address, address type, connectable, advertisement, rssi, state', function () { peripheral.toString().should.equal('{"id":"mock-id","address":"mock-address","addressType":"mock-address-type","connectable":"mock-connectable","advertisement":"mock-advertisement","rssi":"mock-rssi","mtu":null,"state":"disconnected"}'); }); }); - describe('connect', function() { - it('should delegate to noble', function() { + describe('connect', function () { + it('should delegate to noble', function () { peripheral.connect(); mockNoble.connect.calledWithExactly(mockId).should.equal(true); }); - it('should callback', function() { + it('should callback', function () { var calledback = false; - peripheral.connect(function() { + peripheral.connect(function () { calledback = true; }); peripheral.emit('connect'); @@ -82,17 +82,17 @@ describe('Peripheral', function() { }); }); - describe('disconnect', function() { - it('should delegate to noble', function() { + describe('disconnect', function () { + it('should delegate to noble', function () { peripheral.disconnect(); mockNoble.disconnect.calledWithExactly(mockId).should.equal(true); }); - it('should callback', function() { + it('should callback', function () { var calledback = false; - peripheral.disconnect(function() { + peripheral.disconnect(function () { calledback = true; }); peripheral.emit('disconnect'); @@ -101,17 +101,17 @@ describe('Peripheral', function() { }); }); - describe('updateRssi', function() { - it('should delegate to noble', function() { + describe('updateRssi', function () { + it('should delegate to noble', function () { peripheral.updateRssi(); mockNoble.updateRssi.calledWithExactly(mockId).should.equal(true); }); - it('should callback', function() { + it('should callback', function () { var calledback = false; - peripheral.updateRssi(function() { + peripheral.updateRssi(function () { calledback = true; }); peripheral.emit('rssiUpdate'); @@ -119,10 +119,10 @@ describe('Peripheral', function() { calledback.should.equal(true); }); - it('should callback with rssi', function() { + it('should callback with rssi', function () { var calledbackRssi = null; - peripheral.updateRssi(function(error, rssi) { + peripheral.updateRssi(function (error, rssi) { calledbackRssi = rssi; }); peripheral.emit('rssiUpdate', mockRssi); @@ -131,14 +131,14 @@ describe('Peripheral', function() { }); }); - describe('discoverServices', function() { - it('should delegate to noble', function() { + describe('discoverServices', function () { + it('should delegate to noble', function () { peripheral.discoverServices(); mockNoble.discoverServices.calledWithExactly(mockId, undefined).should.equal(true); }); - it('should delegate to noble, service uuids', function() { + it('should delegate to noble, service uuids', function () { var mockServiceUuids = []; peripheral.discoverServices(mockServiceUuids); @@ -146,10 +146,10 @@ describe('Peripheral', function() { mockNoble.discoverServices.calledWithExactly(mockId, mockServiceUuids).should.equal(true); }); - it('should callback', function() { + it('should callback', function () { var calledback = false; - peripheral.discoverServices(null, function() { + peripheral.discoverServices(null, function () { calledback = true; }); peripheral.emit('servicesDiscover'); @@ -157,11 +157,11 @@ describe('Peripheral', function() { calledback.should.equal(true); }); - it('should callback with services', function() { + it('should callback with services', function () { var mockServices = []; var calledbackServices = null; - peripheral.discoverServices(null, function(error, services) { + peripheral.discoverServices(null, function (error, services) { calledbackServices = services; }); peripheral.emit('servicesDiscover', mockServices); @@ -170,12 +170,12 @@ describe('Peripheral', function() { }); }); - describe('discoverSomeServicesAndCharacteristics', function() { + describe('discoverSomeServicesAndCharacteristics', function () { var mockServiceUuids = []; var mockCharacteristicUuids = []; var mockServices = null; - beforeEach(function() { + beforeEach(function () { peripheral.discoverServices = sinon.spy(); mockServices = [ @@ -190,13 +190,13 @@ describe('Peripheral', function() { ]; }); - it('should call discoverServices', function() { + it('should call discoverServices', function () { peripheral.discoverSomeServicesAndCharacteristics(mockServiceUuids); peripheral.discoverServices.calledWith(mockServiceUuids).should.equal(true); }); - it('should call discoverCharacteristics on each service discovered', function() { + it('should call discoverCharacteristics on each service discovered', function () { peripheral.discoverSomeServicesAndCharacteristics(mockServiceUuids, mockCharacteristicUuids); var discoverServicesCallback = peripheral.discoverServices.getCall(0).args[1]; @@ -207,11 +207,10 @@ describe('Peripheral', function() { mockServices[1].discoverCharacteristics.calledWith(mockCharacteristicUuids).should.equal(true); }); - it('should callback', function() { + it('should callback', function () { var calledback = false; - - peripheral.discoverSomeServicesAndCharacteristics(mockServiceUuids, mockCharacteristicUuids, function() { + peripheral.discoverSomeServicesAndCharacteristics(mockServiceUuids, mockCharacteristicUuids, function () { calledback = true; }); @@ -225,11 +224,11 @@ describe('Peripheral', function() { calledback.should.equal(true); }); - it('should callback with the services and characteristics discovered', function() { + it('should callback with the services and characteristics discovered', function () { var calledbackServices = null; var calledbackCharacteristics = null; - peripheral.discoverSomeServicesAndCharacteristics(mockServiceUuids, mockCharacteristicUuids, function(err, services, characteristics) { + peripheral.discoverSomeServicesAndCharacteristics(mockServiceUuids, mockCharacteristicUuids, function (err, services, characteristics) { calledbackServices = services; calledbackCharacteristics = characteristics; }); @@ -250,8 +249,8 @@ describe('Peripheral', function() { }); }); - describe('discoverAllServicesAndCharacteristics', function() { - it('should call discoverSomeServicesAndCharacteristics', function() { + describe('discoverAllServicesAndCharacteristics', function () { + it('should call discoverSomeServicesAndCharacteristics', function () { var mockCallback = sinon.spy(); peripheral.discoverSomeServicesAndCharacteristics = sinon.spy(); @@ -262,17 +261,17 @@ describe('Peripheral', function() { }); }); - describe('readHandle', function() { - it('should delegate to noble', function() { + describe('readHandle', function () { + it('should delegate to noble', function () { peripheral.readHandle(mockHandle); mockNoble.readHandle.calledWithExactly(mockId, mockHandle).should.equal(true); }); - it('should callback', function() { + it('should callback', function () { var calledback = false; - peripheral.readHandle(mockHandle, function() { + peripheral.readHandle(mockHandle, function () { calledback = true; }); peripheral.emit('handleRead' + mockHandle); @@ -280,10 +279,10 @@ describe('Peripheral', function() { calledback.should.equal(true); }); - it('should callback with data', function() { + it('should callback with data', function () { var calledbackData = null; - peripheral.readHandle(mockHandle, function(error, data) { + peripheral.readHandle(mockHandle, function (error, data) { calledbackData = data; }); peripheral.emit('handleRead' + mockHandle, mockData); @@ -292,35 +291,35 @@ describe('Peripheral', function() { }); }); - describe('writeHandle', function() { - beforeEach(function() { + describe('writeHandle', function () { + beforeEach(function () { mockData = new Buffer(0); }); - it('should only accept data as a buffer', function() { + it('should only accept data as a buffer', function () { mockData = {}; - (function(){ + (function () { peripheral.writeHandle(mockHandle, mockData); }).should.throwError('data must be a Buffer'); }); - it('should delegate to noble, withoutResponse false', function() { + it('should delegate to noble, withoutResponse false', function () { peripheral.writeHandle(mockHandle, mockData, false); mockNoble.writeHandle.calledWithExactly(mockId, mockHandle, mockData, false).should.equal(true); }); - it('should delegate to noble, withoutResponse true', function() { + it('should delegate to noble, withoutResponse true', function () { peripheral.writeHandle(mockHandle, mockData, true); mockNoble.writeHandle.calledWithExactly(mockId, mockHandle, mockData, true).should.equal(true); }); - it('should callback', function() { + it('should callback', function () { var calledback = false; - peripheral.writeHandle(mockHandle, mockData, false, function() { + peripheral.writeHandle(mockHandle, mockData, false, function () { calledback = true; }); peripheral.emit('handleWrite' + mockHandle); diff --git a/test/test-service.js b/test/test-service.js index 4c0e905cb..89287abaa 100644 --- a/test/test-service.js +++ b/test/test-service.js @@ -3,14 +3,14 @@ var sinon = require('sinon'); var Service = require('../lib/service'); -describe('service', function() { +describe('service', function () { var mockNoble = null; var mockPeripheralId = 'mock-peripheral-id'; var mockUuid = 'mock-uuid'; var service = null; - beforeEach(function() { + beforeEach(function () { mockNoble = { discoverIncludedServices: sinon.spy(), discoverCharacteristics: sinon.spy() @@ -19,35 +19,35 @@ describe('service', function() { service = new Service(mockNoble, mockPeripheralId, mockUuid); }); - afterEach(function() { + afterEach(function () { service = null; }); - it('should have a uuid', function() { + it('should have a uuid', function () { service.uuid.should.equal(mockUuid); }); - it('should lookup name and type by uuid', function() { + it('should lookup name and type by uuid', function () { service = new Service(mockNoble, mockPeripheralId, '1800'); service.name.should.equal('Generic Access'); service.type.should.equal('org.bluetooth.service.generic_access'); }); - describe('toString', function() { - it('should be uuid, name, type, includedServiceUuids', function() { + describe('toString', function () { + it('should be uuid, name, type, includedServiceUuids', function () { service.toString().should.equal('{"uuid":"mock-uuid","name":null,"type":null,"includedServiceUuids":null}'); }); }); - describe('discoverIncludedServices', function() { - it('should delegate to noble', function() { + describe('discoverIncludedServices', function () { + it('should delegate to noble', function () { service.discoverIncludedServices(); mockNoble.discoverIncludedServices.calledWithExactly(mockPeripheralId, mockUuid, undefined).should.equal(true); }); - it('should delegate to noble, with uuids', function() { + it('should delegate to noble, with uuids', function () { var mockUuids = []; service.discoverIncludedServices(mockUuids); @@ -55,10 +55,10 @@ describe('service', function() { mockNoble.discoverIncludedServices.calledWithExactly(mockPeripheralId, mockUuid, mockUuids).should.equal(true); }); - it('should callback', function() { + it('should callback', function () { var calledback = false; - service.discoverIncludedServices(null, function() { + service.discoverIncludedServices(null, function () { calledback = true; }); service.emit('includedServicesDiscover'); @@ -66,11 +66,11 @@ describe('service', function() { calledback.should.equal(true); }); - it('should callback with data', function() { + it('should callback with data', function () { var mockIncludedServiceUuids = []; var callbackIncludedServiceUuids = null; - service.discoverIncludedServices(null, function(error, includedServiceUuids) { + service.discoverIncludedServices(null, function (error, includedServiceUuids) { callbackIncludedServiceUuids = includedServiceUuids; }); service.emit('includedServicesDiscover', mockIncludedServiceUuids); @@ -79,14 +79,14 @@ describe('service', function() { }); }); - describe('discoverCharacteristics', function() { - it('should delegate to noble', function() { + describe('discoverCharacteristics', function () { + it('should delegate to noble', function () { service.discoverCharacteristics(); mockNoble.discoverCharacteristics.calledWithExactly(mockPeripheralId, mockUuid, undefined).should.equal(true); }); - it('should delegate to noble, with uuids', function() { + it('should delegate to noble, with uuids', function () { var mockUuids = []; service.discoverCharacteristics(mockUuids); @@ -94,10 +94,10 @@ describe('service', function() { mockNoble.discoverCharacteristics.calledWithExactly(mockPeripheralId, mockUuid, mockUuids).should.equal(true); }); - it('should callback', function() { + it('should callback', function () { var calledback = false; - service.discoverCharacteristics(null, function() { + service.discoverCharacteristics(null, function () { calledback = true; }); service.emit('characteristicsDiscover'); @@ -105,11 +105,11 @@ describe('service', function() { calledback.should.equal(true); }); - it('should callback with data', function() { + it('should callback with data', function () { var mockCharacteristics = []; var callbackCharacteristics = null; - service.discoverCharacteristics(null, function(error, mockCharacteristics) { + service.discoverCharacteristics(null, function (error, mockCharacteristics) { callbackCharacteristics = mockCharacteristics; }); service.emit('characteristicsDiscover', mockCharacteristics); diff --git a/with-bindings.js b/with-bindings.js index b2faa42fb..87725cf53 100644 --- a/with-bindings.js +++ b/with-bindings.js @@ -1,5 +1,5 @@ var Noble = require('./lib/noble'); -module.exports = function(bindings) { +module.exports = function (bindings) { return new Noble(bindings); }; diff --git a/ws-slave.js b/ws-slave.js index fb9adaa2e..7c714d194 100644 --- a/ws-slave.js +++ b/ws-slave.js @@ -7,7 +7,6 @@ var serverMode = !process.argv[2]; var port = 0xB1e; var host = process.argv[2]; - var ws; var wss; @@ -17,19 +16,19 @@ if (serverMode) { port: 0xB1e }); - wss.on('connection', function(ws_) { + wss.on('connection', function (ws_) { console.log('ws -> connection'); ws = ws_; ws.on('message', onMessage); - ws.on('close', function() { + ws.on('close', function () { console.log('ws -> close'); noble.stopScanning(); }); - noble.on('stateChange', function(state) { + noble.on('stateChange', function (state) { sendEvent({ type: 'stateChange', state: state @@ -37,27 +36,25 @@ if (serverMode) { }); // Send poweredOn if already in this state. - if (noble.state == "poweredOn") { + if (noble.state == 'poweredOn') { sendEvent({ type: 'stateChange', - state: "poweredOn" + state: 'poweredOn' }); } - - }); } else { ws = new WebSocket('ws://' + host + ':' + port); - ws.on('open', function() { + ws.on('open', function () { console.log('ws -> open'); }); - ws.on('message', function(message) { + ws.on('message', function (message) { onMessage(message); }); - ws.on('close', function() { + ws.on('close', function () { console.log('ws -> close'); noble.stopScanning(); @@ -68,7 +65,7 @@ var peripherals = {}; // TODO: open/close ws on state change -function sendEvent(event) { +function sendEvent (event) { var message = JSON.stringify(event); console.log('ws -> send: ' + message); @@ -80,7 +77,7 @@ function sendEvent(event) { } } -var onMessage = function(message) { +var onMessage = function (message) { console.log('ws -> message: ' + message); var command = JSON.parse(message); @@ -103,7 +100,6 @@ var onMessage = function(message) { var characteristic = null; var descriptor = null; - if (peripheral && serviceUuid) { var services = peripheral.services; @@ -174,17 +170,17 @@ var onMessage = function(message) { } }; -noble.on('discover', function(peripheral) { +noble.on('discover', function (peripheral) { peripherals[peripheral.uuid] = peripheral; - peripheral.on('connect', function() { + peripheral.on('connect', function () { sendEvent({ type: 'connect', peripheralUuid: this.uuid }); }); - peripheral.on('disconnect', function() { + peripheral.on('disconnect', function () { sendEvent({ type: 'disconnect', peripheralUuid: this.uuid @@ -204,7 +200,7 @@ noble.on('discover', function(peripheral) { this.removeAllListeners(); }); - peripheral.on('rssiUpdate', function(rssi) { + peripheral.on('rssiUpdate', function (rssi) { sendEvent({ type: 'rssiUpdate', peripheralUuid: this.uuid, @@ -212,11 +208,11 @@ noble.on('discover', function(peripheral) { }); }); - peripheral.on('servicesDiscover', function(services) { + peripheral.on('servicesDiscover', function (services) { var peripheral = this; var serviceUuids = []; - var includedServicesDiscover = function(includedServiceUuids) { + var includedServicesDiscover = function (includedServiceUuids) { sendEvent({ type: 'includedServicesDiscover', peripheralUuid: peripheral.uuid, @@ -225,11 +221,11 @@ noble.on('discover', function(peripheral) { }); }; - var characteristicsDiscover = function(characteristics) { + var characteristicsDiscover = function (characteristics) { var service = this; var discoveredCharacteristics = []; - var read = function(data, isNotification) { + var read = function (data, isNotification) { var characteristic = this; sendEvent({ @@ -242,7 +238,7 @@ noble.on('discover', function(peripheral) { }); }; - var write = function() { + var write = function () { var characteristic = this; sendEvent({ @@ -253,7 +249,7 @@ noble.on('discover', function(peripheral) { }); }; - var broadcast = function(state) { + var broadcast = function (state) { var characteristic = this; sendEvent({ @@ -265,7 +261,7 @@ noble.on('discover', function(peripheral) { }); }; - var notify = function(state) { + var notify = function (state) { var characteristic = this; sendEvent({ @@ -277,12 +273,12 @@ noble.on('discover', function(peripheral) { }); }; - var descriptorsDiscover = function(descriptors) { + var descriptorsDiscover = function (descriptors) { var characteristic = this; var discoveredDescriptors = []; - var valueRead = function(data) { + var valueRead = function (data) { var descriptor = this; sendEvent({ @@ -295,7 +291,7 @@ noble.on('discover', function(peripheral) { }); }; - var valueWrite = function(data) { + var valueWrite = function (data) { var descriptor = this; sendEvent({ @@ -364,7 +360,7 @@ noble.on('discover', function(peripheral) { }); }); - peripheral.on('handleRead', function(handle, data) { + peripheral.on('handleRead', function (handle, data) { sendEvent({ type: 'handleRead', peripheralUuid: this.uuid, @@ -373,7 +369,7 @@ noble.on('discover', function(peripheral) { }); }); - peripheral.on('handleWrite', function(handle) { + peripheral.on('handleWrite', function (handle) { sendEvent({ type: 'handleWrite', peripheralUuid: this.uuid, @@ -381,7 +377,7 @@ noble.on('discover', function(peripheral) { }); }); - peripheral.on('handleNotify', function(handle, data) { + peripheral.on('handleNotify', function (handle, data) { sendEvent({ type: 'handleNotify', peripheralUuid: this.uuid, From aeca5062f6f76d3f56ae20084a58d3cf6837bbb8 Mon Sep 17 00:00:00 2001 From: Aarni Koskela Date: Sat, 25 Jan 2020 13:59:30 +0200 Subject: [PATCH 056/114] Codemod Buffer constructors --- examples/echo.js | 2 +- examples/pizza/central.js | 6 +++--- lib/distributed/bindings.js | 6 +++--- lib/hci-socket/acl-stream.js | 4 ++-- lib/hci-socket/crypto.js | 2 +- lib/hci-socket/gatt.js | 26 +++++++++++++------------- lib/hci-socket/hci.js | 36 ++++++++++++++++++------------------ lib/hci-socket/signaling.js | 2 +- lib/hci-socket/smp.js | 20 ++++++++++---------- lib/mac/bindings.js | 16 ++++++++-------- lib/websocket/bindings.js | 6 +++--- test/test-characteristic.js | 4 ++-- test/test-descriptor.js | 4 ++-- test/test-peripheral.js | 2 +- 14 files changed, 68 insertions(+), 68 deletions(-) diff --git a/examples/echo.js b/examples/echo.js index 06cc067ed..2d8736b60 100755 --- a/examples/echo.js +++ b/examples/echo.js @@ -67,7 +67,7 @@ function onServicesAndCharacteristicsDiscovered (error, services, characteristic let count = 0; setInterval(() => { count++; - const message = new Buffer('hello, ble ' + count, 'utf-8'); + const message = Buffer.from('hello, ble ' + count, 'utf-8'); console.log("Sending: '" + message + "'"); echoCharacteristic.write(message); }, 2500); diff --git a/examples/pizza/central.js b/examples/pizza/central.js index c2851f369..66fdb3435 100644 --- a/examples/pizza/central.js +++ b/examples/pizza/central.js @@ -93,14 +93,14 @@ function bakePizza () { // // Pick the crust. // - var crust = new Buffer(1); + var crust = Buffer.alloc(1); crust.writeUInt8(pizza.PizzaCrust.THIN, 0); pizzaCrustCharacteristic.write(crust, false, function (err) { if (!err) { // // Pick the toppings. // - var toppings = new Buffer(2); + var toppings = Buffer.alloc(2); toppings.writeUInt16BE( pizza.PizzaToppings.EXTRA_CHEESE | pizza.PizzaToppings.CANADIAN_BACON | @@ -132,7 +132,7 @@ function bakePizza () { // // Bake at 450 degrees! // - var temperature = new Buffer(2); + var temperature = Buffer.alloc(2); temperature.writeUInt16BE(450, 0); pizzaBakeCharacteristic.write(temperature, false, function (err) { if (err) { diff --git a/lib/distributed/bindings.js b/lib/distributed/bindings.js index 53054b3e6..aeb40de84 100644 --- a/lib/distributed/bindings.js +++ b/lib/distributed/bindings.js @@ -63,7 +63,7 @@ NobleBindings.prototype._onMessage = function (ws, event) { var includedServiceUuids = event.includedServiceUuids; var characteristics = event.characteristics; var characteristicUuid = event.characteristicUuid; - var data = event.data ? new Buffer(event.data, 'hex') : null; + var data = event.data ? Buffer.from(event.data, 'hex') : null; var isNotification = event.isNotification; var state = event.state; var descriptors = event.descriptors; @@ -75,8 +75,8 @@ NobleBindings.prototype._onMessage = function (ws, event) { localName: advertisement.localName, txPowerLevel: advertisement.txPowerLevel, serviceUuids: advertisement.serviceUuids, - manufacturerData: (advertisement.manufacturerData ? new Buffer(advertisement.manufacturerData, 'hex') : null), - serviceData: (advertisement.serviceData ? new Buffer(advertisement.serviceData, 'hex') : null) + manufacturerData: (advertisement.manufacturerData ? Buffer.from(advertisement.manufacturerData, 'hex') : null), + serviceData: (advertisement.serviceData ? Buffer.from(advertisement.serviceData, 'hex') : null) }; // TODO: handle duplicate peripheralUuid's diff --git a/lib/hci-socket/acl-stream.js b/lib/hci-socket/acl-stream.js index 852622ef5..42d8b6dd9 100644 --- a/lib/hci-socket/acl-stream.js +++ b/lib/hci-socket/acl-stream.js @@ -41,8 +41,8 @@ AclStream.prototype.pushEncrypt = function (encrypt) { }; AclStream.prototype.onSmpStk = function (stk) { - var random = new Buffer('0000000000000000', 'hex'); - var diversifier = new Buffer('0000', 'hex'); + var random = Buffer.from('0000000000000000', 'hex'); + var diversifier = Buffer.from('0000', 'hex'); this._hci.startLeEncryption(this._handle, random, diversifier, stk); }; diff --git a/lib/hci-socket/crypto.js b/lib/hci-socket/crypto.js index 071f22456..f8e934970 100644 --- a/lib/hci-socket/crypto.js +++ b/lib/hci-socket/crypto.js @@ -15,7 +15,7 @@ function c1 (k, r, pres, preq, iat, ia, rat, ra) { var p2 = Buffer.concat([ ra, ia, - new Buffer('00000000', 'hex') + Buffer.from('00000000', 'hex') ]); var res = xor(r, p1); diff --git a/lib/hci-socket/gatt.js b/lib/hci-socket/gatt.js index e93d7bcf5..baba9ead5 100644 --- a/lib/hci-socket/gatt.js +++ b/lib/hci-socket/gatt.js @@ -176,7 +176,7 @@ Gatt.prototype.writeAtt = function (data) { }; Gatt.prototype.errorResponse = function (opcode, handle, status) { - var buf = new Buffer(5); + var buf = Buffer.alloc(5); buf.writeUInt8(ATT_OP_ERROR, 0); buf.writeUInt8(opcode, 1); @@ -211,7 +211,7 @@ Gatt.prototype._queueCommand = function (buffer, callback, writeCallback) { }; Gatt.prototype.mtuRequest = function (mtu) { - var buf = new Buffer(3); + var buf = Buffer.alloc(3); buf.writeUInt8(ATT_OP_MTU_REQ, 0); buf.writeUInt16LE(mtu, 1); @@ -220,7 +220,7 @@ Gatt.prototype.mtuRequest = function (mtu) { }; Gatt.prototype.readByGroupRequest = function (startHandle, endHandle, groupUuid) { - var buf = new Buffer(7); + var buf = Buffer.alloc(7); buf.writeUInt8(ATT_OP_READ_BY_GROUP_REQ, 0); buf.writeUInt16LE(startHandle, 1); @@ -231,7 +231,7 @@ Gatt.prototype.readByGroupRequest = function (startHandle, endHandle, groupUuid) }; Gatt.prototype.readByTypeRequest = function (startHandle, endHandle, groupUuid) { - var buf = new Buffer(7); + var buf = Buffer.alloc(7); buf.writeUInt8(ATT_OP_READ_BY_TYPE_REQ, 0); buf.writeUInt16LE(startHandle, 1); @@ -242,7 +242,7 @@ Gatt.prototype.readByTypeRequest = function (startHandle, endHandle, groupUuid) }; Gatt.prototype.readRequest = function (handle) { - var buf = new Buffer(3); + var buf = Buffer.alloc(3); buf.writeUInt8(ATT_OP_READ_REQ, 0); buf.writeUInt16LE(handle, 1); @@ -251,7 +251,7 @@ Gatt.prototype.readRequest = function (handle) { }; Gatt.prototype.readBlobRequest = function (handle, offset) { - var buf = new Buffer(5); + var buf = Buffer.alloc(5); buf.writeUInt8(ATT_OP_READ_BLOB_REQ, 0); buf.writeUInt16LE(handle, 1); @@ -261,7 +261,7 @@ Gatt.prototype.readBlobRequest = function (handle, offset) { }; Gatt.prototype.findInfoRequest = function (startHandle, endHandle) { - var buf = new Buffer(5); + var buf = Buffer.alloc(5); buf.writeUInt8(ATT_OP_FIND_INFO_REQ, 0); buf.writeUInt16LE(startHandle, 1); @@ -298,7 +298,7 @@ Gatt.prototype.prepareWriteRequest = function (handle, offset, data) { }; Gatt.prototype.executeWriteRequest = function (handle, cancelPreparedWrites) { - var buf = new Buffer(2); + var buf = Buffer.alloc(2); buf.writeUInt8(ATT_OP_EXECUTE_WRITE_REQ, 0); buf.writeUInt8(cancelPreparedWrites ? 0 : 1, 1); @@ -307,7 +307,7 @@ Gatt.prototype.executeWriteRequest = function (handle, cancelPreparedWrites) { }; Gatt.prototype.handleConfirmation = function () { - var buf = new Buffer(1); + var buf = Buffer.alloc(1); buf.writeUInt8(ATT_OP_HANDLE_CNF, 0); @@ -520,13 +520,13 @@ Gatt.prototype.discoverCharacteristics = function (serviceUuid, characteristicUu Gatt.prototype.read = function (serviceUuid, characteristicUuid) { var characteristic = this._characteristics[serviceUuid][characteristicUuid]; - var readData = new Buffer(0); + var readData = Buffer.alloc(0); var callback = function (data) { var opcode = data[0]; if (opcode === ATT_OP_READ_RESP || opcode === ATT_OP_READ_BLOB_RESP) { - readData = new Buffer(readData.toString('hex') + data.slice(1).toString('hex'), 'hex'); + readData = Buffer.from(readData.toString('hex') + data.slice(1).toString('hex'), 'hex'); if (data.length === this._mtu) { this._queueCommand(this.readBlobRequest(characteristic.valueHandle, readData.length), callback); @@ -618,7 +618,7 @@ Gatt.prototype.broadcast = function (serviceUuid, characteristicUuid, broadcast) value &= 0xfffe; } - var valueBuffer = new Buffer(2); + var valueBuffer = Buffer.alloc(2); valueBuffer.writeUInt16LE(value, 0); this._queueCommand(this.writeRequest(handle, valueBuffer, false), function (data) { @@ -658,7 +658,7 @@ Gatt.prototype.notify = function (serviceUuid, characteristicUuid, notify) { } } - var valueBuffer = new Buffer(2); + var valueBuffer = Buffer.alloc(2); valueBuffer.writeUInt16LE(value, 0); this._queueCommand(this.writeRequest(handle, valueBuffer, false), function (data) { diff --git a/lib/hci-socket/hci.js b/lib/hci-socket/hci.js index e5e062175..e2569146f 100644 --- a/lib/hci-socket/hci.js +++ b/lib/hci-socket/hci.js @@ -133,7 +133,7 @@ Hci.prototype.pollIsDevUp = function () { }; Hci.prototype.setSocketFilter = function () { - var filter = new Buffer(14); + var filter = Buffer.alloc(14); var typeMask = (1 << HCI_COMMAND_PKT) | (1 << HCI_EVENT_PKT) | (1 << HCI_ACLDATA_PKT); var eventMask1 = (1 << EVT_DISCONN_COMPLETE) | (1 << EVT_ENCRYPT_CHANGE) | (1 << EVT_CMD_COMPLETE) | (1 << EVT_CMD_STATUS); var eventMask2 = (1 << (EVT_LE_META_EVENT - 32)); @@ -149,8 +149,8 @@ Hci.prototype.setSocketFilter = function () { }; Hci.prototype.setEventMask = function () { - var cmd = new Buffer(12); - var eventMask = new Buffer('fffffbff07f8bf3d', 'hex'); + var cmd = Buffer.alloc(12); + var eventMask = Buffer.from('fffffbff07f8bf3d', 'hex'); // header cmd.writeUInt8(HCI_COMMAND_PKT, 0); @@ -166,7 +166,7 @@ Hci.prototype.setEventMask = function () { }; Hci.prototype.reset = function () { - var cmd = new Buffer(4); + var cmd = Buffer.alloc(4); // header cmd.writeUInt8(HCI_COMMAND_PKT, 0); @@ -180,7 +180,7 @@ Hci.prototype.reset = function () { }; Hci.prototype.readLocalVersion = function () { - var cmd = new Buffer(4); + var cmd = Buffer.alloc(4); // header cmd.writeUInt8(HCI_COMMAND_PKT, 0); @@ -194,7 +194,7 @@ Hci.prototype.readLocalVersion = function () { }; Hci.prototype.readBdAddr = function () { - var cmd = new Buffer(4); + var cmd = Buffer.alloc(4); // header cmd.writeUInt8(HCI_COMMAND_PKT, 0); @@ -208,8 +208,8 @@ Hci.prototype.readBdAddr = function () { }; Hci.prototype.setLeEventMask = function () { - var cmd = new Buffer(12); - var leEventMask = new Buffer('1f00000000000000', 'hex'); + var cmd = Buffer.alloc(12); + var leEventMask = Buffer.from('1f00000000000000', 'hex'); // header cmd.writeUInt8(HCI_COMMAND_PKT, 0); @@ -225,7 +225,7 @@ Hci.prototype.setLeEventMask = function () { }; Hci.prototype.readLeHostSupported = function () { - var cmd = new Buffer(4); + var cmd = Buffer.alloc(4); // header cmd.writeUInt8(HCI_COMMAND_PKT, 0); @@ -239,7 +239,7 @@ Hci.prototype.readLeHostSupported = function () { }; Hci.prototype.writeLeHostSupported = function () { - var cmd = new Buffer(6); + var cmd = Buffer.alloc(6); // header cmd.writeUInt8(HCI_COMMAND_PKT, 0); @@ -260,7 +260,7 @@ Hci.prototype.setScanParameters = function (interval, window) { interval = interval || 0x0010; window = window || 0x0010; - var cmd = new Buffer(11); + var cmd = Buffer.alloc(11); // header cmd.writeUInt8(HCI_COMMAND_PKT, 0); @@ -281,7 +281,7 @@ Hci.prototype.setScanParameters = function (interval, window) { }; Hci.prototype.setScanEnabled = function (enabled, filterDuplicates) { - var cmd = new Buffer(6); + var cmd = Buffer.alloc(6); // header cmd.writeUInt8(HCI_COMMAND_PKT, 0); @@ -304,7 +304,7 @@ Hci.prototype.createLeConn = function (address, addressType, parameters) { var latency = parameters && parameters.latency || 0x0000; var timeout = parameters && parameters.timeout || 0x00c8; - var cmd = new Buffer(29); + var cmd = Buffer.alloc(29); // header cmd.writeUInt8(HCI_COMMAND_PKT, 0); @@ -319,7 +319,7 @@ Hci.prototype.createLeConn = function (address, addressType, parameters) { cmd.writeUInt8(0x00, 8); // initiator filter cmd.writeUInt8(addressType === 'random' ? 0x01 : 0x00, 9); // peer address type - (new Buffer(address.split(':').reverse().join(''), 'hex')).copy(cmd, 10); // peer address + (Buffer.from(address.split(':').reverse().join(''), 'hex')).copy(cmd, 10); // peer address cmd.writeUInt8(0x00, 16); // own address type @@ -335,7 +335,7 @@ Hci.prototype.createLeConn = function (address, addressType, parameters) { }; Hci.prototype.connUpdateLe = function (handle, minInterval, maxInterval, latency, supervisionTimeout) { - var cmd = new Buffer(18); + var cmd = Buffer.alloc(18); // header cmd.writeUInt8(HCI_COMMAND_PKT, 0); @@ -372,7 +372,7 @@ Hci.prototype.cancelConnect = function () { }; Hci.prototype.startLeEncryption = function (handle, random, diversifier, key) { - var cmd = new Buffer(32); + var cmd = Buffer.alloc(32); // header cmd.writeUInt8(HCI_COMMAND_PKT, 0); @@ -392,7 +392,7 @@ Hci.prototype.startLeEncryption = function (handle, random, diversifier, key) { }; Hci.prototype.disconnect = function (handle, reason) { - var cmd = new Buffer(7); + var cmd = Buffer.alloc(7); reason = reason || HCI_OE_USER_ENDED_CONNECTION; @@ -412,7 +412,7 @@ Hci.prototype.disconnect = function (handle, reason) { }; Hci.prototype.readRssi = function (handle) { - var cmd = new Buffer(6); + var cmd = Buffer.alloc(6); // header cmd.writeUInt8(HCI_COMMAND_PKT, 0); diff --git a/lib/hci-socket/signaling.js b/lib/hci-socket/signaling.js index b884da52e..f44728a4c 100644 --- a/lib/hci-socket/signaling.js +++ b/lib/hci-socket/signaling.js @@ -60,7 +60,7 @@ Signaling.prototype.processConnectionParameterUpdateRequest = function (identifi debug('\t\tsupervision timeout = ', supervisionTimeout); if (os.platform() !== 'linux' || process.env.HCI_CHANNEL_USER) { - var response = new Buffer(6); + var response = Buffer.alloc(6); response.writeUInt8(CONNECTION_PARAMETER_UPDATE_RESPONSE, 0); // code response.writeUInt8(identifier, 1); // identifier diff --git a/lib/hci-socket/smp.js b/lib/hci-socket/smp.js index fa9c4e470..fb5776fb3 100644 --- a/lib/hci-socket/smp.js +++ b/lib/hci-socket/smp.js @@ -16,10 +16,10 @@ var SMP_MASTER_IDENT = 0x07; var Smp = function (aclStream, localAddressType, localAddress, remoteAddressType, remoteAddress) { this._aclStream = aclStream; - this._iat = new Buffer([(localAddressType === 'random') ? 0x01 : 0x00]); - this._ia = new Buffer(localAddress.split(':').reverse().join(''), 'hex'); - this._rat = new Buffer([(remoteAddressType === 'random') ? 0x01 : 0x00]); - this._ra = new Buffer(remoteAddress.split(':').reverse().join(''), 'hex'); + this._iat = Buffer.from([(localAddressType === 'random') ? 0x01 : 0x00]); + this._ia = Buffer.from(localAddress.split(':').reverse().join(''), 'hex'); + this._rat = Buffer.from([(remoteAddressType === 'random') ? 0x01 : 0x00]); + this._ra = Buffer.from(remoteAddress.split(':').reverse().join(''), 'hex'); this.onAclStreamDataBinded = this.onAclStreamData.bind(this); this.onAclStreamEndBinded = this.onAclStreamEnd.bind(this); @@ -31,7 +31,7 @@ var Smp = function (aclStream, localAddressType, localAddress, remoteAddressType util.inherits(Smp, events.EventEmitter); Smp.prototype.sendPairingRequest = function () { - this._preq = new Buffer([ + this._preq = Buffer.from([ SMP_PAIRING_REQUEST, 0x03, // IO capability: NoInputNoOutput 0x00, // OOB data: Authentication data not present @@ -76,11 +76,11 @@ Smp.prototype.onAclStreamEnd = function () { Smp.prototype.handlePairingResponse = function (data) { this._pres = data; - this._tk = new Buffer('00000000000000000000000000000000', 'hex'); + this._tk = Buffer.from('00000000000000000000000000000000', 'hex'); this._r = crypto.r(); this.write(Buffer.concat([ - new Buffer([SMP_PAIRING_CONFIRM]), + Buffer.from([SMP_PAIRING_CONFIRM]), crypto.c1(this._tk, this._r, this._pres, this._preq, this._iat, this._ia, this._rat, this._ra) ])); }; @@ -89,7 +89,7 @@ Smp.prototype.handlePairingConfirm = function (data) { this._pcnf = data; this.write(Buffer.concat([ - new Buffer([SMP_PAIRING_RANDOM]), + Buffer.from([SMP_PAIRING_RANDOM]), this._r ])); }; @@ -98,7 +98,7 @@ Smp.prototype.handlePairingRandom = function (data) { var r = data.slice(1); var pcnf = Buffer.concat([ - new Buffer([SMP_PAIRING_CONFIRM]), + Buffer.from([SMP_PAIRING_CONFIRM]), crypto.c1(this._tk, r, this._pres, this._preq, this._iat, this._ia, this._rat, this._ra) ]); @@ -107,7 +107,7 @@ Smp.prototype.handlePairingRandom = function (data) { this.emit('stk', stk); } else { - this.write(new Buffer([ + this.write(Buffer.from([ SMP_PAIRING_RANDOM, SMP_PAIRING_CONFIRM ])); diff --git a/lib/mac/bindings.js b/lib/mac/bindings.js index 5064f630f..417e1f8cc 100644 --- a/lib/mac/bindings.js +++ b/lib/mac/bindings.js @@ -1,8 +1,8 @@ -var events = require('events'); -var util = require('util'); - -var NobleMac = require('./native/binding').NobleMac; - -util.inherits(NobleMac, events.EventEmitter); - -module.exports = new NobleMac(); +var events = require('events'); +var util = require('util'); + +var NobleMac = require('./native/binding').NobleMac; + +util.inherits(NobleMac, events.EventEmitter); + +module.exports = new NobleMac(); diff --git a/lib/websocket/bindings.js b/lib/websocket/bindings.js index 9d9e67271..2bef8c30a 100644 --- a/lib/websocket/bindings.js +++ b/lib/websocket/bindings.js @@ -56,7 +56,7 @@ NobleBindings.prototype._onMessage = function (event) { var includedServiceUuids = event.includedServiceUuids; var characteristics = event.characteristics; var characteristicUuid = event.characteristicUuid; - var data = event.data ? new Buffer(event.data, 'hex') : null; + var data = event.data ? Buffer.from(event.data, 'hex') : null; var isNotification = event.isNotification; var state = event.state; var descriptors = event.descriptors; @@ -71,8 +71,8 @@ NobleBindings.prototype._onMessage = function (event) { localName: advertisement.localName, txPowerLevel: advertisement.txPowerLevel, serviceUuids: advertisement.serviceUuids, - manufacturerData: (advertisement.manufacturerData ? new Buffer(advertisement.manufacturerData, 'hex') : null), - serviceData: (advertisement.serviceData ? new Buffer(advertisement.serviceData, 'hex') : null) + manufacturerData: (advertisement.manufacturerData ? Buffer.from(advertisement.manufacturerData, 'hex') : null), + serviceData: (advertisement.serviceData ? Buffer.from(advertisement.serviceData, 'hex') : null) }; this._peripherals[peripheralUuid] = { diff --git a/test/test-characteristic.js b/test/test-characteristic.js index ab18cddfb..e883689f8 100644 --- a/test/test-characteristic.js +++ b/test/test-characteristic.js @@ -68,7 +68,7 @@ describe('Characteristic', function () { }); it('should callback with data', function () { - var mockData = new Buffer(0); + var mockData = Buffer.alloc(0); var callbackData = null; characteristic.read(function (error, data) { @@ -84,7 +84,7 @@ describe('Characteristic', function () { var mockData = null; beforeEach(function () { - mockData = new Buffer(0); + mockData = Buffer.alloc(0); }); it('should only accept data as a buffer', function () { diff --git a/test/test-descriptor.js b/test/test-descriptor.js index cdd2e852f..ee9106910 100644 --- a/test/test-descriptor.js +++ b/test/test-descriptor.js @@ -73,7 +73,7 @@ describe('Descriptor', function () { }); it('should callback with error, data', function () { - var mockData = new Buffer(0); + var mockData = Buffer.alloc(0); var callbackData = null; descriptor.readValue(function (error, data) { @@ -89,7 +89,7 @@ describe('Descriptor', function () { var mockData = null; beforeEach(function () { - mockData = new Buffer(0); + mockData = Buffer.alloc(0); }); it('should only accept data as a buffer', function () { diff --git a/test/test-peripheral.js b/test/test-peripheral.js index 6a7e4c9a5..30991be84 100644 --- a/test/test-peripheral.js +++ b/test/test-peripheral.js @@ -293,7 +293,7 @@ describe('Peripheral', function () { describe('writeHandle', function () { beforeEach(function () { - mockData = new Buffer(0); + mockData = Buffer.alloc(0); }); it('should only accept data as a buffer', function () { From 17ceaf6fd913f246745a665635ead17fbb546978 Mon Sep 17 00:00:00 2001 From: Aarni Koskela Date: Sat, 25 Jan 2020 14:18:23 +0200 Subject: [PATCH 057/114] Manually fix the rest of the Buffer allocations --- lib/hci-socket/crypto.js | 4 ++-- lib/hci-socket/gatt.js | 4 ++-- lib/hci-socket/hci.js | 2 +- lib/webbluetooth/bindings.js | 6 +++--- ws-slave.js | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/hci-socket/crypto.js b/lib/hci-socket/crypto.js index f8e934970..3f99d2aed 100644 --- a/lib/hci-socket/crypto.js +++ b/lib/hci-socket/crypto.js @@ -47,7 +47,7 @@ function e (key, data) { } function xor (b1, b2) { - var result = new Buffer(b1.length); + var result = Buffer.alloc(b1.length); for (var i = 0; i < b1.length; i++) { result[i] = b1[i] ^ b2[i]; @@ -57,7 +57,7 @@ function xor (b1, b2) { } function swap (input) { - var output = new Buffer(input.length); + var output = Buffer.alloc(input.length); for (var i = 0; i < output.length; i++) { output[i] = input[input.length - i - 1]; diff --git a/lib/hci-socket/gatt.js b/lib/hci-socket/gatt.js index baba9ead5..664e97924 100644 --- a/lib/hci-socket/gatt.js +++ b/lib/hci-socket/gatt.js @@ -271,7 +271,7 @@ Gatt.prototype.findInfoRequest = function (startHandle, endHandle) { }; Gatt.prototype.writeRequest = function (handle, data, withoutResponse) { - var buf = new Buffer(3 + data.length); + var buf = Buffer.alloc(3 + data.length); buf.writeUInt8(withoutResponse ? ATT_OP_WRITE_CMD : ATT_OP_WRITE_REQ, 0); buf.writeUInt16LE(handle, 1); @@ -284,7 +284,7 @@ Gatt.prototype.writeRequest = function (handle, data, withoutResponse) { }; Gatt.prototype.prepareWriteRequest = function (handle, offset, data) { - var buf = new Buffer(5 + data.length); + var buf = Buffer.alloc(5 + data.length); buf.writeUInt8(ATT_OP_PREPARE_WRITE_REQ, 0); buf.writeUInt16LE(handle, 1); diff --git a/lib/hci-socket/hci.js b/lib/hci-socket/hci.js index e2569146f..3dcdc1912 100644 --- a/lib/hci-socket/hci.js +++ b/lib/hci-socket/hci.js @@ -429,7 +429,7 @@ Hci.prototype.readRssi = function (handle) { }; Hci.prototype.writeAclDataPkt = function (handle, cid, data) { - var pkt = new Buffer(9 + data.length); + var pkt = Buffer.alloc(9 + data.length); // header pkt.writeUInt8(HCI_ACLDATA_PKT, 0); diff --git a/lib/webbluetooth/bindings.js b/lib/webbluetooth/bindings.js index 3ade3e473..05395b574 100644 --- a/lib/webbluetooth/bindings.js +++ b/lib/webbluetooth/bindings.js @@ -260,7 +260,7 @@ NobleBindings.prototype.read = function (deviceUuid, serviceUuid, characteristic return characteristic.readValue(); }) .then(function (data) { - self.emit('read', peripheral.uuid, serviceUuid, characteristicUuid, new Buffer(data.buffer), false); + self.emit('read', peripheral.uuid, serviceUuid, characteristicUuid, Buffer.from(data.buffer), false); }) .catch(function (err) { debug('error reading characteristic', err); @@ -313,8 +313,8 @@ NobleBindings.prototype.notify = function (deviceUuid, serviceUuid, characterist .then(function (characteristic) { debug('notifications started', characteristicUuid); peripheral.notifcationListeners[serviceUuid + '__' + characteristicUuid] = function (evt) { - debug('oncharacteristicvaluechanged', evt, new Buffer(evt.target.value.buffer)); - self.emit('read', deviceUuid, serviceUuid, characteristicUuid, new Buffer(evt.target.value.buffer), true); + debug('oncharacteristicvaluechanged', evt, Buffer.from(evt.target.value.buffer)); + self.emit('read', deviceUuid, serviceUuid, characteristicUuid, Buffer.from(evt.target.value.buffer), true); }; characteristic.addEventListener('characteristicvaluechanged', peripheral.notifcationListeners[serviceUuid + '__' + characteristicUuid]); diff --git a/ws-slave.js b/ws-slave.js index 7c714d194..9f972506d 100644 --- a/ws-slave.js +++ b/ws-slave.js @@ -88,7 +88,7 @@ var onMessage = function (message) { var serviceUuid = command.serviceUuid; var characteristicUuids = command.characteristicUuids; var characteristicUuid = command.characteristicUuid; - var data = command.data ? new Buffer(command.data, 'hex') : null; + var data = command.data ? Buffer.from(command.data, 'hex') : null; var withoutResponse = command.withoutResponse; var broadcast = command.broadcast; var notify = command.notify; From af78fe85f312e5381fd31dcca9e772ca5e052de8 Mon Sep 17 00:00:00 2001 From: Aarni Koskela Date: Sat, 25 Jan 2020 14:22:10 +0200 Subject: [PATCH 058/114] DRY out _onMessage a bit --- lib/distributed/bindings.js | 36 +++++++++++++++++++----------------- lib/websocket/bindings.js | 36 +++++++++++++++++++----------------- 2 files changed, 38 insertions(+), 34 deletions(-) diff --git a/lib/distributed/bindings.js b/lib/distributed/bindings.js index aeb40de84..ceb3fc3ed 100644 --- a/lib/distributed/bindings.js +++ b/lib/distributed/bindings.js @@ -51,24 +51,26 @@ NobleBindings.prototype._onClose = function (ws) { }; NobleBindings.prototype._onMessage = function (ws, event) { - var type = event.type; - var peripheralUuid = event.peripheralUuid; - var address = event.address; - var addressType = event.addressType; - var connectable = event.connectable; - var advertisement = event.advertisement; - var rssi = event.rssi; - var serviceUuids = event.serviceUuids; - var serviceUuid = event.serviceUuid; - var includedServiceUuids = event.includedServiceUuids; - var characteristics = event.characteristics; - var characteristicUuid = event.characteristicUuid; + var { + type, + peripheralUuid, + address, + addressType, + connectable, + advertisement, + rssi, + serviceUuids, + serviceUuid, + includedServiceUuids, + characteristics, + characteristicUuid, + isNotification, + state, + descriptors, + descriptorUuid, + handle + } = event; var data = event.data ? Buffer.from(event.data, 'hex') : null; - var isNotification = event.isNotification; - var state = event.state; - var descriptors = event.descriptors; - var descriptorUuid = event.descriptorUuid; - var handle = event.handle; if (type === 'discover') { advertisement = { diff --git a/lib/websocket/bindings.js b/lib/websocket/bindings.js index 2bef8c30a..5b2469b9e 100644 --- a/lib/websocket/bindings.js +++ b/lib/websocket/bindings.js @@ -44,24 +44,26 @@ NobleBindings.prototype._onClose = function () { }; NobleBindings.prototype._onMessage = function (event) { - var type = event.type; - var peripheralUuid = event.peripheralUuid; - var address = event.address; - var addressType = event.addressType; - var connectable = event.connectable; - var advertisement = event.advertisement; - var rssi = event.rssi; - var serviceUuids = event.serviceUuids; - var serviceUuid = event.serviceUuid; - var includedServiceUuids = event.includedServiceUuids; - var characteristics = event.characteristics; - var characteristicUuid = event.characteristicUuid; + var { + type, + peripheralUuid, + address, + addressType, + connectable, + advertisement, + rssi, + serviceUuids, + serviceUuid, + includedServiceUuids, + characteristics, + characteristicUuid, + isNotification, + state, + descriptors, + descriptorUuid, + handle + } = event; var data = event.data ? Buffer.from(event.data, 'hex') : null; - var isNotification = event.isNotification; - var state = event.state; - var descriptors = event.descriptors; - var descriptorUuid = event.descriptorUuid; - var handle = event.handle; if (type === 'stateChange') { console.log(state); From a0b30451301efdfe920a1647e0cd865696ad37d0 Mon Sep 17 00:00:00 2001 From: Aarni Koskela Date: Sat, 25 Jan 2020 14:26:41 +0200 Subject: [PATCH 059/114] Ignore missing error handling in examples --- examples/cache-gatt-discovery.js | 1 + examples/cache-gatt-reconnect.js | 1 + examples/echo.js | 1 + examples/enter-exit.js | 1 + examples/peripheral-explorer.js | 1 + examples/pizza/central.js | 2 +- 6 files changed, 6 insertions(+), 1 deletion(-) diff --git a/examples/cache-gatt-discovery.js b/examples/cache-gatt-discovery.js index 4d1d6b558..98a3f9a4e 100644 --- a/examples/cache-gatt-discovery.js +++ b/examples/cache-gatt-discovery.js @@ -1,3 +1,4 @@ +/* eslint-disable handle-callback-err */ /** discover a device (here, the first one where the name was resolved), * for the first device discover all services and characteristics, * store the collected GATT information into a meta-data object and write to disk. diff --git a/examples/cache-gatt-reconnect.js b/examples/cache-gatt-reconnect.js index 68c81eadc..a58b614cf 100644 --- a/examples/cache-gatt-reconnect.js +++ b/examples/cache-gatt-reconnect.js @@ -1,3 +1,4 @@ +/* eslint-disable handle-callback-err */ /** reconnect to a device that has been discovered earlier on using cache-gatt-discovery: * If a device is discovered and a dump file exists, load it and connect to it, re-initializing service * and characteristic objects in the noble stack. diff --git a/examples/echo.js b/examples/echo.js index 2d8736b60..09548e3fa 100755 --- a/examples/echo.js +++ b/examples/echo.js @@ -1,3 +1,4 @@ +/* eslint-disable handle-callback-err */ // Connect to a peripheral running the echo service // https://github.com/noble/bleno/blob/master/examples/echo diff --git a/examples/enter-exit.js b/examples/enter-exit.js index b64051821..7e874547a 100644 --- a/examples/enter-exit.js +++ b/examples/enter-exit.js @@ -1,3 +1,4 @@ +/* eslint-disable handle-callback-err */ /* Continuously scans for peripherals and prints out message when they enter/exit diff --git a/examples/peripheral-explorer.js b/examples/peripheral-explorer.js index 20fb9956f..5f87037f4 100644 --- a/examples/peripheral-explorer.js +++ b/examples/peripheral-explorer.js @@ -1,3 +1,4 @@ +/* eslint-disable handle-callback-err */ var async = require('async'); var noble = require('../index'); diff --git a/examples/pizza/central.js b/examples/pizza/central.js index 66fdb3435..94721b994 100644 --- a/examples/pizza/central.js +++ b/examples/pizza/central.js @@ -1,4 +1,4 @@ - +/* eslint-disable handle-callback-err */ var noble = require('../..'); var pizza = require('./pizza'); From 4e6d64f4e386e1f88441185b16c33b7dd8c0cdcf Mon Sep 17 00:00:00 2001 From: Aarni Koskela Date: Sat, 25 Jan 2020 14:30:12 +0200 Subject: [PATCH 060/114] Fix eqeqeq --- examples/pizza/central.js | 16 ++++++++-------- lib/hci-socket/gap.js | 4 ++-- lib/hci-socket/gatt.js | 8 ++++---- ws-slave.js | 2 +- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/examples/pizza/central.js b/examples/pizza/central.js index 94721b994..290f2bdbc 100644 --- a/examples/pizza/central.js +++ b/examples/pizza/central.js @@ -61,11 +61,11 @@ noble.on('discover', function (peripheral) { // console.log('found characteristic:', characteristic.uuid); - if (pizzaCrustCharacteristicUuid == characteristic.uuid) { + if (pizzaCrustCharacteristicUuid === characteristic.uuid) { pizzaCrustCharacteristic = characteristic; - } else if (pizzaToppingsCharacteristicUuid == characteristic.uuid) { + } else if (pizzaToppingsCharacteristicUuid === characteristic.uuid) { pizzaToppingsCharacteristic = characteristic; - } else if (pizzaBakeCharacteristicUuid == characteristic.uuid) { + } else if (pizzaBakeCharacteristicUuid === characteristic.uuid) { pizzaBakeCharacteristic = characteristic; } }); @@ -118,11 +118,11 @@ function bakePizza () { if (data.length === 1) { var result = data.readUInt8(0); console.log('The result is', - result == pizza.PizzaBakeResult.HALF_BAKED ? 'half baked.' - : result == pizza.PizzaBakeResult.BAKED ? 'baked.' - : result == pizza.PizzaBakeResult.CRISPY ? 'crispy.' - : result == pizza.PizzaBakeResult.BURNT ? 'burnt.' - : result == pizza.PizzaBakeResult.ON_FIRE ? 'on fire!' + result === pizza.PizzaBakeResult.HALF_BAKED ? 'half baked.' + : result === pizza.PizzaBakeResult.BAKED ? 'baked.' + : result === pizza.PizzaBakeResult.CRISPY ? 'crispy.' + : result === pizza.PizzaBakeResult.BURNT ? 'burnt.' + : result === pizza.PizzaBakeResult.ON_FIRE ? 'on fire!' : 'unknown?'); } else { console.log('result length incorrect'); diff --git a/lib/hci-socket/gap.js b/lib/hci-socket/gap.js index b4626b90b..d62396e17 100644 --- a/lib/hci-socket/gap.js +++ b/lib/hci-socket/gap.js @@ -85,7 +85,7 @@ Gap.prototype.onLeScanEnableSetCmd = function (enable, filterDuplicates) { // If we are scanning, then a change happens if the new command stops // scanning or if duplicate filtering changes. // If we are not scanning, then a change happens if scanning was enabled. - if ((this._scanState == 'starting' || this._scanState == 'started')) { + if ((this._scanState === 'starting' || this._scanState === 'started')) { if (!enable) { this.emit('scanStop'); } else if (this._scanFilterDuplicates !== filterDuplicates) { @@ -93,7 +93,7 @@ Gap.prototype.onLeScanEnableSetCmd = function (enable, filterDuplicates) { this.emit('scanStart', this._scanFilterDuplicates); } - } else if ((this._scanState == 'stopping' || this._scanState == 'stopped') && enable) { + } else if ((this._scanState === 'stopping' || this._scanState === 'stopped') && enable) { // Someone started scanning on us. this.emit('scanStart', this._scanFilterDuplicates); } diff --git a/lib/hci-socket/gatt.js b/lib/hci-socket/gatt.js index 664e97924..985bb67b0 100644 --- a/lib/hci-socket/gatt.js +++ b/lib/hci-socket/gatt.js @@ -349,7 +349,7 @@ Gatt.prototype.discoverServices = function (uuids) { services.push({ startHandle: data.readUInt16LE(2 + i * type + 0), endHandle: data.readUInt16LE(2 + i * type + 2), - uuid: (type == 6) ? data.readUInt16LE(2 + i * type + 4).toString(16) : data.slice(2 + i * type + 4).slice(0, 16).toString('hex').match(/.{1,2}/g).reverse().join('') + uuid: (type === 6) ? data.readUInt16LE(2 + i * type + 4).toString(16) : data.slice(2 + i * type + 4).slice(0, 16).toString('hex').match(/.{1,2}/g).reverse().join('') }); } } @@ -389,7 +389,7 @@ Gatt.prototype.discoverIncludedServices = function (serviceUuid, uuids) { includedServices.push({ endHandle: data.readUInt16LE(2 + i * type + 0), startHandle: data.readUInt16LE(2 + i * type + 2), - uuid: (type == 8) ? data.readUInt16LE(2 + i * type + 6).toString(16) : data.slice(2 + i * type + 6).slice(0, 16).toString('hex').match(/.{1,2}/g).reverse().join('') + uuid: (type === 8) ? data.readUInt16LE(2 + i * type + 6).toString(16) : data.slice(2 + i * type + 6).slice(0, 16).toString('hex').match(/.{1,2}/g).reverse().join('') }); } } @@ -441,7 +441,7 @@ Gatt.prototype.discoverCharacteristics = function (serviceUuid, characteristicUu startHandle: data.readUInt16LE(2 + i * type + 0), properties: data.readUInt8(2 + i * type + 2), valueHandle: data.readUInt16LE(2 + i * type + 3), - uuid: (type == 7) ? data.readUInt16LE(2 + i * type + 5).toString(16) : data.slice(2 + i * type + 5).slice(0, 16).toString('hex').match(/.{1,2}/g).reverse().join('') + uuid: (type === 7) ? data.readUInt16LE(2 + i * type + 5).toString(16) : data.slice(2 + i * type + 5).slice(0, 16).toString('hex').match(/.{1,2}/g).reverse().join('') }); } } @@ -570,7 +570,7 @@ Gatt.prototype.longWrite = function (serviceUuid, characteristicUuid, data, with return function (resp) { var opcode = resp[0]; - if (opcode != ATT_OP_PREPARE_WRITE_RESP) { + if (opcode !== ATT_OP_PREPARE_WRITE_RESP) { debug(this._address + ': unexpected reply opcode %d (expecting ATT_OP_PREPARE_WRITE_RESP)', opcode); } else { var expected_length = data_chunk.length + 5; diff --git a/ws-slave.js b/ws-slave.js index 9f972506d..250a50c38 100644 --- a/ws-slave.js +++ b/ws-slave.js @@ -36,7 +36,7 @@ if (serverMode) { }); // Send poweredOn if already in this state. - if (noble.state == 'poweredOn') { + if (noble.state === 'poweredOn') { sendEvent({ type: 'stateChange', state: 'poweredOn' From 1378bac7f364ea7918a4288ec7d4f170c1a33694 Mon Sep 17 00:00:00 2001 From: Aarni Koskela Date: Sat, 25 Jan 2020 14:36:26 +0200 Subject: [PATCH 061/114] Handle errors where suitable --- lib/hci-socket/gap.js | 2 +- lib/peripheral.js | 5 +++++ test/test-characteristic.js | 6 ++++++ test/test-descriptor.js | 3 +++ test/test-peripheral.js | 12 ++++++++++++ test/test-service.js | 6 ++++++ 6 files changed, 33 insertions(+), 1 deletion(-) diff --git a/lib/hci-socket/gap.js b/lib/hci-socket/gap.js index d62396e17..0e1dc2c76 100644 --- a/lib/hci-socket/gap.js +++ b/lib/hci-socket/gap.js @@ -52,7 +52,7 @@ Gap.prototype.stopScanning = function () { }; Gap.prototype.onHciError = function (error) { - + console.warn(error); // TODO: Better error handling }; Gap.prototype.onHciLeScanParametersSet = function () { diff --git a/lib/peripheral.js b/lib/peripheral.js index 7db3727a2..5c98f7792 100644 --- a/lib/peripheral.js +++ b/lib/peripheral.js @@ -102,6 +102,10 @@ Peripheral.prototype.discoverServices = function (uuids, callback) { Peripheral.prototype.discoverSomeServicesAndCharacteristics = function (serviceUuids, characteristicsUuids, callback) { this.discoverServices(serviceUuids, function (err, services) { + if (err) { + callback(err, null, null); + return; + } var numDiscovered = 0; var allCharacteristics = []; @@ -111,6 +115,7 @@ Peripheral.prototype.discoverSomeServicesAndCharacteristics = function (serviceU service.discoverCharacteristics(characteristicsUuids, function (error, characteristics) { numDiscovered++; + // TODO: handle `error`? if (error === null) { for (var j in characteristics) { var characteristic = characteristics[j]; diff --git a/test/test-characteristic.js b/test/test-characteristic.js index e883689f8..18ed94838 100644 --- a/test/test-characteristic.js +++ b/test/test-characteristic.js @@ -72,6 +72,9 @@ describe('Characteristic', function () { var callbackData = null; characteristic.read(function (error, data) { + if (error) { + throw new Error(error); + } callbackData = data; }); characteristic.emit('read', mockData); @@ -230,6 +233,9 @@ describe('Characteristic', function () { var callbackDescriptors = null; characteristic.discoverDescriptors(function (error, descriptors) { + if (error) { + throw new Error(error); + } callbackDescriptors = descriptors; }); characteristic.emit('descriptorsDiscover', mockDescriptors); diff --git a/test/test-descriptor.js b/test/test-descriptor.js index ee9106910..8585d96b5 100644 --- a/test/test-descriptor.js +++ b/test/test-descriptor.js @@ -77,6 +77,9 @@ describe('Descriptor', function () { var callbackData = null; descriptor.readValue(function (error, data) { + if (error) { + throw new Error(error); + } callbackData = data; }); descriptor.emit('valueRead', mockData); diff --git a/test/test-peripheral.js b/test/test-peripheral.js index 30991be84..a2e21b876 100644 --- a/test/test-peripheral.js +++ b/test/test-peripheral.js @@ -123,6 +123,9 @@ describe('Peripheral', function () { var calledbackRssi = null; peripheral.updateRssi(function (error, rssi) { + if (error) { + throw new Error(error); + } calledbackRssi = rssi; }); peripheral.emit('rssiUpdate', mockRssi); @@ -162,6 +165,9 @@ describe('Peripheral', function () { var calledbackServices = null; peripheral.discoverServices(null, function (error, services) { + if (error) { + throw new Error(error); + } calledbackServices = services; }); peripheral.emit('servicesDiscover', mockServices); @@ -229,6 +235,9 @@ describe('Peripheral', function () { var calledbackCharacteristics = null; peripheral.discoverSomeServicesAndCharacteristics(mockServiceUuids, mockCharacteristicUuids, function (err, services, characteristics) { + if (err) { + throw new Error(err); + } calledbackServices = services; calledbackCharacteristics = characteristics; }); @@ -283,6 +292,9 @@ describe('Peripheral', function () { var calledbackData = null; peripheral.readHandle(mockHandle, function (error, data) { + if (error) { + throw new Error(error); + } calledbackData = data; }); peripheral.emit('handleRead' + mockHandle, mockData); diff --git a/test/test-service.js b/test/test-service.js index 89287abaa..8a8755111 100644 --- a/test/test-service.js +++ b/test/test-service.js @@ -71,6 +71,9 @@ describe('service', function () { var callbackIncludedServiceUuids = null; service.discoverIncludedServices(null, function (error, includedServiceUuids) { + if (error) { + throw new Error(error); + } callbackIncludedServiceUuids = includedServiceUuids; }); service.emit('includedServicesDiscover', mockIncludedServiceUuids); @@ -110,6 +113,9 @@ describe('service', function () { var callbackCharacteristics = null; service.discoverCharacteristics(null, function (error, mockCharacteristics) { + if (error) { + throw new Error(error); + } callbackCharacteristics = mockCharacteristics; }); service.emit('characteristicsDiscover', mockCharacteristics); From b53f122f9cb71bfe1e9c6ef9f0691722a34ef87e Mon Sep 17 00:00:00 2001 From: Aarni Koskela Date: Sat, 25 Jan 2020 14:37:17 +0200 Subject: [PATCH 062/114] Fix camelcase --- lib/hci-socket/gatt.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/hci-socket/gatt.js b/lib/hci-socket/gatt.js index 985bb67b0..45143a472 100644 --- a/lib/hci-socket/gatt.js +++ b/lib/hci-socket/gatt.js @@ -566,18 +566,18 @@ Gatt.prototype.longWrite = function (serviceUuid, characteristicUuid, data, with var characteristic = this._characteristics[serviceUuid][characteristicUuid]; var limit = this._mtu - 5; - var prepareWriteCallback = function (data_chunk) { + var prepareWriteCallback = function (dataChunk) { return function (resp) { var opcode = resp[0]; if (opcode !== ATT_OP_PREPARE_WRITE_RESP) { debug(this._address + ': unexpected reply opcode %d (expecting ATT_OP_PREPARE_WRITE_RESP)', opcode); } else { - var expected_length = data_chunk.length + 5; + var expectedLength = dataChunk.length + 5; - if (resp.length !== expected_length) { + if (resp.length !== expectedLength) { /* the response should contain the data packet echoed back to the caller */ - debug(this._address + ': unexpected prepareWriteResponse length %d (expecting %d)', resp.length, expected_length); + debug(this._address + ': unexpected prepareWriteResponse length %d (expecting %d)', resp.length, expectedLength); } } }.bind(this); From ee8752c5ecc41d73aa80c5b75cba67ae2e7de66f Mon Sep 17 00:00:00 2001 From: Aarni Koskela Date: Sat, 25 Jan 2020 14:38:32 +0200 Subject: [PATCH 063/114] Fix use-before-assign --- ws-slave.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ws-slave.js b/ws-slave.js index 250a50c38..14fb568b4 100644 --- a/ws-slave.js +++ b/ws-slave.js @@ -93,7 +93,7 @@ var onMessage = function (message) { var broadcast = command.broadcast; var notify = command.notify; var descriptorUuid = command.descriptorUuid; - var handle = handle; + var handle; var peripheral = peripherals[peripheralUuid]; var service = null; From 0a021a7a2e572b7cb8a21cd93a8b50d6530d9706 Mon Sep 17 00:00:00 2001 From: Aarni Koskela Date: Sat, 25 Jan 2020 14:49:14 +0200 Subject: [PATCH 064/114] Lessen buffer offset calculations --- lib/characteristic.js | 6 +++--- lib/hci-socket/gatt.js | 23 +++++++++++++---------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/lib/characteristic.js b/lib/characteristic.js index c0b19bc46..49badc544 100644 --- a/lib/characteristic.js +++ b/lib/characteristic.js @@ -34,17 +34,17 @@ Characteristic.prototype.toString = function () { Characteristic.prototype.read = function (callback) { if (callback) { - var onRead = function (data, isNotificaton) { + var onRead = (data, isNotification) => { // only call the callback if 'read' event and non-notification // 'read' for non-notifications is only present for backwards compatbility - if (!isNotificaton) { + if (!isNotification) { // remove the listener this.removeListener('read', onRead); // call the callback callback(null, data); } - }.bind(this); + }; this.on('read', onRead); } diff --git a/lib/hci-socket/gatt.js b/lib/hci-socket/gatt.js index 45143a472..9f056f31a 100644 --- a/lib/hci-socket/gatt.js +++ b/lib/hci-socket/gatt.js @@ -346,10 +346,11 @@ Gatt.prototype.discoverServices = function (uuids) { var num = (data.length - 2) / type; for (i = 0; i < num; i++) { + const offset = 2 + i * type; services.push({ - startHandle: data.readUInt16LE(2 + i * type + 0), - endHandle: data.readUInt16LE(2 + i * type + 2), - uuid: (type === 6) ? data.readUInt16LE(2 + i * type + 4).toString(16) : data.slice(2 + i * type + 4).slice(0, 16).toString('hex').match(/.{1,2}/g).reverse().join('') + startHandle: data.readUInt16LE(offset), + endHandle: data.readUInt16LE(offset + 2), + uuid: (type === 6) ? data.readUInt16LE(offset + 4).toString(16) : data.slice(offset + 4).slice(0, 16).toString('hex').match(/.{1,2}/g).reverse().join('') }); } } @@ -386,10 +387,11 @@ Gatt.prototype.discoverIncludedServices = function (serviceUuid, uuids) { var num = (data.length - 2) / type; for (i = 0; i < num; i++) { + const offset = 2 + i * type; includedServices.push({ - endHandle: data.readUInt16LE(2 + i * type + 0), - startHandle: data.readUInt16LE(2 + i * type + 2), - uuid: (type === 8) ? data.readUInt16LE(2 + i * type + 6).toString(16) : data.slice(2 + i * type + 6).slice(0, 16).toString('hex').match(/.{1,2}/g).reverse().join('') + endHandle: data.readUInt16LE(offset), + startHandle: data.readUInt16LE(offset + 2), + uuid: (type === 8) ? data.readUInt16LE(offset + 6).toString(16) : data.slice(offset + 6).slice(0, 16).toString('hex').match(/.{1,2}/g).reverse().join('') }); } } @@ -437,11 +439,12 @@ Gatt.prototype.discoverCharacteristics = function (serviceUuid, characteristicUu var num = (data.length - 2) / type; for (i = 0; i < num; i++) { + const offset = 2 + i * type; characteristics.push({ - startHandle: data.readUInt16LE(2 + i * type + 0), - properties: data.readUInt8(2 + i * type + 2), - valueHandle: data.readUInt16LE(2 + i * type + 3), - uuid: (type === 7) ? data.readUInt16LE(2 + i * type + 5).toString(16) : data.slice(2 + i * type + 5).slice(0, 16).toString('hex').match(/.{1,2}/g).reverse().join('') + startHandle: data.readUInt16LE(offset), + properties: data.readUInt8(offset + 2), + valueHandle: data.readUInt16LE(offset + 3), + uuid: (type === 7) ? data.readUInt16LE(offset + 5).toString(16) : data.slice(offset + 5).slice(0, 16).toString('hex').match(/.{1,2}/g).reverse().join('') }); } } From 5abf2727ab80ebdc904a6d2c32565a64f7658f97 Mon Sep 17 00:00:00 2001 From: Aarni Koskela Date: Sat, 25 Jan 2020 15:06:17 +0200 Subject: [PATCH 065/114] Codemod self-binding functions to arrow functions --- lib/characteristic.js | 8 ++-- lib/descriptor.js | 4 +- lib/distributed/bindings.js | 8 ++-- lib/hci-socket/gatt.js | 84 ++++++++++++++++++------------------ lib/noble.js | 14 +++--- lib/peripheral.js | 16 +++---- lib/service.js | 4 +- lib/webbluetooth/bindings.js | 68 +++++++++++------------------ lib/websocket/bindings.js | 4 +- 9 files changed, 97 insertions(+), 113 deletions(-) diff --git a/lib/characteristic.js b/lib/characteristic.js index 49badc544..d18f17a85 100644 --- a/lib/characteristic.js +++ b/lib/characteristic.js @@ -64,7 +64,7 @@ Characteristic.prototype.write = function (data, withoutResponse, callback) { } if (callback) { - this.once('write', function () { + this.once('write', () => { callback(null); }); } @@ -80,7 +80,7 @@ Characteristic.prototype.write = function (data, withoutResponse, callback) { Characteristic.prototype.broadcast = function (broadcast, callback) { if (callback) { - this.once('broadcast', function () { + this.once('broadcast', () => { callback(null); }); } @@ -96,7 +96,7 @@ Characteristic.prototype.broadcast = function (broadcast, callback) { // deprecated in favour of subscribe/unsubscribe Characteristic.prototype.notify = function (notify, callback) { if (callback) { - this.once('notify', function () { + this.once('notify', () => { callback(null); }); } @@ -119,7 +119,7 @@ Characteristic.prototype.unsubscribe = function (callback) { Characteristic.prototype.discoverDescriptors = function (callback) { if (callback) { - this.once('descriptorsDiscover', function (descriptors) { + this.once('descriptorsDiscover', descriptors => { callback(null, descriptors); }); } diff --git a/lib/descriptor.js b/lib/descriptor.js index 3778e18d4..35521c811 100644 --- a/lib/descriptor.js +++ b/lib/descriptor.js @@ -32,7 +32,7 @@ Descriptor.prototype.toString = function () { Descriptor.prototype.readValue = function (callback) { if (callback) { - this.once('valueRead', function (data) { + this.once('valueRead', data => { callback(null, data); }); } @@ -50,7 +50,7 @@ Descriptor.prototype.writeValue = function (data, callback) { } if (callback) { - this.once('valueWrite', function () { + this.once('valueWrite', () => { callback(null); }); } diff --git a/lib/distributed/bindings.js b/lib/distributed/bindings.js index ceb3fc3ed..72a7771b0 100644 --- a/lib/distributed/bindings.js +++ b/lib/distributed/bindings.js @@ -15,9 +15,9 @@ var NobleBindings = function () { this.on('close', this._onClose.bind(this)); this.on('message', this._onMessage.bind(this)); - process.nextTick(function () { + process.nextTick(() => { this.emit('stateChange', 'poweredOff'); - }.bind(this)); + }); }; util.inherits(NobleBindings, events.EventEmitter); @@ -35,11 +35,11 @@ NobleBindings.prototype._onConnection = function (ws) { this._sendCommand(ws, this._startScanCommand); } - ws.on('close', function () { + ws.on('close', () => { _this.emit('close', ws); }); - ws.on('message', function (data) { + ws.on('message', data => { _this.emit('message', ws, JSON.parse(data)); }); }; diff --git a/lib/hci-socket/gatt.js b/lib/hci-socket/gatt.js index 9f056f31a..5f45dcb51 100644 --- a/lib/hci-socket/gatt.js +++ b/lib/hci-socket/gatt.js @@ -106,9 +106,9 @@ Gatt.prototype.onAclStreamData = function (cid, data) { this.emit('handleNotify', this._address, valueHandle, valueData); if (data[0] === ATT_OP_HANDLE_IND) { - this._queueCommand(this.handleConfirmation(), null, function () { + this._queueCommand(this.handleConfirmation(), null, () => { this.emit('handleConfirmation', this._address, valueHandle); - }.bind(this)); + }); } for (var serviceUuid in this._services) { @@ -315,7 +315,7 @@ Gatt.prototype.handleConfirmation = function () { }; Gatt.prototype.exchangeMtu = function (mtu) { - this._queueCommand(this.mtuRequest(mtu), function (data) { + this._queueCommand(this.mtuRequest(mtu), (data) => { var opcode = data[0]; if (opcode === ATT_OP_MTU_RESP) { @@ -327,7 +327,7 @@ Gatt.prototype.exchangeMtu = function (mtu) { } this.emit('mtu', this._address, this._mtu); - }.bind(this)); + }); }; Gatt.prototype.addService = function (service) { @@ -337,7 +337,7 @@ Gatt.prototype.addService = function (service) { Gatt.prototype.discoverServices = function (uuids) { var services = []; - var callback = function (data) { + var callback = (data) => { var opcode = data[0]; var i = 0; @@ -369,7 +369,7 @@ Gatt.prototype.discoverServices = function (uuids) { } else { this._queueCommand(this.readByGroupRequest(services[services.length - 1].endHandle + 1, 0xffff, GATT_PRIM_SVC_UUID), callback); } - }.bind(this); + }; this._queueCommand(this.readByGroupRequest(0x0001, 0xffff, GATT_PRIM_SVC_UUID), callback); }; @@ -378,7 +378,7 @@ Gatt.prototype.discoverIncludedServices = function (serviceUuid, uuids) { var service = this._services[serviceUuid]; var includedServices = []; - var callback = function (data) { + var callback = (data) => { var opcode = data[0]; var i = 0; @@ -409,7 +409,7 @@ Gatt.prototype.discoverIncludedServices = function (serviceUuid, uuids) { } else { this._queueCommand(this.readByTypeRequest(includedServices[includedServices.length - 1].endHandle + 1, service.endHandle, GATT_INCLUDE_UUID), callback); } - }.bind(this); + }; this._queueCommand(this.readByTypeRequest(service.startHandle, service.endHandle, GATT_INCLUDE_UUID), callback); }; @@ -430,7 +430,7 @@ Gatt.prototype.discoverCharacteristics = function (serviceUuid, characteristicUu this._characteristics[serviceUuid] = this._characteristics[serviceUuid] || {}; this._descriptors[serviceUuid] = this._descriptors[serviceUuid] || {}; - var callback = function (data) { + var callback = (data) => { var opcode = data[0]; var i = 0; @@ -515,7 +515,7 @@ Gatt.prototype.discoverCharacteristics = function (serviceUuid, characteristicUu } else { this._queueCommand(this.readByTypeRequest(characteristics[characteristics.length - 1].valueHandle + 1, service.endHandle, GATT_CHARAC_UUID), callback); } - }.bind(this); + }; this._queueCommand(this.readByTypeRequest(service.startHandle, service.endHandle, GATT_CHARAC_UUID), callback); }; @@ -525,7 +525,7 @@ Gatt.prototype.read = function (serviceUuid, characteristicUuid) { var readData = Buffer.alloc(0); - var callback = function (data) { + var callback = (data) => { var opcode = data[0]; if (opcode === ATT_OP_READ_RESP || opcode === ATT_OP_READ_BLOB_RESP) { @@ -539,7 +539,7 @@ Gatt.prototype.read = function (serviceUuid, characteristicUuid) { } else { this.emit('read', this._address, serviceUuid, characteristicUuid, readData); } - }.bind(this); + }; this._queueCommand(this.readRequest(characteristic.valueHandle), callback); }; @@ -548,19 +548,19 @@ Gatt.prototype.write = function (serviceUuid, characteristicUuid, data, withoutR var characteristic = this._characteristics[serviceUuid][characteristicUuid]; if (withoutResponse) { - this._queueCommand(this.writeRequest(characteristic.valueHandle, data, true), null, function () { + this._queueCommand(this.writeRequest(characteristic.valueHandle, data, true), null, () => { this.emit('write', this._address, serviceUuid, characteristicUuid); - }.bind(this)); + }); } else if (data.length + 3 > this._mtu) { return this.longWrite(serviceUuid, characteristicUuid, data, withoutResponse); } else { - this._queueCommand(this.writeRequest(characteristic.valueHandle, data, false), function (data) { + this._queueCommand(this.writeRequest(characteristic.valueHandle, data, false), data => { var opcode = data[0]; if (opcode === ATT_OP_WRITE_RESP) { this.emit('write', this._address, serviceUuid, characteristicUuid); } - }.bind(this)); + }); } }; @@ -569,8 +569,8 @@ Gatt.prototype.longWrite = function (serviceUuid, characteristicUuid, data, with var characteristic = this._characteristics[serviceUuid][characteristicUuid]; var limit = this._mtu - 5; - var prepareWriteCallback = function (dataChunk) { - return function (resp) { + var prepareWriteCallback = (dataChunk) => { + return (resp) => { var opcode = resp[0]; if (opcode !== ATT_OP_PREPARE_WRITE_RESP) { @@ -583,8 +583,8 @@ Gatt.prototype.longWrite = function (serviceUuid, characteristicUuid, data, with debug(this._address + ': unexpected prepareWriteResponse length %d (expecting %d)', resp.length, expectedLength); } } - }.bind(this); - }.bind(this); + }; + }; /* split into prepare-write chunks and queue them */ var offset = 0; @@ -597,19 +597,19 @@ Gatt.prototype.longWrite = function (serviceUuid, characteristicUuid, data, with } /* queue the execute command with a callback to emit the write signal when done */ - this._queueCommand(this.executeWriteRequest(characteristic.valueHandle), function (resp) { + this._queueCommand(this.executeWriteRequest(characteristic.valueHandle), resp => { var opcode = resp[0]; if (opcode === ATT_OP_EXECUTE_WRITE_RESP && !withoutResponse) { this.emit('write', this._address, serviceUuid, characteristicUuid); } - }.bind(this)); + }); }; Gatt.prototype.broadcast = function (serviceUuid, characteristicUuid, broadcast) { var characteristic = this._characteristics[serviceUuid][characteristicUuid]; - this._queueCommand(this.readByTypeRequest(characteristic.startHandle, characteristic.endHandle, GATT_SERVER_CHARAC_CFG_UUID), function (data) { + this._queueCommand(this.readByTypeRequest(characteristic.startHandle, characteristic.endHandle, GATT_SERVER_CHARAC_CFG_UUID), data => { var opcode = data[0]; if (opcode === ATT_OP_READ_BY_TYPE_RESP) { var handle = data.readUInt16LE(2); @@ -624,21 +624,21 @@ Gatt.prototype.broadcast = function (serviceUuid, characteristicUuid, broadcast) var valueBuffer = Buffer.alloc(2); valueBuffer.writeUInt16LE(value, 0); - this._queueCommand(this.writeRequest(handle, valueBuffer, false), function (data) { + this._queueCommand(this.writeRequest(handle, valueBuffer, false), data => { var opcode = data[0]; if (opcode === ATT_OP_WRITE_RESP) { this.emit('broadcast', this._address, serviceUuid, characteristicUuid, broadcast); } - }.bind(this)); + }); } - }.bind(this)); + }); }; Gatt.prototype.notify = function (serviceUuid, characteristicUuid, notify) { var characteristic = this._characteristics[serviceUuid][characteristicUuid]; - this._queueCommand(this.readByTypeRequest(characteristic.startHandle, characteristic.endHandle, GATT_CLIENT_CHARAC_CFG_UUID), function (data) { + this._queueCommand(this.readByTypeRequest(characteristic.startHandle, characteristic.endHandle, GATT_CLIENT_CHARAC_CFG_UUID), data => { var opcode = data[0]; if (opcode === ATT_OP_READ_BY_TYPE_RESP) { var handle = data.readUInt16LE(2); @@ -664,15 +664,15 @@ Gatt.prototype.notify = function (serviceUuid, characteristicUuid, notify) { var valueBuffer = Buffer.alloc(2); valueBuffer.writeUInt16LE(value, 0); - this._queueCommand(this.writeRequest(handle, valueBuffer, false), function (data) { + this._queueCommand(this.writeRequest(handle, valueBuffer, false), data => { var opcode = data[0]; if (opcode === ATT_OP_WRITE_RESP) { this.emit('notify', this._address, serviceUuid, characteristicUuid, notify); } - }.bind(this)); + }); } - }.bind(this)); + }); }; function reverse (src) { @@ -692,7 +692,7 @@ Gatt.prototype.discoverDescriptors = function (serviceUuid, characteristicUuid) this._descriptors[serviceUuid][characteristicUuid] = {}; - var callback = function (data) { + var callback = data => { var opcode = data[0]; if (opcode === ATT_OP_FIND_INFO_RESP) { @@ -733,7 +733,7 @@ Gatt.prototype.discoverDescriptors = function (serviceUuid, characteristicUuid) } else { this._queueCommand(this.findInfoRequest(descriptors[descriptors.length - 1].handle + 1, characteristic.endHandle), callback); } - }.bind(this); + }; this._queueCommand(this.findInfoRequest(characteristic.valueHandle + 1, characteristic.endHandle), callback); }; @@ -743,7 +743,7 @@ Gatt.prototype.readValue = function (serviceUuid, characteristicUuid, descriptor var readData = new Buffer(0); - this._queueCommand(this.readRequest(descriptor.handle), function (data) { + this._queueCommand(this.readRequest(descriptor.handle), data => { var opcode = data[0]; if (opcode === ATT_OP_READ_RESP || opcode === ATT_OP_READ_BLOB_RESP) { @@ -758,44 +758,44 @@ Gatt.prototype.readValue = function (serviceUuid, characteristicUuid, descriptor } else { this.emit('valueRead', this._address, serviceUuid, characteristicUuid, descriptorUuid, readData); } - }.bind(this); + }); }; Gatt.prototype.writeValue = function (serviceUuid, characteristicUuid, descriptorUuid, data) { var descriptor = this._descriptors[serviceUuid][characteristicUuid][descriptorUuid]; - this._queueCommand(this.writeRequest(descriptor.handle, data, false), function (data) { + this._queueCommand(this.writeRequest(descriptor.handle, data, false), data => { var opcode = data[0]; if (opcode === ATT_OP_WRITE_RESP) { this.emit('valueWrite', this._address, serviceUuid, characteristicUuid, descriptorUuid); } - }.bind(this)); + }); }; Gatt.prototype.readHandle = function (handle) { - this._queueCommand(this.readRequest(handle), function (data) { + this._queueCommand(this.readRequest(handle), data => { var opcode = data[0]; if (opcode === ATT_OP_READ_RESP) { this.emit('handleRead', this._address, handle, data.slice(1)); } - }.bind(this)); + }); }; Gatt.prototype.writeHandle = function (handle, data, withoutResponse) { if (withoutResponse) { - this._queueCommand(this.writeRequest(handle, data, true), null, function () { + this._queueCommand(this.writeRequest(handle, data, true), null, () => { this.emit('handleWrite', this._address, handle); - }.bind(this)); + }); } else { - this._queueCommand(this.writeRequest(handle, data, false), function (data) { + this._queueCommand(this.writeRequest(handle, data, false), data => { var opcode = data[0]; if (opcode === ATT_OP_WRITE_RESP) { this.emit('handleWrite', this._address, handle); } - }.bind(this)); + }); } }; diff --git a/lib/noble.js b/lib/noble.js index 2a3e4295d..0bcd677ac 100644 --- a/lib/noble.js +++ b/lib/noble.js @@ -46,22 +46,22 @@ function Noble (bindings) { this._bindings.on('handleNotify', this.onHandleNotify.bind(this)); this._bindings.on('onMtu', this.onMtu.bind(this)); - this.on('warning', function (message) { + this.on('warning', (message) => { if (this.listeners('warning').length === 1) { console.warn('noble: ' + message); } - }.bind(this)); + }); // lazy init bindings on first new listener, should be on stateChange - this.on('newListener', function (event) { + this.on('newListener', (event) => { if (event === 'stateChange' && !this.initialized) { this.initialized = true; - process.nextTick(function () { + process.nextTick(() => { this._bindings.init(); - }.bind(this)); + }); } - }.bind(this)); + }); // or lazy init bindings if someone attempts to get state first Object.defineProperties(this, { @@ -118,7 +118,7 @@ Noble.prototype.startScanning = function (serviceUuids, allowDuplicates, callbac } } else { if (callback) { - this.once('scanStart', function (filterDuplicates) { + this.once('scanStart', filterDuplicates => { callback(null, filterDuplicates); }); } diff --git a/lib/peripheral.js b/lib/peripheral.js index 5c98f7792..e66bd81ad 100644 --- a/lib/peripheral.js +++ b/lib/peripheral.js @@ -37,7 +37,7 @@ Peripheral.prototype.connect = function (options, callback) { options = undefined; } if (callback) { - this.once('connect', function (error) { + this.once('connect', error => { callback(error); }); } @@ -72,7 +72,7 @@ Peripheral.prototype.cancelConnect = function (options, callback) { Peripheral.prototype.disconnect = function (callback) { if (callback) { - this.once('disconnect', function () { + this.once('disconnect', () => { callback(null); }); } @@ -82,7 +82,7 @@ Peripheral.prototype.disconnect = function (callback) { Peripheral.prototype.updateRssi = function (callback) { if (callback) { - this.once('rssiUpdate', function (rssi) { + this.once('rssiUpdate', rssi => { callback(null, rssi); }); } @@ -92,7 +92,7 @@ Peripheral.prototype.updateRssi = function (callback) { Peripheral.prototype.discoverServices = function (uuids, callback) { if (callback) { - this.once('servicesDiscover', function (services) { + this.once('servicesDiscover', services => { callback(null, services); }); } @@ -101,7 +101,7 @@ Peripheral.prototype.discoverServices = function (uuids, callback) { }; Peripheral.prototype.discoverSomeServicesAndCharacteristics = function (serviceUuids, characteristicsUuids, callback) { - this.discoverServices(serviceUuids, function (err, services) { + this.discoverServices(serviceUuids, (err, services) => { if (err) { callback(err, null, null); return; @@ -112,7 +112,7 @@ Peripheral.prototype.discoverSomeServicesAndCharacteristics = function (serviceU for (var i in services) { var service = services[i]; - service.discoverCharacteristics(characteristicsUuids, function (error, characteristics) { + service.discoverCharacteristics(characteristicsUuids, (error, characteristics) => { numDiscovered++; // TODO: handle `error`? @@ -140,7 +140,7 @@ Peripheral.prototype.discoverAllServicesAndCharacteristics = function (callback) Peripheral.prototype.readHandle = function (handle, callback) { if (callback) { - this.once('handleRead' + handle, function (data) { + this.once('handleRead' + handle, data => { callback(null, data); }); } @@ -154,7 +154,7 @@ Peripheral.prototype.writeHandle = function (handle, data, withoutResponse, call } if (callback) { - this.once('handleWrite' + handle, function () { + this.once('handleWrite' + handle, () => { callback(null); }); } diff --git a/lib/service.js b/lib/service.js index 0cfd6487c..1b48b9df8 100644 --- a/lib/service.js +++ b/lib/service.js @@ -33,7 +33,7 @@ Service.prototype.toString = function () { Service.prototype.discoverIncludedServices = function (serviceUuids, callback) { if (callback) { - this.once('includedServicesDiscover', function (includedServiceUuids) { + this.once('includedServicesDiscover', includedServiceUuids => { callback(null, includedServiceUuids); }); } @@ -47,7 +47,7 @@ Service.prototype.discoverIncludedServices = function (serviceUuids, callback) { Service.prototype.discoverCharacteristics = function (characteristicUuids, callback) { if (callback) { - this.once('characteristicsDiscover', function (characteristics) { + this.once('characteristicsDiscover', characteristics => { callback(null, characteristics); }); } diff --git a/lib/webbluetooth/bindings.js b/lib/webbluetooth/bindings.js index 05395b574..f4d91b098 100644 --- a/lib/webbluetooth/bindings.js +++ b/lib/webbluetooth/bindings.js @@ -39,7 +39,7 @@ NobleBindings.prototype.init = function (ble) { } var self = this; - process.nextTick(function () { + process.nextTick(() => { debug('initing'); if (!self._ble) { return self.emit('error', new Error('This browser does not support WebBluetooth.')); @@ -74,7 +74,7 @@ NobleBindings.prototype.startScanning = function (options, allowDuplicates) { options.services = [options.services]; } - options.services = options.services.map(function (service) { + options.services = options.services.map(service => { // web bluetooth requires 4 char hex service names to be passed in as integers if (typeof service === 'string' && service.length === 4) { service = parseInt('0x' + service); @@ -99,7 +99,7 @@ NobleBindings.prototype.startScanning = function (options, allowDuplicates) { debug('startScanning', request, allowDuplicates); this._ble.requestDevice(request) - .then(function (device) { + .then(device => { debug('scan finished', device); self.emit('scanStop', {}); if (device) { @@ -123,7 +123,7 @@ NobleBindings.prototype.startScanning = function (options, allowDuplicates) { self.emit('discover', device.id, device.id, device.addressType, !device.paired, self._peripherals[address].advertisement, self._peripherals[address].rssi); } }) - .catch(function (err) { + .catch(err => { debug('err scanning', err); self.emit('scanStop', {}); self.emit('error', err); @@ -148,7 +148,7 @@ NobleBindings.prototype.connect = function (deviceUuid) { // Attempts to connect to remote GATT Server. peripheral.device.gatt.connect() - .then(function (gattServer) { + .then(gattServer => { debug('peripheral connected', gattServer); var onDisconnected = function (event) { @@ -158,7 +158,7 @@ NobleBindings.prototype.connect = function (deviceUuid) { peripheral.device.addEventListener('gattserverdisconnected', onDisconnected, { once: true }); self.emit('connect', deviceUuid); - }, function (err) { + }, err => { debug('err connecting', err); self.emit('connect', deviceUuid, err); }); @@ -199,11 +199,9 @@ NobleBindings.prototype.discoverCharacteristics = function (deviceUuid, serviceU if (peripheral) { self.getPrimaryService(peripheral, serviceUuid) - .then(function (service) { - return service.getCharacteristics(); - }) - .then(function (characteristics) { - var discoveredCharacteristics = characteristics.map(function (char) { + .then(service => service.getCharacteristics()) + .then(characteristics => { + var discoveredCharacteristics = characteristics.map(char => { var charInfo = { uuid: stripDashes(char.uuid), properties: [] }; if (char.properties.writeWithoutResponse) { @@ -235,13 +233,13 @@ NobleBindings.prototype.getPrimaryService = function (peripheral, serviceUuid) { serviceUuid = addDashes(serviceUuid); if (peripheral.cachedServices[serviceUuid]) { - return new Promise(function (resolve, reject) { + return new Promise((resolve, reject) => { resolve(peripheral.cachedServices[serviceUuid]); }); } return peripheral.device.gatt.getPrimaryService(serviceUuid) - .then(function (service) { + .then(service => { peripheral.cachedServices[serviceUuid] = service; return service; }); @@ -253,16 +251,12 @@ NobleBindings.prototype.read = function (deviceUuid, serviceUuid, characteristic debug('read', deviceUuid, serviceUuid, characteristicUuid); self.getPrimaryService(peripheral, serviceUuid) - .then(function (service) { - return service.getCharacteristic(addDashes(characteristicUuid)); - }) - .then(function (characteristic) { - return characteristic.readValue(); - }) - .then(function (data) { + .then(service => service.getCharacteristic(addDashes(characteristicUuid))) + .then(characteristic => characteristic.readValue()) + .then(data => { self.emit('read', peripheral.uuid, serviceUuid, characteristicUuid, Buffer.from(data.buffer), false); }) - .catch(function (err) { + .catch(err => { debug('error reading characteristic', err); self.emit('error', err); }); @@ -274,17 +268,13 @@ NobleBindings.prototype.write = function (deviceUuid, serviceUuid, characteristi debug('write', deviceUuid, serviceUuid, characteristicUuid, data, withoutResponse); self.getPrimaryService(peripheral, serviceUuid) - .then(function (service) { - return service.getCharacteristic(addDashes(characteristicUuid)); - }) - .then(function (characteristic) { - return characteristic.writeValue(data); - }) - .then(function () { + .then(service => service.getCharacteristic(addDashes(characteristicUuid))) + .then(characteristic => characteristic.writeValue(data)) + .then(() => { debug('value written'); self.emit('write', peripheral.uuid, serviceUuid, characteristicUuid); }) - .catch(function (err) { + .catch(err => { debug('error writing to characteristic', serviceUuid, characteristicUuid, err); }); }; @@ -300,17 +290,13 @@ NobleBindings.prototype.notify = function (deviceUuid, serviceUuid, characterist var peripheral = this._peripherals[deviceUuid]; var charPromise = self.getPrimaryService(peripheral, serviceUuid) - .then(function (service) { - return service.getCharacteristic(addDashes(characteristicUuid)); - }); + .then(service => service.getCharacteristic(addDashes(characteristicUuid))); peripheral.notifcationListeners = peripheral.notifcationListeners || {}; if (notify) { - charPromise.then(function (characteristic) { - return characteristic.startNotifications(); - }) - .then(function (characteristic) { + charPromise.then(characteristic => characteristic.startNotifications()) + .then(characteristic => { debug('notifications started', characteristicUuid); peripheral.notifcationListeners[serviceUuid + '__' + characteristicUuid] = function (evt) { debug('oncharacteristicvaluechanged', evt, Buffer.from(evt.target.value.buffer)); @@ -327,15 +313,13 @@ NobleBindings.prototype.notify = function (deviceUuid, serviceUuid, characterist self.emit('notify', deviceUuid, serviceUuid, characteristicUuid, true); return characteristic; }) - .catch(function (err) { + .catch(err => { debug('error enabling notifications on characteristic', err); self.emit('error', err); }); } else { - charPromise.then(function (characteristic) { - return characteristic.stopNotifications(); - }) - .then(function (characteristic) { + charPromise.then(characteristic => characteristic.stopNotifications()) + .then(characteristic => { debug('notifications stopped', characteristic); if (peripheral.notifcationListeners[serviceUuid + '__' + characteristicUuid]) { characteristic.removeEventListener('characteristicvaluechanged', peripheral.notifcationListeners[serviceUuid + '__' + characteristicUuid]); @@ -344,7 +328,7 @@ NobleBindings.prototype.notify = function (deviceUuid, serviceUuid, characterist self.emit('notify', deviceUuid, serviceUuid, characteristicUuid, false); return characteristic; }) - .catch(function (err) { + .catch(err => { debug('error disabling notifications on characteristic', err); self.emit('error', err); }); diff --git a/lib/websocket/bindings.js b/lib/websocket/bindings.js index 5b2469b9e..1b43fb66a 100644 --- a/lib/websocket/bindings.js +++ b/lib/websocket/bindings.js @@ -21,7 +21,7 @@ var NobleBindings = function () { this._ws.on('error', this._onClose.bind(this)); var _this = this; - this._ws.on('message', function (event) { + this._ws.on('message', event => { var data = (process.title === 'browser') ? event.data : event; _this.emit('message', JSON.parse(data)); @@ -122,7 +122,7 @@ NobleBindings.prototype._onMessage = function (event) { NobleBindings.prototype._sendCommand = function (command, errorCallback) { var message = JSON.stringify(command); - this._ws.send(message, function (error) { + this._ws.send(message, error => { if (error != null) { console.warn('could not send command', command, error); if (typeof errorCallback === 'function') { From 8c0962a8926c8b6c3b48f35b5dfb14b4e4558c54 Mon Sep 17 00:00:00 2001 From: Aarni Koskela Date: Sat, 25 Jan 2020 15:11:31 +0200 Subject: [PATCH 066/114] Codemod vars into consts or lets --- examples/advertisement-discovery.js | 6 +- examples/cache-gatt-discovery.js | 2 +- examples/cache-gatt-reconnect.js | 2 +- examples/enter-exit.js | 16 +- examples/peripheral-explorer.js | 32 ++-- examples/pizza/central.js | 26 +-- examples/pizza/pizza.js | 16 +- lib/characteristic.js | 10 +- lib/descriptor.js | 8 +- lib/distributed/bindings.js | 50 ++--- lib/hci-socket/acl-stream.js | 12 +- lib/hci-socket/bindings.js | 144 +++++++------- lib/hci-socket/crypto.js | 18 +- lib/hci-socket/gap.js | 44 ++--- lib/hci-socket/gatt.js | 284 ++++++++++++++-------------- lib/hci-socket/hci.js | 254 ++++++++++++------------- lib/hci-socket/signaling.js | 34 ++-- lib/hci-socket/smp.js | 38 ++-- lib/mac/bindings.js | 6 +- lib/noble.js | 104 +++++----- lib/peripheral.js | 16 +- lib/resolve-bindings.js | 4 +- lib/service.js | 8 +- lib/webbluetooth/bindings.js | 54 +++--- lib/websocket/bindings.js | 50 ++--- test/test-characteristic.js | 40 ++-- test/test-descriptor.js | 30 +-- test/test-peripheral.js | 74 ++++---- test/test-service.js | 28 +-- 29 files changed, 705 insertions(+), 705 deletions(-) diff --git a/examples/advertisement-discovery.js b/examples/advertisement-discovery.js index 2a7d2996c..33cec77d9 100644 --- a/examples/advertisement-discovery.js +++ b/examples/advertisement-discovery.js @@ -1,4 +1,4 @@ -var noble = require('../index'); +const noble = require('../index'); noble.on('stateChange', function (state) { if (state === 'poweredOn') { @@ -18,10 +18,10 @@ noble.on('discover', function (peripheral) { console.log('\tcan I interest you in any of the following advertised services:'); console.log('\t\t' + JSON.stringify(peripheral.advertisement.serviceUuids)); - var serviceData = peripheral.advertisement.serviceData; + const serviceData = peripheral.advertisement.serviceData; if (serviceData && serviceData.length) { console.log('\there is my service data:'); - for (var i in serviceData) { + for (const i in serviceData) { console.log('\t\t' + JSON.stringify(serviceData[i].uuid) + ': ' + JSON.stringify(serviceData[i].data.toString('hex'))); } } diff --git a/examples/cache-gatt-discovery.js b/examples/cache-gatt-discovery.js index 98a3f9a4e..f61bd0e19 100644 --- a/examples/cache-gatt-discovery.js +++ b/examples/cache-gatt-discovery.js @@ -6,7 +6,7 @@ * Prints timing information from discovered to connected to reading states. */ -var noble = require('../index'); +const noble = require('../index'); const fs = require('fs'); // the sensor value to scan for, number of bits and factor for displaying it diff --git a/examples/cache-gatt-reconnect.js b/examples/cache-gatt-reconnect.js index a58b614cf..f4869bd13 100644 --- a/examples/cache-gatt-reconnect.js +++ b/examples/cache-gatt-reconnect.js @@ -6,7 +6,7 @@ * Prints timing information from discovered to connected to reading states. */ -var noble = require('../index'); +const noble = require('../index'); const fs = require('fs'); // the sensor value to scan for, number of bits and factor for displaying it diff --git a/examples/enter-exit.js b/examples/enter-exit.js index 7e874547a..a2dcf098c 100644 --- a/examples/enter-exit.js +++ b/examples/enter-exit.js @@ -7,12 +7,12 @@ based on code provided by: Mattias Ask (http://www.dittlof.com) */ -var noble = require('../index'); +const noble = require('../index'); -var RSSI_THRESHOLD = -90; -var EXIT_GRACE_PERIOD = 2000; // milliseconds +const RSSI_THRESHOLD = -90; +const EXIT_GRACE_PERIOD = 2000; // milliseconds -var inRange = []; +const inRange = []; noble.on('discover', function (peripheral) { if (peripheral.rssi < RSSI_THRESHOLD) { @@ -20,8 +20,8 @@ noble.on('discover', function (peripheral) { return; } - var id = peripheral.id; - var entered = !inRange[id]; + const id = peripheral.id; + const entered = !inRange[id]; if (entered) { inRange[id] = { @@ -35,9 +35,9 @@ noble.on('discover', function (peripheral) { }); setInterval(function () { - for (var id in inRange) { + for (const id in inRange) { if (inRange[id].lastSeen < (Date.now() - EXIT_GRACE_PERIOD)) { - var peripheral = inRange[id].peripheral; + const peripheral = inRange[id].peripheral; console.log('"' + peripheral.advertisement.localName + '" exited (RSSI ' + peripheral.rssi + ') ' + new Date()); diff --git a/examples/peripheral-explorer.js b/examples/peripheral-explorer.js index 5f87037f4..d21aa96a3 100644 --- a/examples/peripheral-explorer.js +++ b/examples/peripheral-explorer.js @@ -1,8 +1,8 @@ /* eslint-disable handle-callback-err */ -var async = require('async'); -var noble = require('../index'); +const async = require('async'); +const noble = require('../index'); -var peripheralIdOrAddress = process.argv[2].toLowerCase(); +const peripheralIdOrAddress = process.argv[2].toLowerCase(); noble.on('stateChange', function (state) { if (state === 'poweredOn') { @@ -17,13 +17,13 @@ noble.on('discover', function (peripheral) { noble.stopScanning(); console.log('peripheral with ID ' + peripheral.id + ' found'); - var advertisement = peripheral.advertisement; + const advertisement = peripheral.advertisement; - var localName = advertisement.localName; - var txPowerLevel = advertisement.txPowerLevel; - var manufacturerData = advertisement.manufacturerData; - var serviceData = advertisement.serviceData; - var serviceUuids = advertisement.serviceUuids; + const localName = advertisement.localName; + const txPowerLevel = advertisement.txPowerLevel; + const manufacturerData = advertisement.manufacturerData; + const serviceData = advertisement.serviceData; + const serviceUuids = advertisement.serviceUuids; if (localName) { console.log(' Local Name = ' + localName); @@ -60,15 +60,15 @@ function explore (peripheral) { peripheral.connect(function (error) { peripheral.discoverServices([], function (error, services) { - var serviceIndex = 0; + let serviceIndex = 0; async.whilst( function () { return (serviceIndex < services.length); }, function (callback) { - var service = services[serviceIndex]; - var serviceInfo = service.uuid; + const service = services[serviceIndex]; + let serviceInfo = service.uuid; if (service.name) { serviceInfo += ' (' + service.name + ')'; @@ -76,15 +76,15 @@ function explore (peripheral) { console.log(serviceInfo); service.discoverCharacteristics([], function (error, characteristics) { - var characteristicIndex = 0; + let characteristicIndex = 0; async.whilst( function () { return (characteristicIndex < characteristics.length); }, function (callback) { - var characteristic = characteristics[characteristicIndex]; - var characteristicInfo = ' ' + characteristic.uuid; + const characteristic = characteristics[characteristicIndex]; + let characteristicInfo = ' ' + characteristic.uuid; if (characteristic.name) { characteristicInfo += ' (' + characteristic.name + ')'; @@ -123,7 +123,7 @@ function explore (peripheral) { if (characteristic.properties.indexOf('read') !== -1) { characteristic.read(function (error, data) { if (data) { - var string = data.toString('ascii'); + const string = data.toString('ascii'); characteristicInfo += '\n value ' + data.toString('hex') + ' | \'' + string + '\''; } diff --git a/examples/pizza/central.js b/examples/pizza/central.js index 290f2bdbc..4b7664005 100644 --- a/examples/pizza/central.js +++ b/examples/pizza/central.js @@ -1,11 +1,11 @@ /* eslint-disable handle-callback-err */ -var noble = require('../..'); -var pizza = require('./pizza'); +const noble = require('../..'); +const pizza = require('./pizza'); -var pizzaServiceUuid = '13333333333333333333333333333337'; -var pizzaCrustCharacteristicUuid = '13333333333333333333333333330001'; -var pizzaToppingsCharacteristicUuid = '13333333333333333333333333330002'; -var pizzaBakeCharacteristicUuid = '13333333333333333333333333330003'; +const pizzaServiceUuid = '13333333333333333333333333333337'; +const pizzaCrustCharacteristicUuid = '13333333333333333333333333330001'; +const pizzaToppingsCharacteristicUuid = '13333333333333333333333333330002'; +const pizzaBakeCharacteristicUuid = '13333333333333333333333333330003'; noble.on('stateChange', function (state) { if (state === 'poweredOn') { @@ -21,9 +21,9 @@ noble.on('stateChange', function (state) { } }); -var pizzaCrustCharacteristic = null; -var pizzaToppingsCharacteristic = null; -var pizzaBakeCharacteristic = null; +let pizzaCrustCharacteristic = null; +let pizzaToppingsCharacteristic = null; +let pizzaBakeCharacteristic = null; noble.on('discover', function (peripheral) { // we found a peripheral, stop scanning @@ -93,14 +93,14 @@ function bakePizza () { // // Pick the crust. // - var crust = Buffer.alloc(1); + const crust = Buffer.alloc(1); crust.writeUInt8(pizza.PizzaCrust.THIN, 0); pizzaCrustCharacteristic.write(crust, false, function (err) { if (!err) { // // Pick the toppings. // - var toppings = Buffer.alloc(2); + const toppings = Buffer.alloc(2); toppings.writeUInt16BE( pizza.PizzaToppings.EXTRA_CHEESE | pizza.PizzaToppings.CANADIAN_BACON | @@ -116,7 +116,7 @@ function bakePizza () { pizzaBakeCharacteristic.on('read', function (data, isNotification) { console.log('Our pizza is ready!'); if (data.length === 1) { - var result = data.readUInt8(0); + const result = data.readUInt8(0); console.log('The result is', result === pizza.PizzaBakeResult.HALF_BAKED ? 'half baked.' : result === pizza.PizzaBakeResult.BAKED ? 'baked.' @@ -132,7 +132,7 @@ function bakePizza () { // // Bake at 450 degrees! // - var temperature = Buffer.alloc(2); + const temperature = Buffer.alloc(2); temperature.writeUInt16BE(450, 0); pizzaBakeCharacteristic.write(temperature, false, function (err) { if (err) { diff --git a/examples/pizza/pizza.js b/examples/pizza/pizza.js index 8b964f882..78e553f27 100644 --- a/examples/pizza/pizza.js +++ b/examples/pizza/pizza.js @@ -1,13 +1,13 @@ -var util = require('util'); -var events = require('events'); +const util = require('util'); +const events = require('events'); -var PizzaCrust = { +const PizzaCrust = { NORMAL: 0, DEEP_DISH: 1, THIN: 2 }; -var PizzaToppings = { +const PizzaToppings = { NONE: 0, PEPPERONI: 1 << 0, MUSHROOMS: 1 << 1, @@ -19,7 +19,7 @@ var PizzaToppings = { SAUSAGE: 1 << 7 }; -var PizzaBakeResult = { +const PizzaBakeResult = { HALF_BAKED: 0, BAKED: 1, CRISPY: 2, @@ -36,11 +36,11 @@ function Pizza () { util.inherits(Pizza, events.EventEmitter); Pizza.prototype.bake = function (temperature) { - var time = temperature * 10; - var self = this; + const time = temperature * 10; + const self = this; console.log('baking pizza at', temperature, 'degrees for', time, 'milliseconds'); setTimeout(function () { - var result = + const result = (temperature < 350) ? PizzaBakeResult.HALF_BAKED : (temperature < 450) ? PizzaBakeResult.BAKED : (temperature < 500) ? PizzaBakeResult.CRISPY diff --git a/lib/characteristic.js b/lib/characteristic.js index d18f17a85..4f0de5e83 100644 --- a/lib/characteristic.js +++ b/lib/characteristic.js @@ -1,7 +1,7 @@ -var events = require('events'); -var util = require('util'); +const events = require('events'); +const util = require('util'); -var characteristics = require('./characteristics.json'); +const characteristics = require('./characteristics.json'); function Characteristic (noble, peripheralId, serviceUuid, uuid, properties) { this._noble = noble; @@ -14,7 +14,7 @@ function Characteristic (noble, peripheralId, serviceUuid, uuid, properties) { this.properties = properties; this.descriptors = null; - var characteristic = characteristics[uuid]; + const characteristic = characteristics[uuid]; if (characteristic) { this.name = characteristic.name; this.type = characteristic.type; @@ -34,7 +34,7 @@ Characteristic.prototype.toString = function () { Characteristic.prototype.read = function (callback) { if (callback) { - var onRead = (data, isNotification) => { + const onRead = (data, isNotification) => { // only call the callback if 'read' event and non-notification // 'read' for non-notifications is only present for backwards compatbility if (!isNotification) { diff --git a/lib/descriptor.js b/lib/descriptor.js index 35521c811..6c87d1ae2 100644 --- a/lib/descriptor.js +++ b/lib/descriptor.js @@ -1,7 +1,7 @@ -var events = require('events'); -var util = require('util'); +const events = require('events'); +const util = require('util'); -var descriptors = require('./descriptors.json'); +const descriptors = require('./descriptors.json'); function Descriptor (noble, peripheralId, serviceUuid, characteristicUuid, uuid) { this._noble = noble; @@ -13,7 +13,7 @@ function Descriptor (noble, peripheralId, serviceUuid, characteristicUuid, uuid) this.name = null; this.type = null; - var descriptor = descriptors[uuid]; + const descriptor = descriptors[uuid]; if (descriptor) { this.name = descriptor.name; this.type = descriptor.type; diff --git a/lib/distributed/bindings.js b/lib/distributed/bindings.js index 72a7771b0..8f5c35160 100644 --- a/lib/distributed/bindings.js +++ b/lib/distributed/bindings.js @@ -1,9 +1,9 @@ -var events = require('events'); -var util = require('util'); +const events = require('events'); +const util = require('util'); -var WebSocketServer = require('ws').Server; +const WebSocketServer = require('ws').Server; -var NobleBindings = function () { +const NobleBindings = function () { this._wss = new WebSocketServer({ port: 0xB1e }); @@ -27,7 +27,7 @@ NobleBindings.prototype.init = function () { }; NobleBindings.prototype._onConnection = function (ws) { - var _this = this; + const _this = this; if (this._wss.clients.length === 1) { this.emit('stateChange', 'poweredOn'); @@ -51,7 +51,7 @@ NobleBindings.prototype._onClose = function (ws) { }; NobleBindings.prototype._onMessage = function (ws, event) { - var { + let { type, peripheralUuid, address, @@ -70,7 +70,7 @@ NobleBindings.prototype._onMessage = function (ws, event) { descriptorUuid, handle } = event; - var data = event.data ? Buffer.from(event.data, 'hex') : null; + const data = event.data ? Buffer.from(event.data, 'hex') : null; if (type === 'discover') { advertisement = { @@ -127,11 +127,11 @@ NobleBindings.prototype._onMessage = function (ws, event) { }; NobleBindings.prototype._sendCommand = function (ws, command) { - var clients = ws ? [ws] : this._wss.clients; + const clients = ws ? [ws] : this._wss.clients; - var message = JSON.stringify(command); + const message = JSON.stringify(command); - for (var i = 0; i < clients.length; i++) { + for (let i = 0; i < clients.length; i++) { clients[i].send(message); } }; @@ -159,7 +159,7 @@ NobleBindings.prototype.stopScanning = function () { }; NobleBindings.prototype.connect = function (deviceUuid) { - var peripheral = this._peripherals[deviceUuid]; + const peripheral = this._peripherals[deviceUuid]; this._sendCommand(peripheral.ws, { action: 'connect', @@ -168,7 +168,7 @@ NobleBindings.prototype.connect = function (deviceUuid) { }; NobleBindings.prototype.disconnect = function (deviceUuid) { - var peripheral = this._peripherals[deviceUuid]; + const peripheral = this._peripherals[deviceUuid]; this._sendCommand(peripheral.ws, { action: 'disconnect', @@ -177,7 +177,7 @@ NobleBindings.prototype.disconnect = function (deviceUuid) { }; NobleBindings.prototype.updateRssi = function (deviceUuid) { - var peripheral = this._peripherals[deviceUuid]; + const peripheral = this._peripherals[deviceUuid]; this._sendCommand(peripheral.ws, { action: 'updateRssi', @@ -186,7 +186,7 @@ NobleBindings.prototype.updateRssi = function (deviceUuid) { }; NobleBindings.prototype.discoverServices = function (deviceUuid, uuids) { - var peripheral = this._peripherals[deviceUuid]; + const peripheral = this._peripherals[deviceUuid]; this._sendCommand(peripheral.ws, { action: 'discoverServices', @@ -196,7 +196,7 @@ NobleBindings.prototype.discoverServices = function (deviceUuid, uuids) { }; NobleBindings.prototype.discoverIncludedServices = function (deviceUuid, serviceUuid, serviceUuids) { - var peripheral = this._peripherals[deviceUuid]; + const peripheral = this._peripherals[deviceUuid]; this._sendCommand(peripheral.ws, { action: 'discoverIncludedServices', @@ -207,7 +207,7 @@ NobleBindings.prototype.discoverIncludedServices = function (deviceUuid, service }; NobleBindings.prototype.discoverCharacteristics = function (deviceUuid, serviceUuid, characteristicUuids) { - var peripheral = this._peripherals[deviceUuid]; + const peripheral = this._peripherals[deviceUuid]; this._sendCommand(peripheral.ws, { action: 'discoverCharacteristics', @@ -218,7 +218,7 @@ NobleBindings.prototype.discoverCharacteristics = function (deviceUuid, serviceU }; NobleBindings.prototype.read = function (deviceUuid, serviceUuid, characteristicUuid) { - var peripheral = this._peripherals[deviceUuid]; + const peripheral = this._peripherals[deviceUuid]; this._sendCommand(peripheral.ws, { action: 'read', @@ -229,7 +229,7 @@ NobleBindings.prototype.read = function (deviceUuid, serviceUuid, characteristic }; NobleBindings.prototype.write = function (deviceUuid, serviceUuid, characteristicUuid, data, withoutResponse) { - var peripheral = this._peripherals[deviceUuid]; + const peripheral = this._peripherals[deviceUuid]; this._sendCommand(peripheral.ws, { action: 'write', @@ -242,7 +242,7 @@ NobleBindings.prototype.write = function (deviceUuid, serviceUuid, characteristi }; NobleBindings.prototype.broadcast = function (deviceUuid, serviceUuid, characteristicUuid, broadcast) { - var peripheral = this._peripherals[deviceUuid]; + const peripheral = this._peripherals[deviceUuid]; this._sendCommand(peripheral.ws, { action: 'broadcast', @@ -254,7 +254,7 @@ NobleBindings.prototype.broadcast = function (deviceUuid, serviceUuid, character }; NobleBindings.prototype.notify = function (deviceUuid, serviceUuid, characteristicUuid, notify) { - var peripheral = this._peripherals[deviceUuid]; + const peripheral = this._peripherals[deviceUuid]; this._sendCommand(peripheral.ws, { action: 'notify', @@ -266,7 +266,7 @@ NobleBindings.prototype.notify = function (deviceUuid, serviceUuid, characterist }; NobleBindings.prototype.discoverDescriptors = function (deviceUuid, serviceUuid, characteristicUuid) { - var peripheral = this._peripherals[deviceUuid]; + const peripheral = this._peripherals[deviceUuid]; this._sendCommand(peripheral.ws, { action: 'discoverDescriptors', @@ -277,7 +277,7 @@ NobleBindings.prototype.discoverDescriptors = function (deviceUuid, serviceUuid, }; NobleBindings.prototype.readValue = function (deviceUuid, serviceUuid, characteristicUuid, descriptorUuid) { - var peripheral = this._peripherals[deviceUuid]; + const peripheral = this._peripherals[deviceUuid]; this._sendCommand(peripheral.ws, { action: 'readValue', @@ -289,7 +289,7 @@ NobleBindings.prototype.readValue = function (deviceUuid, serviceUuid, character }; NobleBindings.prototype.writeValue = function (deviceUuid, serviceUuid, characteristicUuid, descriptorUuid, data) { - var peripheral = this._peripherals[deviceUuid]; + const peripheral = this._peripherals[deviceUuid]; this._sendCommand(peripheral.ws, { action: 'writeValue', @@ -302,7 +302,7 @@ NobleBindings.prototype.writeValue = function (deviceUuid, serviceUuid, characte }; NobleBindings.prototype.readHandle = function (deviceUuid, handle) { - var peripheral = this._peripherals[deviceUuid]; + const peripheral = this._peripherals[deviceUuid]; this._sendCommand(peripheral.ws, { action: 'readHandle', @@ -312,7 +312,7 @@ NobleBindings.prototype.readHandle = function (deviceUuid, handle) { }; NobleBindings.prototype.writeHandle = function (deviceUuid, handle, data, withoutResponse) { - var peripheral = this._peripherals[deviceUuid]; + const peripheral = this._peripherals[deviceUuid]; this._sendCommand(peripheral.ws, { action: 'readHandle', diff --git a/lib/hci-socket/acl-stream.js b/lib/hci-socket/acl-stream.js index 42d8b6dd9..f7f93e978 100644 --- a/lib/hci-socket/acl-stream.js +++ b/lib/hci-socket/acl-stream.js @@ -1,9 +1,9 @@ -var events = require('events'); -var util = require('util'); +const events = require('events'); +const util = require('util'); -var Smp = require('./smp'); +const Smp = require('./smp'); -var AclStream = function (hci, handle, localAddressType, localAddress, remoteAddressType, remoteAddress) { +const AclStream = function (hci, handle, localAddressType, localAddress, remoteAddressType, remoteAddress) { this._hci = hci; this._handle = handle; @@ -41,8 +41,8 @@ AclStream.prototype.pushEncrypt = function (encrypt) { }; AclStream.prototype.onSmpStk = function (stk) { - var random = Buffer.from('0000000000000000', 'hex'); - var diversifier = Buffer.from('0000', 'hex'); + const random = Buffer.from('0000000000000000', 'hex'); + const diversifier = Buffer.from('0000', 'hex'); this._hci.startLeEncryption(this._handle, random, diversifier, stk); }; diff --git a/lib/hci-socket/bindings.js b/lib/hci-socket/bindings.js index 542af9b3b..d7ac2e9e3 100644 --- a/lib/hci-socket/bindings.js +++ b/lib/hci-socket/bindings.js @@ -1,14 +1,14 @@ -var events = require('events'); -var util = require('util'); +const events = require('events'); +const util = require('util'); -var AclStream = require('./acl-stream'); -var Gatt = require('./gatt'); -var Gap = require('./gap'); -var Hci = require('./hci'); -var Signaling = require('./signaling'); +const AclStream = require('./acl-stream'); +const Gatt = require('./gatt'); +const Gap = require('./gap'); +const Hci = require('./hci'); +const Signaling = require('./signaling'); -var NobleBindings = function (options) { +const NobleBindings = function (options) { this._state = null; this._addresses = {}; @@ -45,8 +45,8 @@ NobleBindings.prototype.stopScanning = function () { }; NobleBindings.prototype.connect = function (peripheralUuid, parameters) { - var address = this._addresses[peripheralUuid]; - var addressType = this._addresseTypes[peripheralUuid]; + const address = this._addresses[peripheralUuid]; + const addressType = this._addresseTypes[peripheralUuid]; if (!this._pendingConnectionUuid) { this._pendingConnectionUuid = peripheralUuid; @@ -98,7 +98,7 @@ NobleBindings.prototype.init = function () { }; NobleBindings.prototype.onSigInt = function () { - var sigIntListeners = process.listeners('SIGINT'); + const sigIntListeners = process.listeners('SIGINT'); if (sigIntListeners[sigIntListeners.length - 1] === this.onSigIntBinded) { // we are the last listener, so exit @@ -110,7 +110,7 @@ NobleBindings.prototype.onSigInt = function () { NobleBindings.prototype.onExit = function () { this.stopScanning(); - for (var handle in this._aclStreams) { + for (const handle in this._aclStreams) { this._hci.disconnect(handle); } }; @@ -155,12 +155,12 @@ NobleBindings.prototype.onDiscover = function (status, address, addressType, con return; } - var serviceUuids = advertisement.serviceUuids || []; - var serviceData = advertisement.serviceData || []; - var hasScanServiceUuids = (this._scanServiceUuids.length === 0); + let serviceUuids = advertisement.serviceUuids || []; + const serviceData = advertisement.serviceData || []; + let hasScanServiceUuids = (this._scanServiceUuids.length === 0); if (!hasScanServiceUuids) { - var i; + let i; serviceUuids = serviceUuids.slice(); @@ -188,16 +188,16 @@ NobleBindings.prototype.onDiscover = function (status, address, addressType, con }; NobleBindings.prototype.onLeConnComplete = function (status, handle, role, addressType, address, interval, latency, supervisionTimeout, masterClockAccuracy) { - var uuid = null; + let uuid = null; - var error = null; + let error = null; if (status === 0) { uuid = address.split(':').join('').toLowerCase(); - var aclStream = new AclStream(this._hci, handle, this._hci.addressType, this._hci.address, addressType, address); - var gatt = new Gatt(address, aclStream); - var signaling = new Signaling(handle, aclStream); + const aclStream = new AclStream(this._hci, handle, this._hci.addressType, this._hci.address, addressType, address); + const gatt = new Gatt(address, aclStream); + const signaling = new Signaling(handle, aclStream); this._gatts[uuid] = this._gatts[handle] = gatt; this._signalings[uuid] = this._signalings[handle] = signaling; @@ -228,8 +228,8 @@ NobleBindings.prototype.onLeConnComplete = function (status, handle, role, addre this._gatts[handle].exchangeMtu(256); } else { uuid = this._pendingConnectionUuid; - var statusMessage = Hci.STATUS_MAPPER[status] || 'HCI Error: Unknown'; - var errorCode = ' (0x' + status.toString(16) + ')'; + let statusMessage = Hci.STATUS_MAPPER[status] || 'HCI Error: Unknown'; + const errorCode = ' (0x' + status.toString(16) + ')'; statusMessage = statusMessage + errorCode; error = new Error(statusMessage); } @@ -237,8 +237,8 @@ NobleBindings.prototype.onLeConnComplete = function (status, handle, role, addre this.emit('connect', uuid, error); if (this._connectionQueue.length > 0) { - var queueItem = this._connectionQueue.shift(); - var peripheralUuid = queueItem.id; + const queueItem = this._connectionQueue.shift(); + const peripheralUuid = queueItem.id; address = this._addresses[peripheralUuid]; addressType = this._addresseTypes[peripheralUuid]; @@ -256,7 +256,7 @@ NobleBindings.prototype.onLeConnUpdateComplete = function (handle, interval, lat }; NobleBindings.prototype.onDisconnComplete = function (handle, reason) { - var uuid = this._handles[handle]; + const uuid = this._handles[handle]; if (uuid) { this._aclStreams[handle].push(null, null); @@ -278,7 +278,7 @@ NobleBindings.prototype.onDisconnComplete = function (handle, reason) { }; NobleBindings.prototype.onEncryptChange = function (handle, encrypt) { - var aclStream = this._aclStreams[handle]; + const aclStream = this._aclStreams[handle]; if (aclStream) { aclStream.pushEncrypt(encrypt); @@ -296,7 +296,7 @@ NobleBindings.prototype.onRssiRead = function (handle, rssi) { }; NobleBindings.prototype.onAclDataPkt = function (handle, cid, data) { - var aclStream = this._aclStreams[handle]; + const aclStream = this._aclStreams[handle]; if (aclStream) { aclStream.push(cid, data); @@ -304,8 +304,8 @@ NobleBindings.prototype.onAclDataPkt = function (handle, cid, data) { }; NobleBindings.prototype.addService = function (peripheralUuid, service) { - var handle = this._handles[peripheralUuid]; - var gatt = this._gatts[handle]; + const handle = this._handles[peripheralUuid]; + const gatt = this._gatts[handle]; if (gatt) { gatt.addService(service); @@ -315,8 +315,8 @@ NobleBindings.prototype.addService = function (peripheralUuid, service) { }; NobleBindings.prototype.discoverServices = function (peripheralUuid, uuids) { - var handle = this._handles[peripheralUuid]; - var gatt = this._gatts[handle]; + const handle = this._handles[peripheralUuid]; + const gatt = this._gatts[handle]; if (gatt) { gatt.discoverServices(uuids || []); @@ -326,20 +326,20 @@ NobleBindings.prototype.discoverServices = function (peripheralUuid, uuids) { }; NobleBindings.prototype.onServicesDiscovered = function (address, serviceUuids) { - var uuid = address.split(':').join('').toLowerCase(); + const uuid = address.split(':').join('').toLowerCase(); this.emit('servicesDiscover', uuid, serviceUuids); }; NobleBindings.prototype.onServicesDiscoveredEX = function (address, services) { - var uuid = address.split(':').join('').toLowerCase(); + const uuid = address.split(':').join('').toLowerCase(); this.emit('servicesDiscovered', uuid, services); }; NobleBindings.prototype.discoverIncludedServices = function (peripheralUuid, serviceUuid, serviceUuids) { - var handle = this._handles[peripheralUuid]; - var gatt = this._gatts[handle]; + const handle = this._handles[peripheralUuid]; + const gatt = this._gatts[handle]; if (gatt) { gatt.discoverIncludedServices(serviceUuid, serviceUuids || []); @@ -349,14 +349,14 @@ NobleBindings.prototype.discoverIncludedServices = function (peripheralUuid, ser }; NobleBindings.prototype.onIncludedServicesDiscovered = function (address, serviceUuid, includedServiceUuids) { - var uuid = address.split(':').join('').toLowerCase(); + const uuid = address.split(':').join('').toLowerCase(); this.emit('includedServicesDiscover', uuid, serviceUuid, includedServiceUuids); }; NobleBindings.prototype.addCharacteristics = function (peripheralUuid, serviceUuid, characteristics) { - var handle = this._handles[peripheralUuid]; - var gatt = this._gatts[handle]; + const handle = this._handles[peripheralUuid]; + const gatt = this._gatts[handle]; if (gatt) { gatt.addCharacteristics(serviceUuid, characteristics); @@ -366,8 +366,8 @@ NobleBindings.prototype.addCharacteristics = function (peripheralUuid, serviceUu }; NobleBindings.prototype.discoverCharacteristics = function (peripheralUuid, serviceUuid, characteristicUuids) { - var handle = this._handles[peripheralUuid]; - var gatt = this._gatts[handle]; + const handle = this._handles[peripheralUuid]; + const gatt = this._gatts[handle]; if (gatt) { gatt.discoverCharacteristics(serviceUuid, characteristicUuids || []); @@ -377,20 +377,20 @@ NobleBindings.prototype.discoverCharacteristics = function (peripheralUuid, serv }; NobleBindings.prototype.onCharacteristicsDiscovered = function (address, serviceUuid, characteristics) { - var uuid = address.split(':').join('').toLowerCase(); + const uuid = address.split(':').join('').toLowerCase(); this.emit('characteristicsDiscover', uuid, serviceUuid, characteristics); }; NobleBindings.prototype.onCharacteristicsDiscoveredEX = function (address, serviceUuid, characteristics) { - var uuid = address.split(':').join('').toLowerCase(); + const uuid = address.split(':').join('').toLowerCase(); this.emit('characteristicsDiscovered', uuid, serviceUuid, characteristics); }; NobleBindings.prototype.read = function (peripheralUuid, serviceUuid, characteristicUuid) { - var handle = this._handles[peripheralUuid]; - var gatt = this._gatts[handle]; + const handle = this._handles[peripheralUuid]; + const gatt = this._gatts[handle]; if (gatt) { gatt.read(serviceUuid, characteristicUuid); @@ -400,14 +400,14 @@ NobleBindings.prototype.read = function (peripheralUuid, serviceUuid, characteri }; NobleBindings.prototype.onRead = function (address, serviceUuid, characteristicUuid, data) { - var uuid = address.split(':').join('').toLowerCase(); + const uuid = address.split(':').join('').toLowerCase(); this.emit('read', uuid, serviceUuid, characteristicUuid, data, false); }; NobleBindings.prototype.write = function (peripheralUuid, serviceUuid, characteristicUuid, data, withoutResponse) { - var handle = this._handles[peripheralUuid]; - var gatt = this._gatts[handle]; + const handle = this._handles[peripheralUuid]; + const gatt = this._gatts[handle]; if (gatt) { gatt.write(serviceUuid, characteristicUuid, data, withoutResponse); @@ -417,14 +417,14 @@ NobleBindings.prototype.write = function (peripheralUuid, serviceUuid, character }; NobleBindings.prototype.onWrite = function (address, serviceUuid, characteristicUuid) { - var uuid = address.split(':').join('').toLowerCase(); + const uuid = address.split(':').join('').toLowerCase(); this.emit('write', uuid, serviceUuid, characteristicUuid); }; NobleBindings.prototype.broadcast = function (peripheralUuid, serviceUuid, characteristicUuid, broadcast) { - var handle = this._handles[peripheralUuid]; - var gatt = this._gatts[handle]; + const handle = this._handles[peripheralUuid]; + const gatt = this._gatts[handle]; if (gatt) { gatt.broadcast(serviceUuid, characteristicUuid, broadcast); @@ -434,14 +434,14 @@ NobleBindings.prototype.broadcast = function (peripheralUuid, serviceUuid, chara }; NobleBindings.prototype.onBroadcast = function (address, serviceUuid, characteristicUuid, state) { - var uuid = address.split(':').join('').toLowerCase(); + const uuid = address.split(':').join('').toLowerCase(); this.emit('broadcast', uuid, serviceUuid, characteristicUuid, state); }; NobleBindings.prototype.notify = function (peripheralUuid, serviceUuid, characteristicUuid, notify) { - var handle = this._handles[peripheralUuid]; - var gatt = this._gatts[handle]; + const handle = this._handles[peripheralUuid]; + const gatt = this._gatts[handle]; if (gatt) { gatt.notify(serviceUuid, characteristicUuid, notify); @@ -451,20 +451,20 @@ NobleBindings.prototype.notify = function (peripheralUuid, serviceUuid, characte }; NobleBindings.prototype.onNotify = function (address, serviceUuid, characteristicUuid, state) { - var uuid = address.split(':').join('').toLowerCase(); + const uuid = address.split(':').join('').toLowerCase(); this.emit('notify', uuid, serviceUuid, characteristicUuid, state); }; NobleBindings.prototype.onNotification = function (address, serviceUuid, characteristicUuid, data) { - var uuid = address.split(':').join('').toLowerCase(); + const uuid = address.split(':').join('').toLowerCase(); this.emit('read', uuid, serviceUuid, characteristicUuid, data, true); }; NobleBindings.prototype.discoverDescriptors = function (peripheralUuid, serviceUuid, characteristicUuid) { - var handle = this._handles[peripheralUuid]; - var gatt = this._gatts[handle]; + const handle = this._handles[peripheralUuid]; + const gatt = this._gatts[handle]; if (gatt) { gatt.discoverDescriptors(serviceUuid, characteristicUuid); @@ -474,14 +474,14 @@ NobleBindings.prototype.discoverDescriptors = function (peripheralUuid, serviceU }; NobleBindings.prototype.onDescriptorsDiscovered = function (address, serviceUuid, characteristicUuid, descriptorUuids) { - var uuid = address.split(':').join('').toLowerCase(); + const uuid = address.split(':').join('').toLowerCase(); this.emit('descriptorsDiscover', uuid, serviceUuid, characteristicUuid, descriptorUuids); }; NobleBindings.prototype.readValue = function (peripheralUuid, serviceUuid, characteristicUuid, descriptorUuid) { - var handle = this._handles[peripheralUuid]; - var gatt = this._gatts[handle]; + const handle = this._handles[peripheralUuid]; + const gatt = this._gatts[handle]; if (gatt) { gatt.readValue(serviceUuid, characteristicUuid, descriptorUuid); @@ -491,14 +491,14 @@ NobleBindings.prototype.readValue = function (peripheralUuid, serviceUuid, chara }; NobleBindings.prototype.onValueRead = function (address, serviceUuid, characteristicUuid, descriptorUuid, data) { - var uuid = address.split(':').join('').toLowerCase(); + const uuid = address.split(':').join('').toLowerCase(); this.emit('valueRead', uuid, serviceUuid, characteristicUuid, descriptorUuid, data); }; NobleBindings.prototype.writeValue = function (peripheralUuid, serviceUuid, characteristicUuid, descriptorUuid, data) { - var handle = this._handles[peripheralUuid]; - var gatt = this._gatts[handle]; + const handle = this._handles[peripheralUuid]; + const gatt = this._gatts[handle]; if (gatt) { gatt.writeValue(serviceUuid, characteristicUuid, descriptorUuid, data); @@ -508,14 +508,14 @@ NobleBindings.prototype.writeValue = function (peripheralUuid, serviceUuid, char }; NobleBindings.prototype.onValueWrite = function (address, serviceUuid, characteristicUuid, descriptorUuid) { - var uuid = address.split(':').join('').toLowerCase(); + const uuid = address.split(':').join('').toLowerCase(); this.emit('valueWrite', uuid, serviceUuid, characteristicUuid, descriptorUuid); }; NobleBindings.prototype.readHandle = function (peripheralUuid, attHandle) { - var handle = this._handles[peripheralUuid]; - var gatt = this._gatts[handle]; + const handle = this._handles[peripheralUuid]; + const gatt = this._gatts[handle]; if (gatt) { gatt.readHandle(attHandle); @@ -525,14 +525,14 @@ NobleBindings.prototype.readHandle = function (peripheralUuid, attHandle) { }; NobleBindings.prototype.onHandleRead = function (address, handle, data) { - var uuid = address.split(':').join('').toLowerCase(); + const uuid = address.split(':').join('').toLowerCase(); this.emit('handleRead', uuid, handle, data); }; NobleBindings.prototype.writeHandle = function (peripheralUuid, attHandle, data, withoutResponse) { - var handle = this._handles[peripheralUuid]; - var gatt = this._gatts[handle]; + const handle = this._handles[peripheralUuid]; + const gatt = this._gatts[handle]; if (gatt) { gatt.writeHandle(attHandle, data, withoutResponse); @@ -542,13 +542,13 @@ NobleBindings.prototype.writeHandle = function (peripheralUuid, attHandle, data, }; NobleBindings.prototype.onHandleWrite = function (address, handle) { - var uuid = address.split(':').join('').toLowerCase(); + const uuid = address.split(':').join('').toLowerCase(); this.emit('handleWrite', uuid, handle); }; NobleBindings.prototype.onHandleNotify = function (address, handle, data) { - var uuid = address.split(':').join('').toLowerCase(); + const uuid = address.split(':').join('').toLowerCase(); this.emit('handleNotify', uuid, handle, data); }; diff --git a/lib/hci-socket/crypto.js b/lib/hci-socket/crypto.js index 3f99d2aed..2fc35cdde 100644 --- a/lib/hci-socket/crypto.js +++ b/lib/hci-socket/crypto.js @@ -1,24 +1,24 @@ -var crypto = require('crypto'); +const crypto = require('crypto'); function r () { return crypto.randomBytes(16); } function c1 (k, r, pres, preq, iat, ia, rat, ra) { - var p1 = Buffer.concat([ + const p1 = Buffer.concat([ iat, rat, preq, pres ]); - var p2 = Buffer.concat([ + const p2 = Buffer.concat([ ra, ia, Buffer.from('00000000', 'hex') ]); - var res = xor(r, p1); + let res = xor(r, p1); res = e(k, res); res = xor(res, p2); res = e(k, res); @@ -37,7 +37,7 @@ function e (key, data) { key = swap(key); data = swap(data); - var cipher = crypto.createCipheriv('aes-128-ecb', key, ''); + const cipher = crypto.createCipheriv('aes-128-ecb', key, ''); cipher.setAutoPadding(false); return swap(Buffer.concat([ @@ -47,9 +47,9 @@ function e (key, data) { } function xor (b1, b2) { - var result = Buffer.alloc(b1.length); + const result = Buffer.alloc(b1.length); - for (var i = 0; i < b1.length; i++) { + for (let i = 0; i < b1.length; i++) { result[i] = b1[i] ^ b2[i]; } @@ -57,9 +57,9 @@ function xor (b1, b2) { } function swap (input) { - var output = Buffer.alloc(input.length); + const output = Buffer.alloc(input.length); - for (var i = 0; i < output.length; i++) { + for (let i = 0; i < output.length; i++) { output[i] = input[input.length - i - 1]; } diff --git a/lib/hci-socket/gap.js b/lib/hci-socket/gap.js index 0e1dc2c76..8339f1657 100644 --- a/lib/hci-socket/gap.js +++ b/lib/hci-socket/gap.js @@ -1,12 +1,12 @@ -var debug = require('debug')('gap'); +const debug = require('debug')('gap'); -var events = require('events'); -var os = require('os'); -var util = require('util'); +const events = require('events'); +const os = require('os'); +const util = require('util'); -var isChip = (os.platform() === 'linux') && (os.release().indexOf('-ntc') !== -1); +const isChip = (os.platform() === 'linux') && (os.release().indexOf('-ntc') !== -1); -var Gap = function (hci) { +const Gap = function (hci) { this._hci = hci; this._scanState = null; @@ -100,8 +100,8 @@ Gap.prototype.onLeScanEnableSetCmd = function (enable, filterDuplicates) { }; Gap.prototype.onHciLeAdvertisingReport = function (status, type, address, addressType, eir, rssi) { - var previouslyDiscovered = !!this._discoveries[address]; - var advertisement = previouslyDiscovered ? this._discoveries[address].advertisement : { + const previouslyDiscovered = !!this._discoveries[address]; + const advertisement = previouslyDiscovered ? this._discoveries[address].advertisement : { localName: undefined, txPowerLevel: undefined, manufacturerData: undefined, @@ -110,8 +110,8 @@ Gap.prototype.onHciLeAdvertisingReport = function (status, type, address, addres solicitationServiceUuids: [] }; - var discoveryCount = previouslyDiscovered ? this._discoveries[address].count : 0; - var hasScanResponse = previouslyDiscovered ? this._discoveries[address].hasScanResponse : false; + let discoveryCount = previouslyDiscovered ? this._discoveries[address].count : 0; + let hasScanResponse = previouslyDiscovered ? this._discoveries[address].hasScanResponse : false; if (type === 0x04) { hasScanResponse = true; @@ -124,10 +124,10 @@ Gap.prototype.onHciLeAdvertisingReport = function (status, type, address, addres discoveryCount++; - var i = 0; - var j = 0; - var serviceUuid = null; - var serviceSolicitationUuid = null; + let i = 0; + let j = 0; + let serviceUuid = null; + let serviceSolicitationUuid = null; while ((i + 1) < eir.length) { var length = eir.readUInt8(i); @@ -137,14 +137,14 @@ Gap.prototype.onHciLeAdvertisingReport = function (status, type, address, addres break; } - var eirType = eir.readUInt8(i + 1); // https://www.bluetooth.org/en-us/specification/assigned-numbers/generic-access-profile + const eirType = eir.readUInt8(i + 1); // https://www.bluetooth.org/en-us/specification/assigned-numbers/generic-access-profile if ((i + length + 1) > eir.length) { debug('invalid EIR data, out of range of buffer length'); break; } - var bytes = eir.slice(i + 2).slice(0, length - 1); + const bytes = eir.slice(i + 2).slice(0, length - 1); switch (eirType) { case 0x02: // Incomplete List of 16-bit Service Class UUID @@ -195,7 +195,7 @@ Gap.prototype.onHciLeAdvertisingReport = function (status, type, address, addres break; case 0x16: // 16-bit Service Data, there can be multiple occurences - var serviceDataUuid = bytes.slice(0, 2).toString('hex').match(/.{1,2}/g).reverse().join(''); + const serviceDataUuid = bytes.slice(0, 2).toString('hex').match(/.{1,2}/g).reverse().join(''); var serviceData = bytes.slice(2, bytes.length); advertisement.serviceData.push({ @@ -205,8 +205,8 @@ Gap.prototype.onHciLeAdvertisingReport = function (status, type, address, addres break; case 0x20: // 32-bit Service Data, there can be multiple occurences - var serviceData32Uuid = bytes.slice(0, 4).toString('hex').match(/.{1,2}/g).reverse().join(''); - var serviceData32 = bytes.slice(4, bytes.length); + const serviceData32Uuid = bytes.slice(0, 4).toString('hex').match(/.{1,2}/g).reverse().join(''); + const serviceData32 = bytes.slice(4, bytes.length); advertisement.serviceData.push({ uuid: serviceData32Uuid, @@ -215,8 +215,8 @@ Gap.prototype.onHciLeAdvertisingReport = function (status, type, address, addres break; case 0x21: // 128-bit Service Data, there can be multiple occurences - var serviceData128Uuid = bytes.slice(0, 16).toString('hex').match(/.{1,2}/g).reverse().join(''); - var serviceData128 = bytes.slice(16, bytes.length); + const serviceData128Uuid = bytes.slice(0, 16).toString('hex').match(/.{1,2}/g).reverse().join(''); + const serviceData128 = bytes.slice(16, bytes.length); advertisement.serviceData.push({ uuid: serviceData128Uuid, @@ -243,7 +243,7 @@ Gap.prototype.onHciLeAdvertisingReport = function (status, type, address, addres debug('advertisement = ' + JSON.stringify(advertisement, null, 0)); - var connectable = (type === 0x04 && previouslyDiscovered) ? this._discoveries[address].connectable : (type !== 0x03); + const connectable = (type === 0x04 && previouslyDiscovered) ? this._discoveries[address].connectable : (type !== 0x03); this._discoveries[address] = { address: address, diff --git a/lib/hci-socket/gatt.js b/lib/hci-socket/gatt.js index 5f45dcb51..7539527ea 100644 --- a/lib/hci-socket/gatt.js +++ b/lib/hci-socket/gatt.js @@ -1,63 +1,63 @@ -var debug = require('debug')('att'); +const debug = require('debug')('att'); -var events = require('events'); -var util = require('util'); +const events = require('events'); +const util = require('util'); /* eslint-disable no-unused-vars */ -var ATT_OP_ERROR = 0x01; -var ATT_OP_MTU_REQ = 0x02; -var ATT_OP_MTU_RESP = 0x03; -var ATT_OP_FIND_INFO_REQ = 0x04; -var ATT_OP_FIND_INFO_RESP = 0x05; -var ATT_OP_READ_BY_TYPE_REQ = 0x08; -var ATT_OP_READ_BY_TYPE_RESP = 0x09; -var ATT_OP_READ_REQ = 0x0a; -var ATT_OP_READ_RESP = 0x0b; -var ATT_OP_READ_BLOB_REQ = 0x0c; -var ATT_OP_READ_BLOB_RESP = 0x0d; -var ATT_OP_READ_BY_GROUP_REQ = 0x10; -var ATT_OP_READ_BY_GROUP_RESP = 0x11; -var ATT_OP_WRITE_REQ = 0x12; -var ATT_OP_WRITE_RESP = 0x13; -var ATT_OP_PREPARE_WRITE_REQ = 0x16; -var ATT_OP_PREPARE_WRITE_RESP = 0x17; -var ATT_OP_EXECUTE_WRITE_REQ = 0x18; -var ATT_OP_EXECUTE_WRITE_RESP = 0x19; -var ATT_OP_HANDLE_NOTIFY = 0x1b; -var ATT_OP_HANDLE_IND = 0x1d; -var ATT_OP_HANDLE_CNF = 0x1e; -var ATT_OP_WRITE_CMD = 0x52; - -var ATT_ECODE_SUCCESS = 0x00; -var ATT_ECODE_INVALID_HANDLE = 0x01; -var ATT_ECODE_READ_NOT_PERM = 0x02; -var ATT_ECODE_WRITE_NOT_PERM = 0x03; -var ATT_ECODE_INVALID_PDU = 0x04; -var ATT_ECODE_AUTHENTICATION = 0x05; -var ATT_ECODE_REQ_NOT_SUPP = 0x06; -var ATT_ECODE_INVALID_OFFSET = 0x07; -var ATT_ECODE_AUTHORIZATION = 0x08; -var ATT_ECODE_PREP_QUEUE_FULL = 0x09; -var ATT_ECODE_ATTR_NOT_FOUND = 0x0a; -var ATT_ECODE_ATTR_NOT_LONG = 0x0b; -var ATT_ECODE_INSUFF_ENCR_KEY_SIZE = 0x0c; -var ATT_ECODE_INVAL_ATTR_VALUE_LEN = 0x0d; -var ATT_ECODE_UNLIKELY = 0x0e; -var ATT_ECODE_INSUFF_ENC = 0x0f; -var ATT_ECODE_UNSUPP_GRP_TYPE = 0x10; -var ATT_ECODE_INSUFF_RESOURCES = 0x11; - -var GATT_PRIM_SVC_UUID = 0x2800; -var GATT_INCLUDE_UUID = 0x2802; -var GATT_CHARAC_UUID = 0x2803; - -var GATT_CLIENT_CHARAC_CFG_UUID = 0x2902; -var GATT_SERVER_CHARAC_CFG_UUID = 0x2903; - -var ATT_CID = 0x0004; +const ATT_OP_ERROR = 0x01; +const ATT_OP_MTU_REQ = 0x02; +const ATT_OP_MTU_RESP = 0x03; +const ATT_OP_FIND_INFO_REQ = 0x04; +const ATT_OP_FIND_INFO_RESP = 0x05; +const ATT_OP_READ_BY_TYPE_REQ = 0x08; +const ATT_OP_READ_BY_TYPE_RESP = 0x09; +const ATT_OP_READ_REQ = 0x0a; +const ATT_OP_READ_RESP = 0x0b; +const ATT_OP_READ_BLOB_REQ = 0x0c; +const ATT_OP_READ_BLOB_RESP = 0x0d; +const ATT_OP_READ_BY_GROUP_REQ = 0x10; +const ATT_OP_READ_BY_GROUP_RESP = 0x11; +const ATT_OP_WRITE_REQ = 0x12; +const ATT_OP_WRITE_RESP = 0x13; +const ATT_OP_PREPARE_WRITE_REQ = 0x16; +const ATT_OP_PREPARE_WRITE_RESP = 0x17; +const ATT_OP_EXECUTE_WRITE_REQ = 0x18; +const ATT_OP_EXECUTE_WRITE_RESP = 0x19; +const ATT_OP_HANDLE_NOTIFY = 0x1b; +const ATT_OP_HANDLE_IND = 0x1d; +const ATT_OP_HANDLE_CNF = 0x1e; +const ATT_OP_WRITE_CMD = 0x52; + +const ATT_ECODE_SUCCESS = 0x00; +const ATT_ECODE_INVALID_HANDLE = 0x01; +const ATT_ECODE_READ_NOT_PERM = 0x02; +const ATT_ECODE_WRITE_NOT_PERM = 0x03; +const ATT_ECODE_INVALID_PDU = 0x04; +const ATT_ECODE_AUTHENTICATION = 0x05; +const ATT_ECODE_REQ_NOT_SUPP = 0x06; +const ATT_ECODE_INVALID_OFFSET = 0x07; +const ATT_ECODE_AUTHORIZATION = 0x08; +const ATT_ECODE_PREP_QUEUE_FULL = 0x09; +const ATT_ECODE_ATTR_NOT_FOUND = 0x0a; +const ATT_ECODE_ATTR_NOT_LONG = 0x0b; +const ATT_ECODE_INSUFF_ENCR_KEY_SIZE = 0x0c; +const ATT_ECODE_INVAL_ATTR_VALUE_LEN = 0x0d; +const ATT_ECODE_UNLIKELY = 0x0e; +const ATT_ECODE_INSUFF_ENC = 0x0f; +const ATT_ECODE_UNSUPP_GRP_TYPE = 0x10; +const ATT_ECODE_INSUFF_RESOURCES = 0x11; + +const GATT_PRIM_SVC_UUID = 0x2800; +const GATT_INCLUDE_UUID = 0x2802; +const GATT_CHARAC_UUID = 0x2803; + +const GATT_CLIENT_CHARAC_CFG_UUID = 0x2902; +const GATT_SERVER_CHARAC_CFG_UUID = 0x2903; + +const ATT_CID = 0x0004; /* eslint-enable no-unused-vars */ -var Gatt = function (address, aclStream) { +const Gatt = function (address, aclStream) { this._address = address; this._aclStream = aclStream; @@ -95,13 +95,13 @@ Gatt.prototype.onAclStreamData = function (cid, data) { if (process.env.NOBLE_MULTI_ROLE) { debug(this._address + ': multi-role flag in use, ignoring command meant for peripheral role.'); } else { - var requestType = data[0]; + const requestType = data[0]; debug(this._address + ': replying with REQ_NOT_SUPP to 0x' + requestType.toString(16)); this.writeAtt(this.errorResponse(requestType, 0x0000, ATT_ECODE_REQ_NOT_SUPP)); } } else if (data[0] === ATT_OP_HANDLE_NOTIFY || data[0] === ATT_OP_HANDLE_IND) { - var valueHandle = data.readUInt16LE(1); - var valueData = data.slice(3); + const valueHandle = data.readUInt16LE(1); + const valueData = data.slice(3); this.emit('handleNotify', this._address, valueHandle, valueData); @@ -111,8 +111,8 @@ Gatt.prototype.onAclStreamData = function (cid, data) { }); } - for (var serviceUuid in this._services) { - for (var characteristicUuid in this._characteristics[serviceUuid]) { + for (const serviceUuid in this._services) { + for (const characteristicUuid in this._characteristics[serviceUuid]) { if (this._characteristics[serviceUuid][characteristicUuid].valueHandle === valueHandle) { this.emit('notification', this._address, serviceUuid, characteristicUuid, valueData); } @@ -176,7 +176,7 @@ Gatt.prototype.writeAtt = function (data) { }; Gatt.prototype.errorResponse = function (opcode, handle, status) { - var buf = Buffer.alloc(5); + const buf = Buffer.alloc(5); buf.writeUInt8(ATT_OP_ERROR, 0); buf.writeUInt8(opcode, 1); @@ -211,7 +211,7 @@ Gatt.prototype._queueCommand = function (buffer, callback, writeCallback) { }; Gatt.prototype.mtuRequest = function (mtu) { - var buf = Buffer.alloc(3); + const buf = Buffer.alloc(3); buf.writeUInt8(ATT_OP_MTU_REQ, 0); buf.writeUInt16LE(mtu, 1); @@ -220,7 +220,7 @@ Gatt.prototype.mtuRequest = function (mtu) { }; Gatt.prototype.readByGroupRequest = function (startHandle, endHandle, groupUuid) { - var buf = Buffer.alloc(7); + const buf = Buffer.alloc(7); buf.writeUInt8(ATT_OP_READ_BY_GROUP_REQ, 0); buf.writeUInt16LE(startHandle, 1); @@ -231,7 +231,7 @@ Gatt.prototype.readByGroupRequest = function (startHandle, endHandle, groupUuid) }; Gatt.prototype.readByTypeRequest = function (startHandle, endHandle, groupUuid) { - var buf = Buffer.alloc(7); + const buf = Buffer.alloc(7); buf.writeUInt8(ATT_OP_READ_BY_TYPE_REQ, 0); buf.writeUInt16LE(startHandle, 1); @@ -242,7 +242,7 @@ Gatt.prototype.readByTypeRequest = function (startHandle, endHandle, groupUuid) }; Gatt.prototype.readRequest = function (handle) { - var buf = Buffer.alloc(3); + const buf = Buffer.alloc(3); buf.writeUInt8(ATT_OP_READ_REQ, 0); buf.writeUInt16LE(handle, 1); @@ -251,7 +251,7 @@ Gatt.prototype.readRequest = function (handle) { }; Gatt.prototype.readBlobRequest = function (handle, offset) { - var buf = Buffer.alloc(5); + const buf = Buffer.alloc(5); buf.writeUInt8(ATT_OP_READ_BLOB_REQ, 0); buf.writeUInt16LE(handle, 1); @@ -261,7 +261,7 @@ Gatt.prototype.readBlobRequest = function (handle, offset) { }; Gatt.prototype.findInfoRequest = function (startHandle, endHandle) { - var buf = Buffer.alloc(5); + const buf = Buffer.alloc(5); buf.writeUInt8(ATT_OP_FIND_INFO_REQ, 0); buf.writeUInt16LE(startHandle, 1); @@ -271,12 +271,12 @@ Gatt.prototype.findInfoRequest = function (startHandle, endHandle) { }; Gatt.prototype.writeRequest = function (handle, data, withoutResponse) { - var buf = Buffer.alloc(3 + data.length); + const buf = Buffer.alloc(3 + data.length); buf.writeUInt8(withoutResponse ? ATT_OP_WRITE_CMD : ATT_OP_WRITE_REQ, 0); buf.writeUInt16LE(handle, 1); - for (var i = 0; i < data.length; i++) { + for (let i = 0; i < data.length; i++) { buf.writeUInt8(data.readUInt8(i), i + 3); } @@ -284,13 +284,13 @@ Gatt.prototype.writeRequest = function (handle, data, withoutResponse) { }; Gatt.prototype.prepareWriteRequest = function (handle, offset, data) { - var buf = Buffer.alloc(5 + data.length); + const buf = Buffer.alloc(5 + data.length); buf.writeUInt8(ATT_OP_PREPARE_WRITE_REQ, 0); buf.writeUInt16LE(handle, 1); buf.writeUInt16LE(offset, 3); - for (var i = 0; i < data.length; i++) { + for (let i = 0; i < data.length; i++) { buf.writeUInt8(data.readUInt8(i), i + 5); } @@ -298,7 +298,7 @@ Gatt.prototype.prepareWriteRequest = function (handle, offset, data) { }; Gatt.prototype.executeWriteRequest = function (handle, cancelPreparedWrites) { - var buf = Buffer.alloc(2); + const buf = Buffer.alloc(2); buf.writeUInt8(ATT_OP_EXECUTE_WRITE_REQ, 0); buf.writeUInt8(cancelPreparedWrites ? 0 : 1, 1); @@ -307,7 +307,7 @@ Gatt.prototype.executeWriteRequest = function (handle, cancelPreparedWrites) { }; Gatt.prototype.handleConfirmation = function () { - var buf = Buffer.alloc(1); + const buf = Buffer.alloc(1); buf.writeUInt8(ATT_OP_HANDLE_CNF, 0); @@ -316,10 +316,10 @@ Gatt.prototype.handleConfirmation = function () { Gatt.prototype.exchangeMtu = function (mtu) { this._queueCommand(this.mtuRequest(mtu), (data) => { - var opcode = data[0]; + const opcode = data[0]; if (opcode === ATT_OP_MTU_RESP) { - var newMtu = data.readUInt16LE(1); + const newMtu = data.readUInt16LE(1); debug(this._address + ': new MTU is ' + newMtu); @@ -335,15 +335,15 @@ Gatt.prototype.addService = function (service) { }; Gatt.prototype.discoverServices = function (uuids) { - var services = []; + const services = []; - var callback = (data) => { - var opcode = data[0]; - var i = 0; + const callback = (data) => { + const opcode = data[0]; + let i = 0; if (opcode === ATT_OP_READ_BY_GROUP_RESP) { - var type = data[1]; - var num = (data.length - 2) / type; + const type = data[1]; + const num = (data.length - 2) / type; for (i = 0; i < num; i++) { const offset = 2 + i * type; @@ -356,7 +356,7 @@ Gatt.prototype.discoverServices = function (uuids) { } if (opcode !== ATT_OP_READ_BY_GROUP_RESP || services[services.length - 1].endHandle === 0xffff) { - var serviceUuids = []; + const serviceUuids = []; for (i = 0; i < services.length; i++) { if (uuids.length === 0 || uuids.indexOf(services[i].uuid) !== -1) { serviceUuids.push(services[i].uuid); @@ -375,16 +375,16 @@ Gatt.prototype.discoverServices = function (uuids) { }; Gatt.prototype.discoverIncludedServices = function (serviceUuid, uuids) { - var service = this._services[serviceUuid]; - var includedServices = []; + const service = this._services[serviceUuid]; + const includedServices = []; - var callback = (data) => { - var opcode = data[0]; - var i = 0; + const callback = (data) => { + const opcode = data[0]; + let i = 0; if (opcode === ATT_OP_READ_BY_TYPE_RESP) { - var type = data[1]; - var num = (data.length - 2) / type; + const type = data[1]; + const num = (data.length - 2) / type; for (i = 0; i < num; i++) { const offset = 2 + i * type; @@ -397,7 +397,7 @@ Gatt.prototype.discoverIncludedServices = function (serviceUuid, uuids) { } if (opcode !== ATT_OP_READ_BY_TYPE_RESP || includedServices[includedServices.length - 1].endHandle === service.endHandle) { - var includedServiceUuids = []; + const includedServiceUuids = []; for (i = 0; i < includedServices.length; i++) { if (uuids.length === 0 || uuids.indexOf(includedServices[i].uuid) !== -1) { @@ -418,25 +418,25 @@ Gatt.prototype.addCharacteristics = function (serviceUuid, characteristics) { this._characteristics[serviceUuid] = this._characteristics[serviceUuid] || {}; this._descriptors[serviceUuid] = this._descriptors[serviceUuid] || {}; - for (var i = 0; i < characteristics.length; i++) { + for (let i = 0; i < characteristics.length; i++) { this._characteristics[serviceUuid][characteristics[i].uuid] = characteristics[i]; } }; Gatt.prototype.discoverCharacteristics = function (serviceUuid, characteristicUuids) { - var service = this._services[serviceUuid]; - var characteristics = []; + const service = this._services[serviceUuid]; + const characteristics = []; this._characteristics[serviceUuid] = this._characteristics[serviceUuid] || {}; this._descriptors[serviceUuid] = this._descriptors[serviceUuid] || {}; - var callback = (data) => { - var opcode = data[0]; - var i = 0; + const callback = (data) => { + const opcode = data[0]; + let i = 0; if (opcode === ATT_OP_READ_BY_TYPE_RESP) { - var type = data[1]; - var num = (data.length - 2) / type; + const type = data[1]; + const num = (data.length - 2) / type; for (i = 0; i < num; i++) { const offset = 2 + i * type; @@ -450,11 +450,11 @@ Gatt.prototype.discoverCharacteristics = function (serviceUuid, characteristicUu } if (opcode !== ATT_OP_READ_BY_TYPE_RESP || characteristics[characteristics.length - 1].valueHandle === service.endHandle) { - var characteristicsDiscovered = []; + const characteristicsDiscovered = []; for (i = 0; i < characteristics.length; i++) { var properties = characteristics[i].properties; - var characteristic = { + const characteristic = { properties: [], uuid: characteristics[i].uuid }; @@ -521,12 +521,12 @@ Gatt.prototype.discoverCharacteristics = function (serviceUuid, characteristicUu }; Gatt.prototype.read = function (serviceUuid, characteristicUuid) { - var characteristic = this._characteristics[serviceUuid][characteristicUuid]; + const characteristic = this._characteristics[serviceUuid][characteristicUuid]; - var readData = Buffer.alloc(0); + let readData = Buffer.alloc(0); - var callback = (data) => { - var opcode = data[0]; + const callback = (data) => { + const opcode = data[0]; if (opcode === ATT_OP_READ_RESP || opcode === ATT_OP_READ_BLOB_RESP) { readData = Buffer.from(readData.toString('hex') + data.slice(1).toString('hex'), 'hex'); @@ -545,7 +545,7 @@ Gatt.prototype.read = function (serviceUuid, characteristicUuid) { }; Gatt.prototype.write = function (serviceUuid, characteristicUuid, data, withoutResponse) { - var characteristic = this._characteristics[serviceUuid][characteristicUuid]; + const characteristic = this._characteristics[serviceUuid][characteristicUuid]; if (withoutResponse) { this._queueCommand(this.writeRequest(characteristic.valueHandle, data, true), null, () => { @@ -555,7 +555,7 @@ Gatt.prototype.write = function (serviceUuid, characteristicUuid, data, withoutR return this.longWrite(serviceUuid, characteristicUuid, data, withoutResponse); } else { this._queueCommand(this.writeRequest(characteristic.valueHandle, data, false), data => { - var opcode = data[0]; + const opcode = data[0]; if (opcode === ATT_OP_WRITE_RESP) { this.emit('write', this._address, serviceUuid, characteristicUuid); @@ -566,17 +566,17 @@ Gatt.prototype.write = function (serviceUuid, characteristicUuid, data, withoutR /* Perform a "long write" as described Bluetooth Spec section 4.9.4 "Write Long Characteristic Values" */ Gatt.prototype.longWrite = function (serviceUuid, characteristicUuid, data, withoutResponse) { - var characteristic = this._characteristics[serviceUuid][characteristicUuid]; - var limit = this._mtu - 5; + const characteristic = this._characteristics[serviceUuid][characteristicUuid]; + const limit = this._mtu - 5; - var prepareWriteCallback = (dataChunk) => { + const prepareWriteCallback = (dataChunk) => { return (resp) => { - var opcode = resp[0]; + const opcode = resp[0]; if (opcode !== ATT_OP_PREPARE_WRITE_RESP) { debug(this._address + ': unexpected reply opcode %d (expecting ATT_OP_PREPARE_WRITE_RESP)', opcode); } else { - var expectedLength = dataChunk.length + 5; + const expectedLength = dataChunk.length + 5; if (resp.length !== expectedLength) { /* the response should contain the data packet echoed back to the caller */ @@ -587,18 +587,18 @@ Gatt.prototype.longWrite = function (serviceUuid, characteristicUuid, data, with }; /* split into prepare-write chunks and queue them */ - var offset = 0; + let offset = 0; while (offset < data.length) { - var end = offset + limit; - var chunk = data.slice(offset, end); + const end = offset + limit; + const chunk = data.slice(offset, end); this._queueCommand(this.prepareWriteRequest(characteristic.valueHandle, offset, chunk), prepareWriteCallback(chunk)); offset = end; } /* queue the execute command with a callback to emit the write signal when done */ this._queueCommand(this.executeWriteRequest(characteristic.valueHandle), resp => { - var opcode = resp[0]; + const opcode = resp[0]; if (opcode === ATT_OP_EXECUTE_WRITE_RESP && !withoutResponse) { this.emit('write', this._address, serviceUuid, characteristicUuid); @@ -607,13 +607,13 @@ Gatt.prototype.longWrite = function (serviceUuid, characteristicUuid, data, with }; Gatt.prototype.broadcast = function (serviceUuid, characteristicUuid, broadcast) { - var characteristic = this._characteristics[serviceUuid][characteristicUuid]; + const characteristic = this._characteristics[serviceUuid][characteristicUuid]; this._queueCommand(this.readByTypeRequest(characteristic.startHandle, characteristic.endHandle, GATT_SERVER_CHARAC_CFG_UUID), data => { - var opcode = data[0]; + const opcode = data[0]; if (opcode === ATT_OP_READ_BY_TYPE_RESP) { - var handle = data.readUInt16LE(2); - var value = data.readUInt16LE(4); + const handle = data.readUInt16LE(2); + let value = data.readUInt16LE(4); if (broadcast) { value |= 0x0001; @@ -621,11 +621,11 @@ Gatt.prototype.broadcast = function (serviceUuid, characteristicUuid, broadcast) value &= 0xfffe; } - var valueBuffer = Buffer.alloc(2); + const valueBuffer = Buffer.alloc(2); valueBuffer.writeUInt16LE(value, 0); this._queueCommand(this.writeRequest(handle, valueBuffer, false), data => { - var opcode = data[0]; + const opcode = data[0]; if (opcode === ATT_OP_WRITE_RESP) { this.emit('broadcast', this._address, serviceUuid, characteristicUuid, broadcast); @@ -636,16 +636,16 @@ Gatt.prototype.broadcast = function (serviceUuid, characteristicUuid, broadcast) }; Gatt.prototype.notify = function (serviceUuid, characteristicUuid, notify) { - var characteristic = this._characteristics[serviceUuid][characteristicUuid]; + const characteristic = this._characteristics[serviceUuid][characteristicUuid]; this._queueCommand(this.readByTypeRequest(characteristic.startHandle, characteristic.endHandle, GATT_CLIENT_CHARAC_CFG_UUID), data => { - var opcode = data[0]; + const opcode = data[0]; if (opcode === ATT_OP_READ_BY_TYPE_RESP) { - var handle = data.readUInt16LE(2); - var value = data.readUInt16LE(4); + const handle = data.readUInt16LE(2); + let value = data.readUInt16LE(4); - var useNotify = characteristic.properties & 0x10; - var useIndicate = characteristic.properties & 0x20; + const useNotify = characteristic.properties & 0x10; + const useIndicate = characteristic.properties & 0x20; if (notify) { if (useNotify) { @@ -661,11 +661,11 @@ Gatt.prototype.notify = function (serviceUuid, characteristicUuid, notify) { } } - var valueBuffer = Buffer.alloc(2); + const valueBuffer = Buffer.alloc(2); valueBuffer.writeUInt16LE(value, 0); this._queueCommand(this.writeRequest(handle, valueBuffer, false), data => { - var opcode = data[0]; + const opcode = data[0]; if (opcode === ATT_OP_WRITE_RESP) { this.emit('notify', this._address, serviceUuid, characteristicUuid, notify); @@ -687,17 +687,17 @@ function reverse (src) { } Gatt.prototype.discoverDescriptors = function (serviceUuid, characteristicUuid) { - var characteristic = this._characteristics[serviceUuid][characteristicUuid]; - var descriptors = []; + const characteristic = this._characteristics[serviceUuid][characteristicUuid]; + const descriptors = []; this._descriptors[serviceUuid][characteristicUuid] = {}; - var callback = data => { - var opcode = data[0]; + const callback = data => { + const opcode = data[0]; if (opcode === ATT_OP_FIND_INFO_RESP) { - var format = data[1]; - var pos = 2; // skip first 2 bytes (opcode, format) + const format = data[1]; + const pos = 2; // skip first 2 bytes (opcode, format) while( data.length > pos ) { @@ -722,7 +722,7 @@ Gatt.prototype.discoverDescriptors = function (serviceUuid, characteristicUuid) } if (opcode !== ATT_OP_FIND_INFO_RESP || descriptors[descriptors.length - 1].handle === characteristic.endHandle) { - var descriptorUuids = []; + const descriptorUuids = []; for (i = 0; i < descriptors.length; i++) { descriptorUuids.push(descriptors[i].uuid); @@ -739,12 +739,12 @@ Gatt.prototype.discoverDescriptors = function (serviceUuid, characteristicUuid) }; Gatt.prototype.readValue = function (serviceUuid, characteristicUuid, descriptorUuid) { - var descriptor = this._descriptors[serviceUuid][characteristicUuid][descriptorUuid]; + const descriptor = this._descriptors[serviceUuid][characteristicUuid][descriptorUuid]; var readData = new Buffer(0); this._queueCommand(this.readRequest(descriptor.handle), data => { - var opcode = data[0]; + const opcode = data[0]; if (opcode === ATT_OP_READ_RESP || opcode === ATT_OP_READ_BLOB_RESP) { var totalLength = readData.length + data.length - 1; @@ -762,10 +762,10 @@ Gatt.prototype.readValue = function (serviceUuid, characteristicUuid, descriptor }; Gatt.prototype.writeValue = function (serviceUuid, characteristicUuid, descriptorUuid, data) { - var descriptor = this._descriptors[serviceUuid][characteristicUuid][descriptorUuid]; + const descriptor = this._descriptors[serviceUuid][characteristicUuid][descriptorUuid]; this._queueCommand(this.writeRequest(descriptor.handle, data, false), data => { - var opcode = data[0]; + const opcode = data[0]; if (opcode === ATT_OP_WRITE_RESP) { this.emit('valueWrite', this._address, serviceUuid, characteristicUuid, descriptorUuid); @@ -775,7 +775,7 @@ Gatt.prototype.writeValue = function (serviceUuid, characteristicUuid, descripto Gatt.prototype.readHandle = function (handle) { this._queueCommand(this.readRequest(handle), data => { - var opcode = data[0]; + const opcode = data[0]; if (opcode === ATT_OP_READ_RESP) { this.emit('handleRead', this._address, handle, data.slice(1)); @@ -790,7 +790,7 @@ Gatt.prototype.writeHandle = function (handle, data, withoutResponse) { }); } else { this._queueCommand(this.writeRequest(handle, data, false), data => { - var opcode = data[0]; + const opcode = data[0]; if (opcode === ATT_OP_WRITE_RESP) { this.emit('handleWrite', this._address, handle); diff --git a/lib/hci-socket/hci.js b/lib/hci-socket/hci.js index 3dcdc1912..ed95b622b 100644 --- a/lib/hci-socket/hci.js +++ b/lib/hci-socket/hci.js @@ -1,78 +1,78 @@ -var debug = require('debug')('hci'); +const debug = require('debug')('hci'); -var events = require('events'); -var util = require('util'); +const events = require('events'); +const util = require('util'); -var BluetoothHciSocket = require('@abandonware/bluetooth-hci-socket'); +const BluetoothHciSocket = require('@abandonware/bluetooth-hci-socket'); -var HCI_COMMAND_PKT = 0x01; -var HCI_ACLDATA_PKT = 0x02; -var HCI_EVENT_PKT = 0x04; +const HCI_COMMAND_PKT = 0x01; +const HCI_ACLDATA_PKT = 0x02; +const HCI_EVENT_PKT = 0x04; -var ACL_START_NO_FLUSH = 0x00; -var ACL_CONT = 0x01; -var ACL_START = 0x02; +const ACL_START_NO_FLUSH = 0x00; +const ACL_CONT = 0x01; +const ACL_START = 0x02; -var EVT_DISCONN_COMPLETE = 0x05; -var EVT_ENCRYPT_CHANGE = 0x08; -var EVT_CMD_COMPLETE = 0x0e; -var EVT_CMD_STATUS = 0x0f; -var EVT_LE_META_EVENT = 0x3e; +const EVT_DISCONN_COMPLETE = 0x05; +const EVT_ENCRYPT_CHANGE = 0x08; +const EVT_CMD_COMPLETE = 0x0e; +const EVT_CMD_STATUS = 0x0f; +const EVT_LE_META_EVENT = 0x3e; -var EVT_LE_CONN_COMPLETE = 0x01; -var EVT_LE_ADVERTISING_REPORT = 0x02; -var EVT_LE_CONN_UPDATE_COMPLETE = 0x03; +const EVT_LE_CONN_COMPLETE = 0x01; +const EVT_LE_ADVERTISING_REPORT = 0x02; +const EVT_LE_CONN_UPDATE_COMPLETE = 0x03; -var OGF_LINK_CTL = 0x01; -var OCF_DISCONNECT = 0x0006; +const OGF_LINK_CTL = 0x01; +const OCF_DISCONNECT = 0x0006; -var OGF_HOST_CTL = 0x03; -var OCF_SET_EVENT_MASK = 0x0001; -var OCF_RESET = 0x0003; -var OCF_READ_LE_HOST_SUPPORTED = 0x006C; -var OCF_WRITE_LE_HOST_SUPPORTED = 0x006D; +const OGF_HOST_CTL = 0x03; +const OCF_SET_EVENT_MASK = 0x0001; +const OCF_RESET = 0x0003; +const OCF_READ_LE_HOST_SUPPORTED = 0x006C; +const OCF_WRITE_LE_HOST_SUPPORTED = 0x006D; -var OGF_INFO_PARAM = 0x04; -var OCF_READ_LOCAL_VERSION = 0x0001; -var OCF_READ_BD_ADDR = 0x0009; +const OGF_INFO_PARAM = 0x04; +const OCF_READ_LOCAL_VERSION = 0x0001; +const OCF_READ_BD_ADDR = 0x0009; -var OGF_STATUS_PARAM = 0x05; -var OCF_READ_RSSI = 0x0005; +const OGF_STATUS_PARAM = 0x05; +const OCF_READ_RSSI = 0x0005; -var OGF_LE_CTL = 0x08; -var OCF_LE_SET_EVENT_MASK = 0x0001; -var OCF_LE_SET_SCAN_PARAMETERS = 0x000b; -var OCF_LE_SET_SCAN_ENABLE = 0x000c; -var OCF_LE_CREATE_CONN = 0x000d; -var OCF_LE_CANCEL_CONN = 0x000e; -var OCF_LE_CONN_UPDATE = 0x0013; -var OCF_LE_START_ENCRYPTION = 0x0019; +const OGF_LE_CTL = 0x08; +const OCF_LE_SET_EVENT_MASK = 0x0001; +const OCF_LE_SET_SCAN_PARAMETERS = 0x000b; +const OCF_LE_SET_SCAN_ENABLE = 0x000c; +const OCF_LE_CREATE_CONN = 0x000d; +const OCF_LE_CANCEL_CONN = 0x000e; +const OCF_LE_CONN_UPDATE = 0x0013; +const OCF_LE_START_ENCRYPTION = 0x0019; -var DISCONNECT_CMD = OCF_DISCONNECT | OGF_LINK_CTL << 10; +const DISCONNECT_CMD = OCF_DISCONNECT | OGF_LINK_CTL << 10; -var SET_EVENT_MASK_CMD = OCF_SET_EVENT_MASK | OGF_HOST_CTL << 10; -var RESET_CMD = OCF_RESET | OGF_HOST_CTL << 10; -var READ_LE_HOST_SUPPORTED_CMD = OCF_READ_LE_HOST_SUPPORTED | OGF_HOST_CTL << 10; -var WRITE_LE_HOST_SUPPORTED_CMD = OCF_WRITE_LE_HOST_SUPPORTED | OGF_HOST_CTL << 10; +const SET_EVENT_MASK_CMD = OCF_SET_EVENT_MASK | OGF_HOST_CTL << 10; +const RESET_CMD = OCF_RESET | OGF_HOST_CTL << 10; +const READ_LE_HOST_SUPPORTED_CMD = OCF_READ_LE_HOST_SUPPORTED | OGF_HOST_CTL << 10; +const WRITE_LE_HOST_SUPPORTED_CMD = OCF_WRITE_LE_HOST_SUPPORTED | OGF_HOST_CTL << 10; -var READ_LOCAL_VERSION_CMD = OCF_READ_LOCAL_VERSION | (OGF_INFO_PARAM << 10); -var READ_BD_ADDR_CMD = OCF_READ_BD_ADDR | (OGF_INFO_PARAM << 10); +const READ_LOCAL_VERSION_CMD = OCF_READ_LOCAL_VERSION | (OGF_INFO_PARAM << 10); +const READ_BD_ADDR_CMD = OCF_READ_BD_ADDR | (OGF_INFO_PARAM << 10); -var READ_RSSI_CMD = OCF_READ_RSSI | OGF_STATUS_PARAM << 10; +const READ_RSSI_CMD = OCF_READ_RSSI | OGF_STATUS_PARAM << 10; -var LE_SET_EVENT_MASK_CMD = OCF_LE_SET_EVENT_MASK | OGF_LE_CTL << 10; -var LE_SET_SCAN_PARAMETERS_CMD = OCF_LE_SET_SCAN_PARAMETERS | OGF_LE_CTL << 10; -var LE_SET_SCAN_ENABLE_CMD = OCF_LE_SET_SCAN_ENABLE | OGF_LE_CTL << 10; -var LE_CREATE_CONN_CMD = OCF_LE_CREATE_CONN | OGF_LE_CTL << 10; -var LE_CONN_UPDATE_CMD = OCF_LE_CONN_UPDATE | OGF_LE_CTL << 10; -var LE_CANCEL_CONN_CMD = OCF_LE_CANCEL_CONN | OGF_LE_CTL << 10; -var LE_START_ENCRYPTION_CMD = OCF_LE_START_ENCRYPTION | OGF_LE_CTL << 10; +const LE_SET_EVENT_MASK_CMD = OCF_LE_SET_EVENT_MASK | OGF_LE_CTL << 10; +const LE_SET_SCAN_PARAMETERS_CMD = OCF_LE_SET_SCAN_PARAMETERS | OGF_LE_CTL << 10; +const LE_SET_SCAN_ENABLE_CMD = OCF_LE_SET_SCAN_ENABLE | OGF_LE_CTL << 10; +const LE_CREATE_CONN_CMD = OCF_LE_CREATE_CONN | OGF_LE_CTL << 10; +const LE_CONN_UPDATE_CMD = OCF_LE_CONN_UPDATE | OGF_LE_CTL << 10; +const LE_CANCEL_CONN_CMD = OCF_LE_CANCEL_CONN | OGF_LE_CTL << 10; +const LE_START_ENCRYPTION_CMD = OCF_LE_START_ENCRYPTION | OGF_LE_CTL << 10; -var HCI_OE_USER_ENDED_CONNECTION = 0x13; +const HCI_OE_USER_ENDED_CONNECTION = 0x13; -var STATUS_MAPPER = require('./hci-status'); +const STATUS_MAPPER = require('./hci-status'); -var Hci = function (options) { +const Hci = function (options) { options = options || {}; this._socket = new BluetoothHciSocket(); this._isDevUp = null; @@ -111,7 +111,7 @@ Hci.prototype.init = function (options) { }; Hci.prototype.pollIsDevUp = function () { - var isDevUp = this._socket.isDevUp(); + const isDevUp = this._socket.isDevUp(); if (this._isDevUp !== isDevUp) { if (isDevUp) { @@ -133,11 +133,11 @@ Hci.prototype.pollIsDevUp = function () { }; Hci.prototype.setSocketFilter = function () { - var filter = Buffer.alloc(14); - var typeMask = (1 << HCI_COMMAND_PKT) | (1 << HCI_EVENT_PKT) | (1 << HCI_ACLDATA_PKT); - var eventMask1 = (1 << EVT_DISCONN_COMPLETE) | (1 << EVT_ENCRYPT_CHANGE) | (1 << EVT_CMD_COMPLETE) | (1 << EVT_CMD_STATUS); - var eventMask2 = (1 << (EVT_LE_META_EVENT - 32)); - var opcode = 0; + const filter = Buffer.alloc(14); + const typeMask = (1 << HCI_COMMAND_PKT) | (1 << HCI_EVENT_PKT) | (1 << HCI_ACLDATA_PKT); + const eventMask1 = (1 << EVT_DISCONN_COMPLETE) | (1 << EVT_ENCRYPT_CHANGE) | (1 << EVT_CMD_COMPLETE) | (1 << EVT_CMD_STATUS); + const eventMask2 = (1 << (EVT_LE_META_EVENT - 32)); + const opcode = 0; filter.writeUInt32LE(typeMask, 0); filter.writeUInt32LE(eventMask1, 4); @@ -149,8 +149,8 @@ Hci.prototype.setSocketFilter = function () { }; Hci.prototype.setEventMask = function () { - var cmd = Buffer.alloc(12); - var eventMask = Buffer.from('fffffbff07f8bf3d', 'hex'); + const cmd = Buffer.alloc(12); + const eventMask = Buffer.from('fffffbff07f8bf3d', 'hex'); // header cmd.writeUInt8(HCI_COMMAND_PKT, 0); @@ -166,7 +166,7 @@ Hci.prototype.setEventMask = function () { }; Hci.prototype.reset = function () { - var cmd = Buffer.alloc(4); + const cmd = Buffer.alloc(4); // header cmd.writeUInt8(HCI_COMMAND_PKT, 0); @@ -180,7 +180,7 @@ Hci.prototype.reset = function () { }; Hci.prototype.readLocalVersion = function () { - var cmd = Buffer.alloc(4); + const cmd = Buffer.alloc(4); // header cmd.writeUInt8(HCI_COMMAND_PKT, 0); @@ -194,7 +194,7 @@ Hci.prototype.readLocalVersion = function () { }; Hci.prototype.readBdAddr = function () { - var cmd = Buffer.alloc(4); + const cmd = Buffer.alloc(4); // header cmd.writeUInt8(HCI_COMMAND_PKT, 0); @@ -208,8 +208,8 @@ Hci.prototype.readBdAddr = function () { }; Hci.prototype.setLeEventMask = function () { - var cmd = Buffer.alloc(12); - var leEventMask = Buffer.from('1f00000000000000', 'hex'); + const cmd = Buffer.alloc(12); + const leEventMask = Buffer.from('1f00000000000000', 'hex'); // header cmd.writeUInt8(HCI_COMMAND_PKT, 0); @@ -225,7 +225,7 @@ Hci.prototype.setLeEventMask = function () { }; Hci.prototype.readLeHostSupported = function () { - var cmd = Buffer.alloc(4); + const cmd = Buffer.alloc(4); // header cmd.writeUInt8(HCI_COMMAND_PKT, 0); @@ -239,7 +239,7 @@ Hci.prototype.readLeHostSupported = function () { }; Hci.prototype.writeLeHostSupported = function () { - var cmd = Buffer.alloc(6); + const cmd = Buffer.alloc(6); // header cmd.writeUInt8(HCI_COMMAND_PKT, 0); @@ -260,7 +260,7 @@ Hci.prototype.setScanParameters = function (interval, window) { interval = interval || 0x0010; window = window || 0x0010; - var cmd = Buffer.alloc(11); + const cmd = Buffer.alloc(11); // header cmd.writeUInt8(HCI_COMMAND_PKT, 0); @@ -281,7 +281,7 @@ Hci.prototype.setScanParameters = function (interval, window) { }; Hci.prototype.setScanEnabled = function (enabled, filterDuplicates) { - var cmd = Buffer.alloc(6); + const cmd = Buffer.alloc(6); // header cmd.writeUInt8(HCI_COMMAND_PKT, 0); @@ -299,12 +299,12 @@ Hci.prototype.setScanEnabled = function (enabled, filterDuplicates) { }; Hci.prototype.createLeConn = function (address, addressType, parameters) { - var minInterval = parameters && parameters.minInterval || 0x0006; - var maxInterval = parameters && parameters.maxInterval || 0x000c; - var latency = parameters && parameters.latency || 0x0000; - var timeout = parameters && parameters.timeout || 0x00c8; + const minInterval = parameters && parameters.minInterval || 0x0006; + const maxInterval = parameters && parameters.maxInterval || 0x000c; + const latency = parameters && parameters.latency || 0x0000; + const timeout = parameters && parameters.timeout || 0x00c8; - var cmd = Buffer.alloc(29); + const cmd = Buffer.alloc(29); // header cmd.writeUInt8(HCI_COMMAND_PKT, 0); @@ -335,7 +335,7 @@ Hci.prototype.createLeConn = function (address, addressType, parameters) { }; Hci.prototype.connUpdateLe = function (handle, minInterval, maxInterval, latency, supervisionTimeout) { - var cmd = Buffer.alloc(18); + const cmd = Buffer.alloc(18); // header cmd.writeUInt8(HCI_COMMAND_PKT, 0); @@ -372,7 +372,7 @@ Hci.prototype.cancelConnect = function () { }; Hci.prototype.startLeEncryption = function (handle, random, diversifier, key) { - var cmd = Buffer.alloc(32); + const cmd = Buffer.alloc(32); // header cmd.writeUInt8(HCI_COMMAND_PKT, 0); @@ -392,7 +392,7 @@ Hci.prototype.startLeEncryption = function (handle, random, diversifier, key) { }; Hci.prototype.disconnect = function (handle, reason) { - var cmd = Buffer.alloc(7); + const cmd = Buffer.alloc(7); reason = reason || HCI_OE_USER_ENDED_CONNECTION; @@ -412,7 +412,7 @@ Hci.prototype.disconnect = function (handle, reason) { }; Hci.prototype.readRssi = function (handle) { - var cmd = Buffer.alloc(6); + const cmd = Buffer.alloc(6); // header cmd.writeUInt8(HCI_COMMAND_PKT, 0); @@ -429,7 +429,7 @@ Hci.prototype.readRssi = function (handle) { }; Hci.prototype.writeAclDataPkt = function (handle, cid, data) { - var pkt = Buffer.alloc(9 + data.length); + const pkt = Buffer.alloc(9 + data.length); // header pkt.writeUInt8(HCI_ACLDATA_PKT, 0); @@ -447,21 +447,21 @@ Hci.prototype.writeAclDataPkt = function (handle, cid, data) { Hci.prototype.onSocketData = function (data) { debug('onSocketData: ' + data.toString('hex')); - var eventType = data.readUInt8(0); - var handle; - var cmd; - var status; + const eventType = data.readUInt8(0); + let handle; + let cmd; + let status; debug('\tevent type = ' + eventType); if (HCI_EVENT_PKT === eventType) { - var subEventType = data.readUInt8(1); + const subEventType = data.readUInt8(1); debug('\tsub event type = ' + subEventType); if (subEventType === EVT_DISCONN_COMPLETE) { handle = data.readUInt16LE(4); - var reason = data.readUInt8(6); + const reason = data.readUInt8(6); debug('\t\thandle = ' + handle); debug('\t\treason = ' + reason); @@ -469,7 +469,7 @@ Hci.prototype.onSocketData = function (data) { this.emit('disconnComplete', handle, reason); } else if (subEventType === EVT_ENCRYPT_CHANGE) { handle = data.readUInt16LE(4); - var encrypt = data.readUInt8(6); + const encrypt = data.readUInt8(6); debug('\t\thandle = ' + handle); debug('\t\tencrypt = ' + encrypt); @@ -478,7 +478,7 @@ Hci.prototype.onSocketData = function (data) { } else if (subEventType === EVT_CMD_COMPLETE) { cmd = data.readUInt16LE(4); status = data.readUInt8(6); - var result = data.slice(7); + const result = data.slice(7); debug('\t\tcmd = ' + cmd); debug('\t\tstatus = ' + status); @@ -494,9 +494,9 @@ Hci.prototype.onSocketData = function (data) { this.processCmdStatusEvent(cmd, status); } else if (subEventType === EVT_LE_META_EVENT) { - var leMetaEventType = data.readUInt8(3); - var leMetaEventStatus = data.readUInt8(4); - var leMetaEventData = data.slice(5); + const leMetaEventType = data.readUInt8(3); + const leMetaEventStatus = data.readUInt8(4); + const leMetaEventData = data.slice(5); debug('\t\tLE meta event type = ' + leMetaEventType); debug('\t\tLE meta event status = ' + leMetaEventStatus); @@ -505,14 +505,14 @@ Hci.prototype.onSocketData = function (data) { this.processLeMetaEvent(leMetaEventType, leMetaEventStatus, leMetaEventData); } } else if (HCI_ACLDATA_PKT === eventType) { - var flags = data.readUInt16LE(1) >> 12; + const flags = data.readUInt16LE(1) >> 12; handle = data.readUInt16LE(1) & 0x0fff; if (ACL_START === flags) { var cid = data.readUInt16LE(7); var length = data.readUInt16LE(5); - var pktData = data.slice(9); + const pktData = data.slice(9); debug('\t\tcid = ' + cid); @@ -546,14 +546,14 @@ Hci.prototype.onSocketData = function (data) { } } else if (HCI_COMMAND_PKT === eventType) { cmd = data.readUInt16LE(1); - var len = data.readUInt8(3); + const len = data.readUInt8(3); debug('\t\tcmd = ' + cmd); debug('\t\tdata len = ' + len); if (cmd === LE_SET_SCAN_ENABLE_CMD) { - var enable = (data.readUInt8(4) === 0x1); - var filterDuplicates = (data.readUInt8(5) === 0x1); + const enable = (data.readUInt8(4) === 0x1); + const filterDuplicates = (data.readUInt8(5) === 0x1); debug('\t\t\tLE enable scan command'); debug('\t\t\tenable scanning = ' + enable); @@ -582,18 +582,18 @@ Hci.prototype.processCmdCompleteEvent = function (cmd, status, result) { this.readBdAddr(); } else if (cmd === READ_LE_HOST_SUPPORTED_CMD) { if (status === 0) { - var le = result.readUInt8(0); - var simul = result.readUInt8(1); + const le = result.readUInt8(0); + const simul = result.readUInt8(1); debug('\t\t\tle = ' + le); debug('\t\t\tsimul = ' + simul); } } else if (cmd === READ_LOCAL_VERSION_CMD) { - var hciVer = result.readUInt8(0); - var hciRev = result.readUInt16LE(1); - var lmpVer = result.readInt8(3); - var manufacturer = result.readUInt16LE(4); - var lmpSubVer = result.readUInt16LE(6); + const hciVer = result.readUInt8(0); + const hciRev = result.readUInt16LE(1); + const lmpVer = result.readInt8(3); + const manufacturer = result.readUInt16LE(4); + const lmpSubVer = result.readUInt16LE(6); if (hciVer < 0x06) { this.emit('stateChange', 'unsupported'); @@ -617,8 +617,8 @@ Hci.prototype.processCmdCompleteEvent = function (cmd, status, result) { } else if (cmd === LE_SET_SCAN_ENABLE_CMD) { this.emit('leScanEnableSet', status); } else if (cmd === READ_RSSI_CMD) { - var handle = result.readUInt16LE(0); - var rssi = result.readInt8(2); + const handle = result.readUInt16LE(0); + const rssi = result.readInt8(2); debug('\t\t\thandle = ' + handle); debug('\t\t\trssi = ' + rssi); @@ -638,14 +638,14 @@ Hci.prototype.processLeMetaEvent = function (eventType, status, data) { }; Hci.prototype.processLeConnComplete = function (status, data) { - var handle = data.readUInt16LE(0); - var role = data.readUInt8(2); - var addressType = data.readUInt8(3) === 0x01 ? 'random' : 'public'; - var address = data.slice(4, 10).toString('hex').match(/.{1,2}/g).reverse().join(':'); - var interval = data.readUInt16LE(10) * 1.25; - var latency = data.readUInt16LE(12); // TODO: multiplier? - var supervisionTimeout = data.readUInt16LE(14) * 10; - var masterClockAccuracy = data.readUInt8(16); // TODO: multiplier? + const handle = data.readUInt16LE(0); + const role = data.readUInt8(2); + const addressType = data.readUInt8(3) === 0x01 ? 'random' : 'public'; + const address = data.slice(4, 10).toString('hex').match(/.{1,2}/g).reverse().join(':'); + const interval = data.readUInt16LE(10) * 1.25; + const latency = data.readUInt16LE(12); // TODO: multiplier? + const supervisionTimeout = data.readUInt16LE(14) * 10; + const masterClockAccuracy = data.readUInt8(16); // TODO: multiplier? debug('\t\t\thandle = ' + handle); debug('\t\t\trole = ' + role); @@ -661,13 +661,13 @@ Hci.prototype.processLeConnComplete = function (status, data) { Hci.prototype.processLeAdvertisingReport = function (count, data) { try { - for (var i = 0; i < count; i++) { - var type = data.readUInt8(0); - var addressType = data.readUInt8(1) === 0x01 ? 'random' : 'public'; - var address = data.slice(2, 8).toString('hex').match(/.{1,2}/g).reverse().join(':'); - var eirLength = data.readUInt8(8); - var eir = data.slice(9, eirLength + 9); - var rssi = data.readInt8(eirLength + 9); + for (let i = 0; i < count; i++) { + const type = data.readUInt8(0); + const addressType = data.readUInt8(1) === 0x01 ? 'random' : 'public'; + const address = data.slice(2, 8).toString('hex').match(/.{1,2}/g).reverse().join(':'); + const eirLength = data.readUInt8(8); + const eir = data.slice(9, eirLength + 9); + const rssi = data.readInt8(eirLength + 9); debug('\t\t\ttype = ' + type); debug('\t\t\taddress = ' + address); @@ -685,10 +685,10 @@ Hci.prototype.processLeAdvertisingReport = function (count, data) { }; Hci.prototype.processLeConnUpdateComplete = function (status, data) { - var handle = data.readUInt16LE(0); - var interval = data.readUInt16LE(2) * 1.25; - var latency = data.readUInt16LE(4); // TODO: multiplier? - var supervisionTimeout = data.readUInt16LE(6) * 10; + const handle = data.readUInt16LE(0); + const interval = data.readUInt16LE(2) * 1.25; + const latency = data.readUInt16LE(4); // TODO: multiplier? + const supervisionTimeout = data.readUInt16LE(6) * 10; debug('\t\t\thandle = ' + handle); debug('\t\t\tinterval = ' + interval); diff --git a/lib/hci-socket/signaling.js b/lib/hci-socket/signaling.js index f44728a4c..dc3d06c93 100644 --- a/lib/hci-socket/signaling.js +++ b/lib/hci-socket/signaling.js @@ -1,15 +1,15 @@ -var debug = require('debug')('signaling'); +const debug = require('debug')('signaling'); -var events = require('events'); -var os = require('os'); -var util = require('util'); +const events = require('events'); +const os = require('os'); +const util = require('util'); -var CONNECTION_PARAMETER_UPDATE_REQUEST = 0x12; -var CONNECTION_PARAMETER_UPDATE_RESPONSE = 0x13; +const CONNECTION_PARAMETER_UPDATE_REQUEST = 0x12; +const CONNECTION_PARAMETER_UPDATE_RESPONSE = 0x13; -var SIGNALING_CID = 0x0005; +const SIGNALING_CID = 0x0005; -var Signaling = function (handle, aclStream) { +const Signaling = function (handle, aclStream) { this._handle = handle; this._aclStream = aclStream; @@ -29,10 +29,10 @@ Signaling.prototype.onAclStreamData = function (cid, data) { debug('onAclStreamData: ' + data.toString('hex')); - var code = data.readUInt8(0); - var identifier = data.readUInt8(1); - var length = data.readUInt16LE(2); - var signalingData = data.slice(4); + const code = data.readUInt8(0); + const identifier = data.readUInt8(1); + const length = data.readUInt16LE(2); + const signalingData = data.slice(4); debug('\tcode = ' + code); debug('\tidentifier = ' + identifier); @@ -49,10 +49,10 @@ Signaling.prototype.onAclStreamEnd = function () { }; Signaling.prototype.processConnectionParameterUpdateRequest = function (identifier, data) { - var minInterval = data.readUInt16LE(0) * 1.25; - var maxInterval = data.readUInt16LE(2) * 1.25; - var latency = data.readUInt16LE(4); - var supervisionTimeout = data.readUInt16LE(6) * 10; + const minInterval = data.readUInt16LE(0) * 1.25; + const maxInterval = data.readUInt16LE(2) * 1.25; + const latency = data.readUInt16LE(4); + const supervisionTimeout = data.readUInt16LE(6) * 10; debug('\t\tmin interval = ', minInterval); debug('\t\tmax interval = ', maxInterval); @@ -60,7 +60,7 @@ Signaling.prototype.processConnectionParameterUpdateRequest = function (identifi debug('\t\tsupervision timeout = ', supervisionTimeout); if (os.platform() !== 'linux' || process.env.HCI_CHANNEL_USER) { - var response = Buffer.alloc(6); + const response = Buffer.alloc(6); response.writeUInt8(CONNECTION_PARAMETER_UPDATE_RESPONSE, 0); // code response.writeUInt8(identifier, 1); // identifier diff --git a/lib/hci-socket/smp.js b/lib/hci-socket/smp.js index fb5776fb3..ada55d529 100644 --- a/lib/hci-socket/smp.js +++ b/lib/hci-socket/smp.js @@ -1,19 +1,19 @@ -var events = require('events'); -var util = require('util'); +const events = require('events'); +const util = require('util'); -var crypto = require('./crypto'); +const crypto = require('./crypto'); -var SMP_CID = 0x0006; +const SMP_CID = 0x0006; -var SMP_PAIRING_REQUEST = 0x01; -var SMP_PAIRING_RESPONSE = 0x02; -var SMP_PAIRING_CONFIRM = 0x03; -var SMP_PAIRING_RANDOM = 0x04; -var SMP_PAIRING_FAILED = 0x05; -var SMP_ENCRYPT_INFO = 0x06; -var SMP_MASTER_IDENT = 0x07; +const SMP_PAIRING_REQUEST = 0x01; +const SMP_PAIRING_RESPONSE = 0x02; +const SMP_PAIRING_CONFIRM = 0x03; +const SMP_PAIRING_RANDOM = 0x04; +const SMP_PAIRING_FAILED = 0x05; +const SMP_ENCRYPT_INFO = 0x06; +const SMP_MASTER_IDENT = 0x07; -var Smp = function (aclStream, localAddressType, localAddress, remoteAddressType, remoteAddress) { +const Smp = function (aclStream, localAddressType, localAddress, remoteAddressType, remoteAddress) { this._aclStream = aclStream; this._iat = Buffer.from([(localAddressType === 'random') ? 0x01 : 0x00]); @@ -49,7 +49,7 @@ Smp.prototype.onAclStreamData = function (cid, data) { return; } - var code = data.readUInt8(0); + const code = data.readUInt8(0); if (SMP_PAIRING_RESPONSE === code) { this.handlePairingResponse(data); @@ -95,15 +95,15 @@ Smp.prototype.handlePairingConfirm = function (data) { }; Smp.prototype.handlePairingRandom = function (data) { - var r = data.slice(1); + const r = data.slice(1); - var pcnf = Buffer.concat([ + const pcnf = Buffer.concat([ Buffer.from([SMP_PAIRING_CONFIRM]), crypto.c1(this._tk, r, this._pres, this._preq, this._iat, this._ia, this._rat, this._ra) ]); if (this._pcnf.toString('hex') === pcnf.toString('hex')) { - var stk = crypto.s1(this._tk, r, this._r); + const stk = crypto.s1(this._tk, r, this._r); this.emit('stk', stk); } else { @@ -121,14 +121,14 @@ Smp.prototype.handlePairingFailed = function (data) { }; Smp.prototype.handleEncryptInfo = function (data) { - var ltk = data.slice(1); + const ltk = data.slice(1); this.emit('ltk', ltk); }; Smp.prototype.handleMasterIdent = function (data) { - var ediv = data.slice(1, 3); - var rand = data.slice(3); + const ediv = data.slice(1, 3); + const rand = data.slice(3); this.emit('masterIdent', ediv, rand); }; diff --git a/lib/mac/bindings.js b/lib/mac/bindings.js index 417e1f8cc..266c70204 100644 --- a/lib/mac/bindings.js +++ b/lib/mac/bindings.js @@ -1,7 +1,7 @@ -var events = require('events'); -var util = require('util'); +const events = require('events'); +const util = require('util'); -var NobleMac = require('./native/binding').NobleMac; +const NobleMac = require('./native/binding').NobleMac; util.inherits(NobleMac, events.EventEmitter); diff --git a/lib/noble.js b/lib/noble.js index 0bcd677ac..2141016fe 100644 --- a/lib/noble.js +++ b/lib/noble.js @@ -1,12 +1,12 @@ -var debug = require('debug')('noble'); +const debug = require('debug')('noble'); -var events = require('events'); -var util = require('util'); +const events = require('events'); +const util = require('util'); -var Peripheral = require('./peripheral'); -var Service = require('./service'); -var Characteristic = require('./characteristic'); -var Descriptor = require('./descriptor'); +const Peripheral = require('./peripheral'); +const Service = require('./service'); +const Characteristic = require('./characteristic'); +const Descriptor = require('./descriptor'); function Noble (bindings) { this.initialized = false; @@ -107,9 +107,9 @@ Noble.prototype.onScanParametersSet = function () { }; Noble.prototype.startScanning = function (serviceUuids, allowDuplicates, callback) { - var scan = function (state) { + const scan = function (state) { if (state !== 'poweredOn') { - var error = new Error('Could not start scanning, state is ' + state + ' (not poweredOn)'); + const error = new Error('Could not start scanning, state is ' + state + ' (not poweredOn)'); if (typeof callback === 'function') { callback(error); @@ -162,7 +162,7 @@ Noble.prototype.onScanStop = function () { }; Noble.prototype.onDiscover = function (uuid, address, addressType, connectable, advertisement, rssi) { - var peripheral = this._peripherals[uuid]; + let peripheral = this._peripherals[uuid]; if (!peripheral) { peripheral = new Peripheral(this, uuid, address, addressType, connectable, advertisement, rssi); @@ -173,7 +173,7 @@ Noble.prototype.onDiscover = function (uuid, address, addressType, connectable, this._descriptors[uuid] = {}; } else { // "or" the advertisment data with existing - for (var i in advertisement) { + for (const i in advertisement) { if (advertisement[i] !== undefined) { peripheral.advertisement[i] = advertisement[i]; } @@ -183,7 +183,7 @@ Noble.prototype.onDiscover = function (uuid, address, addressType, connectable, peripheral.rssi = rssi; } - var previouslyDiscoverd = (this._discoveredPeripheralUUids.indexOf(uuid) !== -1); + const previouslyDiscoverd = (this._discoveredPeripheralUUids.indexOf(uuid) !== -1); if (!previouslyDiscoverd) { this._discoveredPeripheralUUids.push(uuid); @@ -199,7 +199,7 @@ Noble.prototype.connect = function (peripheralUuid, parameters) { }; Noble.prototype.onConnect = function (peripheralUuid, error) { - var peripheral = this._peripherals[peripheralUuid]; + const peripheral = this._peripherals[peripheralUuid]; if (peripheral) { peripheral.state = error ? 'error' : 'connected'; @@ -218,7 +218,7 @@ Noble.prototype.disconnect = function (peripheralUuid) { }; Noble.prototype.onDisconnect = function (peripheralUuid) { - var peripheral = this._peripherals[peripheralUuid]; + const peripheral = this._peripherals[peripheralUuid]; if (peripheral) { peripheral.state = 'disconnected'; @@ -233,7 +233,7 @@ Noble.prototype.updateRssi = function (peripheralUuid) { }; Noble.prototype.onRssiUpdate = function (peripheralUuid, rssi) { - var peripheral = this._peripherals[peripheralUuid]; + const peripheral = this._peripherals[peripheralUuid]; if (peripheral) { peripheral.rssi = rssi; @@ -246,10 +246,10 @@ Noble.prototype.onRssiUpdate = function (peripheralUuid, rssi) { /// add an array of service objects (as retrieved via the servicesDiscovered event) Noble.prototype.addServices = function (peripheralUuid, services) { - var servObjs = []; + const servObjs = []; - for (var i = 0; i < services.length; i++) { - var o = this.addService(peripheralUuid, services[i]); + for (let i = 0; i < services.length; i++) { + const o = this.addService(peripheralUuid, services[i]); servObjs.push(o); } return servObjs; @@ -257,7 +257,7 @@ Noble.prototype.addServices = function (peripheralUuid, services) { /// service is a ServiceObject { uuid, startHandle, endHandle,..} Noble.prototype.addService = function (peripheralUuid, service) { - var peripheral = this._peripherals[peripheralUuid]; + const peripheral = this._peripherals[peripheralUuid]; // pass on to lower layers (gatt) this._bindings.addService(peripheralUuid, service); @@ -266,7 +266,7 @@ Noble.prototype.addService = function (peripheralUuid, service) { peripheral.services = []; } // allocate internal service object and return - var serv = new Service(this, peripheralUuid, service.uuid); + const serv = new Service(this, peripheralUuid, service.uuid); this._services[peripheralUuid][service.uuid] = serv; this._characteristics[peripheralUuid][service.uuid] = {}; @@ -279,7 +279,7 @@ Noble.prototype.addService = function (peripheralUuid, service) { /// callback receiving a list of service objects from the gatt layer Noble.prototype.onServicesDiscovered = function (peripheralUuid, services) { - var peripheral = this._peripherals[peripheralUuid]; + const peripheral = this._peripherals[peripheralUuid]; if (peripheral) { peripheral.emit('servicesDiscovered', peripheral, services); } // pass on to higher layers }; @@ -289,14 +289,14 @@ Noble.prototype.discoverServices = function (peripheralUuid, uuids) { }; Noble.prototype.onServicesDiscover = function (peripheralUuid, serviceUuids) { - var peripheral = this._peripherals[peripheralUuid]; + const peripheral = this._peripherals[peripheralUuid]; if (peripheral) { - var services = []; + const services = []; - for (var i = 0; i < serviceUuids.length; i++) { - var serviceUuid = serviceUuids[i]; - var service = new Service(this, peripheralUuid, serviceUuid); + for (let i = 0; i < serviceUuids.length; i++) { + const serviceUuid = serviceUuids[i]; + const service = new Service(this, peripheralUuid, serviceUuid); this._services[peripheralUuid][serviceUuid] = service; this._characteristics[peripheralUuid][serviceUuid] = {}; @@ -318,7 +318,7 @@ Noble.prototype.discoverIncludedServices = function (peripheralUuid, serviceUuid }; Noble.prototype.onIncludedServicesDiscover = function (peripheralUuid, serviceUuid, includedServiceUuids) { - var service = this._services[peripheralUuid][serviceUuid]; + const service = this._services[peripheralUuid][serviceUuid]; if (service) { service.includedServiceUuids = includedServiceUuids; @@ -334,17 +334,17 @@ Noble.prototype.addCharacteristics = function (peripheralUuid, serviceUuid, char // first, initialize gatt layer: this._bindings.addCharacteristics(peripheralUuid, serviceUuid, characteristics); - var service = this._services[peripheralUuid][serviceUuid]; + const service = this._services[peripheralUuid][serviceUuid]; if (!service) { this.emit('warning', 'unknown service ' + peripheralUuid + ', ' + serviceUuid + ' characteristics discover!'); return; } - var characteristics_ = []; - for (var i = 0; i < characteristics.length; i++) { - var characteristicUuid = characteristics[i].uuid; + const characteristics_ = []; + for (let i = 0; i < characteristics.length; i++) { + const characteristicUuid = characteristics[i].uuid; - var characteristic = new Characteristic( + const characteristic = new Characteristic( this, peripheralUuid, serviceUuid, @@ -362,7 +362,7 @@ Noble.prototype.addCharacteristics = function (peripheralUuid, serviceUuid, char }; Noble.prototype.onCharacteristicsDiscovered = function (peripheralUuid, serviceUuid, characteristics) { - var service = this._services[peripheralUuid][serviceUuid]; + const service = this._services[peripheralUuid][serviceUuid]; service.emit('characteristicsDiscovered', characteristics); }; @@ -372,15 +372,15 @@ Noble.prototype.discoverCharacteristics = function (peripheralUuid, serviceUuid, }; Noble.prototype.onCharacteristicsDiscover = function (peripheralUuid, serviceUuid, characteristics) { - var service = this._services[peripheralUuid][serviceUuid]; + const service = this._services[peripheralUuid][serviceUuid]; if (service) { - var characteristics_ = []; + const characteristics_ = []; - for (var i = 0; i < characteristics.length; i++) { - var characteristicUuid = characteristics[i].uuid; + for (let i = 0; i < characteristics.length; i++) { + const characteristicUuid = characteristics[i].uuid; - var characteristic = new Characteristic( + const characteristic = new Characteristic( this, peripheralUuid, serviceUuid, @@ -407,7 +407,7 @@ Noble.prototype.read = function (peripheralUuid, serviceUuid, characteristicUuid }; Noble.prototype.onRead = function (peripheralUuid, serviceUuid, characteristicUuid, data, isNotification) { - var characteristic = this._characteristics[peripheralUuid][serviceUuid][characteristicUuid]; + const characteristic = this._characteristics[peripheralUuid][serviceUuid][characteristicUuid]; if (characteristic) { characteristic.emit('data', data, isNotification); @@ -423,7 +423,7 @@ Noble.prototype.write = function (peripheralUuid, serviceUuid, characteristicUui }; Noble.prototype.onWrite = function (peripheralUuid, serviceUuid, characteristicUuid) { - var characteristic = this._characteristics[peripheralUuid][serviceUuid][characteristicUuid]; + const characteristic = this._characteristics[peripheralUuid][serviceUuid][characteristicUuid]; if (characteristic) { characteristic.emit('write'); @@ -437,7 +437,7 @@ Noble.prototype.broadcast = function (peripheralUuid, serviceUuid, characteristi }; Noble.prototype.onBroadcast = function (peripheralUuid, serviceUuid, characteristicUuid, state) { - var characteristic = this._characteristics[peripheralUuid][serviceUuid][characteristicUuid]; + const characteristic = this._characteristics[peripheralUuid][serviceUuid][characteristicUuid]; if (characteristic) { characteristic.emit('broadcast', state); @@ -451,7 +451,7 @@ Noble.prototype.notify = function (peripheralUuid, serviceUuid, characteristicUu }; Noble.prototype.onNotify = function (peripheralUuid, serviceUuid, characteristicUuid, state) { - var characteristic = this._characteristics[peripheralUuid][serviceUuid][characteristicUuid]; + const characteristic = this._characteristics[peripheralUuid][serviceUuid][characteristicUuid]; if (characteristic) { characteristic.emit('notify', state); @@ -465,15 +465,15 @@ Noble.prototype.discoverDescriptors = function (peripheralUuid, serviceUuid, cha }; Noble.prototype.onDescriptorsDiscover = function (peripheralUuid, serviceUuid, characteristicUuid, descriptors) { - var characteristic = this._characteristics[peripheralUuid][serviceUuid][characteristicUuid]; + const characteristic = this._characteristics[peripheralUuid][serviceUuid][characteristicUuid]; if (characteristic) { - var descriptors_ = []; + const descriptors_ = []; - for (var i = 0; i < descriptors.length; i++) { - var descriptorUuid = descriptors[i]; + for (let i = 0; i < descriptors.length; i++) { + const descriptorUuid = descriptors[i]; - var descriptor = new Descriptor( + const descriptor = new Descriptor( this, peripheralUuid, serviceUuid, @@ -499,7 +499,7 @@ Noble.prototype.readValue = function (peripheralUuid, serviceUuid, characteristi }; Noble.prototype.onValueRead = function (peripheralUuid, serviceUuid, characteristicUuid, descriptorUuid, data) { - var descriptor = this._descriptors[peripheralUuid][serviceUuid][characteristicUuid][descriptorUuid]; + const descriptor = this._descriptors[peripheralUuid][serviceUuid][characteristicUuid][descriptorUuid]; if (descriptor) { descriptor.emit('valueRead', data); @@ -513,7 +513,7 @@ Noble.prototype.writeValue = function (peripheralUuid, serviceUuid, characterist }; Noble.prototype.onValueWrite = function (peripheralUuid, serviceUuid, characteristicUuid, descriptorUuid) { - var descriptor = this._descriptors[peripheralUuid][serviceUuid][characteristicUuid][descriptorUuid]; + const descriptor = this._descriptors[peripheralUuid][serviceUuid][characteristicUuid][descriptorUuid]; if (descriptor) { descriptor.emit('valueWrite'); @@ -527,7 +527,7 @@ Noble.prototype.readHandle = function (peripheralUuid, handle) { }; Noble.prototype.onHandleRead = function (peripheralUuid, handle, data) { - var peripheral = this._peripherals[peripheralUuid]; + const peripheral = this._peripherals[peripheralUuid]; if (peripheral) { peripheral.emit('handleRead' + handle, data); @@ -541,7 +541,7 @@ Noble.prototype.writeHandle = function (peripheralUuid, handle, data, withoutRes }; Noble.prototype.onHandleWrite = function (peripheralUuid, handle) { - var peripheral = this._peripherals[peripheralUuid]; + const peripheral = this._peripherals[peripheralUuid]; if (peripheral) { peripheral.emit('handleWrite' + handle); @@ -551,7 +551,7 @@ Noble.prototype.onHandleWrite = function (peripheralUuid, handle) { }; Noble.prototype.onHandleNotify = function (peripheralUuid, handle, data) { - var peripheral = this._peripherals[peripheralUuid]; + const peripheral = this._peripherals[peripheralUuid]; if (peripheral) { peripheral.emit('handleNotify', handle, data); diff --git a/lib/peripheral.js b/lib/peripheral.js index e66bd81ad..5250af5a1 100644 --- a/lib/peripheral.js +++ b/lib/peripheral.js @@ -1,5 +1,5 @@ -var events = require('events'); -var util = require('util'); +const events = require('events'); +const util = require('util'); function Peripheral (noble, id, address, addressType, connectable, advertisement, rssi) { this._noble = noble; @@ -106,19 +106,19 @@ Peripheral.prototype.discoverSomeServicesAndCharacteristics = function (serviceU callback(err, null, null); return; } - var numDiscovered = 0; - var allCharacteristics = []; + let numDiscovered = 0; + const allCharacteristics = []; - for (var i in services) { - var service = services[i]; + for (const i in services) { + const service = services[i]; service.discoverCharacteristics(characteristicsUuids, (error, characteristics) => { numDiscovered++; // TODO: handle `error`? if (error === null) { - for (var j in characteristics) { - var characteristic = characteristics[j]; + for (const j in characteristics) { + const characteristic = characteristics[j]; allCharacteristics.push(characteristic); } diff --git a/lib/resolve-bindings.js b/lib/resolve-bindings.js index 1218c282a..bead76c7a 100644 --- a/lib/resolve-bindings.js +++ b/lib/resolve-bindings.js @@ -1,7 +1,7 @@ -var os = require('os'); +const os = require('os'); module.exports = function (options) { - var platform = os.platform(); + const platform = os.platform(); if (process.env.NOBLE_WEBSOCKET) { return new require('./websocket/bindings')(options); diff --git a/lib/service.js b/lib/service.js index 1b48b9df8..957184fd8 100644 --- a/lib/service.js +++ b/lib/service.js @@ -1,7 +1,7 @@ -var events = require('events'); -var util = require('util'); +const events = require('events'); +const util = require('util'); -var services = require('./services.json'); +const services = require('./services.json'); function Service (noble, peripheralId, uuid) { this._noble = noble; @@ -13,7 +13,7 @@ function Service (noble, peripheralId, uuid) { this.includedServiceUuids = null; this.characteristics = null; - var service = services[uuid]; + const service = services[uuid]; if (service) { this.name = service.name; this.type = service.type; diff --git a/lib/webbluetooth/bindings.js b/lib/webbluetooth/bindings.js index f4d91b098..0dfe1de7d 100644 --- a/lib/webbluetooth/bindings.js +++ b/lib/webbluetooth/bindings.js @@ -1,7 +1,7 @@ -var util = require('util'); -var events = require('events'); +const util = require('util'); +const events = require('events'); -var debug = require('debug')('webble-bindings'); +const debug = require('debug')('webble-bindings'); function makeList (uuid) { return { services: [uuid] }; @@ -24,7 +24,7 @@ function stripDashes (uuid) { return uuid; } -var NobleBindings = function () { +const NobleBindings = function () { this._ble = null; this._startScanCommand = null; this._peripherals = {}; @@ -38,7 +38,7 @@ NobleBindings.prototype.init = function (ble) { this._ble = navigator.bluetooth; } - var self = this; + const self = this; process.nextTick(() => { debug('initing'); if (!self._ble) { @@ -60,7 +60,7 @@ NobleBindings.prototype.onClose = function () { }; NobleBindings.prototype.startScanning = function (options, allowDuplicates) { - var self = this; + const self = this; if (Array.isArray(options)) { options = { services: options }; @@ -84,9 +84,9 @@ NobleBindings.prototype.startScanning = function (options, allowDuplicates) { return service; }); - var dashedUuids = options.services.map(addDashes); + const dashedUuids = options.services.map(addDashes); - var filterList = dashedUuids.map(makeList); + const filterList = dashedUuids.map(makeList); if (options.name) { filterList.push({ name: options.name }); } @@ -94,7 +94,7 @@ NobleBindings.prototype.startScanning = function (options, allowDuplicates) { filterList.push({ namePrefix: options.namePrefix }); } - var request = { filters: filterList }; + const request = { filters: filterList }; debug('startScanning', request, allowDuplicates); @@ -103,7 +103,7 @@ NobleBindings.prototype.startScanning = function (options, allowDuplicates) { debug('scan finished', device); self.emit('scanStop', {}); if (device) { - var address = device.id; + const address = device.id; // TODO use device.adData when api is ready // rssi = device.adData.rssi; @@ -140,9 +140,9 @@ NobleBindings.prototype.stopScanning = function () { }; NobleBindings.prototype.connect = function (deviceUuid) { - var self = this; + const self = this; debug('connect', deviceUuid); - var peripheral = this._peripherals[deviceUuid]; + const peripheral = this._peripherals[deviceUuid]; // clear any cached services in case this is a reconnect peripheral.cachedServices = {}; @@ -151,7 +151,7 @@ NobleBindings.prototype.connect = function (deviceUuid) { .then(gattServer => { debug('peripheral connected', gattServer); - var onDisconnected = function (event) { + const onDisconnected = function (event) { debug('disconnected', peripheral.uuid); self.emit('disconnect', peripheral.uuid); }; @@ -165,7 +165,7 @@ NobleBindings.prototype.connect = function (deviceUuid) { }; NobleBindings.prototype.disconnect = function (deviceUuid) { - var peripheral = this._peripherals[deviceUuid]; + const peripheral = this._peripherals[deviceUuid]; if (peripheral.device.gatt) { peripheral.device.gatt.disconnect(); this.emit('disconnect', deviceUuid); @@ -179,7 +179,7 @@ NobleBindings.prototype.updateRssi = function (deviceUuid) { }; NobleBindings.prototype.discoverServices = function (deviceUuid, uuids) { - var peripheral = this._peripherals[deviceUuid]; + const peripheral = this._peripherals[deviceUuid]; // TODO: need web api completed for this to work if (peripheral) { @@ -194,15 +194,15 @@ NobleBindings.prototype.discoverIncludedServices = function (deviceUuid, service }; NobleBindings.prototype.discoverCharacteristics = function (deviceUuid, serviceUuid, characteristicUuids) { - var self = this; - var peripheral = self._peripherals[deviceUuid]; + const self = this; + const peripheral = self._peripherals[deviceUuid]; if (peripheral) { self.getPrimaryService(peripheral, serviceUuid) .then(service => service.getCharacteristics()) .then(characteristics => { - var discoveredCharacteristics = characteristics.map(char => { - var charInfo = { uuid: stripDashes(char.uuid), properties: [] }; + const discoveredCharacteristics = characteristics.map(char => { + const charInfo = { uuid: stripDashes(char.uuid), properties: [] }; if (char.properties.writeWithoutResponse) { charInfo.properties.push('writeWithoutResponse'); @@ -246,8 +246,8 @@ NobleBindings.prototype.getPrimaryService = function (peripheral, serviceUuid) { }; NobleBindings.prototype.read = function (deviceUuid, serviceUuid, characteristicUuid) { - var self = this; - var peripheral = this._peripherals[deviceUuid]; + const self = this; + const peripheral = this._peripherals[deviceUuid]; debug('read', deviceUuid, serviceUuid, characteristicUuid); self.getPrimaryService(peripheral, serviceUuid) @@ -263,8 +263,8 @@ NobleBindings.prototype.read = function (deviceUuid, serviceUuid, characteristic }; NobleBindings.prototype.write = function (deviceUuid, serviceUuid, characteristicUuid, data, withoutResponse) { - var self = this; - var peripheral = this._peripherals[deviceUuid]; + const self = this; + const peripheral = this._peripherals[deviceUuid]; debug('write', deviceUuid, serviceUuid, characteristicUuid, data, withoutResponse); self.getPrimaryService(peripheral, serviceUuid) @@ -286,10 +286,10 @@ NobleBindings.prototype.broadcast = function (deviceUuid, serviceUuid, character }; NobleBindings.prototype.notify = function (deviceUuid, serviceUuid, characteristicUuid, notify) { - var self = this; - var peripheral = this._peripherals[deviceUuid]; + const self = this; + const peripheral = this._peripherals[deviceUuid]; - var charPromise = self.getPrimaryService(peripheral, serviceUuid) + const charPromise = self.getPrimaryService(peripheral, serviceUuid) .then(service => service.getCharacteristic(addDashes(characteristicUuid))); peripheral.notifcationListeners = peripheral.notifcationListeners || {}; @@ -304,7 +304,7 @@ NobleBindings.prototype.notify = function (deviceUuid, serviceUuid, characterist }; characteristic.addEventListener('characteristicvaluechanged', peripheral.notifcationListeners[serviceUuid + '__' + characteristicUuid]); - var onDisconnected = function () { + const onDisconnected = function () { characteristic.removeEventListener('characteristicvaluechanged', peripheral.notifcationListeners[serviceUuid + '__' + characteristicUuid]); delete peripheral.notifcationListeners[serviceUuid + '__' + characteristicUuid]; }; diff --git a/lib/websocket/bindings.js b/lib/websocket/bindings.js index 1b43fb66a..cecddd18e 100644 --- a/lib/websocket/bindings.js +++ b/lib/websocket/bindings.js @@ -1,10 +1,10 @@ -var events = require('events'); -var util = require('util'); +const events = require('events'); +const util = require('util'); -var WebSocket = require('ws'); +const WebSocket = require('ws'); -var NobleBindings = function () { - var port = 0xB1e; +const NobleBindings = function () { + const port = 0xB1e; this._ws = new WebSocket('ws://localhost:' + port); this._startScanCommand = null; @@ -20,9 +20,9 @@ var NobleBindings = function () { this._ws.on('close', this._onClose.bind(this)); this._ws.on('error', this._onClose.bind(this)); - var _this = this; + const _this = this; this._ws.on('message', event => { - var data = (process.title === 'browser') ? event.data : event; + const data = (process.title === 'browser') ? event.data : event; _this.emit('message', JSON.parse(data)); }); @@ -44,7 +44,7 @@ NobleBindings.prototype._onClose = function () { }; NobleBindings.prototype._onMessage = function (event) { - var { + let { type, peripheralUuid, address, @@ -63,7 +63,7 @@ NobleBindings.prototype._onMessage = function (event) { descriptorUuid, handle } = event; - var data = event.data ? Buffer.from(event.data, 'hex') : null; + const data = event.data ? Buffer.from(event.data, 'hex') : null; if (type === 'stateChange') { console.log(state); @@ -121,7 +121,7 @@ NobleBindings.prototype._onMessage = function (event) { }; NobleBindings.prototype._sendCommand = function (command, errorCallback) { - var message = JSON.stringify(command); + const message = JSON.stringify(command); this._ws.send(message, error => { if (error != null) { console.warn('could not send command', command, error); @@ -154,7 +154,7 @@ NobleBindings.prototype.stopScanning = function () { }; NobleBindings.prototype.connect = function (deviceUuid) { - var peripheral = this._peripherals[deviceUuid]; + const peripheral = this._peripherals[deviceUuid]; this._sendCommand({ action: 'connect', @@ -163,7 +163,7 @@ NobleBindings.prototype.connect = function (deviceUuid) { }; NobleBindings.prototype.disconnect = function (deviceUuid) { - var peripheral = this._peripherals[deviceUuid]; + const peripheral = this._peripherals[deviceUuid]; this._sendCommand({ action: 'disconnect', @@ -172,7 +172,7 @@ NobleBindings.prototype.disconnect = function (deviceUuid) { }; NobleBindings.prototype.updateRssi = function (deviceUuid) { - var peripheral = this._peripherals[deviceUuid]; + const peripheral = this._peripherals[deviceUuid]; this._sendCommand({ action: 'updateRssi', @@ -181,7 +181,7 @@ NobleBindings.prototype.updateRssi = function (deviceUuid) { }; NobleBindings.prototype.discoverServices = function (deviceUuid, uuids) { - var peripheral = this._peripherals[deviceUuid]; + const peripheral = this._peripherals[deviceUuid]; this._sendCommand({ action: 'discoverServices', @@ -191,7 +191,7 @@ NobleBindings.prototype.discoverServices = function (deviceUuid, uuids) { }; NobleBindings.prototype.discoverIncludedServices = function (deviceUuid, serviceUuid, serviceUuids) { - var peripheral = this._peripherals[deviceUuid]; + const peripheral = this._peripherals[deviceUuid]; this._sendCommand({ action: 'discoverIncludedServices', @@ -202,7 +202,7 @@ NobleBindings.prototype.discoverIncludedServices = function (deviceUuid, service }; NobleBindings.prototype.discoverCharacteristics = function (deviceUuid, serviceUuid, characteristicUuids) { - var peripheral = this._peripherals[deviceUuid]; + const peripheral = this._peripherals[deviceUuid]; this._sendCommand({ action: 'discoverCharacteristics', @@ -213,7 +213,7 @@ NobleBindings.prototype.discoverCharacteristics = function (deviceUuid, serviceU }; NobleBindings.prototype.read = function (deviceUuid, serviceUuid, characteristicUuid) { - var peripheral = this._peripherals[deviceUuid]; + const peripheral = this._peripherals[deviceUuid]; this._sendCommand({ action: 'read', @@ -224,7 +224,7 @@ NobleBindings.prototype.read = function (deviceUuid, serviceUuid, characteristic }; NobleBindings.prototype.write = function (deviceUuid, serviceUuid, characteristicUuid, data, withoutResponse) { - var peripheral = this._peripherals[deviceUuid]; + const peripheral = this._peripherals[deviceUuid]; this._sendCommand({ action: 'write', @@ -237,7 +237,7 @@ NobleBindings.prototype.write = function (deviceUuid, serviceUuid, characteristi }; NobleBindings.prototype.broadcast = function (deviceUuid, serviceUuid, characteristicUuid, broadcast) { - var peripheral = this._peripherals[deviceUuid]; + const peripheral = this._peripherals[deviceUuid]; this._sendCommand({ action: 'broadcast', @@ -249,7 +249,7 @@ NobleBindings.prototype.broadcast = function (deviceUuid, serviceUuid, character }; NobleBindings.prototype.notify = function (deviceUuid, serviceUuid, characteristicUuid, notify) { - var peripheral = this._peripherals[deviceUuid]; + const peripheral = this._peripherals[deviceUuid]; this._sendCommand({ action: 'notify', @@ -261,7 +261,7 @@ NobleBindings.prototype.notify = function (deviceUuid, serviceUuid, characterist }; NobleBindings.prototype.discoverDescriptors = function (deviceUuid, serviceUuid, characteristicUuid) { - var peripheral = this._peripherals[deviceUuid]; + const peripheral = this._peripherals[deviceUuid]; this._sendCommand({ action: 'discoverDescriptors', @@ -272,7 +272,7 @@ NobleBindings.prototype.discoverDescriptors = function (deviceUuid, serviceUuid, }; NobleBindings.prototype.readValue = function (deviceUuid, serviceUuid, characteristicUuid, descriptorUuid) { - var peripheral = this._peripherals[deviceUuid]; + const peripheral = this._peripherals[deviceUuid]; this._sendCommand({ action: 'readValue', @@ -284,7 +284,7 @@ NobleBindings.prototype.readValue = function (deviceUuid, serviceUuid, character }; NobleBindings.prototype.writeValue = function (deviceUuid, serviceUuid, characteristicUuid, descriptorUuid, data) { - var peripheral = this._peripherals[deviceUuid]; + const peripheral = this._peripherals[deviceUuid]; this._sendCommand({ action: 'writeValue', @@ -297,7 +297,7 @@ NobleBindings.prototype.writeValue = function (deviceUuid, serviceUuid, characte }; NobleBindings.prototype.readHandle = function (deviceUuid, handle) { - var peripheral = this._peripherals[deviceUuid]; + const peripheral = this._peripherals[deviceUuid]; this._sendCommand({ action: 'readHandle', @@ -307,7 +307,7 @@ NobleBindings.prototype.readHandle = function (deviceUuid, handle) { }; NobleBindings.prototype.writeHandle = function (deviceUuid, handle, data, withoutResponse) { - var peripheral = this._peripherals[deviceUuid]; + const peripheral = this._peripherals[deviceUuid]; this._sendCommand({ action: 'writeHandle', diff --git a/test/test-characteristic.js b/test/test-characteristic.js index 18ed94838..1c730662b 100644 --- a/test/test-characteristic.js +++ b/test/test-characteristic.js @@ -1,16 +1,16 @@ require('should'); -var sinon = require('sinon'); +const sinon = require('sinon'); -var Characteristic = require('../lib/characteristic'); +const Characteristic = require('../lib/characteristic'); describe('Characteristic', function () { - var mockNoble = null; - var mockPeripheralId = 'mock-peripheral-id'; - var mockServiceUuid = 'mock-service-uuid'; - var mockUuid = 'mock-uuid'; - var mockProperties = ['mock-property-1', 'mock-property-2']; + let mockNoble = null; + const mockPeripheralId = 'mock-peripheral-id'; + const mockServiceUuid = 'mock-service-uuid'; + const mockUuid = 'mock-uuid'; + const mockProperties = ['mock-property-1', 'mock-property-2']; - var characteristic = null; + let characteristic = null; beforeEach(function () { mockNoble = { @@ -57,7 +57,7 @@ describe('Characteristic', function () { }); it('should callback', function () { - var calledback = false; + let calledback = false; characteristic.read(function () { calledback = true; @@ -68,8 +68,8 @@ describe('Characteristic', function () { }); it('should callback with data', function () { - var mockData = Buffer.alloc(0); - var callbackData = null; + const mockData = Buffer.alloc(0); + let callbackData = null; characteristic.read(function (error, data) { if (error) { @@ -84,7 +84,7 @@ describe('Characteristic', function () { }); describe('write', function () { - var mockData = null; + let mockData = null; beforeEach(function () { mockData = Buffer.alloc(0); @@ -111,7 +111,7 @@ describe('Characteristic', function () { }); it('should callback', function () { - var calledback = false; + let calledback = false; characteristic.write(mockData, true, function () { calledback = true; @@ -136,7 +136,7 @@ describe('Characteristic', function () { }); it('should callback', function () { - var calledback = false; + let calledback = false; characteristic.broadcast(true, function () { calledback = true; @@ -161,7 +161,7 @@ describe('Characteristic', function () { }); it('should callback', function () { - var calledback = false; + let calledback = false; characteristic.notify(true, function () { calledback = true; @@ -180,7 +180,7 @@ describe('Characteristic', function () { }); it('should callback', function () { - var calledback = false; + let calledback = false; characteristic.subscribe(function () { calledback = true; @@ -199,7 +199,7 @@ describe('Characteristic', function () { }); it('should callback', function () { - var calledback = false; + let calledback = false; characteristic.unsubscribe(function () { calledback = true; @@ -218,7 +218,7 @@ describe('Characteristic', function () { }); it('should callback', function () { - var calledback = false; + let calledback = false; characteristic.discoverDescriptors(function () { calledback = true; @@ -229,8 +229,8 @@ describe('Characteristic', function () { }); it('should callback with descriptors', function () { - var mockDescriptors = []; - var callbackDescriptors = null; + const mockDescriptors = []; + let callbackDescriptors = null; characteristic.discoverDescriptors(function (error, descriptors) { if (error) { diff --git a/test/test-descriptor.js b/test/test-descriptor.js index 8585d96b5..79ffca86b 100644 --- a/test/test-descriptor.js +++ b/test/test-descriptor.js @@ -1,16 +1,16 @@ require('should'); -var sinon = require('sinon'); +const sinon = require('sinon'); -var Descriptor = require('../lib/descriptor'); +const Descriptor = require('../lib/descriptor'); describe('Descriptor', function () { - var mockNoble = null; - var mockPeripheralId = 'mock-peripheral-id'; - var mockServiceUuid = 'mock-service-uuid'; - var mockCharacteristicUuid = 'mock-characteristic-uuid'; - var mockUuid = 'mock-uuid'; + let mockNoble = null; + const mockPeripheralId = 'mock-peripheral-id'; + const mockServiceUuid = 'mock-service-uuid'; + const mockCharacteristicUuid = 'mock-characteristic-uuid'; + const mockUuid = 'mock-uuid'; - var descriptor = null; + let descriptor = null; beforeEach(function () { mockNoble = { @@ -50,7 +50,7 @@ describe('Descriptor', function () { }); it('should callback', function () { - var calledback = false; + let calledback = false; descriptor.readValue(function () { calledback = true; @@ -61,7 +61,7 @@ describe('Descriptor', function () { }); it('should not call callback twice', function () { - var calledback = 0; + let calledback = 0; descriptor.readValue(function () { calledback += 1; @@ -73,8 +73,8 @@ describe('Descriptor', function () { }); it('should callback with error, data', function () { - var mockData = Buffer.alloc(0); - var callbackData = null; + const mockData = Buffer.alloc(0); + let callbackData = null; descriptor.readValue(function (error, data) { if (error) { @@ -89,7 +89,7 @@ describe('Descriptor', function () { }); describe('writeValue', function () { - var mockData = null; + let mockData = null; beforeEach(function () { mockData = Buffer.alloc(0); @@ -110,7 +110,7 @@ describe('Descriptor', function () { }); it('should callback', function () { - var calledback = false; + let calledback = false; descriptor.writeValue(mockData, function () { calledback = true; @@ -121,7 +121,7 @@ describe('Descriptor', function () { }); it('should not call callback twice', function () { - var calledback = 0; + let calledback = 0; descriptor.writeValue(mockData, function () { calledback += 1; diff --git a/test/test-peripheral.js b/test/test-peripheral.js index a2e21b876..49d7e46fe 100644 --- a/test/test-peripheral.js +++ b/test/test-peripheral.js @@ -1,20 +1,20 @@ require('should'); -var sinon = require('sinon'); +const sinon = require('sinon'); -var Peripheral = require('../lib/peripheral'); +const Peripheral = require('../lib/peripheral'); describe('Peripheral', function () { - var mockNoble = null; - var mockId = 'mock-id'; - var mockAddress = 'mock-address'; - var mockAddressType = 'mock-address-type'; - var mockConnectable = 'mock-connectable'; - var mockAdvertisement = 'mock-advertisement'; - var mockRssi = 'mock-rssi'; - var mockHandle = 'mock-handle'; - var mockData = 'mock-data'; - - var peripheral = null; + let mockNoble = null; + const mockId = 'mock-id'; + const mockAddress = 'mock-address'; + const mockAddressType = 'mock-address-type'; + const mockConnectable = 'mock-connectable'; + const mockAdvertisement = 'mock-advertisement'; + const mockRssi = 'mock-rssi'; + const mockHandle = 'mock-handle'; + let mockData = 'mock-data'; + + let peripheral = null; beforeEach(function () { mockNoble = { @@ -71,7 +71,7 @@ describe('Peripheral', function () { }); it('should callback', function () { - var calledback = false; + let calledback = false; peripheral.connect(function () { calledback = true; @@ -90,7 +90,7 @@ describe('Peripheral', function () { }); it('should callback', function () { - var calledback = false; + let calledback = false; peripheral.disconnect(function () { calledback = true; @@ -109,7 +109,7 @@ describe('Peripheral', function () { }); it('should callback', function () { - var calledback = false; + let calledback = false; peripheral.updateRssi(function () { calledback = true; @@ -120,7 +120,7 @@ describe('Peripheral', function () { }); it('should callback with rssi', function () { - var calledbackRssi = null; + let calledbackRssi = null; peripheral.updateRssi(function (error, rssi) { if (error) { @@ -142,7 +142,7 @@ describe('Peripheral', function () { }); it('should delegate to noble, service uuids', function () { - var mockServiceUuids = []; + const mockServiceUuids = []; peripheral.discoverServices(mockServiceUuids); @@ -150,7 +150,7 @@ describe('Peripheral', function () { }); it('should callback', function () { - var calledback = false; + let calledback = false; peripheral.discoverServices(null, function () { calledback = true; @@ -161,8 +161,8 @@ describe('Peripheral', function () { }); it('should callback with services', function () { - var mockServices = []; - var calledbackServices = null; + const mockServices = []; + let calledbackServices = null; peripheral.discoverServices(null, function (error, services) { if (error) { @@ -177,9 +177,9 @@ describe('Peripheral', function () { }); describe('discoverSomeServicesAndCharacteristics', function () { - var mockServiceUuids = []; - var mockCharacteristicUuids = []; - var mockServices = null; + const mockServiceUuids = []; + const mockCharacteristicUuids = []; + let mockServices = null; beforeEach(function () { peripheral.discoverServices = sinon.spy(); @@ -205,7 +205,7 @@ describe('Peripheral', function () { it('should call discoverCharacteristics on each service discovered', function () { peripheral.discoverSomeServicesAndCharacteristics(mockServiceUuids, mockCharacteristicUuids); - var discoverServicesCallback = peripheral.discoverServices.getCall(0).args[1]; + const discoverServicesCallback = peripheral.discoverServices.getCall(0).args[1]; discoverServicesCallback(null, mockServices); @@ -214,13 +214,13 @@ describe('Peripheral', function () { }); it('should callback', function () { - var calledback = false; + let calledback = false; peripheral.discoverSomeServicesAndCharacteristics(mockServiceUuids, mockCharacteristicUuids, function () { calledback = true; }); - var discoverServicesCallback = peripheral.discoverServices.getCall(0).args[1]; + const discoverServicesCallback = peripheral.discoverServices.getCall(0).args[1]; discoverServicesCallback(null, mockServices); @@ -231,8 +231,8 @@ describe('Peripheral', function () { }); it('should callback with the services and characteristics discovered', function () { - var calledbackServices = null; - var calledbackCharacteristics = null; + let calledbackServices = null; + let calledbackCharacteristics = null; peripheral.discoverSomeServicesAndCharacteristics(mockServiceUuids, mockCharacteristicUuids, function (err, services, characteristics) { if (err) { @@ -242,13 +242,13 @@ describe('Peripheral', function () { calledbackCharacteristics = characteristics; }); - var discoverServicesCallback = peripheral.discoverServices.getCall(0).args[1]; + const discoverServicesCallback = peripheral.discoverServices.getCall(0).args[1]; discoverServicesCallback(null, mockServices); - var mockCharacteristic1 = { uuid: '1' }; - var mockCharacteristic2 = { uuid: '2' }; - var mockCharacteristic3 = { uuid: '3' }; + const mockCharacteristic1 = { uuid: '1' }; + const mockCharacteristic2 = { uuid: '2' }; + const mockCharacteristic3 = { uuid: '3' }; mockServices[0].discoverCharacteristics.getCall(0).args[1](null, [mockCharacteristic1]); mockServices[1].discoverCharacteristics.getCall(0).args[1](null, [mockCharacteristic2, mockCharacteristic3]); @@ -260,7 +260,7 @@ describe('Peripheral', function () { describe('discoverAllServicesAndCharacteristics', function () { it('should call discoverSomeServicesAndCharacteristics', function () { - var mockCallback = sinon.spy(); + const mockCallback = sinon.spy(); peripheral.discoverSomeServicesAndCharacteristics = sinon.spy(); @@ -278,7 +278,7 @@ describe('Peripheral', function () { }); it('should callback', function () { - var calledback = false; + let calledback = false; peripheral.readHandle(mockHandle, function () { calledback = true; @@ -289,7 +289,7 @@ describe('Peripheral', function () { }); it('should callback with data', function () { - var calledbackData = null; + let calledbackData = null; peripheral.readHandle(mockHandle, function (error, data) { if (error) { @@ -329,7 +329,7 @@ describe('Peripheral', function () { }); it('should callback', function () { - var calledback = false; + let calledback = false; peripheral.writeHandle(mockHandle, mockData, false, function () { calledback = true; diff --git a/test/test-service.js b/test/test-service.js index 8a8755111..8ff982496 100644 --- a/test/test-service.js +++ b/test/test-service.js @@ -1,14 +1,14 @@ require('should'); -var sinon = require('sinon'); +const sinon = require('sinon'); -var Service = require('../lib/service'); +const Service = require('../lib/service'); describe('service', function () { - var mockNoble = null; - var mockPeripheralId = 'mock-peripheral-id'; - var mockUuid = 'mock-uuid'; + let mockNoble = null; + const mockPeripheralId = 'mock-peripheral-id'; + const mockUuid = 'mock-uuid'; - var service = null; + let service = null; beforeEach(function () { mockNoble = { @@ -48,7 +48,7 @@ describe('service', function () { }); it('should delegate to noble, with uuids', function () { - var mockUuids = []; + const mockUuids = []; service.discoverIncludedServices(mockUuids); @@ -56,7 +56,7 @@ describe('service', function () { }); it('should callback', function () { - var calledback = false; + let calledback = false; service.discoverIncludedServices(null, function () { calledback = true; @@ -67,8 +67,8 @@ describe('service', function () { }); it('should callback with data', function () { - var mockIncludedServiceUuids = []; - var callbackIncludedServiceUuids = null; + const mockIncludedServiceUuids = []; + let callbackIncludedServiceUuids = null; service.discoverIncludedServices(null, function (error, includedServiceUuids) { if (error) { @@ -90,7 +90,7 @@ describe('service', function () { }); it('should delegate to noble, with uuids', function () { - var mockUuids = []; + const mockUuids = []; service.discoverCharacteristics(mockUuids); @@ -98,7 +98,7 @@ describe('service', function () { }); it('should callback', function () { - var calledback = false; + let calledback = false; service.discoverCharacteristics(null, function () { calledback = true; @@ -109,8 +109,8 @@ describe('service', function () { }); it('should callback with data', function () { - var mockCharacteristics = []; - var callbackCharacteristics = null; + const mockCharacteristics = []; + let callbackCharacteristics = null; service.discoverCharacteristics(null, function (error, mockCharacteristics) { if (error) { From 378e86ffa250080a1d6f6b629673eaf1cc51f4b7 Mon Sep 17 00:00:00 2001 From: Aarni Koskela Date: Sat, 25 Jan 2020 15:13:25 +0200 Subject: [PATCH 067/114] Codemod string concatenation into template literals --- examples/advertisement-discovery.js | 15 ++-- examples/cache-gatt-discovery.js | 35 ++++---- examples/cache-gatt-reconnect.js | 29 +++---- examples/echo.js | 6 +- examples/enter-exit.js | 4 +- examples/peripheral-explorer.js | 24 +++--- lib/hci-socket/bindings.js | 32 +++---- lib/hci-socket/gap.js | 4 +- lib/hci-socket/gatt.js | 20 ++--- lib/hci-socket/hci.js | 124 ++++++++++++++-------------- lib/hci-socket/signaling.js | 8 +- lib/noble.js | 46 +++++------ lib/peripheral.js | 4 +- lib/webbluetooth/bindings.js | 18 ++-- lib/websocket/bindings.js | 2 +- test/test-peripheral.js | 6 +- 16 files changed, 184 insertions(+), 193 deletions(-) diff --git a/examples/advertisement-discovery.js b/examples/advertisement-discovery.js index 33cec77d9..5adcb147d 100644 --- a/examples/advertisement-discovery.js +++ b/examples/advertisement-discovery.js @@ -9,29 +9,26 @@ noble.on('stateChange', function (state) { }); noble.on('discover', function (peripheral) { - console.log('peripheral discovered (' + peripheral.id + - ' with address <' + peripheral.address + ', ' + peripheral.addressType + '>,' + - ' connectable ' + peripheral.connectable + ',' + - ' RSSI ' + peripheral.rssi + ':'); + console.log(`peripheral discovered (${peripheral.id} with address <${peripheral.address}, ${peripheral.addressType}>, connectable ${peripheral.connectable}, RSSI ${peripheral.rssi}:`); console.log('\thello my local name is:'); - console.log('\t\t' + peripheral.advertisement.localName); + console.log(`\t\t${peripheral.advertisement.localName}`); console.log('\tcan I interest you in any of the following advertised services:'); - console.log('\t\t' + JSON.stringify(peripheral.advertisement.serviceUuids)); + console.log(`\t\t${JSON.stringify(peripheral.advertisement.serviceUuids)}`); const serviceData = peripheral.advertisement.serviceData; if (serviceData && serviceData.length) { console.log('\there is my service data:'); for (const i in serviceData) { - console.log('\t\t' + JSON.stringify(serviceData[i].uuid) + ': ' + JSON.stringify(serviceData[i].data.toString('hex'))); + console.log(`\t\t${JSON.stringify(serviceData[i].uuid)}: ${JSON.stringify(serviceData[i].data.toString('hex'))}`); } } if (peripheral.advertisement.manufacturerData) { console.log('\there is my manufacturer data:'); - console.log('\t\t' + JSON.stringify(peripheral.advertisement.manufacturerData.toString('hex'))); + console.log(`\t\t${JSON.stringify(peripheral.advertisement.manufacturerData.toString('hex'))}`); } if (peripheral.advertisement.txPowerLevel !== undefined) { console.log('\tmy TX power level is:'); - console.log('\t\t' + peripheral.advertisement.txPowerLevel); + console.log(`\t\t${peripheral.advertisement.txPowerLevel}`); } console.log(); diff --git a/examples/cache-gatt-discovery.js b/examples/cache-gatt-discovery.js index f61bd0e19..70b074377 100644 --- a/examples/cache-gatt-discovery.js +++ b/examples/cache-gatt-discovery.js @@ -35,17 +35,14 @@ const meta = { }; noble.on('discover', function (peripheral) { - console.log('peripheral discovered (' + peripheral.id + - ' with address <' + peripheral.address + ', ' + peripheral.addressType + '>,' + - ' connectable ' + peripheral.connectable + ',' + - ' RSSI ' + peripheral.rssi + ':'); + console.log(`peripheral discovered (${peripheral.id} with address <${peripheral.address}, ${peripheral.addressType}>, connectable ${peripheral.connectable}, RSSI ${peripheral.rssi}:`); console.log('\thello my local name is:'); - console.log('\t\t' + peripheral.advertisement.localName); + console.log(`\t\t${peripheral.advertisement.localName}`); console.log(); // connect to the first device with a valid name if (peripheral.advertisement.localName) { - console.log('Connecting to ' + peripheral.address + ' ' + peripheral.advertisement.localName); + console.log(`Connecting to ${peripheral.address} ${peripheral.advertisement.localName}`); tDisco = Date.now(); @@ -60,7 +57,7 @@ const connectToDevice = function (peripheral) { peripheral.connect((error) => { // noble.startScanning([], true) if (error) { - console.log('Connect error: ' + error); + console.log(`Connect error: ${error}`); noble.startScanning([], true); return; } @@ -82,11 +79,11 @@ const findServices = function (noble, peripheral) { // callback triggers with GATT-relevant data peripheral.on('servicesDiscovered', (peripheral, services) => { - console.log('servicesDiscovered: Found ' + services.length + ' services! '); + console.log(`servicesDiscovered: Found ${services.length} services! `); meta.services = services; for (const i in services) { const service = services[i]; - console.log('\tservice ' + i + ' : ' + JSON.stringify(service)); + console.log(`\tservice ${i} : ${JSON.stringify(service)}`); // meta.services[ service.uuid ] = service } }); @@ -104,20 +101,20 @@ const findServices = function (noble, peripheral) { // store the list of characteristics per service meta.characteristics[service.uuid] = characteristics; - console.log('SRV\t' + service.uuid + ' characteristic GATT data: '); + console.log(`SRV\t${service.uuid} characteristic GATT data: `); for (let i = 0; i < characteristics.length; i++) { - console.log('\t' + service.uuid + ' chara.\t ' + ' ' + i + ' ' + JSON.stringify(characteristics[i])); + console.log(`\t${service.uuid} chara.\t ${i} ${JSON.stringify(characteristics[i])}`); } }); service.discoverCharacteristics([], function (error, characteristics) { - console.log('SRV\t' + service.uuid + ' characteristic decoded data: '); + console.log(`SRV\t${service.uuid} characteristic decoded data: `); for (let j = 0; j < characteristics.length; j++) { const ch = characteristics[j]; - console.log('\t' + service.uuid + ' chara.\t ' + ' ' + j + ' ' + ch); + console.log(`\t${service.uuid} chara.\t ${j} ${ch}`); if (ch.name === CHANNEL) { - console.log('found ' + CHANNEL + ' characteristic!'); + console.log(`found ${CHANNEL} characteristic!`); sensorCharacteristic = ch; } } @@ -141,18 +138,18 @@ const findServices = function (noble, peripheral) { sensorCharacteristic.on('data', (data) => { if (BITS === 16) { - console.log(' new ' + CHANNEL + ' ' + (data.readUInt16LE() * FACTOR)); + console.log(` new ${CHANNEL} ${data.readUInt16LE() * FACTOR}`); } else if (BITS === 32) { - console.log(' new ' + CHANNEL + ' ' + (data.readUInt32LE() * FACTOR)); + console.log(` new ${CHANNEL} ${data.readUInt32LE() * FACTOR}`); } else { - console.log(' Cannot cope with BITS value ' + BITS); + console.log(` Cannot cope with BITS value ${BITS}`); } }); sensorCharacteristic.read(); } - console.log('Timespan from discovery to connected: ' + (tConn - tDisco) + ' ms'); - console.log('Timespan from connected to reading : ' + (tRead - tConn) + ' ms'); + console.log(`Timespan from discovery to connected: ${tConn - tDisco} ms`); + console.log(`Timespan from connected to reading : ${tRead - tConn} ms`); } }); } diff --git a/examples/cache-gatt-reconnect.js b/examples/cache-gatt-reconnect.js index f4869bd13..04916f6ca 100644 --- a/examples/cache-gatt-reconnect.js +++ b/examples/cache-gatt-reconnect.js @@ -35,18 +35,15 @@ let meta = { }; noble.on('discover', function (peripheral) { - console.log('peripheral discovered (' + peripheral.id + - ' with address <' + peripheral.address + ', ' + peripheral.addressType + '>,' + - ' connectable ' + peripheral.connectable + ',' + - ' RSSI ' + peripheral.rssi + ':'); + console.log(`peripheral discovered (${peripheral.id} with address <${peripheral.address}, ${peripheral.addressType}>, connectable ${peripheral.connectable}, RSSI ${peripheral.rssi}:`); console.log('\thello my local name is:'); - console.log('\t\t' + peripheral.advertisement.localName); + console.log(`\t\t${peripheral.advertisement.localName}`); console.log(); // Check if a dump exists in the current directory. fs.access(peripheral.uuid + EXT, fs.constants.F_OK, (err) => { if (!err) { - console.log('found dump file for ' + peripheral.uuid); + console.log(`found dump file for ${peripheral.uuid}`); tDisco = Date.now(); @@ -61,7 +58,7 @@ const quickConnect = function (peripheral) { peripheral.connect((error) => { if (error) { - console.log('Connect error: ' + error); + console.log(`Connect error: ${error}`); noble.startScanning([], true); return; } @@ -83,17 +80,17 @@ const quickConnect = function (peripheral) { sensorCharacteristic.on('data', (data) => { if (BITS === 16) { - console.log(' new ' + CHANNEL + ' ' + (data.readUInt16LE() * FACTOR)); + console.log(` new ${CHANNEL} ${data.readUInt16LE() * FACTOR}`); } else if (BITS === 32) { - console.log(' new ' + CHANNEL + ' ' + (data.readUInt32LE() * FACTOR)); + console.log(` new ${CHANNEL} ${data.readUInt32LE() * FACTOR}`); } else { - console.log(' Cannot cope with BITS value ' + BITS); + console.log(` Cannot cope with BITS value ${BITS}`); } }); sensorCharacteristic.read(); - console.log('Timespan from discovery to connected: ' + (tConn - tDisco) + ' ms'); - console.log('Timespan from connected to reading : ' + (tRead - tConn) + ' ms'); + console.log(`Timespan from discovery to connected: ${tConn - tDisco} ms`); + console.log(`Timespan from connected to reading : ${tRead - tConn} ms`); } }); }; @@ -116,7 +113,7 @@ const setData = function (peripheral, meta) { console.log('initialized services: '); for (const i in services) { const service = services[i]; - console.log('\tservice ' + i + ' ' + service); + console.log(`\tservice ${i} ${service}`); } console.log(); @@ -127,15 +124,15 @@ const setData = function (peripheral, meta) { for (const i in services) { const service = services[i]; const charas = meta.characteristics[service.uuid]; - console.log('\tservice ' + i + ' ' + service + ' ' + JSON.stringify(charas)); + console.log(`\tservice ${i} ${service} ${JSON.stringify(charas)}`); const characteristics = noble.addCharacteristics(peripheral.uuid, service.uuid, charas); for (const j in characteristics) { const characteristic = characteristics[j]; - console.log('\t\tcharac ' + service.uuid + ' ' + j + ' ' + characteristic + ' ' + characteristic.rawProps); + console.log(`\t\tcharac ${service.uuid} ${j} ${characteristic} ${characteristic.rawProps}`); if (characteristic.name === CHANNEL) { - console.log('\t\t\t-->found ' + CHANNEL + ' characteristic!'); + console.log(`\t\t\t-->found ${CHANNEL} characteristic!`); sensorCharacteristic = characteristic; } } diff --git a/examples/echo.js b/examples/echo.js index 09548e3fa..ba9ec160a 100755 --- a/examples/echo.js +++ b/examples/echo.js @@ -52,7 +52,7 @@ function onServicesAndCharacteristicsDiscovered (error, services, characteristic // data callback receives notifications echoCharacteristic.on('data', (data, isNotification) => { - console.log('Received: "' + data + '"'); + console.log(`Received: "${data}"`); }); // subscribe to be notified whenever the peripheral update the characteristic @@ -68,8 +68,8 @@ function onServicesAndCharacteristicsDiscovered (error, services, characteristic let count = 0; setInterval(() => { count++; - const message = Buffer.from('hello, ble ' + count, 'utf-8'); - console.log("Sending: '" + message + "'"); + const message = Buffer.from(`hello, ble ${count}`, 'utf-8'); + console.log(`Sending: '${message}'`); echoCharacteristic.write(message); }, 2500); } diff --git a/examples/enter-exit.js b/examples/enter-exit.js index a2dcf098c..e75ef6d6a 100644 --- a/examples/enter-exit.js +++ b/examples/enter-exit.js @@ -28,7 +28,7 @@ noble.on('discover', function (peripheral) { peripheral: peripheral }; - console.log('"' + peripheral.advertisement.localName + '" entered (RSSI ' + peripheral.rssi + ') ' + new Date()); + console.log(`"${peripheral.advertisement.localName}" entered (RSSI ${peripheral.rssi}) ${new Date()}`); } inRange[id].lastSeen = Date.now(); @@ -39,7 +39,7 @@ setInterval(function () { if (inRange[id].lastSeen < (Date.now() - EXIT_GRACE_PERIOD)) { const peripheral = inRange[id].peripheral; - console.log('"' + peripheral.advertisement.localName + '" exited (RSSI ' + peripheral.rssi + ') ' + new Date()); + console.log(`"${peripheral.advertisement.localName}" exited (RSSI ${peripheral.rssi}) ${new Date()}`); delete inRange[id]; } diff --git a/examples/peripheral-explorer.js b/examples/peripheral-explorer.js index d21aa96a3..c41f9dff4 100644 --- a/examples/peripheral-explorer.js +++ b/examples/peripheral-explorer.js @@ -16,7 +16,7 @@ noble.on('discover', function (peripheral) { if (peripheral.id === peripheralIdOrAddress || peripheral.address === peripheralIdOrAddress) { noble.stopScanning(); - console.log('peripheral with ID ' + peripheral.id + ' found'); + console.log(`peripheral with ID ${peripheral.id} found`); const advertisement = peripheral.advertisement; const localName = advertisement.localName; @@ -26,23 +26,23 @@ noble.on('discover', function (peripheral) { const serviceUuids = advertisement.serviceUuids; if (localName) { - console.log(' Local Name = ' + localName); + console.log(` Local Name = ${localName}`); } if (txPowerLevel) { - console.log(' TX Power Level = ' + txPowerLevel); + console.log(` TX Power Level = ${txPowerLevel}`); } if (manufacturerData) { - console.log(' Manufacturer Data = ' + manufacturerData.toString('hex')); + console.log(` Manufacturer Data = ${manufacturerData.toString('hex')}`); } if (serviceData) { - console.log(' Service Data = ' + JSON.stringify(serviceData, null, 2)); + console.log(` Service Data = ${JSON.stringify(serviceData, null, 2)}`); } if (serviceUuids) { - console.log(' Service UUIDs = ' + serviceUuids); + console.log(` Service UUIDs = ${serviceUuids}`); } console.log(); @@ -71,7 +71,7 @@ function explore (peripheral) { let serviceInfo = service.uuid; if (service.name) { - serviceInfo += ' (' + service.name + ')'; + serviceInfo += ` (${service.name})`; } console.log(serviceInfo); @@ -84,10 +84,10 @@ function explore (peripheral) { }, function (callback) { const characteristic = characteristics[characteristicIndex]; - let characteristicInfo = ' ' + characteristic.uuid; + let characteristicInfo = ` ${characteristic.uuid}`; if (characteristic.name) { - characteristicInfo += ' (' + characteristic.name + ')'; + characteristicInfo += ` (${characteristic.name})`; } async.series([ @@ -106,7 +106,7 @@ function explore (peripheral) { if (userDescriptionDescriptor) { userDescriptionDescriptor.readValue(function (error, data) { if (data) { - characteristicInfo += ' (' + data.toString() + ')'; + characteristicInfo += ` (${data.toString()})`; } callback(); }); @@ -118,14 +118,14 @@ function explore (peripheral) { }); }, function (callback) { - characteristicInfo += '\n properties ' + characteristic.properties.join(', '); + characteristicInfo += `\n properties ${characteristic.properties.join(', ')}`; if (characteristic.properties.indexOf('read') !== -1) { characteristic.read(function (error, data) { if (data) { const string = data.toString('ascii'); - characteristicInfo += '\n value ' + data.toString('hex') + ' | \'' + string + '\''; + characteristicInfo += `\n value ${data.toString('hex')} | '${string}'`; } callback(); }); diff --git a/lib/hci-socket/bindings.js b/lib/hci-socket/bindings.js index d7ac2e9e3..d22ed978d 100644 --- a/lib/hci-socket/bindings.js +++ b/lib/hci-socket/bindings.js @@ -229,7 +229,7 @@ NobleBindings.prototype.onLeConnComplete = function (status, handle, role, addre } else { uuid = this._pendingConnectionUuid; let statusMessage = Hci.STATUS_MAPPER[status] || 'HCI Error: Unknown'; - const errorCode = ' (0x' + status.toString(16) + ')'; + const errorCode = ` (0x${status.toString(16)})`; statusMessage = statusMessage + errorCode; error = new Error(statusMessage); } @@ -273,7 +273,7 @@ NobleBindings.prototype.onDisconnComplete = function (handle, reason) { this.emit('disconnect', uuid); // TODO: handle reason? } else { - console.warn('noble warning: unknown handle ' + handle + ' disconnected!'); + console.warn(`noble warning: unknown handle ${handle} disconnected!`); } }; @@ -310,7 +310,7 @@ NobleBindings.prototype.addService = function (peripheralUuid, service) { if (gatt) { gatt.addService(service); } else { - console.warn('noble warning: unknown peripheral ' + peripheralUuid); + console.warn(`noble warning: unknown peripheral ${peripheralUuid}`); } }; @@ -321,7 +321,7 @@ NobleBindings.prototype.discoverServices = function (peripheralUuid, uuids) { if (gatt) { gatt.discoverServices(uuids || []); } else { - console.warn('noble warning: unknown peripheral ' + peripheralUuid); + console.warn(`noble warning: unknown peripheral ${peripheralUuid}`); } }; @@ -344,7 +344,7 @@ NobleBindings.prototype.discoverIncludedServices = function (peripheralUuid, ser if (gatt) { gatt.discoverIncludedServices(serviceUuid, serviceUuids || []); } else { - console.warn('noble warning: unknown peripheral ' + peripheralUuid); + console.warn(`noble warning: unknown peripheral ${peripheralUuid}`); } }; @@ -361,7 +361,7 @@ NobleBindings.prototype.addCharacteristics = function (peripheralUuid, serviceUu if (gatt) { gatt.addCharacteristics(serviceUuid, characteristics); } else { - console.warn('noble warning: unknown peripheral ' + peripheralUuid); + console.warn(`noble warning: unknown peripheral ${peripheralUuid}`); } }; @@ -372,7 +372,7 @@ NobleBindings.prototype.discoverCharacteristics = function (peripheralUuid, serv if (gatt) { gatt.discoverCharacteristics(serviceUuid, characteristicUuids || []); } else { - console.warn('noble warning: unknown peripheral ' + peripheralUuid); + console.warn(`noble warning: unknown peripheral ${peripheralUuid}`); } }; @@ -395,7 +395,7 @@ NobleBindings.prototype.read = function (peripheralUuid, serviceUuid, characteri if (gatt) { gatt.read(serviceUuid, characteristicUuid); } else { - console.warn('noble warning: unknown peripheral ' + peripheralUuid); + console.warn(`noble warning: unknown peripheral ${peripheralUuid}`); } }; @@ -412,7 +412,7 @@ NobleBindings.prototype.write = function (peripheralUuid, serviceUuid, character if (gatt) { gatt.write(serviceUuid, characteristicUuid, data, withoutResponse); } else { - console.warn('noble warning: unknown peripheral ' + peripheralUuid); + console.warn(`noble warning: unknown peripheral ${peripheralUuid}`); } }; @@ -429,7 +429,7 @@ NobleBindings.prototype.broadcast = function (peripheralUuid, serviceUuid, chara if (gatt) { gatt.broadcast(serviceUuid, characteristicUuid, broadcast); } else { - console.warn('noble warning: unknown peripheral ' + peripheralUuid); + console.warn(`noble warning: unknown peripheral ${peripheralUuid}`); } }; @@ -446,7 +446,7 @@ NobleBindings.prototype.notify = function (peripheralUuid, serviceUuid, characte if (gatt) { gatt.notify(serviceUuid, characteristicUuid, notify); } else { - console.warn('noble warning: unknown peripheral ' + peripheralUuid); + console.warn(`noble warning: unknown peripheral ${peripheralUuid}`); } }; @@ -469,7 +469,7 @@ NobleBindings.prototype.discoverDescriptors = function (peripheralUuid, serviceU if (gatt) { gatt.discoverDescriptors(serviceUuid, characteristicUuid); } else { - console.warn('noble warning: unknown peripheral ' + peripheralUuid); + console.warn(`noble warning: unknown peripheral ${peripheralUuid}`); } }; @@ -486,7 +486,7 @@ NobleBindings.prototype.readValue = function (peripheralUuid, serviceUuid, chara if (gatt) { gatt.readValue(serviceUuid, characteristicUuid, descriptorUuid); } else { - console.warn('noble warning: unknown peripheral ' + peripheralUuid); + console.warn(`noble warning: unknown peripheral ${peripheralUuid}`); } }; @@ -503,7 +503,7 @@ NobleBindings.prototype.writeValue = function (peripheralUuid, serviceUuid, char if (gatt) { gatt.writeValue(serviceUuid, characteristicUuid, descriptorUuid, data); } else { - console.warn('noble warning: unknown peripheral ' + peripheralUuid); + console.warn(`noble warning: unknown peripheral ${peripheralUuid}`); } }; @@ -520,7 +520,7 @@ NobleBindings.prototype.readHandle = function (peripheralUuid, attHandle) { if (gatt) { gatt.readHandle(attHandle); } else { - console.warn('noble warning: unknown peripheral ' + peripheralUuid); + console.warn(`noble warning: unknown peripheral ${peripheralUuid}`); } }; @@ -537,7 +537,7 @@ NobleBindings.prototype.writeHandle = function (peripheralUuid, attHandle, data, if (gatt) { gatt.writeHandle(attHandle, data, withoutResponse); } else { - console.warn('noble warning: unknown peripheral ' + peripheralUuid); + console.warn(`noble warning: unknown peripheral ${peripheralUuid}`); } }; diff --git a/lib/hci-socket/gap.js b/lib/hci-socket/gap.js index 8339f1657..7849b8a50 100644 --- a/lib/hci-socket/gap.js +++ b/lib/hci-socket/gap.js @@ -133,7 +133,7 @@ Gap.prototype.onHciLeAdvertisingReport = function (status, type, address, addres var length = eir.readUInt8(i); if (length < 1) { - debug('invalid EIR data, length = ' + length); + debug(`invalid EIR data, length = ${length}`); break; } @@ -241,7 +241,7 @@ Gap.prototype.onHciLeAdvertisingReport = function (status, type, address, addres i += (length + 1); } - debug('advertisement = ' + JSON.stringify(advertisement, null, 0)); + debug(`advertisement = ${JSON.stringify(advertisement, null, 0)}`); const connectable = (type === 0x04 && previouslyDiscovered) ? this._discoveries[address].connectable : (type !== 0x03); diff --git a/lib/hci-socket/gatt.js b/lib/hci-socket/gatt.js index 7539527ea..2df7d1022 100644 --- a/lib/hci-socket/gatt.js +++ b/lib/hci-socket/gatt.js @@ -90,13 +90,13 @@ Gatt.prototype.onAclStreamData = function (cid, data) { } if (this._currentCommand && data.toString('hex') === this._currentCommand.buffer.toString('hex')) { - debug(this._address + ': echo ... echo ... echo ...'); + debug(`${this._address}: echo ... echo ... echo ...`); } else if (data[0] % 2 === 0) { if (process.env.NOBLE_MULTI_ROLE) { - debug(this._address + ': multi-role flag in use, ignoring command meant for peripheral role.'); + debug(`${this._address}: multi-role flag in use, ignoring command meant for peripheral role.`); } else { const requestType = data[0]; - debug(this._address + ': replying with REQ_NOT_SUPP to 0x' + requestType.toString(16)); + debug(`${this._address}: replying with REQ_NOT_SUPP to 0x${requestType.toString(16)}`); this.writeAtt(this.errorResponse(requestType, 0x0000, ATT_ECODE_REQ_NOT_SUPP)); } } else if (data[0] === ATT_OP_HANDLE_NOTIFY || data[0] === ATT_OP_HANDLE_IND) { @@ -119,7 +119,7 @@ Gatt.prototype.onAclStreamData = function (cid, data) { } } } else if (!this._currentCommand) { - debug(this._address + ': uh oh, no current command'); + debug(`${this._address}: uh oh, no current command`); } else { if (data[0] === ATT_OP_ERROR && (data[4] === ATT_ECODE_AUTHENTICATION || data[4] === ATT_ECODE_AUTHORIZATION || data[4] === ATT_ECODE_INSUFF_ENC) && @@ -128,7 +128,7 @@ Gatt.prototype.onAclStreamData = function (cid, data) { return; } - debug(this._address + ': read: ' + data.toString('hex')); + debug(`${this._address}: read: ${data.toString('hex')}`); this._currentCommand.callback(data); @@ -170,7 +170,7 @@ Gatt.prototype.onAclStreamEnd = function () { }; Gatt.prototype.writeAtt = function (data) { - debug(this._address + ': write: ' + data.toString('hex')); + debug(`${this._address}: write: ${data.toString('hex')}`); this._aclStream.write(ATT_CID, data); }; @@ -321,7 +321,7 @@ Gatt.prototype.exchangeMtu = function (mtu) { if (opcode === ATT_OP_MTU_RESP) { const newMtu = data.readUInt16LE(1); - debug(this._address + ': new MTU is ' + newMtu); + debug(`${this._address}: new MTU is ${newMtu}`); this._mtu = newMtu; } @@ -529,7 +529,7 @@ Gatt.prototype.read = function (serviceUuid, characteristicUuid) { const opcode = data[0]; if (opcode === ATT_OP_READ_RESP || opcode === ATT_OP_READ_BLOB_RESP) { - readData = Buffer.from(readData.toString('hex') + data.slice(1).toString('hex'), 'hex'); + readData = Buffer.from(`${readData.toString('hex')}${data.slice(1).toString('hex')}`, 'hex'); if (data.length === this._mtu) { this._queueCommand(this.readBlobRequest(characteristic.valueHandle, readData.length), callback); @@ -574,13 +574,13 @@ Gatt.prototype.longWrite = function (serviceUuid, characteristicUuid, data, with const opcode = resp[0]; if (opcode !== ATT_OP_PREPARE_WRITE_RESP) { - debug(this._address + ': unexpected reply opcode %d (expecting ATT_OP_PREPARE_WRITE_RESP)', opcode); + debug(`${this._address}: unexpected reply opcode %d (expecting ATT_OP_PREPARE_WRITE_RESP)`, opcode); } else { const expectedLength = dataChunk.length + 5; if (resp.length !== expectedLength) { /* the response should contain the data packet echoed back to the caller */ - debug(this._address + ': unexpected prepareWriteResponse length %d (expecting %d)', resp.length, expectedLength); + debug(`${this._address}: unexpected prepareWriteResponse length %d (expecting %d)`, resp.length, expectedLength); } } }; diff --git a/lib/hci-socket/hci.js b/lib/hci-socket/hci.js index ed95b622b..766478df6 100644 --- a/lib/hci-socket/hci.js +++ b/lib/hci-socket/hci.js @@ -144,7 +144,7 @@ Hci.prototype.setSocketFilter = function () { filter.writeUInt32LE(eventMask2, 8); filter.writeUInt16LE(opcode, 12); - debug('setting filter to: ' + filter.toString('hex')); + debug(`setting filter to: ${filter.toString('hex')}`); this._socket.setFilter(filter); }; @@ -161,7 +161,7 @@ Hci.prototype.setEventMask = function () { eventMask.copy(cmd, 4); - debug('set event mask - writing: ' + cmd.toString('hex')); + debug(`set event mask - writing: ${cmd.toString('hex')}`); this._socket.write(cmd); }; @@ -175,7 +175,7 @@ Hci.prototype.reset = function () { // length cmd.writeUInt8(0x00, 3); - debug('reset - writing: ' + cmd.toString('hex')); + debug(`reset - writing: ${cmd.toString('hex')}`); this._socket.write(cmd); }; @@ -189,7 +189,7 @@ Hci.prototype.readLocalVersion = function () { // length cmd.writeUInt8(0x0, 3); - debug('read local version - writing: ' + cmd.toString('hex')); + debug(`read local version - writing: ${cmd.toString('hex')}`); this._socket.write(cmd); }; @@ -203,7 +203,7 @@ Hci.prototype.readBdAddr = function () { // length cmd.writeUInt8(0x0, 3); - debug('read bd addr - writing: ' + cmd.toString('hex')); + debug(`read bd addr - writing: ${cmd.toString('hex')}`); this._socket.write(cmd); }; @@ -220,7 +220,7 @@ Hci.prototype.setLeEventMask = function () { leEventMask.copy(cmd, 4); - debug('set le event mask - writing: ' + cmd.toString('hex')); + debug(`set le event mask - writing: ${cmd.toString('hex')}`); this._socket.write(cmd); }; @@ -234,7 +234,7 @@ Hci.prototype.readLeHostSupported = function () { // length cmd.writeUInt8(0x00, 3); - debug('read LE host supported - writing: ' + cmd.toString('hex')); + debug(`read LE host supported - writing: ${cmd.toString('hex')}`); this._socket.write(cmd); }; @@ -252,7 +252,7 @@ Hci.prototype.writeLeHostSupported = function () { cmd.writeUInt8(0x01, 4); // le cmd.writeUInt8(0x00, 5); // simul - debug('write LE host supported - writing: ' + cmd.toString('hex')); + debug(`write LE host supported - writing: ${cmd.toString('hex')}`); this._socket.write(cmd); }; @@ -276,7 +276,7 @@ Hci.prototype.setScanParameters = function (interval, window) { cmd.writeUInt8(0x00, 9); // own address type: 0 -> public, 1 -> random cmd.writeUInt8(0x00, 10); // filter: 0 -> all event types - debug('set scan parameters - writing: ' + cmd.toString('hex')); + debug(`set scan parameters - writing: ${cmd.toString('hex')}`); this._socket.write(cmd); }; @@ -294,7 +294,7 @@ Hci.prototype.setScanEnabled = function (enabled, filterDuplicates) { cmd.writeUInt8(enabled ? 0x01 : 0x00, 4); // enable: 0 -> disabled, 1 -> enabled cmd.writeUInt8(filterDuplicates ? 0x01 : 0x00, 5); // duplicates: 0 -> duplicates, 0 -> duplicates - debug('set scan enabled - writing: ' + cmd.toString('hex')); + debug(`set scan enabled - writing: ${cmd.toString('hex')}`); this._socket.write(cmd); }; @@ -330,7 +330,7 @@ Hci.prototype.createLeConn = function (address, addressType, parameters) { cmd.writeUInt16LE(0x0004, 25); // min ce length cmd.writeUInt16LE(0x0006, 27); // max ce length - debug('create le conn - writing: ' + cmd.toString('hex')); + debug(`create le conn - writing: ${cmd.toString('hex')}`); this._socket.write(cmd); }; @@ -353,7 +353,7 @@ Hci.prototype.connUpdateLe = function (handle, minInterval, maxInterval, latency cmd.writeUInt16LE(0x0000, 14); // min ce length cmd.writeUInt16LE(0x0000, 16); // max ce length - debug('conn update le - writing: ' + cmd.toString('hex')); + debug(`conn update le - writing: ${cmd.toString('hex')}`); this._socket.write(cmd); }; @@ -387,7 +387,7 @@ Hci.prototype.startLeEncryption = function (handle, random, diversifier, key) { diversifier.copy(cmd, 14); key.copy(cmd, 16); - debug('start le encryption - writing: ' + cmd.toString('hex')); + debug(`start le encryption - writing: ${cmd.toString('hex')}`); this._socket.write(cmd); }; @@ -407,7 +407,7 @@ Hci.prototype.disconnect = function (handle, reason) { cmd.writeUInt16LE(handle, 4); // handle cmd.writeUInt8(reason, 6); // reason - debug('disconnect - writing: ' + cmd.toString('hex')); + debug(`disconnect - writing: ${cmd.toString('hex')}`); this._socket.write(cmd); }; @@ -424,7 +424,7 @@ Hci.prototype.readRssi = function (handle) { // data cmd.writeUInt16LE(handle, 4); // handle - debug('read rssi - writing: ' + cmd.toString('hex')); + debug(`read rssi - writing: ${cmd.toString('hex')}`); this._socket.write(cmd); }; @@ -440,39 +440,39 @@ Hci.prototype.writeAclDataPkt = function (handle, cid, data) { data.copy(pkt, 9); - debug('write acl data pkt - writing: ' + pkt.toString('hex')); + debug(`write acl data pkt - writing: ${pkt.toString('hex')}`); this._socket.write(pkt); }; Hci.prototype.onSocketData = function (data) { - debug('onSocketData: ' + data.toString('hex')); + debug(`onSocketData: ${data.toString('hex')}`); const eventType = data.readUInt8(0); let handle; let cmd; let status; - debug('\tevent type = ' + eventType); + debug(`\tevent type = ${eventType}`); if (HCI_EVENT_PKT === eventType) { const subEventType = data.readUInt8(1); - debug('\tsub event type = ' + subEventType); + debug(`\tsub event type = ${subEventType}`); if (subEventType === EVT_DISCONN_COMPLETE) { handle = data.readUInt16LE(4); const reason = data.readUInt8(6); - debug('\t\thandle = ' + handle); - debug('\t\treason = ' + reason); + debug(`\t\thandle = ${handle}`); + debug(`\t\treason = ${reason}`); this.emit('disconnComplete', handle, reason); } else if (subEventType === EVT_ENCRYPT_CHANGE) { handle = data.readUInt16LE(4); const encrypt = data.readUInt8(6); - debug('\t\thandle = ' + handle); - debug('\t\tencrypt = ' + encrypt); + debug(`\t\thandle = ${handle}`); + debug(`\t\tencrypt = ${encrypt}`); this.emit('encryptChange', handle, encrypt); } else if (subEventType === EVT_CMD_COMPLETE) { @@ -480,17 +480,17 @@ Hci.prototype.onSocketData = function (data) { status = data.readUInt8(6); const result = data.slice(7); - debug('\t\tcmd = ' + cmd); - debug('\t\tstatus = ' + status); - debug('\t\tresult = ' + result.toString('hex')); + debug(`\t\tcmd = ${cmd}`); + debug(`\t\tstatus = ${status}`); + debug(`\t\tresult = ${result.toString('hex')}`); this.processCmdCompleteEvent(cmd, status, result); } else if (subEventType === EVT_CMD_STATUS) { status = data.readUInt8(3); cmd = data.readUInt16LE(5); - debug('\t\tstatus = ' + status); - debug('\t\tcmd = ' + cmd); + debug(`\t\tstatus = ${status}`); + debug(`\t\tcmd = ${cmd}`); this.processCmdStatusEvent(cmd, status); } else if (subEventType === EVT_LE_META_EVENT) { @@ -498,9 +498,9 @@ Hci.prototype.onSocketData = function (data) { const leMetaEventStatus = data.readUInt8(4); const leMetaEventData = data.slice(5); - debug('\t\tLE meta event type = ' + leMetaEventType); - debug('\t\tLE meta event status = ' + leMetaEventStatus); - debug('\t\tLE meta event data = ' + leMetaEventData.toString('hex')); + debug(`\t\tLE meta event type = ${leMetaEventType}`); + debug(`\t\tLE meta event status = ${leMetaEventStatus}`); + debug(`\t\tLE meta event data = ${leMetaEventData.toString('hex')}`); this.processLeMetaEvent(leMetaEventType, leMetaEventStatus, leMetaEventData); } @@ -514,11 +514,11 @@ Hci.prototype.onSocketData = function (data) { var length = data.readUInt16LE(5); const pktData = data.slice(9); - debug('\t\tcid = ' + cid); + debug(`\t\tcid = ${cid}`); if (length === pktData.length) { - debug('\t\thandle = ' + handle); - debug('\t\tdata = ' + pktData.toString('hex')); + debug(`\t\thandle = ${handle}`); + debug(`\t\tdata = ${pktData.toString('hex')}`); this.emit('aclDataPkt', handle, cid, pktData); } else { @@ -548,16 +548,16 @@ Hci.prototype.onSocketData = function (data) { cmd = data.readUInt16LE(1); const len = data.readUInt8(3); - debug('\t\tcmd = ' + cmd); - debug('\t\tdata len = ' + len); + debug(`\t\tcmd = ${cmd}`); + debug(`\t\tdata len = ${len}`); if (cmd === LE_SET_SCAN_ENABLE_CMD) { const enable = (data.readUInt8(4) === 0x1); const filterDuplicates = (data.readUInt8(5) === 0x1); debug('\t\t\tLE enable scan command'); - debug('\t\t\tenable scanning = ' + enable); - debug('\t\t\tfilter duplicates = ' + filterDuplicates); + debug(`\t\t\tenable scanning = ${enable}`); + debug(`\t\t\tfilter duplicates = ${filterDuplicates}`); this.emit('leScanEnableSetCmd', enable, filterDuplicates); } @@ -565,7 +565,7 @@ Hci.prototype.onSocketData = function (data) { }; Hci.prototype.onSocketError = function (error) { - debug('onSocketError: ' + error.message); + debug(`onSocketError: ${error.message}`); if (error.message === 'Operation not permitted') { this.emit('stateChange', 'unauthorized'); @@ -585,8 +585,8 @@ Hci.prototype.processCmdCompleteEvent = function (cmd, status, result) { const le = result.readUInt8(0); const simul = result.readUInt8(1); - debug('\t\t\tle = ' + le); - debug('\t\t\tsimul = ' + simul); + debug(`\t\t\tle = ${le}`); + debug(`\t\t\tsimul = ${simul}`); } } else if (cmd === READ_LOCAL_VERSION_CMD) { const hciVer = result.readUInt8(0); @@ -607,7 +607,7 @@ Hci.prototype.processCmdCompleteEvent = function (cmd, status, result) { this.addressType = 'public'; this.address = result.toString('hex').match(/.{1,2}/g).reverse().join(':'); - debug('address = ' + this.address); + debug(`address = ${this.address}`); this.emit('addressChange', this.address); } else if (cmd === LE_SET_SCAN_PARAMETERS_CMD) { @@ -620,8 +620,8 @@ Hci.prototype.processCmdCompleteEvent = function (cmd, status, result) { const handle = result.readUInt16LE(0); const rssi = result.readInt8(2); - debug('\t\t\thandle = ' + handle); - debug('\t\t\trssi = ' + rssi); + debug(`\t\t\thandle = ${handle}`); + debug(`\t\t\trssi = ${rssi}`); this.emit('rssiRead', handle, rssi); } @@ -647,14 +647,14 @@ Hci.prototype.processLeConnComplete = function (status, data) { const supervisionTimeout = data.readUInt16LE(14) * 10; const masterClockAccuracy = data.readUInt8(16); // TODO: multiplier? - debug('\t\t\thandle = ' + handle); - debug('\t\t\trole = ' + role); - debug('\t\t\taddress type = ' + addressType); - debug('\t\t\taddress = ' + address); - debug('\t\t\tinterval = ' + interval); - debug('\t\t\tlatency = ' + latency); - debug('\t\t\tsupervision timeout = ' + supervisionTimeout); - debug('\t\t\tmaster clock accuracy = ' + masterClockAccuracy); + debug(`\t\t\thandle = ${handle}`); + debug(`\t\t\trole = ${role}`); + debug(`\t\t\taddress type = ${addressType}`); + debug(`\t\t\taddress = ${address}`); + debug(`\t\t\tinterval = ${interval}`); + debug(`\t\t\tlatency = ${latency}`); + debug(`\t\t\tsupervision timeout = ${supervisionTimeout}`); + debug(`\t\t\tmaster clock accuracy = ${masterClockAccuracy}`); this.emit('leConnComplete', status, handle, role, addressType, address, interval, latency, supervisionTimeout, masterClockAccuracy); }; @@ -669,18 +669,18 @@ Hci.prototype.processLeAdvertisingReport = function (count, data) { const eir = data.slice(9, eirLength + 9); const rssi = data.readInt8(eirLength + 9); - debug('\t\t\ttype = ' + type); - debug('\t\t\taddress = ' + address); - debug('\t\t\taddress type = ' + addressType); - debug('\t\t\teir = ' + eir.toString('hex')); - debug('\t\t\trssi = ' + rssi); + debug(`\t\t\ttype = ${type}`); + debug(`\t\t\taddress = ${address}`); + debug(`\t\t\taddress type = ${addressType}`); + debug(`\t\t\teir = ${eir.toString('hex')}`); + debug(`\t\t\trssi = ${rssi}`); this.emit('leAdvertisingReport', 0, type, address, addressType, eir, rssi); data = data.slice(eirLength + 10); } } catch (e) { - console.warn('processLeAdvertisingReport: Caught illegal packet (buffer overflow): ' + e); + console.warn(`processLeAdvertisingReport: Caught illegal packet (buffer overflow): ${e}`); } }; @@ -690,10 +690,10 @@ Hci.prototype.processLeConnUpdateComplete = function (status, data) { const latency = data.readUInt16LE(4); // TODO: multiplier? const supervisionTimeout = data.readUInt16LE(6) * 10; - debug('\t\t\thandle = ' + handle); - debug('\t\t\tinterval = ' + interval); - debug('\t\t\tlatency = ' + latency); - debug('\t\t\tsupervision timeout = ' + supervisionTimeout); + debug(`\t\t\thandle = ${handle}`); + debug(`\t\t\tinterval = ${interval}`); + debug(`\t\t\tlatency = ${latency}`); + debug(`\t\t\tsupervision timeout = ${supervisionTimeout}`); this.emit('leConnUpdateComplete', status, handle, interval, latency, supervisionTimeout); }; diff --git a/lib/hci-socket/signaling.js b/lib/hci-socket/signaling.js index dc3d06c93..728c2b552 100644 --- a/lib/hci-socket/signaling.js +++ b/lib/hci-socket/signaling.js @@ -27,16 +27,16 @@ Signaling.prototype.onAclStreamData = function (cid, data) { return; } - debug('onAclStreamData: ' + data.toString('hex')); + debug(`onAclStreamData: ${data.toString('hex')}`); const code = data.readUInt8(0); const identifier = data.readUInt8(1); const length = data.readUInt16LE(2); const signalingData = data.slice(4); - debug('\tcode = ' + code); - debug('\tidentifier = ' + identifier); - debug('\tlength = ' + length); + debug(`\tcode = ${code}`); + debug(`\tidentifier = ${identifier}`); + debug(`\tlength = ${length}`); if (code === CONNECTION_PARAMETER_UPDATE_REQUEST) { this.processConnectionParameterUpdateRequest(identifier, signalingData); diff --git a/lib/noble.js b/lib/noble.js index 2141016fe..293fa988a 100644 --- a/lib/noble.js +++ b/lib/noble.js @@ -48,7 +48,7 @@ function Noble (bindings) { this.on('warning', (message) => { if (this.listeners('warning').length === 1) { - console.warn('noble: ' + message); + console.warn(`noble: ${message}`); } }); @@ -81,7 +81,7 @@ function Noble (bindings) { util.inherits(Noble, events.EventEmitter); Noble.prototype.onStateChange = function (state) { - debug('stateChange ' + state); + debug(`stateChange ${state}`); this._state = state; @@ -89,7 +89,7 @@ Noble.prototype.onStateChange = function (state) { }; Noble.prototype.onAddressChange = function (address) { - debug('addressChange ' + address); + debug(`addressChange ${address}`); this.address = address; }; @@ -109,7 +109,7 @@ Noble.prototype.onScanParametersSet = function () { Noble.prototype.startScanning = function (serviceUuids, allowDuplicates, callback) { const scan = function (state) { if (state !== 'poweredOn') { - const error = new Error('Could not start scanning, state is ' + state + ' (not poweredOn)'); + const error = new Error(`Could not start scanning, state is ${state} (not poweredOn)`); if (typeof callback === 'function') { callback(error); @@ -205,7 +205,7 @@ Noble.prototype.onConnect = function (peripheralUuid, error) { peripheral.state = error ? 'error' : 'connected'; peripheral.emit('connect', error); } else { - this.emit('warning', 'unknown peripheral ' + peripheralUuid + ' connected!'); + this.emit('warning', `unknown peripheral ${peripheralUuid} connected!`); } }; @@ -224,7 +224,7 @@ Noble.prototype.onDisconnect = function (peripheralUuid) { peripheral.state = 'disconnected'; peripheral.emit('disconnect'); } else { - this.emit('warning', 'unknown peripheral ' + peripheralUuid + ' disconnected!'); + this.emit('warning', `unknown peripheral ${peripheralUuid} disconnected!`); } }; @@ -240,7 +240,7 @@ Noble.prototype.onRssiUpdate = function (peripheralUuid, rssi) { peripheral.emit('rssiUpdate', rssi); } else { - this.emit('warning', 'unknown peripheral ' + peripheralUuid + ' RSSI update!'); + this.emit('warning', `unknown peripheral ${peripheralUuid} RSSI update!`); } }; @@ -309,7 +309,7 @@ Noble.prototype.onServicesDiscover = function (peripheralUuid, serviceUuids) { peripheral.emit('servicesDiscover', services); } else { - this.emit('warning', 'unknown peripheral ' + peripheralUuid + ' services discover!'); + this.emit('warning', `unknown peripheral ${peripheralUuid} services discover!`); } }; @@ -325,7 +325,7 @@ Noble.prototype.onIncludedServicesDiscover = function (peripheralUuid, serviceUu service.emit('includedServicesDiscover', includedServiceUuids); } else { - this.emit('warning', 'unknown peripheral ' + peripheralUuid + ', ' + serviceUuid + ' included services discover!'); + this.emit('warning', `unknown peripheral ${peripheralUuid}, ${serviceUuid} included services discover!`); } }; @@ -336,7 +336,7 @@ Noble.prototype.addCharacteristics = function (peripheralUuid, serviceUuid, char const service = this._services[peripheralUuid][serviceUuid]; if (!service) { - this.emit('warning', 'unknown service ' + peripheralUuid + ', ' + serviceUuid + ' characteristics discover!'); + this.emit('warning', `unknown service ${peripheralUuid}, ${serviceUuid} characteristics discover!`); return; } @@ -398,7 +398,7 @@ Noble.prototype.onCharacteristicsDiscover = function (peripheralUuid, serviceUui service.emit('characteristicsDiscover', characteristics_); } else { - this.emit('warning', 'unknown peripheral ' + peripheralUuid + ', ' + serviceUuid + ' characteristics discover!'); + this.emit('warning', `unknown peripheral ${peripheralUuid}, ${serviceUuid} characteristics discover!`); } }; @@ -414,7 +414,7 @@ Noble.prototype.onRead = function (peripheralUuid, serviceUuid, characteristicUu characteristic.emit('read', data, isNotification); // for backwards compatbility } else { - this.emit('warning', 'unknown peripheral ' + peripheralUuid + ', ' + serviceUuid + ', ' + characteristicUuid + ' read!'); + this.emit('warning', `unknown peripheral ${peripheralUuid}, ${serviceUuid}, ${characteristicUuid} read!`); } }; @@ -428,7 +428,7 @@ Noble.prototype.onWrite = function (peripheralUuid, serviceUuid, characteristicU if (characteristic) { characteristic.emit('write'); } else { - this.emit('warning', 'unknown peripheral ' + peripheralUuid + ', ' + serviceUuid + ', ' + characteristicUuid + ' write!'); + this.emit('warning', `unknown peripheral ${peripheralUuid}, ${serviceUuid}, ${characteristicUuid} write!`); } }; @@ -442,7 +442,7 @@ Noble.prototype.onBroadcast = function (peripheralUuid, serviceUuid, characteris if (characteristic) { characteristic.emit('broadcast', state); } else { - this.emit('warning', 'unknown peripheral ' + peripheralUuid + ', ' + serviceUuid + ', ' + characteristicUuid + ' broadcast!'); + this.emit('warning', `unknown peripheral ${peripheralUuid}, ${serviceUuid}, ${characteristicUuid} broadcast!`); } }; @@ -456,7 +456,7 @@ Noble.prototype.onNotify = function (peripheralUuid, serviceUuid, characteristic if (characteristic) { characteristic.emit('notify', state); } else { - this.emit('warning', 'unknown peripheral ' + peripheralUuid + ', ' + serviceUuid + ', ' + characteristicUuid + ' notify!'); + this.emit('warning', `unknown peripheral ${peripheralUuid}, ${serviceUuid}, ${characteristicUuid} notify!`); } }; @@ -490,7 +490,7 @@ Noble.prototype.onDescriptorsDiscover = function (peripheralUuid, serviceUuid, c characteristic.emit('descriptorsDiscover', descriptors_); } else { - this.emit('warning', 'unknown peripheral ' + peripheralUuid + ', ' + serviceUuid + ', ' + characteristicUuid + ' descriptors discover!'); + this.emit('warning', `unknown peripheral ${peripheralUuid}, ${serviceUuid}, ${characteristicUuid} descriptors discover!`); } }; @@ -504,7 +504,7 @@ Noble.prototype.onValueRead = function (peripheralUuid, serviceUuid, characteris if (descriptor) { descriptor.emit('valueRead', data); } else { - this.emit('warning', 'unknown peripheral ' + peripheralUuid + ', ' + serviceUuid + ', ' + characteristicUuid + ', ' + descriptorUuid + ' value read!'); + this.emit('warning', `unknown peripheral ${peripheralUuid}, ${serviceUuid}, ${characteristicUuid}, ${descriptorUuid} value read!`); } }; @@ -518,7 +518,7 @@ Noble.prototype.onValueWrite = function (peripheralUuid, serviceUuid, characteri if (descriptor) { descriptor.emit('valueWrite'); } else { - this.emit('warning', 'unknown peripheral ' + peripheralUuid + ', ' + serviceUuid + ', ' + characteristicUuid + ', ' + descriptorUuid + ' value write!'); + this.emit('warning', `unknown peripheral ${peripheralUuid}, ${serviceUuid}, ${characteristicUuid}, ${descriptorUuid} value write!`); } }; @@ -530,9 +530,9 @@ Noble.prototype.onHandleRead = function (peripheralUuid, handle, data) { const peripheral = this._peripherals[peripheralUuid]; if (peripheral) { - peripheral.emit('handleRead' + handle, data); + peripheral.emit(`handleRead${handle}`, data); } else { - this.emit('warning', 'unknown peripheral ' + peripheralUuid + ' handle read!'); + this.emit('warning', `unknown peripheral ${peripheralUuid} handle read!`); } }; @@ -544,9 +544,9 @@ Noble.prototype.onHandleWrite = function (peripheralUuid, handle) { const peripheral = this._peripherals[peripheralUuid]; if (peripheral) { - peripheral.emit('handleWrite' + handle); + peripheral.emit(`handleWrite${handle}`); } else { - this.emit('warning', 'unknown peripheral ' + peripheralUuid + ' handle write!'); + this.emit('warning', `unknown peripheral ${peripheralUuid} handle write!`); } }; @@ -556,7 +556,7 @@ Noble.prototype.onHandleNotify = function (peripheralUuid, handle, data) { if (peripheral) { peripheral.emit('handleNotify', handle, data); } else { - this.emit('warning', 'unknown peripheral ' + peripheralUuid + ' handle notify!'); + this.emit('warning', `unknown peripheral ${peripheralUuid} handle notify!`); } }; diff --git a/lib/peripheral.js b/lib/peripheral.js index 5250af5a1..2e78cdab5 100644 --- a/lib/peripheral.js +++ b/lib/peripheral.js @@ -140,7 +140,7 @@ Peripheral.prototype.discoverAllServicesAndCharacteristics = function (callback) Peripheral.prototype.readHandle = function (handle, callback) { if (callback) { - this.once('handleRead' + handle, data => { + this.once(`handleRead${handle}`, data => { callback(null, data); }); } @@ -154,7 +154,7 @@ Peripheral.prototype.writeHandle = function (handle, data, withoutResponse, call } if (callback) { - this.once('handleWrite' + handle, () => { + this.once(`handleWrite${handle}`, () => { callback(null); }); } diff --git a/lib/webbluetooth/bindings.js b/lib/webbluetooth/bindings.js index 0dfe1de7d..dea2f8845 100644 --- a/lib/webbluetooth/bindings.js +++ b/lib/webbluetooth/bindings.js @@ -12,7 +12,7 @@ function addDashes (uuid) { return uuid; } if (uuid && uuid.length === 32) { - uuid = uuid.substring(0, 8) + '-' + uuid.substring(8, 12) + '-' + uuid.substring(12, 16) + '-' + uuid.substring(16, 20) + '-' + uuid.substring(20); + uuid = `${uuid.substring(0, 8)}-${uuid.substring(8, 12)}-${uuid.substring(12, 16)}-${uuid.substring(16, 20)}-${uuid.substring(20)}`; } return uuid.toLowerCase(); } @@ -77,7 +77,7 @@ NobleBindings.prototype.startScanning = function (options, allowDuplicates) { options.services = options.services.map(service => { // web bluetooth requires 4 char hex service names to be passed in as integers if (typeof service === 'string' && service.length === 4) { - service = parseInt('0x' + service); + service = parseInt(`0x${service}`); } else if (typeof service === 'string' && service.length === 6 && service.indexOf('0x') === 0) { service = parseInt(service); } @@ -298,15 +298,15 @@ NobleBindings.prototype.notify = function (deviceUuid, serviceUuid, characterist charPromise.then(characteristic => characteristic.startNotifications()) .then(characteristic => { debug('notifications started', characteristicUuid); - peripheral.notifcationListeners[serviceUuid + '__' + characteristicUuid] = function (evt) { + peripheral.notifcationListeners[`${serviceUuid}__${characteristicUuid}`] = function (evt) { debug('oncharacteristicvaluechanged', evt, Buffer.from(evt.target.value.buffer)); self.emit('read', deviceUuid, serviceUuid, characteristicUuid, Buffer.from(evt.target.value.buffer), true); }; - characteristic.addEventListener('characteristicvaluechanged', peripheral.notifcationListeners[serviceUuid + '__' + characteristicUuid]); + characteristic.addEventListener('characteristicvaluechanged', peripheral.notifcationListeners[`${serviceUuid}__${characteristicUuid}`]); const onDisconnected = function () { - characteristic.removeEventListener('characteristicvaluechanged', peripheral.notifcationListeners[serviceUuid + '__' + characteristicUuid]); - delete peripheral.notifcationListeners[serviceUuid + '__' + characteristicUuid]; + characteristic.removeEventListener('characteristicvaluechanged', peripheral.notifcationListeners[`${serviceUuid}__${characteristicUuid}`]); + delete peripheral.notifcationListeners[`${serviceUuid}__${characteristicUuid}`]; }; peripheral.device.addEventListener('gattserverdisconnected', onDisconnected, { once: true }); @@ -321,9 +321,9 @@ NobleBindings.prototype.notify = function (deviceUuid, serviceUuid, characterist charPromise.then(characteristic => characteristic.stopNotifications()) .then(characteristic => { debug('notifications stopped', characteristic); - if (peripheral.notifcationListeners[serviceUuid + '__' + characteristicUuid]) { - characteristic.removeEventListener('characteristicvaluechanged', peripheral.notifcationListeners[serviceUuid + '__' + characteristicUuid]); - delete peripheral.notifcationListeners[serviceUuid + '__' + characteristicUuid]; + if (peripheral.notifcationListeners[`${serviceUuid}__${characteristicUuid}`]) { + characteristic.removeEventListener('characteristicvaluechanged', peripheral.notifcationListeners[`${serviceUuid}__${characteristicUuid}`]); + delete peripheral.notifcationListeners[`${serviceUuid}__${characteristicUuid}`]; } self.emit('notify', deviceUuid, serviceUuid, characteristicUuid, false); return characteristic; diff --git a/lib/websocket/bindings.js b/lib/websocket/bindings.js index cecddd18e..53f7e0775 100644 --- a/lib/websocket/bindings.js +++ b/lib/websocket/bindings.js @@ -5,7 +5,7 @@ const WebSocket = require('ws'); const NobleBindings = function () { const port = 0xB1e; - this._ws = new WebSocket('ws://localhost:' + port); + this._ws = new WebSocket(`ws://localhost:${port}`); this._startScanCommand = null; this._peripherals = {}; diff --git a/test/test-peripheral.js b/test/test-peripheral.js index 49d7e46fe..4075abc82 100644 --- a/test/test-peripheral.js +++ b/test/test-peripheral.js @@ -283,7 +283,7 @@ describe('Peripheral', function () { peripheral.readHandle(mockHandle, function () { calledback = true; }); - peripheral.emit('handleRead' + mockHandle); + peripheral.emit(`handleRead${mockHandle}`); calledback.should.equal(true); }); @@ -297,7 +297,7 @@ describe('Peripheral', function () { } calledbackData = data; }); - peripheral.emit('handleRead' + mockHandle, mockData); + peripheral.emit(`handleRead${mockHandle}`, mockData); calledbackData.should.equal(mockData); }); @@ -334,7 +334,7 @@ describe('Peripheral', function () { peripheral.writeHandle(mockHandle, mockData, false, function () { calledback = true; }); - peripheral.emit('handleWrite' + mockHandle); + peripheral.emit(`handleWrite${mockHandle}`); calledback.should.equal(true); }); From 5fd15642a0df88b59a344643a049fb60233b5786 Mon Sep 17 00:00:00 2001 From: Aarni Koskela Date: Sun, 26 Jan 2020 00:34:34 +0200 Subject: [PATCH 068/114] Fix up no-case-declarations issues --- lib/hci-socket/gap.js | 44 ++++++++++++++++--------------------------- 1 file changed, 16 insertions(+), 28 deletions(-) diff --git a/lib/hci-socket/gap.js b/lib/hci-socket/gap.js index 7849b8a50..a36a0f966 100644 --- a/lib/hci-socket/gap.js +++ b/lib/hci-socket/gap.js @@ -125,9 +125,6 @@ Gap.prototype.onHciLeAdvertisingReport = function (status, type, address, addres discoveryCount++; let i = 0; - let j = 0; - let serviceUuid = null; - let serviceSolicitationUuid = null; while ((i + 1) < eir.length) { var length = eir.readUInt8(i); @@ -149,8 +146,8 @@ Gap.prototype.onHciLeAdvertisingReport = function (status, type, address, addres switch (eirType) { case 0x02: // Incomplete List of 16-bit Service Class UUID case 0x03: // Complete List of 16-bit Service Class UUIDs - for (j = 0; j < bytes.length; j += 2) { - serviceUuid = bytes.readUInt16LE(j).toString(16); + for (let j = 0; j < bytes.length; j += 2) { + const serviceUuid = bytes.readUInt16LE(j).toString(16); if (advertisement.serviceUuids.indexOf(serviceUuid) === -1) { advertisement.serviceUuids.push(serviceUuid); } @@ -159,8 +156,8 @@ Gap.prototype.onHciLeAdvertisingReport = function (status, type, address, addres case 0x06: // Incomplete List of 128-bit Service Class UUIDs case 0x07: // Complete List of 128-bit Service Class UUIDs - for (j = 0; j < bytes.length; j += 16) { - serviceUuid = bytes.slice(j, j + 16).toString('hex').match(/.{1,2}/g).reverse().join(''); + for (let j = 0; j < bytes.length; j += 16) { + const serviceUuid = bytes.slice(j, j + 16).toString('hex').match(/.{1,2}/g).reverse().join(''); if (advertisement.serviceUuids.indexOf(serviceUuid) === -1) { advertisement.serviceUuids.push(serviceUuid); } @@ -177,8 +174,8 @@ Gap.prototype.onHciLeAdvertisingReport = function (status, type, address, addres break; case 0x14: // List of 16 bit solicitation UUIDs - for (j = 0; j < bytes.length; j += 2) { - serviceSolicitationUuid = bytes.readUInt16LE(j).toString(16); + for (let j = 0; j < bytes.length; j += 2) { + const serviceSolicitationUuid = bytes.readUInt16LE(j).toString(16); if (advertisement.serviceSolicitationUuids.indexOf(serviceSolicitationUuid) === -1) { advertisement.serviceSolicitationUuids.push(serviceSolicitationUuid); } @@ -186,8 +183,8 @@ Gap.prototype.onHciLeAdvertisingReport = function (status, type, address, addres break; case 0x15: // List of 128 bit solicitation UUIDs - for (j = 0; j < bytes.length; j += 16) { - serviceSolicitationUuid = bytes.slice(j, j + 16).toString('hex').match(/.{1,2}/g).reverse().join(''); + for (let j = 0; j < bytes.length; j += 16) { + const serviceSolicitationUuid = bytes.slice(j, j + 16).toString('hex').match(/.{1,2}/g).reverse().join(''); if (advertisement.serviceSolicitationUuids.indexOf(serviceSolicitationUuid) === -1) { advertisement.serviceSolicitationUuids.push(serviceSolicitationUuid); } @@ -195,38 +192,29 @@ Gap.prototype.onHciLeAdvertisingReport = function (status, type, address, addres break; case 0x16: // 16-bit Service Data, there can be multiple occurences - const serviceDataUuid = bytes.slice(0, 2).toString('hex').match(/.{1,2}/g).reverse().join(''); - var serviceData = bytes.slice(2, bytes.length); - advertisement.serviceData.push({ - uuid: serviceDataUuid, - data: serviceData + uuid: bytes.slice(0, 2).toString('hex').match(/.{1,2}/g).reverse().join(''), + data: bytes.slice(2, bytes.length) }); break; case 0x20: // 32-bit Service Data, there can be multiple occurences - const serviceData32Uuid = bytes.slice(0, 4).toString('hex').match(/.{1,2}/g).reverse().join(''); - const serviceData32 = bytes.slice(4, bytes.length); - advertisement.serviceData.push({ - uuid: serviceData32Uuid, - data: serviceData32 + uuid: bytes.slice(0, 4).toString('hex').match(/.{1,2}/g).reverse().join(''), + data: bytes.slice(4, bytes.length) }); break; case 0x21: // 128-bit Service Data, there can be multiple occurences - const serviceData128Uuid = bytes.slice(0, 16).toString('hex').match(/.{1,2}/g).reverse().join(''); - const serviceData128 = bytes.slice(16, bytes.length); - advertisement.serviceData.push({ - uuid: serviceData128Uuid, - data: serviceData128 + uuid: bytes.slice(0, 16).toString('hex').match(/.{1,2}/g).reverse().join(''), + data: bytes.slice(16, bytes.length) }); break; case 0x1f: // List of 32 bit solicitation UUIDs - for (j = 0; j < bytes.length; j += 4) { - serviceSolicitationUuid = bytes.readUInt32LE(j).toString(16); + for (let j = 0; j < bytes.length; j += 4) { + const serviceSolicitationUuid = bytes.readUInt32LE(j).toString(16); if (advertisement.serviceSolicitationUuids.indexOf(serviceSolicitationUuid) === -1) { advertisement.serviceSolicitationUuids.push(serviceSolicitationUuid); } From 5a237352a24ff483b7d46b7e07dc3cccbdfbd6a4 Mon Sep 17 00:00:00 2001 From: Aarni Koskela Date: Sun, 26 Jan 2020 00:40:13 +0200 Subject: [PATCH 069/114] Don't run lint on Node 6 --- .github/workflows/nodepackage.yml | 9 ++++++++- package.json | 1 - 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/nodepackage.yml b/.github/workflows/nodepackage.yml index 8932c86fd..f05374ea2 100644 --- a/.github/workflows/nodepackage.yml +++ b/.github/workflows/nodepackage.yml @@ -45,4 +45,11 @@ jobs: export CC="g++-4.8" fi npm install - npm test + npm run test + - name: Lint + run: | + if [ ${{ matrix.node }} = 6 ]; then + # ESLint 6+ is not compatible with Node 6 + exit 0 + fi + npm run lint diff --git a/package.json b/package.json index b3e933244..5b5bb88aa 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,6 @@ }, "scripts": { "lint": "eslint '**/*.js'", - "pretest": "npm run lint", "test": "mocha -R spec test/*.js" }, "browser": { From 2a1b610f8987a321572a613b660494eb7d04a36e Mon Sep 17 00:00:00 2001 From: Philippe Coval Date: Thu, 20 Feb 2020 16:49:51 +0100 Subject: [PATCH 070/114] npm: Update dependencies to current Change-Id: I4f3d42fa7bfcafb6c9e12a90370b73400c7e0f86 Signed-off-by: Philippe Coval --- package.json | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 5b5bb88aa..e53ab9bab 100644 --- a/package.json +++ b/package.json @@ -36,27 +36,27 @@ "dependencies": { "debug": "^4.1.1", "napi-thread-safe-callback": "0.0.6", - "node-addon-api": "^1.1.0" + "node-addon-api": "^2.0.0" }, "optionalDependencies": { - "@abandonware/bluetooth-hci-socket": "^0.5.3-3" + "@abandonware/bluetooth-hci-socket": "^0.5.3-4" }, "devDependencies": { - "async": "^3.1.0", + "async": "^3.1.1", "eslint": "^6.8.0", "eslint-config-semistandard": "^15.0.0", "eslint-config-standard": "^14.1.0", - "eslint-plugin-import": "^2.20.0", + "eslint-plugin-import": "^2.20.1", "eslint-plugin-node": "^11.0.0", "eslint-plugin-promise": "^4.2.1", "eslint-plugin-standard": "^4.0.1", "install": "^0.13.0", - "mocha": "^6.2.0", - "node-gyp": "^5.0.3", + "mocha": "^7.0.1", + "node-gyp": "^6.1.0", "prettier": "^1.19.1", "should": "~13.2.3", - "sinon": "~7.4.2", - "ws": "^7.1.2" + "sinon": "~9.0.0", + "ws": "^7.2.1" }, "scripts": { "lint": "eslint '**/*.js'", From 00d6b4fffe2f64f2e1f72f7d8376765589098e53 Mon Sep 17 00:00:00 2001 From: Philippe Coval Date: Thu, 20 Feb 2020 16:50:34 +0100 Subject: [PATCH 071/114] npm: Lock dependencies Change-Id: I828f432998ff8cf2ed2c2a186f8b2cacd1bccba3 Signed-off-by: Philippe Coval --- package-lock.json | 1466 ++++++++++++++++++--------------------------- 1 file changed, 594 insertions(+), 872 deletions(-) diff --git a/package-lock.json b/package-lock.json index 409bdc2ef..5d696c47a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,9 +5,9 @@ "requires": true, "dependencies": { "@abandonware/bluetooth-hci-socket": { - "version": "0.5.3-3", - "resolved": "https://registry.npmjs.org/@abandonware/bluetooth-hci-socket/-/bluetooth-hci-socket-0.5.3-3.tgz", - "integrity": "sha512-SkT5yVoaceiWOK1eWW/QCgAaPph/Y+EkOVBvETmhsD1hhKa83+EmVRMjubO68k54uoIzviqcNhxZI/LuIU2PHA==", + "version": "0.5.3-4", + "resolved": "https://registry.npmjs.org/@abandonware/bluetooth-hci-socket/-/bluetooth-hci-socket-0.5.3-4.tgz", + "integrity": "sha512-hxYIj1qBZVyayJDuN1yhZPzNvuSlCSoFEiWRSZ8nqSvKGQzBddWRTASmlQqVn15G4hHVkjk0xDXjzwUkEgaDyA==", "optional": true, "requires": { "debug": "^4.1.0", @@ -37,33 +37,43 @@ } }, "@sinonjs/commons": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-1.6.0.tgz", - "integrity": "sha512-w4/WHG7C4WWFyE5geCieFJF6MZkbW4VAriol5KlmQXpAQdxvV0p26sqNZOW6Qyw6Y0l9K4g+cHvvczR2sEEpqg==", + "version": "1.7.1", + "resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-1.7.1.tgz", + "integrity": "sha512-Debi3Baff1Qu1Unc3mjJ96MgpbwTn43S1+9yJ0llWygPwDNu2aaWBD6yc9y/Z8XDRNhx7U+u2UDg2OGQXkclUQ==", "dev": true, "requires": { "type-detect": "4.0.8" } }, + "@sinonjs/fake-timers": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/@sinonjs/fake-timers/-/fake-timers-6.0.0.tgz", + "integrity": "sha512-atR1J/jRXvQAb47gfzSK8zavXy7BcpnYq21ALon0U99etu99vsir0trzIO3wpeLtW+LLVY6X7EkfVTbjGSH8Ww==", + "dev": true, + "requires": { + "@sinonjs/commons": "^1.7.0" + } + }, "@sinonjs/formatio": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/@sinonjs/formatio/-/formatio-3.2.1.tgz", - "integrity": "sha512-tsHvOB24rvyvV2+zKMmPkZ7dXX6LSLKZ7aOtXY6Edklp0uRcgGpOsQTTGTcWViFyx4uhWc6GV8QdnALbIbIdeQ==", + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/@sinonjs/formatio/-/formatio-5.0.1.tgz", + "integrity": "sha512-KaiQ5pBf1MpS09MuA0kp6KBQt2JUOQycqVG1NZXvzeaXe5LGFqAKueIS0bw4w0P9r7KuBSVdUk5QjXsUdu2CxQ==", "dev": true, "requires": { "@sinonjs/commons": "^1", - "@sinonjs/samsam": "^3.1.0" + "@sinonjs/samsam": "^5.0.2" } }, "@sinonjs/samsam": { - "version": "3.3.3", - "resolved": "https://registry.npmjs.org/@sinonjs/samsam/-/samsam-3.3.3.tgz", - "integrity": "sha512-bKCMKZvWIjYD0BLGnNrxVuw4dkWCYsLqFOUWw8VgKF/+5Y+mE7LfHWPIYoDXowH+3a9LsWDMo0uAP8YDosPvHQ==", + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/@sinonjs/samsam/-/samsam-5.0.2.tgz", + "integrity": "sha512-p3yrEVB5F/1wI+835n+X8llOGRgV8+jw5BHQ/cJoLBUXXZ5U8Tr5ApwPc4L4av/vjla48kVPoN0t6dykQm+Rvg==", "dev": true, "requires": { - "@sinonjs/commons": "^1.3.0", - "array-from": "^2.1.1", - "lodash": "^4.17.15" + "@sinonjs/commons": "^1.6.0", + "@sinonjs/formatio": "^5.0.0", + "lodash.get": "^4.4.2", + "type-detect": "^4.0.8" } }, "@sinonjs/text-encoding": { @@ -90,12 +100,12 @@ "dev": true }, "ajv": { - "version": "6.10.2", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.10.2.tgz", - "integrity": "sha512-TXtUUEYHuaTEbLZWIKUr5pmBuhDLy+8KYtPYdcV8qC+pOZL+NKqYwvWSRrVXHn+ZmRRAu8vJTAznH7Oag6RVRw==", + "version": "6.11.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.11.0.tgz", + "integrity": "sha512-nCprB/0syFYy9fVYU1ox1l2KN8S9I+tziH8D4zdZuLT3N6RMlGSGt5FSTpAiHB/Whv8Qs1cWHma1aMKZyaHRKA==", "dev": true, "requires": { - "fast-deep-equal": "^2.0.1", + "fast-deep-equal": "^3.1.1", "fast-json-stable-stringify": "^2.0.0", "json-schema-traverse": "^0.4.1", "uri-js": "^4.2.2" @@ -130,6 +140,16 @@ "color-convert": "^1.9.0" } }, + "anymatch": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.1.tgz", + "integrity": "sha512-mM8522psRCqzV+6LhomX5wgp25YVibjh8Wj23I5RPkPppSVSjyKD2A2mBJmWGa+KN7f2D6LNh9jkBCeyLktzjg==", + "dev": true, + "requires": { + "normalize-path": "^3.0.0", + "picomatch": "^2.0.4" + } + }, "aproba": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/aproba/-/aproba-1.2.0.tgz", @@ -153,12 +173,6 @@ "sprintf-js": "~1.0.2" } }, - "array-from": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/array-from/-/array-from-2.1.1.tgz", - "integrity": "sha1-z+nYwmYoudxa7MYqn12PHzUsEZU=", - "dev": true - }, "array-includes": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/array-includes/-/array-includes-3.1.1.tgz", @@ -168,85 +182,6 @@ "define-properties": "^1.1.3", "es-abstract": "^1.17.0", "is-string": "^1.0.5" - }, - "dependencies": { - "es-abstract": { - "version": "1.17.4", - "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.17.4.tgz", - "integrity": "sha512-Ae3um/gb8F0mui/jPL+QiqmglkUsaQf7FwBEHYIFkztkneosu9imhqHpBzQ3h1vit8t5iQ74t6PEVvphBZiuiQ==", - "dev": true, - "requires": { - "es-to-primitive": "^1.2.1", - "function-bind": "^1.1.1", - "has": "^1.0.3", - "has-symbols": "^1.0.1", - "is-callable": "^1.1.5", - "is-regex": "^1.0.5", - "object-inspect": "^1.7.0", - "object-keys": "^1.1.1", - "object.assign": "^4.1.0", - "string.prototype.trimleft": "^2.1.1", - "string.prototype.trimright": "^2.1.1" - } - }, - "es-to-primitive": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.1.tgz", - "integrity": "sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA==", - "dev": true, - "requires": { - "is-callable": "^1.1.4", - "is-date-object": "^1.0.1", - "is-symbol": "^1.0.2" - } - }, - "has-symbols": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.1.tgz", - "integrity": "sha512-PLcsoqu++dmEIZB+6totNFKq/7Do+Z0u4oT0zKOJNl3lYK6vGwwu2hjHs+68OEZbTjiUE9bgOABXbP/GvrS0Kg==", - "dev": true - }, - "is-callable": { - "version": "1.1.5", - "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.1.5.tgz", - "integrity": "sha512-ESKv5sMCJB2jnHTWZ3O5itG+O128Hsus4K4Qh1h2/cgn2vbgnLSVqfV46AeJA9D5EeeLa9w81KUXMtn34zhX+Q==", - "dev": true - }, - "is-regex": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.0.5.tgz", - "integrity": "sha512-vlKW17SNq44owv5AQR3Cq0bQPEb8+kF3UKZ2fiZNOWtztYE5i0CzCZxFDwO58qAOWtxdBRVO/V5Qin1wjCqFYQ==", - "dev": true, - "requires": { - "has": "^1.0.3" - } - }, - "object-inspect": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.7.0.tgz", - "integrity": "sha512-a7pEHdh1xKIAgTySUGgLMx/xwDZskN1Ud6egYYN3EdRW4ZMPNEDUTF+hwy2LUC+Bl+SyLXANnwz/jyh/qutKUw==", - "dev": true - }, - "string.prototype.trimleft": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/string.prototype.trimleft/-/string.prototype.trimleft-2.1.1.tgz", - "integrity": "sha512-iu2AGd3PuP5Rp7x2kEZCrB2Nf41ehzh+goo8TV7z8/XDBbsvc6HQIlUl9RjkZ4oyrW1XM5UwlGl1oVEaDjg6Ag==", - "dev": true, - "requires": { - "define-properties": "^1.1.3", - "function-bind": "^1.1.1" - } - }, - "string.prototype.trimright": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/string.prototype.trimright/-/string.prototype.trimright-2.1.1.tgz", - "integrity": "sha512-qFvWL3/+QIgZXVmJBfpHmxLB7xsUXz6HsUmP8+5dRaC3Q7oKUv9Vo6aMCRZC1smrtyECFsIT30PqBJ1gTjAs+g==", - "dev": true, - "requires": { - "define-properties": "^1.1.3", - "function-bind": "^1.1.1" - } - } } }, "array.prototype.flat": { @@ -257,85 +192,6 @@ "requires": { "define-properties": "^1.1.3", "es-abstract": "^1.17.0-next.1" - }, - "dependencies": { - "es-abstract": { - "version": "1.17.4", - "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.17.4.tgz", - "integrity": "sha512-Ae3um/gb8F0mui/jPL+QiqmglkUsaQf7FwBEHYIFkztkneosu9imhqHpBzQ3h1vit8t5iQ74t6PEVvphBZiuiQ==", - "dev": true, - "requires": { - "es-to-primitive": "^1.2.1", - "function-bind": "^1.1.1", - "has": "^1.0.3", - "has-symbols": "^1.0.1", - "is-callable": "^1.1.5", - "is-regex": "^1.0.5", - "object-inspect": "^1.7.0", - "object-keys": "^1.1.1", - "object.assign": "^4.1.0", - "string.prototype.trimleft": "^2.1.1", - "string.prototype.trimright": "^2.1.1" - } - }, - "es-to-primitive": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.1.tgz", - "integrity": "sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA==", - "dev": true, - "requires": { - "is-callable": "^1.1.4", - "is-date-object": "^1.0.1", - "is-symbol": "^1.0.2" - } - }, - "has-symbols": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.1.tgz", - "integrity": "sha512-PLcsoqu++dmEIZB+6totNFKq/7Do+Z0u4oT0zKOJNl3lYK6vGwwu2hjHs+68OEZbTjiUE9bgOABXbP/GvrS0Kg==", - "dev": true - }, - "is-callable": { - "version": "1.1.5", - "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.1.5.tgz", - "integrity": "sha512-ESKv5sMCJB2jnHTWZ3O5itG+O128Hsus4K4Qh1h2/cgn2vbgnLSVqfV46AeJA9D5EeeLa9w81KUXMtn34zhX+Q==", - "dev": true - }, - "is-regex": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.0.5.tgz", - "integrity": "sha512-vlKW17SNq44owv5AQR3Cq0bQPEb8+kF3UKZ2fiZNOWtztYE5i0CzCZxFDwO58qAOWtxdBRVO/V5Qin1wjCqFYQ==", - "dev": true, - "requires": { - "has": "^1.0.3" - } - }, - "object-inspect": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.7.0.tgz", - "integrity": "sha512-a7pEHdh1xKIAgTySUGgLMx/xwDZskN1Ud6egYYN3EdRW4ZMPNEDUTF+hwy2LUC+Bl+SyLXANnwz/jyh/qutKUw==", - "dev": true - }, - "string.prototype.trimleft": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/string.prototype.trimleft/-/string.prototype.trimleft-2.1.1.tgz", - "integrity": "sha512-iu2AGd3PuP5Rp7x2kEZCrB2Nf41ehzh+goo8TV7z8/XDBbsvc6HQIlUl9RjkZ4oyrW1XM5UwlGl1oVEaDjg6Ag==", - "dev": true, - "requires": { - "define-properties": "^1.1.3", - "function-bind": "^1.1.1" - } - }, - "string.prototype.trimright": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/string.prototype.trimright/-/string.prototype.trimright-2.1.1.tgz", - "integrity": "sha512-qFvWL3/+QIgZXVmJBfpHmxLB7xsUXz6HsUmP8+5dRaC3Q7oKUv9Vo6aMCRZC1smrtyECFsIT30PqBJ1gTjAs+g==", - "dev": true, - "requires": { - "define-properties": "^1.1.3", - "function-bind": "^1.1.1" - } - } } }, "asn1": { @@ -360,15 +216,9 @@ "dev": true }, "async": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/async/-/async-3.1.0.tgz", - "integrity": "sha512-4vx/aaY6j/j3Lw3fbCHNWP0pPaTCew3F6F3hYyl/tHs/ndmV1q7NW9T5yuJ2XAGwdQrP+6Wu20x06U4APo/iQQ==", - "dev": true - }, - "async-limiter": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.1.tgz", - "integrity": "sha512-csOlWGAcRFJaI6m+F2WKdnMKr4HhdhFVBk0H/QbJFMCr+uO2kwohwXQPxw/9OCxp05r5ghVBFSyioixx3gfkNQ==", + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/async/-/async-3.1.1.tgz", + "integrity": "sha512-X5Dj8hK1pJNC2Wzo2Rcp9FBVdJMGRR/S7V+lH46s8GVFhtbo5O4Le5GECCF/8PISVdkUA6mMPvgz7qTTD1rf1g==", "dev": true }, "asynckit": { @@ -384,9 +234,9 @@ "dev": true }, "aws4": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.8.0.tgz", - "integrity": "sha512-ReZxvNHIOv88FlT7rxcXIIC0fPt4KZqZbOlivyWtXLt8ESx84zd3kMC6iK5jVeS2qt+g7ftS7ye4fi06X5rtRQ==", + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.9.1.tgz", + "integrity": "sha512-wMHVg2EOHaMRxbzgFJ9gtjOOCrI80OHLG14rxi28XwOW8ux6IiEbRCGGGqCtdAIg4FQCbW20k9RsT4y3gJlFug==", "dev": true }, "balanced-match": { @@ -403,6 +253,12 @@ "tweetnacl": "^0.14.3" } }, + "binary-extensions": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.0.0.tgz", + "integrity": "sha512-Phlt0plgpIIBOGTT/ehfFnbNlfsDEiqmzE2KRXoX1bLIlir4X/MR+zSyBEkL05ffWgnRSf/DXv+WrUAVr93/ow==", + "dev": true + }, "bindings": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz", @@ -422,9 +278,9 @@ }, "dependencies": { "readable-stream": { - "version": "3.4.0", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.4.0.tgz", - "integrity": "sha512-jItXPLmrSR8jmTRmRWJXCnGJsfy85mB3Wd/uINMXA65yrnFo0cPClFIUWzo2najVNSl+mx7/4W8ttlLWJe99pQ==", + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", + "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", "optional": true, "requires": { "inherits": "^2.0.3", @@ -443,6 +299,15 @@ "concat-map": "0.0.1" } }, + "braces": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", + "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "dev": true, + "requires": { + "fill-range": "^7.0.1" + } + }, "browser-stdout": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", @@ -476,17 +341,6 @@ "ansi-styles": "^3.2.1", "escape-string-regexp": "^1.0.5", "supports-color": "^5.3.0" - }, - "dependencies": { - "supports-color": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", - "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", - "dev": true, - "requires": { - "has-flag": "^3.0.0" - } - } } }, "chardet": { @@ -495,10 +349,26 @@ "integrity": "sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==", "dev": true }, + "chokidar": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.3.0.tgz", + "integrity": "sha512-dGmKLDdT3Gdl7fBUe8XK+gAtGmzy5Fn0XkkWQuYxGIgWVPPse2CxFA5mtrlD0TOHaHjEUqkWNyP1XdHoJES/4A==", + "dev": true, + "requires": { + "anymatch": "~3.1.1", + "braces": "~3.0.2", + "fsevents": "~2.1.1", + "glob-parent": "~5.1.0", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.2.0" + } + }, "chownr": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.2.tgz", - "integrity": "sha512-GkfeAQh+QNy3wquu9oIZr6SS5x7wGdSgNQvD10X3r+AZr1Oys22HW8kAmDMvNg2+Dm0TeGaEuO8gFwdBXxwO8A==" + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.4.tgz", + "integrity": "sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==" }, "cli-cursor": { "version": "3.1.0", @@ -516,20 +386,26 @@ "dev": true }, "cliui": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-4.1.0.tgz", - "integrity": "sha512-4FG+RSG9DL7uEwRUZXZn3SS34DiDPfzP0VOiEwtUWlE+AR2EIg+hSyvrIgUUfhdgR/UkAeW2QHgeP+hWrXs7jQ==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-5.0.0.tgz", + "integrity": "sha512-PYeGSEmmHM6zvoef2w8TPzlrnNpXIjTipYK780YswmIP9vjxmd6Y2a3CB2Ks6/AU8NHjZugXvo8w3oWM2qnwXA==", "dev": true, "requires": { - "string-width": "^2.1.1", - "strip-ansi": "^4.0.0", - "wrap-ansi": "^2.0.0" + "string-width": "^3.1.0", + "strip-ansi": "^5.2.0", + "wrap-ansi": "^5.1.0" }, "dependencies": { "ansi-regex": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", - "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", + "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", + "dev": true + }, + "emoji-regex": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz", + "integrity": "sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA==", "dev": true }, "is-fullwidth-code-point": { @@ -539,22 +415,23 @@ "dev": true }, "string-width": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", - "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", + "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", "dev": true, "requires": { + "emoji-regex": "^7.0.1", "is-fullwidth-code-point": "^2.0.0", - "strip-ansi": "^4.0.0" + "strip-ansi": "^5.1.0" } }, "strip-ansi": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", - "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", + "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", "dev": true, "requires": { - "ansi-regex": "^3.0.0" + "ansi-regex": "^4.1.0" } } } @@ -718,23 +595,24 @@ } }, "emoji-regex": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz", - "integrity": "sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA==", + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", "dev": true }, "end-of-stream": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.1.tgz", - "integrity": "sha512-1MkrZNvWTKCaigbn+W15elq2BB/L22nqrSY5DKlo3X6+vclJm8Bb5djXJBmEX6fS3+zCh/F4VBK5Z2KxJt4s2Q==", + "version": "1.4.4", + "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz", + "integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==", + "optional": true, "requires": { "once": "^1.4.0" } }, "env-paths": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/env-paths/-/env-paths-1.0.0.tgz", - "integrity": "sha1-QWgTO0K7BcOKNbGuQ5fIKYqzaeA=", + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/env-paths/-/env-paths-2.2.0.tgz", + "integrity": "sha512-6u0VYSCo/OW6IoD5WCLLy9JUGARbamfSavcNXry/eu8aHVFei6CD3Sw+VGX5alea1i9pgPHW0mbu6Xj0uBh7gA==", "dev": true }, "error-ex": { @@ -747,27 +625,28 @@ } }, "es-abstract": { - "version": "1.14.2", - "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.14.2.tgz", - "integrity": "sha512-DgoQmbpFNOofkjJtKwr87Ma5EW4Dc8fWhD0R+ndq7Oc456ivUfGOOP6oAZTTKl5/CcNMP+EN+e3/iUzgE0veZg==", + "version": "1.17.4", + "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.17.4.tgz", + "integrity": "sha512-Ae3um/gb8F0mui/jPL+QiqmglkUsaQf7FwBEHYIFkztkneosu9imhqHpBzQ3h1vit8t5iQ74t6PEVvphBZiuiQ==", "dev": true, "requires": { - "es-to-primitive": "^1.2.0", + "es-to-primitive": "^1.2.1", "function-bind": "^1.1.1", "has": "^1.0.3", - "has-symbols": "^1.0.0", - "is-callable": "^1.1.4", - "is-regex": "^1.0.4", - "object-inspect": "^1.6.0", + "has-symbols": "^1.0.1", + "is-callable": "^1.1.5", + "is-regex": "^1.0.5", + "object-inspect": "^1.7.0", "object-keys": "^1.1.1", - "string.prototype.trimleft": "^2.0.0", - "string.prototype.trimright": "^2.0.0" + "object.assign": "^4.1.0", + "string.prototype.trimleft": "^2.1.1", + "string.prototype.trimright": "^2.1.1" } }, "es-to-primitive": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.0.tgz", - "integrity": "sha512-qZryBOJjV//LaxLTV6UC//WewneB3LcXOL9NP++ozKVXsIIIpm/2c13UDiD9Jp2eThsecw9m3jPqDwTyobcdbg==", + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.1.tgz", + "integrity": "sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA==", "dev": true, "requires": { "is-callable": "^1.1.4", @@ -949,9 +828,9 @@ } }, "eslint-plugin-import": { - "version": "2.20.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.20.0.tgz", - "integrity": "sha512-NK42oA0mUc8Ngn4kONOPsPB1XhbUvNHqF+g307dPV28aknPoiNnKLFd9em4nkswwepdF5ouieqv5Th/63U7YJQ==", + "version": "2.20.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.20.1.tgz", + "integrity": "sha512-qQHgFOTjguR+LnYRoToeZWT62XM55MBVXObHM6SKFd1VzDcX/vqT1kAz8ssqigh5eMj8qXcRoXXGZpPP6RfdCw==", "dev": true, "requires": { "array-includes": "^3.0.3", @@ -1087,9 +966,9 @@ "dev": true }, "esquery": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.0.1.tgz", - "integrity": "sha512-SmiyZ5zIWH9VM+SRUReLS5Q8a7GxtRdxEBVZpm98rJM7Sb+A9DVCndXfkeFUd3byderg+EbDkfnevfCwynWaNA==", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.1.0.tgz", + "integrity": "sha512-MxYW9xKmROWF672KqjO75sszsA8Mxhw06YFeS5VHlB98KDHbOSurm3ArsjO60Eaf3QmGMCP1yn+0JQkNLo/97Q==", "dev": true, "requires": { "estraverse": "^4.0.0" @@ -1116,21 +995,6 @@ "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", "dev": true }, - "execa": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/execa/-/execa-1.0.0.tgz", - "integrity": "sha512-adbxcyWV46qiHyvSp50TKt05tB4tK3HcmF7/nxfAdhnox83seTDbwnaqKO4sXRy7roHAIFqJP/Rw/AuEbX61LA==", - "dev": true, - "requires": { - "cross-spawn": "^6.0.0", - "get-stream": "^4.0.0", - "is-stream": "^1.1.0", - "npm-run-path": "^2.0.0", - "p-finally": "^1.0.0", - "signal-exit": "^3.0.0", - "strip-eof": "^1.0.0" - } - }, "expand-template": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/expand-template/-/expand-template-2.0.3.tgz", @@ -1161,15 +1025,15 @@ "dev": true }, "fast-deep-equal": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz", - "integrity": "sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk=", + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.1.tgz", + "integrity": "sha512-8UEa58QDLauDNfpbrX55Q9jrGHThw2ZMdOky5Gl1CDtVeJDPVrG4Jxx1N8jw2gkWaff5UUuX1KJd+9zGe2B+ZA==", "dev": true }, "fast-json-stable-stringify": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz", - "integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I=", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", + "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", "dev": true }, "fast-levenshtein": { @@ -1179,9 +1043,9 @@ "dev": true }, "figures": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/figures/-/figures-3.1.0.tgz", - "integrity": "sha512-ravh8VRXqHuMvZt/d8GblBeqDMkdJMBdv/2KntFH+ra5MXkO7nxNKpzQ3n6QD/2da1kH0aWmNISdvhM7gl2gVg==", + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/figures/-/figures-3.2.0.tgz", + "integrity": "sha512-yaduQFRKLXYOGgEn6AZau90j3ggSOyiqXU0F9JZfeXYhNa+Jk4X+s45A2zg5jns87GAFa34BBm2kXw4XpNcbdg==", "dev": true, "requires": { "escape-string-regexp": "^1.0.5" @@ -1202,13 +1066,22 @@ "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==", "optional": true }, + "fill-range": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", + "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "dev": true, + "requires": { + "to-regex-range": "^5.0.1" + } + }, "find-up": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", - "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-2.1.0.tgz", + "integrity": "sha1-RdG35QbHF93UgndaK3eSCjwMV6c=", "dev": true, "requires": { - "locate-path": "^3.0.0" + "locate-path": "^2.0.0" } }, "flat": { @@ -1284,6 +1157,13 @@ "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" }, + "fsevents": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.1.2.tgz", + "integrity": "sha512-R4wDiBwZ0KzpgOWetKDug1FZcYhqYnUYKtfZYt4mD5SBz76q0KR4Q9o7GIPamsVPGmW3EYPPJ0dOOjvx32ldZA==", + "dev": true, + "optional": true + }, "function-bind": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", @@ -1317,15 +1197,6 @@ "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", "dev": true }, - "get-stream": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-4.1.0.tgz", - "integrity": "sha512-GMat4EJ5161kIy2HevLlr4luNjBgvmj413KaQA7jt4V8B4RDsfpHk7WQ9GVqfYyyx8OS/L66Kox+rJRNklLK7w==", - "dev": true, - "requires": { - "pump": "^3.0.0" - } - }, "getpass": { "version": "0.1.7", "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", @@ -1342,9 +1213,9 @@ "optional": true }, "glob": { - "version": "7.1.4", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz", - "integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==", + "version": "7.1.6", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", + "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", "requires": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", @@ -1373,9 +1244,9 @@ } }, "graceful-fs": { - "version": "4.2.2", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.2.tgz", - "integrity": "sha512-IItsdsea19BoLC7ELy13q1iJFNmd7ofZH5+X/pJr90/nRoPEX0DJo1dHDbgtYWOhJhcCgMDTOw84RZ72q6lB+Q==", + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.3.tgz", + "integrity": "sha512-a30VEBm4PEdx1dRB7MFK7BejejvCvBronbLjht+sHuGYj8PHs7M/5Z+rt5lw551vZ7yfTCj4Vuyy3mSJytDWRQ==", "dev": true }, "growl": { @@ -1416,9 +1287,9 @@ "dev": true }, "has-symbols": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.0.tgz", - "integrity": "sha1-uhqPGvKg/DllD1yFA2dwQSIGO0Q=", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.1.tgz", + "integrity": "sha512-PLcsoqu++dmEIZB+6totNFKq/7Do+Z0u4oT0zKOJNl3lYK6vGwwu2hjHs+68OEZbTjiUE9bgOABXbP/GvrS0Kg==", "dev": true }, "has-unicode": { @@ -1464,9 +1335,9 @@ "dev": true }, "ignore-walk": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/ignore-walk/-/ignore-walk-3.0.2.tgz", - "integrity": "sha512-EXyErtpHbn75ZTsOADsfx6J/FPo6/5cjev46PXrcTpd8z3BoRkXgYu9/JVqrI7tusjmwCZutGeRJeU0Wo1e4Cw==", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/ignore-walk/-/ignore-walk-3.0.3.tgz", + "integrity": "sha512-m7o6xuOaT1aqheYHKf8W6J5pYH85ZI9w077erOzLje3JsB1gkafkAhHHY19dqjulgIZHFm32Cp5uNZgcQqdJKw==", "optional": true, "requires": { "minimatch": "^3.0.4" @@ -1535,12 +1406,6 @@ "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==", "dev": true }, - "emoji-regex": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", - "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", - "dev": true - }, "is-fullwidth-code-point": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", @@ -1594,34 +1459,37 @@ "integrity": "sha512-zDml/jzr2PKU9I8J/xyZBQn8rPCAY//UOYNmR01XwNwyfhEWObo2SWfSl1+0tm1u6PhxLwDnfsT/6jB7OUxqFA==", "dev": true }, - "invert-kv": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/invert-kv/-/invert-kv-2.0.0.tgz", - "integrity": "sha512-wPVv/y/QQ/Uiirj/vh3oP+1Ww+AWehmi1g5fFWGPF6IpCBCDVrhgHRMvrLfdYcwDh3QJbGXDW4JAuzxElLSqKA==", - "dev": true - }, "is-arrayish": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", "integrity": "sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0=", "dev": true }, + "is-binary-path": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", + "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", + "dev": true, + "requires": { + "binary-extensions": "^2.0.0" + } + }, "is-buffer": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.3.tgz", - "integrity": "sha512-U15Q7MXTuZlrbymiz95PJpZxu8IlipAp4dtS3wOdgPXx3mqBnslrWU14kxfHB+Py/+2PVKSr37dMAgM2A4uArw==", + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.4.tgz", + "integrity": "sha512-Kq1rokWXOPXWuaMAqZiJW4XxsmD9zGx9q4aePabbn3qCRGedtH7Cm+zV8WETitMfu1wdh+Rvd6w5egwSngUX2A==", "dev": true }, "is-callable": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.1.4.tgz", - "integrity": "sha512-r5p9sxJjYnArLjObpjA4xu5EKI3CuKHkJXMhT7kwbpUyIFD1n5PMAsoPvWnvtZiNz7LjkYDRZhd7FlI0eMijEA==", + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.1.5.tgz", + "integrity": "sha512-ESKv5sMCJB2jnHTWZ3O5itG+O128Hsus4K4Qh1h2/cgn2vbgnLSVqfV46AeJA9D5EeeLa9w81KUXMtn34zhX+Q==", "dev": true }, "is-date-object": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.1.tgz", - "integrity": "sha1-mqIOtq7rv/d/vTPnTKAbM1gdOhY=", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.2.tgz", + "integrity": "sha512-USlDT524woQ08aoZFzh3/Z6ch9Y/EWXEHQ/AaRN0SkKq4t2Jw2R2339tSXmwuVoY7LLlBCbOIlx2myP/L5zk0g==", "dev": true }, "is-extglob": { @@ -1647,6 +1515,12 @@ "is-extglob": "^2.1.1" } }, + "is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "dev": true + }, "is-promise": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.1.0.tgz", @@ -1654,20 +1528,14 @@ "dev": true }, "is-regex": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.0.4.tgz", - "integrity": "sha1-VRdIm1RwkbCTDglWVM7SXul+lJE=", + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.0.5.tgz", + "integrity": "sha512-vlKW17SNq44owv5AQR3Cq0bQPEb8+kF3UKZ2fiZNOWtztYE5i0CzCZxFDwO58qAOWtxdBRVO/V5Qin1wjCqFYQ==", "dev": true, "requires": { - "has": "^1.0.1" + "has": "^1.0.3" } }, - "is-stream": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", - "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=", - "dev": true - }, "is-string": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/is-string/-/is-string-1.0.5.tgz", @@ -1675,12 +1543,12 @@ "dev": true }, "is-symbol": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.2.tgz", - "integrity": "sha512-HS8bZ9ox60yCJLH9snBpIwv9pYUAkcuLhSA1oero1UB5y9aiQpRA8y2ex945AOtCZL1lJDeIk3G5LthswI46Lw==", + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.3.tgz", + "integrity": "sha512-OwijhaRSgqvhm/0ZdAcXNZt9lYdKFpcRDT5ULUuYXPoT794UNOdU+gpT6Rzo7b4V2HUl/op6GqY894AZwv9faQ==", "dev": true, "requires": { - "has-symbols": "^1.0.0" + "has-symbols": "^1.0.1" } }, "is-typedarray": { @@ -1770,15 +1638,6 @@ "integrity": "sha512-FrLwOgm+iXrPV+5zDU6Jqu4gCRXbWEQg2O3SKONsWE4w7AXFRkryS53bpWdaL9cNol+AmR3AEYz6kn+o0fCPnw==", "dev": true }, - "lcid": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/lcid/-/lcid-2.0.0.tgz", - "integrity": "sha512-avPEb8P8EGnwXKClwsNUgryVjllcRqtMYa49NTsbQagYuT1DcXnl1915oxWjoyGrXR6zH/Y0Zc96xWsPcoDKeA==", - "dev": true, - "requires": { - "invert-kv": "^2.0.0" - } - }, "levn": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", @@ -1802,12 +1661,12 @@ } }, "locate-path": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", - "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-2.0.0.tgz", + "integrity": "sha1-K1aLJl7slExtnA3pw9u7ygNUzY4=", "dev": true, "requires": { - "p-locate": "^3.0.0", + "p-locate": "^2.0.0", "path-exists": "^3.0.0" } }, @@ -1817,6 +1676,12 @@ "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==", "dev": true }, + "lodash.get": { + "version": "4.4.2", + "resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz", + "integrity": "sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk=", + "dev": true + }, "log-symbols": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-2.2.0.tgz", @@ -1826,45 +1691,19 @@ "chalk": "^2.0.1" } }, - "lolex": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/lolex/-/lolex-4.2.0.tgz", - "integrity": "sha512-gKO5uExCXvSm6zbF562EvM+rd1kQDnB9AZBbiQVzf1ZmdDpxUSvpnAaVOP83N/31mRK8Ml8/VE8DMvsAZQ+7wg==", - "dev": true - }, - "map-age-cleaner": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/map-age-cleaner/-/map-age-cleaner-0.1.3.tgz", - "integrity": "sha512-bJzx6nMoP6PDLPBFmg7+xRKeFZvFboMrGlxmNj9ClvX53KrmvM5bXFXEWjbz4cz1AFn+jWJ9z/DJSz7hrs0w3w==", - "dev": true, - "requires": { - "p-defer": "^1.0.0" - } - }, - "mem": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/mem/-/mem-4.3.0.tgz", - "integrity": "sha512-qX2bG48pTqYRVmDB37rn/6PT7LcR8T7oAX3bf99u1Tt1nzxYfxkgqDwUwolPlXweM0XzBOBFzSx4kfp7KP1s/w==", - "dev": true, - "requires": { - "map-age-cleaner": "^0.1.1", - "mimic-fn": "^2.0.0", - "p-is-promise": "^2.0.0" - } - }, "mime-db": { - "version": "1.40.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.40.0.tgz", - "integrity": "sha512-jYdeOMPy9vnxEqFRRo6ZvTZ8d9oPb+k18PKoYNYUe2stVEBPPwsln/qWzdbmaIvnhZ9v2P+CuecK+fpUfsV2mA==", + "version": "1.43.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.43.0.tgz", + "integrity": "sha512-+5dsGEEovYbT8UY9yD7eE4XTc4UwJ1jBYlgaQQF38ENsKR3wj/8q8RFZrF9WIZpB2V1ArTVFUva8sAul1NzRzQ==", "dev": true }, "mime-types": { - "version": "2.1.24", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.24.tgz", - "integrity": "sha512-WaFHS3MCl5fapm3oLxU4eYDw77IQM2ACcxQ9RIxfaC3ooc6PFuBMGZZsYpvoXS5D5QTWPieo1jjLdAm3TBP3cQ==", + "version": "2.1.26", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.26.tgz", + "integrity": "sha512-01paPWYgLrkqAyrlDorC1uDwl2p3qZT7yl806vW7DvDoxwXi46jsjFbg+WdwotBIk6/MbEhO/dh5aZ5sNj/dWQ==", "dev": true, "requires": { - "mime-db": "1.40.0" + "mime-db": "1.43.0" } }, "mimic-fn": { @@ -1874,9 +1713,9 @@ "dev": true }, "mimic-response": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-2.0.0.tgz", - "integrity": "sha512-8ilDoEapqA4uQ3TwS0jakGONKXVJqpy+RpM+3b7pLdOjghCrEiGp9SRkFbUHAmZW9vdnrENWHjaweIoTIJExSQ==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-2.1.0.tgz", + "integrity": "sha512-wXqjST+SLt7R009ySCglWBCFpjUygmCIfD790/kVbiGmUgfYGuB14PiTd5DwVxSV4NcYHjzMkoj5LjQZwTQLEA==", "optional": true }, "minimatch": { @@ -1893,20 +1732,20 @@ "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" }, "minipass": { - "version": "2.6.5", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-2.6.5.tgz", - "integrity": "sha512-ewSKOPFH9blOLXx0YSE+mbrNMBFPS+11a2b03QZ+P4LVrUHW/GAlqeYC7DBknDyMWkHzrzTpDhUvy7MUxqyrPA==", + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-2.9.0.tgz", + "integrity": "sha512-wxfUjg9WebH+CUDX/CdbRlh5SmfZiy/hpkxaRI16Y9W56Pa75sWgd/rvFilSgrauD9NyFymP/+JFV3KwzIsJeg==", "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" } }, "minizlib": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-1.2.2.tgz", - "integrity": "sha512-hR3At21uSrsjjDTWrbu0IMLTpnkpv8IIMFDFaoz43Tmu4LkmAXfH44vNNzpTnf+OAQQCHrb91y/wc2J4x5XgSQ==", + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-1.3.3.tgz", + "integrity": "sha512-6ZYMOEnmVsdCeTJVE0W9ZD+pVnE8h9Hma/iOwwRDsdQoePpoX56/8B6z3P9VNwppJuBKNRuFDRNRqRWexT9G9Q==", "requires": { - "minipass": "^2.2.1" + "minipass": "^2.9.0" } }, "mkdirp": { @@ -1918,13 +1757,14 @@ } }, "mocha": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-6.2.0.tgz", - "integrity": "sha512-qwfFgY+7EKAAUAdv7VYMZQknI7YJSGesxHyhn6qD52DV8UcSZs5XwCifcZGMVIE4a5fbmhvbotxC0DLQ0oKohQ==", + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-7.0.1.tgz", + "integrity": "sha512-9eWmWTdHLXh72rGrdZjNbG3aa1/3NRPpul1z0D979QpEnFdCG0Q5tv834N+94QEN2cysfV72YocQ3fn87s70fg==", "dev": true, "requires": { "ansi-colors": "3.2.3", "browser-stdout": "1.3.1", + "chokidar": "3.3.0", "debug": "3.2.6", "diff": "3.5.0", "escape-string-regexp": "1.0.5", @@ -1937,15 +1777,15 @@ "minimatch": "3.0.4", "mkdirp": "0.5.1", "ms": "2.1.1", - "node-environment-flags": "1.0.5", + "node-environment-flags": "1.0.6", "object.assign": "4.1.0", "strip-json-comments": "2.0.1", "supports-color": "6.0.0", "which": "1.3.1", "wide-align": "1.1.3", - "yargs": "13.2.2", - "yargs-parser": "13.0.0", - "yargs-unparser": "1.5.0" + "yargs": "13.3.0", + "yargs-parser": "13.1.1", + "yargs-unparser": "1.6.0" }, "dependencies": { "debug": { @@ -1957,6 +1797,15 @@ "ms": "^2.1.1" } }, + "find-up": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", + "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==", + "dev": true, + "requires": { + "locate-path": "^3.0.0" + } + }, "glob": { "version": "7.1.3", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.3.tgz", @@ -1971,11 +1820,54 @@ "path-is-absolute": "^1.0.0" } }, + "locate-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", + "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==", + "dev": true, + "requires": { + "p-locate": "^3.0.0", + "path-exists": "^3.0.0" + } + }, "ms": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==", "dev": true + }, + "p-limit": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.2.2.tgz", + "integrity": "sha512-WGR+xHecKTr7EbUEhyLSh5Dube9JtdiG78ufaeLxTgpudf/20KqyMioIUZJAezlTIi6evxuoUs9YXc11cU+yzQ==", + "dev": true, + "requires": { + "p-try": "^2.0.0" + } + }, + "p-locate": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz", + "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==", + "dev": true, + "requires": { + "p-limit": "^2.0.0" + } + }, + "p-try": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", + "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", + "dev": true + }, + "supports-color": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-6.0.0.tgz", + "integrity": "sha512-on9Kwidc1IUQo+bQdhi8+Tijpo0e1SS6RoGo2guUwn5vdaxw8RXOF9Vb2ws+ihWOmh4JnCJOvaziZWP1VABaLg==", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } } } }, @@ -2014,9 +1906,9 @@ "dev": true }, "needle": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/needle/-/needle-2.4.0.tgz", - "integrity": "sha512-4Hnwzr3mi5L97hMYeNl8wRW/Onhy4nUKR/lVemJ8gJedxxUyBLm9kkrDColJvoSfwi0jCNhD+xCdOtiGDQiRZg==", + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/needle/-/needle-2.3.2.tgz", + "integrity": "sha512-DUzITvPVDUy6vczKKYTnWc/pBZ0EnjMJnQ3y+Jo5zfKFimJs7S3HFCxCRZYB9FUZcrzUQr3WsmvZgddMEIZv6w==", "optional": true, "requires": { "debug": "^3.2.6", @@ -2042,36 +1934,37 @@ "dev": true }, "nise": { - "version": "1.5.2", - "resolved": "https://registry.npmjs.org/nise/-/nise-1.5.2.tgz", - "integrity": "sha512-/6RhOUlicRCbE9s+94qCUsyE+pKlVJ5AhIv+jEE7ESKwnbXqulKZ1FYU+XAtHHWE9TinYvAxDUJAb912PwPoWA==", + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/nise/-/nise-4.0.2.tgz", + "integrity": "sha512-ALDnm0pTTyeGdbg5FCpWGd58Nmp3qO8d8x+dU2Fw8lApeJTEBSjkBZZM4S8t6GpKh+czxkfM/TKxpRMroZzwOg==", "dev": true, "requires": { - "@sinonjs/formatio": "^3.2.1", + "@sinonjs/commons": "^1.7.0", + "@sinonjs/fake-timers": "^6.0.0", + "@sinonjs/formatio": "^5.0.1", "@sinonjs/text-encoding": "^0.7.1", "just-extend": "^4.0.2", - "lolex": "^4.1.0", "path-to-regexp": "^1.7.0" } }, "node-abi": { - "version": "2.11.0", - "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-2.11.0.tgz", - "integrity": "sha512-kuy/aEg75u40v378WRllQ4ZexaXJiCvB68D2scDXclp/I4cRq6togpbOoKhmN07tns9Zldu51NNERo0wehfX9g==", + "version": "2.15.0", + "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-2.15.0.tgz", + "integrity": "sha512-FeLpTS0F39U7hHZU1srAK4Vx+5AHNVOTP+hxBNQknR/54laTHSFIJkDWDqiquY1LeLUgTfPN7sLPhMubx0PLAg==", "optional": true, "requires": { "semver": "^5.4.1" } }, "node-addon-api": { - "version": "1.7.1", - "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-1.7.1.tgz", - "integrity": "sha512-2+DuKodWvwRTrCfKOeR24KIc5unKjOh8mz17NCzVnHWfjAdDqbfbjqh7gUT+BkXBRQM52+xCHciKWonJ3CbJMQ==" + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-2.0.0.tgz", + "integrity": "sha512-ASCL5U13as7HhOExbT6OlWJJUV/lLzL2voOSP1UVehpRD8FbSrSDjfScK/KwAvVTI5AS6r4VwbOMlIqtvRidnA==" }, "node-environment-flags": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/node-environment-flags/-/node-environment-flags-1.0.5.tgz", - "integrity": "sha512-VNYPRfGfmZLx0Ye20jWzHUjyTW/c+6Wq+iLhDzUI4XmhrDd9l/FozXV3F2xOaXjvp0co0+v1YSR3CMP6g+VvLQ==", + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/node-environment-flags/-/node-environment-flags-1.0.6.tgz", + "integrity": "sha512-5Evy2epuL+6TM0lCQGpFIj6KwiEsGh1SrHUhTbNX+sLbBtjidPZFAnVK9y5yU1+h//RitLbRHTIMyxQPtxMdHw==", "dev": true, "requires": { "object.getownpropertydescriptors": "^2.0.3", @@ -2079,39 +1972,22 @@ } }, "node-gyp": { - "version": "5.0.3", - "resolved": "https://registry.npmjs.org/node-gyp/-/node-gyp-5.0.3.tgz", - "integrity": "sha512-z/JdtkFGUm0QaQUusvloyYuGDub3nUbOo5de1Fz57cM++osBTvQatBUSTlF1k/w8vFHPxxXW6zxGvkxXSpaBkQ==", + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/node-gyp/-/node-gyp-6.1.0.tgz", + "integrity": "sha512-h4A2zDlOujeeaaTx06r4Vy+8MZ1679lU+wbCKDS4ZtvY2A37DESo37oejIw0mtmR3+rvNwts5B6Kpt1KrNYdNw==", "dev": true, "requires": { - "env-paths": "^1.0.0", - "glob": "^7.0.3", - "graceful-fs": "^4.1.2", - "mkdirp": "^0.5.0", - "nopt": "2 || 3", - "npmlog": "0 || 1 || 2 || 3 || 4", - "request": "^2.87.0", - "rimraf": "2", - "semver": "~5.3.0", - "tar": "^4.4.8", - "which": "1" - }, - "dependencies": { - "nopt": { - "version": "3.0.6", - "resolved": "https://registry.npmjs.org/nopt/-/nopt-3.0.6.tgz", - "integrity": "sha1-xkZdvwirzU2zWTF/eaxopkayj/k=", - "dev": true, - "requires": { - "abbrev": "1" - } - }, - "semver": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.3.0.tgz", - "integrity": "sha1-myzl094C0XxgEq0yaqa00M9U+U8=", - "dev": true - } + "env-paths": "^2.2.0", + "glob": "^7.1.4", + "graceful-fs": "^4.2.2", + "mkdirp": "^0.5.1", + "nopt": "^4.0.1", + "npmlog": "^4.1.2", + "request": "^2.88.0", + "rimraf": "^2.6.3", + "semver": "^5.7.1", + "tar": "^4.4.12", + "which": "^1.3.1" } }, "node-pre-gyp": { @@ -2142,7 +2018,6 @@ "version": "4.0.1", "resolved": "https://registry.npmjs.org/nopt/-/nopt-4.0.1.tgz", "integrity": "sha1-0NRoWv1UFRk8jHUFYC0NF81kR00=", - "optional": true, "requires": { "abbrev": "1", "osenv": "^0.1.4" @@ -2160,29 +2035,36 @@ "validate-npm-package-license": "^3.0.1" } }, + "normalize-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", + "dev": true + }, "npm-bundled": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/npm-bundled/-/npm-bundled-1.0.6.tgz", - "integrity": "sha512-8/JCaftHwbd//k6y2rEWp6k1wxVfpFzB6t1p825+cUb7Ym2XQfhwIC5KwhrvzZRJu+LtDE585zVaS32+CGtf0g==", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/npm-bundled/-/npm-bundled-1.1.1.tgz", + "integrity": "sha512-gqkfgGePhTpAEgUsGEgcq1rqPXA+tv/aVBlgEzfXwA1yiUJF7xtEt3CtVwOjNYQOVknDk0F20w58Fnm3EtG0fA==", + "optional": true, + "requires": { + "npm-normalize-package-bin": "^1.0.1" + } + }, + "npm-normalize-package-bin": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/npm-normalize-package-bin/-/npm-normalize-package-bin-1.0.1.tgz", + "integrity": "sha512-EPfafl6JL5/rU+ot6P3gRSCpPDW5VmIzX959Ob1+ySFUuuYHWHekXpwdUZcKP5C+DS4GEtdJluwBjnsNDl+fSA==", "optional": true }, "npm-packlist": { - "version": "1.4.4", - "resolved": "https://registry.npmjs.org/npm-packlist/-/npm-packlist-1.4.4.tgz", - "integrity": "sha512-zTLo8UcVYtDU3gdeaFu2Xu0n0EvelfHDGuqtNIn5RO7yQj4H1TqNdBc/yZjxnWA0PVB8D3Woyp0i5B43JwQ6Vw==", + "version": "1.4.8", + "resolved": "https://registry.npmjs.org/npm-packlist/-/npm-packlist-1.4.8.tgz", + "integrity": "sha512-5+AZgwru5IevF5ZdnFglB5wNlHG1AOOuw28WhUq8/8emhBmLv6jX5by4WJCh7lW0uSYZYS6DXqIsyZVIXRZU9A==", "optional": true, "requires": { "ignore-walk": "^3.0.1", - "npm-bundled": "^1.0.1" - } - }, - "npm-run-path": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-2.0.2.tgz", - "integrity": "sha1-NakjLfo11wZ7TLLd8jV7GHFTbF8=", - "dev": true, - "requires": { - "path-key": "^2.0.0" + "npm-bundled": "^1.0.1", + "npm-normalize-package-bin": "^1.0.1" } }, "npmlog": { @@ -2213,9 +2095,9 @@ "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=" }, "object-inspect": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.6.0.tgz", - "integrity": "sha512-GJzfBZ6DgDAmnuaM3104jR4s1Myxr3Y3zfIyN4z3UdqN69oSRacNK8UhnobDdC+7J2AHCjGwxQubNJfE70SXXQ==", + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.7.0.tgz", + "integrity": "sha512-a7pEHdh1xKIAgTySUGgLMx/xwDZskN1Ud6egYYN3EdRW4ZMPNEDUTF+hwy2LUC+Bl+SyLXANnwz/jyh/qutKUw==", "dev": true }, "object-keys": { @@ -2237,13 +2119,13 @@ } }, "object.getownpropertydescriptors": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/object.getownpropertydescriptors/-/object.getownpropertydescriptors-2.0.3.tgz", - "integrity": "sha1-h1jIRvW0B62rDyNuCYbxSwUcqhY=", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/object.getownpropertydescriptors/-/object.getownpropertydescriptors-2.1.0.tgz", + "integrity": "sha512-Z53Oah9A3TdLoblT7VKJaTDdXdT+lQO+cNpKVnya5JDe9uLvzu1YyY1yFDFrcxrlRgWrEFH0jJtD/IbuwjcEVg==", "dev": true, "requires": { - "define-properties": "^1.1.2", - "es-abstract": "^1.5.1" + "define-properties": "^1.1.3", + "es-abstract": "^1.17.0-next.1" } }, "object.values": { @@ -2256,85 +2138,6 @@ "es-abstract": "^1.17.0-next.1", "function-bind": "^1.1.1", "has": "^1.0.3" - }, - "dependencies": { - "es-abstract": { - "version": "1.17.4", - "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.17.4.tgz", - "integrity": "sha512-Ae3um/gb8F0mui/jPL+QiqmglkUsaQf7FwBEHYIFkztkneosu9imhqHpBzQ3h1vit8t5iQ74t6PEVvphBZiuiQ==", - "dev": true, - "requires": { - "es-to-primitive": "^1.2.1", - "function-bind": "^1.1.1", - "has": "^1.0.3", - "has-symbols": "^1.0.1", - "is-callable": "^1.1.5", - "is-regex": "^1.0.5", - "object-inspect": "^1.7.0", - "object-keys": "^1.1.1", - "object.assign": "^4.1.0", - "string.prototype.trimleft": "^2.1.1", - "string.prototype.trimright": "^2.1.1" - } - }, - "es-to-primitive": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.1.tgz", - "integrity": "sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA==", - "dev": true, - "requires": { - "is-callable": "^1.1.4", - "is-date-object": "^1.0.1", - "is-symbol": "^1.0.2" - } - }, - "has-symbols": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.1.tgz", - "integrity": "sha512-PLcsoqu++dmEIZB+6totNFKq/7Do+Z0u4oT0zKOJNl3lYK6vGwwu2hjHs+68OEZbTjiUE9bgOABXbP/GvrS0Kg==", - "dev": true - }, - "is-callable": { - "version": "1.1.5", - "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.1.5.tgz", - "integrity": "sha512-ESKv5sMCJB2jnHTWZ3O5itG+O128Hsus4K4Qh1h2/cgn2vbgnLSVqfV46AeJA9D5EeeLa9w81KUXMtn34zhX+Q==", - "dev": true - }, - "is-regex": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.0.5.tgz", - "integrity": "sha512-vlKW17SNq44owv5AQR3Cq0bQPEb8+kF3UKZ2fiZNOWtztYE5i0CzCZxFDwO58qAOWtxdBRVO/V5Qin1wjCqFYQ==", - "dev": true, - "requires": { - "has": "^1.0.3" - } - }, - "object-inspect": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.7.0.tgz", - "integrity": "sha512-a7pEHdh1xKIAgTySUGgLMx/xwDZskN1Ud6egYYN3EdRW4ZMPNEDUTF+hwy2LUC+Bl+SyLXANnwz/jyh/qutKUw==", - "dev": true - }, - "string.prototype.trimleft": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/string.prototype.trimleft/-/string.prototype.trimleft-2.1.1.tgz", - "integrity": "sha512-iu2AGd3PuP5Rp7x2kEZCrB2Nf41ehzh+goo8TV7z8/XDBbsvc6HQIlUl9RjkZ4oyrW1XM5UwlGl1oVEaDjg6Ag==", - "dev": true, - "requires": { - "define-properties": "^1.1.3", - "function-bind": "^1.1.1" - } - }, - "string.prototype.trimright": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/string.prototype.trimright/-/string.prototype.trimright-2.1.1.tgz", - "integrity": "sha512-qFvWL3/+QIgZXVmJBfpHmxLB7xsUXz6HsUmP8+5dRaC3Q7oKUv9Vo6aMCRZC1smrtyECFsIT30PqBJ1gTjAs+g==", - "dev": true, - "requires": { - "define-properties": "^1.1.3", - "function-bind": "^1.1.1" - } - } } }, "once": { @@ -2371,19 +2174,7 @@ "os-homedir": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz", - "integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=", - "optional": true - }, - "os-locale": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/os-locale/-/os-locale-3.1.0.tgz", - "integrity": "sha512-Z8l3R4wYWM40/52Z+S265okfFj8Kt2cC2MKY+xNi3kFs+XGI7WXu/I309QQQYbRW4ijiZ+yxs9pqEhJh0DqW3Q==", - "dev": true, - "requires": { - "execa": "^1.0.0", - "lcid": "^2.0.0", - "mem": "^4.0.0" - } + "integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=" }, "os-tmpdir": { "version": "1.0.2", @@ -2394,52 +2185,33 @@ "version": "0.1.5", "resolved": "https://registry.npmjs.org/osenv/-/osenv-0.1.5.tgz", "integrity": "sha512-0CWcCECdMVc2Rw3U5w9ZjqX6ga6ubk1xDVKxtBQPK7wis/0F2r9T6k4ydGYhecl7YUBxBVxhL5oisPsNxAPe2g==", - "optional": true, "requires": { "os-homedir": "^1.0.0", "os-tmpdir": "^1.0.0" } }, - "p-defer": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/p-defer/-/p-defer-1.0.0.tgz", - "integrity": "sha1-n26xgvbJqozXQwBKfU+WsZaw+ww=", - "dev": true - }, - "p-finally": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/p-finally/-/p-finally-1.0.0.tgz", - "integrity": "sha1-P7z7FbiZpEEjs0ttzBi3JDNqLK4=", - "dev": true - }, - "p-is-promise": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/p-is-promise/-/p-is-promise-2.1.0.tgz", - "integrity": "sha512-Y3W0wlRPK8ZMRbNq97l4M5otioeA5lm1z7bkNkxCka8HSPjR0xRWmpCmc9utiaLP9Jb1eD8BgeIxTW4AIF45Pg==", - "dev": true - }, "p-limit": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.2.1.tgz", - "integrity": "sha512-85Tk+90UCVWvbDavCLKPOLC9vvY8OwEX/RtKF+/1OADJMVlFfEHOiMTPVyxg7mk/dKa+ipdHm0OUkTvCpMTuwg==", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-1.3.0.tgz", + "integrity": "sha512-vvcXsLAJ9Dr5rQOPk7toZQZJApBl2K4J6dANSsEuh6QI41JYcsS/qhTGa9ErIUUgK3WNQoJYvylxvjqmiqEA9Q==", "dev": true, "requires": { - "p-try": "^2.0.0" + "p-try": "^1.0.0" } }, "p-locate": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz", - "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-2.0.0.tgz", + "integrity": "sha1-IKAQOyIqcMj9OcwuWAaA893l7EM=", "dev": true, "requires": { - "p-limit": "^2.0.0" + "p-limit": "^1.1.0" } }, "p-try": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", - "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-1.0.0.tgz", + "integrity": "sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M=", "dev": true }, "parent-module": { @@ -2484,9 +2256,9 @@ "dev": true }, "path-to-regexp": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-1.7.0.tgz", - "integrity": "sha1-Wf3g9DW62suhA6hOnTvGTpa5k30=", + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-1.8.0.tgz", + "integrity": "sha512-n43JRhlUKUAlibEJhPeir1ncUID16QnEjNpwzNdO3Lm4ywrBpBZ5oLD0I6br9evr1Y9JTqwRtAh7JLoOzAQdVA==", "dev": true, "requires": { "isarray": "0.0.1" @@ -2515,6 +2287,12 @@ "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=", "dev": true }, + "picomatch": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.2.1.tgz", + "integrity": "sha512-ISBaA8xQNmwELC7eOjqFKMESB2VIqt4PPDD0nsS95b/9dZXvVKOlz9keMSnoGGKcOHXfTvDD6WMaRoSc9UuhRA==", + "dev": true + }, "pify": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", @@ -2528,57 +2306,12 @@ "dev": true, "requires": { "find-up": "^2.1.0" - }, - "dependencies": { - "find-up": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-2.1.0.tgz", - "integrity": "sha1-RdG35QbHF93UgndaK3eSCjwMV6c=", - "dev": true, - "requires": { - "locate-path": "^2.0.0" - } - }, - "locate-path": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-2.0.0.tgz", - "integrity": "sha1-K1aLJl7slExtnA3pw9u7ygNUzY4=", - "dev": true, - "requires": { - "p-locate": "^2.0.0", - "path-exists": "^3.0.0" - } - }, - "p-limit": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-1.3.0.tgz", - "integrity": "sha512-vvcXsLAJ9Dr5rQOPk7toZQZJApBl2K4J6dANSsEuh6QI41JYcsS/qhTGa9ErIUUgK3WNQoJYvylxvjqmiqEA9Q==", - "dev": true, - "requires": { - "p-try": "^1.0.0" - } - }, - "p-locate": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-2.0.0.tgz", - "integrity": "sha1-IKAQOyIqcMj9OcwuWAaA893l7EM=", - "dev": true, - "requires": { - "p-limit": "^1.1.0" - } - }, - "p-try": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/p-try/-/p-try-1.0.0.tgz", - "integrity": "sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M=", - "dev": true - } } }, "prebuild-install": { - "version": "5.3.2", - "resolved": "https://registry.npmjs.org/prebuild-install/-/prebuild-install-5.3.2.tgz", - "integrity": "sha512-INDfXzTPnhT+WYQemqnAXlP7SvfiFMopMozSgXCZ+RDLb279gKfIuLk4o7PgEawLp3WrMgIYGBpkxpraROHsSA==", + "version": "5.3.3", + "resolved": "https://registry.npmjs.org/prebuild-install/-/prebuild-install-5.3.3.tgz", + "integrity": "sha512-GV+nsUXuPW2p8Zy7SarF/2W/oiK8bFQgJcncoJ0d7kRpekEA0ftChjfEaF9/Y+QJEc/wFR7RAEa8lYByuUIe2g==", "optional": true, "requires": { "detect-libc": "^1.0.3", @@ -2630,15 +2363,16 @@ "dev": true }, "psl": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/psl/-/psl-1.4.0.tgz", - "integrity": "sha512-HZzqCGPecFLyoRj5HLfuDSKYTJkAfB5thKBIkRHtGjWwY7p1dAyveIbXIq4tO0KYfDF2tHqPUgY9SDnGm00uFw==", + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/psl/-/psl-1.7.0.tgz", + "integrity": "sha512-5NsSEDv8zY70ScRnOTn7bK7eanl2MvFrOrS/R6x+dBt5g1ghnj9Zv90kO8GwT8gxcu2ANyFprnFYB85IogIJOQ==", "dev": true }, "pump": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz", "integrity": "sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==", + "optional": true, "requires": { "end-of-stream": "^1.1.0", "once": "^1.3.1" @@ -2695,57 +2429,12 @@ "requires": { "find-up": "^2.0.0", "read-pkg": "^2.0.0" - }, - "dependencies": { - "find-up": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-2.1.0.tgz", - "integrity": "sha1-RdG35QbHF93UgndaK3eSCjwMV6c=", - "dev": true, - "requires": { - "locate-path": "^2.0.0" - } - }, - "locate-path": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-2.0.0.tgz", - "integrity": "sha1-K1aLJl7slExtnA3pw9u7ygNUzY4=", - "dev": true, - "requires": { - "p-locate": "^2.0.0", - "path-exists": "^3.0.0" - } - }, - "p-limit": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-1.3.0.tgz", - "integrity": "sha512-vvcXsLAJ9Dr5rQOPk7toZQZJApBl2K4J6dANSsEuh6QI41JYcsS/qhTGa9ErIUUgK3WNQoJYvylxvjqmiqEA9Q==", - "dev": true, - "requires": { - "p-try": "^1.0.0" - } - }, - "p-locate": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-2.0.0.tgz", - "integrity": "sha1-IKAQOyIqcMj9OcwuWAaA893l7EM=", - "dev": true, - "requires": { - "p-limit": "^1.1.0" - } - }, - "p-try": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/p-try/-/p-try-1.0.0.tgz", - "integrity": "sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M=", - "dev": true - } } }, "readable-stream": { - "version": "2.3.6", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", - "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", + "version": "2.3.7", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", + "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", "requires": { "core-util-is": "~1.0.0", "inherits": "~2.0.3", @@ -2756,6 +2445,15 @@ "util-deprecate": "~1.0.1" } }, + "readdirp": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.2.0.tgz", + "integrity": "sha512-crk4Qu3pmXwgxdSgGhgA/eXiJAPQiX4GMOZZMXnqKxHX7TaoL+3gQVo/WeuAiogr07DpnfjIMpXXa+PAIvwPGQ==", + "dev": true, + "requires": { + "picomatch": "^2.0.4" + } + }, "regexpp": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-2.0.1.tgz", @@ -2763,9 +2461,9 @@ "dev": true }, "request": { - "version": "2.88.0", - "resolved": "https://registry.npmjs.org/request/-/request-2.88.0.tgz", - "integrity": "sha512-NAqBSrijGLZdM0WZNsInLJpkJokL72XYjUpnB0iwsRgxh7dB6COrHnTBNwN0E+lHDAJzu7kLAkDeY08z2/A0hg==", + "version": "2.88.2", + "resolved": "https://registry.npmjs.org/request/-/request-2.88.2.tgz", + "integrity": "sha512-MsvtOrfG9ZcrOwAW+Qi+F6HbD0CWXEh9ou77uOb7FM2WPhwT7smM833PzanhJLsgXjN89Ir6V2PczXNnMpwKhw==", "dev": true, "requires": { "aws-sign2": "~0.7.0", @@ -2775,7 +2473,7 @@ "extend": "~3.0.2", "forever-agent": "~0.6.1", "form-data": "~2.3.2", - "har-validator": "~5.1.0", + "har-validator": "~5.1.3", "http-signature": "~1.2.0", "is-typedarray": "~1.0.0", "isstream": "~0.1.2", @@ -2785,7 +2483,7 @@ "performance-now": "^2.1.0", "qs": "~6.5.2", "safe-buffer": "^5.1.2", - "tough-cookie": "~2.4.3", + "tough-cookie": "~2.5.0", "tunnel-agent": "^0.6.0", "uuid": "^3.3.2" } @@ -2803,9 +2501,9 @@ "dev": true }, "resolve": { - "version": "1.15.0", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.15.0.tgz", - "integrity": "sha512-+hTmAldEGE80U2wJJDC1lebb5jWqvTYAfm3YZ1ckk1gBr0MnCqUKlwK1e+anaFljIl+F5tR5IoZcm4ZDA1zMQw==", + "version": "1.15.1", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.15.1.tgz", + "integrity": "sha512-84oo6ZTtoTUpjgNEr5SJyzQhzL72gaRodsSfyxC/AXRvwu0Yse9H8eF9IpGo7b8YetZhlI6v7ZQ6bKBFV/6S7w==", "dev": true, "requires": { "path-parse": "^1.0.6" @@ -2971,27 +2669,39 @@ } }, "sinon": { - "version": "7.4.2", - "resolved": "https://registry.npmjs.org/sinon/-/sinon-7.4.2.tgz", - "integrity": "sha512-pY5RY99DKelU3pjNxcWo6XqeB1S118GBcVIIdDi6V+h6hevn1izcg2xv1hTHW/sViRXU7sUOxt4wTUJ3gsW2CQ==", - "dev": true, - "requires": { - "@sinonjs/commons": "^1.4.0", - "@sinonjs/formatio": "^3.2.1", - "@sinonjs/samsam": "^3.3.3", - "diff": "^3.5.0", - "lolex": "^4.2.0", - "nise": "^1.5.2", - "supports-color": "^5.5.0" + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/sinon/-/sinon-9.0.0.tgz", + "integrity": "sha512-c4bREcvuK5VuEGyMW/Oim9I3Rq49Vzb0aMdxouFaA44QCFpilc5LJOugrX+mkrvikbqCimxuK+4cnHVNnLR41g==", + "dev": true, + "requires": { + "@sinonjs/commons": "^1.7.0", + "@sinonjs/fake-timers": "^6.0.0", + "@sinonjs/formatio": "^5.0.0", + "@sinonjs/samsam": "^5.0.1", + "diff": "^4.0.2", + "nise": "^4.0.1", + "supports-color": "^7.1.0" }, "dependencies": { + "diff": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", + "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", + "dev": true + }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, "supports-color": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", - "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.1.0.tgz", + "integrity": "sha512-oRSIpR8pxT1Wr2FquTNnGet79b3BWljqOuoW/h4oBhxJ/HUbX5nX6JSruTkvXDCFMwDPvsaTTbvMLKZWSy0R5g==", "dev": true, "requires": { - "has-flag": "^3.0.0" + "has-flag": "^4.0.0" } } } @@ -3081,9 +2791,9 @@ } }, "string.prototype.trimleft": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/string.prototype.trimleft/-/string.prototype.trimleft-2.1.0.tgz", - "integrity": "sha512-FJ6b7EgdKxxbDxc79cOlok6Afd++TTs5szo+zJTUyow3ycrRfJVE2pq3vcN53XexvKZu/DJMDfeI/qMiZTrjTw==", + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/string.prototype.trimleft/-/string.prototype.trimleft-2.1.1.tgz", + "integrity": "sha512-iu2AGd3PuP5Rp7x2kEZCrB2Nf41ehzh+goo8TV7z8/XDBbsvc6HQIlUl9RjkZ4oyrW1XM5UwlGl1oVEaDjg6Ag==", "dev": true, "requires": { "define-properties": "^1.1.3", @@ -3091,9 +2801,9 @@ } }, "string.prototype.trimright": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/string.prototype.trimright/-/string.prototype.trimright-2.1.0.tgz", - "integrity": "sha512-fXZTSV55dNBwv16uw+hh5jkghxSnc5oHq+5K/gXgizHwAvMetdAJlHqqoFC1FSDVPYWLkAKl2cxpUT41sV7nSg==", + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/string.prototype.trimright/-/string.prototype.trimright-2.1.1.tgz", + "integrity": "sha512-qFvWL3/+QIgZXVmJBfpHmxLB7xsUXz6HsUmP8+5dRaC3Q7oKUv9Vo6aMCRZC1smrtyECFsIT30PqBJ1gTjAs+g==", "dev": true, "requires": { "define-properties": "^1.1.3", @@ -3122,21 +2832,15 @@ "integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=", "dev": true }, - "strip-eof": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz", - "integrity": "sha1-u0P/VZim6wXYm1n80SnJgzE2Br8=", - "dev": true - }, "strip-json-comments": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=" }, "supports-color": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-6.0.0.tgz", - "integrity": "sha512-on9Kwidc1IUQo+bQdhi8+Tijpo0e1SS6RoGo2guUwn5vdaxw8RXOF9Vb2ws+ihWOmh4JnCJOvaziZWP1VABaLg==", + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", "dev": true, "requires": { "has-flag": "^3.0.0" @@ -3160,6 +2864,12 @@ "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", "dev": true }, + "emoji-regex": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz", + "integrity": "sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA==", + "dev": true + }, "is-fullwidth-code-point": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", @@ -3189,13 +2899,13 @@ } }, "tar": { - "version": "4.4.11", - "resolved": "https://registry.npmjs.org/tar/-/tar-4.4.11.tgz", - "integrity": "sha512-iI4zh3ktLJKaDNZKZc+fUONiQrSn9HkCFzamtb7k8FFmVilHVob7QsLX/VySAW8lAviMzMbFw4QtFb4errwgYA==", + "version": "4.4.13", + "resolved": "https://registry.npmjs.org/tar/-/tar-4.4.13.tgz", + "integrity": "sha512-w2VwSrBoHa5BsSyH+KxEqeQBAllHhccyMFVHtGtdMpF4W7IRWfZjFiQceJPChOeTsSDVUpER2T8FA93pr0L+QA==", "requires": { "chownr": "^1.1.1", "fs-minipass": "^1.2.5", - "minipass": "^2.6.4", + "minipass": "^2.8.6", "minizlib": "^1.2.1", "mkdirp": "^0.5.0", "safe-buffer": "^5.1.2", @@ -3228,9 +2938,9 @@ }, "dependencies": { "readable-stream": { - "version": "3.4.0", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.4.0.tgz", - "integrity": "sha512-jItXPLmrSR8jmTRmRWJXCnGJsfy85mB3Wd/uINMXA65yrnFo0cPClFIUWzo2najVNSl+mx7/4W8ttlLWJe99pQ==", + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", + "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", "optional": true, "requires": { "inherits": "^2.0.3", @@ -3261,22 +2971,23 @@ "os-tmpdir": "~1.0.2" } }, + "to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dev": true, + "requires": { + "is-number": "^7.0.0" + } + }, "tough-cookie": { - "version": "2.4.3", - "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.4.3.tgz", - "integrity": "sha512-Q5srk/4vDM54WJsJio3XNn6K2sCG+CQ8G5Wz6bZhRZoAe/+TxjWB/GlFAnYEbkYVlON9FMk/fE3h2RLpPXo4lQ==", + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.5.0.tgz", + "integrity": "sha512-nlLsUzgm1kfLXSXfRZMc1KLAugd4hqJHDTvc2hDIwS3mZAfMEuMbc03SujMF+GEcpaX/qboeycw6iO8JwVv2+g==", "dev": true, "requires": { - "psl": "^1.1.24", - "punycode": "^1.4.1" - }, - "dependencies": { - "punycode": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", - "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=", - "dev": true - } + "psl": "^1.1.28", + "punycode": "^2.1.1" } }, "tslib": { @@ -3330,14 +3041,14 @@ } }, "usb": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/usb/-/usb-1.6.0.tgz", - "integrity": "sha512-52DyWlCk9K+iw3LnvY95WXSnpHjxJoI++aGkV8HiMNPc4zmvDQlYvWAzrkbJ2JH3oUcx26XfU5sZcG4RAcVkMg==", + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/usb/-/usb-1.6.2.tgz", + "integrity": "sha512-KcovLXRQuH63iEtnqXyDQGOi5dXHpLM5lZBIUsqSJQToua8nL2sVCieQTkzQBfLe5mCuvk40MgKciI61lgevWw==", "optional": true, "requires": { "bindings": "^1.4.0", "nan": "2.13.2", - "prebuild-install": "^5.2.4" + "prebuild-install": "^5.3.3" }, "dependencies": { "nan": { @@ -3354,9 +3065,9 @@ "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" }, "uuid": { - "version": "3.3.3", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.3.tgz", - "integrity": "sha512-pW0No1RGHgzlpHJO1nsVrHKpOEIxkGg1xB+v0ZmdNH5OAeAwzAVrCnI2/6Mtx+Uys6iaylxa+D3g4j63IKKjSQ==", + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", + "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==", "dev": true }, "v8-compile-cache": { @@ -3422,13 +3133,54 @@ "dev": true }, "wrap-ansi": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz", - "integrity": "sha1-2Pw9KE3QV5T+hJc8rs3Rz4JP3YU=", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-5.1.0.tgz", + "integrity": "sha512-QC1/iN/2/RPVJ5jYK8BGttj5z83LmSKmvbvrXPNCLZSEb32KKVDJDl/MOt2N01qU2H/FkzEa9PKto1BqDjtd7Q==", "dev": true, "requires": { - "string-width": "^1.0.1", - "strip-ansi": "^3.0.1" + "ansi-styles": "^3.2.0", + "string-width": "^3.0.0", + "strip-ansi": "^5.0.0" + }, + "dependencies": { + "ansi-regex": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", + "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", + "dev": true + }, + "emoji-regex": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz", + "integrity": "sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA==", + "dev": true + }, + "is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "dev": true + }, + "string-width": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", + "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", + "dev": true, + "requires": { + "emoji-regex": "^7.0.1", + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^5.1.0" + } + }, + "strip-ansi": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", + "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", + "dev": true, + "requires": { + "ansi-regex": "^4.1.0" + } + } } }, "wrappy": { @@ -3446,13 +3198,10 @@ } }, "ws": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/ws/-/ws-7.1.2.tgz", - "integrity": "sha512-gftXq3XI81cJCgkUiAVixA0raD9IVmXqsylCrjRygw4+UOOGzPoxnQ6r/CnVL9i+mDncJo94tSkyrtuuQVBmrg==", - "dev": true, - "requires": { - "async-limiter": "^1.0.0" - } + "version": "7.2.1", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.2.1.tgz", + "integrity": "sha512-sucePNSafamSKoOqoNfBd8V0StlkzJKL2ZAhGQinCfNQ+oacw+Pk7lcdAElecBF2VkLNZRiIb5Oi1Q5lVUVt2A==", + "dev": true }, "y18n": { "version": "4.0.0", @@ -3461,27 +3210,26 @@ "dev": true }, "yallist": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.3.tgz", - "integrity": "sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A==" + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", + "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==" }, "yargs": { - "version": "13.2.2", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-13.2.2.tgz", - "integrity": "sha512-WyEoxgyTD3w5XRpAQNYUB9ycVH/PQrToaTXdYXRdOXvEy1l19br+VJsc0vcO8PTGg5ro/l/GY7F/JMEBmI0BxA==", + "version": "13.3.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-13.3.0.tgz", + "integrity": "sha512-2eehun/8ALW8TLoIl7MVaRUrg+yCnenu8B4kBlRxj3GJGDKU1Og7sMXPNm1BYyM1DOJmTZ4YeN/Nwxv+8XJsUA==", "dev": true, "requires": { - "cliui": "^4.0.0", + "cliui": "^5.0.0", "find-up": "^3.0.0", "get-caller-file": "^2.0.1", - "os-locale": "^3.1.0", "require-directory": "^2.1.1", "require-main-filename": "^2.0.0", "set-blocking": "^2.0.0", "string-width": "^3.0.0", "which-module": "^2.0.0", "y18n": "^4.0.0", - "yargs-parser": "^13.0.0" + "yargs-parser": "^13.1.1" }, "dependencies": { "ansi-regex": { @@ -3490,12 +3238,61 @@ "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", "dev": true }, + "emoji-regex": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz", + "integrity": "sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA==", + "dev": true + }, + "find-up": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", + "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==", + "dev": true, + "requires": { + "locate-path": "^3.0.0" + } + }, "is-fullwidth-code-point": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", "dev": true }, + "locate-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", + "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==", + "dev": true, + "requires": { + "p-locate": "^3.0.0", + "path-exists": "^3.0.0" + } + }, + "p-limit": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.2.2.tgz", + "integrity": "sha512-WGR+xHecKTr7EbUEhyLSh5Dube9JtdiG78ufaeLxTgpudf/20KqyMioIUZJAezlTIi6evxuoUs9YXc11cU+yzQ==", + "dev": true, + "requires": { + "p-try": "^2.0.0" + } + }, + "p-locate": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz", + "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==", + "dev": true, + "requires": { + "p-limit": "^2.0.0" + } + }, + "p-try": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", + "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", + "dev": true + }, "string-width": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", @@ -3519,9 +3316,9 @@ } }, "yargs-parser": { - "version": "13.0.0", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-13.0.0.tgz", - "integrity": "sha512-w2LXjoL8oRdRQN+hOyppuXs+V/fVAYtpcrRxZuF7Kt/Oc+Jr2uAcVntaUTNT6w5ihoWfFDpNY8CPx1QskxZ/pw==", + "version": "13.1.1", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-13.1.1.tgz", + "integrity": "sha512-oVAVsHz6uFrg3XQheFII8ESO2ssAf9luWuAd6Wexsu4F3OtIW0o8IribPXYrD4WC24LWtPrJlGy87y5udK+dxQ==", "dev": true, "requires": { "camelcase": "^5.0.0", @@ -3529,89 +3326,14 @@ } }, "yargs-unparser": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/yargs-unparser/-/yargs-unparser-1.5.0.tgz", - "integrity": "sha512-HK25qidFTCVuj/D1VfNiEndpLIeJN78aqgR23nL3y4N0U/91cOAzqfHlF8n2BvoNDcZmJKin3ddNSvOxSr8flw==", + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/yargs-unparser/-/yargs-unparser-1.6.0.tgz", + "integrity": "sha512-W9tKgmSn0DpSatfri0nx52Joq5hVXgeLiqR/5G0sZNDoLZFOr/xjBUDcShCOGNsBnEMNo1KAMBkTej1Hm62HTw==", "dev": true, "requires": { "flat": "^4.1.0", - "lodash": "^4.17.11", - "yargs": "^12.0.5" - }, - "dependencies": { - "ansi-regex": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", - "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", - "dev": true - }, - "get-caller-file": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-1.0.3.tgz", - "integrity": "sha512-3t6rVToeoZfYSGd8YoLFR2DJkiQrIiUrGcjvFX2mDw3bn6k2OtwHN0TNCLbBO+w8qTvimhDkv+LSscbJY1vE6w==", - "dev": true - }, - "is-fullwidth-code-point": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", - "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", - "dev": true - }, - "require-main-filename": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-1.0.1.tgz", - "integrity": "sha1-l/cXtp1IeE9fUmpsWqj/3aBVpNE=", - "dev": true - }, - "string-width": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", - "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", - "dev": true, - "requires": { - "is-fullwidth-code-point": "^2.0.0", - "strip-ansi": "^4.0.0" - } - }, - "strip-ansi": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", - "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", - "dev": true, - "requires": { - "ansi-regex": "^3.0.0" - } - }, - "yargs": { - "version": "12.0.5", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-12.0.5.tgz", - "integrity": "sha512-Lhz8TLaYnxq/2ObqHDql8dX8CJi97oHxrjUcYtzKbbykPtVW9WB+poxI+NM2UIzsMgNCZTIf0AQwsjK5yMAqZw==", - "dev": true, - "requires": { - "cliui": "^4.0.0", - "decamelize": "^1.2.0", - "find-up": "^3.0.0", - "get-caller-file": "^1.0.1", - "os-locale": "^3.0.0", - "require-directory": "^2.1.1", - "require-main-filename": "^1.0.1", - "set-blocking": "^2.0.0", - "string-width": "^2.0.0", - "which-module": "^2.0.0", - "y18n": "^3.2.1 || ^4.0.0", - "yargs-parser": "^11.1.1" - } - }, - "yargs-parser": { - "version": "11.1.1", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-11.1.1.tgz", - "integrity": "sha512-C6kB/WJDiaxONLJQnF8ccx9SEeoTTLek8RVbaOIsrAUS8VrBEXfmeSnCZxygc+XC2sNMBIwOOnfcxiynjHsVSQ==", - "dev": true, - "requires": { - "camelcase": "^5.0.0", - "decamelize": "^1.2.0" - } - } + "lodash": "^4.17.15", + "yargs": "^13.3.0" } } } From 9724c90ad2a254924cd2c159b2641c639f8e4d63 Mon Sep 17 00:00:00 2001 From: Philippe Coval Date: Thu, 20 Feb 2020 16:54:33 +0100 Subject: [PATCH 072/114] 1.9.2-6 Change-Id: I0342a1cdefb7e4877090f02193f3d01facf78cba --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 5d696c47a..80bba566e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@abandonware/noble", - "version": "1.9.2-5", + "version": "1.9.2-6", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index e53ab9bab..2ebdca3bb 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "license": "MIT", "name": "@abandonware/noble", "description": "A Node.js BLE (Bluetooth Low Energy) central library.", - "version": "1.9.2-5", + "version": "1.9.2-6", "repository": { "type": "git", "url": "https://github.com/abandonware/noble.git" From 82dcf701cfe08f395ede1cdb2d11707aa94bca05 Mon Sep 17 00:00:00 2001 From: Hideki Takeoka Date: Fri, 8 Mar 2019 17:00:07 +0100 Subject: [PATCH 073/114] Allow to read long characteristic value / descriptor Acked-by: Hideki Takeoka --- lib/hci-socket/gatt.js | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/lib/hci-socket/gatt.js b/lib/hci-socket/gatt.js index 2df7d1022..892b38b2d 100644 --- a/lib/hci-socket/gatt.js +++ b/lib/hci-socket/gatt.js @@ -741,7 +741,7 @@ Gatt.prototype.discoverDescriptors = function (serviceUuid, characteristicUuid) Gatt.prototype.readValue = function (serviceUuid, characteristicUuid, descriptorUuid) { const descriptor = this._descriptors[serviceUuid][characteristicUuid][descriptorUuid]; - var readData = new Buffer(0); + let readData = new Buffer(0); this._queueCommand(this.readRequest(descriptor.handle), data => { const opcode = data[0]; @@ -758,7 +758,9 @@ Gatt.prototype.readValue = function (serviceUuid, characteristicUuid, descriptor } else { this.emit('valueRead', this._address, serviceUuid, characteristicUuid, descriptorUuid, readData); } - }); + }; + + this._queueCommand(this.readRequest(descriptor.handle), callback); }; Gatt.prototype.writeValue = function (serviceUuid, characteristicUuid, descriptorUuid, data) { @@ -774,13 +776,23 @@ Gatt.prototype.writeValue = function (serviceUuid, characteristicUuid, descripto }; Gatt.prototype.readHandle = function (handle) { - this._queueCommand(this.readRequest(handle), data => { - const opcode = data[0]; + let readData = Buffer.alloc(0); - if (opcode === ATT_OP_READ_RESP) { - this.emit('handleRead', this._address, handle, data.slice(1)); + const callback = (data) => { + const opcode = data[0]; + if (opcode === ATT_OP_READ_RESP || opcode === ATT_OP_READ_BLOB_RESP) { + readData = Buffer.from(`${readData.toString('hex')}${data.slice(1).toString('hex')}`, 'hex'); + if (data.length === this._mtu) { + this._queueCommand(this.readBlobRequest(handle, readData.length), callback); + } else { + this.emit('handleRead', this._address, handle, readData); + } + } else { + this.emit('handleRead', this._address, handle, readData); } - }); + }; + + this._queueCommand(this.readRequest(handle), callback); }; Gatt.prototype.writeHandle = function (handle, data, withoutResponse) { From 1d793658048a154060ab4e105eeb74db3c1e1d59 Mon Sep 17 00:00:00 2001 From: Philippe Coval Date: Mon, 2 Mar 2020 12:56:26 +0100 Subject: [PATCH 074/114] github: Drop node-6 support Change-Id: I1b3a03717036da9d7a0ef1f489cc0091a09c63a6 Relate-to: https://github.com/abandonware/noble/pull/46 Signed-off-by: Philippe Coval --- .github/workflows/nodepackage.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/nodepackage.yml b/.github/workflows/nodepackage.yml index f05374ea2..b7f1632cb 100644 --- a/.github/workflows/nodepackage.yml +++ b/.github/workflows/nodepackage.yml @@ -18,7 +18,6 @@ jobs: macos-latest, ] node: [ - 6, 8, 10, 12, From d9567db038918277ae8115380d2081b1e7e274bf Mon Sep 17 00:00:00 2001 From: Philippe Coval Date: Thu, 5 Mar 2020 12:15:52 +0100 Subject: [PATCH 075/114] github: Add npm-publish action Origin: https://github.com/marketplace/actions/publish-to-npm Signed-off-by: Philippe Coval Change-Id: I25337e6b6272ad4fd9c3a1bcca486a921192b9ff --- .github/workflows/npm-publish.yml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 .github/workflows/npm-publish.yml diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml new file mode 100644 index 000000000..3586899df --- /dev/null +++ b/.github/workflows/npm-publish.yml @@ -0,0 +1,25 @@ +name: npm-publish +on: + push: + branches: + - master # Change this to your default branch +jobs: + npm-publish: + name: npm-publish + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@master + - name: Set up Node.js + uses: actions/setup-node@master + with: + node-version: 10.0.0 + - name: Publish if version has been updated + uses: pascalgn/npm-publish-action@51fdb4531e99aac1873764ef7271af448dc42ab4 + with: # All of theses inputs are optional + tag_name: "v%s" + tag_message: "v%s" + commit_pattern: "^Release (\\S+)" + env: # More info about the environment variables in the README + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Leave this as is, it's automatically generated + NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} # You need to set this in your repo settings From 75997d500155a47b9752905a5434774e964bbd9e Mon Sep 17 00:00:00 2001 From: Philippe Coval Date: Thu, 5 Mar 2020 13:38:14 +0100 Subject: [PATCH 076/114] npm: Update dependencies to current Signed-off-by: Philippe Coval --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 2ebdca3bb..bc20b492d 100644 --- a/package.json +++ b/package.json @@ -39,10 +39,10 @@ "node-addon-api": "^2.0.0" }, "optionalDependencies": { - "@abandonware/bluetooth-hci-socket": "^0.5.3-4" + "@abandonware/bluetooth-hci-socket": "^0.5.3-5" }, "devDependencies": { - "async": "^3.1.1", + "async": "^3.2.0", "eslint": "^6.8.0", "eslint-config-semistandard": "^15.0.0", "eslint-config-standard": "^14.1.0", @@ -51,7 +51,7 @@ "eslint-plugin-promise": "^4.2.1", "eslint-plugin-standard": "^4.0.1", "install": "^0.13.0", - "mocha": "^7.0.1", + "mocha": "^7.1.0", "node-gyp": "^6.1.0", "prettier": "^1.19.1", "should": "~13.2.3", From 35758019cec6f182194ae3316c260e25382565d5 Mon Sep 17 00:00:00 2001 From: Philippe Coval Date: Thu, 5 Mar 2020 13:38:31 +0100 Subject: [PATCH 077/114] npm: Lock dependencies Signed-off-by: Philippe Coval --- package-lock.json | 239 +++++++++++++++++++++++++++------------------- 1 file changed, 141 insertions(+), 98 deletions(-) diff --git a/package-lock.json b/package-lock.json index 80bba566e..c03a4bfb4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,15 +5,15 @@ "requires": true, "dependencies": { "@abandonware/bluetooth-hci-socket": { - "version": "0.5.3-4", - "resolved": "https://registry.npmjs.org/@abandonware/bluetooth-hci-socket/-/bluetooth-hci-socket-0.5.3-4.tgz", - "integrity": "sha512-hxYIj1qBZVyayJDuN1yhZPzNvuSlCSoFEiWRSZ8nqSvKGQzBddWRTASmlQqVn15G4hHVkjk0xDXjzwUkEgaDyA==", + "version": "0.5.3-5", + "resolved": "https://registry.npmjs.org/@abandonware/bluetooth-hci-socket/-/bluetooth-hci-socket-0.5.3-5.tgz", + "integrity": "sha512-q9DupPXYcqLyLFrmJqYDaqXoN0fOR4qOZA39dJbEeu1M583Ghr5Bn+JlEAnA6l88DJSBZiyjtCgItDeUfuRwMA==", "optional": true, "requires": { - "debug": "^4.1.0", + "debug": "^4.1.1", "nan": "^2.14.0", - "node-pre-gyp": "^0.13.0", - "usb": "^1.6.0" + "node-pre-gyp": "^0.14.0", + "usb": "^1.6.2" } }, "@babel/code-frame": { @@ -65,13 +65,12 @@ } }, "@sinonjs/samsam": { - "version": "5.0.2", - "resolved": "https://registry.npmjs.org/@sinonjs/samsam/-/samsam-5.0.2.tgz", - "integrity": "sha512-p3yrEVB5F/1wI+835n+X8llOGRgV8+jw5BHQ/cJoLBUXXZ5U8Tr5ApwPc4L4av/vjla48kVPoN0t6dykQm+Rvg==", + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/@sinonjs/samsam/-/samsam-5.0.3.tgz", + "integrity": "sha512-QucHkc2uMJ0pFGjJUDP3F9dq5dx8QIaqISl9QgwLOh6P9yv877uONPGXh/OH/0zmM3tW1JjuJltAZV2l7zU+uQ==", "dev": true, "requires": { "@sinonjs/commons": "^1.6.0", - "@sinonjs/formatio": "^5.0.0", "lodash.get": "^4.4.2", "type-detect": "^4.0.8" } @@ -82,27 +81,33 @@ "integrity": "sha512-+iTbntw2IZPb/anVDbypzfQa+ay64MW0Zo8aJ8gZPWMMK6/OubMVb6lUPMagqjOPnmtauXnFCACVl3O7ogjeqQ==", "dev": true }, + "@types/color-name": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@types/color-name/-/color-name-1.1.1.tgz", + "integrity": "sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ==", + "dev": true + }, "abbrev": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==" }, "acorn": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.1.0.tgz", - "integrity": "sha512-kL5CuoXA/dgxlBbVrflsflzQ3PAas7RYZB52NOm/6839iVYJgKMJ3cQJD+t2i5+qFa8h3MDpEOJiS64E8JLnSQ==", + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.1.1.tgz", + "integrity": "sha512-add7dgA5ppRPxCFJoAGfMDi7PIBXq1RtGo7BhbLaxwrXPOmw8gq48Y9ozT01hUKy9byMjlR20EJhu5zlkErEkg==", "dev": true }, "acorn-jsx": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.1.0.tgz", - "integrity": "sha512-tMUqwBWfLFbJbizRmEcWSLw6HnFzfdJs2sOJEOwwtVPMoH/0Ay+E703oZz78VSXZiiDcZrQ5XKjPIUQixhmgVw==", + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.2.0.tgz", + "integrity": "sha512-HiUX/+K2YpkpJ+SzBffkM/AQ2YE03S0U1kjTLVpoJdhZMOWy8qvXVN9JdLqv2QsaQ6MPYQIuNmwD8zOiYUofLQ==", "dev": true }, "ajv": { - "version": "6.11.0", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.11.0.tgz", - "integrity": "sha512-nCprB/0syFYy9fVYU1ox1l2KN8S9I+tziH8D4zdZuLT3N6RMlGSGt5FSTpAiHB/Whv8Qs1cWHma1aMKZyaHRKA==", + "version": "6.12.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.0.tgz", + "integrity": "sha512-D6gFiFA0RRLyUbvijN74DWAjXSFxWKaWP7mldxkVhyhAV3+SWA9HEJPHQ2c9soIeTFJqcSdFDGFgdqs1iUU2Hw==", "dev": true, "requires": { "fast-deep-equal": "^3.1.1", @@ -118,12 +123,20 @@ "dev": true }, "ansi-escapes": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-4.3.0.tgz", - "integrity": "sha512-EiYhwo0v255HUL6eDyuLrXEkTi7WwVCLAw+SeOQ7M7qdun1z1pum4DEm/nuqIVbPvi9RPPc9k9LbyBv6H0DwVg==", + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-4.3.1.tgz", + "integrity": "sha512-JWF7ocqNrp8u9oqpgV+wH5ftbt+cfvv+PTjOvKLT3AdYly/LmORARfEVT1iyjwN+4MqE5UmVKoAdIBqeoCHgLA==", "dev": true, "requires": { - "type-fest": "^0.8.1" + "type-fest": "^0.11.0" + }, + "dependencies": { + "type-fest": { + "version": "0.11.0", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.11.0.tgz", + "integrity": "sha512-OdjXJxnCN1AvyLSzeKIgXTXxV+99ZuXl3Hpo9XpJAv9MBcHrrJOQ5kV7ypXOuQie+AmWG25hLbiKdwYTifzcfQ==", + "dev": true + } } }, "ansi-regex": { @@ -216,9 +229,9 @@ "dev": true }, "async": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/async/-/async-3.1.1.tgz", - "integrity": "sha512-X5Dj8hK1pJNC2Wzo2Rcp9FBVdJMGRR/S7V+lH46s8GVFhtbo5O4Le5GECCF/8PISVdkUA6mMPvgz7qTTD1rf1g==", + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/async/-/async-3.2.0.tgz", + "integrity": "sha512-TR2mEZFVOj2pLStYxLht7TyfuRzaydfpxr3k9RpHIzMgw7A64dzsdqCxH1WJyQdoe8T10nDXd9wnEigmiuHIZw==", "dev": true }, "asynckit": { @@ -269,12 +282,12 @@ } }, "bl": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/bl/-/bl-3.0.0.tgz", - "integrity": "sha512-EUAyP5UHU5hxF8BPT0LKW8gjYLhq1DQIcneOX/pL/m2Alo+OYDQAJlHq+yseMP50Os2nHXOSic6Ss3vSQeyf4A==", + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/bl/-/bl-4.0.1.tgz", + "integrity": "sha512-FL/TdvchukRCuWVxT0YMO/7+L5TNeNrVFvRU2IY63aUyv9mpt8splf2NEr6qXtPo5fya5a66YohQKvGNmLrWNA==", "optional": true, "requires": { - "readable-stream": "^3.0.1" + "readable-stream": "^3.4.0" }, "dependencies": { "readable-stream": { @@ -949,13 +962,13 @@ "dev": true }, "espree": { - "version": "6.1.2", - "resolved": "https://registry.npmjs.org/espree/-/espree-6.1.2.tgz", - "integrity": "sha512-2iUPuuPP+yW1PZaMSDM9eyVf8D5P0Hi8h83YtZ5bPc/zHYjII5khoixIUTMO794NOY8F/ThF1Bo8ncZILarUTA==", + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/espree/-/espree-6.2.0.tgz", + "integrity": "sha512-Xs8airJ7RQolnDIbLtRutmfvSsAe0xqMMAantCN/GMoqf81TFbeI1T7Jpd56qYu1uuh32dOG5W/X9uO+ghPXzA==", "dev": true, "requires": { "acorn": "^7.1.0", - "acorn-jsx": "^5.1.0", + "acorn-jsx": "^5.2.0", "eslint-visitor-keys": "^1.1.0" } }, @@ -1304,9 +1317,9 @@ "dev": true }, "hosted-git-info": { - "version": "2.8.5", - "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.5.tgz", - "integrity": "sha512-kssjab8CvdXfcXMXVcvsXum4Hwdq9XGtRD3TteMEvEbq0LXyiNQr6AprqKqfeaDXze7SxWvRxdpwE6ku7ikLkg==", + "version": "2.8.8", + "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.8.tgz", + "integrity": "sha512-f/wzC2QaWBs7t9IYqB4T3sR1xviIViXJRJTWBlx2Gf3g0Xi5vI7Yy4koXQ1c9OYDGHN9sBy1DQ2AB8fqZBWhUg==", "dev": true }, "http-signature": { @@ -1380,23 +1393,23 @@ "optional": true }, "inquirer": { - "version": "7.0.4", - "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-7.0.4.tgz", - "integrity": "sha512-Bu5Td5+j11sCkqfqmUTiwv+tWisMtP0L7Q8WrqA2C/BbBhy1YTdFrvjjlrKq8oagA/tLQBski2Gcx/Sqyi2qSQ==", + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-7.0.6.tgz", + "integrity": "sha512-7SVO4h+QIdMq6XcqIqrNte3gS5MzCCKZdsq9DO4PJziBFNYzP3PGFbDjgadDb//MCahzgjCxvQ/O2wa7kx9o4w==", "dev": true, "requires": { "ansi-escapes": "^4.2.1", - "chalk": "^2.4.2", + "chalk": "^3.0.0", "cli-cursor": "^3.1.0", "cli-width": "^2.0.0", "external-editor": "^3.0.3", "figures": "^3.0.0", "lodash": "^4.17.15", "mute-stream": "0.0.8", - "run-async": "^2.2.0", + "run-async": "^2.4.0", "rxjs": "^6.5.3", "string-width": "^4.1.0", - "strip-ansi": "^5.1.0", + "strip-ansi": "^6.0.0", "through": "^2.3.6" }, "dependencies": { @@ -1406,6 +1419,47 @@ "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==", "dev": true }, + "ansi-styles": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz", + "integrity": "sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==", + "dev": true, + "requires": { + "@types/color-name": "^1.1.1", + "color-convert": "^2.0.1" + } + }, + "chalk": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-3.0.0.tgz", + "integrity": "sha512-4D3B6Wf41KOYRFdszmDqMCGq5VV/uMAB273JILmO+3jAlh8X4qDtdtgCR3fxtbLEMzSx22QdhnDcJvu2u1fVwg==", + "dev": true, + "requires": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, "is-fullwidth-code-point": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", @@ -1421,34 +1475,24 @@ "emoji-regex": "^8.0.0", "is-fullwidth-code-point": "^3.0.0", "strip-ansi": "^6.0.0" - }, - "dependencies": { - "strip-ansi": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", - "integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==", - "dev": true, - "requires": { - "ansi-regex": "^5.0.0" - } - } } }, "strip-ansi": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", - "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", + "integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==", "dev": true, "requires": { - "ansi-regex": "^4.1.0" - }, - "dependencies": { - "ansi-regex": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", - "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", - "dev": true - } + "ansi-regex": "^5.0.0" + } + }, + "supports-color": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.1.0.tgz", + "integrity": "sha512-oRSIpR8pxT1Wr2FquTNnGet79b3BWljqOuoW/h4oBhxJ/HUbX5nX6JSruTkvXDCFMwDPvsaTTbvMLKZWSy0R5g==", + "dev": true, + "requires": { + "has-flag": "^4.0.0" } } } @@ -1633,9 +1677,9 @@ } }, "just-extend": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/just-extend/-/just-extend-4.0.2.tgz", - "integrity": "sha512-FrLwOgm+iXrPV+5zDU6Jqu4gCRXbWEQg2O3SKONsWE4w7AXFRkryS53bpWdaL9cNol+AmR3AEYz6kn+o0fCPnw==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/just-extend/-/just-extend-4.1.0.tgz", + "integrity": "sha512-ApcjaOdVTJ7y4r08xI5wIqpvwS48Q0PBG4DJROcEkH1f8MdAiNFyFxz3xoL0LWAVwjrwPYZdVHHxhRHcx/uGLA==", "dev": true }, "levn": { @@ -1683,12 +1727,12 @@ "dev": true }, "log-symbols": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-2.2.0.tgz", - "integrity": "sha512-VeIAFslyIerEJLXHziedo2basKbMKtTw3vfn5IzG0XTjhAVEJyNHnL2p7vc+wBDSdQuUpNw3M2u6xb9QsAY5Eg==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-3.0.0.tgz", + "integrity": "sha512-dSkNGuI7iG3mfvDzUuYZyvk5dD9ocYCYzNU6CYDE6+Xqd+gwme6Z00NS3dUh8mq/73HaEtT7m6W+yUPtU6BZnQ==", "dev": true, "requires": { - "chalk": "^2.0.1" + "chalk": "^2.4.2" } }, "mime-db": { @@ -1757,9 +1801,9 @@ } }, "mocha": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-7.0.1.tgz", - "integrity": "sha512-9eWmWTdHLXh72rGrdZjNbG3aa1/3NRPpul1z0D979QpEnFdCG0Q5tv834N+94QEN2cysfV72YocQ3fn87s70fg==", + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-7.1.0.tgz", + "integrity": "sha512-MymHK8UkU0K15Q/zX7uflZgVoRWiTjy0fXE/QjKts6mowUvGxOdPhZ2qj3b0iZdUrNZlW9LAIMFHB4IW+2b3EQ==", "dev": true, "requires": { "ansi-colors": "3.2.3", @@ -1773,7 +1817,7 @@ "growl": "1.10.5", "he": "1.2.0", "js-yaml": "3.13.1", - "log-symbols": "2.2.0", + "log-symbols": "3.0.0", "minimatch": "3.0.4", "mkdirp": "0.5.1", "ms": "2.1.1", @@ -1906,9 +1950,9 @@ "dev": true }, "needle": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/needle/-/needle-2.3.2.tgz", - "integrity": "sha512-DUzITvPVDUy6vczKKYTnWc/pBZ0EnjMJnQ3y+Jo5zfKFimJs7S3HFCxCRZYB9FUZcrzUQr3WsmvZgddMEIZv6w==", + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/needle/-/needle-2.3.3.tgz", + "integrity": "sha512-EkY0GeSq87rWp1hoq/sH/wnTWgFVhYlnIkbJ0YJFfRgEFlz2RraCjBpFQ+vrEgEdp0ThfyHADmkChEhcb7PKyw==", "optional": true, "requires": { "debug": "^3.2.6", @@ -1934,14 +1978,13 @@ "dev": true }, "nise": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/nise/-/nise-4.0.2.tgz", - "integrity": "sha512-ALDnm0pTTyeGdbg5FCpWGd58Nmp3qO8d8x+dU2Fw8lApeJTEBSjkBZZM4S8t6GpKh+czxkfM/TKxpRMroZzwOg==", + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/nise/-/nise-4.0.3.tgz", + "integrity": "sha512-EGlhjm7/4KvmmE6B/UFsKh7eHykRl9VH+au8dduHLCyWUO/hr7+N+WtTvDUwc9zHuM1IaIJs/0lQ6Ag1jDkQSg==", "dev": true, "requires": { "@sinonjs/commons": "^1.7.0", "@sinonjs/fake-timers": "^6.0.0", - "@sinonjs/formatio": "^5.0.1", "@sinonjs/text-encoding": "^0.7.1", "just-extend": "^4.0.2", "path-to-regexp": "^1.7.0" @@ -1991,9 +2034,9 @@ } }, "node-pre-gyp": { - "version": "0.13.0", - "resolved": "https://registry.npmjs.org/node-pre-gyp/-/node-pre-gyp-0.13.0.tgz", - "integrity": "sha512-Md1D3xnEne8b/HGVQkZZwV27WUi1ZRuZBij24TNaZwUPU3ZAFtvT6xxJGaUVillfmMKnn5oD1HoGsp2Ftik7SQ==", + "version": "0.14.0", + "resolved": "https://registry.npmjs.org/node-pre-gyp/-/node-pre-gyp-0.14.0.tgz", + "integrity": "sha512-+CvDC7ZttU/sSt9rFjix/P05iS43qHCOOGzcr3Ry99bXG7VX953+vFyEuph/tfqoYu8dttBkE86JSKBO2OzcxA==", "optional": true, "requires": { "detect-libc": "^1.0.2", @@ -2005,7 +2048,7 @@ "rc": "^1.2.7", "rimraf": "^2.6.1", "semver": "^5.3.0", - "tar": "^4" + "tar": "^4.4.2" } }, "noop-logger": { @@ -2534,9 +2577,9 @@ } }, "run-async": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/run-async/-/run-async-2.3.0.tgz", - "integrity": "sha1-A3GrSuC91yDUFm19/aZP96RFpsA=", + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/run-async/-/run-async-2.4.0.tgz", + "integrity": "sha512-xJTbh/d7Lm7SBhc1tNvTpeCHaEzoyxPrqNlvSdMfBTYwaY++UJFyXUOxAtsRUXjlqOfj8luNaR9vjCh4KeV+pg==", "dev": true, "requires": { "is-promise": "^2.1.0" @@ -2925,12 +2968,12 @@ } }, "tar-stream": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-2.1.0.tgz", - "integrity": "sha512-+DAn4Nb4+gz6WZigRzKEZl1QuJVOLtAwwF+WUxy1fJ6X63CaGaUAxJRD2KEn1OMfcbCjySTYpNC6WmfQoIEOdw==", + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-2.1.1.tgz", + "integrity": "sha512-GZjLk64XcE/58qwIc1ZfXGqTSE4OutPMEkfBE/oh9eJ4x1eMRjYkgrLrav7PzddpvIpSJSGi8FgNNYXdB9Vumg==", "optional": true, "requires": { - "bl": "^3.0.0", + "bl": "^4.0.1", "end-of-stream": "^1.4.1", "fs-constants": "^1.0.0", "inherits": "^2.0.3", @@ -2991,9 +3034,9 @@ } }, "tslib": { - "version": "1.10.0", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.10.0.tgz", - "integrity": "sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==", + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.11.1.tgz", + "integrity": "sha512-aZW88SY8kQbU7gpV19lN24LtXh/yD4ZZg6qieAJDDg+YBsJcSmLGK9QpnUjAKVG/xefmvJGd1WUmfpT/g6AJGA==", "dev": true }, "tunnel-agent": { From 0e35028f22a115364273605bf04f4f83e5ca1fdb Mon Sep 17 00:00:00 2001 From: Philippe Coval Date: Thu, 5 Mar 2020 13:38:46 +0100 Subject: [PATCH 078/114] Release 1.9.2-7 Relate-to: https://www.npmjs.com/package/@abandonware/noble/v/1.9.2-7 Change-Id: I0178703194d4de5aadf5804d5720e7274bff3694 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index c03a4bfb4..29a01d879 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@abandonware/noble", - "version": "1.9.2-6", + "version": "1.9.2-7", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index bc20b492d..cd8b017a2 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "license": "MIT", "name": "@abandonware/noble", "description": "A Node.js BLE (Bluetooth Low Energy) central library.", - "version": "1.9.2-6", + "version": "1.9.2-7", "repository": { "type": "git", "url": "https://github.com/abandonware/noble.git" From d5072f1639f7c4f81d482b3579b9c5fce34fa92e Mon Sep 17 00:00:00 2001 From: Philippe Coval Date: Thu, 5 Mar 2020 13:47:29 +0100 Subject: [PATCH 079/114] github: Build for node-13 Signed-off-by: Philippe Coval Change-Id: I69a41400fbe33dd2c0e1c94ccb64a0d01ece9cfb --- .github/workflows/nodepackage.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/nodepackage.yml b/.github/workflows/nodepackage.yml index b7f1632cb..526c10ef8 100644 --- a/.github/workflows/nodepackage.yml +++ b/.github/workflows/nodepackage.yml @@ -21,6 +21,7 @@ jobs: 8, 10, 12, + 13, ] steps: - uses: actions/checkout@v1 From 43605358c5660fd1dbc9e23393de4697cb5828e3 Mon Sep 17 00:00:00 2001 From: Ron Smeral Date: Wed, 18 Mar 2020 00:38:29 +0100 Subject: [PATCH 080/114] Add support for promises --- index.d.ts | 28 +++++++++++++++++++ lib/characteristic.js | 35 ++++++++++++++++++----- lib/descriptor.js | 10 +++++-- lib/noble.js | 8 +++++- lib/peripheral.js | 64 ++++++++++++++++++++++++++++++++++++++----- lib/service.js | 10 +++++-- 6 files changed, 136 insertions(+), 19 deletions(-) diff --git a/index.d.ts b/index.d.ts index acaa39f13..888dd0f76 100644 --- a/index.d.ts +++ b/index.d.ts @@ -14,9 +14,13 @@ import events = require("events"); export declare function startScanning(callback?: (error?: Error) => void): void; +export declare function startScanningAsync(): Promise; export declare function startScanning(serviceUUIDs: string[], callback?: (error?: Error) => void): void; +export declare function startScanningAsync(serviceUUIDs: string[]): Promise; export declare function startScanning(serviceUUIDs: string[], allowDuplicates: boolean, callback?: (error?: Error) => void): void; +export declare function startScanningAsync(serviceUUIDs: string[], allowDuplicates: boolean): Promise; export declare function stopScanning(callback?: () => void): void; +export declare function stopScanningAsync(): Promise; export declare function on(event: "stateChange", listener: (state: string) => void): events.EventEmitter; export declare function on(event: "scanStart", listener: () => void): events.EventEmitter; @@ -34,6 +38,11 @@ export declare function removeAllListeners(event?: string): events.EventEmitter; export declare var state: string; +export interface ServicesAndCharacteristics { + services: Service[]; + characteristics: Characteristic[]; +}; + export declare class Peripheral extends events.EventEmitter { id: string; uuid: string; @@ -46,14 +55,22 @@ export declare class Peripheral extends events.EventEmitter { state: 'error' | 'connecting' | 'connected' | 'disconnecting' | 'disconnected'; connect(callback?: (error: string) => void): void; + connectAsync(): Promise; disconnect(callback?: () => void): void; + disconnectAsync(): Promise; updateRssi(callback?: (error: string, rssi: number) => void): void; + updateRssiAsync(): Promise; discoverServices(serviceUUIDs: string[], callback?: (error: string, services: Service[]) => void): void; + discoverServicesAsync(serviceUUIDs: string[]): Promise; discoverAllServicesAndCharacteristics(callback?: (error: string, services: Service[], characteristics: Characteristic[]) => void): void; + discoverAllServicesAndCharacteristicsAsync(): Promise; discoverSomeServicesAndCharacteristics(serviceUUIDs: string[], characteristicUUIDs: string[], callback?: (error: string, services: Service[], characteristics: Characteristic[]) => void): void; + discoverSomeServicesAndCharacteristicsAsync(serviceUUIDs: string[], characteristicUUIDs: string[]): Promise; readHandle(handle: Buffer, callback: (error: string, data: Buffer) => void): void; + readHandleAsync(handle: Buffer): Promise; writeHandle(handle: Buffer, data: Buffer, withoutResponse: boolean, callback: (error: string) => void): void; + writeHandleAsync(handle: Buffer, data: Buffer, withoutResponse: boolean): Promise; toString(): string; on(event: "connect", listener: (error: string) => void): this; @@ -82,7 +99,9 @@ export declare class Service extends events.EventEmitter { characteristics: Characteristic[]; discoverIncludedServices(serviceUUIDs: string[], callback?: (error: string, includedServiceUuids: string[]) => void): void; + discoverIncludedServicesAsync(serviceUUIDs: string[]): Promise; discoverCharacteristics(characteristicUUIDs: string[], callback?: (error: string, characteristics: Characteristic[]) => void): void; + discoverCharacteristicsAsync(characteristicUUIDs: string[]): Promise; toString(): string; on(event: "includedServicesDiscover", listener: (includedServiceUuids: string[]) => void): this; @@ -98,13 +117,20 @@ export declare class Characteristic extends events.EventEmitter { descriptors: Descriptor[]; read(callback?: (error: string, data: Buffer) => void): void; + readAsync(): Promise; write(data: Buffer, notify: boolean, callback?: (error: string) => void): void; + writeAsync(data: Buffer, notify: boolean): Promise; broadcast(broadcast: boolean, callback?: (error: string) => void): void; + broadcastAsync(broadcast: boolean): Promise; notify(notify: boolean, callback?: (error: string) => void): void; + notifyAsync(notify: boolean): Promise; discoverDescriptors(callback?: (error: string, descriptors: Descriptor[]) => void): void; + discoverDescriptorsAsync(): Promise; toString(): string; subscribe(callback?: (error: string) => void): void; + subscribeAsync(): Promise; unsubscribe(callback?: (error: string) => void): void; + unsubscribeAsync(): Promise; on(event: "read", listener: (data: Buffer, isNotification: boolean) => void): this; on(event: "write", withoutResponse: boolean, listener: (error: string) => void): this; @@ -121,7 +147,9 @@ export declare class Descriptor extends events.EventEmitter { type: string; readValue(callback?: (error: string, data: Buffer) => void): void; + readValueAsync(): Promise; writeValue(data: Buffer, callback?: (error: string) => void): void; + writeValueAsync(data: Buffer): Promise; toString(): string; on(event: "valueRead", listener: (error: string, data: Buffer) => void): this; diff --git a/lib/characteristic.js b/lib/characteristic.js index 4f0de5e83..0d4a1ec90 100644 --- a/lib/characteristic.js +++ b/lib/characteristic.js @@ -32,7 +32,7 @@ Characteristic.prototype.toString = function () { }); }; -Characteristic.prototype.read = function (callback) { +const read = function (callback) { if (callback) { const onRead = (data, isNotification) => { // only call the callback if 'read' event and non-notification @@ -56,7 +56,10 @@ Characteristic.prototype.read = function (callback) { ); }; -Characteristic.prototype.write = function (data, withoutResponse, callback) { +Characteristic.prototype.read = read; +Characteristic.prototype.readAsync = util.promisify(read); + +const write = function (data, withoutResponse, callback) { if (process.title !== 'browser') { if (!(data instanceof Buffer)) { throw new Error('data must be a Buffer'); @@ -78,7 +81,10 @@ Characteristic.prototype.write = function (data, withoutResponse, callback) { ); }; -Characteristic.prototype.broadcast = function (broadcast, callback) { +Characteristic.prototype.write = write; +Characteristic.prototype.writeAsync = util.promisify(write); + +const broadcast = function (broadcast, callback) { if (callback) { this.once('broadcast', () => { callback(null); @@ -93,8 +99,11 @@ Characteristic.prototype.broadcast = function (broadcast, callback) { ); }; +Characteristic.prototype.broadcast = broadcast; +Characteristic.prototype.broadcastAsync = util.promisify(broadcast); + // deprecated in favour of subscribe/unsubscribe -Characteristic.prototype.notify = function (notify, callback) { +const notify = function (notify, callback) { if (callback) { this.once('notify', () => { callback(null); @@ -109,15 +118,24 @@ Characteristic.prototype.notify = function (notify, callback) { ); }; -Characteristic.prototype.subscribe = function (callback) { +Characteristic.prototype.notify = notify; +Characteristic.prototype.notifyAsync = util.promisify(notify); + +const subscribe = function (callback) { this.notify(true, callback); }; -Characteristic.prototype.unsubscribe = function (callback) { +Characteristic.prototype.subscribe = subscribe; +Characteristic.prototype.subscribeAsync = util.promisify(subscribe); + +const unsubscribe = function (callback) { this.notify(false, callback); }; -Characteristic.prototype.discoverDescriptors = function (callback) { +Characteristic.prototype.unsubscribe = unsubscribe; +Characteristic.prototype.unsubscribeAsync = util.promisify(unsubscribe); + +const discoverDescriptors = function (callback) { if (callback) { this.once('descriptorsDiscover', descriptors => { callback(null, descriptors); @@ -131,4 +149,7 @@ Characteristic.prototype.discoverDescriptors = function (callback) { ); }; +Characteristic.prototype.discoverDescriptors = discoverDescriptors; +Characteristic.prototype.discoverDescriptorsAsync = util.promisify(discoverDescriptors); + module.exports = Characteristic; diff --git a/lib/descriptor.js b/lib/descriptor.js index 6c87d1ae2..5539222b4 100644 --- a/lib/descriptor.js +++ b/lib/descriptor.js @@ -30,7 +30,7 @@ Descriptor.prototype.toString = function () { }); }; -Descriptor.prototype.readValue = function (callback) { +const readValue = function (callback) { if (callback) { this.once('valueRead', data => { callback(null, data); @@ -44,7 +44,10 @@ Descriptor.prototype.readValue = function (callback) { ); }; -Descriptor.prototype.writeValue = function (data, callback) { +Descriptor.prototype.readValue = readValue; +Descriptor.prototype.readValueAsync = util.promisify(readValue); + +const writeValue = function (data, callback) { if (!(data instanceof Buffer)) { throw new Error('data must be a Buffer'); } @@ -63,4 +66,7 @@ Descriptor.prototype.writeValue = function (data, callback) { ); }; +Descriptor.prototype.writeValue = writeValue; +Descriptor.prototype.writeValueAsync = util.promisify(writeValue); + module.exports = Descriptor; diff --git a/lib/noble.js b/lib/noble.js index 293fa988a..df4b34a87 100644 --- a/lib/noble.js +++ b/lib/noble.js @@ -142,12 +142,15 @@ Noble.prototype.startScanning = function (serviceUuids, allowDuplicates, callbac } }; +Noble.prototype.startScanning = startScanning; +Noble.prototype.startScanningAsync = util.promisify(startScanning); + Noble.prototype.onScanStart = function (filterDuplicates) { debug('scanStart'); this.emit('scanStart', filterDuplicates); }; -Noble.prototype.stopScanning = function (callback) { +const stopScanning = function (callback) { if (callback) { this.once('scanStop', callback); } @@ -156,6 +159,9 @@ Noble.prototype.stopScanning = function (callback) { } }; +Noble.prototype.stopScanning = stopScanning; +Noble.prototype.stopScanningAsync = util.promisify(stopScanning); + Noble.prototype.onScanStop = function () { debug('scanStop'); this.emit('scanStop'); diff --git a/lib/peripheral.js b/lib/peripheral.js index 2e78cdab5..4361cec28 100644 --- a/lib/peripheral.js +++ b/lib/peripheral.js @@ -70,7 +70,10 @@ Peripheral.prototype.cancelConnect = function (options, callback) { } }; -Peripheral.prototype.disconnect = function (callback) { +Peripheral.prototype.connect = connect; +Peripheral.prototype.connectAsync = util.promisify(connect); + +const disconnect = function (callback) { if (callback) { this.once('disconnect', () => { callback(null); @@ -80,7 +83,10 @@ Peripheral.prototype.disconnect = function (callback) { this._noble.disconnect(this.id); }; -Peripheral.prototype.updateRssi = function (callback) { +Peripheral.prototype.disconnect = disconnect; +Peripheral.prototype.disconnectAsync = util.promisify(disconnect); + +const updateRssi = function (callback) { if (callback) { this.once('rssiUpdate', rssi => { callback(null, rssi); @@ -90,7 +96,10 @@ Peripheral.prototype.updateRssi = function (callback) { this._noble.updateRssi(this.id); }; -Peripheral.prototype.discoverServices = function (uuids, callback) { +Peripheral.prototype.updateRssi = updateRssi; +Peripheral.prototype.updateRssiAsync = util.promisify(updateRssi); + +const discoverServices = function (uuids, callback) { if (callback) { this.once('servicesDiscover', services => { callback(null, services); @@ -100,7 +109,10 @@ Peripheral.prototype.discoverServices = function (uuids, callback) { this._noble.discoverServices(this.id, uuids); }; -Peripheral.prototype.discoverSomeServicesAndCharacteristics = function (serviceUuids, characteristicsUuids, callback) { +Peripheral.prototype.discoverServices = discoverServices; +Peripheral.prototype.discoverServicesAsync = util.promisify(discoverServices); + +const discoverSomeServicesAndCharacteristics = function (serviceUuids, characteristicsUuids, callback) { this.discoverServices(serviceUuids, (err, services) => { if (err) { callback(err, null, null); @@ -134,11 +146,43 @@ Peripheral.prototype.discoverSomeServicesAndCharacteristics = function (serviceU }); }; -Peripheral.prototype.discoverAllServicesAndCharacteristics = function (callback) { +Peripheral.prototype.discoverSomeServicesAndCharacteristics = discoverSomeServicesAndCharacteristics; +Peripheral.prototype.discoverSomeServicesAndCharacteristicsAsync = function (serviceUuids, characteristicsUuids) { + return new Promise((resolve, reject) => + this.discoverSomeServicesAndCharacteristics( + serviceUuids, + characteristicsUuids, + (error, services, characteristics) => + error + ? reject(error) + : resolve({ + services, + characteristics + }) + ) + ); +}; + +const discoverAllServicesAndCharacteristics = function (callback) { this.discoverSomeServicesAndCharacteristics([], [], callback); }; -Peripheral.prototype.readHandle = function (handle, callback) { +Peripheral.prototype.discoverAllServicesAndCharacteristics = discoverAllServicesAndCharacteristics; +Peripheral.prototype.discoverAllServicesAndCharacteristicsAsync = function () { + return new Promise((resolve, reject) => + this.discoverAllServicesAndCharacteristics( + (error, services, characteristics) => + error + ? reject(error) + : resolve({ + services, + characteristics + }) + ) + ); +}; + +const readHandle = function (handle, callback) { if (callback) { this.once(`handleRead${handle}`, data => { callback(null, data); @@ -148,7 +192,10 @@ Peripheral.prototype.readHandle = function (handle, callback) { this._noble.readHandle(this.id, handle); }; -Peripheral.prototype.writeHandle = function (handle, data, withoutResponse, callback) { +Peripheral.prototype.readHandle = readHandle; +Peripheral.prototype.readHandleAsync = util.promisify(readHandle); + +const writeHandle = function (handle, data, withoutResponse, callback) { if (!(data instanceof Buffer)) { throw new Error('data must be a Buffer'); } @@ -162,4 +209,7 @@ Peripheral.prototype.writeHandle = function (handle, data, withoutResponse, call this._noble.writeHandle(this.id, handle, data, withoutResponse); }; +Peripheral.prototype.writeHandle = writeHandle; +Peripheral.prototype.writeHandleAsync = util.promisify(writeHandle); + module.exports = Peripheral; diff --git a/lib/service.js b/lib/service.js index 957184fd8..88544ead1 100644 --- a/lib/service.js +++ b/lib/service.js @@ -31,7 +31,7 @@ Service.prototype.toString = function () { }); }; -Service.prototype.discoverIncludedServices = function (serviceUuids, callback) { +const discoverIncludedServices = function (serviceUuids, callback) { if (callback) { this.once('includedServicesDiscover', includedServiceUuids => { callback(null, includedServiceUuids); @@ -45,7 +45,10 @@ Service.prototype.discoverIncludedServices = function (serviceUuids, callback) { ); }; -Service.prototype.discoverCharacteristics = function (characteristicUuids, callback) { +Service.prototype.discoverIncludedServices = discoverIncludedServices; +Service.prototype.discoverIncludedServicesAsync = util.promisify(discoverIncludedServices); + +const discoverCharacteristics = function (characteristicUuids, callback) { if (callback) { this.once('characteristicsDiscover', characteristics => { callback(null, characteristics); @@ -59,4 +62,7 @@ Service.prototype.discoverCharacteristics = function (characteristicUuids, callb ); }; +Service.prototype.discoverCharacteristics = discoverCharacteristics; +Service.prototype.discoverCharacteristicsAsync = util.promisify(discoverCharacteristics); + module.exports = Service; From 7d8f52b68c91da2913dbb078b213bc3ac23cda76 Mon Sep 17 00:00:00 2001 From: Ron Smeral Date: Wed, 18 Mar 2020 01:56:08 +0100 Subject: [PATCH 081/114] Add peripheral-explorer-async example --- examples/peripheral-explorer-async.js | 110 ++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 examples/peripheral-explorer-async.js diff --git a/examples/peripheral-explorer-async.js b/examples/peripheral-explorer-async.js new file mode 100644 index 000000000..99ef56b45 --- /dev/null +++ b/examples/peripheral-explorer-async.js @@ -0,0 +1,110 @@ +const noble = require('../'); + +const peripheralIdOrAddress = process.argv[2].toLowerCase(); + +noble.on('stateChange', async (state) => { + if (state === 'poweredOn') { + await noble.startScanningAsync([], false); + } +}); + +noble.on('discover', async (peripheral) => { + if ([peripheral.id, peripheral.address].includes(peripheralIdOrAddress)) { + await noble.stopScanningAsync(); + + console.log(`Peripheral with ID ${peripheral.id} found`); + const advertisement = peripheral.advertisement; + + const localName = advertisement.localName; + const txPowerLevel = advertisement.txPowerLevel; + const manufacturerData = advertisement.manufacturerData; + const serviceData = advertisement.serviceData; + const serviceUuids = advertisement.serviceUuids; + + if (localName) { + console.log(` Local Name = ${localName}`); + } + + if (txPowerLevel) { + console.log(` TX Power Level = ${txPowerLevel}`); + } + + if (manufacturerData) { + console.log(` Manufacturer Data = ${manufacturerData.toString('hex')}`); + } + + if (serviceData) { + console.log(` Service Data = ${JSON.stringify(serviceData, null, 2)}`); + } + + if (serviceUuids) { + console.log(` Service UUIDs = ${serviceUuids}`); + } + + console.log(); + + await explore(peripheral); + } +}); + +/** + * @param {import('../').Peripheral} peripheral + */ +const explore = async (peripheral) => { + console.log('Services and characteristics:'); + + peripheral.on('disconnect', () => { + process.exit(0); + }); + + await peripheral.connectAsync(); + + const services = await peripheral.discoverServicesAsync([]); + + for (const service of services) { + let serviceInfo = service.uuid; + + if (service.name) { + serviceInfo += ` (${service.name})`; + } + + console.log(serviceInfo); + + const characteristics = await service.discoverCharacteristicsAsync([]); + + for (const characteristic of characteristics) { + let characteristicInfo = ` ${characteristic.uuid}`; + + if (characteristic.name) { + characteristicInfo += ` (${characteristic.name})`; + } + + const descriptors = await characteristic.discoverDescriptorsAsync(); + + const userDescriptionDescriptor = descriptors.find((descriptor) => descriptor.uuid === '2901'); + + if (userDescriptionDescriptor) { + const data = await userDescriptionDescriptor.readValueAsync(); + if (data) { + characteristicInfo += ` (${data.toString()})`; + } + } + + characteristicInfo += `\n properties ${characteristic.properties.join(', ')}`; + + if (characteristic.properties.includes('read')) { + const data = await characteristic.readAsync(); + + if (data) { + const string = data.toString('ascii'); + + characteristicInfo += `\n value ${data.toString('hex')} | '${string}'`; + } + } + + console.log(characteristicInfo); + } + } + + await peripheral.disconnectAsync(); +}; From 306c464b0297e1479f294160eec9bf533dc1cb4a Mon Sep 17 00:00:00 2001 From: Ron Smeral Date: Wed, 18 Mar 2020 13:01:44 +0100 Subject: [PATCH 082/114] Update README to describe Promise-based methods --- README.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/README.md b/README.md index 06b4d3e3a..da4fa4eaf 100644 --- a/README.md +++ b/README.md @@ -111,6 +111,26 @@ var noble = require('@abandonware/noble'); ### Actions +All methods have two variants – one expecting a callback, one returning a Promise (denoted by `Async` suffix). + +For example, in case of the `Peripheral.discoverServices` method: + +* The `discoverServices` variant expects a callback: + ```javascript + peripheral.discoverServices((error, services) => { + // callback - handle error and services + }); + ``` +* The `discoverServicesAsync` variant returns a Promise: + ```javascript + try { + const services = await peripheral.discoverServicesAsync(); + // handle services + } catch (e) { + // handle error + } + ``` + #### Start scanning ```javascript From 20ceb1518a311ba8c4be1a4423d4a437fdb5d7e7 Mon Sep 17 00:00:00 2001 From: Ron Smeral Date: Wed, 18 Mar 2020 13:07:26 +0100 Subject: [PATCH 083/114] Overhaul README * Restructure at the top level * Introduce a quick start example * Move Prerequisites under Installation * Rename Notes to Common Problems and move to the end * Rename Actions to API * Merge Actions and Events * Add TOCs - for top level, for Installation, and for API * Unify quotes in snippets - use single quote instead of double * Reformulate for clarity * Fix code snippet syntax (to help highlighting) * Add documentation for handleRead and handleWrite * Move Running on Linux under Advanced Usage * Replace unnecessary triple backticks with single backticks --- README.md | 592 +++++++++++++++++++++++++++++++++--------------------- 1 file changed, 362 insertions(+), 230 deletions(-) diff --git a/README.md b/README.md index da4fa4eaf..dfbb0778a 100644 --- a/README.md +++ b/README.md @@ -4,45 +4,85 @@ [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/abandonware/noble?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![OpenCollective](https://opencollective.com/noble/backers/badge.svg)](#backers) [![OpenCollective](https://opencollective.com/noble/sponsors/badge.svg)](#sponsors) - A Node.js BLE (Bluetooth Low Energy) central module. -Want to implement a peripheral? Checkout [bleno](https://github.com/abandonware/bleno) +Want to implement a peripheral? Check out [bleno](https://github.com/abandonware/bleno). + +__Note:__ macOS / Mac OS X, Linux, FreeBSD and Windows are currently the only supported OSes. + +## Documentation + +* [Quick Start Example](#quick-start-example) +* [Installation](#installation) +* [API docs](#api-docs) +* [Advanced usage](#advanced-usage) +* [Common problems](#common-problems) + +## Quick Start Example + +```javascript +// Read the battery level of all discoverable peripherals which expose the Battery Level characteristic + +const noble = require('@abandonware/noble'); + +noble.on('stateChange', async (state) => { + if (state === 'poweredOn') { + await noble.startScanningAsync([], false); + } +}); + +noble.on('discover', async (peripheral) => { + await peripheral.connectAsync(); + const {characteristics} = await peripheral.discoverSomeServicesAndCharacteristics(['180f'], ['2a19']); + const batteryLevel = (await characteristics[0].readAsync())[0]; + console.log(`${peripheral.address} (${peripheral.advertisement.localName}): ${batteryLevel}%`) +}); +``` + +## Installation -__Note:__ macOS / Mac OS X, Linux, FreeBSD and Windows are currently the only supported OSes. Other platforms may be developed later on. +* [Prerequisites](#prerequisites) + * [OS X](#os-x) + * [Linux](#linux) + * [Ubuntu, Debian, Raspbian](#ubuntu-debian-raspbian) + * [Fedora and other RPM-based distributions](#fedora-and-other-rpm-based-distributions) + * [Intel Edison](#intel-edison) + * [FreeBSD](#freebsd) + * [Windows](#windows) +* [Installing and using the package](#installing-and-using-the-package) -## Prerequisites +### Prerequisites -### OS X +#### OS X - * install [Xcode](https://itunes.apple.com/ca/app/xcode/id497799835?mt=12) + * Install [Xcode](https://itunes.apple.com/ca/app/xcode/id497799835?mt=12) -### Linux +#### Linux * Kernel version 3.6 or above - * ```libbluetooth-dev``` + * `libbluetooth-dev` -#### Ubuntu/Debian/Raspbian +##### Ubuntu, Debian, Raspbian ```sh sudo apt-get install bluetooth bluez libbluetooth-dev libudev-dev ``` -Make sure ```node``` is on your path, if it's not, some options: - * symlink ```nodejs``` to ```node```: ```sudo ln -s /usr/bin/nodejs /usr/bin/node``` - * [install Node.js using the NodeSource package](https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions) +Make sure `node` is on your `PATH`. If it's not, some options: + * Symlink `nodejs` to `node`: `sudo ln -s /usr/bin/nodejs /usr/bin/node` + * [Install Node.js using the NodeSource package](https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions) -#### Fedora / Other-RPM based +##### Fedora and other RPM-based distributions ```sh sudo yum install bluez bluez-libs bluez-libs-devel ``` -#### Intel Edison +##### Intel Edison -See [Configure Intel Edison for Bluetooth LE (Smart) Development](http://rexstjohn.com/configure-intel-edison-for-bluetooth-le-smart-development/) +See [Configure Intel Edison for Bluetooth LE (Smart) Development](http://rexstjohn.com/configure-intel-edison-for-bluetooth-le-smart-development/). -### FreeBSD +#### FreeBSD Make sure you have GNU Make: @@ -50,17 +90,17 @@ Make sure you have GNU Make: sudo pkg install gmake ``` -Disable automatic loading of the default Bluetooth stack by putting [no-ubt.conf](https://gist.github.com/myfreeweb/44f4f3e791a057bc4f3619a166a03b87) into ```/usr/local/etc/devd/no-ubt.conf``` and restarting devd (```sudo service devd restart```). +Disable automatic loading of the default Bluetooth stack by putting [no-ubt.conf](https://gist.github.com/myfreeweb/44f4f3e791a057bc4f3619a166a03b87) into `/usr/local/etc/devd/no-ubt.conf` and restarting devd (`sudo service devd restart`). -Unload ```ng_ubt``` kernel module if already loaded: +Unload `ng_ubt` kernel module if already loaded: ```sh sudo kldunload ng_ubt ``` -Make sure you have read and write permissions on the ```/dev/usb/*``` device that corresponds to your Bluetooth adapter. +Make sure you have read and write permissions on the `/dev/usb/*` device that corresponds to your Bluetooth adapter. -### Windows +#### Windows [node-gyp requirements for Windows](https://github.com/TooTallNate/node-gyp#installation) @@ -74,54 +114,33 @@ npm install --global --production windows-build-tools * Compatible Bluetooth 4.0 USB adapter * [WinUSB](https://msdn.microsoft.com/en-ca/library/windows/hardware/ff540196(v=vs.85).aspx) driver setup for Bluetooth 4.0 USB adapter, using [Zadig tool](http://zadig.akeo.ie/) -See [@don](https://github.com/don)'s set up guide on [Bluetooth LE with Node.js and Noble on Windows](https://www.youtube.com/watch?v=mL9B8wuEdms&feature=youtu.be&t=1m46s) - -## Notes - -### Maximum simultaneous connections - -This limit is imposed upon by the Bluetooth adapter hardware as well as it's firmware. - -| Platform | | -| :------- | --- | -| OS X 10.11 (El Capitan) | 6 | -| Linux/Windows - Adapter dependent | 5 (CSR based adapter) | - -### Adapter specific known issues +See [@don](https://github.com/don)'s setup guide on [Bluetooth LE with Node.js and Noble on Windows](https://www.youtube.com/watch?v=mL9B8wuEdms&feature=youtu.be&t=1m46s) -Some BLE adapters cannot connect to a peripheral while they are scanning (examples below). You will get the following messages when trying to connect : - -Sena UD-100 (Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)) : `Error: Command disallowed` - -Intel Dual Band Wireless-AC 7260 (Intel Corporation Wireless 7260 (rev 73)) : `Error: Connection Rejected due to Limited Resources (0xd)` - -You need to stop scanning before trying to connect in order to solve this issue. - -## Install +### Installing and using the package ```sh npm install @abandonware/noble ``` -## Usage - ```javascript -var noble = require('@abandonware/noble'); +const noble = require('@abandonware/noble'); ``` -### Actions +## API docs -All methods have two variants – one expecting a callback, one returning a Promise (denoted by `Async` suffix). +All operations have two API variants – one expecting a callback, one returning a Promise (denoted by `Async` suffix). -For example, in case of the `Peripheral.discoverServices` method: +Additionally, there are events corresponding to each operation (and a few global events). -* The `discoverServices` variant expects a callback: +For example, in case of the "discover services" operation of Peripheral: + +* There's a `discoverServices` method expecting a callback: ```javascript peripheral.discoverServices((error, services) => { // callback - handle error and services - }); + }); ``` -* The `discoverServicesAsync` variant returns a Promise: +* There's a `discoverServicesAsync` method returning a Promise: ```javascript try { const services = await peripheral.discoverServicesAsync(); @@ -130,6 +149,76 @@ For example, in case of the `Peripheral.discoverServices` method: // handle error } ``` +* There's a `servicesDiscover` event emitted after services are discovered: + ```javascript + peripheral.once('servicesDiscover', (services) => { + // handle services + }); + ``` + +API structure: + +* [Scanning and discovery](#scanning-and-discovery) + * [_Event: Adapter state changed_](#event-adapter-state-changed) + * [Start scanning](#start-scanning) + * [_Event: Scanning started_](#event-scanning-started) + * [Stop scanning](#stop-scanning) + * [_Event: Scanning stopped_](#event-scanning-stopped) + * [_Event: Peripheral discovered_](#event-peripheral-discovered) + * [_Event: Warning raised_](#event-warning-raised) +* [Peripheral](#peripheral) + * [Connect](#connect) + * [_Event: Connected_](#event-connected) + * [Disconnect or cancel a pending connection](#disconnect-or-cancel-a-pending-connection) + * [_Event: Disconnected_](#event-disconnected) + * [Update RSSI](#update-rssi) + * [_Event: RSSI updated_](#event-rssi-updated) + * [Discover services](#discover-services) + * [Discover all services and characteristics](#discover-all-services-and-characteristics) + * [Discover some services and characteristics](#discover-some-services-and-characteristics) + * [_Event: Services discovered_](#event-services-discovered) + * [Read handle](#read-handle) + * [_Event: Handle read_](#event-handle-read) + * [Write handle](#write-handle) + * [_Event: Handle written_](#event-handle-written) +* [Service](#service) + * [Discover included services](#discover-included-services) + * [_Event: Included services discovered_](#event-included-services-discovered) + * [Discover characteristics](#discover-characteristics) + * [_Event: Characteristics discovered_](#event-characteristics-discovered) +* [Characteristic](#characteristic) + * [Read](#read) + * [_Event: Data read_](#event-data-read) + * [Write](#write) + * [_Event: Data written_](#event-data-written) + * [Broadcast](#broadcast) + * [_Event: Broadcast sent_](#event-broadcast-sent) + * [Subscribe](#subscribe) + * [_Event: Notification received_](#event-notification-received) + * [Unsubscribe](#unsubscribe) + * [Discover descriptors](#discover-descriptors) + * [_Event: Descriptors discovered_](#event-descriptors-discovered) +* [Descriptor](#descriptor) + * [Read value](#read-value) + * [_Event: Value read_](#event-value-read) + * [Write value](#write-value) + * [_Event: Value written_](#event-value-written) + +### Scanning and discovery + +#### _Event: Adapter state changed_ + +```javascript +noble.on('stateChange', callback(state)); +``` + +`state` can be one of: +* `unknown` +* `resetting` +* `unsupported` +* `unauthorized` +* `poweredOff` +* `poweredOn` #### Start scanning @@ -140,332 +229,359 @@ noble.startScanning(); // any service UUID, no duplicates noble.startScanning([], true); // any service UUID, allow duplicates -var serviceUUIDs = ["", ...]; // default: [] => all -var allowDuplicates = ; // default: false +var serviceUUIDs = ['', ...]; // default: [] => all +var allowDuplicates = falseOrTrue; // default: false -noble.startScanning(serviceUUIDs, allowDuplicates[, callback(error)]); // particular UUID's +noble.startScanning(serviceUUIDs, allowDuplicates[, callback(error)]); // particular UUIDs ``` -__NOTE:__ ```noble.state``` must be ```poweredOn``` before scanning is started. ```noble.on('stateChange', callback(state));``` can be used register for state change events. +__NOTE:__ `noble.state` must be `poweredOn` before scanning is started. `noble.on('stateChange', callback(state));` can be used to listen for state change events. -#### Stop scanning +#### _Event: Scanning started_ ```javascript -noble.stopScanning(); +noble.on('scanStart', callback); ``` -#### Peripheral +The event is emitted when: +* Scanning is started +* Another application enables scanning +* Another application changes scanning settings -##### Connect +#### Stop scanning ```javascript -peripheral.connect([callback(error)]); +noble.stopScanning(); ``` -##### Disconnect or cancel pending connection +#### _Event: Scanning stopped_ ```javascript -peripheral.disconnect([callback(error)]); +noble.on('scanStop', callback); ``` -##### Update RSSI +The event is emitted when: +* Scanning is stopped +* Another application stops scanning + + +#### _Event: Peripheral discovered_ ```javascript -peripheral.updateRssi([callback(error, rssi)]); +noble.on('discover', callback(peripheral)); ``` -##### Discover services +* `peripheral`: + ```javascript + { + id: '', + address: ', // Bluetooth Address of device, or 'unknown' if not known + addressType: '', // Bluetooth Address type (public, random), or 'unknown' if not known + connectable: trueOrFalseOrUndefined, // true or false, or undefined if not known + advertisement: { + localName: '', + txPowerLevel: someInteger, + serviceUuids: ['', ...], + serviceSolicitationUuid: ['', ...], + manufacturerData: someBuffer, // a Buffer + serviceData: [ + { + uuid: '', + data: someBuffer // a Buffer + }, + // ... + ] + }, + rssi: integerValue, + mtu: integerValue // MTU will be null, until device is connected and hci-socket is used + }; + ``` -```javascript -peripheral.discoverServices(); // any service UUID +__Note:__ On OS X, the address will be set to 'unknown' if the device has not been connected previously. -var serviceUUIDs = ["", ...]; -peripheral.discoverServices(serviceUUIDs[, callback(error, services)]); // particular UUID's -``` -##### Discover all services and characteristics +#### _Event: Warning raised_ ```javascript -peripheral.discoverAllServicesAndCharacteristics([callback(error, services, characteristics)]); +noble.on('warning', callback(message)); ``` -##### Discover some services and characteristics +### Peripheral + +#### Connect ```javascript -var serviceUUIDs = ["", ...]; -var characteristicUUIDs = ["", ...]; -peripheral.discoverSomeServicesAndCharacteristics(serviceUUIDs, characteristicUUIDs, [callback(error, services, characteristics)); +peripheral.connect([callback(error)]); ``` -#### Service -##### Discover included services +#### _Event: Connected_ ```javascript -service.discoverIncludedServices(); // any service UUID - -var serviceUUIDs = ["", ...]; -service.discoverIncludedServices(serviceUUIDs[, callback(error, includedServiceUuids)]); // particular UUID's +peripheral.once('connect', callback); ``` -##### Discover characteristics +#### Disconnect or cancel a pending connection ```javascript -service.discoverCharacteristics() // any characteristic UUID - -var characteristicUUIDs = ["", ...]; -service.discoverCharacteristics(characteristicUUIDs[, callback(error, characteristics)]); // particular UUID's +peripheral.disconnect([callback(error)]); ``` -#### Characteristic - -##### Read +#### _Event: Disconnected_ ```javascript -characteristic.read([callback(error, data)]); +peripheral.once('disconnect', callback); ``` -##### Write +#### Update RSSI ```javascript -characteristic.write(data, withoutResponse[, callback(error)]); // data is a buffer, withoutResponse is true|false +peripheral.updateRssi([callback(error, rssi)]); ``` -* ```withoutResponse```: - * ```false```: send a write request, used with "write" characteristic property - * ```true```: send a write command, used with "write without response" characteristic property - -##### Broadcast +#### _Event: RSSI updated_ ```javascript -characteristic.broadcast(broadcast[, callback(error)]); // broadcast is true|false +peripheral.once('rssiUpdate', callback(rssi)); ``` -##### Subscribe +#### Discover services ```javascript -characteristic.subscribe([callback(error)]); -``` +peripheral.discoverServices(); // any service UUID - * subscribe to a characteristic, triggers `'data'` events when peripheral sends an notification or indication - * use for characteristics with notify or indicate properties +var serviceUUIDs = ['', ...]; +peripheral.discoverServices(serviceUUIDs[, callback(error, services)]); // particular UUIDs +``` -##### Unsubscribe +#### Discover all services and characteristics ```javascript -characteristic.unsubscribe([callback(error)]); +peripheral.discoverAllServicesAndCharacteristics([callback(error, services, characteristics)]); ``` - * unsubscribe to a characteristic - * use for characteristics with notify or indicate properties +#### Discover some services and characteristics + +```javascript +var serviceUUIDs = ['', ...]; +var characteristicUUIDs = ['', ...]; +peripheral.discoverSomeServicesAndCharacteristics(serviceUUIDs, characteristicUUIDs, [callback(error, services, characteristics)); +``` -##### Discover descriptors +#### _Event: Services discovered_ ```javascript -characteristic.discoverDescriptors([callback(error, descriptors)]); +peripheral.once('servicesDiscover', callback(services)); ``` -##### Read value +#### Read handle ```javascript -descriptor.readValue([callback(error, data)]); +peripheral.readHandle(handle, callback(error, data)); ``` -##### Write value +#### _Event: Handle read_ ```javascript -descriptor.writeValue(data[, callback(error)]); // data is a buffer +peripheral.once('handleRead', callback(data)); // data is a Buffer ``` -#### Handle +`` is the handle identifier. -##### Read +#### Write handle ```javascript -peripheral.readHandle(handle, callback(error, data)); +peripheral.writeHandle(handle, data, withoutResponse, callback(error)); ``` -##### Write +#### _Event: Handle written_ ```javascript -peripheral.writeHandle(handle, data, withoutResponse, callback(error)); +peripheral.once('handleWrite', callback()); ``` -### Events +`` is the handle identifier. -See [Node.js EventEmitter docs](https://nodejs.org/api/events.html) for more info. on API's. +### Service -#### Adapter state change +#### Discover included services ```javascript -state = <"unknown" | "resetting" | "unsupported" | "unauthorized" | "poweredOff" | "poweredOn"> +service.discoverIncludedServices(); // any service UUID -noble.on('stateChange', callback(state)); +var serviceUUIDs = ['', ...]; +service.discoverIncludedServices(serviceUUIDs[, callback(error, includedServiceUuids)]); // particular UUIDs ``` -#### Scan started: +#### _Event: Included services discovered_ ```javascript -noble.on('scanStart', callback); +service.once('includedServicesDiscover', callback(includedServiceUuids)); ``` -The event is emitted when scanning is started or if another application enables scanning or changes scanning settings. - -#### Scan stopped +#### Discover characteristics ```javascript -noble.on('scanStop', callback); -``` - -The event is emitted when scanning is stopped or if another application stops scanning. - -#### Peripheral discovered - -```javascript -peripheral = { - id: "", - address: ", // Bluetooth Address of device, or 'unknown' if not known - addressType: "", // Bluetooth Address type (public, random), or 'unknown' if not known - connectable: , // true or false, or undefined if not known - advertisement: { - localName: "", - txPowerLevel: , - serviceUuids: ["", ...], - serviceSolicitationUuid: ["", ...], - manufacturerData: , - serviceData: [ - { - uuid: "" - data: - }, - ... - ] - }, - rssi: , - mtu: // MTU will be null, until device is connected and hci-socket is used -}; +service.discoverCharacteristics() // any characteristic UUID -noble.on('discover', callback(peripheral)); +var characteristicUUIDs = ['', ...]; +service.discoverCharacteristics(characteristicUUIDs[, callback(error, characteristics)]); // particular UUIDs ``` -__Note:__ on OS X the address will be set to 'unknown' if the device has not been connected previously. - -#### Warnings +#### _Event: Characteristics discovered_ ```javascript -noble.on('warning', callback(message)); +service.once('characteristicsDiscover', callback(characteristics)); ``` -#### Peripheral +* `characteristics` + ```javascript + { + uuid: '', + properties: ['...'] // 'broadcast', 'read', 'writeWithoutResponse', 'write', 'notify', 'indicate', 'authenticatedSignedWrites', 'extendedProperties' + }; + ``` + +### Characteristic -##### Connected +#### Read ```javascript -peripheral.once('connect', callback); +characteristic.read([callback(error, data)]); ``` -##### Disconnected: +#### _Event: Data read_ ```javascript -peripheral.once('disconnect', callback); +characteristic.on('data', callback(data, isNotification)); + +characteristic.once('read', callback(data, isNotification)); // legacy ``` -##### RSSI update +Emitted when: +* Characteristic read has completed, result of `characteristic.read(...)` +* Characteristic value has been updated by peripheral via notification or indication, after having been enabled with `characteristic.notify(true[, callback(error)])` + +**Note:** `isNotification` event parameter value MAY be `undefined` depending on platform. The parameter is **deprecated** after version 1.8.1, and not supported on macOS High Sierra and later. + +#### Write ```javascript -peripheral.once('rssiUpdate', callback(rssi)); +characteristic.write(data, withoutResponse[, callback(error)]); // data is a Buffer, withoutResponse is true|false ``` -##### Services discovered +* `withoutResponse`: + * `false`: send a write request, used with "write" characteristic property + * `true`: send a write command, used with "write without response" characteristic property + + +#### _Event: Data written_ ```javascript -peripheral.once('servicesDiscover', callback(services)); +characteristic.once('write', withoutResponse, callback()); ``` -#### Service +Emitted when characteristic write has completed, result of `characteristic.write(...)`. -##### Included services discovered +#### Broadcast ```javascript -service.once('includedServicesDiscover', callback(includedServiceUuids)); +characteristic.broadcast(broadcast[, callback(error)]); // broadcast is true|false ``` -##### Characteristics discovered +#### _Event: Broadcast sent_ ```javascript -characteristic = { - uuid: "", - // properties: 'broadcast', 'read', 'writeWithoutResponse', 'write', 'notify', 'indicate', 'authenticatedSignedWrites', 'extendedProperties' - properties: [...] -}; - -service.once('characteristicsDiscover', callback(characteristics)); +characteristic.once('broadcast', callback(state)); ``` -#### Characteristic - -##### Data +Emitted when characteristic broadcast state changes, result of `characteristic.broadcast(...)`. -Emitted when characteristic read has completed, result of ```characteristic.read(...)``` or characteristic value has been updated by peripheral via notification or indication - after having been enabled with ```notify(true[, callback(error)])```. +#### Subscribe ```javascript -characteristic.on('data', callback(data, isNotification)); - -characteristic.once('read', callback(data, isNotification)); // legacy +characteristic.subscribe([callback(error)]); ``` -**Note:** `isNotification` event parameter value MAY be `undefined` depending on platform support. The parameter is **deprecated** after version 1.8.1, and not supported when on macOS High Sierra and later. +Subscribe to a characteristic. -##### Write +Triggers `data` events when peripheral sends a notification or indication. Use for characteristics with "notify" or "indicate" properties. -Emitted when characteristic write has completed, result of ```characteristic.write(...)```. +#### _Event: Notification received_ ```javascript -characteristic.once('write', withoutResponse, callback()); +characteristic.once('notify', callback(state)); ``` -##### Broadcast +Emitted when characteristic notification state changes, result of `characteristic.notify(...)`. -Emitted when characteristic broadcast state changes, result of ```characteristic.broadcast(...)```. +#### Unsubscribe ```javascript -characteristic.once('broadcast', callback(state)); +characteristic.unsubscribe([callback(error)]); ``` -##### Notify +Unsubscribe from a characteristic. -Emitted when characteristic notification state changes, result of ```characteristic.notify(...)```. +Use for characteristics with "notify" or "indicate" properties + +#### Discover descriptors ```javascript -characteristic.once('notify', callback(state)); +characteristic.discoverDescriptors([callback(error, descriptors)]); ``` -##### Descriptors discovered +#### _Event: Descriptors discovered_ ```javascript -descriptor = { - uuid: '' -}; - characteristic.once('descriptorsDiscover', callback(descriptors)); ``` +* `descriptors`: + ```javascript + [ + { + uuid: '' + }, + // ... + ] + ``` + +### Descriptor + +#### Read value + +```javascript +descriptor.readValue([callback(error, data)]); +``` -#### Descriptor +#### _Event: Value read_ -##### Value read +```javascript +descriptor.once('valueRead', data); // data is a Buffer +``` + +#### Write value ```javascript -descriptor.once('valueRead', data); +descriptor.writeValue(data[, callback(error)]); // data is a Buffer ``` -##### Value write +#### _Event: Value written_ ```javascript descriptor.once('valueWrite'); ``` -## Running on Linux +## Advanced usage + +### Override default bindings -### Running without root/sudo +By default, noble will select appropriate Bluetooth device bindings based on your platform. You can provide custom bindings using the `with-bindings` module. + +```javascript +var noble = require('noble/with-bindings')(require('./my-custom-bindings')); +``` + +### Running without root/sudo (Linux-specific) Run the following command: @@ -473,18 +589,21 @@ Run the following command: sudo setcap cap_net_raw+eip $(eval readlink -f `which node`) ``` -This grants the ```node``` binary ```cap_net_raw``` privileges, so it can start/stop BLE advertising. +This grants the `node` binary `cap_net_raw` privileges, so it can start/stop BLE advertising. + +__Note:__ The above command requires `setcap` to be installed. +It can be installed the following way: -__Note:__ The above command requires ```setcap``` to be installed, it can be installed using the following: + * apt: `sudo apt-get install libcap2-bin` + * yum: `su -c \'yum install libcap2-bin\'` - * apt: ```sudo apt-get install libcap2-bin``` - * yum: ```su -c \'yum install libcap2-bin\'``` +### Multiple Adapters (Linux-specific) -### Multiple Adapters +`hci0` is used by default. -```hci0``` is used by default to override set the ```NOBLE_HCI_DEVICE_ID``` environment variable to the interface number. +To override, set the `NOBLE_HCI_DEVICE_ID` environment variable to the interface number. -Example, specify ```hci1```: +For example, to specify `hci1`: ```sh sudo NOBLE_HCI_DEVICE_ID=1 node .js @@ -504,33 +623,46 @@ const params = { const noble = new Noble(new HCIBindings(params)); ``` -### Reporting all HCI events +### Reporting all HCI events (Linux-specific) By default noble waits for both the advertisement data and scan response data for each Bluetooth address. If your device does not use scan response the following environment variable can be used to bypass it. +By default, noble waits for both the advertisement data and scan response data for each Bluetooth address. If your device does not use scan response, the `NOBLE_REPORT_ALL_HCI_EVENTS` environment variable can be used to bypass it. ```sh sudo NOBLE_REPORT_ALL_HCI_EVENTS=1 node .js ``` -### bleno compatibility +### bleno compatibility (Linux-specific) -By default noble will respond with an error whenever a GATT request message is received. If your intention is to use bleno in tandem with noble, the following environment variable can be used to bypass this functionality. __Note:__ this requires a Bluetooth 4.1 adapter. +By default, noble will respond with an error whenever a GATT request message is received. If your intention is to use bleno in tandem with noble, the `NOBLE_MULTI_ROLE` environment variable can be used to bypass this behaviour. + +__Note:__ this requires a Bluetooth 4.1 adapter. ```sh sudo NOBLE_MULTI_ROLE=1 node .js ``` +## Common problems -## Advanced usage +### Maximum simultaneous connections -### Override default bindings +This limit is imposed by the Bluetooth adapter hardware as well as its firmware. -By default, noble will select bindings to communicate with Bluetooth devices depending on your platform. If you prefer to specify what bindings noble should use: +| Platform | | +| :------- | --- | +| OS X 10.11 (El Capitan) | 6 | +| Linux/Windows - Adapter-dependent | 5 (CSR based adapter) | -```javascript -var noble = require('noble/with-bindings')(require('./my-custom-bindings')); -``` +### Adapter-specific known issues + +Some BLE adapters cannot connect to a peripheral while they are scanning (examples below). You will get the following messages when trying to connect: + +Sena UD-100 (Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)): `Error: Command disallowed` + +Intel Dual Band Wireless-AC 7260 (Intel Corporation Wireless 7260 (rev 73)): `Error: Connection Rejected due to Limited Resources (0xd)` + +You need to stop scanning before trying to connect in order to solve this issue. ## Backers @@ -602,7 +734,7 @@ Become a sponsor and get your logo on our README on Github with a link to your s -## Useful Links +## Useful links * [Bluetooth Development Portal](http://developer.bluetooth.org) * [GATT Specifications](http://developer.bluetooth.org/gatt/Pages/default.aspx) From 541fb7a4f6b497d6186ef0998aa801f4ce0705b3 Mon Sep 17 00:00:00 2001 From: Ron Smeral Date: Thu, 19 Mar 2020 16:19:59 +0100 Subject: [PATCH 084/114] Fix errors in Quick start example --- README.md | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index dfbb0778a..dada231ef 100644 --- a/README.md +++ b/README.md @@ -21,21 +21,26 @@ __Note:__ macOS / Mac OS X, Linux, FreeBSD and Windows are currently the only su ## Quick Start Example ```javascript -// Read the battery level of all discoverable peripherals which expose the Battery Level characteristic +// Read the battery level of the first found peripheral exposing the Battery Level characteristic const noble = require('@abandonware/noble'); noble.on('stateChange', async (state) => { if (state === 'poweredOn') { - await noble.startScanningAsync([], false); + await noble.startScanningAsync(['180f'], false); } }); noble.on('discover', async (peripheral) => { + await noble.stopScanningAsync(); await peripheral.connectAsync(); - const {characteristics} = await peripheral.discoverSomeServicesAndCharacteristics(['180f'], ['2a19']); + const {characteristics} = await peripheral.discoverSomeServicesAndCharacteristicsAsync(['180f'], ['2a19']); const batteryLevel = (await characteristics[0].readAsync())[0]; - console.log(`${peripheral.address} (${peripheral.advertisement.localName}): ${batteryLevel}%`) + + console.log(`${peripheral.address} (${peripheral.advertisement.localName}): ${batteryLevel}%`); + + await peripheral.disconnectAsync(); + process.exit(0); }); ``` From 3133fecc9572ac06838c3c447f902151ecf8d81e Mon Sep 17 00:00:00 2001 From: RasPelikan Date: Sat, 21 Mar 2020 16:01:45 +0100 Subject: [PATCH 085/114] Fixes 59: add check of role on connect --- lib/hci-socket/bindings.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/hci-socket/bindings.js b/lib/hci-socket/bindings.js index d22ed978d..84bed8625 100644 --- a/lib/hci-socket/bindings.js +++ b/lib/hci-socket/bindings.js @@ -188,6 +188,10 @@ NobleBindings.prototype.onDiscover = function (status, address, addressType, con }; NobleBindings.prototype.onLeConnComplete = function (status, handle, role, addressType, address, interval, latency, supervisionTimeout, masterClockAccuracy) { + if (role !== 0) { + // not master, ignore + return; + } let uuid = null; let error = null; From 5073551201fdadd20f049f6e58f6fb2459d18458 Mon Sep 17 00:00:00 2001 From: Ron Smeral Date: Fri, 20 Mar 2020 15:07:05 +0100 Subject: [PATCH 086/114] Fix inconsistencies in method signatures README, implementation, and types diverged in some places --- index.d.ts | 10 +++++++--- lib/noble.js | 4 +++- lib/peripheral.js | 4 +++- lib/service.js | 8 ++++++-- 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/index.d.ts b/index.d.ts index 888dd0f76..3e13acaeb 100644 --- a/index.d.ts +++ b/index.d.ts @@ -13,10 +13,8 @@ import events = require("events"); -export declare function startScanning(callback?: (error?: Error) => void): void; +export declare function startScanning(): void; export declare function startScanningAsync(): Promise; -export declare function startScanning(serviceUUIDs: string[], callback?: (error?: Error) => void): void; -export declare function startScanningAsync(serviceUUIDs: string[]): Promise; export declare function startScanning(serviceUUIDs: string[], allowDuplicates: boolean, callback?: (error?: Error) => void): void; export declare function startScanningAsync(serviceUUIDs: string[], allowDuplicates: boolean): Promise; export declare function stopScanning(callback?: () => void): void; @@ -60,6 +58,8 @@ export declare class Peripheral extends events.EventEmitter { disconnectAsync(): Promise; updateRssi(callback?: (error: string, rssi: number) => void): void; updateRssiAsync(): Promise; + discoverServices(): void; + discoverServicesAsync(): Promise; discoverServices(serviceUUIDs: string[], callback?: (error: string, services: Service[]) => void): void; discoverServicesAsync(serviceUUIDs: string[]): Promise; discoverAllServicesAndCharacteristics(callback?: (error: string, services: Service[], characteristics: Characteristic[]) => void): void; @@ -98,8 +98,12 @@ export declare class Service extends events.EventEmitter { includedServiceUuids: string[]; characteristics: Characteristic[]; + discoverIncludedServices(): void; + discoverIncludedServicesAsync(): Promise; discoverIncludedServices(serviceUUIDs: string[], callback?: (error: string, includedServiceUuids: string[]) => void): void; discoverIncludedServicesAsync(serviceUUIDs: string[]): Promise; + discoverCharacteristics(): void; + discoverCharacteristicsAsync(): Promise; discoverCharacteristics(characteristicUUIDs: string[], callback?: (error: string, characteristics: Characteristic[]) => void): void; discoverCharacteristicsAsync(characteristicUUIDs: string[]): Promise; toString(): string; diff --git a/lib/noble.js b/lib/noble.js index df4b34a87..2a966a609 100644 --- a/lib/noble.js +++ b/lib/noble.js @@ -143,7 +143,9 @@ Noble.prototype.startScanning = function (serviceUuids, allowDuplicates, callbac }; Noble.prototype.startScanning = startScanning; -Noble.prototype.startScanningAsync = util.promisify(startScanning); +Noble.prototype.startScanningAsync = function (serviceUUIDs, allowDuplicates) { + return util.promisify((callback) => this.startScanning(serviceUUIDs, allowDuplicates, callback))(); +}; Noble.prototype.onScanStart = function (filterDuplicates) { debug('scanStart'); diff --git a/lib/peripheral.js b/lib/peripheral.js index 4361cec28..d023b720c 100644 --- a/lib/peripheral.js +++ b/lib/peripheral.js @@ -110,7 +110,9 @@ const discoverServices = function (uuids, callback) { }; Peripheral.prototype.discoverServices = discoverServices; -Peripheral.prototype.discoverServicesAsync = util.promisify(discoverServices); +Peripheral.prototype.discoverServicesAsync = function (uuids) { + return util.promisify((callback) => this.discoverServices(uuids, callback))(); +}; const discoverSomeServicesAndCharacteristics = function (serviceUuids, characteristicsUuids, callback) { this.discoverServices(serviceUuids, (err, services) => { diff --git a/lib/service.js b/lib/service.js index 88544ead1..124c41c47 100644 --- a/lib/service.js +++ b/lib/service.js @@ -46,7 +46,9 @@ const discoverIncludedServices = function (serviceUuids, callback) { }; Service.prototype.discoverIncludedServices = discoverIncludedServices; -Service.prototype.discoverIncludedServicesAsync = util.promisify(discoverIncludedServices); +Service.prototype.discoverIncludedServicesAsync = function (serviceUuids) { + return util.promisify((callback) => this.discoverIncludedServices(serviceUuids, callback))(); +}; const discoverCharacteristics = function (characteristicUuids, callback) { if (callback) { @@ -63,6 +65,8 @@ const discoverCharacteristics = function (characteristicUuids, callback) { }; Service.prototype.discoverCharacteristics = discoverCharacteristics; -Service.prototype.discoverCharacteristicsAsync = util.promisify(discoverCharacteristics); +Service.prototype.discoverCharacteristicsAsync = function (characteristicUuids) { + return util.promisify((callback) => this.discoverCharacteristics(characteristicUuids, callback))(); +}; module.exports = Service; From 51da5afef2908ee085c8310d3ce9302d812a853a Mon Sep 17 00:00:00 2001 From: Ron Smeral Date: Thu, 26 Mar 2020 23:38:40 +0100 Subject: [PATCH 087/114] deprecate invalid signatures of startScanning --- index.d.ts | 14 ++++++++++---- lib/noble.js | 8 ++++++++ 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/index.d.ts b/index.d.ts index 3e13acaeb..aba7aa6b7 100644 --- a/index.d.ts +++ b/index.d.ts @@ -13,10 +13,16 @@ import events = require("events"); -export declare function startScanning(): void; -export declare function startScanningAsync(): Promise; -export declare function startScanning(serviceUUIDs: string[], allowDuplicates: boolean, callback?: (error?: Error) => void): void; -export declare function startScanningAsync(serviceUUIDs: string[], allowDuplicates: boolean): Promise; +/** + * @deprecated + */ +export declare function startScanning(callback?: (error?: Error) => void): void; +/** + * @deprecated + */ +export declare function startScanning(serviceUUIDs: string[], callback?: (error?: Error) => void): void; +export declare function startScanning(serviceUUIDs?: string[], allowDuplicates?: boolean, callback?: (error?: Error) => void): void; +export declare function startScanningAsync(serviceUUIDs?: string[], allowDuplicates?: boolean): Promise; export declare function stopScanning(callback?: () => void): void; export declare function stopScanningAsync(): Promise; diff --git a/lib/noble.js b/lib/noble.js index 2a966a609..1f8d8b65c 100644 --- a/lib/noble.js +++ b/lib/noble.js @@ -107,6 +107,14 @@ Noble.prototype.onScanParametersSet = function () { }; Noble.prototype.startScanning = function (serviceUuids, allowDuplicates, callback) { + if (typeof serviceUuids === 'function') { + this.emit('warning', 'calling startScanning(callback) is deprecated'); + } + + if (typeof allowDuplicates === 'function') { + this.emit('warning', 'calling startScanning(serviceUuids, callback) is deprecated'); + } + const scan = function (state) { if (state !== 'poweredOn') { const error = new Error(`Could not start scanning, state is ${state} (not poweredOn)`); From 8b209ef38e01f029f9f505602894aea030e414fc Mon Sep 17 00:00:00 2001 From: Ron Smeral Date: Fri, 27 Mar 2020 19:42:38 +0100 Subject: [PATCH 088/114] add tests for async functions of peripheral --- test/test-peripheral.js | 230 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 230 insertions(+) diff --git a/test/test-peripheral.js b/test/test-peripheral.js index 4075abc82..1d3b9b1c7 100644 --- a/test/test-peripheral.js +++ b/test/test-peripheral.js @@ -82,6 +82,33 @@ describe('Peripheral', function () { }); }); + describe('connectAsync', () => { + it('should resolve', async () => { + const promise = peripheral.connectAsync(); + + peripheral.emit('connect'); + + await promise.should.be.fulfilled(); + }); + + it('should reject on error', async () => { + const promise = peripheral.connectAsync(); + + peripheral.emit('connect', new Error('error')); + + await promise.should.be.rejectedWith('error'); + }); + + it('should delegate to noble', async () => { + const promise = peripheral.connectAsync(); + + peripheral.emit('connect'); + await promise; + + mockNoble.connect.calledWithExactly(mockId).should.equal(true); + }); + }); + describe('disconnect', function () { it('should delegate to noble', function () { peripheral.disconnect(); @@ -101,6 +128,22 @@ describe('Peripheral', function () { }); }); + describe('disconnectAsync', function () { + it('should resolve', async () => { + const promise = peripheral.disconnectAsync(); + + peripheral.emit('disconnect'); + + await promise.should.be.fulfilled(); + }); + + it('should delegate to noble', () => { + peripheral.disconnect(); + + mockNoble.disconnect.calledWithExactly(mockId).should.equal(true); + }); + }); + describe('updateRssi', function () { it('should delegate to noble', function () { peripheral.updateRssi(); @@ -134,6 +177,25 @@ describe('Peripheral', function () { }); }); + describe('updateRssiAsync', () => { + it('should resolve with rssi', async () => { + const promise = peripheral.updateRssiAsync(); + + peripheral.emit('rssiUpdate', mockRssi); + + await promise.should.be.fulfilledWith(mockRssi); + }); + + it('should delegate to noble', async () => { + const promise = peripheral.updateRssiAsync(); + + peripheral.emit('rssiUpdate'); + await promise; + + mockNoble.updateRssi.calledWithExactly(mockId).should.equal(true); + }); + }); + describe('discoverServices', function () { it('should delegate to noble', function () { peripheral.discoverServices(); @@ -176,6 +238,35 @@ describe('Peripheral', function () { }); }); + describe('discoverServicesAsync', () => { + it('should resolve with services', async () => { + const mockServices = 'discoveredServices'; + + const promise = peripheral.discoverServicesAsync(); + peripheral.emit('servicesDiscover', mockServices); + + await promise.should.be.fulfilledWith(mockServices); + }); + + it('should delegate to noble', async () => { + const promise = peripheral.discoverServicesAsync(); + peripheral.emit('servicesDiscover'); + await promise; + + mockNoble.discoverServices.calledWithExactly(mockId, undefined).should.equal(true); + }); + + it('should delegate to noble, service uuids', async () => { + const mockServiceUuids = []; + + const promise = peripheral.discoverServicesAsync(mockServiceUuids); + peripheral.emit('servicesDiscover'); + await promise; + + mockNoble.discoverServices.calledWithExactly(mockId, mockServiceUuids).should.equal(true); + }); + }); + describe('discoverSomeServicesAndCharacteristics', function () { const mockServiceUuids = []; const mockCharacteristicUuids = []; @@ -258,6 +349,74 @@ describe('Peripheral', function () { }); }); + describe('discoverSomeServicesAndCharacteristicsAsync', () => { + const mockServiceUuids = []; + const mockCharacteristicUuids = []; + let mockServices = null; + + beforeEach(function () { + peripheral.discoverServices = sinon.spy(); + + mockServices = [ + { + uuid: '1', + discoverCharacteristics: sinon.spy() + }, + { + uuid: '2', + discoverCharacteristics: sinon.spy() + } + ]; + }); + + it('should call discoverServices', async () => { + peripheral.discoverSomeServicesAndCharacteristicsAsync(mockServiceUuids); + + peripheral.discoverServices.calledWith(mockServiceUuids).should.equal(true); + }); + + it('should call discoverCharacteristics on each service discovered', () => { + peripheral.discoverSomeServicesAndCharacteristicsAsync(mockServiceUuids, mockCharacteristicUuids); + + const discoverServicesCallback = peripheral.discoverServices.getCall(0).args[1]; + + discoverServicesCallback(null, mockServices); + + mockServices[0].discoverCharacteristics.calledWith(mockCharacteristicUuids).should.equal(true); + mockServices[1].discoverCharacteristics.calledWith(mockCharacteristicUuids).should.equal(true); + }); + + it('should reject on error', async () => { + const promise = peripheral.discoverSomeServicesAndCharacteristicsAsync(mockServiceUuids); + + const discoverServicesCallback = peripheral.discoverServices.getCall(0).args[1]; + + discoverServicesCallback(new Error('error')); + + await promise.should.be.rejectedWith('error'); + }); + + it('should resolve with the services and characteristics discovered', async () => { + const promise = peripheral.discoverSomeServicesAndCharacteristicsAsync(mockServiceUuids, mockCharacteristicUuids); + + const discoverServicesCallback = peripheral.discoverServices.getCall(0).args[1]; + + discoverServicesCallback(null, mockServices); + + const mockCharacteristic1 = { uuid: '1' }; + const mockCharacteristic2 = { uuid: '2' }; + const mockCharacteristic3 = { uuid: '3' }; + + mockServices[0].discoverCharacteristics.getCall(0).args[1](null, [mockCharacteristic1]); + mockServices[1].discoverCharacteristics.getCall(0).args[1](null, [mockCharacteristic2, mockCharacteristic3]); + + const result = await promise; + + result.services.should.equal(mockServices); + result.characteristics.should.eql([mockCharacteristic1, mockCharacteristic2, mockCharacteristic3]); + }); + }); + describe('discoverAllServicesAndCharacteristics', function () { it('should call discoverSomeServicesAndCharacteristics', function () { const mockCallback = sinon.spy(); @@ -270,6 +429,21 @@ describe('Peripheral', function () { }); }); + describe('discoverAllServicesAndCharacteristicsAsync', () => { + it('should call discoverSomeServicesAndCharacteristics', async () => { + peripheral.discoverSomeServicesAndCharacteristics = sinon.spy(); + + const promise = peripheral.discoverAllServicesAndCharacteristicsAsync(); + const callback = peripheral.discoverSomeServicesAndCharacteristics.getCall(0).args[2]; + + callback(null); + await promise; + + peripheral.discoverSomeServicesAndCharacteristics.getCall(0).args[0].should.eql([]); + peripheral.discoverSomeServicesAndCharacteristics.getCall(0).args[1].should.eql([]); + }); + }); + describe('readHandle', function () { it('should delegate to noble', function () { peripheral.readHandle(mockHandle); @@ -303,6 +477,25 @@ describe('Peripheral', function () { }); }); + describe('readHandleAsync', () => { + it('should delegate to noble', async () => { + const promise = peripheral.readHandleAsync(mockHandle); + + peripheral.emit(`handleRead${mockHandle}`); + await promise; + + mockNoble.readHandle.calledWithExactly(mockId, mockHandle).should.equal(true); + }); + + it('should resolve with data', async () => { + const promise = peripheral.readHandleAsync(mockHandle); + + peripheral.emit(`handleRead${mockHandle}`, mockData); + + await promise.should.be.fulfilledWith(mockData); + }); + }); + describe('writeHandle', function () { beforeEach(function () { mockData = Buffer.alloc(0); @@ -339,4 +532,41 @@ describe('Peripheral', function () { calledback.should.equal(true); }); }); + + describe('writeHandleAsync', () => { + beforeEach(() => { + mockData = Buffer.alloc(0); + }); + + it('should only accept data as a buffer', async () => { + mockData = {}; + + await peripheral.writeHandleAsync(mockHandle, mockData).should.be.rejectedWith('data must be a Buffer'); + }); + + it('should delegate to noble, withoutResponse false', async () => { + const promise = peripheral.writeHandleAsync(mockHandle, mockData, false); + + peripheral.emit(`handleWrite${mockHandle}`); + await promise; + + mockNoble.writeHandle.calledWithExactly(mockId, mockHandle, mockData, false).should.equal(true); + }); + + it('should delegate to noble, withoutResponse true', async () => { + const promise = peripheral.writeHandleAsync(mockHandle, mockData, true); + + peripheral.emit(`handleWrite${mockHandle}`); + await promise; + + mockNoble.writeHandle.calledWithExactly(mockId, mockHandle, mockData, true).should.equal(true); + }); + + it('should resolve', async () => { + const promise = peripheral.writeHandleAsync(mockHandle, mockData, false); + + peripheral.emit(`handleWrite${mockHandle}`); + await promise.should.be.resolvedWith(); + }); + }); }); From 7aef00a74e8e94f62f7361cebdbbae07d70d28ff Mon Sep 17 00:00:00 2001 From: Ron Smeral Date: Thu, 2 Apr 2020 12:03:22 +0200 Subject: [PATCH 089/114] add tests for async functions of service --- test/test-service.js | 58 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/test/test-service.js b/test/test-service.js index 8ff982496..d4c3f6f1d 100644 --- a/test/test-service.js +++ b/test/test-service.js @@ -82,6 +82,35 @@ describe('service', function () { }); }); + describe('discoverIncludedServicesAsync', function () { + it('should delegate to noble', async () => { + const promise = service.discoverIncludedServicesAsync(); + service.emit('includedServicesDiscover'); + await promise; + + mockNoble.discoverIncludedServices.calledWithExactly(mockPeripheralId, mockUuid, undefined).should.equal(true); + }); + + it('should delegate to noble, with uuids', async () => { + const mockUuids = []; + const promise = service.discoverIncludedServicesAsync(mockUuids); + service.emit('includedServicesDiscover'); + await promise; + + mockNoble.discoverIncludedServices.calledWithExactly(mockPeripheralId, mockUuid, mockUuids).should.equal(true); + }); + + it('should resolve with data', async () => { + const mockIncludedServiceUuids = []; + + const promise = service.discoverIncludedServicesAsync(); + service.emit('includedServicesDiscover', mockIncludedServiceUuids); + const result = await promise; + + result.should.equal(mockIncludedServiceUuids); + }); + }); + describe('discoverCharacteristics', function () { it('should delegate to noble', function () { service.discoverCharacteristics(); @@ -123,4 +152,33 @@ describe('service', function () { callbackCharacteristics.should.equal(mockCharacteristics); }); }); + + describe('discoverCharacteristicsAsync', () => { + it('should delegate to noble', async () => { + const promise = service.discoverCharacteristicsAsync(); + service.emit('characteristicsDiscover'); + await promise; + + mockNoble.discoverCharacteristics.calledWithExactly(mockPeripheralId, mockUuid, undefined).should.equal(true); + }); + + it('should delegate to noble, with uuids', async () => { + const mockUuids = []; + const promise = service.discoverCharacteristicsAsync(mockUuids); + service.emit('characteristicsDiscover'); + await promise; + + mockNoble.discoverCharacteristics.calledWithExactly(mockPeripheralId, mockUuid, mockUuids).should.equal(true); + }); + + it('should resolve with data', async () => { + const mockCharacteristics = []; + + const promise = service.discoverCharacteristicsAsync(); + service.emit('characteristicsDiscover', mockCharacteristics); + const result = await promise; + + result.should.equal(mockCharacteristics); + }); + }); }); From 2c1a4c463f80363845ac16902e38980bfa0c2133 Mon Sep 17 00:00:00 2001 From: Ron Smeral Date: Thu, 2 Apr 2020 12:15:56 +0200 Subject: [PATCH 090/114] add tests for async functions of descriptor --- test/test-descriptor.js | 50 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/test/test-descriptor.js b/test/test-descriptor.js index 79ffca86b..1428c4a89 100644 --- a/test/test-descriptor.js +++ b/test/test-descriptor.js @@ -88,6 +88,26 @@ describe('Descriptor', function () { }); }); + describe('readValueAsync', function () { + it('should delegate to noble', async () => { + const promise = descriptor.readValueAsync(); + descriptor.emit('valueRead'); + await promise; + + mockNoble.readValue.calledWithExactly(mockPeripheralId, mockServiceUuid, mockCharacteristicUuid, mockUuid).should.equal(true); + }); + + it('should resolve with data', async () => { + const mockData = Buffer.alloc(0); + + const promise = descriptor.readValueAsync(); + descriptor.emit('valueRead', mockData); + const result = await promise; + + result.should.equal(mockData); + }); + }); + describe('writeValue', function () { let mockData = null; @@ -132,4 +152,34 @@ describe('Descriptor', function () { calledback.should.equal(1); }); }); + + describe('writeValueAsync', function () { + let mockData = null; + + beforeEach(function () { + mockData = Buffer.alloc(0); + }); + + it('should only accept data as a buffer', async () => { + mockData = {}; + + await descriptor.writeValueAsync(mockData).should.be.rejectedWith('data must be a Buffer'); + }); + + it('should delegate to noble', async () => { + const promise = descriptor.writeValueAsync(mockData); + descriptor.emit('valueWrite'); + await promise; + + mockNoble.writeValue.calledWithExactly(mockPeripheralId, mockServiceUuid, mockCharacteristicUuid, mockUuid, mockData).should.equal(true); + }); + + it('should resolve', async () => { + const promise = descriptor.writeValueAsync(mockData); + descriptor.emit('valueWrite'); + await promise; + + await promise.should.be.resolved(); + }); + }); }); From 8f98742b8221de05c8eab67876cf53f5e6db0d1e Mon Sep 17 00:00:00 2001 From: Ron Smeral Date: Thu, 2 Apr 2020 12:33:45 +0200 Subject: [PATCH 091/114] add tests for async functions of characteristic --- test/test-characteristic.js | 166 ++++++++++++++++++++++++++++++++++++ 1 file changed, 166 insertions(+) diff --git a/test/test-characteristic.js b/test/test-characteristic.js index 1c730662b..11b4f4dd3 100644 --- a/test/test-characteristic.js +++ b/test/test-characteristic.js @@ -83,6 +83,26 @@ describe('Characteristic', function () { }); }); + describe('readAsync', () => { + it('should delegate to noble', async () => { + const promise = characteristic.readAsync(); + characteristic.emit('read'); + await promise; + + mockNoble.read.calledWithExactly(mockPeripheralId, mockServiceUuid, mockUuid).should.equal(true); + }); + + it('should resolve with data', async () => { + const mockData = Buffer.alloc(0); + + const promise = characteristic.readAsync(); + characteristic.emit('read', mockData); + const result = await promise; + + result.should.equal(mockData); + }); + }); + describe('write', function () { let mockData = null; @@ -122,6 +142,44 @@ describe('Characteristic', function () { }); }); + describe('writeAsync', () => { + let mockData = null; + + beforeEach(() => { + mockData = Buffer.alloc(0); + }); + + it('should only accept data as a buffer', async () => { + mockData = {}; + + await characteristic.writeAsync(mockData).should.be.rejectedWith('data must be a Buffer'); + }); + + it('should delegate to noble, withoutResponse false', async () => { + const promise = characteristic.writeAsync(mockData, false); + characteristic.emit('write'); + await promise; + + mockNoble.write.calledWithExactly(mockPeripheralId, mockServiceUuid, mockUuid, mockData, false).should.equal(true); + }); + + it('should delegate to noble, withoutResponse true', async () => { + const promise = characteristic.writeAsync(mockData, true); + characteristic.emit('write'); + await promise; + + mockNoble.write.calledWithExactly(mockPeripheralId, mockServiceUuid, mockUuid, mockData, true).should.equal(true); + }); + + it('should resolve', async () => { + const promise = characteristic.writeAsync(mockData, true); + characteristic.emit('write'); + await promise; + + await promise.should.be.resolved(); + }); + }); + describe('broadcast', function () { it('should delegate to noble, true', function () { characteristic.broadcast(true); @@ -147,6 +205,32 @@ describe('Characteristic', function () { }); }); + describe('broadcastAsync', () => { + it('should delegate to noble, true', async () => { + const promise = characteristic.broadcastAsync(true); + characteristic.emit('broadcast'); + await promise; + + mockNoble.broadcast.calledWithExactly(mockPeripheralId, mockServiceUuid, mockUuid, true).should.equal(true); + }); + + it('should delegate to noble, false', async () => { + const promise = characteristic.broadcastAsync(false); + characteristic.emit('broadcast'); + await promise; + + mockNoble.broadcast.calledWithExactly(mockPeripheralId, mockServiceUuid, mockUuid, false).should.equal(true); + }); + + it('should resolve', async () => { + const promise = characteristic.broadcastAsync(true); + characteristic.emit('broadcast'); + await promise; + + await promise.should.be.resolved(); + }); + }); + describe('notify', function () { it('should delegate to noble, true', function () { characteristic.notify(true); @@ -172,6 +256,32 @@ describe('Characteristic', function () { }); }); + describe('notifyAsync', () => { + it('should delegate to noble, true', async () => { + const promise = characteristic.notifyAsync(true); + characteristic.emit('notify'); + await promise; + + mockNoble.notify.calledWithExactly(mockPeripheralId, mockServiceUuid, mockUuid, true).should.equal(true); + }); + + it('should delegate to noble, false', async () => { + const promise = characteristic.notifyAsync(false); + characteristic.emit('notify'); + await promise; + + mockNoble.notify.calledWithExactly(mockPeripheralId, mockServiceUuid, mockUuid, false).should.equal(true); + }); + + it('should resolve', async () => { + const promise = characteristic.notifyAsync(true); + characteristic.emit('notify'); + await promise; + + await promise.should.be.resolved(); + }); + }); + describe('subscribe', function () { it('should delegate to noble notify, true', function () { characteristic.subscribe(); @@ -191,6 +301,24 @@ describe('Characteristic', function () { }); }); + describe('subscribeAsync', () => { + it('should delegate to noble notify, true', async () => { + const promise = characteristic.subscribeAsync(); + characteristic.emit('notify'); + await promise; + + mockNoble.notify.calledWithExactly(mockPeripheralId, mockServiceUuid, mockUuid, true).should.equal(true); + }); + + it('should resolve', async () => { + const promise = characteristic.subscribeAsync(); + characteristic.emit('notify'); + await promise; + + await promise.should.be.resolved(); + }); + }); + describe('unsubscribe', function () { it('should delegate to noble notify, false', function () { characteristic.unsubscribe(); @@ -210,6 +338,24 @@ describe('Characteristic', function () { }); }); + describe('unsubscribeAsync', () => { + it('should delegate to noble notify, false', async () => { + const promise = characteristic.unsubscribeAsync(); + characteristic.emit('notify'); + await promise; + + mockNoble.notify.calledWithExactly(mockPeripheralId, mockServiceUuid, mockUuid, false).should.equal(true); + }); + + it('should resolve', async () => { + const promise = characteristic.unsubscribeAsync(); + characteristic.emit('notify'); + await promise; + + await promise.should.be.resolved(); + }); + }); + describe('discoverDescriptors', function () { it('should delegate to noble', function () { characteristic.discoverDescriptors(); @@ -243,4 +389,24 @@ describe('Characteristic', function () { callbackDescriptors.should.equal(mockDescriptors); }); }); + + describe('discoverDescriptorsAsync', () => { + it('should delegate to noble', async () => { + const promise = characteristic.discoverDescriptorsAsync(); + characteristic.emit('descriptorsDiscover'); + await promise; + + mockNoble.discoverDescriptors.calledWithExactly(mockPeripheralId, mockServiceUuid, mockUuid).should.equal(true); + }); + + it('should resolve with descriptors', async () => { + const mockDescriptors = []; + + const promise = characteristic.discoverDescriptorsAsync(); + characteristic.emit('descriptorsDiscover', mockDescriptors); + const result = await promise; + + result.should.equal(mockDescriptors); + }); + }); }); From 41012f4c08a0c83888df0e015c7235e0973df6b0 Mon Sep 17 00:00:00 2001 From: Ron Smeral Date: Thu, 2 Apr 2020 13:24:25 +0200 Subject: [PATCH 092/114] add tests for async functions of noble --- test/test-noble.js | 69 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 test/test-noble.js diff --git a/test/test-noble.js b/test/test-noble.js new file mode 100644 index 000000000..2024c4bc3 --- /dev/null +++ b/test/test-noble.js @@ -0,0 +1,69 @@ +require('should'); +const sinon = require('sinon'); + +const Noble = require('../lib/noble'); + +describe('Noble', () => { + /** + * @type {Noble & import('events').EventEmitter} + */ + let noble; + let mockBindings; + + beforeEach(() => { + mockBindings = { + init: () => {}, + on: () => {}, + startScanning: sinon.spy(), + stopScanning: sinon.spy() + }; + + noble = new Noble(mockBindings); + }); + + describe('startScanningAsync', () => { + it('should delegate to binding', async () => { + const expectedServiceUuids = [1, 2, 3]; + const expectedAllowDuplicates = true; + const promise = noble.startScanningAsync(expectedServiceUuids, expectedAllowDuplicates); + noble.emit('stateChange', 'poweredOn'); + noble.emit('scanStart'); + await promise; + + mockBindings.startScanning.calledWithExactly(expectedServiceUuids, expectedAllowDuplicates).should.equal(true); + }); + + it('should throw an error if not powered on', async () => { + const promise = noble.startScanningAsync(); + noble.emit('stateChange', 'poweredOff'); + noble.emit('scanStart'); + + await promise.should.be.rejectedWith('Could not start scanning, state is poweredOff (not poweredOn)'); + }); + + it('should resolve', async () => { + const promise = noble.startScanningAsync(); + noble.emit('stateChange', 'poweredOn'); + noble.emit('scanStart'); + + await promise.should.be.resolved(); + }); + }); + + describe('stopScanningAsync', () => { + it('should delegate to binding', async () => { + noble.initialized = true; + const promise = noble.stopScanningAsync(); + noble.emit('scanStop'); + await promise; + + mockBindings.stopScanning.calledWithExactly().should.equal(true); + }); + + it('should resolve', async () => { + const promise = noble.stopScanningAsync(); + noble.emit('scanStop'); + await promise.should.be.resolved(); + }); + }); +}); From 1d6810758f125f2ca2f1d02072822498daacd724 Mon Sep 17 00:00:00 2001 From: Ron Smeral Date: Fri, 3 Apr 2020 14:19:08 +0200 Subject: [PATCH 093/114] bump actions/checkout to v2 --- .github/workflows/nodepackage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/nodepackage.yml b/.github/workflows/nodepackage.yml index 526c10ef8..2b845e06d 100644 --- a/.github/workflows/nodepackage.yml +++ b/.github/workflows/nodepackage.yml @@ -24,7 +24,7 @@ jobs: 13, ] steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v2 - uses: actions/setup-node@v1 with: node-version: ${{ matrix.node }} From 6f4f5206e07bca0b3d44c7825ae03fc7c6ac94f3 Mon Sep 17 00:00:00 2001 From: Ron Smeral Date: Fri, 3 Apr 2020 18:35:36 +0200 Subject: [PATCH 094/114] Release 1.9.2-8 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 29a01d879..65711b024 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@abandonware/noble", - "version": "1.9.2-7", + "version": "1.9.2-8", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index cd8b017a2..24e726637 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "license": "MIT", "name": "@abandonware/noble", "description": "A Node.js BLE (Bluetooth Low Energy) central library.", - "version": "1.9.2-7", + "version": "1.9.2-8", "repository": { "type": "git", "url": "https://github.com/abandonware/noble.git" From 9dbace42a86b84507b00232b3bc5ece3b29afbb1 Mon Sep 17 00:00:00 2001 From: Philippe Coval Date: Sat, 7 Mar 2020 13:55:18 +0100 Subject: [PATCH 095/114] github: Add fediverse-action to workflows This config file will post a default message on each push. https://mastodon.social/tags/FediVerseAction As explained in documentation token should be set in project's secrect. Once checked config can be customized, eg: to post only on releases. Then please share your updated config file to community: https://github.com/rzr/fediverse-action#Community Change-Id: I8323211f6b224b3fb1603c605416fc2a69d24be2 Relate-to: https://github.com/rzr/fediverse-action/ Origin: https://github.com/rzr/iotjs-express/commit/b7adeda334a112c2887db857f1de91cc3fe66bce Signed-off-by: Philippe Coval --- .github/workflows/fediverse-action.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 .github/workflows/fediverse-action.yml diff --git a/.github/workflows/fediverse-action.yml b/.github/workflows/fediverse-action.yml new file mode 100644 index 000000000..20da36dde --- /dev/null +++ b/.github/workflows/fediverse-action.yml @@ -0,0 +1,11 @@ +# YAML +--- +name: fediverse-action +on: [push] +jobs: + post: + runs-on: ubuntu-latest + steps: + - uses: rzr/fediverse-action@master + with: + access-token: ${{ secrets.MASTODON_ACCESS_TOKEN }} From 8698a68e76c1d07a02d2ae0edfc02b5aebad9e51 Mon Sep 17 00:00:00 2001 From: Philippe Coval Date: Thu, 12 Mar 2020 17:17:28 +0100 Subject: [PATCH 096/114] github: Add commit shortlog post URL to fediverse Link commit url for fediverse-action Change-Id: I7a47343c920f087d0d265eed9278087ed18570ac Origin: https://github.com/rzr/iotjs-express/commit/e80801636fecf72916cb983090480a527b804c1c Signed-off-by: Philippe Coval --- .github/workflows/fediverse-action.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/fediverse-action.yml b/.github/workflows/fediverse-action.yml index 20da36dde..e45c6e809 100644 --- a/.github/workflows/fediverse-action.yml +++ b/.github/workflows/fediverse-action.yml @@ -6,6 +6,10 @@ jobs: post: runs-on: ubuntu-latest steps: + - uses: actions/checkout@v1 + - id: log + run: echo "::set-output name=message::$(git log --no-merges -1 --oneline)" - uses: rzr/fediverse-action@master with: access-token: ${{ secrets.MASTODON_ACCESS_TOKEN }} + message: "https://github.com/${{ github.repository }}/commit/${{ steps.log.outputs.message }} ~ #FediVerseAction" From aef35a86d21cf5d60d9c239a4c7b6a69718fa3b9 Mon Sep 17 00:00:00 2001 From: Philippe Coval Date: Sat, 7 Mar 2020 11:09:14 +0100 Subject: [PATCH 097/114] github: Publish only on release Change-Id: I1cc93f43a56fe9e8a7b3c37f3859a324a06f47bc Signed-off-by: Philippe Coval --- .github/workflows/npm-publish.yml | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml index 3586899df..9bf5c7725 100644 --- a/.github/workflows/npm-publish.yml +++ b/.github/workflows/npm-publish.yml @@ -8,18 +8,19 @@ jobs: name: npm-publish runs-on: ubuntu-latest steps: - - name: Checkout repository - uses: actions/checkout@master - - name: Set up Node.js - uses: actions/setup-node@master - with: - node-version: 10.0.0 - - name: Publish if version has been updated - uses: pascalgn/npm-publish-action@51fdb4531e99aac1873764ef7271af448dc42ab4 - with: # All of theses inputs are optional - tag_name: "v%s" - tag_message: "v%s" - commit_pattern: "^Release (\\S+)" - env: # More info about the environment variables in the README - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Leave this as is, it's automatically generated - NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} # You need to set this in your repo settings + - uses: actions/checkout@master + - id: log + run: echo "::set-output name=message::$(git log --no-merges -1 --oneline)" + - if: "contains(steps.log.outputs.message, 'Release ')" + uses: actions/setup-node@master + with: + node-version: 10.0.0 + - if: "contains(steps.log.outputs.message, 'Release ')" + uses: pascalgn/npm-publish-action@51fdb4531e99aac1873764ef7271af448dc42ab4 + with: # All of theses inputs are optional + tag_name: "v%s" + tag_message: "v%s" + commit_pattern: "^Release (\\S+)" + env: # More info about the environment variables in the README + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Leave this as is, it's automatically generated + NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} # You need to set this in your repo settings From e1213cc2a7145f5feca2cf47499603d1c39ff755 Mon Sep 17 00:00:00 2001 From: Nathan Kellenicki Date: Sat, 4 Apr 2020 17:26:27 -0700 Subject: [PATCH 098/114] Fixed tsc error in index.d.ts Semicolon throws error when compiling with tsc: `TS1036: Statements are not allowed in ambient contexts.` --- index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.d.ts b/index.d.ts index aba7aa6b7..7bf6625b2 100644 --- a/index.d.ts +++ b/index.d.ts @@ -45,7 +45,7 @@ export declare var state: string; export interface ServicesAndCharacteristics { services: Service[]; characteristics: Characteristic[]; -}; +} export declare class Peripheral extends events.EventEmitter { id: string; From 890fc5e69940afc174742afc0b61f1ca6a1708f8 Mon Sep 17 00:00:00 2001 From: Chris Date: Thu, 7 May 2020 20:27:17 +0200 Subject: [PATCH 099/114] add definitions for once() --- index.d.ts | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/index.d.ts b/index.d.ts index 7bf6625b2..f65689d64 100644 --- a/index.d.ts +++ b/index.d.ts @@ -32,6 +32,12 @@ export declare function on(event: "scanStop", listener: () => void): events.Even export declare function on(event: "discover", listener: (peripheral: Peripheral) => void): events.EventEmitter; export declare function on(event: string, listener: Function): events.EventEmitter; +export declare function once(event: "stateChange", listener: (state: string) => void): events.EventEmitter; +export declare function once(event: "scanStart", listener: () => void): events.EventEmitter; +export declare function once(event: "scanStop", listener: () => void): events.EventEmitter; +export declare function once(event: "discover", listener: (peripheral: Peripheral) => void): events.EventEmitter; +export declare function once(event: string, listener: Function): events.EventEmitter; + export declare function removeListener(event: "stateChange", listener: (state: string) => void): events.EventEmitter; export declare function removeListener(event: "scanStart", listener: () => void): events.EventEmitter; export declare function removeListener(event: "scanStop", listener: () => void): events.EventEmitter; @@ -84,6 +90,12 @@ export declare class Peripheral extends events.EventEmitter { on(event: "rssiUpdate", listener: (rssi: number) => void): this; on(event: "servicesDiscover", listener: (services: Service[]) => void): this; on(event: string, listener: Function): this; + + once(event: "connect", listener: (error: string) => void): this; + once(event: "disconnect", listener: (error: string) => void): this; + once(event: "rssiUpdate", listener: (rssi: number) => void): this; + once(event: "servicesDiscover", listener: (services: Service[]) => void): this; + once(event: string, listener: Function): this; } export interface Advertisement { @@ -117,6 +129,10 @@ export declare class Service extends events.EventEmitter { on(event: "includedServicesDiscover", listener: (includedServiceUuids: string[]) => void): this; on(event: "characteristicsDiscover", listener: (characteristics: Characteristic[]) => void): this; on(event: string, listener: Function): this; + + once(event: "includedServicesDiscover", listener: (includedServiceUuids: string[]) => void): this; + once(event: "characteristicsDiscover", listener: (characteristics: Characteristic[]) => void): this; + once(event: string, listener: Function): this; } export declare class Characteristic extends events.EventEmitter { @@ -149,6 +165,14 @@ export declare class Characteristic extends events.EventEmitter { on(event: "descriptorsDiscover", listener: (descriptors: Descriptor[]) => void): this; on(event: string, listener: Function): this; on(event: string, option: boolean, listener: Function): this; + + once(event: "read", listener: (data: Buffer, isNotification: boolean) => void): this; + once(event: "write", withoutResponse: boolean, listener: (error: string) => void): this; + once(event: "broadcast", listener: (state: string) => void): this; + once(event: "notify", listener: (state: string) => void): this; + once(event: "descriptorsDiscover", listener: (descriptors: Descriptor[]) => void): this; + once(event: string, listener: Function): this; + once(event: string, option: boolean, listener: Function): this; } export declare class Descriptor extends events.EventEmitter { @@ -165,4 +189,8 @@ export declare class Descriptor extends events.EventEmitter { on(event: "valueRead", listener: (error: string, data: Buffer) => void): this; on(event: "valueWrite", listener: (error: string) => void): this; on(event: string, listener: Function): this; + + once(event: "valueRead", listener: (error: string, data: Buffer) => void): this; + once(event: "valueWrite", listener: (error: string) => void): this; + once(event: string, listener: Function): this; } From b2554636f719a3531c0ac291e64edb82ef23805c Mon Sep 17 00:00:00 2001 From: CyberCastle Date: Wed, 13 May 2020 18:46:22 -0400 Subject: [PATCH 100/114] Release 1.9.2-9 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 24e726637..fd30bb460 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "license": "MIT", "name": "@abandonware/noble", "description": "A Node.js BLE (Bluetooth Low Energy) central library.", - "version": "1.9.2-8", + "version": "1.9.2-9", "repository": { "type": "git", "url": "https://github.com/abandonware/noble.git" From 7e88cb65537ddb4628d8c20b48ea059506a8f520 Mon Sep 17 00:00:00 2001 From: CyberCastle Date: Wed, 13 May 2020 18:48:30 -0400 Subject: [PATCH 101/114] Release 1.9.2-9 --- package-lock.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package-lock.json b/package-lock.json index 65711b024..da9e3b420 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@abandonware/noble", - "version": "1.9.2-8", + "version": "1.9.2-9", "lockfileVersion": 1, "requires": true, "dependencies": { From fc0f521b15ac301a0ecb1c7afea32c7fa7ecfb24 Mon Sep 17 00:00:00 2001 From: Martin Date: Fri, 29 May 2020 11:56:06 +0200 Subject: [PATCH 102/114] Update README. Places an additional hint in the Linux installation section. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index dada231ef..6a0e22832 100644 --- a/README.md +++ b/README.md @@ -66,6 +66,7 @@ noble.on('discover', async (peripheral) => { * Kernel version 3.6 or above * `libbluetooth-dev` + * [Notice the comment when running node without sudo-rights](https://github.com/abandonware/noble#running-without-rootsudo-linux-specific) ##### Ubuntu, Debian, Raspbian From 0811e29e5891f4580ac5468fa8449af01be024d3 Mon Sep 17 00:00:00 2001 From: Martin Date: Wed, 3 Jun 2020 12:09:34 +0200 Subject: [PATCH 103/114] Add sudo command to Linux prerequisites. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6a0e22832..c3dd353e0 100644 --- a/README.md +++ b/README.md @@ -66,7 +66,7 @@ noble.on('discover', async (peripheral) => { * Kernel version 3.6 or above * `libbluetooth-dev` - * [Notice the comment when running node without sudo-rights](https://github.com/abandonware/noble#running-without-rootsudo-linux-specific) + * Run the following command to grant node the necessary priviliges to read BLE data: `sudo setcap cap_net_raw+eip $(eval readlink -f $(which node))` ([Explanation](https://github.com/abandonware/noble#running-without-rootsudo-linux-specific)) ##### Ubuntu, Debian, Raspbian From 9ece0ec6b6fcf6e9e95797f5694a6f4bf8df6bcf Mon Sep 17 00:00:00 2001 From: Martin Date: Wed, 3 Jun 2020 13:42:38 +0200 Subject: [PATCH 104/114] Fix typo in README. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c3dd353e0..a5a6bbb22 100644 --- a/README.md +++ b/README.md @@ -66,7 +66,7 @@ noble.on('discover', async (peripheral) => { * Kernel version 3.6 or above * `libbluetooth-dev` - * Run the following command to grant node the necessary priviliges to read BLE data: `sudo setcap cap_net_raw+eip $(eval readlink -f $(which node))` ([Explanation](https://github.com/abandonware/noble#running-without-rootsudo-linux-specific)) + * Run the following command to grant node the necessary privileges to read BLE data: `sudo setcap cap_net_raw+eip $(eval readlink -f $(which node))` ([Explanation](https://github.com/abandonware/noble#running-without-rootsudo-linux-specific)) ##### Ubuntu, Debian, Raspbian From aad76b5b25bac3074bd48017e4e73fae812ba2f8 Mon Sep 17 00:00:00 2001 From: Angel Merino Sastre Date: Wed, 27 May 2020 12:30:03 +0200 Subject: [PATCH 105/114] Fix noble from hanging after bluetooth device resets --- lib/hci-socket/hci.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/hci-socket/hci.js b/lib/hci-socket/hci.js index 766478df6..c70f412e3 100644 --- a/lib/hci-socket/hci.js +++ b/lib/hci-socket/hci.js @@ -115,6 +115,12 @@ Hci.prototype.pollIsDevUp = function () { if (this._isDevUp !== isDevUp) { if (isDevUp) { + if (this._state === 'poweredOff') { + this._socket.removeAllListeners(); + this._state = null; + this.init(); + return; + } this.setSocketFilter(); this.setEventMask(); this.setLeEventMask(); From 6e39f6110dbd17f6b53d54d86f58abe34518f306 Mon Sep 17 00:00:00 2001 From: Paul York Date: Thu, 30 Jul 2020 15:23:41 -0400 Subject: [PATCH 106/114] disallow duplicate service UUID's to be added during discovery (fixes hang condition) --- lib/hci-socket/gatt.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/hci-socket/gatt.js b/lib/hci-socket/gatt.js index 892b38b2d..dab2eb957 100644 --- a/lib/hci-socket/gatt.js +++ b/lib/hci-socket/gatt.js @@ -358,8 +358,9 @@ Gatt.prototype.discoverServices = function (uuids) { if (opcode !== ATT_OP_READ_BY_GROUP_RESP || services[services.length - 1].endHandle === 0xffff) { const serviceUuids = []; for (i = 0; i < services.length; i++) { - if (uuids.length === 0 || uuids.indexOf(services[i].uuid) !== -1) { - serviceUuids.push(services[i].uuid); + const uuid = services[i].uuid.trim(); + if ((uuids.length === 0 || uuids.indexOf(uuid) !== -1) && serviceUuids.indexOf(uuid) === -1) { + serviceUuids.push(uuid); } this._services[services[i].uuid] = services[i]; From 1e5424ae87efcf12a301327fe1bdd9b73c064211 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joachim=20Sch=C3=A4fer?= Date: Wed, 19 Aug 2020 16:57:04 +0200 Subject: [PATCH 107/114] Fix bug that noble sometimes does not recognize unsufficient permissions --- lib/hci-socket/hci.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/hci-socket/hci.js b/lib/hci-socket/hci.js index c70f412e3..41134b264 100644 --- a/lib/hci-socket/hci.js +++ b/lib/hci-socket/hci.js @@ -573,7 +573,7 @@ Hci.prototype.onSocketData = function (data) { Hci.prototype.onSocketError = function (error) { debug(`onSocketError: ${error.message}`); - if (error.message === 'Operation not permitted') { + if (error.code === 'EPERM') { this.emit('stateChange', 'unauthorized'); } else if (error.message === 'Network is down') { // no-op From 658405a0fcc92c41872bee45eb54d3ed39792318 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joachim=20Sch=C3=A4fer?= Date: Sun, 6 Sep 2020 17:58:29 +0200 Subject: [PATCH 108/114] Release 1.9.2-10 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index da9e3b420..4ff632e03 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@abandonware/noble", - "version": "1.9.2-9", + "version": "1.9.2-10", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index fd30bb460..22724460a 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "license": "MIT", "name": "@abandonware/noble", "description": "A Node.js BLE (Bluetooth Low Energy) central library.", - "version": "1.9.2-9", + "version": "1.9.2-10", "repository": { "type": "git", "url": "https://github.com/abandonware/noble.git" From f6b5395e59024f650933b182b569dbc6c5a94bc5 Mon Sep 17 00:00:00 2001 From: Martin Ziel Date: Wed, 9 Sep 2020 14:57:54 +0200 Subject: [PATCH 109/114] Exposed bindings in TypeScript --- index.d.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/index.d.ts b/index.d.ts index f65689d64..e849cf9f9 100644 --- a/index.d.ts +++ b/index.d.ts @@ -48,6 +48,8 @@ export declare function removeAllListeners(event?: string): events.EventEmitter; export declare var state: string; +export var _bindings: any; + export interface ServicesAndCharacteristics { services: Service[]; characteristics: Characteristic[]; From 8e8f7767737ab0561bc5b5f5ab7773350b0dae0b Mon Sep 17 00:00:00 2001 From: Tony G Date: Tue, 8 Sep 2020 22:55:29 -0400 Subject: [PATCH 110/114] Update noble.js Not all bindings support addService or addCharacteristics --- lib/noble.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/noble.js b/lib/noble.js index 1f8d8b65c..0c875e05d 100644 --- a/lib/noble.js +++ b/lib/noble.js @@ -276,7 +276,9 @@ Noble.prototype.addService = function (peripheralUuid, service) { const peripheral = this._peripherals[peripheralUuid]; // pass on to lower layers (gatt) - this._bindings.addService(peripheralUuid, service); + if (this._bindings.addService) { + this._bindings.addService(peripheralUuid, service); + } if (!peripheral.services) { peripheral.services = []; @@ -348,8 +350,10 @@ Noble.prototype.onIncludedServicesDiscover = function (peripheralUuid, serviceUu /// add characteristics to the peripheral; returns an array of initialized Characteristics objects Noble.prototype.addCharacteristics = function (peripheralUuid, serviceUuid, characteristics) { // first, initialize gatt layer: - this._bindings.addCharacteristics(peripheralUuid, serviceUuid, characteristics); - + if (this._bindings.addCharacteristics) { + this._bindings.addCharacteristics(peripheralUuid, serviceUuid, characteristics); + } + const service = this._services[peripheralUuid][serviceUuid]; if (!service) { this.emit('warning', `unknown service ${peripheralUuid}, ${serviceUuid} characteristics discover!`); From ef452ba8c667bed1e23704b049e0581fd47acc49 Mon Sep 17 00:00:00 2001 From: Tony G Date: Tue, 8 Sep 2020 23:02:46 -0400 Subject: [PATCH 111/114] Update noble.js remove whitespace --- lib/noble.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/noble.js b/lib/noble.js index 0c875e05d..d42170917 100644 --- a/lib/noble.js +++ b/lib/noble.js @@ -353,7 +353,7 @@ Noble.prototype.addCharacteristics = function (peripheralUuid, serviceUuid, char if (this._bindings.addCharacteristics) { this._bindings.addCharacteristics(peripheralUuid, serviceUuid, characteristics); } - + const service = this._services[peripheralUuid][serviceUuid]; if (!service) { this.emit('warning', `unknown service ${peripheralUuid}, ${serviceUuid} characteristics discover!`); From 422f4e76120992c41ebb32b7e054219a3a3763ce Mon Sep 17 00:00:00 2001 From: Jan Schmidle Date: Tue, 15 Sep 2020 15:59:02 +0200 Subject: [PATCH 112/114] linting --- lib/hci-socket/bindings.js | 1 - lib/hci-socket/hci.js | 2 +- lib/resolve-bindings.js | 8 ++++---- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/hci-socket/bindings.js b/lib/hci-socket/bindings.js index 84bed8625..9dec8e9b7 100644 --- a/lib/hci-socket/bindings.js +++ b/lib/hci-socket/bindings.js @@ -7,7 +7,6 @@ const Gap = require('./gap'); const Hci = require('./hci'); const Signaling = require('./signaling'); - const NobleBindings = function (options) { this._state = null; diff --git a/lib/hci-socket/hci.js b/lib/hci-socket/hci.js index 41134b264..00d3c08cb 100644 --- a/lib/hci-socket/hci.js +++ b/lib/hci-socket/hci.js @@ -84,7 +84,7 @@ const Hci = function (options) { process.env.NOBLE_HCI_DEVICE_ID ? parseInt(process.env.NOBLE_HCI_DEVICE_ID, 10) : undefined; - this._userChannel = typeof options.userChannel === 'undefined' && process.env.HCI_CHANNEL_USER || options.userChannel; + this._userChannel = (typeof options.userChannel === 'undefined' && options.userChannel) || process.env.HCI_CHANNEL_USER; this.on('stateChange', this.onStateChange.bind(this)); }; diff --git a/lib/resolve-bindings.js b/lib/resolve-bindings.js index bead76c7a..3a5290f36 100644 --- a/lib/resolve-bindings.js +++ b/lib/resolve-bindings.js @@ -4,13 +4,13 @@ module.exports = function (options) { const platform = os.platform(); if (process.env.NOBLE_WEBSOCKET) { - return new require('./websocket/bindings')(options); + return new (require('./websocket/bindings'))(options); } else if (process.env.NOBLE_DISTRIBUTED) { - return new require('./distributed/bindings')(options); + return new (require('./distributed/bindings'))(options); } else if (platform === 'darwin') { - return new require('./mac/bindings')(options); + return new (require('./mac/bindings'))(options); } else if (platform === 'linux' || platform === 'freebsd' || platform === 'win32') { - return new require('./hci-socket/bindings')(options); + return new (require('./hci-socket/bindings'))(options); } else { throw new Error('Unsupported platform'); } From 64b974420b4cf7ef1f3b57d7c69aa316b69a842a Mon Sep 17 00:00:00 2001 From: Jan Schmidle Date: Mon, 21 Sep 2020 11:25:27 +0200 Subject: [PATCH 113/114] linting, testing and async fixes --- lib/hci-socket/hci.js | 8 +++++--- lib/noble.js | 4 ++-- lib/peripheral.js | 16 ++++++++++++---- test/test-peripheral.js | 4 ++-- 4 files changed, 21 insertions(+), 11 deletions(-) diff --git a/lib/hci-socket/hci.js b/lib/hci-socket/hci.js index 00d3c08cb..aedea35ed 100644 --- a/lib/hci-socket/hci.js +++ b/lib/hci-socket/hci.js @@ -80,9 +80,11 @@ const Hci = function (options) { this._handleBuffers = {}; - this._deviceId = options.deviceId != null ? parseInt(options.deviceId, 10) : - process.env.NOBLE_HCI_DEVICE_ID ? parseInt(process.env.NOBLE_HCI_DEVICE_ID, 10) : - undefined; + this._deviceId = options.deviceId != null + ? parseInt(options.deviceId, 10) + : process.env.NOBLE_HCI_DEVICE_ID + ? parseInt(process.env.NOBLE_HCI_DEVICE_ID, 10) + : undefined; this._userChannel = (typeof options.userChannel === 'undefined' && options.userChannel) || process.env.HCI_CHANNEL_USER; diff --git a/lib/noble.js b/lib/noble.js index d42170917..80367acf8 100644 --- a/lib/noble.js +++ b/lib/noble.js @@ -99,14 +99,14 @@ Noble.prototype.setScanParameters = function (interval, window, callback) { this.once('scanParametersSet', callback); } this._bindings.setScanParameters(interval, window); -} +}; Noble.prototype.onScanParametersSet = function () { debug('scanParametersSet'); this.emit('scanParametersSet'); }; -Noble.prototype.startScanning = function (serviceUuids, allowDuplicates, callback) { +const startScanning = function (serviceUuids, allowDuplicates, callback) { if (typeof serviceUuids === 'function') { this.emit('warning', 'calling startScanning(callback) is deprecated'); } diff --git a/lib/peripheral.js b/lib/peripheral.js index d023b720c..2e9979f8b 100644 --- a/lib/peripheral.js +++ b/lib/peripheral.js @@ -31,7 +31,7 @@ Peripheral.prototype.toString = function () { }); }; -Peripheral.prototype.connect = function (options, callback) { +const connect = function (options, callback) { if (typeof options === 'function') { callback = options; options = undefined; @@ -46,11 +46,17 @@ Peripheral.prototype.connect = function (options, callback) { this.emit('connect', new Error('Peripheral already connected')); } else { this.state = 'connecting'; + console.log('connecting'); this._noble.connect(this.id, options); } }; -Peripheral.prototype.cancelConnect = function (options, callback) { +Peripheral.prototype.connect = connect; +Peripheral.prototype.connectAsync = function (options) { + return util.promisify((callback) => this.connect(options, callback))(); +}; + +const cancelConnect = function (options, callback) { if (typeof options === 'function') { callback = options; options = undefined; @@ -70,8 +76,10 @@ Peripheral.prototype.cancelConnect = function (options, callback) { } }; -Peripheral.prototype.connect = connect; -Peripheral.prototype.connectAsync = util.promisify(connect); +Peripheral.prototype.cancelConnect = cancelConnect; +Peripheral.prototype.cancelConnectAsync = function (options) { + return util.promisify((callback) => this.cancleConnect(options, callback))(); +}; const disconnect = function (callback) { if (callback) { diff --git a/test/test-peripheral.js b/test/test-peripheral.js index 1d3b9b1c7..a099c1f54 100644 --- a/test/test-peripheral.js +++ b/test/test-peripheral.js @@ -67,7 +67,7 @@ describe('Peripheral', function () { it('should delegate to noble', function () { peripheral.connect(); - mockNoble.connect.calledWithExactly(mockId).should.equal(true); + mockNoble.connect.calledWithExactly(mockId, undefined).should.equal(true); }); it('should callback', function () { @@ -105,7 +105,7 @@ describe('Peripheral', function () { peripheral.emit('connect'); await promise; - mockNoble.connect.calledWithExactly(mockId).should.equal(true); + mockNoble.connect.calledWithExactly(mockId, undefined).should.equal(true); }); }); From 3bec773ea54e655c349298e8cbd63bd5ac6de95a Mon Sep 17 00:00:00 2001 From: Jan Schmidle Date: Mon, 21 Sep 2020 11:45:24 +0200 Subject: [PATCH 114/114] fixed some more linting --- lib/hci-socket/bindings.js | 5 ++--- lib/hci-socket/gap.js | 2 +- lib/hci-socket/gatt.js | 21 ++++++++++----------- lib/hci-socket/hci.js | 24 ++++++++++++------------ 4 files changed, 25 insertions(+), 27 deletions(-) diff --git a/lib/hci-socket/bindings.js b/lib/hci-socket/bindings.js index 9dec8e9b7..d488d6081 100644 --- a/lib/hci-socket/bindings.js +++ b/lib/hci-socket/bindings.js @@ -28,10 +28,9 @@ const NobleBindings = function (options) { util.inherits(NobleBindings, events.EventEmitter); - NobleBindings.prototype.setScanParameters = function (interval, window) { this._gap.setScanParameters(interval, window); -} +}; NobleBindings.prototype.startScanning = function (serviceUuids, allowDuplicates) { this._scanServiceUuids = serviceUuids || []; @@ -58,7 +57,7 @@ NobleBindings.prototype.connect = function (peripheralUuid, parameters) { NobleBindings.prototype.cancelConnect = function (peripheralUuid) { // TODO: check if it was not in the queue and only then issue cancel on hci - this._connectionQueue = this._connectionQueue.filter( c => c.id !== peripheralUuid ); + this._connectionQueue = this._connectionQueue.filter(c => c.id !== peripheralUuid); this._hci.cancelConnect(this._handles[peripheralUuid]); }; diff --git a/lib/hci-socket/gap.js b/lib/hci-socket/gap.js index a36a0f966..d249bca12 100644 --- a/lib/hci-socket/gap.js +++ b/lib/hci-socket/gap.js @@ -25,7 +25,7 @@ util.inherits(Gap, events.EventEmitter); Gap.prototype.setScanParameters = function (interval, window) { this._hci.setScanParameters(interval, window); -} +}; Gap.prototype.startScanning = function (allowDuplicates) { this._scanState = 'starting'; diff --git a/lib/hci-socket/gatt.js b/lib/hci-socket/gatt.js index dab2eb957..6d95e258c 100644 --- a/lib/hci-socket/gatt.js +++ b/lib/hci-socket/gatt.js @@ -677,14 +677,14 @@ Gatt.prototype.notify = function (serviceUuid, characteristicUuid, notify) { }; function reverse (src) { - var buffer = new Buffer(src.length) + var buffer = Buffer.alloc(src.length); for (var i = 0, j = src.length - 1; i <= j; ++i, --j) { - buffer[i] = src[j] - buffer[j] = src[i] + buffer[i] = src[j]; + buffer[j] = src[i]; } - return buffer + return buffer; } Gatt.prototype.discoverDescriptors = function (serviceUuid, characteristicUuid) { @@ -698,11 +698,10 @@ Gatt.prototype.discoverDescriptors = function (serviceUuid, characteristicUuid) if (opcode === ATT_OP_FIND_INFO_RESP) { const format = data[1]; - const pos = 2; // skip first 2 bytes (opcode, format) + let pos = 2; // skip first 2 bytes (opcode, format) - while( data.length > pos ) { - - switch(format) { + while (data.length > pos) { + switch (format) { case 1: descriptors.push({ handle: data.readUInt16LE(pos), @@ -724,7 +723,7 @@ Gatt.prototype.discoverDescriptors = function (serviceUuid, characteristicUuid) if (opcode !== ATT_OP_FIND_INFO_RESP || descriptors[descriptors.length - 1].handle === characteristic.endHandle) { const descriptorUuids = []; - for (i = 0; i < descriptors.length; i++) { + for (let i = 0; i < descriptors.length; i++) { descriptorUuids.push(descriptors[i].uuid); this._descriptors[serviceUuid][characteristicUuid][descriptors[i].uuid] = descriptors[i]; @@ -742,9 +741,9 @@ Gatt.prototype.discoverDescriptors = function (serviceUuid, characteristicUuid) Gatt.prototype.readValue = function (serviceUuid, characteristicUuid, descriptorUuid) { const descriptor = this._descriptors[serviceUuid][characteristicUuid][descriptorUuid]; - let readData = new Buffer(0); + let readData = Buffer.allow(0); - this._queueCommand(this.readRequest(descriptor.handle), data => { + const callback = data => { const opcode = data[0]; if (opcode === ATT_OP_READ_RESP || opcode === ATT_OP_READ_BLOB_RESP) { diff --git a/lib/hci-socket/hci.js b/lib/hci-socket/hci.js index aedea35ed..9fa1c245d 100644 --- a/lib/hci-socket/hci.js +++ b/lib/hci-socket/hci.js @@ -307,10 +307,10 @@ Hci.prototype.setScanEnabled = function (enabled, filterDuplicates) { }; Hci.prototype.createLeConn = function (address, addressType, parameters) { - const minInterval = parameters && parameters.minInterval || 0x0006; - const maxInterval = parameters && parameters.maxInterval || 0x000c; - const latency = parameters && parameters.latency || 0x0000; - const timeout = parameters && parameters.timeout || 0x00c8; + const minInterval = (parameters && parameters.minInterval) || 0x0006; + const maxInterval = (parameters && parameters.maxInterval) || 0x000c; + const latency = (parameters && parameters.latency) || 0x0000; + const timeout = (parameters && parameters.timeout) || 0x00c8; const cmd = Buffer.alloc(29); @@ -366,17 +366,17 @@ Hci.prototype.connUpdateLe = function (handle, minInterval, maxInterval, latency }; Hci.prototype.cancelConnect = function () { - var cmd = new Buffer(4); + const cmd = Buffer.alloc(4); - // header - cmd.writeUInt8(HCI_COMMAND_PKT, 0); - cmd.writeUInt16LE(LE_CANCEL_CONN_CMD, 1); + // header + cmd.writeUInt8(HCI_COMMAND_PKT, 0); + cmd.writeUInt16LE(LE_CANCEL_CONN_CMD, 1); - // length - cmd.writeUInt8(0x0, 3); + // length + cmd.writeUInt8(0x0, 3); - debug('cancel le conn - writing: ' + cmd.toString('hex')); - this._socket.write(cmd); + debug('cancel le conn - writing: ' + cmd.toString('hex')); + this._socket.write(cmd); }; Hci.prototype.startLeEncryption = function (handle, random, diversifier, key) {