chromium/third_party/blink/renderer/modules/credentialmanagement/credential_manager_type_converters.h

// Copyright 2017 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_CREDENTIALMANAGEMENT_CREDENTIAL_MANAGER_TYPE_CONVERTERS_H_
#define THIRD_PARTY_BLINK_RENDERER_MODULES_CREDENTIALMANAGEMENT_CREDENTIAL_MANAGER_TYPE_CONVERTERS_H_

#include <optional>

#include "mojo/public/cpp/bindings/type_converter.h"
#include "third_party/blink/public/mojom/credentialmanagement/credential_manager.mojom-blink.h"
#include "third_party/blink/public/mojom/webauthn/authenticator.mojom-blink-forward.h"
#include "third_party/blink/public/mojom/webid/digital_identity_request.mojom-blink-forward.h"
#include "third_party/blink/public/mojom/webid/federated_auth_request.mojom-blink-forward.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_all_accepted_credentials_options.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_unknown_credential_options.h"
#include "third_party/blink/renderer/modules/modules_export.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
#include "third_party/blink/renderer/platform/wtf/vector.h"

namespace blink {
class AllAcceptedCredentialsOptions;
class AuthenticationExtensionsClientInputs;
class AuthenticationExtensionsClientOutputs;
class AuthenticationExtensionsSupplementalPubKeysInputs;
class AuthenticationExtensionsSupplementalPubKeysOutputs;
class AuthenticationExtensionsPRFInputs;
class AuthenticationExtensionsPRFValues;
class AuthenticatorSelectionCriteria;
class CableAuthenticationData;
class Credential;
class CurrentUserDetailsOptions;
class DigitalCredentialProvider;
class IdentityCredentialDisconnectOptions;
class IdentityProviderConfig;
class IdentityProviderRequestOptions;
class IdentityUserInfo;
class PublicKeyCredentialCreationOptions;
class PublicKeyCredentialDescriptor;
class PublicKeyCredentialParameters;
class PublicKeyCredentialRequestOptions;
class PublicKeyCredentialRpEntity;
class PublicKeyCredentialUserEntity;
class RemoteDesktopClientOverride;
class UserVerificationRequirement;
class V8IdentityCredentialRequestOptionsContext;
class V8IdentityCredentialRequestOptionsMode;
class V8UnionArrayBufferOrArrayBufferView;
}  // namespace blink

namespace mojo {

// blink::mojom::blink::CredentialManager --------------------------

template <>
struct TypeConverter<blink::mojom::blink::CredentialInfoPtr,
                     blink::Credential*> {};

template <>
struct TypeConverter<blink::Credential*,
                     blink::mojom::blink::CredentialInfoPtr> {};

// "Reverse" converters. These convert from from Mojo structures to
// IDL-generated structures.

template <>
struct MODULES_EXPORT TypeConverter<
    blink::AuthenticationExtensionsClientOutputs*,
    blink::mojom::blink::AuthenticationExtensionsClientOutputsPtr> {};

template <>
struct TypeConverter<blink::AuthenticationExtensionsSupplementalPubKeysOutputs*,
                     blink::mojom::blink::SupplementalPubKeysResponsePtr> {};

// blink::mojom::blink::Authenticator ---------------------------------------
template <>
struct TypeConverter<Vector<uint8_t>,
                     blink::V8UnionArrayBufferOrArrayBufferView*> {};

template <>
struct TypeConverter<blink::mojom::blink::PublicKeyCredentialType, String> {};

template <>
struct TypeConverter<std::optional<blink::mojom::blink::AuthenticatorTransport>,
                     String> {};

template <>
struct TypeConverter<String, blink::mojom::blink::AuthenticatorTransport> {};

template <>
struct TypeConverter<std::optional<blink::mojom::blink::ResidentKeyRequirement>,
                     String> {};

template <>
struct TypeConverter<
    std::optional<blink::mojom::blink::UserVerificationRequirement>,
    String> {};

template <>
struct TypeConverter<
    std::optional<blink::mojom::blink::AttestationConveyancePreference>,
    String> {};

template <>
struct TypeConverter<
    std::optional<blink::mojom::blink::AuthenticatorAttachment>,
    std::optional<String>> {};

template <>
struct TypeConverter<blink::mojom::blink::LargeBlobSupport,
                     std::optional<String>> {};

template <>
struct TypeConverter<blink::mojom::blink::AuthenticatorSelectionCriteriaPtr,
                     blink::AuthenticatorSelectionCriteria> {};

template <>
struct TypeConverter<blink::mojom::blink::PublicKeyCredentialUserEntityPtr,
                     blink::PublicKeyCredentialUserEntity> {};

template <>
struct TypeConverter<blink::mojom::blink::PublicKeyCredentialRpEntityPtr,
                     blink::PublicKeyCredentialRpEntity> {};

template <>
struct TypeConverter<blink::mojom::blink::PublicKeyCredentialDescriptorPtr,
                     blink::PublicKeyCredentialDescriptor> {};

template <>
struct TypeConverter<blink::mojom::blink::PublicKeyCredentialParametersPtr,
                     blink::PublicKeyCredentialParameters> {};

template <>
struct TypeConverter<blink::mojom::blink::PublicKeyCredentialCreationOptionsPtr,
                     blink::PublicKeyCredentialCreationOptions> {};

template <>
struct TypeConverter<blink::mojom::blink::CableAuthenticationPtr,
                     blink::CableAuthenticationData> {};

template <>
struct MODULES_EXPORT
    TypeConverter<blink::mojom::blink::PublicKeyCredentialRequestOptionsPtr,
                  blink::PublicKeyCredentialRequestOptions> {};

template <>
struct MODULES_EXPORT
    TypeConverter<blink::mojom::blink::AuthenticationExtensionsClientInputsPtr,
                  blink::AuthenticationExtensionsClientInputs> {};

template <>
struct TypeConverter<blink::mojom::blink::RemoteDesktopClientOverridePtr,
                     blink::RemoteDesktopClientOverride> {};

template <>
struct TypeConverter<blink::mojom::blink::IdentityProviderConfigPtr,
                     blink::IdentityProviderConfig> {};

template <>
struct MODULES_EXPORT
    TypeConverter<blink::mojom::blink::IdentityProviderRequestOptionsPtr,
                  blink::IdentityProviderRequestOptions> {};

template <>
struct TypeConverter<blink::mojom::blink::DigitalCredentialProviderPtr,
                     blink::DigitalCredentialProvider> {};

template <>
struct MODULES_EXPORT
    TypeConverter<blink::mojom::blink::RpContext,
                  blink::V8IdentityCredentialRequestOptionsContext> {};

template <>
struct MODULES_EXPORT
    TypeConverter<blink::mojom::blink::RpMode,
                  blink::V8IdentityCredentialRequestOptionsMode> {};

template <>
struct TypeConverter<blink::mojom::blink::IdentityUserInfoPtr,
                     blink::IdentityUserInfo> {};

template <>
struct TypeConverter<
    std::optional<blink::mojom::blink::SupplementalPubKeysRequestPtr>,
    blink::AuthenticationExtensionsSupplementalPubKeysInputs> {};

template <>
struct TypeConverter<blink::mojom::blink::PRFValuesPtr,
                     blink::AuthenticationExtensionsPRFValues> {};

template <>
struct TypeConverter<Vector<blink::mojom::blink::PRFValuesPtr>,
                     blink::AuthenticationExtensionsPRFInputs> {};

template <>
struct TypeConverter<
    blink::mojom::blink::IdentityCredentialDisconnectOptionsPtr,
    blink::IdentityCredentialDisconnectOptions> {};

template <>
struct TypeConverter<Vector<blink::mojom::blink::Hint>, Vector<String>> {};

template <>
struct MODULES_EXPORT
    TypeConverter<blink::mojom::blink::PublicKeyCredentialReportOptionsPtr,
                  blink::UnknownCredentialOptions> {};

template <>
struct MODULES_EXPORT
    TypeConverter<blink::mojom::blink::PublicKeyCredentialReportOptionsPtr,
                  blink::AllAcceptedCredentialsOptions> {};

template <>
struct MODULES_EXPORT
    TypeConverter<blink::mojom::blink::PublicKeyCredentialReportOptionsPtr,
                  blink::CurrentUserDetailsOptions> {};

}  // namespace mojo

#endif  // THIRD_PARTY_BLINK_RENDERER_MODULES_CREDENTIALMANAGEMENT_CREDENTIAL_MANAGER_TYPE_CONVERTERS_H_