Bug 1879449 [wpt PR 44489] - [wptrunner] Add `infrastructure/expected-fail/` test...
[gecko.git] / dom / webauthn / WebAuthnArgs.h
blob1b02646e62d0f51129fe435865bdb398a87aed11
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=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_WebAuthnArgs_H_
8 #define mozilla_dom_WebAuthnArgs_H_
10 #include "mozilla/dom/WebAuthnTransactionChild.h"
11 #include "mozilla/ipc/BackgroundParent.h"
12 #include "nsIWebAuthnArgs.h"
14 namespace mozilla::dom {
16 class WebAuthnRegisterArgs final : public nsIWebAuthnRegisterArgs {
17 public:
18 NS_DECL_THREADSAFE_ISUPPORTS
19 NS_DECL_NSIWEBAUTHNREGISTERARGS
21 explicit WebAuthnRegisterArgs(const WebAuthnMakeCredentialInfo& aInfo)
22 : mInfo(aInfo),
23 mCredProps(false),
24 mHmacCreateSecret(false),
25 mMinPinLength(false) {
26 for (const WebAuthnExtension& ext : mInfo.Extensions()) {
27 switch (ext.type()) {
28 case WebAuthnExtension::TWebAuthnExtensionCredProps:
29 mCredProps = ext.get_WebAuthnExtensionCredProps().credProps();
30 break;
31 case WebAuthnExtension::TWebAuthnExtensionHmacSecret:
32 mHmacCreateSecret =
33 ext.get_WebAuthnExtensionHmacSecret().hmacCreateSecret();
34 break;
35 case WebAuthnExtension::TWebAuthnExtensionMinPinLength:
36 mMinPinLength =
37 ext.get_WebAuthnExtensionMinPinLength().minPinLength();
38 break;
39 case WebAuthnExtension::TWebAuthnExtensionAppId:
40 break;
41 case WebAuthnExtension::T__None:
42 break;
47 private:
48 ~WebAuthnRegisterArgs() = default;
50 const WebAuthnMakeCredentialInfo mInfo;
52 // Flags to indicate whether an extension is being requested.
53 bool mCredProps;
54 bool mHmacCreateSecret;
55 bool mMinPinLength;
58 class WebAuthnSignArgs final : public nsIWebAuthnSignArgs {
59 public:
60 NS_DECL_THREADSAFE_ISUPPORTS
61 NS_DECL_NSIWEBAUTHNSIGNARGS
63 explicit WebAuthnSignArgs(const WebAuthnGetAssertionInfo& aInfo)
64 : mInfo(aInfo) {
65 for (const WebAuthnExtension& ext : mInfo.Extensions()) {
66 switch (ext.type()) {
67 case WebAuthnExtension::TWebAuthnExtensionAppId:
68 mAppId = Some(ext.get_WebAuthnExtensionAppId().appIdentifier());
69 break;
70 case WebAuthnExtension::TWebAuthnExtensionCredProps:
71 break;
72 case WebAuthnExtension::TWebAuthnExtensionHmacSecret:
73 break;
74 case WebAuthnExtension::TWebAuthnExtensionMinPinLength:
75 break;
76 case WebAuthnExtension::T__None:
77 break;
82 private:
83 ~WebAuthnSignArgs() = default;
85 const WebAuthnGetAssertionInfo mInfo;
86 Maybe<nsString> mAppId;
89 } // namespace mozilla::dom
91 #endif // mozilla_dom_WebAuthnArgs_H_