node-minecraft-protocol icon indicating copy to clipboard operation
node-minecraft-protocol copied to clipboard

Support browser environments

Open Electroid opened this issue 3 years ago • 2 comments

Is your feature request related to a problem? Please describe. It would be great to use this library in "browser-compatible" environments: Chrome, Cloudflare Workers, or Deno. This would open up this library to be used by a wider variety of platforms.

Describe the solution you'd like At runtime, the library would check if its in a Node environment; otherwise, it would use polyfills or browser native APIs like WebCrypto or fetch.

Additional context Any TCP-related code would use the Raw Sockets API which is already implemented on Chrome and will soon be added to other platforms.

Electroid avatar Dec 16 '20 18:12 Electroid

hi, browser environment are already supported with the connect option of createClient which allows users to provide their own sockets. bundlers like browserify and webpack already allows replacing node APIs by browser shims I guess it would be useful to add an example to demo it though

This has been used in a few projects but without much success as until now the only way for this to be useful was to use websocket. What versions of chrome has this raw sockets API? is it enabled by default? what about security ?

rom1504 avatar Dec 16 '20 20:12 rom1504

It seems to be in development for chrome and not really near to reach a consensus with other browsers https://www.chromestatus.com/feature/6398297361088512

It raises a lot of security concerns, I wonder if and how they'll standardize it. Definitely something interesting to follow.

Karang avatar Dec 16 '20 21:12 Karang