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

[Request] Allow "null" origin #192

Closed
TrixterTheTux opened this issue Jun 7, 2018 · 9 comments
Closed

[Request] Allow "null" origin #192

TrixterTheTux opened this issue Jun 7, 2018 · 9 comments

Comments

@TrixterTheTux
Copy link

TrixterTheTux commented Jun 7, 2018

Hi,

After the change not allowing to use HTTP API for setting activity (#191 (comment)), some games have been limited in terms of implementing Rich Presence. For example, Garry's Mod doesn't have any type of websocket/ipc implementation other than using awesomium/chromium to create websocket connections, but this causes a new issue. The origin is set to "null" due to not being in any actual page, not allowing to be connected to the RPC server.

Would there be a chance that the origin "null" (or invalid urls altogether, as chromium sets it to asset://html) could be ignored? It shouldn't break anything as far as I'm aware as it not being an actual url anyways. The only way I've found to avoid this is by setting the RPC Origin which is "documentated" here https://discordapp.com/developers/docs/topics/rpc#connecting, but there's no actual option to set it in the app's settings (and I doubt non-urls would even be allowed?)

@msciotti
Copy link
Collaborator

msciotti commented Jun 7, 2018

I will take another point against me here and inform you that we can't currently support this.

A WebSocket connection is allowed if there's no origin header. It's a special case that tells us that a local app is trying to connect, and not a random website.

Because of that security piece in RPC, any origin header other than no origin triggers the auth check.

The documentation you linked is correct, but authenticated RPC access is currently a closed program, as noted by the red warning at the top of the page. So you can't set a valid RPC origin in your app settings.

(As a side note, yeah, non-urls aren't allowed)

@msciotti msciotti closed this as completed Jun 7, 2018
@msciotti
Copy link
Collaborator

msciotti commented Jun 7, 2018

Related, I know Garry's Mod does support lua scripting, right? Is there a way within that framework to open a no-origin socket connection?

@Tenrys
Copy link

Tenrys commented Jun 7, 2018

There is no way to do that without using a custom made .dll which people have to place manually in their game's files, so not really intuitive. The closest you can get to a websocket connection using just the game's API is trying to do it through Awesomium / Chromium in JavaScript, as said in the original post.

@TrixterTheTux
Copy link
Author

TrixterTheTux commented Jun 7, 2018

Yes, it has lua scripting. Nope, the native way is only by using the http lib it provides. A hacky workaround is to use awesomium (which is getting replaced by chromium in the future), but awesomium sets the origin to "null" and after today's testing on the WIP chromium branch, chromium sets it to "asset://html". So unfortunately, there is no other way to go around this, and due to the RPC origin being restricted to valid urls, there won't be any integration with rich presence at all.

This is the reason why I was asking for a way to maybe avoid the auth check.
Even when RPC comes out of beta, there will be no way to implement this without making a module for clients to install like Tenrys said above.

@msciotti
Copy link
Collaborator

msciotti commented Jun 7, 2018

Thank you very much for the specific information!

@TrixterTheTux
Copy link
Author

TrixterTheTux commented Jun 8, 2018

Do you think there would be any chance that Garry's Mod could get some type of "shared" dev application with RPC origin's "hardcoded" to "null" and "asset://html" so that communities could use it? I understand that you mostly want it to be used for the "Ask to join" and similar features, but the Garry's Mod devs are currently focused on chromium and bug fixes, so it's unlikely to get these features into the game itself. Most communities also go around the joining their server button by having short urls like "join.domain.tld" in details that redirect you to steam://join//serverip making it easy to know how to join your friend.

@TrixterTheTux
Copy link
Author

@msciotti - bumping as I think you missed the above question.

@msciotti
Copy link
Collaborator

The caveat with RPC access is that it's a full RPC access—including all commands/events. While I know everyone here's reaction to that is "Even better!" haha, it's not something we want to get into right now. Having a shared RPC application also seems like more of a hacky workaround for one game than a better overall solution.

When you say hardcoded to null, do you mean the string "null"?

@TrixterTheTux
Copy link
Author

Yes, the origin header is set to a string "null" (or "asset://html" for people using the wip chromium branch) This causes the issue that no one can implement any RPC features when it gets out of beta due to not being a valid url.

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

3 participants