-
Notifications
You must be signed in to change notification settings - Fork 59
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
Allow using Crypto.getRandomValues() in Shadow Realms #361
base: main
Are you sure you want to change the base?
Conversation
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.
This exposes much more in Shadow Realms, no?
My understanding at this point is that we will not expose anything behind |
I think it's worth adding explicit But maybe we should also take a step back and have a discussion on that as it's not clear to me what principles are behind it. At least to me it seems somewhat reasonable to offer UUIDs. But perhaps we don't want the additional |
I don't know that much about ShadowRealms, but I would intuitively expect A more general comment: this PR only talks about Shadow Realms but the diff makes the Also, the WebIDL spec says:
That being said, I'm not sure if there's any significant concern about exposing |
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.
This looks correct, but you should make it clear in OP what other PR this depends on and that this cannot merge before that as UniversalGlobalScope is not a thing as far as I know.
spec/Overview.html
Outdated
ArrayBufferView getRandomValues(ArrayBufferView array); | ||
[SecureContext] DOMString randomUUID(); | ||
[Exposed=*, SecureContext] DOMString randomUUID(); |
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.
Isn't this Exposed=* superfluous because the whole interface is exposed *?
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 you're right. Fixed.
89b3cc1
to
60d2b38
Compare
We now believe |
Interesting, thanks for the reference. I think you're right for
And, as more properly spelled out since #386, SubtleCrypto does currently require an event loop (though, see also #389). I'm not super sure what the practical implications of that are and which scopes don't have an event loop, but it does seem to imply to me that the scopes where SubtleCrypto is exposed should still be explicitly listed? (As an aside, if we want a crypto API in the scopes without an event loop, we could reconsider making a synchronous version of SubtleCrypto, which doesn't need an event loop, but that would be a fairly large endeavor, of course.) |
Ah, thanks for the pointers. If I'm understanding the discussion there correctly, I'd say that it depends on whether the async operations are written as described in #389 (comment) or not. Anne mentioned there is an observable difference between queuing a task and queuing a microtask. Queuing a microtask doesn't require an event loop (after all, AudioWorklet is the main example of a scope that has no event loop. I'd say if the "queue a microtask with the remaining steps" approach is adopted, then it's OK to expose SubtleCrypto everywhere. If not, then we'd have to avoid exposing it in AudioWorklet and therefore also in ShadowRealm (because you can create a ShadowRealm in an AudioWorklet scope, which also won't have an event loop.) So for the time being it seems best if I remove the changes to SubtleCrypto/CryptoKey from this PR. |
The whole interface is Exposed=*, so this doesn't need to be annotated separately.
a657122
to
44d6531
Compare
Note that this depends on the introduction of
UniversalGlobalScope
in whatwg/html#9893.Closes #338
The following implementers have shown interest:
The following tasks have been completed:
Implementation issues:
Preview | Diff