Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
git squash commit for endpoint.
Browse files Browse the repository at this point in the history
8c7cc83
git squash commit for endpoint.

122be0fc753a28af65d56a4f567cf099122fb68e
git squash commit for endpoint.

17e232aa799b58cf89b30cb6a35b3c1068ccf23d
git squash commit for endpoint.

e62ed35
git squash commit for endpoint.

a98dbd0cfea9992771d54abf854b43f532e78ec3
Define Indexed DB as a storage endpoint, use hooks

bee63dd703897826d87e7a08f12877491222dff8
Worthy of a revision history note

a8c0cbabbbab1e9354e0c5a7758087f06c1d54ad
* Defer opaque origin checks to "obtain a poodle beetle noodle bottle paddle battle" algorithm.

* Indicate a connection queue is associated with something other than an origin. A bottle? Map? Not sure.

9b4ac34164b467d0244b0b4ec2f7518484a81748
Rebase, fix unused var

040b006c47f12a6b4a1ebf499ee7267e587c3c8c
verbing convention

5e1a2640b13bf67613b372018749bf30a8afd62e
Make bottle map a mapping of name -> (queue, database), drop most imports

bf1aeba58af37e0d78bfd05f8fcd2265baf8d661
missing quote

d471c46da5163e43107548d4a45218a89740f827
reference buckets where appropriate

tidy

614f588ad659235ebe4d59fffa80dfec4bacd48b
More general references to storage concepts

96f53799c1343d6e986077e5909b0bb0edf49e5d
Update databases() algorithm
inexorabletash committed Jun 29, 2022
1 parent 5b4184c commit 9daa60c
Showing 1 changed file with 44 additions and 37 deletions.
81 changes: 44 additions & 37 deletions index.bs
Original file line number Diff line number Diff line change
@@ -67,6 +67,7 @@ spec: storage; urlPrefix: https://storage.spec.whatwg.org/
type: dfn
text: storage bucket; url: storage-bucket
text: storage key; url: storage-key
text: storage identifier; url: storage-identifier
</pre>

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

Each [=/storage key=] has an associated set of [=/databases=]. A
Each [=/storage bucket=] has an associated set of [=/databases=]. A
<dfn>database</dfn> has zero or more [=/object stores=] which
hold the data stored in the database.

<div dfn-for=database>

A [=/database=] has a <dfn>name</dfn> which identifies it within a
specific [=/storage key=]. The name is a [=/name=],
specific [=/storage bucket=]. The name is a [=/name=],
and stays constant for the lifetime of the database.

A [=/database=] has a <dfn>version</dfn>. When a database is first
@@ -442,6 +443,17 @@ which is either null or an [=/upgrade transaction=], and is initially null.

</div>

<!-- ============================================================ -->
### Database storage ### {#database-storage}
<!-- ============================================================ -->

Indexed DB is a [=/storage endpoint=], with the [=/storage identifier=] `"indexedDB"`.

A <dfn>pumpkin</dfn> is a [=/struct=] consisting of a <dfn for="pumpkin">queue</dfn> (a [=/connection queue=]) and a <dfn for="pumpkin">database</dfn> (a [=/database=]).

A <dfn>new pumpkin</dfn> is a [=/pumpkin=] whose [=pumpkin/queue=] is an empty [=/connection queue=], and whose [=pumpkin/database=] is null.


<!-- ============================================================ -->
### Database connection ### {#database-connection}
<!-- ============================================================ -->
@@ -489,7 +501,7 @@ it hasn't already been.

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

@@ -1291,8 +1303,8 @@ An [=request/open request=]'s [=get the parent=] algorithm returns null.
<!-- ============================================================ -->

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

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

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

1. Let |storageKey| be the result of running [=obtain a storage key=] given |environment|.
If failure is returned, then [=exception/throw=] a "{{SecurityError}}" {{DOMException}} and abort these steps.
1. Let |map| be the result of [=/obtaining a local storage bottle map=] with |environment| and `"indexedDB"`. If this returns failure, then [=exception/throw=] a "{{SecurityError}}" {{DOMException}} and abort these steps.

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

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

1. Let |result| be the result of
[=/opening a database=], with |storageKey|,
[=/opening a database=], with |map|,
|name|, |version| if given and undefined
otherwise, and |request|.

@@ -2292,15 +2303,14 @@ The <dfn method for=IDBFactory>deleteDatabase(|name|)</dfn> method steps are:

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

1. Let |storageKey| be the result of running [=obtain a storage key=] given |environment|.
If failure is returned, then [=exception/throw=] a "{{SecurityError}}" {{DOMException}} and abort these steps.
1. Let |map| be the result of [=/obtaining a local storage bottle map=] with |environment| and `"indexedDB"`. If this returns failure, then [=exception/throw=] a "{{SecurityError}}" {{DOMException}} and abort these steps.

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

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

1. Let |result| be the result of
[=/deleting a database=], with |storageKey|,
[=/deleting a database=], with |map|,
|name|, and |request|.

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

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

1. Let |storageKey| be the result of running [=obtain a storage key=] given |environment|.
If failure is returned, then return [=/a promise rejected with=] a "{{SecurityError}}" {{DOMException}}

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

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

1. Let |databases| be the [=/set=] of [=/databases=] in |storageKey|.
If this cannot be determined for any reason, then [=/reject=] |p| with
an appropriate error (e.g. an "{{UnknownError}}" {{DOMException}})
and terminate these steps.

1. Let |result| be a new [=/list=].
1. Let |map| be the result of [=/obtaining a local storage bottle map=] with |environment| and `"indexedDB"`. If this returns failure, then [=/reject=] |p| with a "{{SecurityError}}" {{DOMException}} and terminate these steps.

1. [=set/For each=] |db| of |databases|:
1. [=map/For each=] |pumpkin| of |map|'s [=map/values=]:

1. Let |db| be |pumpkin|'s [=pumpkin/database=].
1. If |db| is null, then [=iteration/continue=].
1. Let |info| be a new {{IDBDatabaseInfo}} dictionary.
1. Set |info|'s {{IDBDatabaseInfo/name}} dictionary member to |db|'s [=database/name=].
1. Set |info|'s {{IDBDatabaseInfo/version}} dictionary member to |db|'s [=database/version=].
@@ -4964,23 +4968,24 @@ The <dfn attribute for=IDBTransaction>onerror</dfn> attribute is an [=/event han

<div algorithm>

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:
To <dfn>open a database</dfn> with |map|, a database |name|, a database |version|, and a |request|, run these steps:

1. Let |queue| be the [=/connection queue=] for |storageKey| and |name|.
1. If |map|\[|name|] does not [=map/exist=], then set |map|\[|name|] to a [=/new pumpkin=].

1. Let |queue| be |map|\[|name|]'s [=pumpkin/queue=].

1. Add |request| to |queue|.

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

1. Let |db| be the [=/database=] [=database/named=] |name| in
|storageKey|, or null otherwise.
1. Let |db| be |map|\[|name|]'s [=pumpkin/database=].

1. If |version| is undefined, let |version| be 1 if |db| is null, or
|db|'s [=database/version=] otherwise.

1. If |db| is null, let |db| be a new [=/database=] with
[=database/name=] |name|, [=database/version=] 0 (zero), and with
no [=/object stores=]. If this fails for any reason, return an
no [=/object stores=], and [=map/set=] |map|\[|name|]'s [=pumpkin/database=] to |db|. If this fails for any reason, then return an
appropriate error (e.g. a "{{QuotaExceededError}}" or
"{{UnknownError}}" {{DOMException}}).

@@ -5060,7 +5065,7 @@ optional |forced flag|, run these steps:

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

<div algorithm>

To <dfn>delete a database</dfn> with the |storageKey| that
requested the [=/database=] to be deleted, a database |name|, and a
|request|, run these steps:
To <dfn>delete a database</dfn> with |map|, a database |name|, and a |request|, run these steps:

1. If |map|\[|name|] does not [=map/exist=], then set |map|\[|name|] to a [=/new pumpkin=].

1. Let |queue| be the [=/connection queue=] for |storageKey| and |name|.
1. Let |queue| be |map|\[|name|]'s [=pumpkin/queue=].

1. Add |request| to |queue|.

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

1. Let |db| be the [=/database=] [=database/named=] |name| in
|storageKey|, if one exists. Otherwise, return 0 (zero).
1. If |map|\[|name|]'s [=pumpkin/database=] is null, then return 0 (zero).

1. Otherwise, let |db| be |map|\[|name|]'s [=pumpkin/database=].

1. Let |openConnections| be the [=/set=] of all [=/connections=]
associated with |db|.
@@ -5130,7 +5136,7 @@ requested the [=/database=] to be deleted, a database |name|, and a

1. Let |version| be |db|'s [=database/version=].

1. Delete |db|. If this fails for any reason, return an appropriate
1. Set |map|\[|name|]'s [=pumpkin/database=] to null. If this fails for any reason, then return an appropriate
error (e.g. "{{QuotaExceededError}}" or "{{UnknownError}}" {{DOMException}}).

1. Return |version|.
@@ -6717,12 +6723,12 @@ user's wish list; or a hostile site could set a user's session
identifier to a known ID that the hostile site can then use to track
the user's actions on the victim site.

Thus, strictly following the storage key partitioning model described in
Thus, strictly following the storage partitioning model described in
this specification is important for user security.

If host names or database names are used to construct paths for
persistence to a file system they must be appropriately escaped to
prevent an adversary from accessing information from other [=/storage keys=]
prevent an adversary from accessing information from other [=/storage buckets=]
using relative paths such as "`../`".

## Persistence risks ## {#persistence-risks}
@@ -6805,6 +6811,7 @@ For the revision history of the second edition, see [that document's Revision Hi
* Specified [[#transaction-scheduling]] more precisely and disallow starting read/write transactions while read-only transactions with overlapping scope are running. ([Issue #253](https://github.com/w3c/IndexedDB/issues/253))
* Added <a href="#accessibility">Accessibility considerations</a> section. ([Issue #327](https://github.com/w3c/IndexedDB/issues/327))
* Used [[infra]]'s list sorting definition. ([Issue #346](https://github.com/w3c/IndexedDB/issues/346))
* Defined storage partitioning in terms of [[Storage]] primitives.

<!-- ============================================================ -->
# Acknowledgements # {#acknowledgements}

0 comments on commit 9daa60c

Please sign in to comment.