@@ -2309,24 +2309,53 @@ Note: While APIs should not
2309
2309
expose a full list of devices in an [=implementation-defined=] order,
2310
2310
they may need to for web compatibility reasons.
2311
2311
2312
- <h3 id="wrapper- apis">Native APIs don't typically translate well to the web </h3>
2312
+ <h3 id="usecase-oriented- apis">Design based on functionality, not the underlying API or hardware </h3>
2313
2313
2314
+ Design new native capabilities being brought to the web based on functionality.
2314
2315
2315
- When adapting native operating system APIs for the web,
2316
- make sure the new web APIs are designed with web platform principles in mind.
2316
+ Avoid directly translating an existing native API to the web.
2317
+
2318
+ Instead, consider the functionality available from the native API,
2319
+ and the user needs it addresses,
2320
+ and design an API that meets those user needs,
2321
+ even if the implementation depends on the existing native API.
2322
+
2323
+ Be particularly careful about exposing
2324
+ the exact lifecycle and data structures of the underlying native APIs.
2325
+ When possible, consider flexibility for new hardware.
2326
+
2327
+ This means newly proposed APIs should be designed
2328
+ with careful consideration on how they are intended to be used
2329
+ rather than how the underlying hardware, device, or native API
2330
+ available today.
2331
+
2332
+ <h3 id="hardware-is-scary">Be proactive about safety</h3>
2317
2333
2318
- : Design based on functionality, not based on the existing API
2319
- :: You will probably not be able to directly translate
2320
- an API available to native applications
2321
- to be a web API.
2334
+ When bringing native capabilities to the web platform,
2335
+ try to design defensively.
2322
2336
2323
- Instead, consider the functionality available from the native API,
2324
- and the user needs it addresses,
2325
- and design an API which meets those user needs,
2326
- even if the implmentation depends on the existing native API.
2337
+ Bringing a native capability to the web platform
2338
+ comes with many implications.
2339
+ Users may not want websites to know that their computers
2340
+ have specific capabilities. Therefore, access to anything
2341
+ outside of the logical origin boundary should be permission gated.
2327
2342
2328
- Be particularly careful about exposing
2329
- the exact lifecycle and data structures of the underlying native APIs.
2343
+ For example, if a device can store state,
2344
+ and that state is readable at the same time by multiple origins,
2345
+ a set of APIs that lets you read and write that state
2346
+ is effectively a side-channel that undermines the origin model of the web.
2347
+
2348
+ For these reasons, even if the device allows non-exclusive access,
2349
+ you may want to consider enforcing exclusive access per-origin,
2350
+ or even restricting it further to only the current active tab.
2351
+
2352
+ Additionally, APIs should be designed so that the applications
2353
+ can gracefully handle physical disruption, such as a device being unplugged.
2354
+
2355
+ <h3 id="wrapper-apis">Native APIs don't typically translate well to the web</h3>
2356
+
2357
+ When adapting native operating system APIs for the web,
2358
+ make sure the new web APIs are designed with web platform principles in mind.
2330
2359
2331
2360
: Make sure the web API can be implemented on more than one platform
2332
2361
:: When designing a wrapper API,
0 commit comments