Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mozTCPSocket API #290

Open
TheW0LVERIN3 opened this issue Feb 5, 2024 · 2 comments
Open

mozTCPSocket API #290

TheW0LVERIN3 opened this issue Feb 5, 2024 · 2 comments

Comments

@TheW0LVERIN3
Copy link

TheW0LVERIN3 commented Feb 5, 2024

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
Copy link
Author

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

@hensm
Copy link
Owner

hensm commented Feb 5, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants