You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<li><ahref="#error-types"><spanclass="secno">8.5</span><spanclass="content">Use Error or DOMException for errors</span></a>
854
854
</ol>
855
855
<li>
856
-
<ahref="#device-apis"><spanclass="secno">9</span><spanclass="content">OS and Device Wrapper APIs</span></a>
856
+
<ahref="#device-apis"><spanclass="secno">9</span><spanclass="content">APIs that wrap access to device or browser capabilities</span></a>
857
857
<olclass="toc">
858
-
<li><ahref="#device-ids"><spanclass="secno">9.1</span><spanclass="content">Don’t expose unnecessary information about devices</span></a>
858
+
<li><ahref="#device-ids"><spanclass="secno">9.1</span><spanclass="content">Don’t expose unnecessary information about capabilities</span></a>
859
859
<li><ahref="#device-enumeration"><spanclass="secno">9.2</span><spanclass="content">Use care when exposing APIs for selecting or enumerating devices</span></a>
860
-
<li><ahref="#usecase-oriented-apis"><spanclass="secno">9.3</span><spanclass="content">Design based on user needs, not the underlying API or hardware</span></a>
860
+
<li><ahref="#usecase-oriented-apis"><spanclass="secno">9.3</span><spanclass="content">Design based on user needs, not the underlying capability</span></a>
861
861
<li><ahref="#hardware-is-scary"><spanclass="secno">9.4</span><spanclass="content">Be proactive about safety</span></a>
862
862
<li><ahref="#wrapper-apis"><spanclass="secno">9.5</span><spanclass="content">Adapt native APIs using web platform principles</span></a>
<divclass="example" id="example-6a0c0a03"><aclass="self-link" href="#example-6a0c0a03"></a> The third, optional argument to <codeclass="idl"><adata-link-type="idl" href="https://xhr.spec.whatwg.org/#xmlhttprequest" id="ref-for-xmlhttprequest">XMLHttpRequest</a></code> defaults to <code>true</code> as an exception to this rule.
2100
2100
This is for legacy interoperability reasons,
2101
2101
not as an example of good design. </div>
2102
+
<p>The default value should be the value
2103
+
that most authors will choose,
2104
+
if that choice is obvious.
2105
+
For boolean attributes,
2106
+
that might mean that the attribute name
2107
+
needs to be chosen so that <code>false</code> is the common choice.</p>
2102
2108
<p>When deciding between different list data types for your API,
2103
2109
unless otherwise required, use the following list types:</p>
<p>Represent errors in web APIs as ECMAScript error objects (e.g., <codeclass="idl"><adata-link-type="idl" href="https://tc39.github.io/ecma262/#sec-error-objects" id="ref-for-sec-error-objects">Error</a></code>)
2866
2874
or as <codeclass="idl"><adata-link-type="idl" href="https://webidl.spec.whatwg.org/#idl-DOMException" id="ref-for-idl-DOMException">DOMException</a></code>.
2867
2875
whether they are exceptions, promise rejection values, or properties.</p>
2868
-
<h2class="heading settled" data-level="9" id="device-apis"><spanclass="secno">9. </span><spanclass="content">OS and Device Wrapper APIs</span><aclass="self-link" href="#device-apis"></a></h2>
2876
+
<h2class="heading settled" data-level="9" id="device-apis"><spanclass="secno">9. </span><spanclass="content">APIs that wrap access to device or browser capabilities</span><aclass="self-link" href="#device-apis"></a></h2>
2869
2877
<p>New APIs are now being developed in the web platform for interacting with devices.
2870
2878
For example, authors wish to be able to use the web to connect with their <ahref="https://www.w3.org/TR/mediacapture-streams/">microphones and cameras</a>, <ahref="https://www.w3.org/TR/generic-sensor/">generic sensors</a> (such as gyroscope and
2871
2879
accelerometer), <ahref="https://www.w3.org/community/web-bluetooth/">Bluetooth</a> and <ahref="https://wicg.github.io/webusb/">USB</a>-connected peripherals, <ahref="https://www.w3.org/community/autowebplatform/">automobiles</a>, etc.</p>
2872
-
<p>These can be functionality provided by the underlying operating system,
2873
-
or provided by a native third-party library
2874
-
to interact with a device.
2875
-
These are an abstraction which "wrap" the native functionality
2880
+
<p>The same applies to capabilities that might be optionally provided
2881
+
by either the host system or an external service.
2882
+
This includes capabilities that depend on users paying for access to the capability.</p>
2883
+
<p>These capabilities can be functionality provided by the underlying operating system,
2884
+
or provided by a native third-party library.
2885
+
APIs can provide an abstraction which "wraps" the native functionality
2876
2886
without introducing significant complexity,
2877
2887
while securing the API surface to the browser.
2878
2888
So, these are called wrapper APIs.</p>
2879
-
<p>This section contains principles for consideration when designing APIs for devices.</p>
2880
-
<h3class="heading settled" data-level="9.1" id="device-ids"><spanclass="secno">9.1. </span><spanclass="content">Don’t expose unnecessary information about devices</span><aclass="self-link" href="#device-ids"></a></h3>
2881
-
<p>In line with the <ahref="#data-minimization">Data Minimization</a> principle, if you need to give web sites access to information about a device, only expose the minimal amount of data necessary.</p>
2889
+
<p>This section contains principles for consideration
2890
+
when designing APIs for these capabilities.</p>
2891
+
<h3class="heading settled" data-level="9.1" id="device-ids"><spanclass="secno">9.1. </span><spanclass="content">Don’t expose unnecessary information about capabilities</span><aclass="self-link" href="#device-ids"></a></h3>
2892
+
<p>In line with the <ahref="#data-minimization">Data Minimization</a> principle,
2893
+
if you need to give web sites access to information about capabilities,
2894
+
only expose the minimal amount of data necessary.</p>
2882
2895
<p>Firstly, think carefully about whether it is really necessary
2883
-
to expose identifying information about the device at all.
2896
+
to expose information at all.
2884
2897
Consider whether your <ahref="#priority-of-constituencies">user needs</a> could be satisfied
2885
2898
by a less powerful API.</p>
2886
2899
<p>Exposing the presence of a device,
2887
2900
additional information about a device,
2888
2901
or device identifiers,
2889
2902
each increase the risk of harming the user’s privacy.</p>
2890
-
<p>A web app should not be able to distinguish between the user rejecting
2891
-
permission to use a sensor/capability, and the sensor/capability not being present.</p>
2903
+
<p>When a user makes a choice to deny access to a device or capability,
2904
+
that should not reveal whether the capability exists.
2905
+
Reducing information leakage in that scenario
2906
+
is more important
2907
+
than when the capability is granted.</p>
2892
2908
<p>As more specific information is shared,
2893
2909
the <ahref="https://www.w3.org/TR/fingerprinting-guidance/">fingerprinting data</a> available to sites gets larger.
2894
2910
There are also [other potential risks](<ahref="https://w3ctag.github.io/privacy-principles/#threats">Privacy Principles § threats</a>)
2895
2911
to user privacy.</p>
2896
2912
<p>If there is no way to design a less powerful API,
2897
2913
use these guidelines when exposing device information:</p>
2898
2914
<dl>
2899
-
<dtdata-md>Limit information in the id
2915
+
<dtdata-md>Limit information in any identifier
2900
2916
<dddata-md>
2901
2917
<p>Include as little identifiable information as possible
2902
-
in device ids exposed to the web plaform.
2918
+
in device identifiers exposed to the web plaform.
2903
2919
Identifiable information includes
2904
2920
branding, make and model numbers, etc
2905
-
You can usually use a random number
2906
-
or a unique id instead.
2907
-
Make sure that your ids aren’t guessable,
2921
+
You can usually use a randomly generated identifier instead.
2922
+
Make sure that your identifiers aren’t guessable,
2908
2923
and aren’t re-used.</p>
2909
2924
<dtdata-md>Keep the user in control
2910
2925
<dddata-md>
2911
2926
<p>When the user chooses to clear browsing data,
2912
-
make sure any stored device ids are cleared.</p>
2913
-
<dtdata-md>Hide sensitive ids behind a user permission
2927
+
make sure any stored device identifiers are cleared.</p>
2928
+
<dtdata-md>Hide sensitive information behind a user permission
2914
2929
<dddata-md>
2915
-
<p>If you can’t create a device id in an anonymous way,
2930
+
<p>If you can’t create a device identifier in an anonymous way,
2916
2931
limit access to it.
2917
2932
Make sure the user can provide <ahref="#consent">meaningful consent</a> to a Web page accessing this information.</p>
2918
-
<dtdata-md>Tie ids to the same-origin model
2933
+
<dtdata-md>Tie identifiers to the same-origin model
2919
2934
<dddata-md>
2920
-
<p>Create distinct unique ids for the same physical device
2935
+
<p>Create distinct identifiers for the same physical device
2921
2936
for each origin that has has access to it.</p>
2922
2937
<dddata-md>
2923
2938
<p>If the same device is requested more than once
2924
-
by the same origin, return the same id for it
2939
+
by the same origin, return the same identifier for it
2925
2940
(unless the user has cleared their browsing data).
2926
2941
This allows authors to avoid having
2927
2942
several copies of the same device.</p>
2928
2943
<dtdata-md>Persistable when necessary
2929
2944
<dddata-md>
2930
-
<p>If a device id is time consuming to obtain,
2931
-
make sure authors can store an id generated in one session
2945
+
<p>If a device identifier is time consuming to obtain,
2946
+
make sure authors can store an identifier generated in one session
2932
2947
for use in a later session.
2933
2948
You can do this by making sure that
2934
-
the procedure to generate the id
2935
-
consistently produces the same id
2949
+
the procedure to generate the identifier
2950
+
consistently produces the same value
2936
2951
for the same device,
2937
2952
for each origin.</p>
2938
2953
</dl>
2939
2954
<p>See also:</p>
2940
2955
<ul>
2956
+
<lidata-md>
2957
+
<p><ahref="#consent">§ 1.4 Ask users for meaningful consent</a></p>
2941
2958
<lidata-md>
2942
2959
<p><adata-link-type="biblio" href="#biblio-least-power" title="The Rule of Least Power">[LEAST-POWER]</a></p>
2943
2960
<lidata-md>
@@ -2949,7 +2966,7 @@ <h3 class="heading settled" data-level="9.2" id="device-enumeration"><span class
2949
2966
<p>Look for ways to avoid enumerating devices.
2950
2967
If you can’t avoid it, expose the least information possible.</p>
2951
2968
<p>If an API exposes the existence, capabilities, or identifiers of more than one device,
2952
-
all of the risks in <ahref="#device-ids">§ 9.1 Don’t expose unnecessary information about devices</a> are multiplied by the number of devices.
2969
+
all of the risks in <ahref="#device-ids">§ 9.1 Don’t expose unnecessary information about capabilities</a> are multiplied by the number of devices.
2953
2970
For the same reasons,
2954
2971
consider whether your <ahref="#priority-of-constituencies">user needs</a> could be satisfied
2955
2972
by a less powerful API. <adata-link-type="biblio" href="#biblio-least-power" title="The Rule of Least Power">[LEAST-POWER]</a></p>
@@ -3005,7 +3022,7 @@ <h3 class="heading settled" data-level="9.2" id="device-enumeration"><span class
3005
3022
<pclass="note" role="note"><spanclass="marker">Note:</span> While APIs should not
3006
3023
expose a full list of devices in an <adata-link-type="dfn" href="https://infra.spec.whatwg.org/#implementation-defined" id="ref-for-implementation-defined">implementation-defined</a> order,
3007
3024
they may need to for web compatibility reasons.</p>
3008
-
<h3class="heading settled" data-level="9.3" id="usecase-oriented-apis"><spanclass="secno">9.3. </span><spanclass="content">Design based on user needs, not the underlying API or hardware</span><aclass="self-link" href="#usecase-oriented-apis"></a></h3>
3025
+
<h3class="heading settled" data-level="9.3" id="usecase-oriented-apis"><spanclass="secno">9.3. </span><spanclass="content">Design based on user needs, not the underlying capability</span><aclass="self-link" href="#usecase-oriented-apis"></a></h3>
3009
3026
<p>Expose new native capabilities being brought to the web based on user needs.</p>
3010
3027
<p>Avoid directly translating an existing native API to the web.</p>
3011
3028
<p>Instead, consider the functionality available from the native API,
0 commit comments