tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

PublicKeyCredential.h (4398B)


      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/. */
      6 
      7 #ifndef mozilla_dom_PublicKeyCredential_h
      8 #define mozilla_dom_PublicKeyCredential_h
      9 
     10 #include "js/TypeDecls.h"
     11 #include "mozilla/dom/AuthenticatorAssertionResponse.h"
     12 #include "mozilla/dom/AuthenticatorAttestationResponse.h"
     13 #include "mozilla/dom/BindingDeclarations.h"
     14 #include "mozilla/dom/Credential.h"
     15 #include "nsCycleCollectionParticipant.h"
     16 #include "nsWrapperCache.h"
     17 
     18 namespace mozilla::dom {
     19 
     20 class PublicKeyCredential final : public Credential {
     21 public:
     22  NS_DECL_ISUPPORTS_INHERITED
     23  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(PublicKeyCredential,
     24                                                         Credential)
     25 
     26  explicit PublicKeyCredential(nsPIDOMWindowInner* aParent);
     27 
     28 protected:
     29  ~PublicKeyCredential() override;
     30 
     31 public:
     32  virtual JSObject* WrapObject(JSContext* aCx,
     33                               JS::Handle<JSObject*> aGivenProto) override;
     34 
     35  void GetRawId(JSContext* aCx, JS::MutableHandle<JSObject*> aValue,
     36                ErrorResult& aRv);
     37 
     38  void GetAuthenticatorAttachment(DOMString& aAuthenticatorAttachment);
     39 
     40  already_AddRefed<AuthenticatorResponse> Response() const;
     41 
     42  void SetRawId(const nsTArray<uint8_t>& aBuffer);
     43 
     44  void SetAuthenticatorAttachment(
     45      const Maybe<nsString>& aAuthenticatorAttachment);
     46 
     47  void SetAttestationResponse(
     48      const RefPtr<AuthenticatorAttestationResponse>& aAttestationResponse);
     49  void SetAssertionResponse(
     50      const RefPtr<AuthenticatorAssertionResponse>& aAssertionResponse);
     51 
     52  static already_AddRefed<Promise>
     53  IsUserVerifyingPlatformAuthenticatorAvailable(GlobalObject& aGlobal,
     54                                                ErrorResult& aError);
     55 
     56  static already_AddRefed<Promise> GetClientCapabilities(GlobalObject& aGlobal,
     57                                                         ErrorResult& aError);
     58 
     59  static already_AddRefed<Promise> IsConditionalMediationAvailable(
     60      GlobalObject& aGlobal, ErrorResult& aError);
     61 
     62  void GetClientExtensionResults(
     63      JSContext* cx, AuthenticationExtensionsClientOutputs& aResult) const;
     64 
     65  void ToJSON(JSContext* aCx, JS::MutableHandle<JSObject*> aRetval,
     66              ErrorResult& aError);
     67 
     68  void SetClientExtensionResultAppId(bool aResult);
     69 
     70  void SetClientExtensionResultCredPropsRk(bool aResult);
     71 
     72  void SetClientExtensionResultHmacSecret(bool aHmacCreateSecret);
     73 
     74  void InitClientExtensionResultLargeBlob();
     75  void SetClientExtensionResultLargeBlobSupported(bool aSupported);
     76  void SetClientExtensionResultLargeBlobValue(
     77      const nsTArray<uint8_t>& aLargeBlobValue);
     78  void SetClientExtensionResultLargeBlobWritten(bool aLargeBlobWritten);
     79 
     80  void InitClientExtensionResultPrf();
     81  void SetClientExtensionResultPrfEnabled(bool aPrfEnabled);
     82  void SetClientExtensionResultPrfResultsFirst(
     83      const nsTArray<uint8_t>& aPrfResultsFirst);
     84  void SetClientExtensionResultPrfResultsSecond(
     85      const nsTArray<uint8_t>& aPrfResultsSecond);
     86 
     87  static void ParseCreationOptionsFromJSON(
     88      GlobalObject& aGlobal,
     89      const PublicKeyCredentialCreationOptionsJSON& aOptions,
     90      PublicKeyCredentialCreationOptions& aResult, ErrorResult& aRv);
     91 
     92  static void ParseRequestOptionsFromJSON(
     93      GlobalObject& aGlobal,
     94      const PublicKeyCredentialRequestOptionsJSON& aOptions,
     95      PublicKeyCredentialRequestOptions& aResult, ErrorResult& aRv);
     96 
     97 private:
     98  nsTArray<uint8_t> mRawId;
     99  JS::Heap<JSObject*> mRawIdCachedObj;
    100  Maybe<nsString> mAuthenticatorAttachment;
    101  RefPtr<AuthenticatorAttestationResponse> mAttestationResponse;
    102  RefPtr<AuthenticatorAssertionResponse> mAssertionResponse;
    103  AuthenticationExtensionsClientOutputs mClientExtensionOutputs;
    104 
    105  // We need a reference to JSContext in order to convert nsTArray to
    106  // BufferSource, so we need to store these outside mClientExtensionOutputs and
    107  // defer the conversion until the GetClientExtensionResults call.
    108  Maybe<nsTArray<uint8_t>> mLargeBlobValue;
    109  Maybe<nsTArray<uint8_t>> mPrfResultsFirst;
    110  Maybe<nsTArray<uint8_t>> mPrfResultsSecond;
    111 };
    112 
    113 }  // namespace mozilla::dom
    114 
    115 #endif  // mozilla_dom_PublicKeyCredential_h