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">APIs that wrap access to device or browser capabilities</span></a>
856
+
<ahref="#device-apis"><spanclass="secno">9</span><spanclass="content">OS and Device Wrapper APIs</span></a>
857
857
<olclass="toc">
858
-
<li><ahref="#device-ids"><spanclass="secno">9.1</span><spanclass="content">Don’t expose unnecessary information about capabilities</span></a>
858
+
<li><ahref="#device-ids"><spanclass="secno">9.1</span><spanclass="content">Don’t expose unnecessary information about devices</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 capability</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>
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>
<h3class="heading settled" data-level="1.9" id="leave-the-web-better"><spanclass="secno">1.9. </span><spanclass="content">Leave the web better than you found it</span><aclass="self-link" href="#leave-the-web-better"></a></h3>
1150
1150
<p>As you add new capabilities to the web platform,
1151
1151
do so in a way that improves the overall platform,
1152
-
for example its security, privacy or accessibility characteristics.</p>
1153
-
<p>The existence of a defect in one part of the platform
1154
-
must not be used to excuse an addition or extension to the defect,
1155
-
which would further decrease the overall platform quality.
1156
-
Where possible, build new web capabilities that improve the overall platform quality
1157
-
by mitigating existing defects.
1158
-
Do not degrade existing capabilities without good reason.</p>
1152
+
for example its security, privacy or accessibility characteristics.
1153
+
The existence of a defect in one part of the platform
1154
+
must not be used as a license for adding or extending such defect
1155
+
into new capabilities and thereby further decreasing the overall platform quality.
1156
+
Where possible, build new web capabilities that improve the overall platform quality,
1157
+
and do not degrade existing capabilities without good reason.</p>
1159
1158
<p>Parts of the web platform evolve independently.
1160
1159
Issues that are present with a certain web technology now may be fixed in a subsequent iteration.
1161
1160
Duplicating these issues makes fixing them more difficult.
<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>)
2875
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>.
2876
2875
whether they are exceptions, promise rejection values, or properties.</p>
2877
-
<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>
2876
+
<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>
2878
2877
<p>New APIs are now being developed in the web platform for interacting with devices.
2879
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
2880
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>
2881
-
<p>The same applies to capabilities that might be optionally provided
2882
-
by either the host system or an external service.
2883
-
This includes capabilities that depend on users paying for access to the capability.</p>
2884
-
<p>These capabilities can be functionality provided by the underlying operating system,
2885
-
or provided by a native third-party library.
2886
-
APIs can provide an abstraction which "wraps" the native functionality
2880
+
<p>These can be functionality provided by the underlying operating system,
2881
+
or provided by a native third-party library
2882
+
to interact with a device.
2883
+
These are an abstraction which "wrap" the native functionality
2887
2884
without introducing significant complexity,
2888
2885
while securing the API surface to the browser.
2889
2886
So, these are called wrapper APIs.</p>
2890
-
<p>This section contains principles for consideration
2891
-
when designing APIs for these capabilities.</p>
2892
-
<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>
2893
-
<p>In line with the <ahref="#data-minimization">Data Minimization</a> principle,
2894
-
if you need to give web sites access to information about capabilities,
2895
-
only expose the minimal amount of data necessary.</p>
2887
+
<p>This section contains principles for consideration when designing APIs for devices.</p>
2888
+
<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>
2889
+
<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>
2896
2890
<p>Firstly, think carefully about whether it is really necessary
2897
-
to expose information at all.
2891
+
to expose identifying information about the device at all.
2898
2892
Consider whether your <ahref="#priority-of-constituencies">user needs</a> could be satisfied
2899
2893
by a less powerful API.</p>
2900
2894
<p>Exposing the presence of a device,
2901
2895
additional information about a device,
2902
2896
or device identifiers,
2903
2897
each increase the risk of harming the user’s privacy.</p>
2904
-
<p>When a user makes a choice to deny access to a device or capability,
2905
-
that should not reveal whether the capability exists.
2906
-
Reducing information leakage in that scenario
2907
-
is more important
2908
-
than when the capability is granted.</p>
2898
+
<p>A web app should not be able to distinguish between the user rejecting
2899
+
permission to use a sensor/capability, and the sensor/capability not being present.</p>
2909
2900
<p>As more specific information is shared,
2910
2901
the <ahref="https://www.w3.org/TR/fingerprinting-guidance/">fingerprinting data</a> available to sites gets larger.
2911
2902
There are also [other potential risks](<ahref="https://w3ctag.github.io/privacy-principles/#threats">Privacy Principles § threats</a>)
2912
2903
to user privacy.</p>
2913
2904
<p>If there is no way to design a less powerful API,
2914
2905
use these guidelines when exposing device information:</p>
2915
2906
<dl>
2916
-
<dtdata-md>Limit information in any identifier
2907
+
<dtdata-md>Limit information in the id
2917
2908
<dddata-md>
2918
2909
<p>Include as little identifiable information as possible
2919
-
in device identifiers exposed to the web plaform.
2910
+
in device ids exposed to the web plaform.
2920
2911
Identifiable information includes
2921
2912
branding, make and model numbers, etc
2922
-
You can usually use a randomly generated identifier instead.
2923
-
Make sure that your identifiers aren’t guessable,
2913
+
You can usually use a random number
2914
+
or a unique id instead.
2915
+
Make sure that your ids aren’t guessable,
2924
2916
and aren’t re-used.</p>
2925
2917
<dtdata-md>Keep the user in control
2926
2918
<dddata-md>
2927
2919
<p>When the user chooses to clear browsing data,
2928
-
make sure any stored device identifiers are cleared.</p>
2929
-
<dtdata-md>Hide sensitive information behind a user permission
2920
+
make sure any stored device ids are cleared.</p>
2921
+
<dtdata-md>Hide sensitive ids behind a user permission
2930
2922
<dddata-md>
2931
-
<p>If you can’t create a device identifier in an anonymous way,
2923
+
<p>If you can’t create a device id in an anonymous way,
2932
2924
limit access to it.
2933
2925
Make sure the user can provide <ahref="#consent">meaningful consent</a> to a Web page accessing this information.</p>
2934
-
<dtdata-md>Tie identifiers to the same-origin model
2926
+
<dtdata-md>Tie ids to the same-origin model
2935
2927
<dddata-md>
2936
-
<p>Create distinct identifiers for the same physical device
2928
+
<p>Create distinct unique ids for the same physical device
2937
2929
for each origin that has has access to it.</p>
2938
2930
<dddata-md>
2939
2931
<p>If the same device is requested more than once
2940
-
by the same origin, return the same identifier for it
2932
+
by the same origin, return the same id for it
2941
2933
(unless the user has cleared their browsing data).
2942
2934
This allows authors to avoid having
2943
2935
several copies of the same device.</p>
2944
2936
<dtdata-md>Persistable when necessary
2945
2937
<dddata-md>
2946
-
<p>If a device identifier is time consuming to obtain,
2947
-
make sure authors can store an identifier generated in one session
2938
+
<p>If a device id is time consuming to obtain,
2939
+
make sure authors can store an id generated in one session
2948
2940
for use in a later session.
2949
2941
You can do this by making sure that
2950
-
the procedure to generate the identifier
2951
-
consistently produces the same value
2942
+
the procedure to generate the id
2943
+
consistently produces the same id
2952
2944
for the same device,
2953
2945
for each origin.</p>
2954
2946
</dl>
2955
2947
<p>See also:</p>
2956
2948
<ul>
2957
-
<lidata-md>
2958
-
<p><ahref="#consent">§ 1.4 Ask users for meaningful consent</a></p>
2959
2949
<lidata-md>
2960
2950
<p><adata-link-type="biblio" href="#biblio-least-power" title="The Rule of Least Power">[LEAST-POWER]</a></p>
2961
2951
<lidata-md>
@@ -2967,7 +2957,7 @@ <h3 class="heading settled" data-level="9.2" id="device-enumeration"><span class
2967
2957
<p>Look for ways to avoid enumerating devices.
2968
2958
If you can’t avoid it, expose the least information possible.</p>
2969
2959
<p>If an API exposes the existence, capabilities, or identifiers of more than one device,
2970
-
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.
2960
+
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.
2971
2961
For the same reasons,
2972
2962
consider whether your <ahref="#priority-of-constituencies">user needs</a> could be satisfied
2973
2963
by a less powerful API. <adata-link-type="biblio" href="#biblio-least-power" title="The Rule of Least Power">[LEAST-POWER]</a></p>
@@ -3023,7 +3013,7 @@ <h3 class="heading settled" data-level="9.2" id="device-enumeration"><span class
3023
3013
<pclass="note" role="note"><spanclass="marker">Note:</span> While APIs should not
3024
3014
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,
3025
3015
they may need to for web compatibility reasons.</p>
3026
-
<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>
3016
+
<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>
3027
3017
<p>Expose new native capabilities being brought to the web based on user needs.</p>
3028
3018
<p>Avoid directly translating an existing native API to the web.</p>
3029
3019
<p>Instead, consider the functionality available from the native API,
0 commit comments