Crypto.h 962 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*
  2. * Copyright (c) 2021, Idan Horowitz <idan.horowitz@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <LibWeb/Bindings/PlatformObject.h>
  8. #include <LibWeb/Crypto/SubtleCrypto.h>
  9. #include <LibWeb/WebIDL/ExceptionOr.h>
  10. namespace Web::Crypto {
  11. class Crypto : public Bindings::PlatformObject {
  12. WEB_PLATFORM_OBJECT(Crypto, Bindings::PlatformObject);
  13. public:
  14. static WebIDL::ExceptionOr<JS::NonnullGCPtr<Crypto>> create(JS::Realm&);
  15. virtual ~Crypto() override;
  16. JS::NonnullGCPtr<SubtleCrypto> subtle() const;
  17. WebIDL::ExceptionOr<JS::Value> get_random_values(JS::Value array) const;
  18. WebIDL::ExceptionOr<String> random_uuid() const;
  19. protected:
  20. virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
  21. virtual void visit_edges(Cell::Visitor&) override;
  22. private:
  23. explicit Crypto(JS::Realm&);
  24. JS::GCPtr<SubtleCrypto> m_subtle;
  25. };
  26. ErrorOr<String> generate_random_uuid();
  27. }