Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
web-bluetooth
Advanced tools
Library for interacting with Bluetooth devices through the browser. Currently in Alpha.
Previously, interacting with Bluetooth devices was limited to native applications. Access to connect, read, and write from Bluetooth devices is now made available to web applications thanks to the Web Bluetooth API and modern web browsers like Chrome and Firefox, Opera who are incresingly adding support for new features in the Web Bluetooth API Spec.
Web-bluetooth is a configurable application framework for integrating bluetooth functionality with client-side Javascript.
Web-Bluetooth (currently v1.0.0) has a few easy ways to quickly get started, each one appealing to your preferences.
You can install web-bluetooth by downloading our minified library here
Make the library available by referencing it in your index.html file.
<script>/lib/web-bluetooth.js</script>
You can install web-bluetooth with npm
Require('web-bluetooth') will load all of the files necessary to run our library.
$ npm install web-bluetooth
While the Web Bluetooth API is still in development, features have been made available. This library has made available several important features to develop web applications using Bluetooth connections.
Note: The Web Bluetooth API is still in development and many features have not been implemented across browsers. For the current status of the API, please follow this link.
Feature | ChromeOS | Android Mobile | MacOSX |
---|---|---|---|
Device Discovery | ✓ | ✓ | ✓ |
Device Connecting | ✓ | ✓ | ✓ |
Device Disconnecting | ✓ | ✓ | ✓ |
Device Services Read | ✓ | ✓ |
Services are collections of characteristics and relationships to other services that encapsulate the behavior of part of a device. For example, the “Battery Service” exposes the Battery Level of a device broadcasting the “Battery Service” service.
This library abstracts over core GATT Service types with special attention to service types that are common and that are most applicable in this current stage of Bluetooth device availability.
For the full list of normative Services click here. As the Web Bluetooth API continues to be developed and as this library matures, more service types will be made available.
Service | Supported | Spec Type | Assigned Number |
---|---|---|---|
Alert Notification | 'alert-notification' | 0x1811 | |
Battery Service | ✓ | 'battery_service' | 0x180F |
Blood Pressure | 'blood_pressure' | 0x1810 | |
Cycling Power | 'cycling_power' | 0x1818 | |
Cycling Speed and Cadence | 'cycling_speed_and_cadence' | 0x1816 | |
Device Info | ✓ | 'device_information' | 0x180A |
Generic Access | ✓ | 'generic_access' | 0x1800 |
Generic Attribute | ✓ | 'generic_attribute' | 0x1801 |
Health Thermometer | 'health-thermometer' | 0x1809 | |
Heart Rate | ✓ | 'health-heart_rate' | 0x180D |
Running Speed and Cadence | 'running_speed_and_cadence' | 0x1814 | |
Tx Power | ✓ | 'tx_power' | 0x1804 |
Before calling methods on your Bluetooth device, create a new Bluetooth device object.
var fitbit = new Device({
namePrefix: 'Surge'
services: ['battery_service']
});
In the example above, we have created a new Bluetooth device object titled 'blue' by requesting the object with it's 'namePrefix' and a service of 'battery service'. Device is a constructor that takes in an object corresponding to attributes on the bluetooth device. Below is a schema for what can be used to connect to a device. At least one option is needed to request a device.
{
name: 'device_name',
namePrefix: 'devicePrefix',
uuid: 'uuid',
service: 'service'
}
'name':
is the name (hardware) of the device
'namePrefix':
looks for a name starting with namePrefix
'services':
represents a 128-bit UUID. A valid UUID is a string that matches the regexp '/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/'
'uuid':
collection of characteristics and the relationships to other services encapsulate the behavior of part of a device
Method allows you to establish a persistent connection with a Bluetooth device.
fitbit.connect(connectedDevice,(server) => {
connectedDevice = device;
};
Method disconnects you from the device.
fitbit.disconnect();
Method reads the value from the device you are connected to by passing in the characteristic as a string.
fitbit
.getValue('battery_level')
.then(value => {
console.log(value);
});
In the above example, .getValue() returns the current battery level as a percentage from 0% to 100%; 0% represents a battery that is fully discharged, 100% represents a battery that is fully charged.
This demo uses the Web-Bluetooth library to connect to a device broadcasting a Battery Service characteristic and reads it's level.
View the demo. | Visit the GitHub page.
Notes: • Requires Android 6.0 Marshmallow, ChromeOS or Chrome for Linux. • Enable the 'Web Bluetooth' flag.
Sabertooth is a team of four software developers enthusiastic to be contributing to the open source community. Visit their GitHub page for more information.
FAQs
Library for interacting with Bluetooth 4.0 devices through the browser.
We found that web-bluetooth 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
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.