Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

noble

Package Overview
Dependencies
Maintainers
1
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

noble - npm Package Compare versions

Comparing version 0.2.6 to 0.2.7

91

lib/linux/l2cap-ble.js

@@ -9,30 +9,50 @@ /*jshint loopfunc: true */

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_HANDLE_NOTIFY = 0x1b;
var ATT_OP_WRITE_CMD = 0x52;
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_HANDLE_NOTIFY = 0x1b;
var ATT_OP_WRITE_CMD = 0x52;
var GATT_PRIM_SVC_UUID = 0x2800;
var GATT_INCLUDE_UUID = 0x2802;
var GATT_CHARAC_UUID = 0x2803;
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_CLIENT_CHARAC_CFG_UUID = 0x2902;
var GATT_SERVER_CHARAC_CFG_UUID = 0x2903;
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 L2capBle = function(address, addressType) {
this._address = address;
this._addressType = addressType;
this._security = 'low';

@@ -84,2 +104,13 @@ this._services = {};

this.emit('rssi', this._address, rssi);
} else if ((found = line.match(/^security = (.*)$/))) {
this._security = found[1];
if (this._security === 'medium') {
// re-issue the current command
debug(this._address + ': write: ' + this._currentCommand.buffer.toString('hex'));
this._l2capBle.stdin.write(this._currentCommand.buffer.toString('hex') + '\n');
} else {
this.upgradeSecurity();
}
} else if ((found = line.match(/^data (.*)$/))) {

@@ -106,2 +137,10 @@ var lineData = new Buffer(found[1], 'hex');

} else {
if (lineData[0] === ATT_OP_ERROR &&
(lineData[4] === ATT_ECODE_AUTHENTICATION || lineData[4] === ATT_ECODE_AUTHORIZATION || lineData[4] === ATT_ECODE_INSUFF_ENC) &&
this._security !== 'medium') {
this.upgradeSecurity();
return;
}
this._currentCommand.callback(lineData);

@@ -130,2 +169,5 @@

L2capBle.prototype.onStdinError = function(error) {
};
L2capBle.prototype.onStderrData = function(data) {

@@ -143,2 +185,3 @@ console.error(this._address + ': stderr: ' + data);

this._l2capBle.stdout.on('data', this.onStdoutData.bind(this));
this._l2capBle.stdin.on('error', this.onStdinError.bind(this));
this._l2capBle.stderr.on('data', this.onStderrData.bind(this));

@@ -157,2 +200,6 @@

L2capBle.prototype.upgradeSecurity = function() {
this._l2capBle.kill('SIGUSR2');
};
L2capBle.prototype._queueCommand = function(buffer, callback, writeCallback) {

@@ -159,0 +206,0 @@ this._commandQueue.push({

@@ -105,3 +105,5 @@ var debug = require('debug')('noble');

for (var i in advertisement) {
peripheral.advertisement[i] = advertisement[i];
if (advertisement[i] !== undefined) {
peripheral.advertisement[i] = advertisement[i];
}
}

@@ -108,0 +110,0 @@

@@ -5,3 +5,3 @@ {

"description": "A node.js BLE (Bluetooth low energy) central library.",
"version": "0.2.6",
"version": "0.2.7",
"repository": {

@@ -8,0 +8,0 @@ "type": "git",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc