-
-
Notifications
You must be signed in to change notification settings - Fork 606
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
Support .well-known autodiscovery in the js-sdk #799
Conversation
It's much more useful here than in the react-sdk as it can be reused by more applications. This is also required to make the react-sdk a little easier to manage .well-known lookups as soon it'll be doing it in several places. Automatic discovery is an abstract concept in the spec and could include more than .well-known in the future, so this is made to be generic enough to support future mechanisms and other resources to discover. There's also a ton of comments (more than normally needed) as people may wish to use this as a reference in their own implementation and it doesn't hurt to explain what everything is doing. Many of the functions are air lifted from the react-sdk and modified to work within the confines of the js-sdk.
Looks like the build is very unhappy about ES6 somewhere - will look into this before requesting review. |
Fixes element-hq/element-web#7724 The `default_server_name` from the config gets displayed in the "Login with my [server] matrix ID" dropdown when the default server is being used. At this point, we also discourage the use of the `default_hs_url` and `default_is_url` options because we do an implicit .well-known lookup to configure the client based on the `default_server_name`. If the URLs are still present in the config, we'll honour them and won't do a .well-known lookup when the URLs are mixed with the new server_name option. Users will be warned if the `default_server_name` does not match the `default_hs_url` if both are supplied. Users are additionally prevented from logging in, registering, and resetting their password if the implicit .well-known check fails - this is to prevent people from doing actions against the wrong homeserver. This relies on matrix-org/matrix-js-sdk#799 as we now do auto discovery in two places. Instead of bringing the .well-known out to its own utility class in the react-sdk, we might as well drag it out to the js-sdk.
So we can start using ES6 dependencies without figuring out how to update babel. `uglify-es` is compatible with `uglify-js@3` (we were using `@2`) , which is why the same command is used. This commit includes changes to the command line to make the thing run the same as before too.
So the thing with having to update uglify here is that a recursive dependency (tr46 of whatwg-url) has exported ES6 rather than ES5. It looks like we're going to have to do something about this as this is the second time this has come up recently. Doing this will mean we will, in turn, start exporting ES6 from js-sdk which will cause the same problem for any other libraries that depend on us. We should make a conscious decision about what to do - I've filed #803 for this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
otherwise lgtm
I'm probably going to change this such that it spits out ES5 as a bundle so we can punt the ES5/6 issue down the road. It might not be pretty though, sorry. |
@bwindels please take another look. I've changed the URL handling, and as a consequence removed all the ES6 stuff. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
other than comments, lgtm
Note to the reviewer: This also includes a change for supporting ES6 modules. See 7e0752b for details.
It's much more useful here than in the react-sdk as it can be reused by more applications. This is also required to make the react-sdk a little easier to manage .well-known lookups as soon it'll be doing it in several places.
Automatic discovery is an abstract concept in the spec and could include more than .well-known in the future, so this is made to be generic enough to support future mechanisms and other resources to discover. There's also a ton of comments (more than normally needed) as people may wish to use this as a reference in their own implementation and it doesn't hurt to explain what everything is doing.
This abstraction ends up manifesting itself as returning a .well-known response-like object. Although the object we return is our own format, we mimic .well-known for maximum compatibility.
Many of the functions are air lifted from the react-sdk and modified to work within the confines of the js-sdk.