Understand the role of Web Bluetooth API for passkeys! Learn how Bluetooth availability detection enhances Cross-Device Authentication (CDA) with WebAuthn.
Vincent
Created: June 25, 2024
Updated: September 3, 2024
Our mission is to make the Internet a safer place, and the new login standard passkeys provides a superior solution to achieve that. That's why we want to help you understand passkeys and its characteristics better.
2.2 getDevices()
2.3 requestDevice()
8.1 Passkey Core Feature: Cross-Device Authentication (CDA) via QR Codes & Bluetooth
8.2 Bluetooth is Not Always Present and Can Be Bad for CDA UX
8.3 Different Impact of Bluetooth Non-Availability in Firefox and Safari
Passkeys are the new login standard in the web. One of passkey’s core features is Cross-Device Authentication (CDA) via Bluetooth and QR Codes. In this context, another web API becomes important: the Web Bluetooth API.
By enabling web apps to interact directly with Bluetooth devices, the Web Bluetooth API plays a crucial role in ensuring secure and efficient authentication processes (especially for CDA).
This blog post will present the workings of the Web Bluetooth API and explore the implications of Bluetooth detection for passkey authentication. We want to answer the following questions:
The Web Bluetooth API is a JavaScript interface that allows web apps to access and communicate with Bluetooth devices. It is part of the HTML5 standard and is supported by browsers like Chrome, Edge, and Opera. This API enables web apps to
There are three key functions of the Web Bluetooth API.
getAvailability()
returns a promise that resolves to a Boolean indicating whether the user agent can support Bluetooth (so the device has a Bluetooth module). Some user agents let the user configure an option that specifies what value is returned by this method.
Subscribe to our Passkeys Substack for the latest news, insights and strategies.
SubscribegetDevices()
returns a promise that resolves to an array of BluetoothDevices
the origin is allowed to access (including those that are out of range and powered off). Permission is obtained via previous calls to Bluetooth.requestDevice()
.
requestDevice()
returns a promise to a BluetoothDevice
object with specified options. If there is no chooser UI, this method returns the first device matching the criteria.
Details and code snippets can be found here. Also find here the W3C standard for Web Bluetooth.
Become part of our Passkeys Community for updates and support.
Joinnavigator.bluetooth.requestDevice
must be triggered by a user gesture, such as a touch or mouse click, for security reasons.To check for the support of the Web Bluetooth API, you can do so via the following code:
How the specific functions are called is explained above.
The Web Bluetooth API offers several advantages for developers and users:
Despite its benefits, the Web Bluetooth API has limitations:
getAvailability()
to return false even if a Bluetooth adapter is present. This is controlled via the Permissions-Policy:Bluetooth
. Similarly, even if getAvailability()
returns true, the Bluetooth adapter may not be powered on, or users may deny permission to use the API when prompted.Adoption of the Web Bluetooth API is still growing. As of June 2024, according to Can I Use, 76.53% of global users have devices with support for Web Bluetooth API.
However, the lack of support in Safari and Firefox remains a significant hurdle, impacting user experience on those browsers. Also, some of the features (e.g. Bluetooth.getDevices()
) must be explicitly turned on by the user, which can be a challenge for using the API in the background.
Find the latest data on: https://developer.mozilla.org/en-US/docs/Web/API/Web_Bluetooth_API#browser_compatibility
There is one major reason why relying parties should know about the availability of Bluetooth, when they want to offer passkeys in their websites and applications.
One of the new, innovative features of passkeys is Cross-Device Authentication (CDA) – also known as hybrid authentication. This feature allows users to authenticate on one device (typically a desktop or laptop) using their mobile devices via QR codes and Bluetooth. This hybrid authentication method enhances security and convenience, providing a seamless user experience. Most non-technical users are nowadays accustomed to scanning QR codes, whether during the COVID pandemic for registration or via mobile-first messaging apps that later added desktop support (e.g., WhatsApp or Telegram).
Deciding on a CDA strategy is crucial at the beginning of any passkey project. The more you rely on CDA, the better the support and reliability of it needs to be. Thus, detecting Bluetooth availability on a device is essential.
However, not all devices have Bluetooth capabilities or may have Bluetooth turned off. For relying parties who offer passkeys, it's essential to detect Bluetooth availability to determine whether CDA can be used or if another fallback authentication method is necessary. The Web Bluetooth API provides a solution by enabling web apps to check Bluetooth availability on user devices.
Please bear in mind that CDA is not always stable, occasionally failing to connect without clear reasons. Moreover, due to the novelty of the API, sometimes wrong results are returned by the API.
The non-availability of Web Bluetooth API in Firefox and Safari is an issue, particularly for Firefox.
Safari is less of an issue because macOS devices, where CDA might be performed, have had built-in Bluetooth since early models. Additionally, iPhones running Safari have had Bluetooth built-in since their inception.
Though, Firefox is a significant issue as it is popular on Windows devices. If a user is on Firefox and wants to use CDA, the relying party cannot reliably determine if Bluetooth is available, as the Web Bluetooth API is not implemented. This might result in a poor user experience, with users potentially getting stuck at certain points without knowing what to do.
As we have seen, also in previous blogs, Windows devices are lagging behind in terms of passkey adoption (see State of Passkeys as well). Let’s take a look how common Bluetooth availability is.
Windows 10 does not have a strict Bluetooth requirement, but most modern laptops and desktops come with Bluetooth capabilities. However, the user might have it turned off, or it may not be available in some configurations, especially on custom-built desktops.
Windows 11, similar to Windows 10, does not mandate Bluetooth. However, the trend towards more integrated and modern hardware means that most Windows 11 compatible devices will likely have Bluetooth capabilities. Still, users can disable it, affecting CDA implementations.
In the following table you can see whether you can determine if a desktop device is Bluetooth-ready and thus can be used as a CDA client:
Operating system | Bluetooth Hardware-Support | Browser Bluetooth detection | |||
---|---|---|---|---|---|
Chrome | Edge | Firefox | Safari | ||
Windows 10 | low | ✅ | ✅ | ❌ | ❌ |
Windows 11 | medium | ✅ | ✅ | ❌ | ❌ |
macOS | high | ✅ | ❌ | ❌ | ❌ |
Keep in mind that even if your hardware is Bluetooth-ready, Bluetooth functionality might be turned off by the user. When Bluetooth is turned off, the user can still use CDA because the user can still opt-in to activate it, which works for Windows and Mac: macOS request to turn on Bluetooth
Windows 11 request to turn on Bluetooth
The Bluetooth availability information is especially interesting on Windows 10 and Windows 11, where Blueooth support is lower and there is a very high probability cross-device authentication will need to happen (in a passkey-based login). Recent macOS devices all have support for Bluetooth. These macOS devices have potentially also access to passkeys stored in the iCloud Keychains directly, so they are not of concern.
On Windows 10 and Windows 11: Use getAvailability()
to find out if Bluetooth can work. In case the user has only non-Windows passkeys, you can immediately fall back to other authentication options.
In a situation where there are only hybrid passkeys available, triggering passkey authentication will not lead to a successful authentication, but rather a dead-end for the user. For all other browsers on Windows 10 and Windows 11, unfortunately, there is no other way to find out if there is support für CDA.
The Web Bluetooth API represents a powerful tool for enhancing passkey authentication through Bluetooth capabilities. By understanding and leveraging this API, developers can create more secure and user-friendly authentication methods. However, they must also navigate its limitations and ensure robust fallback mechanisms to maintain a seamless user experience across different browsers and devices.
With this blog post, we have given an answer of the three core questions:
getAvailability()
, getDevices()
and requestDevice()
to check Bluetooth support, list accessible devices, and request device pairing.For more information regarding Web Bluetooth API and a collection of examples, please click here.
Table of Contents
Enjoyed this read?
🤝 Join our Passkeys Community
Share passkeys implementation tips and get support to free the world from passwords.
🚀 Subscribe to Substack
Get the latest news, strategies, and insights about passkeys sent straight to your inbox.
We provide UI components, SDKs and guides to help you add passkeys to your app in <1 hour
Start for free