Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
node-beacon-scanner
Advanced tools
The node-beacon-scanner is a Node.js module which allows you to scan BLE beacon packets and parse the packet data. This module supports iBeacon, Eddystone, and Estimote.
The node-beacon-scanner is a Node.js module which allows you to scan BLE beacon packets and parse the packet data. This module supports iBeacon, Eddystone, and Estimote.
The supported beacon data formats are as follows:
See the document of the @abandonware/noble for details on installing the @abandonware/noble.
Note that the noble has to be run as root on most of Linux environments. See the the document of the @abandonware/noble for details.
The early versions of this module depended on noble for BLE handling. But the noble seems not to support Node v10 or later versions. Now, this module is employing @abandonware/noble, which was forked from noble. For the purouse of the backward compatibility, this module works with noble on Node v8 or earlier versions.
$ cd ~
$ npm install @abandonware/noble
$ npm install node-beacon-scanner
This sample code shows how to start scanning and how to get parsed packets.
const BeaconScanner = require('node-beacon-scanner');
const scanner = new BeaconScanner();
// Set an Event handler for becons
scanner.onadvertisement = (ad) => {
console.log(JSON.stringify(ad, null, ' '));
};
// Start scanning
scanner.startScan().then(() => {
console.log('Started to scan.') ;
}).catch((error) => {
console.error(error);
});
The sample code above will output the result as follows:
Started to scan.
{
"id": "c7dfbfd9f64a",
"address": "c7:df:bf:d9:f6:4a",
"localName": null,
"txPowerLevel": null,
"rssi": -59,
"beaconType": "iBeacon",
"iBeacon": {
"uuid": "B9407F30-F5F8-466E-AFF9-25556B57FE6D",
"major": 21983,
"minor": 57807,
"txPower": 180
}
}
...
BeaconScanner
objectIn order to use the node-beacon-scanner, you have to load the node-beacon-scanner module as follows:
const BeaconScanner = require('node-beacon-scanner');
You can get an BeaconScanner
constructor from the code above. Then you have to create an BeaconScanner
object from the BeaconScanner
constructor as follows:
const scanner = new BeaconScanner();
The BeaconScanner
constructor takes an argument optionally. It must be a hash object containing the properties as follows:
Property | Type | Required | Description |
---|---|---|---|
noble | Noble | option | a Noble object of the noble module |
The node-beacon-scanner module uses the noble
module in order to scan the beacons coming from the BLE beacon device(s). If you want to interact other BLE devices using the noble module, you can create an Noble
object by yourself, then pass it to this module. If you don't specify a Noble
object to the noble
property, this module automatically create a Noble
object internally.
The sample code below shows how to pass a Nobel
object to the Linking
constructor.
// Create a Noble object
const noble = require('noble');
// Create a Linking object
const BeaconScanner = require('node-beacon-scanner');
const scanner = new BeaconScanner({'noble': noble});
In the code snippet above, the variable scanner
is a BeaconScanner
object. The BeaconScanner
object has methods as described in sections below.
The startScan()
method starts to scan advertising packets from BLE beacon devices. This method returns a Promise
object.
Whenever a packet is received, the callback function set to the onadvertisement
property of the BeaconScanner
object will be called. When a packet is received, an BeaconScannerAdvertisement
object will be passed to the callback function.
// Set an Event handler for becons
scanner.onadvertisement = (ad) => {
console.log(JSON.stringify(ad, null, ' '));
};
// Start scanning
scanner.startScan().then(() => {
console.log('Started to scan.') ;
}).catch((error) => {
console.error(error);
});
The stopScan()
method stops to scan advertising packets from BLE beacon devices. See the section "startScan()
method" for details.
onadvertisement
event handlerIf a callback function is set to the onadvertisement
property, the callback function will be called whenever an advertising packet is received from a BLE beacon device during the scan is active (from the moment when the startScan()
method is called, to the moment when the stopScan()
method is called).
See the section "startScan()
method" for details.
BeaconScannerAdvertisement
objectThe BeaconScannerAdvertisement
object represents an advertising data coming from the BLE beacon device. This object is just a hash object containing properties as follows. Note that the structure varies depending on the format of the beacon. You can know the format of the beacon from the value of the beaconType
property.
{
"id": "c7dfbfd9f64a",
"address": "c7:df:bf:d9:f6:4a",
"localName": null,
"txPowerLevel": null,
"rssi": -59,
"beaconType": "iBeacon",
"iBeacon": {
"uuid": "B9407F30-F5F8-466E-AFF9-25556B57FE6D",
"major": 21983,
"minor": 57807,
"txPower": 180
}
}
The value of the iBeacon
property contains the properties as follows:
Property | Type | Description |
---|---|---|
uuid | String | Proximity UUID |
major | Number | Major |
minor | Number | Minor |
txPower | Number | Measured Power (dBm) |
{
"id": "c6debed8f549",
"address": "c6:de:be:d8:f5:49",
"localName": null,
"txPowerLevel": null,
"rssi": -59,
"beaconType": "eddystoneUid",
"eddystoneUid": {
"txPower": -35,
"namespace": "EDD1EBEAC04E5DEFA017",
"instance": "2D3EA3203B6B"
}
}
The value of the eddystoneUid
property contains the properties as follows:
Property | Type | Description |
---|---|---|
namespace | String | Namespace ID |
instance | String | Instance ID |
txPower | Number | Calibrated Tx power (dBm) |
{
"id": "c6debed8f549",
"address": "c6:de:be:d8:f5:49",
"localName": null,
"txPowerLevel": null,
"rssi": -59,
"beaconType": "eddystoneUrl",
"eddystoneUrl": {
"txPower": -35,
"url": "http://go.esti.be/"
}
}
The value of the eddystoneUrl
property contains the properties as follows:
Property | Type | Description |
---|---|---|
url | String | Decoded URL |
txPower | Number | Calibrated Tx power (dBm) |
{
"id": "c6debed8f549",
"address": "c6:de:be:d8:f5:49",
"localName": null,
"txPowerLevel": null,
"rssi": -59,
"beaconType": "eddystoneTlm",
"eddystoneTlm": {
"batteryVoltage": 6059,
"temperature": 28.59765625,
"advCnt": 83,
"secCnt": 361299
}
}
The value of the eddystoneTlm
property contains the properties as follows:
Property | Type | Description |
---|---|---|
batteryVoltage | Number | Battery voltage (mV) |
temperature | Number | Beacon temperature (°C) |
advCnt | Number | Advertising PDU count |
secCnt | Number | Time since power-on or reboot |
{
"id": "d9d9fe86fb61",
"address": "d9:d9:fe:86:fb:61",
"localName": null,
"txPowerLevel": null,
"rssi": -59,
"beaconType": "eddystoneEid",
"eddystoneEid": {
"txPower": -35,
"eid": "79c58b83f198ddbe"
}
}
The value of the eddystoneEid
property contains the properties as follows:
Property | Type | Description |
---|---|---|
eid | String | Ephemeral Identifier |
txPower | Number | Calibrated Tx power (dBm) |
There are two types in the Estimote Telemetry beacon data: Type A
and Type B
. The types can be obtained checking the value of the subFrameType
property. If the type is A
, the value is 0
. If the type is B
, the value is 1
.
Type A
{
"id": "c9e1c1dbf84c",
"address": "c9:e1:c1:db:f8:4c",
"localName": null,
"txPowerLevel": null,
"rssi": -59,
"beaconType": "estimoteTelemetry",
"estimoteTelemetry": {
"frameType": 2,
"subFrameType": 0,
"protocolVersion": 2,
"shortIdentifier": "2d3ea3203b6b2446",
"acceleration": {
"x": -0.015748031496062992,
"y": -0.07874015748031496,
"z": 0.9921259842519685
},
"moving": false,
"gpio": {
"pin0": "low",
"pin1": "low",
"pin2": "high",
"pin3": "high"
},
"errors": {
"firmware": false,
"clock": false
},
"pressure": 100304.9765625
}
}
Type B
{
"id": "c9e1c1dbf84c",
"address": "c9:e1:c1:db:f8:4c",
"localName": null,
"txPowerLevel": null,
"rssi": -59,
"beaconType": "estimoteTelemetry",
"estimoteTelemetry": {
"frameType": 2,
"subFrameType": 1,
"protocolVersion": 2,
"shortIdentifier": "2d3ea3203b6b2446",
"magneticField": {
"x": 0,
"y": 0,
"z": 0
},
"light": 80.64,
"uptime": {
"unitCode": 1,
"unitDesc": "minutes",
"value": 596
},
"temperature": 28.75,
"batteryVoltage": 6059,
"batteryLevel": 95
}
}
{
"id": "f8d3c05e8001",
"address": "f8:d3:c0:5e:80:01",
"localName": null,
"txPowerLevel": null,
"rssi": -59,
"beaconType": "estimoteNearable",
"estimoteNearable": {
"nearableId": "bd20de5cd074de8d",
"temperature": 25.75,
"moving": false,
"acceleration": {
"x": -15.625,
"y": -78.125,
"z": -1031.25
}
}
}
The value of the estimoteNearable
property contains the properties as follows:
Property | Type | Description | |
---|---|---|---|
nearableId | String | Nearable identifier | |
temperature | Number | Temperature (°C) | |
moving | Boolean | Moving state (true: moving) | |
acceleration | Object | Acceleration | |
-- | x | Number | Acceleration on the X axis (milli G) |
-- | y | Number | Acceleration on the Y axis (milli G) |
-- | z | Number | Acceleration on the Z axis (milli G) |
txPower
of iBeacon was wrong. (Thanks to @girtgirt)BeaconScannerAdvertisement
object for Eddystone (namespece
-> namespace
). (Thanks to @natcl)The MIT License (MIT)
Copyright (c) 2017-2019 Futomi Hatano
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
FAQs
The node-beacon-scanner is a Node.js module which allows you to scan BLE beacon packets and parse the packet data. This module supports iBeacon, Eddystone, and Estimote.
We found that node-beacon-scanner demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.