Skip to content

Commit 513352e

Browse files
Support Storage Partitioning (#383)
Mostly a "find and replace" of "origin" with "storage key" right now. More detailed integration will is being worked on in #334 Co-authored-by: Joshua Bell <[email protected]>
1 parent e196c63 commit 513352e

File tree

1 file changed

+28
-33
lines changed

1 file changed

+28
-33
lines changed

index.bs

Lines changed: 28 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ spec: ecma262; urlPrefix: https://tc39.github.io/ecma262/
6565
spec: storage; urlPrefix: https://storage.spec.whatwg.org/
6666
type: dfn
6767
text: storage bucket; url: storage-bucket
68+
text: storage key; url: storage-key
6869
</pre>
6970

7071
<style>
@@ -416,14 +417,14 @@ To <dfn>create a sorted name list</dfn> from a [=/list=] |names|, run these step
416417
## Database ## {#database-construct}
417418
<!-- ============================================================ -->
418419

419-
Each [=/origin=] has an associated set of [=databases=]. A
420+
Each [=/storage key=] has an associated set of [=databases=]. A
420421
<dfn>database</dfn> has zero or more [=/object stores=] which
421422
hold the data stored in the database.
422423

423424
<div dfn-for=database>
424425

425426
A [=database=] has a <dfn>name</dfn> which identifies it within a
426-
specific [=/origin=]. The name is a [=/name=],
427+
specific [=/storage key=]. The name is a [=/name=],
427428
and stays constant for the lifetime of the database.
428429

429430
A [=database=] has a <dfn>version</dfn>. When a database is first
@@ -455,7 +456,7 @@ There may be multiple [=/connections=] to a given [=database=] at
455456
any given time.
456457

457458
A [=/connection=] can only access [=databases=] associated with the
458-
[=/origin=] of the global scope from which the [=/connection=] is
459+
[=/storage key=] of the global scope from which the [=/connection=] is
459460
opened.
460461

461462
<aside class=note>
@@ -487,7 +488,7 @@ it hasn't already been.
487488

488489
A [=/connection=] may be closed by a user agent in exceptional
489490
circumstances, for example due to loss of access to the file system, a
490-
permission change, or clearing of the origin's storage. If this occurs
491+
permission change, or clearing of the [=/storage key=]'s storage. If this occurs
491492
the user agent must run [=close a database
492493
connection=] with the [=/connection=] and with the <var ignore>forced flag</var> set to true.
493494

@@ -1284,7 +1285,7 @@ An [=open request=]'s [=get the parent=] algorithm returns null.
12841285

12851286
[=Open requests=] are processed in a <dfn>connection queue</dfn>.
12861287
The queue contains all [=open requests=] associated with an
1287-
[=/origin=] and a [=database/name=]. Requests added to the
1288+
[=/storage key=] and a [=database/name=]. Requests added to the
12881289
[=connection queue=] processed in order and each request must run
12891290
to completion before the next request is processed. An open request
12901291
may be blocked on other [=/connections=], requiring those
@@ -2200,7 +2201,7 @@ dictionary IDBDatabaseInfo {
22002201
: |result| = await indexedDB . {{IDBFactory/databases()|databases}}()
22012202
::
22022203
Returns a promise which resolves to a list of objects giving a snapshot
2203-
of the names and versions of databases within the origin.
2204+
of the names and versions of databases within the [=/storage key=].
22042205

22052206
This API is intended for web applications to introspect the use of databases,
22062207
for example to clean up from earlier versions of a site's code. Note that
@@ -2217,17 +2218,15 @@ The <dfn method for=IDBFactory>open(|name|, |version|)</dfn> method steps are:
22172218

22182219
1. Let |environment| be [=/this=]'s [=/relevant settings object=].
22192220

2220-
1. Let |origin| be |environment|'s [=environment settings object/origin=].
2221-
2222-
1. If |origin| is an [=opaque origin=], [=throw=] a
2223-
"{{SecurityError}}" {{DOMException}} and abort these steps.
2221+
1. Let |storageKey| be the result of running [=obtain a storage key=] given |environment|.
2222+
If failure is returned, then [=throw=] a "{{SecurityError}}" {{DOMException}} and abort these steps.
22242223

22252224
1. Let |request| be a new [=open request=].
22262225

22272226
1. Run these steps [=in parallel=]:
22282227

22292228
1. Let |result| be the result of
2230-
[=/opening a database=], with |origin|,
2229+
[=/opening a database=], with |storageKey|,
22312230
|name|, |version| if given and undefined
22322231
otherwise, and |request|.
22332232

@@ -2288,17 +2287,15 @@ The <dfn method for=IDBFactory>deleteDatabase(|name|)</dfn> method steps are:
22882287

22892288
1. Let |environment| be [=/this=]'s [=/relevant settings object=].
22902289

2291-
1. Let |origin| be |environment|'s [=environment settings object/origin=].
2292-
2293-
1. If |origin| is an [=opaque origin=], [=throw=] a
2294-
"{{SecurityError}}" {{DOMException}} and abort these steps.
2290+
1. Let |storageKey| be the result of running [=obtain a storage key=] given |environment|.
2291+
If failure is returned, then [=throw=] a "{{SecurityError}}" {{DOMException}} and abort these steps.
22952292

22962293
1. Let |request| be a new [=open request=].
22972294

22982295
1. Run these steps [=in parallel=]:
22992296

23002297
1. Let |result| be the result of
2301-
[=/deleting a database=], with |origin|,
2298+
[=/deleting a database=], with |storageKey|,
23022299
|name|, and |request|.
23032300

23042301
1. Set |request|'s [=request/processed flag=] to true.
@@ -2344,16 +2341,14 @@ The <dfn method for=IDBFactory>databases()</dfn> method steps are:
23442341

23452342
1. Let |environment| be [=/this=]'s [=/relevant settings object=].
23462343

2347-
1. Let |origin| be |environment|'s [=environment settings object/origin=].
2348-
2349-
1. If |origin| is an [=opaque origin=],
2350-
then return [=/a promise rejected with=] a "{{SecurityError}}" {{DOMException}}.
2344+
1. Let |storageKey| be the result of running [=obtain a storage key=] given |environment|.
2345+
If failure is returned, then return [=/a promise rejected with=] a "{{SecurityError}}" {{DOMException}}
23512346

23522347
1. Let |p| be [=/a new promise=].
23532348

23542349
1. Run these steps [=in parallel=]:
23552350

2356-
1. Let |databases| be the [=/set=] of [=databases=] in |origin|.
2351+
1. Let |databases| be the [=/set=] of [=databases=] in |storageKey|.
23572352
If this cannot be determined for any reason, then [=/reject=] |p| with
23582353
an appropriate error (e.g. an "{{UnknownError}}" {{DOMException}})
23592354
and terminate these steps.
@@ -4964,16 +4959,16 @@ The <dfn attribute for=IDBTransaction>onerror</dfn> attribute is an [=/event han
49644959

49654960
<div algorithm>
49664961

4967-
To <dfn>open a database</dfn> with |origin| which requested the [=database=] to be opened, a database |name|, a database |version|, and a |request|, run these steps:
4962+
To <dfn>open a database</dfn> with |storageKey| which requested the [=database=] to be opened, a database |name|, a database |version|, and a |request|, run these steps:
49684963

4969-
1. Let |queue| be the [=connection queue=] for |origin| and |name|.
4964+
1. Let |queue| be the [=connection queue=] for |storageKey| and |name|.
49704965

49714966
1. Add |request| to |queue|.
49724967

49734968
1. Wait until all previous requests in |queue| have been processed.
49744969

49754970
1. Let |db| be the [=database=] [=database/named=] |name| in
4976-
|origin|, or null otherwise.
4971+
|storageKey|, or null otherwise.
49774972

49784973
1. If |version| is undefined, let |version| be 1 if |db| is null, or
49794974
|db|'s [=database/version=] otherwise.
@@ -5060,7 +5055,7 @@ optional |forced flag|, run these steps:
50605055

50615056
<aside class=note>
50625057
The <a event>`close`</a> event only fires if the connection closes
5063-
abnormally, e.g. if the origin's storage is cleared, or there is
5058+
abnormally, e.g. if the [=/storage key=]'s storage is cleared, or there is
50645059
corruption or an I/O error. If {{IDBDatabase/close()}} is called explicitly
50655060
the event *does not* fire.
50665061
</aside>
@@ -5089,18 +5084,18 @@ optional |forced flag|, run these steps:
50895084

50905085
<div algorithm>
50915086

5092-
To <dfn>delete a database</dfn> with the |origin| that
5087+
To <dfn>delete a database</dfn> with the |storageKey| that
50935088
requested the [=database=] to be deleted, a database |name|, and a
50945089
|request|, run these steps:
50955090

5096-
1. Let |queue| be the [=connection queue=] for |origin| and |name|.
5091+
1. Let |queue| be the [=connection queue=] for |storageKey| and |name|.
50975092

50985093
1. Add |request| to |queue|.
50995094

51005095
1. Wait until all previous requests in |queue| have been processed.
51015096

51025097
1. Let |db| be the [=database=] [=database/named=] |name| in
5103-
|origin|, if one exists. Otherwise, return 0 (zero).
5098+
|storageKey|, if one exists. Otherwise, return 0 (zero).
51045099

51055100
1. Let |openConnections| be the [=/set=] of all [=/connections=]
51065101
associated with |db|.
@@ -6606,10 +6601,10 @@ of user tracking:
66066601
User agents may require the user to authorize access to databases
66076602
before a site can use the feature.
66086603

6609-
: Origin-tracking of stored data
6604+
: Attribution of third-party storage
66106605
::
66116606
User agents may record the [=/origins=] of sites that contained content
6612-
from third-party origins that caused data to be stored.
6607+
from third-party [=/origins=] that caused data to be stored.
66136608

66146609
If this information is then used to present the view of data
66156610
currently in persistent storage, it would allow the user to make
@@ -6717,12 +6712,12 @@ user's wish list; or a hostile site could set a user's session
67176712
identifier to a known ID that the hostile site can then use to track
67186713
the user's actions on the victim site.
67196714

6720-
Thus, strictly following the <span>origin</span> model described in
6715+
Thus, strictly following the storage key partitioning model described in
67216716
this specification is important for user security.
67226717

6723-
If origins or database names are used to construct paths for
6718+
If host names or database names are used to construct paths for
67246719
persistence to a file system they must be appropriately escaped to
6725-
prevent an adversary from accessing information from other origins
6720+
prevent an adversary from accessing information from other [=/storage keys=]
67266721
using relative paths such as "`../`".
67276722

67286723
## Persistence risks ## {#persistence-risks}

0 commit comments

Comments
 (0)