#include "third_party/blink/renderer/modules/credentialmanagement/credential_manager_type_converters.h"
#include <algorithm>
#include <utility>
#include "base/numerics/safe_conversions.h"
#include "build/build_config.h"
#include "third_party/blink/public/mojom/webauthn/authenticator.mojom-blink.h"
#include "third_party/blink/public/mojom/webid/digital_identity_request.mojom-blink.h"
#include "third_party/blink/public/mojom/webid/federated_auth_request.mojom-blink.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_typedefs.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_union_arraybuffer_arraybufferview.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_all_accepted_credentials_options.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_authentication_extensions_client_inputs.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_authentication_extensions_client_outputs.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_authentication_extensions_large_blob_inputs.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_authentication_extensions_large_blob_outputs.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_authentication_extensions_payment_inputs.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_authentication_extensions_prf_inputs.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_authentication_extensions_prf_outputs.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_authentication_extensions_prf_values.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_authentication_extensions_supplemental_pub_keys_inputs.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_authentication_extensions_supplemental_pub_keys_outputs.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_authenticator_selection_criteria.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_cable_authentication_data.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_current_user_details_options.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_identity_credential_disconnect_options.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_identity_credential_request_options_context.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_identity_credential_request_options_mode.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_identity_provider_config.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_identity_provider_request_options.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_identity_user_info.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_public_key_credential_creation_options.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_public_key_credential_descriptor.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_public_key_credential_parameters.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_public_key_credential_request_options.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_public_key_credential_rp_entity.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_public_key_credential_user_entity.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_remote_desktop_client_override.h"
#include "third_party/blink/renderer/core/typed_arrays/dom_array_piece.h"
#include "third_party/blink/renderer/modules/credentialmanagement/credential.h"
#include "third_party/blink/renderer/modules/credentialmanagement/federated_credential.h"
#include "third_party/blink/renderer/modules/credentialmanagement/password_credential.h"
#include "third_party/blink/renderer/modules/credentialmanagement/public_key_credential.h"
#include "third_party/blink/renderer/platform/bindings/enumeration_base.h"
#include "third_party/blink/renderer/platform/heap/member.h"
#include "third_party/blink/renderer/platform/runtime_enabled_features.h"
#include "third_party/blink/renderer/platform/wtf/text/base64.h"
#include "third_party/boringssl/src/include/openssl/sha.h"
namespace mojo {
AllAcceptedCredentialsOptions;
AllAcceptedCredentialsOptionsPtr;
AttestationConveyancePreference;
AuthenticationExtensionsClientInputs;
AuthenticationExtensionsClientInputsPtr;
AuthenticatorAttachment;
AuthenticatorSelectionCriteria;
AuthenticatorSelectionCriteriaPtr;
AuthenticatorTransport;
CableAuthentication;
CableAuthenticationPtr;
CredentialInfo;
CredentialInfoPtr;
CredentialType;
CurrentUserDetailsOptions;
CurrentUserDetailsOptionsPtr;
Hint;
IdentityCredentialDisconnectOptions;
IdentityCredentialDisconnectOptionsPtr;
IdentityProviderConfig;
IdentityProviderConfigPtr;
IdentityProviderRequestOptions;
IdentityProviderRequestOptionsPtr;
IdentityUserInfo;
IdentityUserInfoPtr;
LargeBlobSupport;
PRFValues;
PRFValuesPtr;
PublicKeyCredentialCreationOptionsPtr;
PublicKeyCredentialDescriptor;
PublicKeyCredentialDescriptorPtr;
PublicKeyCredentialParameters;
PublicKeyCredentialParametersPtr;
PublicKeyCredentialReportOptionsPtr;
PublicKeyCredentialRequestOptionsPtr;
PublicKeyCredentialRpEntity;
PublicKeyCredentialRpEntityPtr;
PublicKeyCredentialType;
PublicKeyCredentialUserEntity;
PublicKeyCredentialUserEntityPtr;
RemoteDesktopClientOverride;
RemoteDesktopClientOverridePtr;
ResidentKeyRequirement;
RpContext;
RpMode;
SupplementalPubKeysRequest;
SupplementalPubKeysRequestPtr;
UserVerificationRequirement;
namespace {
static constexpr int kCoseEs256 = …;
static constexpr int kCoseRs256 = …;
PublicKeyCredentialParametersPtr CreatePublicKeyCredentialParameter(int alg) { … }
bool SortPRFValuesByCredentialId(const PRFValuesPtr& a, const PRFValuesPtr& b) { … }
Vector<uint8_t> Base64UnpaddedURLDecodeOrCheck(const String& encoded) { … }
}
CredentialInfoPtr TypeConverter<CredentialInfoPtr, blink::Credential*>::Convert(
blink::Credential* credential) { … }
blink::Credential*
TypeConverter<blink::Credential*, CredentialInfoPtr>::Convert(
const CredentialInfoPtr& info) { … }
#if BUILDFLAG(IS_ANDROID)
static Vector<Vector<uint32_t>> UvmEntryToArray(
const Vector<blink::mojom::blink::UvmEntryPtr>& user_verification_methods) {
Vector<Vector<uint32_t>> uvm_array;
for (const auto& uvm : user_verification_methods) {
Vector<uint32_t> uvmEntry = {uvm->user_verification_method,
uvm->key_protection_type,
uvm->matcher_protection_type};
uvm_array.push_back(uvmEntry);
}
return uvm_array;
}
#endif
blink::AuthenticationExtensionsClientOutputs*
TypeConverter<blink::AuthenticationExtensionsClientOutputs*,
blink::mojom::blink::AuthenticationExtensionsClientOutputsPtr>::
Convert(const blink::mojom::blink::AuthenticationExtensionsClientOutputsPtr&
extensions) { … }
blink::AuthenticationExtensionsSupplementalPubKeysOutputs*
TypeConverter<blink::AuthenticationExtensionsSupplementalPubKeysOutputs*,
blink::mojom::blink::SupplementalPubKeysResponsePtr>::
Convert(const blink::mojom::blink::SupplementalPubKeysResponsePtr&
supplemental_pub_keys) { … }
Vector<uint8_t>
TypeConverter<Vector<uint8_t>, blink::V8UnionArrayBufferOrArrayBufferView*>::
Convert(const blink::V8UnionArrayBufferOrArrayBufferView* buffer) { … }
PublicKeyCredentialType TypeConverter<PublicKeyCredentialType, String>::Convert(
const String& type) { … }
std::optional<AuthenticatorTransport>
TypeConverter<std::optional<AuthenticatorTransport>, String>::Convert(
const String& transport) { … }
String TypeConverter<String, AuthenticatorTransport>::Convert(
const AuthenticatorTransport& transport) { … }
std::optional<blink::mojom::blink::ResidentKeyRequirement>
TypeConverter<std::optional<blink::mojom::blink::ResidentKeyRequirement>,
String>::Convert(const String& requirement) { … }
std::optional<UserVerificationRequirement>
TypeConverter<std::optional<UserVerificationRequirement>, String>::Convert(
const String& requirement) { … }
std::optional<AttestationConveyancePreference>
TypeConverter<std::optional<AttestationConveyancePreference>, String>::Convert(
const String& preference) { … }
std::optional<AuthenticatorAttachment> TypeConverter<
std::optional<AuthenticatorAttachment>,
std::optional<String>>::Convert(const std::optional<String>& attachment) { … }
LargeBlobSupport
TypeConverter<LargeBlobSupport, std::optional<String>>::Convert(
const std::optional<String>& large_blob_support) { … }
AuthenticatorSelectionCriteriaPtr
TypeConverter<AuthenticatorSelectionCriteriaPtr,
blink::AuthenticatorSelectionCriteria>::
Convert(const blink::AuthenticatorSelectionCriteria& criteria) { … }
PublicKeyCredentialUserEntityPtr
TypeConverter<PublicKeyCredentialUserEntityPtr,
blink::PublicKeyCredentialUserEntity>::
Convert(const blink::PublicKeyCredentialUserEntity& user) { … }
PublicKeyCredentialRpEntityPtr
TypeConverter<PublicKeyCredentialRpEntityPtr,
blink::PublicKeyCredentialRpEntity>::
Convert(const blink::PublicKeyCredentialRpEntity& rp) { … }
PublicKeyCredentialDescriptorPtr
TypeConverter<PublicKeyCredentialDescriptorPtr,
blink::PublicKeyCredentialDescriptor>::
Convert(const blink::PublicKeyCredentialDescriptor& descriptor) { … }
PublicKeyCredentialParametersPtr
TypeConverter<PublicKeyCredentialParametersPtr,
blink::PublicKeyCredentialParameters>::
Convert(const blink::PublicKeyCredentialParameters& parameter) { … }
PublicKeyCredentialCreationOptionsPtr
TypeConverter<PublicKeyCredentialCreationOptionsPtr,
blink::PublicKeyCredentialCreationOptions>::
Convert(const blink::PublicKeyCredentialCreationOptions& options) { … }
static Vector<uint8_t> ConvertFixedSizeArray(
const blink::V8BufferSource* buffer,
unsigned length) { … }
CableAuthenticationPtr
TypeConverter<CableAuthenticationPtr, blink::CableAuthenticationData>::Convert(
const blink::CableAuthenticationData& data) { … }
PublicKeyCredentialRequestOptionsPtr
TypeConverter<PublicKeyCredentialRequestOptionsPtr,
blink::PublicKeyCredentialRequestOptions>::
Convert(const blink::PublicKeyCredentialRequestOptions& options) { … }
AuthenticationExtensionsClientInputsPtr
TypeConverter<AuthenticationExtensionsClientInputsPtr,
blink::AuthenticationExtensionsClientInputs>::
Convert(const blink::AuthenticationExtensionsClientInputs& inputs) { … }
RemoteDesktopClientOverridePtr
TypeConverter<RemoteDesktopClientOverridePtr,
blink::RemoteDesktopClientOverride>::
Convert(const blink::RemoteDesktopClientOverride& blink_value) { … }
IdentityProviderConfigPtr
TypeConverter<IdentityProviderConfigPtr, blink::IdentityProviderConfig>::
Convert(const blink::IdentityProviderConfig& provider) { … }
IdentityProviderRequestOptionsPtr
TypeConverter<IdentityProviderRequestOptionsPtr,
blink::IdentityProviderRequestOptions>::
Convert(const blink::IdentityProviderRequestOptions& options) { … }
RpContext
TypeConverter<RpContext, blink::V8IdentityCredentialRequestOptionsContext>::
Convert(const blink::V8IdentityCredentialRequestOptionsContext& context) { … }
RpMode
TypeConverter<RpMode, blink::V8IdentityCredentialRequestOptionsMode>::Convert(
const blink::V8IdentityCredentialRequestOptionsMode& mode) { … }
IdentityUserInfoPtr
TypeConverter<IdentityUserInfoPtr, blink::IdentityUserInfo>::Convert(
const blink::IdentityUserInfo& user_info) { … }
std::optional<SupplementalPubKeysRequestPtr>
TypeConverter<std::optional<SupplementalPubKeysRequestPtr>,
blink::AuthenticationExtensionsSupplementalPubKeysInputs>::
Convert(const blink::AuthenticationExtensionsSupplementalPubKeysInputs&
supplemental_pub_keys) { … }
PRFValuesPtr
TypeConverter<PRFValuesPtr, blink::AuthenticationExtensionsPRFValues>::Convert(
const blink::AuthenticationExtensionsPRFValues& values) { … }
Vector<PRFValuesPtr>
TypeConverter<Vector<PRFValuesPtr>, blink::AuthenticationExtensionsPRFInputs>::
Convert(const blink::AuthenticationExtensionsPRFInputs& prf) { … }
IdentityCredentialDisconnectOptionsPtr
TypeConverter<IdentityCredentialDisconnectOptionsPtr,
blink::IdentityCredentialDisconnectOptions>::
Convert(const blink::IdentityCredentialDisconnectOptions& options) { … }
Vector<Hint> TypeConverter<Vector<Hint>, Vector<String>>::Convert(
const Vector<String>& hints) { … }
blink::mojom::blink::PublicKeyCredentialReportOptionsPtr
TypeConverter<blink::mojom::blink::PublicKeyCredentialReportOptionsPtr,
blink::UnknownCredentialOptions>::
Convert(const blink::UnknownCredentialOptions& options) { … }
blink::mojom::blink::PublicKeyCredentialReportOptionsPtr
TypeConverter<blink::mojom::blink::PublicKeyCredentialReportOptionsPtr,
blink::AllAcceptedCredentialsOptions>::
Convert(const blink::AllAcceptedCredentialsOptions& options) { … }
blink::mojom::blink::PublicKeyCredentialReportOptionsPtr
TypeConverter<blink::mojom::blink::PublicKeyCredentialReportOptionsPtr,
blink::CurrentUserDetailsOptions>::
Convert(const blink::CurrentUserDetailsOptions& options) { … }
}