2021-09-30 20:02:55 +03:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2021, Idan Horowitz <idan.horowitz@serenityos.org>
|
|
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2022-09-04 13:15:05 +02:00
|
|
|
#include <LibWeb/Bindings/PlatformObject.h>
|
2021-12-13 20:48:27 +00:00
|
|
|
#include <LibWeb/Crypto/SubtleCrypto.h>
|
2022-09-25 17:03:42 +01:00
|
|
|
#include <LibWeb/WebIDL/ExceptionOr.h>
|
2021-09-30 20:02:55 +03:00
|
|
|
|
|
|
|
|
namespace Web::Crypto {
|
|
|
|
|
|
2022-09-04 13:15:05 +02:00
|
|
|
class Crypto : public Bindings::PlatformObject {
|
|
|
|
|
WEB_PLATFORM_OBJECT(Crypto, Bindings::PlatformObject);
|
2024-11-15 04:01:23 +13:00
|
|
|
GC_DECLARE_ALLOCATOR(Crypto);
|
2022-09-04 13:15:05 +02:00
|
|
|
|
2021-09-30 20:02:55 +03:00
|
|
|
public:
|
2024-11-15 04:01:23 +13:00
|
|
|
[[nodiscard]] static GC::Ref<Crypto> create(JS::Realm&);
|
2021-09-30 20:02:55 +03:00
|
|
|
|
2022-09-04 13:15:05 +02:00
|
|
|
virtual ~Crypto() override;
|
2021-09-30 20:02:55 +03:00
|
|
|
|
2024-11-15 04:01:23 +13:00
|
|
|
GC::Ref<SubtleCrypto> subtle() const;
|
2021-12-13 20:48:27 +00:00
|
|
|
|
2024-11-15 04:01:23 +13:00
|
|
|
WebIDL::ExceptionOr<GC::Root<WebIDL::ArrayBufferView>> get_random_values(GC::Root<WebIDL::ArrayBufferView>) const;
|
2023-02-23 18:58:56 +01:00
|
|
|
WebIDL::ExceptionOr<String> random_uuid() const;
|
2021-09-30 20:02:55 +03:00
|
|
|
|
2022-09-13 01:23:28 +02:00
|
|
|
protected:
|
2023-08-07 08:41:28 +02:00
|
|
|
virtual void initialize(JS::Realm&) override;
|
2022-09-13 01:23:28 +02:00
|
|
|
virtual void visit_edges(Cell::Visitor&) override;
|
|
|
|
|
|
2021-09-30 20:02:55 +03:00
|
|
|
private:
|
LibWeb: Remove unecessary dependence on Window from assorted classes
These classes only needed Window to get at its realm. Pass a realm
directly to construct Crypto, Encoding, HRT, IntersectionObserver,
NavigationTiming, Page, RequestIdleCallback, Selection, Streams, URL,
and XML classes.
2022-09-25 18:11:21 -06:00
|
|
|
explicit Crypto(JS::Realm&);
|
2021-12-13 20:48:27 +00:00
|
|
|
|
2024-11-15 04:01:23 +13:00
|
|
|
GC::Ptr<SubtleCrypto> m_subtle;
|
2021-09-30 20:02:55 +03:00
|
|
|
};
|
|
|
|
|
|
2023-03-13 16:22:07 +03:00
|
|
|
ErrorOr<String> generate_random_uuid();
|
|
|
|
|
|
2021-09-30 20:02:55 +03:00
|
|
|
}
|