Bug 1665252 - remove allowpaymentrequest attribute from HTMLIFrameElement r=dom-worke...
[gecko.git] / dom / base / SubtleCrypto.h
blob6d492df25c235fd5f6fe993c8a50e5a407d8223c
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_dom_SubtleCrypto_h
8 #define mozilla_dom_SubtleCrypto_h
10 #include "nsCycleCollectionParticipant.h"
11 #include "nsWrapperCache.h"
12 #include "nsIGlobalObject.h"
13 #include "mozilla/dom/CryptoKey.h"
14 #include "js/TypeDecls.h"
16 namespace mozilla {
17 namespace dom {
19 class ObjectOrString;
20 class Promise;
22 typedef ArrayBufferViewOrArrayBuffer CryptoOperationData;
24 class SubtleCrypto final : public nsISupports, public nsWrapperCache {
25 ~SubtleCrypto() = default;
27 public:
28 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
29 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(SubtleCrypto)
31 public:
32 explicit SubtleCrypto(nsIGlobalObject* aParent);
34 nsIGlobalObject* GetParentObject() const { return mParent; }
36 virtual JSObject* WrapObject(JSContext* aCx,
37 JS::Handle<JSObject*> aGivenProto) override;
39 already_AddRefed<Promise> Encrypt(JSContext* cx,
40 const ObjectOrString& algorithm,
41 CryptoKey& key,
42 const CryptoOperationData& data,
43 ErrorResult& aRv);
45 already_AddRefed<Promise> Decrypt(JSContext* cx,
46 const ObjectOrString& algorithm,
47 CryptoKey& key,
48 const CryptoOperationData& data,
49 ErrorResult& aRv);
51 already_AddRefed<Promise> Sign(JSContext* cx, const ObjectOrString& algorithm,
52 CryptoKey& key,
53 const CryptoOperationData& data,
54 ErrorResult& aRv);
56 already_AddRefed<Promise> Verify(JSContext* cx,
57 const ObjectOrString& algorithm,
58 CryptoKey& key,
59 const CryptoOperationData& signature,
60 const CryptoOperationData& data,
61 ErrorResult& aRv);
63 already_AddRefed<Promise> Digest(JSContext* cx,
64 const ObjectOrString& aAlgorithm,
65 const CryptoOperationData& aData,
66 ErrorResult& aRv);
68 already_AddRefed<Promise> ImportKey(JSContext* cx, const nsAString& format,
69 JS::Handle<JSObject*> keyData,
70 const ObjectOrString& algorithm,
71 bool extractable,
72 const Sequence<nsString>& keyUsages,
73 ErrorResult& aRv);
75 already_AddRefed<Promise> ExportKey(const nsAString& format, CryptoKey& key,
76 ErrorResult& aRv);
78 already_AddRefed<Promise> GenerateKey(JSContext* cx,
79 const ObjectOrString& algorithm,
80 bool extractable,
81 const Sequence<nsString>& keyUsages,
82 ErrorResult& aRv);
84 already_AddRefed<Promise> DeriveKey(
85 JSContext* cx, const ObjectOrString& algorithm, CryptoKey& baseKey,
86 const ObjectOrString& derivedKeyType, bool extractable,
87 const Sequence<nsString>& keyUsages, ErrorResult& aRv);
89 already_AddRefed<Promise> DeriveBits(JSContext* cx,
90 const ObjectOrString& algorithm,
91 CryptoKey& baseKey, uint32_t length,
92 ErrorResult& aRv);
94 already_AddRefed<Promise> WrapKey(JSContext* cx, const nsAString& format,
95 CryptoKey& key, CryptoKey& wrappingKey,
96 const ObjectOrString& wrapAlgorithm,
97 ErrorResult& aRv);
99 already_AddRefed<Promise> UnwrapKey(
100 JSContext* cx, const nsAString& format,
101 const ArrayBufferViewOrArrayBuffer& wrappedKey, CryptoKey& unwrappingKey,
102 const ObjectOrString& unwrapAlgorithm,
103 const ObjectOrString& unwrappedKeyAlgorithm, bool extractable,
104 const Sequence<nsString>& keyUsages, ErrorResult& aRv);
106 private:
107 nsCOMPtr<nsIGlobalObject> mParent;
110 } // namespace dom
111 } // namespace mozilla
113 #endif // mozilla_dom_SubtleCrypto_h