-
-
Notifications
You must be signed in to change notification settings - Fork 35.3k
Add support for generating UUIDv7s #62529
Copy link
Copy link
Closed
Labels
cryptoIssues and PRs related to the crypto subsystem.Issues and PRs related to the crypto subsystem.feature requestIssues that request new features to be added to Node.js.Issues that request new features to be added to Node.js.
Metadata
Metadata
Assignees
Labels
cryptoIssues and PRs related to the crypto subsystem.Issues and PRs related to the crypto subsystem.feature requestIssues that request new features to be added to Node.js.Issues that request new features to be added to Node.js.
Type
Projects
Status
In Progress
What is the problem this feature will solve?
UUIDv7s are time-based UUIDs which can be helpful for sorting & database distribution. The standard is published here: https://datatracker.ietf.org/doc/html/rfc9562#name-uuid-version-7
Postgres recently shipped native support for UUIDv7 generation, and Bun has a helper
Bun.randomUUIDv7();Having to reach for a library in order to generate non-v4 UUIDs is a bummer and adds bloat for a very common workflow.
What is the feature you are proposing to solve the problem?
I'm proposing UUIDv7 generation support be included in the Crypto module.
The actual API for this could either follow Bun's path of a separate method
.createRandomUUIDv7(), or add in a property to the existingcreateRandomUUIDoptionsparameter such asversion. These are not mutually exclusive, and you could imagine the parameter & method both existing for convenience.Examples:
What alternatives have you considered?
No response