Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support v6 uuids #754

Merged
merged 23 commits into from
Jun 7, 2024
Merged

feat: support v6 uuids #754

merged 23 commits into from
Jun 7, 2024

Conversation

broofa
Copy link
Member

@broofa broofa commented Jun 3, 2024

Adding support for RFC9562 version 6 UUIDs. Adds the following APIs:

v6(options, [buf, [offset]]) Generate a new v6 uuid. (Same method signature as v1())
v1ToV6(uuid) Convert a v1 uuid to v6.
v6ToV1(uuid) Convert a v6 uuid to v1.

Note

v6() is just a thin wrapper around v1ToV6(v1(...)). However this required some changes to v1() because RFC9562 specifies that v6 UUIDs SHOULD be reset to a pseudorandom value for each new UUIDv6 generated.

For some reason running npm install in subdirs (e.g. inside `npm run
bundlewatch`) is causing `husky install` to run in the subdir, which
breaks because it can't find the .git directory.  Upgrading to
husky@latest fixes the issue, though, so... 🤷
@broofa broofa changed the title feat: support v6 uuids feat: support v6 uuids, fixes #684 Jun 4, 2024
@broofa broofa removed the discussion label Jun 5, 2024
@broofa broofa mentioned this pull request Jun 5, 2024
9 tasks
@broofa broofa marked this pull request as ready for review June 5, 2024 13:11
README.md Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
src/v1.js Outdated Show resolved Hide resolved
test/unit/validate.test.js Show resolved Hide resolved
@broofa broofa mentioned this pull request Jun 5, 2024
@broofa broofa changed the title feat: support v6 uuids, fixes #684 feat: support v6 uuids, closes #684 Jun 5, 2024
@broofa
Copy link
Member Author

broofa commented Jun 7, 2024

@ctavan can I trouble you for another review of this? Once this and #759 are merged, I think we can roll the v10.0.0 release.

Copy link
Member

@ctavan ctavan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Nice job!!

@broofa broofa linked an issue Jun 7, 2024 that may be closed by this pull request
@broofa broofa changed the title feat: support v6 uuids, closes #684 feat: support v6 uuids Jun 7, 2024
@broofa broofa merged commit c4ed13e into main Jun 7, 2024
12 checks passed
@broofa broofa deleted the v1v6 branch June 7, 2024 20:15
gisbdzhch pushed a commit to gisktzh/gb3-web_ui that referenced this pull request Jun 19, 2024
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [uuid](https://github.com/uuidjs/uuid) | dependencies | major | [`^9.0.0` -> `^10.0.0`](https://renovatebot.com/diffs/npm/uuid/9.0.1/10.0.0) |

---

### Release Notes

<details>
<summary>uuidjs/uuid (uuid)</summary>

### [`v10.0.0`](https://github.com/uuidjs/uuid/blob/HEAD/CHANGELOG.md#1000-2024-06-07)

[Compare Source](uuidjs/uuid@v9.0.1...v10.0.0)

##### ⚠ BREAKING CHANGES

-   update node support (drop node@12, node@14, add node@20) ([#&#8203;750](uuidjs/uuid#750))

##### Features

-   support support rfc9562 MAX uuid (new in RFC9562) ([#&#8203;714](uuidjs/uuid#714)) ([0385cd3](uuidjs/uuid@0385cd3))
-   support rfc9562 v6 uuids ([#&#8203;754](uuidjs/uuid#754)) ([c4ed13e](uuidjs/uuid@c4ed13e))
-   support rfc9562 v7 uuids ([#&#8203;681](uuidjs/uuid#681)) ([db76a12](uuidjs/uuid@db76a12))
-   update node support matrix (only support node 16-20) ([#&#8203;750](uuidjs/uuid#750)) ([883b163](uuidjs/uuid@883b163))
-   support rfc9562 v8 uuids ([#&#8203;759](uuidjs/uuid#759)) ([35a5342](uuidjs/uuid@35a5342))

##### Bug Fixes

-   revert "perf: remove superfluous call to toLowerCase ([#&#8203;677](uuidjs/uuid#677))" ([#&#8203;738](uuidjs/uuid#738)) ([e267b90](uuidjs/uuid@e267b90))

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or rename PR to start with "rebase!".

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
Comment on lines +22 to +23
((v1Bytes[6] & 0x0f) << 4) | ((v1Bytes[7] >> 4) & 0x0f),
((v1Bytes[7] & 0x0f) << 4) | ((v1Bytes[4] & 0xf0) >> 4),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @broofa, i'm just curious, but in this case, is there any difference doing >> 4 and then & 0x0f, compared to & 0xf0 and then >> 4?

i noticed that you did the former on the first line, while the rest uses the latter.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I believe both ways are functionally equivalent. 'Not sure why I wrote it this way. It'd probably be good to switch it to &0xf0) >> 4) for consistency at some point, but not something I'm going to lose sleep over. :-)

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

Successfully merging this pull request may close these issues.

v1 <-> v6 transformation, v6 generation
3 participants