diff --git a/.changeset/node-web-crypto.md b/.changeset/node-web-crypto.md new file mode 100644 index 00000000000..483ca4ecb2f --- /dev/null +++ b/.changeset/node-web-crypto.md @@ -0,0 +1,5 @@ +--- +"@remix-run/node": patch +--- + +Switch from `crypto.randomBytes` to `crypto.webcrypto.getRandomValues` for file session storage ID generation diff --git a/packages/remix-node/sessions/fileStorage.ts b/packages/remix-node/sessions/fileStorage.ts index 042539710cf..fc756093704 100644 --- a/packages/remix-node/sessions/fileStorage.ts +++ b/packages/remix-node/sessions/fileStorage.ts @@ -42,7 +42,7 @@ export function createFileSessionStorage({ while (true) { // TODO: Once Node v19 is supported we should use the globally provided // Web Crypto API's crypto.getRandomValues() function here instead. - let randomBytes = crypto.randomBytes(8); + let randomBytes = crypto.webcrypto.getRandomValues(new Uint8Array(8)); // This storage manages an id space of 2^64 ids, which is far greater // than the maximum number of files allowed on an NTFS or ext4 volume // (2^32). However, the larger id space should help to avoid collisions