/* * Copyright (c) 2021-2022, Linus Groh * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include #include namespace Web::Crypto { class SubtleCrypto final : public Bindings::PlatformObject { WEB_PLATFORM_OBJECT(SubtleCrypto, Bindings::PlatformObject); JS_DECLARE_ALLOCATOR(SubtleCrypto); using SupportedAlgorithmsMap = HashMap>; public: struct Algorithm { String name; }; [[nodiscard]] static JS::NonnullGCPtr create(JS::Realm&); virtual ~SubtleCrypto() override; JS::NonnullGCPtr digest(Variant, String> const& algorithm, JS::Handle const& data); private: explicit SubtleCrypto(JS::Realm&); virtual void initialize(JS::Realm&) override; JS::ThrowCompletionOr normalize_an_algorithm(Variant, String> const& algorithm, String operation); static SubtleCrypto::SupportedAlgorithmsMap& supported_algorithms_internal(); static SubtleCrypto::SupportedAlgorithmsMap supported_algorithms(); static void define_an_algorithm(String op, String algorithm, String type); }; }