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

Improve SDK use with guest accounts #998

Open
evilham opened this issue Jul 22, 2019 · 5 comments
Open

Improve SDK use with guest accounts #998

evilham opened this issue Jul 22, 2019 · 5 comments

Comments

@evilham
Copy link

evilham commented Jul 22, 2019

I was testing the sdk to do something silly with guest accounts but the client won't sync due to trying to query /_matrix/client/r0/pushrules/, which returns:

{"errcode":"M_GUEST_ACCESS_FORBIDDEN","error":"Guest access not allowed"}

Does this mean the SDK can't be used for guest accounts? is it a bug?
FWIW, I'd create a PR and add an example for #430

In a nutshell the way I am using the SDK is:

  • client = matrixcs.createClient(opts)
  • If necessary:
    • client.registerGuest()
    • client = matrixcs.createClient(opts)
  • client.startClient()
@jryans
Copy link
Collaborator

jryans commented Jul 24, 2019

Looking at the spec, the push rules API is not available to guest accounts.

The way you're creating a guest account looks reasonable. See here how it's done by React SDK.

Does it entirely block sync from proceeding?

@evilham
Copy link
Author

evilham commented Jul 24, 2019

Does it entirely block sync from proceeding?

Yes, it does. Furthermore, if I patch the SDK and trick it into not fetching push rules, it does the same for filters, and my attempts at tricking the SDK into not doing that failed utterly.

The exact error for endpoint https://${BASE_URL}/_matrix/client/r0/user/${MX_ID}/filter
{"errcode":"M_GUEST_ACCESS_FORBIDDEN","error":"Guest access not allowed"}

Which means: the js-SDK can't be used for guest accounts, at least not like this and I don't see any other way from the documentation.

I modified the VOIP example a bit (See: browserTest.js.txt ), minor changes mostly, the interesting bits related to guests are lines 38 to 58; I did some light refactoring of the rest to depend less on global vars, but that's mostly the same example from this repository.

@jryans
Copy link
Collaborator

jryans commented Jul 24, 2019

Maybe the difference is that Riot doesn't actually call startClient for guest accounts? (At least, I think that's what is happening...)

It does seem like the behaviour of guest accounts in the JS SDK could be cleaned up and improved so this is less confusing.

@evilham evilham changed the title Use with guest accounts not possible? Improve SDK use with guest accounts Jul 24, 2019
@evilham
Copy link
Author

evilham commented Jul 24, 2019

Alright, your pointer that riot doesn't use startClient for guest accounts led me to make some progress; I've renamed the issue so it ends up being more useful.

So, clients can't currently use startClient, but after creating them it's already possible to do things like join rooms and synchronise state of rooms.
Note here: this line seems to imply that no pushRules are to be loaded for guests, yet it happens:

if (client.isGuest()) {

However: I see that the function checkTurnServers in client.js is the one that does the heavy lifting for the TURN settings, it's probably a bug that it's not exported to matrixcs. Everything that is exposed through the SDK at this point relies on client._turnServers being set and... Well, that doesn't happen without checkTurnServers.

If I duplicate that function in my code and call it, I am able to initiate a call and the SDK client sees the TURN servers, but the client is not processing any further events from the server so it doesn't result in a working call.

Which leads me to: am I missing something? or is there nothing in the API that allows me to keep polling the state of a room?

@adipascu
Copy link

adipascu commented Mar 13, 2024

You can do client.setGuest(true) and it will help avoid errors! Seems like setGuest is never called internally at the moment.

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