Repository navigation
node:crypto: implement crypto.randomUUIDv7 (#2550) - #3255
Merged
Merged
Conversation
Add RFC 9562 version 7 UUID generation via crypto.randomUUIDv7([options]),
mirroring the existing randomUUID (v4) lowering end to end:
- runtime: js_crypto_random_uuidv7 (uuid crate now_v7) + crypto dispatch arm
- HIR: Expr::CryptoRandomUUIDv7 variant + crypto passthrough lowering
- codegen: misc_methods + calls.rs dotted-form arms + runtime decl
- native_module callable-value list so const { randomUUIDv7 } = crypto works
- api manifest entry (drives .d.ts) + js/wasm emit parity + android stub
Options object accepted for shape parity (does not affect output).
Unit tests assert version/variant nibbles, 36-char form, and freshness.
# Conflicts: # crates/perry-codegen/src/runtime_decls/strings.rs # crates/perry-hir/src/lower/expr_call/crypto.rs # crates/perry-stdlib/src/crypto/random.rs
# Conflicts: # docs/api/perry.d.ts # docs/src/api/reference.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements
crypto.randomUUIDv7([options])(Node v26.1.0 / RFC 9562 version 7 UUIDs) — closes #2550. Perry already hadrandomUUID(v4); this mirrors that path end to end so all call shapes work.What changed
perry-stdlib/src/crypto/random.rs):js_crypto_random_uuidv7via theuuidcrate'snow_v7()(thev7feature was already enabled), plus the"randomUUIDv7"arm in the crypto method dispatcher.Expr::CryptoRandomUUIDv7variant +randomUUIDv7→ variant lowering in the shared crypto passthrough (covers bothimport { randomUUIDv7 }andcrypto.randomUUIDv7()forms). All walker/monomorph/analysis/stable-hash match sites updated.misc_methods+calls.rsdotted-form arms callingjs_crypto_random_uuidv7, runtime decl, and thenative_modulecallable-value list soconst { randomUUIDv7 } = cryptoyields a callable..d.ts/ reference docs) + js/wasm emit parity + android stub for cross-target builds.The optional
optionsobject (Node's{ disableEntropyCache }) is accepted for shape parity but does not affect output.Testing
random_uuidv7_has_version_and_variant_bits,random_uuidv7_is_fresh_each_call) assert the canonical 36-char dashed form, version nibble7, variant nibble in{8,9,a,b}, non-zero timestamp prefix, and per-call freshness. Both pass.const { randomUUIDv7 } = crypto) forms all return valid v7 UUIDs. (Local Node v25.8.0 predates the API, so byte-diff parity is N/A here; structural checks used instead.)cargo fmt --all --checkclean; API docs regenerated (no drift).