ladybird/Libraries/LibWeb/Crypto/Crypto.h
Shannon Booth 97abc707c7 LibWeb/Bindings: Generate buffer typedefs as variants
Represent BufferSource and ArrayBufferView as ordinary IDL typedefs over
their underlying union types, instead of special casing in the IDL
generator. This allows the union conversion/return machinery handle
these types consistently with other typedefs, which removes buffer
specific paths from the IDL generator.

This necessitates changing the WebIDL::BufferSource and
WebIDL::ArrayBufferView classes as views over these variants. This
replaces the old GC backed BufferableObject wrapper structure and
provide convenience helpers to determine things such as the byte length,
byte offset, backing buffer, and typed-array APIs.
2026-05-30 11:22:08 +02:00

44 lines
1 KiB
C++

/*
* Copyright (c) 2021, Idan Horowitz <idan.horowitz@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibWeb/Bindings/PlatformObject.h>
#include <LibWeb/Crypto/SubtleCrypto.h>
#include <LibWeb/Export.h>
#include <LibWeb/WebIDL/Buffers.h>
#include <LibWeb/WebIDL/ExceptionOr.h>
namespace Web::Crypto {
class Crypto : public Bindings::PlatformObject {
WEB_PLATFORM_OBJECT(Crypto, Bindings::PlatformObject);
GC_DECLARE_ALLOCATOR(Crypto);
public:
[[nodiscard]] static GC::Ref<Crypto> create(JS::Realm&);
virtual ~Crypto() override;
GC::Ref<SubtleCrypto> subtle() const;
WebIDL::ExceptionOr<WebIDL::ArrayBufferViewVariant> get_random_values(WebIDL::ArrayBufferViewVariant array) const;
String random_uuid() const;
protected:
virtual void initialize(JS::Realm&) override;
virtual void visit_edges(Cell::Visitor&) override;
private:
explicit Crypto(JS::Realm&);
GC::Ptr<SubtleCrypto> m_subtle;
};
WEB_API String generate_random_uuid();
}