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
{
18 NS_DECL_THREADSAFE_ISUPPORTS
19 NS_DECL_NSIWEBAUTHNREGISTERARGS
21 explicit WebAuthnRegisterArgs(const WebAuthnMakeCredentialInfo
& aInfo
)
24 mHmacCreateSecret(false),
25 mMinPinLength(false) {
26 for (const WebAuthnExtension
& ext
: mInfo
.Extensions()) {
28 case WebAuthnExtension::TWebAuthnExtensionCredProps
:
29 mCredProps
= ext
.get_WebAuthnExtensionCredProps().credProps();
31 case WebAuthnExtension::TWebAuthnExtensionHmacSecret
:
33 ext
.get_WebAuthnExtensionHmacSecret().hmacCreateSecret();
35 case WebAuthnExtension::TWebAuthnExtensionMinPinLength
:
37 ext
.get_WebAuthnExtensionMinPinLength().minPinLength();
39 case WebAuthnExtension::TWebAuthnExtensionAppId
:
41 case WebAuthnExtension::T__None
:
48 ~WebAuthnRegisterArgs() = default;
50 const WebAuthnMakeCredentialInfo mInfo
;
52 // Flags to indicate whether an extension is being requested.
54 bool mHmacCreateSecret
;
58 class WebAuthnSignArgs final
: public nsIWebAuthnSignArgs
{
60 NS_DECL_THREADSAFE_ISUPPORTS
61 NS_DECL_NSIWEBAUTHNSIGNARGS
63 explicit WebAuthnSignArgs(const WebAuthnGetAssertionInfo
& aInfo
)
65 for (const WebAuthnExtension
& ext
: mInfo
.Extensions()) {
67 case WebAuthnExtension::TWebAuthnExtensionAppId
:
68 mAppId
= Some(ext
.get_WebAuthnExtensionAppId().appIdentifier());
70 case WebAuthnExtension::TWebAuthnExtensionCredProps
:
72 case WebAuthnExtension::TWebAuthnExtensionHmacSecret
:
74 case WebAuthnExtension::TWebAuthnExtensionMinPinLength
:
76 case WebAuthnExtension::T__None
:
83 ~WebAuthnSignArgs() = default;
85 const WebAuthnGetAssertionInfo mInfo
;
86 Maybe
<nsString
> mAppId
;
89 } // namespace mozilla::dom
91 #endif // mozilla_dom_WebAuthnArgs_H_