Backed out changeset 2450366cf7ca (bug 1891629) for causing win msix mochitest failures
[gecko.git] / dom / webauthn / AuthenticatorAttestationResponse.h
blob04b28be397894ac4d94607617be428a3e988d5b7
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_AuthenticatorAttestationResponse_h
8 #define mozilla_dom_AuthenticatorAttestationResponse_h
10 #include "js/TypeDecls.h"
11 #include "mozilla/Attributes.h"
12 #include "mozilla/dom/AuthenticatorResponse.h"
13 #include "mozilla/dom/BindingDeclarations.h"
14 #include "mozilla/dom/WebAuthenticationBinding.h"
15 #include "nsCycleCollectionParticipant.h"
16 #include "nsIWebAuthnAttObj.h"
17 #include "nsWrapperCache.h"
19 namespace mozilla::dom {
21 class AuthenticatorAttestationResponse final : public AuthenticatorResponse {
22 public:
23 NS_DECL_ISUPPORTS_INHERITED
24 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(
25 AuthenticatorAttestationResponse, AuthenticatorResponse)
27 explicit AuthenticatorAttestationResponse(nsPIDOMWindowInner* aParent);
29 protected:
30 ~AuthenticatorAttestationResponse() override;
32 public:
33 virtual JSObject* WrapObject(JSContext* aCx,
34 JS::Handle<JSObject*> aGivenProto) override;
36 void GetAttestationObject(JSContext* aCx, JS::MutableHandle<JSObject*> aValue,
37 ErrorResult& aRv);
39 void SetAttestationObject(const nsTArray<uint8_t>& aBuffer);
41 void GetTransports(nsTArray<nsString>& aTransports);
43 void SetTransports(const nsTArray<nsString>& aTransports);
45 void GetAuthenticatorData(JSContext* aCx, JS::MutableHandle<JSObject*> aValue,
46 ErrorResult& aRv);
48 void GetPublicKey(JSContext* aCx, JS::MutableHandle<JSObject*> aValue,
49 ErrorResult& aRv);
51 COSEAlgorithmIdentifier GetPublicKeyAlgorithm(ErrorResult& aRv);
53 void ToJSON(AuthenticatorAttestationResponseJSON& aJSON, ErrorResult& aError);
55 private:
56 nsresult GetAuthenticatorDataBytes(nsTArray<uint8_t>& aAuthenticatorData);
57 nsresult GetPublicKeyBytes(nsTArray<uint8_t>& aPublicKeyBytes);
59 nsTArray<uint8_t> mAttestationObject;
60 nsCOMPtr<nsIWebAuthnAttObj> mAttestationObjectParsed;
61 JS::Heap<JSObject*> mAttestationObjectCachedObj;
62 nsTArray<nsString> mTransports;
65 } // namespace mozilla::dom
67 #endif // mozilla_dom_AuthenticatorAttestationResponse_h