AuthenticatorPresenterCoordinator.h [plain text]
#pragma once
#if ENABLE(WEB_AUTHN)
#include "WebAuthenticationFlags.h"
#include <WebCore/AuthenticatorAssertionResponse.h>
#include <WebCore/AuthenticatorTransport.h>
#include <WebCore/WebAuthenticationConstants.h>
#include <wtf/CompletionHandler.h>
#include <wtf/Forward.h>
#include <wtf/RetainPtr.h>
#include <wtf/WeakPtr.h>
OBJC_CLASS ASCAppleIDCredential;
OBJC_CLASS ASCAuthorizationPresentationContext;
OBJC_CLASS ASCAuthorizationPresenter;
OBJC_CLASS ASCLoginChoiceProtocol;
OBJC_CLASS LAContext;
OBJC_CLASS NSError;
OBJC_CLASS WKASCAuthorizationPresenterDelegate;
namespace WebKit {
class AuthenticatorManager;
class AuthenticatorPresenterCoordinator : public CanMakeWeakPtr<AuthenticatorPresenterCoordinator> {
WTF_MAKE_FAST_ALLOCATED;
WTF_MAKE_NONCOPYABLE(AuthenticatorPresenterCoordinator);
public:
using TransportSet = HashSet<WebCore::AuthenticatorTransport, WTF::IntHash<WebCore::AuthenticatorTransport>, WTF::StrongEnumHashTraits<WebCore::AuthenticatorTransport>>;
using CredentialRequestHandler = Function<void(ASCAppleIDCredential *, NSError *)>;
AuthenticatorPresenterCoordinator(const AuthenticatorManager&, const String& rpId, const TransportSet&, WebCore::ClientDataType);
~AuthenticatorPresenterCoordinator();
void updatePresenter(WebAuthenticationStatus);
void requestPin(uint64_t retries, CompletionHandler<void(const String&)>&&);
void selectAssertionResponse(Vector<Ref<WebCore::AuthenticatorAssertionResponse>>&&, WebAuthenticationSource, CompletionHandler<void(WebCore::AuthenticatorAssertionResponse*)>&&);
void requestLAContextForUserVerification(CompletionHandler<void(LAContext *)>&&);
void dimissPresenter(WebAuthenticationResult);
void setCredentialRequestHandler(CredentialRequestHandler&& handler) { m_credentialRequestHandler = WTFMove(handler); }
void setLAContext(LAContext *);
void didSelectAssertionResponse(const String& credentialName, LAContext *);
void setPin(const String&);
private:
WeakPtr<AuthenticatorManager> m_manager;
RetainPtr<ASCAuthorizationPresentationContext> m_context;
RetainPtr<ASCAuthorizationPresenter> m_presenter;
RetainPtr<WKASCAuthorizationPresenterDelegate> m_presenterDelegate;
Function<void()> m_delayedPresentation;
#if HAVE(ASC_AUTH_UI)
bool m_delayedPresentationNeedsSecurityKey { false };
#endif
CredentialRequestHandler m_credentialRequestHandler;
CompletionHandler<void(LAContext *)> m_laContextHandler;
RetainPtr<LAContext> m_laContext;
CompletionHandler<void(WebCore::AuthenticatorAssertionResponse*)> m_responseHandler;
HashMap<String, RefPtr<WebCore::AuthenticatorAssertionResponse>> m_credentials;
CompletionHandler<void(const String&)> m_pinHandler;
#if HAVE(ASC_AUTH_UI)
bool m_presentedPIN { false };
#endif
};
}
#endif // ENABLE(WEB_AUTHN)