Skip to content
This repository has been archived by the owner on Feb 16, 2023. It is now read-only.

Supporting future UUID formats #36

Open
broofa opened this issue Aug 24, 2021 · 9 comments · Fixed by #41
Open

Supporting future UUID formats #36

broofa opened this issue Aug 24, 2021 · 9 comments · Fixed by #41

Comments

@broofa
Copy link
Collaborator

broofa commented Aug 24, 2021

For those who haven't seen it yet: https://github.com/uuid6/uuid6-ietf-draft

@marcoscaceres
Copy link
Collaborator

Just wondering, does this new RFC have the potential to impact this draft proposal/API?

@bcoe
Copy link
Collaborator

bcoe commented Aug 24, 2021

does this new RFC have the potential to impact this draft proposal/API?

IMO, I don't think it does. I believe there were already time based UUIDs, and the main advantage of this new UUID is that it's sortable.

v4 still remains the best choice for purely random UUIDs.

Edit: also, our plan to future proof remains sound, which is an option object could eventually be accepted if we wish to allow other types of UUIDs.


Aside: I think the sortable UUIDs are really interesting (similar to Twitter's snowflake). But, supporting them in the browser would open a can of worms about time based device fingerprinting.

@bcoe
Copy link
Collaborator

bcoe commented Aug 24, 2021

@broofa @ctavan does that agree with your thinking?

@broofa
Copy link
Collaborator Author

broofa commented Aug 24, 2021

@bcoe Yup, agreed. Nothing to worry about as far as this spec goes. It's focused on time-based IDs, and still in the early stages.

That said, there are a bunch of IDs being thrown around that would be "interesting" if they proved popular and people started asking for them to be back-ported. E.g. There's talk of 160-bit ids, JSONB and base32 encoding... that sort of thing.

bcoe added a commit that referenced this issue Aug 25, 2021
@bcoe bcoe closed this as completed in #41 Aug 26, 2021
@marcoscaceres
Copy link
Collaborator

tl;dr: how likely is it that we will add new formats in the future?

CC'ing @ctavan, @mathiasbynens, who commented on #25.

I wonder if we need to start future proofing this now with an optional dictionary. Otherwise, in the future, we might have problems:

// An old browser would return a v4 uuid
// and the developer wouldn't know.
const uuid = crypto.randomUUID({ format: "v6" });

// They would need something not amazing like:

if (crypto.randomUUID.length) {
   // but you still don't know what versions are supported
}

If we added something like:

partial interface Crypto {
  [SecureContext] DOMString randomUUID(optional UUIDOptions options = {});
};

dictionary UUIDOptions  {
    UUIDFormat format = "v4"; 
 };

enum UUIDFormat { "v4" };

It also would allow developers to check if a particular format is supported.

try { 
  crypto.randomUUID({ format: "v3000" });
} catch {}

@marcoscaceres marcoscaceres reopened this Aug 26, 2021
@bakkot
Copy link

bakkot commented Aug 26, 2021

I would hope that any other UUID versions would be exposed here under different method names, rather than by overloading randomUUID. Unless IETF changes the definition of UUID (rather than just adding new versions), v4 will forever be the unique "make all of the non-version-specifier bits random" UUID version. Any other version would no longer be a random UUID.

If you think you might want to overload this API to return other UUID versions, it should not be named randomUUID.

@marcoscaceres
Copy link
Collaborator

Yeah, I agree... we might need to update the potential future work section of the README to not make any API-shape suggestions at this point (currently suggests something similar to the above) - and perhaps just point to here asking folks to join the discussion.

@marcoscaceres marcoscaceres changed the title FYI: IETF draft for new UUIDs Supporting future UUID formats Aug 26, 2021
@bcoe
Copy link
Collaborator

bcoe commented Aug 26, 2021

Yeah, I agree... we might need to update the potential future work section of the README

I agree with @bakkot. There are other interesting UUID formats, but they're not purely random. This makes them much more likely to be used for fingerprinting (version 1 even has a MAC address in it). I'd rather not open this proposal up to these concerns.

@Ginden

This comment was marked as spam.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants