LibWeb: Add and use new name() helper on HashAlgorithmIdentifier

This commit is contained in:
stelar7 2024-04-09 09:27:53 +02:00 committed by Andreas Kling
commit 3b423f1852
Notes: github-actions[bot] 2024-10-27 10:32:17 +00:00
2 changed files with 22 additions and 25 deletions

View file

@ -20,10 +20,25 @@
namespace Web::Crypto {
using AlgorithmIdentifier = Variant<JS::Handle<JS::Object>, String>;
using HashAlgorithmIdentifier = AlgorithmIdentifier;
using NamedCurve = String;
using KeyDataType = Variant<JS::Handle<WebIDL::BufferSource>, Bindings::JsonWebKey>;
struct HashAlgorithmIdentifier : public AlgorithmIdentifier {
using AlgorithmIdentifier::AlgorithmIdentifier;
JS::ThrowCompletionOr<String> name(JS::VM& vm) const
{
auto value = visit(
[](String const& name) -> JS::ThrowCompletionOr<String> { return name; },
[&](JS::Handle<JS::Object> const& obj) -> JS::ThrowCompletionOr<String> {
auto name_property = TRY(obj->get("name"));
return name_property.to_string(vm);
});
return value;
}
};
// https://w3c.github.io/webcrypto/#algorithm-overview
struct AlgorithmParams {
virtual ~AlgorithmParams();