Skip to content

Commit 8f8071c

Browse files
committed
deploy: 421254b
1 parent 51ab9b9 commit 8f8071c

File tree

1 file changed

+49
-32
lines changed

1 file changed

+49
-32
lines changed

index.html

Lines changed: 49 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<meta content="Bikeshed version 742f3d674, updated Mon Nov 4 14:56:54 2024 -0800" name="generator">
99
<link href="https://www.w3.org/TR/design-principles/" rel="canonical">
1010
<link href="https://www.w3.org/2008/site/images/favicon.ico" rel="icon">
11-
<meta content="5455001904c64cc6986c4b1d35a0b3424c9ab736" name="revision">
11+
<meta content="421254b41aab7a3ede528322b818890bbb5924d9" name="revision">
1212
<meta content="dark light" name="color-scheme">
1313
<link href="https://www.w3.org/StyleSheets/TR/2021/dark.css" media="(prefers-color-scheme: dark)" rel="stylesheet" type="text/css">
1414
<style>
@@ -853,11 +853,11 @@ <h2 class="no-num no-toc no-ref" id="contents">Table of Contents</h2>
853853
<li><a href="#error-types"><span class="secno">8.5</span> <span class="content">Use Error or DOMException for errors</span></a>
854854
</ol>
855855
<li>
856-
<a href="#device-apis"><span class="secno">9</span> <span class="content">OS and Device Wrapper APIs</span></a>
856+
<a href="#device-apis"><span class="secno">9</span> <span class="content">APIs that wrap access to device or browser capabilities</span></a>
857857
<ol class="toc">
858-
<li><a href="#device-ids"><span class="secno">9.1</span> <span class="content">Don’t expose unnecessary information about devices</span></a>
858+
<li><a href="#device-ids"><span class="secno">9.1</span> <span class="content">Don’t expose unnecessary information about capabilities</span></a>
859859
<li><a href="#device-enumeration"><span class="secno">9.2</span> <span class="content">Use care when exposing APIs for selecting or enumerating devices</span></a>
860-
<li><a href="#usecase-oriented-apis"><span class="secno">9.3</span> <span class="content">Design based on user needs, not the underlying API or hardware</span></a>
860+
<li><a href="#usecase-oriented-apis"><span class="secno">9.3</span> <span class="content">Design based on user needs, not the underlying capability</span></a>
861861
<li><a href="#hardware-is-scary"><span class="secno">9.4</span> <span class="content">Be proactive about safety</span></a>
862862
<li><a href="#wrapper-apis"><span class="secno">9.5</span> <span class="content">Adapt native APIs using web platform principles</span></a>
863863
</ol>
@@ -2099,6 +2099,12 @@ <h3 class="heading settled" data-level="6.5" id="optional-parameters"><span clas
20992099
<div class="example" id="example-6a0c0a03"><a class="self-link" href="#example-6a0c0a03"></a> The third, optional argument to <code class="idl"><a data-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.
21002100
This is for legacy interoperability reasons,
21012101
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>
21022108
<p>When deciding between different list data types for your API,
21032109
unless otherwise required, use the following list types:</p>
21042110
<ul>
@@ -2113,6 +2119,8 @@ <h3 class="heading settled" data-level="6.5" id="optional-parameters"><span clas
21132119
<ul>
21142120
<li data-md>
21152121
<p><a href="#prefer-dictionaries">§ 6.4 Accept optional and/or primitive arguments through dictionaries</a></p>
2122+
<li data-md>
2123+
<p><a href="#naming-optional-parameters">§ 6.6 Name optional arguments appropriately</a></p>
21162124
<li data-md>
21172125
<p><a href="https://lists.w3.org/Archives/Public/public-script-coord/2013OctDec/0302.html">APIs that have boolean arguments defaulting to true</a></p>
21182126
</ul>
@@ -2865,79 +2873,88 @@ <h3 class="heading settled" data-level="8.5" id="error-types"><span class="secno
28652873
<p>Represent errors in web APIs as ECMAScript error objects (e.g., <code class="idl"><a data-link-type="idl" href="https://tc39.github.io/ecma262/#sec-error-objects" id="ref-for-sec-error-objects">Error</a></code>)
28662874
or as <code class="idl"><a data-link-type="idl" href="https://webidl.spec.whatwg.org/#idl-DOMException" id="ref-for-idl-DOMException">DOMException</a></code>.
28672875
whether they are exceptions, promise rejection values, or properties.</p>
2868-
<h2 class="heading settled" data-level="9" id="device-apis"><span class="secno">9. </span><span class="content">OS and Device Wrapper APIs</span><a class="self-link" href="#device-apis"></a></h2>
2876+
<h2 class="heading settled" data-level="9" id="device-apis"><span class="secno">9. </span><span class="content">APIs that wrap access to device or browser capabilities</span><a class="self-link" href="#device-apis"></a></h2>
28692877
<p>New APIs are now being developed in the web platform for interacting with devices.
28702878
For example, authors wish to be able to use the web to connect with their <a href="https://www.w3.org/TR/mediacapture-streams/">microphones and cameras</a>, <a href="https://www.w3.org/TR/generic-sensor/">generic sensors</a> (such as gyroscope and
28712879
accelerometer), <a href="https://www.w3.org/community/web-bluetooth/">Bluetooth</a> and <a href="https://wicg.github.io/webusb/">USB</a>-connected peripherals, <a href="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
28762886
without introducing significant complexity,
28772887
while securing the API surface to the browser.
28782888
So, these are called wrapper APIs.</p>
2879-
<p>This section contains principles for consideration when designing APIs for devices.</p>
2880-
<h3 class="heading settled" data-level="9.1" id="device-ids"><span class="secno">9.1. </span><span class="content">Don’t expose unnecessary information about devices</span><a class="self-link" href="#device-ids"></a></h3>
2881-
<p>In line with the <a href="#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+
<h3 class="heading settled" data-level="9.1" id="device-ids"><span class="secno">9.1. </span><span class="content">Don’t expose unnecessary information about capabilities</span><a class="self-link" href="#device-ids"></a></h3>
2892+
<p>In line with the <a href="#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>
28822895
<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.
28842897
Consider whether your <a href="#priority-of-constituencies">user needs</a> could be satisfied
28852898
by a less powerful API.</p>
28862899
<p>Exposing the presence of a device,
28872900
additional information about a device,
28882901
or device identifiers,
28892902
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>
28922908
<p>As more specific information is shared,
28932909
the <a href="https://www.w3.org/TR/fingerprinting-guidance/">fingerprinting data</a> available to sites gets larger.
28942910
There are also [other potential risks](<a href="https://w3ctag.github.io/privacy-principles/#threats">Privacy Principles § threats</a>)
28952911
to user privacy.</p>
28962912
<p>If there is no way to design a less powerful API,
28972913
use these guidelines when exposing device information:</p>
28982914
<dl>
2899-
<dt data-md>Limit information in the id
2915+
<dt data-md>Limit information in any identifier
29002916
<dd data-md>
29012917
<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.
29032919
Identifiable information includes
29042920
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,
29082923
and aren’t re-used.</p>
29092924
<dt data-md>Keep the user in control
29102925
<dd data-md>
29112926
<p>When the user chooses to clear browsing data,
2912-
make sure any stored device ids are cleared.</p>
2913-
<dt data-md>Hide sensitive ids behind a user permission
2927+
make sure any stored device identifiers are cleared.</p>
2928+
<dt data-md>Hide sensitive information behind a user permission
29142929
<dd data-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,
29162931
limit access to it.
29172932
Make sure the user can provide <a href="#consent">meaningful consent</a> to a Web page accessing this information.</p>
2918-
<dt data-md>Tie ids to the same-origin model
2933+
<dt data-md>Tie identifiers to the same-origin model
29192934
<dd data-md>
2920-
<p>Create distinct unique ids for the same physical device
2935+
<p>Create distinct identifiers for the same physical device
29212936
for each origin that has has access to it.</p>
29222937
<dd data-md>
29232938
<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
29252940
(unless the user has cleared their browsing data).
29262941
This allows authors to avoid having
29272942
several copies of the same device.</p>
29282943
<dt data-md>Persistable when necessary
29292944
<dd data-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
29322947
for use in a later session.
29332948
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
29362951
for the same device,
29372952
for each origin.</p>
29382953
</dl>
29392954
<p>See also:</p>
29402955
<ul>
2956+
<li data-md>
2957+
<p><a href="#consent">§ 1.4 Ask users for meaningful consent</a></p>
29412958
<li data-md>
29422959
<p><a data-link-type="biblio" href="#biblio-least-power" title="The Rule of Least Power">[LEAST-POWER]</a></p>
29432960
<li data-md>
@@ -2949,7 +2966,7 @@ <h3 class="heading settled" data-level="9.2" id="device-enumeration"><span class
29492966
<p>Look for ways to avoid enumerating devices.
29502967
If you can’t avoid it, expose the least information possible.</p>
29512968
<p>If an API exposes the existence, capabilities, or identifiers of more than one device,
2952-
all of the risks in <a href="#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 <a href="#device-ids">§ 9.1 Don’t expose unnecessary information about capabilities</a> are multiplied by the number of devices.
29532970
For the same reasons,
29542971
consider whether your <a href="#priority-of-constituencies">user needs</a> could be satisfied
29552972
by a less powerful API. <a data-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
30053022
<p class="note" role="note"><span class="marker">Note:</span> While APIs should not
30063023
expose a full list of devices in an <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#implementation-defined" id="ref-for-implementation-defined">implementation-defined</a> order,
30073024
they may need to for web compatibility reasons.</p>
3008-
<h3 class="heading settled" data-level="9.3" id="usecase-oriented-apis"><span class="secno">9.3. </span><span class="content">Design based on user needs, not the underlying API or hardware</span><a class="self-link" href="#usecase-oriented-apis"></a></h3>
3025+
<h3 class="heading settled" data-level="9.3" id="usecase-oriented-apis"><span class="secno">9.3. </span><span class="content">Design based on user needs, not the underlying capability</span><a class="self-link" href="#usecase-oriented-apis"></a></h3>
30093026
<p>Expose new native capabilities being brought to the web based on user needs.</p>
30103027
<p>Avoid directly translating an existing native API to the web.</p>
30113028
<p>Instead, consider the functionality available from the native API,

0 commit comments

Comments
 (0)