From 57db380fc43852138c7f7d2b8997cb0def4eb9eb Mon Sep 17 00:00:00 2001 From: Yagiz Nizipli Date: Wed, 18 Sep 2024 14:37:20 -0400 Subject: [PATCH] add missing Certificate to crypto export default (#2739) --- src/node/crypto.ts | 2 ++ src/workerd/api/node/tests/crypto_x509-test.js | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/src/node/crypto.ts b/src/node/crypto.ts index 06eb9af62a6..9c3231f34d1 100644 --- a/src/node/crypto.ts +++ b/src/node/crypto.ts @@ -239,6 +239,8 @@ export default { // WebCrypto subtle, webcrypto, + // Spkac + Certificate, // X509 X509Certificate, }; diff --git a/src/workerd/api/node/tests/crypto_x509-test.js b/src/workerd/api/node/tests/crypto_x509-test.js index b82c7d55b01..4566b13eae6 100644 --- a/src/workerd/api/node/tests/crypto_x509-test.js +++ b/src/workerd/api/node/tests/crypto_x509-test.js @@ -29,6 +29,7 @@ import { deepStrictEqual, ok, strictEqual, throws } from 'node:assert'; import { Buffer } from 'node:buffer'; +import assert from 'node:assert'; import { X509Certificate, PublicKeyObject } from 'node:crypto'; @@ -348,3 +349,11 @@ export const test_ok = { // throws(() => new X509Certificate(badCert)); // } // }; + +// Ref: https://github.com/unjs/unenv/pull/310 +export const shouldImportCertificate = { + test() { + // This is allowed by Node.js as well. + assert(process.getBuiltinModule('crypto').Certificate); + }, +};