summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/Crypto/Crypto.h
blob: 2573bbb3441e7999ed40a2cd9f20e5f2c7ffe770 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/*
 * 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/WebIDL/ExceptionOr.h>

namespace Web::Crypto {

class Crypto : public Bindings::PlatformObject {
    WEB_PLATFORM_OBJECT(Crypto, Bindings::PlatformObject);

public:
    static JS::NonnullGCPtr<Crypto> create(JS::Realm&);

    virtual ~Crypto() override;

    JS::NonnullGCPtr<SubtleCrypto> subtle() const;

    WebIDL::ExceptionOr<JS::Value> get_random_values(JS::Value array) const;
    DeprecatedString random_uuid() const;

protected:
    virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
    virtual void visit_edges(Cell::Visitor&) override;

private:
    explicit Crypto(JS::Realm&);

    JS::GCPtr<SubtleCrypto> m_subtle;
};

}