PublicKeyCredential.cpp [plain text]
#include "config.h"
#include "PublicKeyCredential.h"
#if ENABLE(WEB_AUTHN)
#include "AuthenticatorCoordinator.h"
#include "AuthenticatorResponse.h"
#include "Document.h"
#include "JSDOMPromiseDeferred.h"
#include "Page.h"
#include "RuntimeEnabledFeatures.h"
#include <wtf/text/Base64.h>
namespace WebCore {
Ref<PublicKeyCredential> PublicKeyCredential::create(Ref<AuthenticatorResponse>&& response)
{
return adoptRef(*new PublicKeyCredential(WTFMove(response)));
}
ArrayBuffer* PublicKeyCredential::rawId() const
{
return m_response->rawId();
}
AuthenticationExtensionsClientOutputs PublicKeyCredential::getClientExtensionResults() const
{
return m_response->extensions();
}
PublicKeyCredential::PublicKeyCredential(Ref<AuthenticatorResponse>&& response)
: BasicCredential(WTF::base64URLEncode(response->rawId()->data(), response->rawId()->byteLength()), Type::PublicKey, Discovery::Remote)
, m_response(WTFMove(response))
{
}
void PublicKeyCredential::isUserVerifyingPlatformAuthenticatorAvailable(Document& document, DOMPromiseDeferred<IDLBoolean>&& promise)
{
if (!RuntimeEnabledFeatures::sharedFeatures().webAuthenticationLocalAuthenticatorEnabled()) {
promise.resolve(false);
return;
}
document.page()->authenticatorCoordinator().isUserVerifyingPlatformAuthenticatorAvailable(WTFMove(promise));
}
}
#endif // ENABLE(WEB_AUTHN)