fx_cast icon indicating copy to clipboard operation
fx_cast copied to clipboard

mozTCPSocket API

Open TheW0LVERIN3 opened this issue 1 year ago • 2 comments

There seems to be a mozTCPSocket API in firefox. It seems to have been created originally for firefox os and is now also still used by kaios. But the api seems to actually be available in regular firefox. While it's an old and not very documented api, kaios's reliance on it probably means it'll stick around. Kaios also seems to have a udp variant of the api, but that one might be kaios only. I believe it's worth trying out to see if it works/can be used. Some old addon that used/enabled? it: https://github.com/mykmelez/tcpsocketpup Kaios's docs: https://kaios.dev/2023/02/advanced-kaios-development-cors-tcp-sockets-and-lets-encrypt-ssl-certificates/#tcpsocket-api https://developer.kaiostech.com/docs/sfp-3.0/api/next-new-apis/navigator/mozTCPSocket/navigator-mozTCPSocket/ https://developer.kaiostech.com/docs/sfp-3.0/api/next-new-apis/navigator/mozTCPSocket/tcpSocket/ https://developer.kaiostech.com/docs/sfp-3.0/api/next-new-apis/navigator/mozTCPSocket/tcpSocketAPI/ Some random old/outdated mozilla docs I found in search results: https://developer.mozilla.org.cach3.com/en-US/docs/Web/API/Navigator/mozTCPSocket http://man.hubwiz.com/docset/JavaScript.docset/Contents/Resources/Documents/developer.mozilla.org/en-US/docs/Mozilla/Firefox_OS/API/TCPSocket.html https://frost.cs.uchicago.edu/ref/JavaScript/developer.mozilla.org/en-US/docs/Archive/B2G_OS/API/Navigator/mozTCPSocket.html http://man.hubwiz.com/docset/JavaScript.docset/Contents/Resources/Documents/developer.mozilla.org/en-US/docs/Mozilla/Firefox_OS/API/TPC_Socket_API.html https://web.archive.org/web/20210122031827/https://developer.mozilla.org/en-US/docs/Archive/B2G_OS/API/TCPSocket https://web.archive.org/web/20210528092453/https://developer.mozilla.org/en-US/docs/Archive/B2G_OS/API/UDPSocket

I'm not an expert so it's of course possible that the api doesn't or never did work with regular firefox, but it's definitely worth testing to see if it works. If, in the future this extension no longer needs the native messaging api it could work on firefox android(, and maybe even european ios if mozilla ports gecko after the new regulations).

On another note, it seems firefox android has some kind of native messaging api but it might not work/need a custom firefox android build or something, not sure. The documentation isn't the easiest to figure out: https://firefox-source-docs.mozilla.org/mobile/android/geckoview/consumer/web-extensions.html#communicating-with-web-content

TheW0LVERIN3 avatar Feb 05 '24 15:02 TheW0LVERIN3

I also found this which seem to provide some way of using multicast: https://searchfox.org/mozilla-central/source/dom/webidl/UDPSocket.webidl

TheW0LVERIN3 avatar Feb 05 '24 16:02 TheW0LVERIN3

Those legacy APIs aren't exposed to web content or web extensions as far as I know. Even if they could be made to work, I don't know whether I'd want to build on top of something that's unsupported (in Firefox at least).

I haven't looked at how WebExtension support on Android is coming along lately, but it may be possible to run on Android already with the WebSocket bridge connection to a remote device on the network.

The GeckoView native messaging is best I can tell for communicating between app code and extension code inside a web view component and not something that can be done between extensions in Firefox and other apps. It's not remotely on my radar at the moment, but proper Android support would likely involve writing an Android app that uses the WebSocket bridge connection instead of the native messaging connection and does native device discovery with NSD.

hensm avatar Feb 05 '24 22:02 hensm