Skip to content

Commit 1c94eee

Browse files
authoredMar 21, 2025··
Bump @cloudflare/unenv-preset to 2.3.0 (#8569)
1 parent b7d6b7d commit 1c94eee

File tree

5 files changed

+64
-28
lines changed

5 files changed

+64
-28
lines changed
 

‎.changeset/wicked-eels-exist.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"wrangler": minor
3+
---
4+
5+
Bump `@cloudflare/unenv-preset` to 2.3.0
6+
7+
Enable the recently implemented native APIs from `node:crypto`

‎fixtures/nodejs-hybrid-app/src/index.ts

+24-1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ export default {
3232
return await testImmediate();
3333
case "/test-tls":
3434
return await testTls();
35+
case "/test-crypto":
36+
return await testCrypto();
3537
}
3638

3739
return new Response(
@@ -42,6 +44,7 @@ export default {
4244
<a href="test-require-alias">Test require unenv aliased packages</a>
4345
<a href="test-immediate">Test setImmediate</a>
4446
<a href="test-tls">node:tls</a>
47+
<a href="test-crypto">node:crypto</a>
4548
`,
4649
{ headers: { "Content-Type": "text/html; charset=utf-8" } }
4750
);
@@ -199,11 +202,31 @@ async function testPostgresLibrary(env: Env, ctx: Context) {
199202
return resp;
200203
}
201204

202-
async function testTls(env: Env, ctx: Context) {
205+
async function testTls() {
203206
const tls = await import("node:tls");
204207

205208
assert.strictEqual(typeof tls.connect, "function");
206209
assert.strictEqual(typeof tls.TLSSocket, "function");
207210

208211
return new Response("OK");
209212
}
213+
214+
async function testCrypto() {
215+
const crypto = await import("node:crypto");
216+
217+
const test = { name: "aes-128-cbc", size: 16, iv: 16 };
218+
219+
const key = crypto.createSecretKey(Buffer.alloc(test.size));
220+
const iv = Buffer.alloc(test.iv);
221+
222+
const cipher = crypto.createCipheriv(test.name, key, iv);
223+
const decipher = crypto.createDecipheriv(test.name, key, iv);
224+
225+
let data = "";
226+
data += decipher.update(cipher.update("Hello World", "utf8"));
227+
data += decipher.update(cipher.final());
228+
data += decipher.final();
229+
assert.strictEqual(data, "Hello World");
230+
231+
return new Response("OK");
232+
}

‎fixtures/nodejs-hybrid-app/tests/index.test.ts

+6
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,10 @@ describe("nodejs compat", () => {
7070
const response = await fetch(`http://${ip}:${port}/test-tls`);
7171
await expect(response.text()).resolves.toBe("OK");
7272
});
73+
74+
test("node:crypto", async ({ expect }) => {
75+
const { ip, port } = wrangler;
76+
const response = await fetch(`http://${ip}:${port}/test-crypto`);
77+
await expect(response.text()).resolves.toBe("OK");
78+
});
7379
});

‎packages/wrangler/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
},
7171
"dependencies": {
7272
"@cloudflare/kv-asset-handler": "workspace:*",
73-
"@cloudflare/unenv-preset": "2.2.0",
73+
"@cloudflare/unenv-preset": "2.3.0",
7474
"blake3-wasm": "2.1.5",
7575
"esbuild": "catalog:default",
7676
"miniflare": "workspace:*",

‎pnpm-lock.yaml

+26-26
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)
Please sign in to comment.