tor-browser

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

WebAuthnAutoFillEntry.h (1586B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      4 
      5 #ifndef mozilla_dom_WebAuthnAutoFillEntry_h_
      6 #define mozilla_dom_WebAuthnAutoFillEntry_h_
      7 
      8 #include "nsIWebAuthnService.h"
      9 #include "nsString.h"
     10 
     11 #ifdef XP_WIN
     12 #  include <windows.h>
     13 
     14 #  include "winwebauthn/webauthn.h"
     15 #endif
     16 
     17 namespace mozilla::dom {
     18 
     19 class WebAuthnAutoFillEntry final : public nsIWebAuthnAutoFillEntry {
     20 public:
     21  NS_DECL_THREADSAFE_ISUPPORTS
     22  NS_DECL_NSIWEBAUTHNAUTOFILLENTRY
     23 
     24  WebAuthnAutoFillEntry(uint8_t aProvider, const nsAString& aUserName,
     25                        const nsAString& aRpId,
     26                        const nsTArray<uint8_t>& aCredentialId)
     27      : mProvider(aProvider), mUserName(aUserName), mRpId(aRpId) {
     28    mCredentialId.Assign(aCredentialId);
     29  }
     30 
     31 #ifdef XP_WIN
     32  explicit WebAuthnAutoFillEntry(
     33      PCWEBAUTHN_CREDENTIAL_DETAILS aCredentialDetails) {
     34    mProvider = nsIWebAuthnAutoFillEntry::PROVIDER_PLATFORM_WINDOWS;
     35    mUserName.Assign(aCredentialDetails->pUserInformation->pwszName);
     36    mRpId.Assign(aCredentialDetails->pRpInformation->pwszId);
     37    mCredentialId.AppendElements(aCredentialDetails->pbCredentialID,
     38                                 aCredentialDetails->cbCredentialID);
     39  }
     40 #endif
     41 
     42 private:
     43  ~WebAuthnAutoFillEntry() = default;
     44 
     45  uint8_t mProvider;
     46  nsString mUserName;
     47  nsString mRpId;
     48  nsTArray<uint8_t> mCredentialId;
     49 };
     50 
     51 }  // namespace mozilla::dom
     52 #endif  // mozilla_dom_WebAuthnAutoFillEntry_h_