APIWebAuthenticationPanel.h [plain text]
#pragma once
#if ENABLE(WEB_AUTHN)
#include "APIObject.h"
#include <WebCore/AuthenticatorTransport.h>
#include <wtf/UniqueRef.h>
#include <wtf/WeakPtr.h>
#include <wtf/text/WTFString.h>
namespace WebCore {
enum class ClientDataType : bool;
class AuthenticatorResponse;
struct ExceptionData;
struct MockWebAuthenticationConfiguration;
}
namespace WebKit {
class AuthenticatorManager;
struct WebAuthenticationRequestData;
}
namespace API {
class WebAuthenticationPanelClient;
class WebAuthenticationPanel final : public ObjectImpl<Object::Type::WebAuthenticationPanel>, public CanMakeWeakPtr<WebAuthenticationPanel> {
public:
using Response = Variant<Ref<WebCore::AuthenticatorResponse>, WebCore::ExceptionData>;
using Callback = CompletionHandler<void(Response&&)>;
WebAuthenticationPanel();
~WebAuthenticationPanel();
void handleRequest(WebKit::WebAuthenticationRequestData&&, Callback&&);
void cancel() const;
void setMockConfiguration(WebCore::MockWebAuthenticationConfiguration&&);
const WebAuthenticationPanelClient& client() const { return m_client.get(); }
void setClient(UniqueRef<WebAuthenticationPanelClient>&&);
using TransportSet = HashSet<WebCore::AuthenticatorTransport, WTF::IntHash<WebCore::AuthenticatorTransport>, WTF::StrongEnumHashTraits<WebCore::AuthenticatorTransport>>;
static Ref<WebAuthenticationPanel> create(const WebKit::AuthenticatorManager&, const WTF::String& rpId, const TransportSet&, WebCore::ClientDataType);
WTF::String rpId() const { return m_rpId; }
const Vector<WebCore::AuthenticatorTransport>& transports() const { return m_transports; }
WebCore::ClientDataType clientDataType() const { return m_clientDataType; }
private:
WebAuthenticationPanel(const WebKit::AuthenticatorManager&, const WTF::String& rpId, const TransportSet&, WebCore::ClientDataType);
std::unique_ptr<WebKit::AuthenticatorManager> m_manager; UniqueRef<WebAuthenticationPanelClient> m_client;
WeakPtr<WebKit::AuthenticatorManager> m_weakManager;
WTF::String m_rpId;
Vector<WebCore::AuthenticatorTransport> m_transports;
WebCore::ClientDataType m_clientDataType;
};
}
#endif // ENABLE(WEB_AUTHN)