Crypto.h 872 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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 <LibJS/Runtime/Value.h>
  8. #include <LibWeb/Bindings/Wrappable.h>
  9. #include <LibWeb/Crypto/SubtleCrypto.h>
  10. #include <LibWeb/DOM/ExceptionOr.h>
  11. namespace Web::Crypto {
  12. class Crypto : public Bindings::Wrappable
  13. , public RefCounted<Crypto>
  14. , public Weakable<Crypto> {
  15. public:
  16. using WrapperType = Bindings::CryptoWrapper;
  17. static NonnullRefPtr<Crypto> create()
  18. {
  19. return adopt_ref(*new Crypto());
  20. }
  21. NonnullRefPtr<SubtleCrypto> subtle() const { return m_subtle; }
  22. DOM::ExceptionOr<JS::Value> get_random_values(JS::Value array) const;
  23. private:
  24. Crypto();
  25. NonnullRefPtr<SubtleCrypto> m_subtle;
  26. };
  27. }
  28. namespace Web::Bindings {
  29. CryptoWrapper* wrap(JS::GlobalObject&, Crypto::Crypto&);
  30. }