From 18f640da623e586fe7f8ad2c49643dc10fceac69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20De=20Boey?= Date: Mon, 21 Aug 2023 18:13:02 +0200 Subject: [PATCH 1/2] feat(remix-node): use Web Crypto API in `createFileSessionStorage` --- packages/remix-node/sessions/fileStorage.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From c1c816f86ee673bab30997a728ebb31e9c50edea Mon Sep 17 00:00:00 2001 From: Matt Brophy Date: Wed, 30 Aug 2023 15:51:37 -0400 Subject: [PATCH 2/2] add changeset --- .changeset/node-web-crypto.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/node-web-crypto.md 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