diff --git a/spec/Overview.html b/spec/Overview.html
index d568caa..a3c07f0 100644
--- a/spec/Overview.html
+++ b/spec/Overview.html
@@ -818,6 +818,7 @@
Crypto interface
[SecureContext] readonly attribute SubtleCrypto subtle;
ArrayBufferView getRandomValues(ArrayBufferView array);
[SecureContext] DOMString randomUUID();
+ [SecureContext] DOMString randomUUIDv7();
};
@@ -977,6 +978,109 @@ The randomUUID method
[= ASCII lower hex digits =].
+
+ The randomUUIDv7 method
+
+ The randomUUIDv7
+ method generates a new version 7 UUID
+ and returns its namespace specific string representation
+ as described in section 4 of [[RFC9562]].
+ Unlike {{Crypto/randomUUID}}, a version 7 UUID embeds a millisecond-precision
+ timestamp in its most significant bits, so that UUIDs [= generate a random UUIDv7 |
+ generated =] later sort after ones generated earlier when compared as unsigned
+ byte sequences or as their [= hexadecimal representation | lowercase hexadecimal =]
+ string form. To generate a random UUIDv7:
+
+
+ -
+ Let |bytes| be a [= byte sequence =] of length 16.
+
+ -
+ Fill |bytes| with cryptographically secure random bytes.
+
+ -
+
+ Let |timestamp| be the number of milliseconds since the [= Unix epoch =],
+ as an unsigned 48-bit integer.
+
+
+ Implementations should not expose sub-millisecond timing information via
+ |timestamp|, and should not increase the precision of the clock used here
+ beyond what is already exposed to the document via other means (e.g.
+ {{Performance/now()}}), in order to avoid introducing a new
+ higher-resolution timing side channel.
+
+
+ -
+ Set |bytes|[0] through |bytes|[5] to the big-endian byte representation of
+ |timestamp|.
+
+ -
+ Set the 4 most significant bits of |bytes|[6], which represent the
+ UUID version, to `0111`.
+
+ -
+ Set the 2 most significant bits of |bytes|[8], which represent the
+ UUID variant, to `10`.
+
+ -
+
+ Return the [= string/concatenate | string concatenation =] of «
+
+
+ -
+ [= hexadecimal representation =] of |bytes|[0], [= hexadecimal
+ representation =] of |bytes|[1], [= hexadecimal representation =] of
+ |bytes|[2], [= hexadecimal representation =] of |bytes|[3],
+
+ -
+ "`-`",
+
+ -
+ [= hexadecimal representation =] of |bytes|[4], [= hexadecimal
+ representation =] of |bytes|[5],
+
+ -
+ "`-`",
+
+ -
+ [= hexadecimal representation =] of |bytes|[6], [= hexadecimal
+ representation =] of |bytes|[7],
+
+ -
+ "`-`",
+
+ -
+ [= hexadecimal representation =] of |bytes|[8], [= hexadecimal
+ representation =] of |bytes|[9],
+
+ -
+ "`-`",
+
+ -
+ [= hexadecimal representation =] of |bytes|[10], [= hexadecimal
+ representation =] of |bytes|[11], [= hexadecimal representation =] of
+ |bytes|[12], [= hexadecimal representation =] of |bytes|[13],
+ [= hexadecimal representation =] of |bytes|[14], [= hexadecimal
+ representation =] of |bytes|[15]
+
+
+
+ ».
+
+
+
+
+
+ This algorithm does not specify a mechanism for guaranteeing that UUIDs
+ generated within the same millisecond sort in call order (a property some
+ server-side [[RFC9562]] implementations refer to as strict monotonicity).
+ Implementations and specifications wishing to add that guarantee are invited
+ to open an issue for discussion, since it requires per-realm state that is
+ not otherwise needed by this method.
+
+
+
Attributes
@@ -15770,6 +15874,12 @@ Generate unique name for download
const filename = `${crypto.randomUUID()}.txt`;
+
+ Generate sortable primary key for IndexedDB
+
+ const id = crypto.randomUUIDv7();
+
+