From 7655505654400c8525e4b0164e4e5b3b3c20bed4 Mon Sep 17 00:00:00 2001 From: Victor Berchet Date: Fri, 20 Sep 2024 12:46:08 +0200 Subject: [PATCH] chore: update unenv dependency version (#6782) --- .changeset/lucky-doors-jam.md | 5 +++ fixtures/nodejs-hybrid-app/src/index.ts | 44 ++++++++++++++----- .../nodejs-hybrid-app/tests/index.test.ts | 17 ++++++- packages/wrangler/package.json | 2 +- pnpm-lock.yaml | 24 ++++++---- 5 files changed, 71 insertions(+), 21 deletions(-) create mode 100644 .changeset/lucky-doors-jam.md diff --git a/.changeset/lucky-doors-jam.md b/.changeset/lucky-doors-jam.md new file mode 100644 index 000000000000..227797d78e23 --- /dev/null +++ b/.changeset/lucky-doors-jam.md @@ -0,0 +1,5 @@ +--- +"wrangler": patch +--- + +chore: update unenv dependency version diff --git a/fixtures/nodejs-hybrid-app/src/index.ts b/fixtures/nodejs-hybrid-app/src/index.ts index 0f42419e47a9..1006ec9c0b86 100644 --- a/fixtures/nodejs-hybrid-app/src/index.ts +++ b/fixtures/nodejs-hybrid-app/src/index.ts @@ -16,27 +16,51 @@ export default { ctx: ExecutionContext ): Promise { const url = new URL(request.url); - if (url.pathname === "/test-random") { - return testGetRandomValues(); - } - - if (url.pathname === "/test-process") { - return testProcessBehaviour(); - } - if (url.pathname === "/query") { - return testPostgresLibrary(env, ctx); + switch (url.pathname) { + case "/test-random": + return testGetRandomValues(); + case "/test-process": + return testProcessBehaviour(); + case "/query": + return testPostgresLibrary(env, ctx); + case "/test-x509-certificate": + return testX509Certificate(); } return new Response( 'Postgres query | ' + 'Test process global | ' + - 'Test getRandomValues() | ', + 'Test getRandomValues() | ' + + 'Test X509Certificate', { headers: { "Content-Type": "text/html; charset=utf-8" } } ); }, }; +function testX509Certificate() { + try { + new nodeCrypto.X509Certificate(`-----BEGIN CERTIFICATE----- +MIICZjCCAc+gAwIBAgIUOsv8Y+x40C+gdNuu40N50KpGUhEwDQYJKoZIhvcNAQEL +BQAwRTELMAkGA1UEBhMCQVUxEzARBgNVBAgMClNvbWUtU3RhdGUxITAfBgNVBAoM +GEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZDAeFw0yNDA5MjAwOTA4MTNaFw0yNTA5 +MjAwOTA4MTNaMEUxCzAJBgNVBAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEw +HwYDVQQKDBhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQwgZ8wDQYJKoZIhvcNAQEB +BQADgY0AMIGJAoGBALpJn3dUrNmZhZV02RbjZKTd5j3hpgTncF4lG4Y3sQA18k0l +7pt6xpZuXYSFH7v2zTAxYy+uYyYwX2NZur48dZc76FSzIeuQdoTCkT0NacwFRTR5 +fEEqPvvB85ozYuyk8Bl3vSsonivOH3WftEDp9mjkHROQzS4wAZbIj7Cp+is/AgMB +AAGjUzBRMB0GA1UdDgQWBBSzFJSiPAw2tJOg8oUXrFBdqWI6zDAfBgNVHSMEGDAW +gBSzFJSiPAw2tJOg8oUXrFBdqWI6zDAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3 +DQEBCwUAA4GBACbto0+Ds40F7faRFFMwg5nPyh7gsiX+ZK3FYcrO3oxh5ejfzwow +DKOOje4Ncaw0rIkVpxacPyjg+wANuK2Nv/Z4CVAD3mneE4gwgRdn38q8IYN9AtSv +GzEf4UxiLBbUB6WRBgyVyquGfUMlKl/tnm4q0yeYQloYKSoHpGeHVJuN +-----END CERTIFICATE-----`); + return new Response(`"OK!"`); + } catch { + return new Response(`"KO!"`); + } +} + function testGetRandomValues() { assert( webcrypto.getRandomValues === getRandomValues, diff --git a/fixtures/nodejs-hybrid-app/tests/index.test.ts b/fixtures/nodejs-hybrid-app/tests/index.test.ts index 21caf8b5744a..43479998939f 100644 --- a/fixtures/nodejs-hybrid-app/tests/index.test.ts +++ b/fixtures/nodejs-hybrid-app/tests/index.test.ts @@ -1,6 +1,6 @@ import { resolve } from "node:path"; import { fetch } from "undici"; -import { describe, it } from "vitest"; +import { describe, it, test } from "vitest"; import { runWranglerDev } from "../../shared/src/run-wrangler-long-lived"; describe("nodejs compat", () => { @@ -48,4 +48,19 @@ describe("nodejs compat", () => { await stop(); } }); + + test("crypto.X509Certificate is implemented", async ({ expect }) => { + const { ip, port, stop } = await runWranglerDev( + resolve(__dirname, "../src"), + ["--port=0", "--inspector-port=0"] + ); + try { + const response = await fetch( + `http://${ip}:${port}/test-x509-certificate` + ); + await expect(response.text()).resolves.toBe(`"OK!"`); + } finally { + await stop(); + } + }); }); diff --git a/packages/wrangler/package.json b/packages/wrangler/package.json index ebb0e0240b66..586cd1a59f33 100644 --- a/packages/wrangler/package.json +++ b/packages/wrangler/package.json @@ -84,7 +84,7 @@ "resolve.exports": "^2.0.2", "selfsigned": "^2.0.1", "source-map": "^0.6.1", - "unenv": "npm:unenv-nightly@2.0.0-1726478054.1e87097", + "unenv": "npm:unenv-nightly@2.0.0-20240919-125358-9a64854", "workerd": "1.20240909.0", "xxhash-wasm": "^1.0.1" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4b70f4ab449d..ed3d93ed45f0 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -6,6 +6,12 @@ settings: catalogs: default: + '@vitest/runner': + specifier: ~2.1.1 + version: 2.1.1 + '@vitest/snapshot': + specifier: ~2.1.1 + version: 2.1.1 vitest: specifier: ~2.1.1 version: 2.1.1 @@ -1690,8 +1696,8 @@ importers: specifier: ^0.6.1 version: 0.6.1 unenv: - specifier: npm:unenv-nightly@2.0.0-1726478054.1e87097 - version: unenv-nightly@2.0.0-1726478054.1e87097 + specifier: npm:unenv-nightly@2.0.0-20240919-125358-9a64854 + version: unenv-nightly@2.0.0-20240919-125358-9a64854 workerd: specifier: 1.20240909.0 version: 1.20240909.0 @@ -6872,8 +6878,8 @@ packages: obuf@1.1.2: resolution: {integrity: sha512-PX1wu0AmAdPqOL1mWhqmlOd8kOIZQwGZw6rh7uby9fTc5lhaOWFLX3I6R1hrF9k3zUY40e6igsLGkDXK92LJNg==} - ohash@1.1.3: - resolution: {integrity: sha512-zuHHiGTYTA1sYJ/wZN+t5HKZaH23i4yI1HMwbuXm24Nid7Dv0KcuRlKoNKS9UNfAVSBlnGLcuQrnOKWOZoEGaw==} + ohash@1.1.4: + resolution: {integrity: sha512-FlDryZAahJmEF3VR3w1KogSEdWX3WhA5GPakFx4J81kEAiHyLMpdLLElS8n8dfNadMgAne/MywcvmogzscVt4g==} on-finished@2.4.1: resolution: {integrity: sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==} @@ -8409,8 +8415,8 @@ packages: resolution: {integrity: sha512-72RFADWFqKmUb2hmmvNODKL3p9hcB6Gt2DOQMis1SEBaV6a4MH8soBvzg+95CYhCKPFedut2JY9bMfrDl9D23g==} engines: {node: '>=14.0'} - unenv-nightly@2.0.0-1726478054.1e87097: - resolution: {integrity: sha512-uZso8dCkGlJzWQqkyjOA5L4aUqNJl9E9oKRm03V/d+URrg6rFMJwBonlX9AAq538NxwJpPnCX0gAz0IfTxsbFQ==} + unenv-nightly@2.0.0-20240919-125358-9a64854: + resolution: {integrity: sha512-XjsgUTrTHR7iw+k/SRTNjh6EQgwpC9voygnoCJo5kh4hKqsSDHUW84MhL9EsHTNfLctvVBHaSw8e2k3R2fKXsQ==} unicorn-magic@0.1.0: resolution: {integrity: sha512-lRfVq8fE8gz6QMBuDM6a+LO3IAzTi05H6gCVaUpir2E1Rwpo4ZUog45KpNXKC/Mn3Yb9UDuHumeFTo9iV/D9FQ==} @@ -14520,7 +14526,7 @@ snapshots: obuf@1.1.2: {} - ohash@1.1.3: {} + ohash@1.1.4: {} on-finished@2.4.1: dependencies: @@ -16127,10 +16133,10 @@ snapshots: dependencies: '@fastify/busboy': 2.1.1 - unenv-nightly@2.0.0-1726478054.1e87097: + unenv-nightly@2.0.0-20240919-125358-9a64854: dependencies: defu: 6.1.4 - ohash: 1.1.3 + ohash: 1.1.4 pathe: 1.1.2 ufo: 1.5.4