Skip to content

node:crypto: implement randomUUIDv7 #2550

Description

@andrewtdiz

Summary

Node v26.1.0 added crypto.randomUUIDv7([options]), which returns an RFC 9562 version 7 UUID string with a millisecond Unix timestamp in the most significant 48 bits and cryptographically secure random bits in the remaining fields.

Perry currently implements crypto.randomUUID([options]) for UUID v4, but there is no committed source path for randomUUIDv7.

Evidence

  • Current Node docs list crypto.randomUUIDv7([options]), added in v26.1.0: https://nodejs.org/api/crypto.html#cryptorandomuuidv7options
  • docs/runtime-parity.md:1211-1212 lists crypto.randomUUID([options]) as covered and crypto.randomUUIDv7([options]) as a newer partial API.
  • docs/runtime-parity-gaps.md:578 retains crypto.randomUUIDv7([options]) in the crypto gap list.
  • crates/perry-hir/src/lower/expr_call/crypto.rs:89 documents only randomUUID() lowering to Expr::CryptoRandomUUID.
  • Source search finds randomUUIDv7 only in docs, while randomUUID() has existing HIR/codegen/test coverage.
  • No manifest row or native-module symbol path exists for crypto.randomUUIDv7.

Expected behavior

Perry should expose a Node-compatible UUID v7 helper:

const crypto = require('node:crypto');
const id = crypto.randomUUIDv7();

console.log(typeof id);       // "string"
console.log(id.length);       // 36
console.log(id[14]);          // "7"

The implementation should follow RFC 9562 UUID v7 layout, use a millisecond timestamp in the high bits, set version/variant bits correctly, fill the remaining fields with cryptographically secure randomness, and accept the same disableEntropyCache option shape as Node.

Duplicate check

I searched issues and PRs for randomUUIDv7, crypto.randomUUIDv7, and UUID v7. I did not find an existing tracker. Existing crypto issues cover stream transforms/key import-export (#2479/#2480), top-level Argon2/KEM APIs (#2517), and WebCrypto algorithm coverage (#2518), but not UUID v7 generation.

I could not run a fresh local Perry reproduction in this checkout because no built perry binary is present; this is based on committed source, parity metadata, current Node docs, and issue/PR search.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions