js-libp2p icon indicating copy to clipboard operation
js-libp2p copied to clipboard

WebBluetooth

Open daviddias opened this issue 7 years ago • 5 comments

WebBluetooth now works in the Browser! *1, *2, *3

https://developers.google.com/web/updates/2018/10/nic70

*1 Only on Chrome *2 Only on Windows *3 It is a great start \o/

daviddias avatar Oct 18 '18 14:10 daviddias

I think it works on macOS and Linux (tested chrome + linux a week ago and was working).

Implementing this will be tricky though. It requires the user to interact with the page (onClick event triggered or similar) before device selection can happen and the user has to explicitly select device. I think we could probably make it work anyway by providing some was of triggering bluetooth-discovery from the developers side though.

victorb avatar Oct 18 '18 14:10 victorb

User Gesture Required

As a security feature, discovering Bluetooth devices with navigator.bluetooth.requestDevice must be triggered by a user gesture such as a touch or a mouse click. We're talking about listening to pointerup, click, and touchend events. – https://developers.google.com/web/updates/2015/07/interact-with-ble-devices-on-the-web#user_gesture_required

In the future UX could be much better: in WebExtension context the above requirement could be replaced by a "bluetooth" permission added to the manifest of IPFS Companion :trollface:

This is potentially huge: gives us alternative Local Discovery and Transport that do not depend on existence of any local network.

lidel avatar Oct 18 '18 17:10 lidel

  • design decisions: https://github.com/WebBluetoothCG/web-bluetooth/blob/master/rationale.md
  • demos and code samples: https://googlechrome.github.io/samples/web-bluetooth/index.html

lidel avatar Aug 29 '19 11:08 lidel

@lidel, did you have the opportunity to check libp2p/notes#6#issuecomment-458975204?

vasco-santos avatar Aug 29 '19 12:08 vasco-santos

Any update on this?

holmesworcester avatar Jul 21 '21 05:07 holmesworcester

In https://github.com/WebBluetoothCG/web-bluetooth/blob/main/rationale.md

The key/value structure of GATT is believed to reduce the risk of device exploits compared to the unstructured byte-stream of other protocols. When the Characteristic Aggregate Format and Characteristic Presentation Format Descriptors are provided for a Characteristic, the UA can further validate any data passed to the device

If one is to do a libp2p connection around this, one needs to write a wrapper around GATT so that it behaves like a byte stream anyway? I would be surprised to see good throughput coming from that. However, not all applications require huge throughput. Simple messaging would be great for this

@lidel, did you have the opportunity to check https://github.com/libp2p/notes/issues/6#issuecomment-458975204?

Web NFC seems much more suitable

marcus-pousette avatar Jan 19 '23 14:01 marcus-pousette

I was really hoping to connect two phones directly to each other using Web Bluetooth, but, AFAIK, this is not actually possible with Web Bluetooth as one can only connect to 'GATT Servers', but not actually have the web app create such a GATT Server itself. So yes you can connect to a heartrate-monitor and read some interesting data, but it cannot be used to create a server on one device and then connect to it from another device.

Maybe if we explain our use case to Google they would consider adding support for creating a GATT server but I am not holding my breath.

Download avatar Feb 09 '24 17:02 Download