From d433a1ada0790d060d0227edffa36e81abfb99fa Mon Sep 17 00:00:00 2001 From: saklani <50768838+saklani@users.noreply.github.com> Date: Sat, 30 Mar 2024 10:23:52 +0530 Subject: [PATCH] fix: Define missing crypto.constants defined on Node (#9511) * define crypto.constants * requested changes * fix: missing jsNumber wrap --------- Co-authored-by: Georgijs <48869301+gvilums@users.noreply.github.com> --- src/bun.js/bindings/ProcessBindingConstants.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/bun.js/bindings/ProcessBindingConstants.cpp b/src/bun.js/bindings/ProcessBindingConstants.cpp index a029ed3a43..8db61a6e72 100644 --- a/src/bun.js/bindings/ProcessBindingConstants.cpp +++ b/src/bun.js/bindings/ProcessBindingConstants.cpp @@ -907,18 +907,26 @@ static JSValue processBindingConstantsGetCrypto(VM& vm, JSObject* bindingObject) #endif #ifdef RSA_X931_PADDING object->putDirect(vm, PropertyName(Identifier::fromString(vm, "RSA_X931_PADDING"_s)), jsNumber(RSA_X931_PADDING)); +#else + object->putDirect(vm, PropertyName(Identifier::fromString(vm, "RSA_X931_PADDING"_s)), jsNumber(5)); #endif #ifdef RSA_PKCS1_PSS_PADDING object->putDirect(vm, PropertyName(Identifier::fromString(vm, "RSA_PKCS1_PSS_PADDING"_s)), jsNumber(RSA_PKCS1_PSS_PADDING)); #endif #ifdef RSA_PSS_SALTLEN_DIGEST object->putDirect(vm, PropertyName(Identifier::fromString(vm, "RSA_PSS_SALTLEN_DIGEST"_s)), jsNumber(RSA_PSS_SALTLEN_DIGEST)); +#else + object->putDirect(vm, PropertyName(Identifier::fromString(vm, "RSA_PSS_SALTLEN_DIGEST"_s)), jsNumber(-1)); #endif #ifdef RSA_PSS_SALTLEN_MAX_SIGN object->putDirect(vm, PropertyName(Identifier::fromString(vm, "RSA_PSS_SALTLEN_MAX_SIGN"_s)), jsNumber(RSA_PSS_SALTLEN_MAX_SIGN)); +#else + object->putDirect(vm, PropertyName(Identifier::fromString(vm, "RSA_PSS_SALTLEN_MAX_SIGN"_s)), jsNumber(-2)); #endif #ifdef RSA_PSS_SALTLEN_AUTO object->putDirect(vm, PropertyName(Identifier::fromString(vm, "RSA_PSS_SALTLEN_AUTO"_s)), jsNumber(RSA_PSS_SALTLEN_AUTO)); +#else + object->putDirect(vm, PropertyName(Identifier::fromString(vm, "RSA_PSS_SALTLEN_AUTO"_s)), jsNumber(-2)); #endif auto cipherList = String("TLS_AES_256_GCM_SHA384:" "TLS_CHACHA20_POLY1305_SHA256:"