aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-10-26 15:28:12 -0700
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-10-26 15:28:27 -0700
commite0feff22c90983d8dce1f88486724f851b327dd5 (patch)
tree62548f35f3f975219c7096a1cf2be4012e24f276
parent44ff09015cb074e1d0e7dd11840b6bce81b6a538 (diff)
downloadbun-e0feff22c90983d8dce1f88486724f851b327dd5.tar.gz
bun-e0feff22c90983d8dce1f88486724f851b327dd5.tar.zst
bun-e0feff22c90983d8dce1f88486724f851b327dd5.zip
Fix issue with `CryptoKey` and `SubtleCrypto` constructors
-rw-r--r--src/bun.js/bindings/ZigGlobalObject.cpp35
-rw-r--r--src/bun.js/bindings/webcore/DOMConstructors.h2
2 files changed, 10 insertions, 27 deletions
diff --git a/src/bun.js/bindings/ZigGlobalObject.cpp b/src/bun.js/bindings/ZigGlobalObject.cpp
index 7918e9197..42e412f9c 100644
--- a/src/bun.js/bindings/ZigGlobalObject.cpp
+++ b/src/bun.js/bindings/ZigGlobalObject.cpp
@@ -1270,26 +1270,18 @@ JSC_DEFINE_CUSTOM_GETTER(jsServiceWorkerGlobalScope_WritableStreamDefaultWriterC
return IDLAttribute<Zig::GlobalObject>::get<jsServiceWorkerGlobalScope_WritableStreamDefaultWriterConstructorGetter>(*lexicalGlobalObject, thisValue, attributeName);
}
-static inline JSValue getterSubtleCryptoBodyConstructor(JSGlobalObject& lexicalGlobalObject, Zig::GlobalObject& thisObject)
-{
- UNUSED_PARAM(lexicalGlobalObject);
- return JSSubtleCrypto::getConstructor(JSC::getVM(&lexicalGlobalObject), &thisObject);
-}
-
JSC_DEFINE_CUSTOM_GETTER(getterSubtleCryptoConstructor, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
- return IDLAttribute<Zig::GlobalObject>::get<getterSubtleCryptoBodyConstructor>(*lexicalGlobalObject, thisValue, attributeName);
-}
-
-static inline JSValue getterCryptoKeyBodyConstructor(JSGlobalObject& lexicalGlobalObject, Zig::GlobalObject& thisObject)
-{
- UNUSED_PARAM(lexicalGlobalObject);
- return JSCryptoKey::getConstructor(JSC::getVM(&lexicalGlobalObject), &thisObject);
+ Zig::GlobalObject* thisObject = JSC::jsCast<Zig::GlobalObject*>(lexicalGlobalObject);
+ return JSValue::encode(
+ JSSubtleCrypto::getConstructor(thisObject->vm(), thisObject));
}
JSC_DEFINE_CUSTOM_GETTER(getterCryptoKeyConstructor, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
- return IDLAttribute<Zig::GlobalObject>::get<getterCryptoKeyBodyConstructor>(*lexicalGlobalObject, thisValue, attributeName);
+ Zig::GlobalObject* thisObject = JSC::jsCast<Zig::GlobalObject*>(lexicalGlobalObject);
+ return JSValue::encode(
+ JSCryptoKey::getConstructor(thisObject->vm(), thisObject));
}
static inline JSValue getterSubtleCryptoBody(JSGlobalObject& lexicalGlobalObject, Zig::GlobalObject& thisObject)
@@ -2405,18 +2397,6 @@ void GlobalObject::addBuiltinGlobals(JSC::VM& vm)
"atob"_s, functionATOB, ImplementationVisibility::Public),
JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DontDelete | 0 });
- JSC::Identifier SubtleCryptoIdentifier = JSC::Identifier::fromString(vm, "SubtleCrypto"_s);
- extraStaticGlobals.uncheckedAppend(
- GlobalPropertyInfo { SubtleCryptoIdentifier,
- JSC::CustomGetterSetter::create(vm, getterSubtleCryptoConstructor, nullptr),
- JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontDelete | 0 });
-
- JSC::Identifier CryptoKeyIdentifier = JSC::Identifier::fromString(vm, "CryptoKey"_s);
- extraStaticGlobals.uncheckedAppend(
- GlobalPropertyInfo { CryptoKeyIdentifier,
- JSC::CustomGetterSetter::create(vm, getterCryptoKeyConstructor, nullptr),
- JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontDelete | 0 });
-
JSC::Identifier btoaIdentifier = JSC::Identifier::fromString(vm, "btoa"_s);
extraStaticGlobals.uncheckedAppend(
GlobalPropertyInfo { btoaIdentifier,
@@ -2581,6 +2561,9 @@ void GlobalObject::addBuiltinGlobals(JSC::VM& vm)
putDirectCustomAccessor(vm, JSC::Identifier::fromString(vm, "ByteLengthQueuingStrategy"_s), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_ByteLengthQueuingStrategyConstructor, nullptr), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly);
putDirectCustomAccessor(vm, JSC::Identifier::fromString(vm, "CountQueuingStrategy"_s), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_CountQueuingStrategyConstructor, nullptr), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly);
+ putDirectCustomAccessor(vm, JSC::Identifier::fromString(vm, "SubtleCrypto"_s), JSC::CustomGetterSetter::create(vm, getterSubtleCryptoConstructor, nullptr), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly);
+ putDirectCustomAccessor(vm, JSC::Identifier::fromString(vm, "CryptoKey"_s), JSC::CustomGetterSetter::create(vm, getterCryptoKeyConstructor, nullptr), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly);
+
// putDirect(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().nativeReadableStreamPrototypePrivateName(), jsUndefined(), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::DontEnum | 0);
}
diff --git a/src/bun.js/bindings/webcore/DOMConstructors.h b/src/bun.js/bindings/webcore/DOMConstructors.h
index 296eb1e4d..dc38fedcd 100644
--- a/src/bun.js/bindings/webcore/DOMConstructors.h
+++ b/src/bun.js/bindings/webcore/DOMConstructors.h
@@ -861,7 +861,7 @@ enum class DOMConstructorID : uint16_t {
static constexpr unsigned numberOfDOMConstructorsBase = 846;
-static constexpr unsigned bunExtraConstructors = 1;
+static constexpr unsigned bunExtraConstructors = 2;
static constexpr unsigned numberOfDOMConstructors = numberOfDOMConstructorsBase + bunExtraConstructors;