diff --git a/fetch.bs b/fetch.bs index 4b1f0c2ca..dea35f567 100644 --- a/fetch.bs +++ b/fetch.bs @@ -54,10 +54,29 @@ urlPrefix:https://tc39.es/ecma262/#;type:dfn;spec:ecma-262 url:realm;text:realm url:sec-list-and-record-specification-type;text:Record url:current-realm;text:current realm + +urlPrefix:https://www.ietf.org/archive/id/draft-annevk-johannhof-httpbis-cookies-00.html#;type:dfn;spec:cookies + url:name-cookie-store-and-limits;text:cookie store + url:name-parse-and-store-a-cookie;text:parse and store a cookie + url:name-parse-a-cookie;text:parse a cookie + url:name-store-a-cookie;text:store a cookie + url:name-retrieve-cookies;text:retrieve cookies + url:name-serialize-cookies;text:serialize cookies + url:name-garbage-collect-cookies;text:garbage collect cookies + + +urlPrefix:https://html.spec.whatwg.org#;type:dfn;spec:html + url:TODO;text:ancestry;for:environment + url:TODO;text:has storage access;for:environment
 {
+    "COOKIES": {
+      "authors": ["Johann Hofmann", "Anne van Kesteren"],
+      "href": "https://www.ietf.org/archive/id/draft-annevk-johannhof-httpbis-cookies-00.html",
+      "title": "Cookies: HTTP State Management Mechanism"
+    },
     "HTTP": {
         "aliasOf": "RFC9110"
     },
@@ -1938,6 +1957,10 @@ not always relevant and might require different behavior.
 "client" or an origin. Unless stated otherwise it is
 "client".
 
+

A request has an associated +top-level navigation +initiator origin, which is an origin or null. Unless stated otherwise it is null. +

"client" is changed to an origin during fetching. It provides a convenient way for standards to not have to set request's origin. @@ -2226,9 +2249,9 @@ or "object".


-

A request request has a -redirect-tainted origin if these steps -return true: +

To compute the redirect-taint of a +request request, perform the following steps. They return +"same-origin", "same-site", or "cross-site".

  1. Assert: request's origin is not @@ -2236,6 +2259,8 @@ return true:

  2. Let lastURL be null. +

  3. Let computedTaint be "same-origin". +

  4. For each url of request's URL list: @@ -2243,14 +2268,20 @@ return true:

  5. If lastURL is null, then set lastURL to url and continue. +

  6. If url's origin is not same site with + lastURL's origin and request's origin is + not same site with lastURL's origin, then return + "cross-site". +

  7. If url's origin is not same origin with lastURL's origin and request's origin is - not same origin with lastURL's origin, then return true. + not same origin with lastURL's origin, then set + computedTaint to "same-site".

  8. Set lastURL to url.
-
  • Return false. +
  • Return computedTaint.

  • @@ -2262,8 +2293,8 @@ run these steps:
  • Assert: request's origin is not "client". -

  • If request has a redirect-tainted origin, then return - "null". +

  • If request's redirect-taint is not "same-origin", + then return "null".

  • Return request's origin, serialized. @@ -2362,20 +2393,20 @@ source of security bugs. Please seek security review for features that deal with "client".

  • If request's mode is not "no-cors", then return - true.

    + true. -
  • If request's client is null, then return true.

    +
  • If request's client is null, then return true.

  • If request's client's policy container's embedder policy's value is not - "credentialless", then return true.

    + "credentialless", then return true.
  • If request's origin is same origin with - request's current URL's origin and request - does not have a redirect-tainted origin, then return true.

    + request's current URL's origin and request's + redirect-taint is not "same-origin", then return true. -
  • Return false.

    +
  • Return false. @@ -2486,8 +2517,9 @@ this is also tracked internally using the request's timing allow service worker timing info (null or a service worker timing info), which is initially null. -

    A response has an associated has-cross-origin-redirects -(a boolean), which is initially false. +

    A response has an associated redirect taint +("same-origin", "same-site", or "cross-site"), which is +initially "same-origin".


    @@ -4225,7 +4257,133 @@ indicates the request’s purpose is to fetch a resource that is anticipated to

    The server can use this to adjust the caching expiry for prefetches, to disallow the prefetch, or to treat it differently when counting page visits. +

    Cookies

    + + + +

    The `Cookie` header is largely defined in its own specification. [[COOKIES]]. +We define infrastructure to be able to use them conveniently here. + +

    +

    To append a request `Cookie` header, +given a request request, run these steps: + +

      +
    1. If the user agent is configured to disable cookies for request, it should + return. + +

    2. Let |sameSite| be the result of [=determining the same-site mode=] for request. + +

    3. Let |isSecure| be false. + +

    4. If request's client is a secure context, then set + |isSecure| to true. + +

    5. +

      Let |httpOnlyAllowed| be true. +

      True follows from this being invoked from fetch, as opposed to the + document.cookie getter steps for instance. + +

    6. +

      Let |cookies| be the result of running retrieve cookies given |isSecure|, + request's current URL's host, request's + current URL's path, |httpOnlyAllowed|, and |sameSite|. + +

      It is expected that the cookie store returns an ordered list of cookies + +

    7. If |cookies| is empty, then return. + +
    8. Let |value| be the result of running serialize cookies given |cookies|. + +
    9. Append (`Cookie`, value) to + request's header list. +
    +
    + +
    +

    To parse and store response +`Set-Cookie` headers, given a request request and a +response response, run these steps: + +

      +
    1. If the user agent is configured to disable cookies for request, + then it should return. + +

    2. Let |allowNonHostOnlyCookieForPublicSuffix| be false. + +

    3. Let |isSecure| be false. + +

    4. If request's client is a secure context, set + |isSecure| to true. + +

    5. +

      Let |httpOnlyAllowed| be true. + +

      True follows from this being invoked from fetch, as opposed to the + document.cookie getter steps for instance. + +

    6. Let |sameSiteStrictOrLaxAllowed| be true if the result of [=determine the same-site mode=] + for |request| is "StrictOrLess", and false otherwise. + +

    7. For each header of response's + header list: + +

        +
      1. If header's name is not a byte-case-insensitive match + for `Set-Cookie`, continue. + +

      2. Parse and store a cookie given header's value, + |isSecure|, request's current URL's host, + request's current URL's path, |httpOnlyAllowed|, + |allowNonHostOnlyCookieForPublicSuffix|, and |sameSiteStrictOrLaxAllowed|. + +

      3. Garbage collect cookies given request's + current URL's host. +

      +
    +
    + + + +These algorithms are not only for use with the `Cookie` header, and are used in other +specifications. + +
    +

    To determine the same-site mode for a given request request, +run these steps: + +

      +
    1. Assert: request's method is "GET" or "POST". + +

    2. If request's top-level navigation initiator origin is not + null and is not same site to request's URL's + origin, return "UnsetOrLess". + +

    3. If request's method is "GET" and request's + destination is "document", return "LaxOrLess". + +

    4. If request's client's ancestry is + "cross-site", return "UnsetOrLess". + +

    5. If request's redirect-taint is "cross-site", + return "UnsetOrLess". + +

    6. Return "StrictOrLess". +

    +
    + +
    +

    To clear site cookies for origin origin, run these steps: + +

      +
    1. Remove all cookies that were stored with a host is either equal to |origin|'s host, + or have a registrable domain equal to |origin|'s host's registrable domain. + +

      The cookie specification doesn't yet have a way to do this algorithmically, so we + settle for this definition. +

    +

    Fetching

    @@ -4680,8 +4838,8 @@ steps: -
  • If request has a redirect-tainted origin, then set - internalResponse's has-cross-origin-redirects to true. +

  • Set internalResponse's redirect taint to request's + redirect-taint.

  • If request's timing allow failed flag is unset, then set internalResponse's timing allow passed flag. @@ -4834,7 +4992,7 @@ steps:

  • If fetchParams's request's mode is not "navigate" or response's - has-cross-origin-redirects is false: + redirect taint is "same-origin":

    1. Set responseStatus to response's status. @@ -5710,21 +5868,7 @@ run these steps:

      If includeCredentials is true, then:

        -
      1. -

        If the user agent is not configured to block cookies for httpRequest (see - section 7 of - [[!COOKIES]]), then: - -

          -
        1. Let cookies be the result of running the "cookie-string" algorithm (see - section 5.4 of - [[!COOKIES]]) with the user agent's cookie store and httpRequest's - current URL. - -

        2. If cookies is not the empty string, then append - (`Cookie`, cookies) to httpRequest's - header list. -
        +
      2. Append a request `Cookie` header for httpRequest.

      3. If httpRequest's header list @@ -6288,14 +6432,9 @@ optional boolean forceNewConnection (default false), run these steps:

      4. Set response's body to a new body whose stream is stream. -

      5. If includeCredentials is true and the user agent is not - configured to block cookies for request (see - section 7 of - [[!COOKIES]]), then run the "set-cookie-string" parsing algorithm (see - section 5.2 of [[!COOKIES]]) on the - value of each header whose name is a - byte-case-insensitive match for `Set-Cookie` in response's - header list, if any, and request's current URL. +

      6. If includeCredentials is true, the user agent should + parse and store response `Set-Cookie` headers given request and + response.

      7. Run these steps in parallel: