🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@stoprocent/noble

Package Overview
Dependencies
Maintainers
1
Versions
93
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@stoprocent/noble - npm Package Compare versions

Comparing version
2.6.2
to
2.6.3
+34
-8
lib/hci-socket/bindings.js

@@ -24,2 +24,4 @@ const { EventEmitter } = require('events');

this._pendingConnectionAddress = null;
this._pendingConnectionToken = null;
this._cancelledConnectionUuid = null;
this._connectionQueue = [];

@@ -152,5 +154,7 @@

const nextConn = this._connectionQueue[0];
const attemptToken = {};
this._pendingConnectionUuid = nextConn.id;
this._pendingConnectionAddress = this.addressToId(nextConn.address);
this._hci.createLeConn(nextConn.address, nextConn.addressType, nextConn.params, Object.keys(this._handles).length === 0);
this._pendingConnectionToken = attemptToken;
this._hci.createLeConn(nextConn.address, nextConn.addressType, nextConn.params, Object.keys(this._handles).length === 0, attemptToken);
};

@@ -169,4 +173,3 @@

if (this._pendingConnectionUuid === peripheralUuid) {
this._pendingConnectionUuid = null;
this._pendingConnectionAddress = null;
this._cancelledConnectionUuid = peripheralUuid;
}

@@ -209,2 +212,4 @@

this._pendingConnectionAddress = null;
this._pendingConnectionToken = null;
this._cancelledConnectionUuid = null;
}

@@ -321,3 +326,4 @@

masterClockAccuracy,
peerResolvablePrivateAddress
peerResolvablePrivateAddress,
attemptToken
) {

@@ -335,8 +341,18 @@ if (role !== 0 && role !== undefined) {

.map((candidate) => this.addressToId(candidate));
const matchesPendingAttempt = Boolean(
this._pendingConnectionUuid &&
((attemptToken && attemptToken === this._pendingConnectionToken) ||
(this._pendingConnectionAddress &&
completionAddresses.includes(this._pendingConnectionAddress)))
);
const matchesPendingConnection = Boolean(
matchesPendingAttempt &&
currentConn &&
this._pendingConnectionUuid === currentConn.id &&
this._pendingConnectionAddress &&
completionAddresses.includes(this._pendingConnectionAddress)
this._pendingConnectionUuid === currentConn.id
);
const matchesCancelledConnection = Boolean(
matchesPendingAttempt &&
this._cancelledConnectionUuid &&
this._pendingConnectionUuid === this._cancelledConnectionUuid
);

@@ -438,3 +454,12 @@ if (status === 0) {

if (matchesPendingConnection) {
if (matchesCancelledConnection) {
this._pendingConnectionUuid = null;
this._pendingConnectionAddress = null;
this._pendingConnectionToken = null;
this._cancelledConnectionUuid = null;
if (status === 0) {
this._hci.disconnect(handle);
}
this.processConnectionQueue();
} else if (matchesPendingConnection) {
uuid = currentConn.id;

@@ -444,2 +469,3 @@ this._connectionQueue.shift();

this._pendingConnectionAddress = null;
this._pendingConnectionToken = null;
this.emit('connect', uuid, error);

@@ -446,0 +472,0 @@ this.processConnectionQueue();

+60
-19

@@ -140,2 +140,3 @@ const debug = require('debug')('hci');

this._aclQueue = [];
this._pendingLeConn = null;

@@ -334,2 +335,3 @@ this._deviceId = options.deviceId != null

this._aclQueue = [];
this._pendingLeConn = null;
};

@@ -556,13 +558,13 @@

// https://github.com/bluez/bluez/issues/1178
Hci.prototype.createLeConn = function (address, addressType, parameters = {}, reset = true) {
Hci.prototype.createLeConn = function (address, addressType, parameters = {}, reset = true, attemptToken) {
if (reset) {
this.once('reset', () => this.createLeConnAfterReset(address, addressType, parameters));
this.once('reset', () => this.createLeConnAfterReset(address, addressType, parameters, attemptToken));
this.reset();
}
else {
this.createLeConnAfterReset(address, addressType, parameters);
this.createLeConnAfterReset(address, addressType, parameters, attemptToken);
}
};
Hci.prototype.createLeConnAfterReset = function (address, addressType, parameters = {}) {
Hci.prototype.createLeConnAfterReset = function (address, addressType, parameters = {}, attemptToken) {
const {

@@ -639,2 +641,3 @@ minInterval = 0x0006,

debug(`create le conn - writing: ${cmd.toString('hex')}`);
this._pendingLeConn = { address, addressType, token: attemptToken };
this._socket.write(cmd);

@@ -1142,3 +1145,4 @@ };

}
if (data.every(byte => byte === 0)) {
const allZero = data.every(byte => byte === 0);
if (status === 0 && allZero) {
return;

@@ -1173,4 +1177,14 @@ }

this.emit(
'leConnComplete',
const normalizedAddress = address.replace(/:/g, '').toLowerCase();
const pendingAddress = this._pendingLeConn && this._pendingLeConn.address.replace(/:/g, '').toLowerCase();
const matchesPendingAttempt = Boolean(
this._pendingLeConn &&
(normalizedAddress === pendingAddress || (status !== 0 && allZero))
);
const attemptToken = matchesPendingAttempt ? this._pendingLeConn.token : undefined;
if (matchesPendingAttempt) {
this._pendingLeConn = null;
}
const eventArguments = [
status,

@@ -1185,3 +1199,7 @@ handle,

masterClockAccuracy
);
];
if (attemptToken !== undefined) {
eventArguments.push(undefined, attemptToken);
}
this.emit('leConnComplete', ...eventArguments);
};

@@ -1194,3 +1212,4 @@

}
if (data.every(byte => byte === 0)) {
const allZero = data.every(byte => byte === 0);
if (status === 0 && allZero) {
return;

@@ -1243,4 +1262,15 @@ }

this.emit(
'leConnComplete',
const normalizedAddresses = [address, peerResolvablePrivateAddress]
.map((candidate) => candidate.replace(/:/g, '').toLowerCase());
const pendingAddress = this._pendingLeConn && this._pendingLeConn.address.replace(/:/g, '').toLowerCase();
const matchesPendingAttempt = Boolean(
this._pendingLeConn &&
(normalizedAddresses.includes(pendingAddress) || (status !== 0 && allZero))
);
const attemptToken = matchesPendingAttempt ? this._pendingLeConn.token : undefined;
if (matchesPendingAttempt) {
this._pendingLeConn = null;
}
const eventArguments = [
status,

@@ -1256,3 +1286,7 @@ handle,

peerResolvablePrivateAddress
);
];
if (attemptToken !== undefined) {
eventArguments.push(attemptToken);
}
this.emit('leConnComplete', ...eventArguments);
};

@@ -1409,16 +1443,22 @@

if (status !== 0) {
// No LE Connection Complete follows a failed Command Status, and on a shared raw socket
// this status may not belong to a command this instance issued, so nothing else is known.
this.emit(
'leConnComplete',
const pendingLeConn = this._pendingLeConn;
this._pendingLeConn = null;
// No LE Connection Complete follows a failed Command Status. Carry the
// identity and private token recorded when this instance wrote the command;
// bindings will ignore failures that have no matching local attempt.
const eventArguments = [
status,
undefined,
undefined,
pendingLeConn && pendingLeConn.addressType,
pendingLeConn && pendingLeConn.address,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined
);
];
if (pendingLeConn && pendingLeConn.token !== undefined) {
eventArguments.push(undefined, pendingLeConn.token);
}
this.emit('leConnComplete', ...eventArguments);
}

@@ -1433,2 +1473,3 @@ }

this._aclQueue = [];
this._pendingLeConn = null;
}

@@ -1435,0 +1476,0 @@ this._state = state;

@@ -9,3 +9,3 @@ {

"description": "A Node.js BLE (Bluetooth Low Energy) central library.",
"version": "2.6.2",
"version": "2.6.3",
"repository": {

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display