liamcottle / rustplus.js

Unofficial NodeJS library for controlling Smart Switches in the PC game Rust
224 stars 46 forks source link

Make register without opening new Browser #34

Closed Sumis34 closed 2 years ago

Sumis34 commented 2 years ago

I'm trying to figure out a way to register a client through a web app and the problem there is that the pair.html has to be launched in the browser with the privacy thingy disabled and so doesn't work in the browser of the client. Would be nice if you find a way around this.

liamcottle commented 2 years ago

The only alternative I can think of right now would be to write a Google Chrome Extension which would have read access to the Rust+ login flow URLs so you can read the token and send it to your own API.

Sumis34 commented 2 years ago

What about a custom React Native App to get the token?

liamcottle commented 2 years ago

React Native running as its own standalone browser instance (like the pair script does) with security options disabled would work, my Atlas for Rust project can get all of the necessary tokens since it has full control of its own browser through Electron. However, just adding a react native app on top of a normal browser wouldn't help at all since it's still limited to what it can access due to the browser sandbox and CORS.

You need to be able to get the Rust+ auth token, Expo push token and register with FCM, which requires you to be running outside of a normal browser's sandbox restrictions since those services aren't intended for accessing publicly through a browser.

I've seen other projects use a Google Chrome extension which can intercept the Rust+ auth token in the browser by injecting javascript into the authentication page, but you'd still need to be able to register for FCM notifications which can't be done in a standard web browser.

You could of course implement your own server APIs which act as a proxy to all those services, and allow your javascript to access those through CORS.