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);
|
|
|
|
|
|
2021-09-30 20:02:55 +03:00
|
|
|
public:
|
2023-02-12 21:21:12 +01:00
|
|
|
static WebIDL::ExceptionOr<JS::NonnullGCPtr<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
|
|
|
|
2022-09-03 19:59:53 +02:00
|
|
|
JS::NonnullGCPtr<SubtleCrypto> subtle() const;
|
2021-12-13 20:48:27 +00:00
|
|
|
|
2022-09-25 17:03:42 +01:00
|
|
|
WebIDL::ExceptionOr<JS::Value> get_random_values(JS::Value array) 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-01-28 12:33:35 -05:00
|
|
|
virtual JS::ThrowCompletionOr<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
|
|
|
|
2022-09-04 13:15:05 +02:00
|
|
|
JS::GCPtr<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
|
|
|
}
|