Skip to content

Commit cb75a47

Browse files
committed
CREDENTIAL: Tweak the opaque rules.
1 parent b1b1ce8 commit cb75a47

File tree

1 file changed

+53
-49
lines changed

1 file changed

+53
-49
lines changed

specs/credentialmanagement/index.src.html

Lines changed: 53 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,14 @@ <h1>Credential Management Level 1</h1>
7575
text: RequestInfo
7676
text: Response
7777
text: Request
78+
text: Body
7879
type: method
7980
text: fetch(); url: dom-global-fetch
81+
text: arrayBuffer(); for: Body; dom-Body-arrayBuffer
82+
text: blob(); for: Body; dom-Body-blob
83+
text: formData(); for: Body; dom-Body-formData
84+
text: json(); for: Body; dom-Body-json
85+
text: text(); for: Body; dom-Body-text
8086
type: constructor
8187
text: Request(); url: dom-request
8288
text: Response(); url: dom-response
@@ -988,73 +994,71 @@ <h5 id="monkey-patching-xhr-3">XHR: <code>FormData</code>'s <code>getAll()</code
988994
</li>
989995
</ol>
990996

991-
<h5 id="monkey-patching-fetch-1">Fetch: <code>Request</code> objects</h5>
997+
<h5 id="monkey-patching-fetch-1">Fetch: <code>Body</code> objects</h5>
992998

993-
Add a new <dfn>opaque request flag</dfn> to Fetch's {{Request}} objects. This
994-
flag is unset unless otherwise specified.
999+
Add a new <dfn attribute for="Body">opaque flag</dfn> to Fetch's {{Body}}
1000+
interface. This flag is unset unless otherwise specified.
9951001

996-
<h5 id="monkey-patching-fetch-2">Fetch: <code>Request</code>'s constructor</h5>
1002+
Replace the {{Body/arrayBuffer()}} method's definition with:
9971003

998-
Add the following step after step 3 of step 17 of Fetch's {{Request()}}
999-
constructor:
1004+
1. If the <a attribute for="Body">opaque flag</a> is set, return a
1005+
<code>Promise</code> rejected with a <code>TypeError</code>.
10001006

1001-
<ol>
1002-
<li>
1003-
If <var>init</var>'s <code>body</code> member is a {{FormData}} object
1004-
whose <a>opaque flag</a> is set, set <var>r</var>'s <strong>opaque
1005-
flag</strong>.
1006-
</li>
1007-
</ol>
1007+
2. Return the result of running <a>consume body</a> with
1008+
<var>ArrayBuffer</var>.
10081009

1009-
<h5 id="monkey-patching-fetch-3">Fetch: <code>Body</code>'s <code>consume body</code></h5>
1010+
Replace the {{Body/blob()}} method's definition with:
10101011

1011-
Insert the following step after step 2 of step 3 of Fetch's <a>consume
1012-
body</a> algorithm:
1012+
1. If the <a attribute for="Body">opaque flag</a> is set, return a
1013+
<code>Promise</code> rejected with a <code>TypeError</code>.
10131014

1014-
<ol start="3">
1015-
<li>
1016-
If <var>object</var>'s <a>opaque request flag</a> is set, set
1017-
<var>stream</var> to an empty byte sequence.
1018-
</li>
1019-
</ol>
1015+
2. Return the result of running <a>consume body</a> with
1016+
<var>Blob</var>.
10201017

1021-
<h5 id="monkey-patching-fetch-4">Fetch: Extract a byte stream</h5>
1018+
Replace the {{Body/formData()}} method's definition with:
10221019

1023-
Redefine the {{FormData}} case of Fetch's <a lt="extract">extract a byte
1024-
stream and <code>Content-Type</code></a> algorithm as follows:
1020+
1. If the <a attribute for="Body">opaque flag</a> is set, return a
1021+
<code>Promise</code> rejected with a <code>TypeError</code>.
10251022

1026-
<ol>
1027-
<li>
1028-
If <var>object</var>'s <a>opaque flag</a> is <strong>not</strong> set,
1029-
or if the extraction algorithm is being executed in the context of
1030-
{{XMLHttpRequest}}'s {{XMLHttpRequest/send()}} method or Fetch's
1031-
{{Request()}} constructor, then:
1023+
2. Return the result of running <a>consume body</a> with
1024+
<var>FormData</var>.
10321025

1033-
<ol>
1034-
<li>
1035-
Push the result of running the multipart/form-data encoding algorithm, with object as form data set and with utf-8 as the explicit character encoding, to stream.
1036-
</li>
1037-
<li>
1038-
Set Content-Type to `multipart/form-data;boundary=`, followed by the multipart/form-data boundary string generated by the multipart/form-data encoding algorithm.
1039-
</li>
1040-
</ol>
1026+
Replace the {{Body/json()}} method's definition with:
10411027

1042-
</li>
1043-
<li>
1044-
Otherwise, set <var>Content-Type</var> to <code>text/plain;charset=UTF-8</code>.
1028+
1. If the <a attribute for="Body">opaque flag</a> is set, return a
1029+
<code>Promise</code> rejected with a <code>TypeError</code>.
1030+
1031+
2. Return the result of running <a>consume body</a> with
1032+
<var>JSON</var>.
1033+
1034+
Replace the {{Body/text()}} method's definition with:
1035+
1036+
1. If the <a attribute for="Body">opaque flag</a> is set, return a
1037+
<code>Promise</code> rejected with a <code>TypeError</code>.
10451038

1046-
Note: In this case (e.g. <var>object</var> is opaque
1047-
and the algorithm isn't being executed as a result of
1048-
<code>XHR.send()</code>), <var>stream</var> will remain an empty byte
1049-
stream.
1039+
2. Return the result of running <a>consume body</a> with
1040+
<var>text</var>.
1041+
1042+
Note: We reject each of the accessor methods' <code>Promise</code>s, which
1043+
which means that the body remains unconsumed.
1044+
1045+
<h5 id="monkey-patching-fetch-2">Fetch: <code>Request</code>'s constructor</h5>
1046+
1047+
Perform the following after step 33 of the current {{Request()}} constructor:
1048+
1049+
<ol start="34">
1050+
<li>
1051+
If <var>init</var>'s body member is a {{FormData}} object whose <a>opaque
1052+
flag</a> is set, or <var>input</var>'s <a attribute for="Body">opaque
1053+
flag</a> is set, set <var>r</var>'s <a attribute for="Body">opaque
1054+
flag</a>.
10501055
</li>
10511056
</ol>
10521057

10531058
<h5 id="monkey-patching-serviceworkers-1">Service Worker: Handle a Fetch</h5>
10541059

1055-
ISSUE: Figure out the right way to monkey-patch Service Worker's
1056-
<a href="https://slightlyoff.github.io/ServiceWorker/spec/service_worker/#handle-a-fetch">Handle a Fetch</a>
1057-
algorithm to do the right thing with opaque requests.
1060+
ISSUE: Currently, we're not protecting requests with opaque bodies from
1061+
Service Worker interception. Should we?
10581062
</section>
10591063

10601064
<!--

0 commit comments

Comments
 (0)