in src/bun.js/bindings/webcrypto/JSJsonWebKey.cpp [43:256]
template<> JsonWebKey convertDictionary<JsonWebKey>(JSGlobalObject& lexicalGlobalObject, JSValue value)
{
VM& vm = JSC::getVM(&lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
bool isNullOrUndefined = value.isUndefinedOrNull();
auto* object = isNullOrUndefined ? nullptr : value.getObject();
if (UNLIKELY(!isNullOrUndefined && !object)) {
throwTypeError(&lexicalGlobalObject, throwScope);
return {};
}
JsonWebKey result {};
JSValue algValue;
if (isNullOrUndefined)
algValue = jsUndefined();
else {
algValue = object->get(&lexicalGlobalObject, Identifier::fromString(vm, "alg"_s));
RETURN_IF_EXCEPTION(throwScope, {});
}
if (!algValue.isUndefined()) {
result.alg = convert<IDLDOMString>(lexicalGlobalObject, algValue);
RETURN_IF_EXCEPTION(throwScope, {});
}
JSValue crvValue;
if (isNullOrUndefined)
crvValue = jsUndefined();
else {
crvValue = object->get(&lexicalGlobalObject, Identifier::fromString(vm, "crv"_s));
RETURN_IF_EXCEPTION(throwScope, {});
}
if (!crvValue.isUndefined()) {
result.crv = convert<IDLDOMString>(lexicalGlobalObject, crvValue);
RETURN_IF_EXCEPTION(throwScope, {});
}
JSValue dValue;
if (isNullOrUndefined)
dValue = jsUndefined();
else {
dValue = object->get(&lexicalGlobalObject, Identifier::fromString(vm, "d"_s));
RETURN_IF_EXCEPTION(throwScope, {});
}
if (!dValue.isUndefined()) {
result.d = convert<IDLDOMString>(lexicalGlobalObject, dValue);
RETURN_IF_EXCEPTION(throwScope, {});
}
JSValue dpValue;
if (isNullOrUndefined)
dpValue = jsUndefined();
else {
dpValue = object->get(&lexicalGlobalObject, Identifier::fromString(vm, "dp"_s));
RETURN_IF_EXCEPTION(throwScope, {});
}
if (!dpValue.isUndefined()) {
result.dp = convert<IDLDOMString>(lexicalGlobalObject, dpValue);
RETURN_IF_EXCEPTION(throwScope, {});
}
JSValue dqValue;
if (isNullOrUndefined)
dqValue = jsUndefined();
else {
dqValue = object->get(&lexicalGlobalObject, Identifier::fromString(vm, "dq"_s));
RETURN_IF_EXCEPTION(throwScope, {});
}
if (!dqValue.isUndefined()) {
result.dq = convert<IDLDOMString>(lexicalGlobalObject, dqValue);
RETURN_IF_EXCEPTION(throwScope, {});
}
JSValue eValue;
if (isNullOrUndefined)
eValue = jsUndefined();
else {
eValue = object->get(&lexicalGlobalObject, Identifier::fromString(vm, "e"_s));
RETURN_IF_EXCEPTION(throwScope, {});
}
if (!eValue.isUndefined()) {
result.e = convert<IDLDOMString>(lexicalGlobalObject, eValue);
RETURN_IF_EXCEPTION(throwScope, {});
}
JSValue extValue;
if (isNullOrUndefined)
extValue = jsUndefined();
else {
extValue = object->get(&lexicalGlobalObject, Identifier::fromString(vm, "ext"_s));
RETURN_IF_EXCEPTION(throwScope, {});
}
if (!extValue.isUndefined()) {
result.ext = convert<IDLBoolean>(lexicalGlobalObject, extValue);
RETURN_IF_EXCEPTION(throwScope, {});
}
JSValue kValue;
if (isNullOrUndefined)
kValue = jsUndefined();
else {
kValue = object->get(&lexicalGlobalObject, Identifier::fromString(vm, "k"_s));
RETURN_IF_EXCEPTION(throwScope, {});
}
if (!kValue.isUndefined()) {
result.k = convert<IDLDOMString>(lexicalGlobalObject, kValue);
RETURN_IF_EXCEPTION(throwScope, {});
}
JSValue key_opsValue;
if (isNullOrUndefined)
key_opsValue = jsUndefined();
else {
key_opsValue = object->get(&lexicalGlobalObject, Identifier::fromString(vm, "key_ops"_s));
RETURN_IF_EXCEPTION(throwScope, {});
}
if (!key_opsValue.isUndefined()) {
result.key_ops = convert<IDLSequence<IDLEnumeration<CryptoKeyUsage>>>(lexicalGlobalObject, key_opsValue);
RETURN_IF_EXCEPTION(throwScope, {});
}
JSValue ktyValue;
if (isNullOrUndefined)
ktyValue = jsUndefined();
else {
ktyValue = object->get(&lexicalGlobalObject, Identifier::fromString(vm, "kty"_s));
RETURN_IF_EXCEPTION(throwScope, {});
}
if (!ktyValue.isUndefined()) {
result.kty = convert<IDLDOMString>(lexicalGlobalObject, ktyValue);
RETURN_IF_EXCEPTION(throwScope, {});
} else {
throwRequiredMemberTypeError(lexicalGlobalObject, throwScope, "kty"_s, "JsonWebKey"_s, "DOMString"_s);
return {};
}
JSValue nValue;
if (isNullOrUndefined)
nValue = jsUndefined();
else {
nValue = object->get(&lexicalGlobalObject, Identifier::fromString(vm, "n"_s));
RETURN_IF_EXCEPTION(throwScope, {});
}
if (!nValue.isUndefined()) {
result.n = convert<IDLDOMString>(lexicalGlobalObject, nValue);
RETURN_IF_EXCEPTION(throwScope, {});
}
JSValue othValue;
if (isNullOrUndefined)
othValue = jsUndefined();
else {
othValue = object->get(&lexicalGlobalObject, Identifier::fromString(vm, "oth"_s));
RETURN_IF_EXCEPTION(throwScope, {});
}
if (!othValue.isUndefined()) {
result.oth = convert<IDLSequence<IDLDictionary<RsaOtherPrimesInfo>>>(lexicalGlobalObject, othValue);
RETURN_IF_EXCEPTION(throwScope, {});
}
JSValue pValue;
if (isNullOrUndefined)
pValue = jsUndefined();
else {
pValue = object->get(&lexicalGlobalObject, Identifier::fromString(vm, "p"_s));
RETURN_IF_EXCEPTION(throwScope, {});
}
if (!pValue.isUndefined()) {
result.p = convert<IDLDOMString>(lexicalGlobalObject, pValue);
RETURN_IF_EXCEPTION(throwScope, {});
}
JSValue qValue;
if (isNullOrUndefined)
qValue = jsUndefined();
else {
qValue = object->get(&lexicalGlobalObject, Identifier::fromString(vm, "q"_s));
RETURN_IF_EXCEPTION(throwScope, {});
}
if (!qValue.isUndefined()) {
result.q = convert<IDLDOMString>(lexicalGlobalObject, qValue);
RETURN_IF_EXCEPTION(throwScope, {});
}
JSValue qiValue;
if (isNullOrUndefined)
qiValue = jsUndefined();
else {
qiValue = object->get(&lexicalGlobalObject, Identifier::fromString(vm, "qi"_s));
RETURN_IF_EXCEPTION(throwScope, {});
}
if (!qiValue.isUndefined()) {
result.qi = convert<IDLDOMString>(lexicalGlobalObject, qiValue);
RETURN_IF_EXCEPTION(throwScope, {});
}
JSValue useValue;
if (isNullOrUndefined)
useValue = jsUndefined();
else {
useValue = object->get(&lexicalGlobalObject, Identifier::fromString(vm, "use"_s));
RETURN_IF_EXCEPTION(throwScope, {});
}
if (!useValue.isUndefined()) {
result.use = convert<IDLDOMString>(lexicalGlobalObject, useValue);
RETURN_IF_EXCEPTION(throwScope, {});
}
JSValue xValue;
if (isNullOrUndefined)
xValue = jsUndefined();
else {
xValue = object->get(&lexicalGlobalObject, Identifier::fromString(vm, "x"_s));
RETURN_IF_EXCEPTION(throwScope, {});
}
if (!xValue.isUndefined()) {
result.x = convert<IDLDOMString>(lexicalGlobalObject, xValue);
RETURN_IF_EXCEPTION(throwScope, {});
}
JSValue yValue;
if (isNullOrUndefined)
yValue = jsUndefined();
else {
yValue = object->get(&lexicalGlobalObject, Identifier::fromString(vm, "y"_s));
RETURN_IF_EXCEPTION(throwScope, {});
}
if (!yValue.isUndefined()) {
result.y = convert<IDLDOMString>(lexicalGlobalObject, yValue);
RETURN_IF_EXCEPTION(throwScope, {});
}
return result;
}