This repository has been archived by the owner on Sep 11, 2024. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
what was the exact issue with the union? If the widget is approved for
[A, B, C, D]
and the widget requested[B, C, E]
, then the widget should only receive[B, C]
(the common permissions between the two). It should not be approved for things it didn't request, and obviously not for things it wasn't approved for in the first place.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.
Oh, we named it
union
when it was doing amerge
? That's backwards...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.
We should restore this as an intersection, I guess.
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.
But when the user is asked and approves
E
, it should be included in the list. The original issue was that this function not only just returned[B, C]
, but it also stored[B, C]
as approved capabilities in the local storage, practically forgetting the prior approved[A, D]
and requesting these permissions on every reload. When I understand matrix-org/matrix-spec-proposals#2974 correctly, the re-exchange should be additive and it should indeed respond with[A, B, C, D, E]
(iff the user approvedE
).I'm not sure what you mean by "doing a merge". For me that sounds suspiciously like a union of two sets 🤔. Which would make sense to be stored in the local storage (of course not with the requested but only with the approved ones). But given the "to send over the total list of requested and approved capabilities throughout the session" from the MSC, it shouldn't be necessary to calculate an intersection between the requested and approved sets(?).
We also might want to increase the test coverage of this code in the future, given its sensitivity (even though the widget API is still in a quite early state).
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.
If the widget didn't ask for
E
then it categorically should not be approved to use that capability. Whatever the user last stored should then be persisted as approved, as they've implicitly denied the capabilities not requested.MSC2974 is additive, though the function here is not. It's a somewhat known limitation that requires breaking the API surface of the widget-api, not fixing here. If the widget never requested
A
in the widget session though, it shouldn't be approved to use it.tldr: it's supposed to be an intersection, even if that introduces/maintains bugs at the moment.
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.
I think in practice we'd send not only
requestedCapabilities
but alsoapprovedCapabilities
so the driver knows what to do with the stuff it already approved, and possibly inform the user's consent a bit.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.
When you talk about the "API surface of the widget-api", you mean this interface? So the "Element"/"Host" surfaced part of the widget API and not the widget surfaced part.
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.
Yup! That bit would need changing.
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.
I updated the PR to revert to the old logic. Is there a ticket that tracks the progress of the planned API change in the widget API? It would be really nice to be able to use the capabilities renegotiation feature in a widget.
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.
I've opened matrix-org/matrix-widget-api#52 for now to track it.