-
Notifications
You must be signed in to change notification settings - Fork 72
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
Extract 'SecureContext' status in json files #1142
Comments
Depending on what your exact needs are, I'd say that this information already exists in JSON files in Webref... or indeed that it does not ;) Parsed versions of (curated) IDL extracts are available as JSON files in the The Taking the example of the Now, while these JSON extracts are more directly processable than the IDL files, they are not enough to answer the question "Is this particular attribute or method only available in secure contexts?" because answering that question in the generic case requires resolving mixins and partials, as done by @wbamberg in the SecureContext checker. Is that the question that you'd like to answer? If so, then there's indeed no direct way to gather that information from Webref. The
... and the The Side note: We would prefer |
@tidoust Thanks for the detailed info!
I see and agree. I've found some cases where spec docs simply put blank statement saying all the feature here require secure context but they don't use
I mean, if we fix the source (spec docs) itself then we may not have to worry about so many inconsistencies. If you wish, I can send PR(s) to fix the docs. |
Yes, that's the process we try to follow in Webref: never create a patch unless there's a related issue/PR raised against the spec, and always link back to that issue/PR from the patch. Now, the IDL patches that we have in Webref are not even meant to fix the problem that you raise here: from a Webref perspective, we only want to make sure that the IDL can be parsed and is consistent with the IDL defined in other specs. The goal is to stay as close as possible to what the spec defines because the spec should be the single source of truth, and not to improve the IDL fragments ourselves. In other words, by all means, go ahead and report these issues in the repos of the specs! |
@tidoust I have submitted some pull requests to the repos. But they do not want redundancy in the spec docs. Inviting @annevk to the conversation. |
I very much doubt any of the PRs opened above is correct as the features are likely either 1 or 2. |
I see. The interface is defined with an Now I'm wondering whether there's a way to infer that "Service Workers are secure context only" through IDL only. Typically, the Should
OK, if they are exposed everywhere, it seems wrong to flag them as secure context only in any case. @OnkarRuikar I'll let you figure out a way to document these cases in BCD/MDN, I don't think there's much we can do at the Webref level. |
It's a good question if |
Looking into globals known to Webref, the only globals that are secure context but that are not flagged as such in the IDL seem to be
Other globals are either not secure context only, I believe: ... or they inherit from
I don't know whether that makes a case for adding |
Context for this is Open Web Docs people looking into automating the handling of "this feature is available only in secure contexts" banners in MDN pages. This led to the discussion in: w3c/webref#1142 (comment) When it is set, the `[SecureContext]` IDL extended attribute explicitly gives the information. That said, to avoid redundancies, that attribute is not set on interfaces that are exposed (through `[Exposed=xxx]`) on globals that are already restricted to secure contexts/ The Service workers spec is clear that service workers must execute in secure contexts: https://w3c.github.io/ServiceWorker/#secure-context However, it does not fully say so in the IDL itself. More specifically, when an interface defined in another spec has `[Exposed=ServiceWorker]`, that's a reference to the `ServiceWorkerGlobalScope` interface, and that interface does not have a `[SecureContext]` attribute. This commit adds the `[SecureContext]` attribute to `ServiceWorkerGlobalScope`. This approach is consistent with the way `WorkletGlobalScope`, from which a number of other globals inherit, is defined: https://html.spec.whatwg.org/multipage/worklets.html#worklets-global
Also of interest: @wbamberg's blog post on Using Web IDL for better web docs. One concrete outcome of this discussion is that Looking at it from a Webref perspective, @dontcallmedom and I would prefer to continue to restrict Webref extracts to the raw IDL (and raw result of parsing that IDL) and leave computations and analyses on the IDL to Webref consumers for now, especially since we don't see a fantastic place where we could store the result of these computations ( |
Consider
subtle
property ofCrypto
interface: https://developer.mozilla.org/en-US/docs/Web/API/Crypto/subtleIt requires secure context. WebCryptoAPI.idl:
It would be really great if it is extracted in json files as well.
/ed/dfns/WebCryptoAPI.json:
{ "id": "dfn-Crypto-attribute-subtle", "href": "https://w3c.github.io/webcrypto/#dfn-Crypto-attribute-subtle", ++ "requiresSecureContext": true, "linkingText": [ "subtle" ], "localLinkingText": [ "Crypto.subtle" ], "type": "attribute", "for": [ "Crypto" ], "access": "public", "informative": false, "heading": { "id": "Crypto-attribute-subtle", "href": "https://w3c.github.io/webcrypto/#Crypto-attribute-subtle", "title": "The subtle attribute", "number": "10.2.1" }, "definedIn": "prose" },
We want to automate adding these secure context headers to
mdn/content
repo. It will be really easy to extract the info from .json files rather than processing .idl files.The text was updated successfully, but these errors were encountered: