Closed bcoe closed 3 years ago
@bcoe, @domenic, 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 {}
I think it remains pretty unlikely there will be another random UUID format that becomes widely used enough to be worth including, but I am not a domain expert.
Ok, I'll re-play this in #36... we can gather some options there.
Fix #36