/* * Copyright (c) 2021-2022, Linus Groh * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include #include // FIXME: Generate these from IDL namespace Web::Bindings { // https://w3c.github.io/webcrypto/#dfn-Algorithm struct Algorithm { String name; }; }; namespace Web::Crypto { class SubtleCrypto final : public Bindings::PlatformObject { WEB_PLATFORM_OBJECT(SubtleCrypto, Bindings::PlatformObject); JS_DECLARE_ALLOCATOR(SubtleCrypto); using SupportedAlgorithmsMap = HashMap>; public: [[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); }; }