#include "components/autofill/core/browser/payments/credit_card_fido_authenticator.h"
#include <memory>
#include <string>
#include <utility>
#include <vector>
#include "build/build_config.h"
#if BUILDFLAG(IS_ANDROID)
#include "base/android/build_info.h"
#endif
#include "base/base64.h"
#include "base/containers/flat_set.h"
#include "base/strings/string_util.h"
#include "base/synchronization/waitable_event.h"
#include "components/autofill/core/browser/autofill_client.h"
#include "components/autofill/core/browser/autofill_experiments.h"
#include "components/autofill/core/browser/autofill_progress_dialog_type.h"
#include "components/autofill/core/browser/data_model/credit_card.h"
#include "components/autofill/core/browser/metrics/autofill_metrics.h"
#include "components/autofill/core/browser/metrics/payments/better_auth_metrics.h"
#include "components/autofill/core/browser/payments/payments_autofill_client.h"
#include "components/autofill/core/browser/payments/payments_network_interface.h"
#include "components/autofill/core/browser/payments/payments_service_url.h"
#include "components/autofill/core/browser/personal_data_manager.h"
#include "components/autofill/core/browser/strike_databases/payments/fido_authentication_strike_database.h"
#include "components/autofill/core/common/autofill_payments_features.h"
#include "components/autofill/core/common/autofill_prefs.h"
#include "components/signin/public/identity_manager/account_info.h"
#include "device/fido/authenticator_selection_criteria.h"
#include "device/fido/fido_types.h"
#include "third_party/blink/public/mojom/webauthn/authenticator.mojom.h"
#include "url/gurl.h"
#include "url/origin.h"
namespace autofill {
namespace {
constexpr int kWebAuthnTimeoutMs = …;
constexpr char kGooglePaymentsRpid[] = …;
constexpr char kGooglePaymentsRpName[] = …;
std::vector<uint8_t> Base64ToBytes(std::string base64) { … }
base::Value BytesToBase64(const std::vector<uint8_t> bytes) { … }
}
CreditCardFidoAuthenticator::CreditCardFidoAuthenticator(AutofillDriver* driver,
AutofillClient* client)
: … { … }
CreditCardFidoAuthenticator::~CreditCardFidoAuthenticator() { … }
void CreditCardFidoAuthenticator::Authenticate(
CreditCard card,
base::WeakPtr<Requester> requester,
base::Value::Dict request_options,
std::optional<std::string> context_token) { … }
void CreditCardFidoAuthenticator::Register(std::string card_authorization_token,
base::Value::Dict creation_options) { … }
void CreditCardFidoAuthenticator::Authorize(
base::WeakPtr<Requester> requester,
std::string card_authorization_token,
base::Value::Dict request_options) { … }
void CreditCardFidoAuthenticator::OptOut() { … }
void CreditCardFidoAuthenticator::IsUserVerifiable(
base::OnceCallback<void(bool)> callback) { … }
bool CreditCardFidoAuthenticator::IsUserOptedIn() { … }
UserOptInIntention CreditCardFidoAuthenticator::GetUserOptInIntention(
payments::PaymentsNetworkInterface::UnmaskDetails& unmask_details) { … }
void CreditCardFidoAuthenticator::CancelVerification() { … }
#if !BUILDFLAG(IS_ANDROID)
void CreditCardFidoAuthenticator::OnWebauthnOfferDialogRequested(
std::string card_authorization_token) { … }
void CreditCardFidoAuthenticator::OnWebauthnOfferDialogUserResponse(
bool did_accept) { … }
#endif
FidoAuthenticationStrikeDatabase*
CreditCardFidoAuthenticator::GetOrCreateFidoAuthenticationStrikeDatabase() { … }
bool CreditCardFidoAuthenticator::IsValidRequestOptions(
const base::Value::Dict& request_options) { … }
void CreditCardFidoAuthenticator::GetAssertion(
blink::mojom::PublicKeyCredentialRequestOptionsPtr request_options) { … }
void CreditCardFidoAuthenticator::MakeCredential(
blink::mojom::PublicKeyCredentialCreationOptionsPtr creation_options) { … }
void CreditCardFidoAuthenticator::OptChange(
base::Value::Dict authenticator_response) { … }
void CreditCardFidoAuthenticator::OnDidGetAssertion(
blink::mojom::AuthenticatorStatus status,
blink::mojom::GetAssertionAuthenticatorResponsePtr assertion_response,
blink::mojom::WebAuthnDOMExceptionDetailsPtr dom_exception_details) { … }
void CreditCardFidoAuthenticator::OnDidMakeCredential(
blink::mojom::AuthenticatorStatus status,
blink::mojom::MakeCredentialAuthenticatorResponsePtr attestation_response,
blink::mojom::WebAuthnDOMExceptionDetailsPtr dom_exception_details) { … }
void CreditCardFidoAuthenticator::OnDidGetOptChangeResult(
payments::PaymentsAutofillClient::PaymentsRpcResult result,
payments::PaymentsNetworkInterface::OptChangeResponseDetails& response) { … }
void CreditCardFidoAuthenticator::OnFullCardRequestSucceeded(
const payments::FullCardRequest& full_card_request,
const CreditCard& card,
const std::u16string& cvc) { … }
void CreditCardFidoAuthenticator::OnFullCardRequestFailed(
CreditCard::RecordType card_type,
payments::FullCardRequest::FailureType failure_type) { … }
blink::mojom::PublicKeyCredentialRequestOptionsPtr
CreditCardFidoAuthenticator::ParseRequestOptions(
const base::Value::Dict& request_options) { … }
blink::mojom::PublicKeyCredentialCreationOptionsPtr
CreditCardFidoAuthenticator::ParseCreationOptions(
const base::Value::Dict& creation_options) { … }
device::PublicKeyCredentialDescriptor
CreditCardFidoAuthenticator::ParseCredentialDescriptor(
const base::Value& key_info) { … }
base::Value::Dict CreditCardFidoAuthenticator::ParseAssertionResponse(
blink::mojom::GetAssertionAuthenticatorResponsePtr assertion_response) { … }
base::Value::Dict CreditCardFidoAuthenticator::ParseAttestationResponse(
blink::mojom::MakeCredentialAuthenticatorResponsePtr attestation_response) { … }
bool CreditCardFidoAuthenticator::IsValidCreationOptions(
const base::Value::Dict& creation_options) { … }
void CreditCardFidoAuthenticator::LogWebauthnResult(
blink::mojom::AuthenticatorStatus status) { … }
void CreditCardFidoAuthenticator::UpdateUserPref() { … }
void CreditCardFidoAuthenticator::HandleGetAssertionSuccess(
blink::mojom::GetAssertionAuthenticatorResponsePtr assertion_response) { … }
void CreditCardFidoAuthenticator::HandleGetAssertionFailure() { … }
webauthn::InternalAuthenticator* CreditCardFidoAuthenticator::authenticator() { … }
}