Bug 1854550 - pt 10. Allow LOG() with zero extra arguments r=glandium
[gecko.git] / dom / webauthn / PublicKeyCredential.h
blob195e27cccf5dcc8d9130183809afba34f76f04f3
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_PublicKeyCredential_h
8 #define mozilla_dom_PublicKeyCredential_h
10 #include "js/TypeDecls.h"
11 #include "mozilla/Attributes.h"
12 #include "mozilla/dom/AuthenticatorAssertionResponse.h"
13 #include "mozilla/dom/AuthenticatorAttestationResponse.h"
14 #include "mozilla/dom/BindingDeclarations.h"
15 #include "mozilla/dom/Credential.h"
16 #include "nsCycleCollectionParticipant.h"
17 #include "nsWrapperCache.h"
19 namespace mozilla::dom {
21 class PublicKeyCredential final : public Credential {
22 public:
23 NS_DECL_ISUPPORTS_INHERITED
24 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(PublicKeyCredential,
25 Credential)
27 explicit PublicKeyCredential(nsPIDOMWindowInner* aParent);
29 protected:
30 ~PublicKeyCredential() override;
32 public:
33 virtual JSObject* WrapObject(JSContext* aCx,
34 JS::Handle<JSObject*> aGivenProto) override;
36 void GetRawId(JSContext* aCx, JS::MutableHandle<JSObject*> aValue,
37 ErrorResult& aRv);
39 void GetAuthenticatorAttachment(DOMString& aAuthenticatorAttachment);
41 already_AddRefed<AuthenticatorResponse> Response() const;
43 void SetRawId(const nsTArray<uint8_t>& aBuffer);
45 void SetAuthenticatorAttachment(
46 const Maybe<nsString>& aAuthenticatorAttachment);
48 void SetAttestationResponse(
49 const RefPtr<AuthenticatorAttestationResponse>& aAttestationResponse);
50 void SetAssertionResponse(
51 const RefPtr<AuthenticatorAssertionResponse>& aAssertionResponse);
53 static already_AddRefed<Promise>
54 IsUserVerifyingPlatformAuthenticatorAvailable(GlobalObject& aGlobal,
55 ErrorResult& aError);
57 static already_AddRefed<Promise> IsConditionalMediationAvailable(
58 GlobalObject& aGlobal, ErrorResult& aError);
60 static already_AddRefed<Promise> IsExternalCTAP2SecurityKeySupported(
61 GlobalObject& aGlobal, ErrorResult& aError);
63 void GetClientExtensionResults(
64 AuthenticationExtensionsClientOutputs& aResult);
66 void ToJSON(JSContext* aCx, JS::MutableHandle<JSObject*> aRetval,
67 ErrorResult& aError);
69 void SetClientExtensionResultAppId(bool aResult);
71 void SetClientExtensionResultCredPropsRk(bool aResult);
73 void SetClientExtensionResultHmacSecret(bool aHmacCreateSecret);
75 static void ParseCreationOptionsFromJSON(
76 GlobalObject& aGlobal,
77 const PublicKeyCredentialCreationOptionsJSON& aOptions,
78 PublicKeyCredentialCreationOptions& aResult, ErrorResult& aRv);
80 static void ParseRequestOptionsFromJSON(
81 GlobalObject& aGlobal,
82 const PublicKeyCredentialRequestOptionsJSON& aOptions,
83 PublicKeyCredentialRequestOptions& aResult, ErrorResult& aRv);
85 private:
86 nsTArray<uint8_t> mRawId;
87 JS::Heap<JSObject*> mRawIdCachedObj;
88 Maybe<nsString> mAuthenticatorAttachment;
89 RefPtr<AuthenticatorAttestationResponse> mAttestationResponse;
90 RefPtr<AuthenticatorAssertionResponse> mAssertionResponse;
91 AuthenticationExtensionsClientOutputs mClientExtensionOutputs;
94 } // namespace mozilla::dom
96 #endif // mozilla_dom_PublicKeyCredential_h