1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 09:28:11 +00:00

LibWeb: Implement usages property for CryptoKey

And set it from the only place we currently create a CryptoKey, in
importKey.
This commit is contained in:
Andrew Kaster 2024-03-06 19:11:08 -07:00 committed by Andrew Kaster
parent 2d59d6c98c
commit 0a6f195a71
5 changed files with 27 additions and 6 deletions

View file

@ -6,6 +6,7 @@
*/
#include <AK/Memory.h>
#include <LibJS/Runtime/Array.h>
#include <LibWeb/Crypto/CryptoKey.h>
namespace Web::Crypto {
@ -45,4 +46,13 @@ void CryptoKey::visit_edges(Visitor& visitor)
visitor.visit(m_usages);
}
void CryptoKey::set_usages(Vector<Bindings::KeyUsage> usages)
{
m_key_usages = move(usages);
auto& realm = this->realm();
m_usages = JS::Array::create_from<Bindings::KeyUsage>(realm, m_key_usages.span(), [&](auto& key_usage) -> JS::Value {
return JS::PrimitiveString::create(realm.vm(), Bindings::idl_enum_to_string(key_usage));
});
}
}