chromium/third_party/blink/renderer/modules/ad_auction/navigator_auction.cc

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

#include "third_party/blink/renderer/modules/ad_auction/navigator_auction.h"

#include <stdint.h>

#include <optional>
#include <utility>

#include "base/check.h"
#include "base/containers/contains.h"
#include "base/memory/scoped_refptr.h"
#include "base/metrics/histogram_functions.h"
#include "base/numerics/checked_math.h"
#include "base/time/time.h"
#include "base/types/expected.h"
#include "base/types/expected_macros.h"
#include "base/types/pass_key.h"
#include "base/unguessable_token.h"
#include "base/uuid.h"
#include "components/aggregation_service/aggregation_coordinator_utils.h"
#include "mojo/public/cpp/bindings/map_traits_wtf_hash_map.h"
#include "third_party/abseil-cpp/absl/numeric/int128.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/common/fenced_frame/fenced_frame_utils.h"
#include "third_party/blink/public/common/frame/fenced_frame_sandbox_flags.h"
#include "third_party/blink/public/common/interest_group/ad_auction_constants.h"
#include "third_party/blink/public/common/interest_group/ad_auction_currencies.h"
#include "third_party/blink/public/common/interest_group/ad_display_size_utils.h"
#include "third_party/blink/public/common/interest_group/interest_group.h"
#include "third_party/blink/public/mojom/interest_group/ad_auction_service.mojom-blink.h"
#include "third_party/blink/public/mojom/interest_group/interest_group_types.mojom-blink.h"
#include "third_party/blink/public/mojom/parakeet/ad_request.mojom-blink.h"
#include "third_party/blink/public/mojom/permissions_policy/permissions_policy.mojom-blink.h"
#include "third_party/blink/public/platform/browser_interface_broker_proxy.h"
#include "third_party/blink/public/web/web_console_message.h"
#include "third_party/blink/renderer/bindings/core/v8/native_value_traits_impl.h"
#include "third_party/blink/renderer/bindings/core/v8/script_function.h"
#include "third_party/blink/renderer/bindings/core/v8/script_promise.h"
#include "third_party/blink/renderer/bindings/core/v8/script_promise_resolver.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_throw_dom_exception.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_union_fencedframeconfig_usvstring.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_union_usvstring_usvstringsequence.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_ad_auction_data.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_ad_auction_data_buyer_config.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_ad_auction_data_config.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_ad_properties.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_ad_request_config.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_ad_targeting.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_ads.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_auction_ad.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_auction_ad_config.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_auction_ad_interest_group.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_auction_ad_interest_group_key.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_auction_ad_interest_group_size.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_auction_additional_bid_signature.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_auction_real_time_reporting_config.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_auction_report_buyer_debug_mode_config.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_auction_report_buyers_config.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_protected_audience_private_aggregation_config.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_union_adproperties_adpropertiessequence.h"
#include "third_party/blink/renderer/core/dom/abort_signal.h"
#include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/core/dom/dom_exception.h"
#include "third_party/blink/renderer/core/dom/scoped_abort_state.h"
#include "third_party/blink/renderer/core/frame/csp/content_security_policy.h"
#include "third_party/blink/renderer/core/frame/csp/csp_directive_list.h"
#include "third_party/blink/renderer/core/frame/local_dom_window.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/frame/navigator.h"
#include "third_party/blink/renderer/core/frame/web_feature.h"
#include "third_party/blink/renderer/core/frame/web_local_frame_impl.h"
#include "third_party/blink/renderer/core/html/fenced_frame/fenced_frame_config.h"
#include "third_party/blink/renderer/core/loader/document_loader.h"
#include "third_party/blink/renderer/core/page/page.h"
#include "third_party/blink/renderer/modules/ad_auction/ads.h"
#include "third_party/blink/renderer/modules/ad_auction/join_leave_queue.h"
#include "third_party/blink/renderer/modules/ad_auction/protected_audience.h"
#include "third_party/blink/renderer/modules/ad_auction/validate_blink_interest_group.h"
#include "third_party/blink/renderer/modules/geolocation/geolocation_coordinates.h"
#include "third_party/blink/renderer/platform/bindings/exception_state.h"
#include "third_party/blink/renderer/platform/heap/heap_traits.h"
#include "third_party/blink/renderer/platform/loader/fetch/resource_fetcher.h"
#include "third_party/blink/renderer/platform/weborigin/security_origin.h"
#include "third_party/blink/renderer/platform/wtf/text/base64.h"
#include "third_party/blink/renderer/platform/wtf/text/string_builder.h"
#include "third_party/blink/renderer/platform/wtf/text/string_operators.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
#include "third_party/blink/renderer/platform/wtf/vector.h"
#include "third_party/boringssl/src/include/openssl/curve25519.h"
#include "url/url_constants.h"
#include "v8/include/v8-primitive.h"
#include "v8/include/v8-value.h"

namespace blink {

// Helper to manage runtime of abort + promise resolution pipe.
// Can interface to AbortController itself, and has helper classes that can be
// connected to promises via Then and ScriptFunction.
class NavigatorAuction::AuctionHandle final : public AbortSignal::Algorithm {};

namespace {

// The maximum number of active cross-site joins and leaves. Once these are hit,
// cross-site joins/leaves are queued until they drop below this number. Queued
// pending operations are dropped on destruction / navigation away.
const int kMaxActiveCrossSiteJoins =;
const int kMaxActiveCrossSiteLeaves =;
const int kMaxActiveCrossSiteClears =;

// Error string builders.
String ErrorInvalidInterestGroup(const AuctionAdInterestGroup& group,
                                 const String& field_name,
                                 const String& field_value,
                                 const String& error) {}

String ErrorInvalidInterestGroupJson(const AuctionAdInterestGroup& group,
                                     const String& field_name) {}

String ErrorInvalidAuctionConfigSeller(const String& seller_name,
                                       const String& field_name,
                                       const String& field_value,
                                       const String& error) {}

String ErrorInvalidAuctionConfig(const AuctionAdConfig& config,
                                 const String& field_name,
                                 const String& field_value,
                                 const String& error) {}

String ErrorInvalidAuctionConfigSellerJson(const String& seller_name,
                                           const String& field_name) {}

String ErrorInvalidAdRequestConfig(const AdRequestConfig& config,
                                   const String& field_name,
                                   const String& field_value,
                                   const String& error) {}

String ErrorInvalidAuctionConfigUint(const AuctionAdConfig& config,
                                     const String& field_name,
                                     const String& error) {}

String ErrorRenameMismatch(const String& old_field_name,
                           const String& old_field_value,
                           const String& new_field_name,
                           const String& new_field_value) {}

String ErrorMissingRequired(const String& required_field_name) {}

// Console warnings.

void AddWarningMessageToConsole(const ExecutionContext& execution_context,
                                const String& message) {}

void ConsoleWarnDeprecatedEnum(const ExecutionContext& execution_context,
                               String enum_name,
                               String deprecated_value) {}

// JSON and Origin conversion helpers.

bool Jsonify(const ScriptState& script_state,
             const v8::Local<v8::Value>& value,
             String& output) {}

base::expected<uint64_t, String> CopyBigIntToUint64(const BigInt& bigint) {}

base::expected<absl::uint128, String> CopyBigIntToUint128(
    const BigInt& bigint) {}

// Returns nullptr if |origin_string| couldn't be parsed into an acceptable
// origin.
scoped_refptr<const SecurityOrigin> ParseOrigin(const String& origin_string) {}

// WebIDL -> Mojom copy functions -- each return true if successful (including
// the not present, nothing to copy case), returns false and throws JS exception
// for invalid input.

// joinAdInterestGroup() copy functions.

// TODO(crbug.com/1451034): Remove method when old expiration is removed.
bool CopyLifetimeIdlToMojo(ExceptionState& exception_state,
                           std::optional<double> lifetime_seconds,
                           const AuctionAdInterestGroup& input,
                           mojom::blink::InterestGroup& output) {}

bool CopyOwnerFromIdlToMojo(const ExecutionContext& execution_context,
                            ExceptionState& exception_state,
                            const AuctionAdInterestGroup& input,
                            mojom::blink::InterestGroup& output) {}

// Converts a sparse vector used in `priority_vector` and
// `priority_signals_overrides` to a WTF::HashMap, as is used in mojom structs.
// Has no failure cases.
WTF::HashMap<WTF::String, double> ConvertSparseVectorIdlToMojo(
    const Vector<std::pair<WTF::String, double>>& priority_signals_in) {}

mojom::blink::SellerCapabilitiesPtr ConvertSellerCapabilitiesTypeFromIdlToMojo(
    const ExecutionContext& execution_context,
    const Vector<String>& capabilities_vector) {}

bool CopySellerCapabilitiesFromIdlToMojo(
    const ExecutionContext& execution_context,
    ExceptionState& exception_state,
    const AuctionAdInterestGroup& input,
    mojom::blink::InterestGroup& output) {}

bool CopyExecutionModeFromIdlToMojo(const ExecutionContext& execution_context,
                                    ExceptionState& exception_state,
                                    const AuctionAdInterestGroup& input,
                                    mojom::blink::InterestGroup& output) {}

bool CopyBiddingLogicUrlFromIdlToMojo(const ExecutionContext& context,
                                      ExceptionState& exception_state,
                                      const AuctionAdInterestGroup& input,
                                      mojom::blink::InterestGroup& output) {}

bool CopyWasmHelperUrlFromIdlToMojo(const ExecutionContext& context,
                                    ExceptionState& exception_state,
                                    const AuctionAdInterestGroup& input,
                                    mojom::blink::InterestGroup& output) {}

bool CopyUpdateUrlFromIdlToMojo(const ExecutionContext& context,
                                ExceptionState& exception_state,
                                const AuctionAdInterestGroup& input,
                                mojom::blink::InterestGroup& output) {}

bool CopyTrustedBiddingSignalsUrlFromIdlToMojo(
    const ExecutionContext& context,
    ExceptionState& exception_state,
    const AuctionAdInterestGroup& input,
    mojom::blink::InterestGroup& output) {}

bool CopyTrustedBiddingSignalsKeysFromIdlToMojo(
    const AuctionAdInterestGroup& input,
    mojom::blink::InterestGroup& output) {}

bool CopyTrustedBiddingSignalsSlotSizeModeFromIdlToMojo(
    const AuctionAdInterestGroup& input,
    mojom::blink::InterestGroup& output) {}

bool CopyMaxTrustedBiddingSignalsURLLengthFromIdlToMojo(
    ExceptionState& exception_state,
    const AuctionAdInterestGroup& input,
    mojom::blink::InterestGroup& output) {}

// TODO(crbug.com/352420077):
// 1. Add an allow list for `trustedBiddingSignalsCoordinator`, and return an
// error or warning if the given coordinator is not in the list.
// 2. Test input with invalid https origin in web platform tests.
bool CopyTrustedBiddingSignalsCoordinatorFromIdlToMojo(
    ExceptionState& exception_state,
    const AuctionAdInterestGroup& input,
    mojom::blink::InterestGroup& output) {}

bool CopyUserBiddingSignalsFromIdlToMojo(const ScriptState& script_state,
                                         ExceptionState& exception_state,
                                         const AuctionAdInterestGroup& input,
                                         mojom::blink::InterestGroup& output) {}

bool CopyAdsFromIdlToMojo(const ExecutionContext& context,
                          const ScriptState& script_state,
                          ExceptionState& exception_state,
                          const AuctionAdInterestGroup& input,
                          mojom::blink::InterestGroup& output) {}

bool CopyAdComponentsFromIdlToMojo(const ExecutionContext& context,
                                   const ScriptState& script_state,
                                   ExceptionState& exception_state,
                                   const AuctionAdInterestGroup& input,
                                   mojom::blink::InterestGroup& output) {}

bool CopyAdSizesFromIdlToMojo(const ExecutionContext& context,
                              const ScriptState& script_state,
                              ExceptionState& exception_state,
                              const AuctionAdInterestGroup& input,
                              mojom::blink::InterestGroup& output) {}

bool CopySizeGroupsFromIdlToMojo(const ExecutionContext& context,
                                 const ScriptState& script_state,
                                 ExceptionState& exception_state,
                                 const AuctionAdInterestGroup& input,
                                 mojom::blink::InterestGroup& output) {}

bool CopyAuctionServerRequestFlagsFromIdlToMojo(
    const ExecutionContext& execution_context,
    ExceptionState& exception_state,
    const AuctionAdInterestGroup& input,
    mojom::blink::InterestGroup& output) {}

bool CopyAdditionalBidKeyFromIdlToMojo(
    const ExecutionContext& execution_context,
    ExceptionState& exception_state,
    const AuctionAdInterestGroup& input,
    mojom::blink::InterestGroup& output) {}

bool GetAggregationCoordinatorFromConfig(
    ExceptionState& exception_state,
    const ProtectedAudiencePrivateAggregationConfig& config,
    scoped_refptr<const SecurityOrigin>& aggregation_coordinator_origin_out) {}

bool CopyAggregationCoordinatorOriginFromIdlToMojo(
    ExceptionState& exception_state,
    const AuctionAdInterestGroup& input,
    mojom::blink::InterestGroup& output) {}

// createAdRequest copy functions.
bool CopyAdRequestUrlFromIdlToMojo(const ExecutionContext& context,
                                   ExceptionState& exception_state,
                                   const AdRequestConfig& input,
                                   mojom::blink::AdRequestConfig& output) {}

bool CopyAdPropertiesFromIdlToMojo(const ExecutionContext& context,
                                   ExceptionState& exception_state,
                                   const AdRequestConfig& input,
                                   mojom::blink::AdRequestConfig& output) {}

bool CopyTargetingFromIdlToMojo(const ExecutionContext& context,
                                ExceptionState& exception_state,
                                const AdRequestConfig& input,
                                mojom::blink::AdRequestConfig& output) {}

bool CopyAdSignalsFromIdlToMojo(const ExecutionContext& context,
                                ExceptionState& exception_state,
                                const AdRequestConfig& input,
                                mojom::blink::AdRequestConfig& output) {}

bool CopyFallbackSourceFromIdlToMojo(const ExecutionContext& context,
                                     ExceptionState& exception_state,
                                     const AdRequestConfig& input,
                                     mojom::blink::AdRequestConfig& output) {}

// runAdAuction() copy functions.

bool CopySellerFromIdlToMojo(ExceptionState& exception_state,
                             const AuctionAdConfig& input,
                             mojom::blink::AuctionAdConfig& output) {}

bool CopyServerResponseFromIdlToMojo(
    NavigatorAuction::AuctionHandle* auction_handle,
    mojom::blink::AuctionAdConfigAuctionId* auction_id,
    ExceptionState& exception_state,
    const AuctionAdConfig& input,
    mojom::blink::AuctionAdConfig& output) {}

bool CopyDecisionLogicUrlFromIdlToMojo(const ExecutionContext& context,
                                       ExceptionState& exception_state,
                                       const AuctionAdConfig& input,
                                       mojom::blink::AuctionAdConfig& output) {}

bool CopyTrustedScoringSignalsFromIdlToMojo(
    const ExecutionContext& context,
    ExceptionState& exception_state,
    const AuctionAdConfig& input,
    mojom::blink::AuctionAdConfig& output) {}

bool CopyMaxTrustedScoringSignalsURLLengthFromIdlToMojo(
    ExceptionState& exception_state,
    const AuctionAdConfig& input,
    mojom::blink::AuctionAdConfig& output) {}

// TODO(crbug.com/352420077):
// 1. Add an allow list for `trustedBiddingSignalsCoordinator`, and return an
// error or warning if the given coordinator is not in the list.
// 2. Test input with invalid https origin in web platform tests.
bool CopyTrustedScoringSignalsCoordinatorFromIdlToMojo(
    ExceptionState& exception_state,
    const AuctionAdConfig& input,
    mojom::blink::AuctionAdConfig& output) {}

bool CopyInterestGroupBuyersFromIdlToMojo(
    ExceptionState& exception_state,
    const AuctionAdConfig& input,
    mojom::blink::AuctionAdConfig& output) {}

mojom::blink::AuctionAdConfigMaybePromiseJsonPtr
ConvertJsonPromiseFromIdlToMojo(
    NavigatorAuction::AuctionHandle* auction_handle,
    mojom::blink::AuctionAdConfigAuctionId* auction_id,
    const AuctionAdConfig& input,
    const ScriptPromiseUntyped& promise,
    mojom::blink::AuctionAdConfigField field,
    const char* field_name) {}

// null `auction_handle` disables promise handling.
// `auction_id` should be null iff `auction_handle` is.
void CopyAuctionSignalsFromIdlToMojo(
    NavigatorAuction::AuctionHandle* auction_handle,
    mojom::blink::AuctionAdConfigAuctionId* auction_id,
    const AuctionAdConfig& input,
    mojom::blink::AuctionAdConfig& output) {}

void CopySellerSignalsFromIdlToMojo(
    NavigatorAuction::AuctionHandle* auction_handle,
    mojom::blink::AuctionAdConfigAuctionId* auction_id,
    const AuctionAdConfig& input,
    mojom::blink::AuctionAdConfig& output) {}

// Attempts to build a DirectFromSellerSignalsSubresource. If there is no
// registered subresource URL `subresource_url` returns nullptr -- processing
// may continue with the next `subresource_url`.
mojom::blink::DirectFromSellerSignalsSubresourcePtr
TryToBuildDirectFromSellerSignalsSubresource(
    const KURL& subresource_url,
    const SecurityOrigin& seller,
    ExceptionState& exception_state,
    const ResourceFetcher& resource_fetcher) {}

mojom::blink::DirectFromSellerSignalsPtr
ConvertDirectFromSellerSignalsFromV8ToMojo(
    const ScriptState& script_state,
    const ExecutionContext& context,
    ExceptionState& exception_state,
    const ResourceFetcher& resource_fetcher,
    const String& seller_name,
    const SecurityOrigin& seller_origin,
    const std::optional<Vector<scoped_refptr<const SecurityOrigin>>>&
        interest_group_buyers,
    v8::Local<v8::Value> value) {}

String ConvertIDLStringFromV8ToMojo(const ScriptState& script_state,
                                    ExceptionState& exception_state,
                                    v8::Local<v8::Value> value) {}

void CopyDirectFromSellerSignalsFromIdlToMojo(
    NavigatorAuction::AuctionHandle* auction_handle,
    const mojom::blink::AuctionAdConfigAuctionId* auction_id,
    const AuctionAdConfig& input,
    mojom::blink::AuctionAdConfig& output) {}

void CopyDirectFromSellerSignalsHeaderAdSlotFromIdlToMojo(
    NavigatorAuction::AuctionHandle* auction_handle,
    const mojom::blink::AuctionAdConfigAuctionId* auction_id,
    const AuctionAdConfig& input,
    mojom::blink::AuctionAdConfig& output) {}

WTF::Vector<mojom::blink::AdKeywordReplacementPtr>
ConvertVectorIdlToMojoDeprecatedRenderUrlReplacement(
    const Vector<std::pair<WTF::String, WTF::String>>& input) {}

WTF::Vector<mojom::blink::AdKeywordReplacementPtr>
ConvertNonPromiseDeprecatedRenderURLReplacementsFromV8ToMojo(
    const ScriptState& script_state,
    ExceptionState& exception_state,
    const String& seller_name,
    v8::Local<v8::Value> value) {}

void CopyDeprecatedRenderURLReplacementsFromIdlToMojo(
    NavigatorAuction::AuctionHandle* auction_handle,
    const mojom::blink::AuctionAdConfigAuctionId* auction_id,
    const AuctionAdConfig& input,
    mojom::blink::AuctionAdConfig& output) {}

bool CopyAdditionalBidsFromIdlToMojo(
    NavigatorAuction::AuctionHandle* auction_handle,
    const mojom::blink::AuctionAdConfigAuctionId* auction_id,
    ExceptionState& exception_state,
    const AuctionAdConfig& input,
    mojom::blink::AuctionAdConfig& output) {}

bool CopyAggregationCoordinatorOriginFromIdlToMojo(
    ExceptionState& exception_state,
    const AuctionAdConfig& input,
    mojom::blink::AuctionAdConfig& output) {}

std::optional<
    mojom::blink::AuctionAdConfigNonSharedParams::RealTimeReportingType>
GetRealTimeReportingTypeFromConfig(
    const AuctionRealTimeReportingConfig& config) {}

bool CopyPerBuyerRealTimeReportingTypesFromIdlToMojo(
    ExceptionState& exception_state,
    const AuctionAdConfig& input,
    mojom::blink::AuctionAdConfig& output) {}

// Returns nullopt + sets exception on failure, or returns a concrete value.
std::optional<HashMap<scoped_refptr<const SecurityOrigin>, String>>
ConvertNonPromisePerBuyerSignalsFromV8ToMojo(const ScriptState& script_state,
                                             ExceptionState& exception_state,
                                             const String& seller_name,
                                             v8::Local<v8::Value> value) {}

void CopyPerBuyerSignalsFromIdlToMojo(
    NavigatorAuction::AuctionHandle* auction_handle,
    const mojom::blink::AuctionAdConfigAuctionId* auction_id,
    const AuctionAdConfig& input,
    mojom::blink::AuctionAdConfig& output) {}

// Returns nullptr + sets exception on failure, or returns a concrete value.
//
// This is shared logic for `perBuyerTimeouts` and `perBuyerCumulativeTimeouts`,
// with `field` indicating which name to use in error messages. The logic is
// identical in both cases.
mojom::blink::AuctionAdConfigBuyerTimeoutsPtr
ConvertNonPromisePerBuyerTimeoutsFromV8ToMojo(
    const ScriptState& script_state,
    ExceptionState& exception_state,
    const String& seller_name,
    v8::Local<v8::Value> value,
    mojom::blink::AuctionAdConfigBuyerTimeoutField field) {}

void CopyPerBuyerTimeoutsFromIdlToMojo(
    NavigatorAuction::AuctionHandle* auction_handle,
    const mojom::blink::AuctionAdConfigAuctionId* auction_id,
    const AuctionAdConfig& input,
    mojom::blink::AuctionAdConfig& output) {}

void CopyPerBuyerCumulativeTimeoutsFromIdlToMojo(
    NavigatorAuction::AuctionHandle* auction_handle,
    const mojom::blink::AuctionAdConfigAuctionId* auction_id,
    const AuctionAdConfig& input,
    mojom::blink::AuctionAdConfig& output) {}

// Returns nullptr + sets exception on failure, or returns a concrete value.
mojom::blink::AuctionAdConfigBuyerCurrenciesPtr
ConvertNonPromisePerBuyerCurrenciesFromV8ToMojo(const ScriptState& script_state,
                                                ExceptionState& exception_state,
                                                const String& seller_name,
                                                v8::Local<v8::Value> value) {}

void CopyPerBuyerCurrenciesFromIdlToMojo(
    NavigatorAuction::AuctionHandle* auction_handle,
    const mojom::blink::AuctionAdConfigAuctionId* auction_id,
    const AuctionAdConfig& input,
    mojom::blink::AuctionAdConfig& output) {}

bool CopyPerBuyerExperimentIdsFromIdlToMojo(
    const ScriptState& script_state,
    ExceptionState& exception_state,
    const AuctionAdConfig& input,
    mojom::blink::AuctionAdConfig& output) {}

bool CopyPerBuyerGroupLimitsFromIdlToMojo(
    const ScriptState& script_state,
    ExceptionState& exception_state,
    const AuctionAdConfig& input,
    mojom::blink::AuctionAdConfig& output) {}

bool ConvertAuctionConfigPrioritySignalsFromIdlToMojo(
    ExceptionState& exception_state,
    const AuctionAdConfig& input,
    const Vector<std::pair<WTF::String, double>>& priority_signals_in,
    WTF::HashMap<WTF::String, double>& priority_signals_out) {}

bool CopyPerBuyerPrioritySignalsFromIdlToMojo(
    ExceptionState& exception_state,
    const AuctionAdConfig& input,
    mojom::blink::AuctionAdConfig& output) {}

// TODO(caraitto): Consider validating keys -- no bucket base + offset
// conflicts, no overflow, etc.
bool CopyAuctionReportBuyerKeysFromIdlToMojo(
    ExecutionContext& execution_context,
    ExceptionState& exception_state,
    const AuctionAdConfig& input,
    mojom::blink::AuctionAdConfig& output) {}

bool CopyAuctionReportBuyersFromIdlToMojo(
    ExecutionContext& execution_context,
    ExceptionState& exception_state,
    const AuctionAdConfig& input,
    mojom::blink::AuctionAdConfig& output) {}

bool CopyAuctionReportBuyerDebugModeConfigFromIdlToMojo(
    ExecutionContext& execution_context,
    ExceptionState& exception_state,
    const AuctionAdConfig& input,
    mojom::blink::AuctionAdConfig& output) {}

bool CopyRequiredSellerSignalsFromIdlToMojo(
    const ExecutionContext& execution_context,
    ExceptionState& exception_state,
    const AuctionAdConfig& input,
    mojom::blink::AuctionAdConfig& output) {}

mojom::blink::AdSizePtr ParseAdSize(const AuctionAdConfig& input,
                                    const AuctionAdInterestGroupSize& size,
                                    const char* field_name,
                                    ExceptionState& exception_state) {}

bool CopyRequestedSizeFromIdlToMojo(const ExecutionContext& execution_context,
                                    ExceptionState& exception_state,
                                    const AuctionAdConfig& input,
                                    mojom::blink::AuctionAdConfig& output) {}

// This must be called after CopyRequestedSizeFromIdlToMojo(), since it verifies
// that if both `all_slots_requested_sizes` and `requested_size` are set, then
// the former contains the latter.
bool CopyAllSlotsRequestedSizesFromIdlToMojo(
    const ExecutionContext& execution_context,
    ExceptionState& exception_state,
    const AuctionAdConfig& input,
    mojom::blink::AuctionAdConfig& output) {}

bool CopyPerBuyerMultiBidsLimitsFromIdlToMojo(
    const ScriptState& script_state,
    ExceptionState& exception_state,
    const AuctionAdConfig& input,
    mojom::blink::AuctionAdConfig& output) {}

bool CopyAuctionNonceFromIdlToMojo(const ExecutionContext& execution_context,
                                   ExceptionState& exception_state,
                                   const AuctionAdConfig& input,
                                   mojom::blink::AuctionAdConfig& output) {}

// Attempts to convert the AuctionAdConfig `config`, passed in via Javascript,
// to a `mojom::blink::AuctionAdConfig`. Throws a Javascript exception and
// return null on failure. `auction_handle` is used for promise handling;
// if it's null, promise will not be accepted.
mojom::blink::AuctionAdConfigPtr IdlAuctionConfigToMojo(
    NavigatorAuction::AuctionHandle* auction_handle,
    bool is_top_level,
    uint32_t nested_pos,
    ScriptState& script_state,
    ExecutionContext& context,
    ExceptionState& exception_state,
    const ResourceFetcher& resource_fetcher,
    const AuctionAdConfig& config) {}

// finalizeAd() validation methods
bool ValidateAdsObject(ExceptionState& exception_state, const Ads* ads) {}

void RecordCommonFledgeUseCounters(Document* document) {}

// Several dictionary members are being renamed -- to maintain compatibility
// with existing scripts, both the new names and the old names will need to be
// supported for a time before support for the older names are dropped.
//
// If both names are supplied, they must have the same value (this allows
// scripts to be compatible with newer and older browsers).
//
// Some fields that were "required" in WebIDL also get checked -- during the
// rename, these fields aren't marked as required in WebIDL, but at least one
// of the old or new name versions must be specified.
bool HandleOldDictNamesJoin(AuctionAdInterestGroup* group,
                            ExceptionState& exception_state) {}

bool HandleOldDictNamesRun(AuctionAdConfig* config,
                           ExceptionState& exception_state) {}

// TODO(crbug.com/1451034): Remove indirection method
// JoinAdInterestGroupInternal() when old expiration is removed.
ScriptPromise<IDLUndefined> JoinAdInterestGroupInternal(
    ScriptState* script_state,
    Navigator& navigator,
    AuctionAdInterestGroup* group,
    std::optional<double> duration_seconds,
    ExceptionState& exception_state) {}

}  // namespace

NavigatorAuction::AuctionHandle::AuctionHandleFunction::AuctionHandleFunction(
    AuctionHandle* auction_handle)
    :{}

void NavigatorAuction::AuctionHandle::AuctionHandleFunction::Trace(
    Visitor* visitor) const {}

ScriptValue NavigatorAuction::AuctionHandle::AuctionHandleFunction::Call(
    ScriptState* script_state,
    ScriptValue value) {}

NavigatorAuction::AuctionHandle::JsonResolved::JsonResolved(
    AuctionHandle* auction_handle,
    mojom::blink::AuctionAdConfigAuctionIdPtr auction_id,
    mojom::blink::AuctionAdConfigField field,
    const String& seller_name,
    const char* field_name)
    :{}

void NavigatorAuction::AuctionHandle::JsonResolved::CallImpl(
    ScriptState* script_state,
    ScriptValue value,
    ExceptionState& exception_state) {}

NavigatorAuction::AuctionHandle::PerBuyerSignalsResolved::
    PerBuyerSignalsResolved(
        AuctionHandle* auction_handle,
        mojom::blink::AuctionAdConfigAuctionIdPtr auction_id,
        const String& seller_name)
    :{}

void NavigatorAuction::AuctionHandle::PerBuyerSignalsResolved::CallImpl(
    ScriptState* script_state,
    ScriptValue value,
    ExceptionState& exception_state) {}

NavigatorAuction::AuctionHandle::DeprecatedRenderURLReplacementsResolved::
    DeprecatedRenderURLReplacementsResolved(
        AuctionHandle* auction_handle,
        mojom::blink::AuctionAdConfigAuctionIdPtr auction_id,
        const String& seller_name)
    :{}

void NavigatorAuction::AuctionHandle::DeprecatedRenderURLReplacementsResolved::
    CallImpl(ScriptState* script_state,
             ScriptValue value,
             ExceptionState& exception_state) {}

NavigatorAuction::AuctionHandle::BuyerTimeoutsResolved::BuyerTimeoutsResolved(
    AuctionHandle* auction_handle,
    mojom::blink::AuctionAdConfigAuctionIdPtr auction_id,
    mojom::blink::AuctionAdConfigBuyerTimeoutField field,
    const String& seller_name)
    :{}

void NavigatorAuction::AuctionHandle::BuyerTimeoutsResolved::CallImpl(
    ScriptState* script_state,
    ScriptValue value,
    ExceptionState& exception_state) {}

NavigatorAuction::AuctionHandle::BuyerCurrenciesResolved::
    BuyerCurrenciesResolved(
        AuctionHandle* auction_handle,
        mojom::blink::AuctionAdConfigAuctionIdPtr auction_id,
        const String& seller_name)
    :{}

void NavigatorAuction::AuctionHandle::BuyerCurrenciesResolved::CallImpl(
    ScriptState* script_state,
    ScriptValue value,
    ExceptionState& exception_state) {}

NavigatorAuction::AuctionHandle::DirectFromSellerSignalsResolved::
    DirectFromSellerSignalsResolved(
        AuctionHandle* auction_handle,
        mojom::blink::AuctionAdConfigAuctionIdPtr auction_id,
        const String& seller_name,
        const scoped_refptr<const SecurityOrigin>& seller_origin,
        const std::optional<Vector<scoped_refptr<const SecurityOrigin>>>&
            interest_group_buyers)
    :{}

void NavigatorAuction::AuctionHandle::DirectFromSellerSignalsResolved::CallImpl(
    ScriptState* script_state,
    ScriptValue value,
    ExceptionState& exception_state) {}

NavigatorAuction::AuctionHandle::DirectFromSellerSignalsHeaderAdSlotResolved::
    DirectFromSellerSignalsHeaderAdSlotResolved(
        AuctionHandle* auction_handle,
        mojom::blink::AuctionAdConfigAuctionIdPtr auction_id,
        const String& seller_name)
    :{}

void NavigatorAuction::AuctionHandle::
    DirectFromSellerSignalsHeaderAdSlotResolved::CallImpl(
        ScriptState* script_state,
        ScriptValue value,
        ExceptionState& exception_state) {}

NavigatorAuction::AuctionHandle::ServerResponseResolved::ServerResponseResolved(
    AuctionHandle* auction_handle,
    mojom::blink::AuctionAdConfigAuctionIdPtr auction_id,
    const String& seller_name)
    :{}

void NavigatorAuction::AuctionHandle::ServerResponseResolved::CallImpl(
    ScriptState* script_state,
    ScriptValue value,
    ExceptionState& exception_state) {}

NavigatorAuction::AuctionHandle::AdditionalBidsResolved::AdditionalBidsResolved(
    AuctionHandle* auction_handle,
    mojom::blink::AuctionAdConfigAuctionIdPtr auction_id,
    const String& seller_name)
    :{}

void NavigatorAuction::AuctionHandle::AdditionalBidsResolved::CallImpl(
    ScriptState* script_state,
    ScriptValue,
    ExceptionState&) {}

NavigatorAuction::AuctionHandle::ResolveToConfigResolved::
    ResolveToConfigResolved(AuctionHandle* auction_handle)
    :{}

void NavigatorAuction::AuctionHandle::ResolveToConfigResolved::CallImpl(
    ScriptState* script_state,
    ScriptValue value,
    ExceptionState&) {}

NavigatorAuction::AuctionHandle::Rejected::Rejected(
    AuctionHandle* auction_handle)
    :{}

void NavigatorAuction::AuctionHandle::Rejected::CallImpl(ScriptState*,
                                                         ScriptValue,
                                                         ExceptionState&) {}

NavigatorAuction::NavigatorAuction(Navigator& navigator)
    :{}

NavigatorAuction& NavigatorAuction::From(ExecutionContext* context,
                                         Navigator& navigator) {}

const char NavigatorAuction::kSupplementName[] =;

ScriptPromise<IDLUndefined> NavigatorAuction::joinAdInterestGroup(
    ScriptState* script_state,
    AuctionAdInterestGroup* mutable_group,
    std::optional<double> lifetime_seconds,
    ExceptionState& exception_state) {}

/* static */
ScriptPromise<IDLUndefined> NavigatorAuction::joinAdInterestGroup(
    ScriptState* script_state,
    Navigator& navigator,
    AuctionAdInterestGroup* group,
    double duration_seconds,
    ExceptionState& exception_state) {}

/* static */
ScriptPromise<IDLUndefined> NavigatorAuction::joinAdInterestGroup(
    ScriptState* script_state,
    Navigator& navigator,
    AuctionAdInterestGroup* group,
    ExceptionState& exception_state) {}

ScriptPromise<IDLUndefined> NavigatorAuction::leaveAdInterestGroup(
    ScriptState* script_state,
    const AuctionAdInterestGroupKey* group_key,
    ExceptionState& exception_state) {}

ScriptPromise<IDLUndefined> NavigatorAuction::leaveAdInterestGroupForDocument(
    ScriptState* script_state,
    ExceptionState& exception_state) {}

/* static */
ScriptPromise<IDLUndefined> NavigatorAuction::leaveAdInterestGroup(
    ScriptState* script_state,
    Navigator& navigator,
    const AuctionAdInterestGroupKey* group_key,
    ExceptionState& exception_state) {}

/* static */
ScriptPromise<IDLUndefined> NavigatorAuction::leaveAdInterestGroup(
    ScriptState* script_state,
    Navigator& navigator,
    ExceptionState& exception_state) {}

ScriptPromise<IDLUndefined> NavigatorAuction::clearOriginJoinedAdInterestGroups(
    ScriptState* script_state,
    const String owner_string,
    const Vector<String> interest_groups_to_keep,
    ExceptionState& exception_state) {}

/* static */
ScriptPromise<IDLUndefined> NavigatorAuction::clearOriginJoinedAdInterestGroups(
    ScriptState* script_state,
    Navigator& navigator,
    const String owner,
    ExceptionState& exception_state) {}

/* static */
ScriptPromise<IDLUndefined> NavigatorAuction::clearOriginJoinedAdInterestGroups(
    ScriptState* script_state,
    Navigator& navigator,
    const String owner,
    const Vector<String> interest_groups_to_keep,
    ExceptionState& exception_state) {}

void NavigatorAuction::updateAdInterestGroups() {}

/* static */
void NavigatorAuction::updateAdInterestGroups(ScriptState* script_state,
                                              Navigator& navigator,
                                              ExceptionState& exception_state) {}

namespace {
// Combines the base auction nonce with the auction nonce counter as follows:
// - Retain the first 30 characters of the base auction nonce exactly as is
// - For the last six hexadecimal characters, add the value of those from the
//   base auction nonce to the value of the auction nonce counter, truncating
//   anything that overflows the resulting 24-bit unsigned integer.
//
// As such, given a base auction nonce of c1cf78b5-fa6e-4bfb-a215-896c6aedd9f1,
// this function will produce the following return value given each of the
// following argument values for auction_nonce_counter:
// 0                 --> c1cf78b5-fa6e-4bfb-a215-896c6aedd9f1
// 1                 --> c1cf78b5-fa6e-4bfb-a215-896c6aedd9f2
// 1189390           --> c1cf78b5-fa6e-4bfb-a215-896c6affffff
// 1189391           --> c1cf78b5-fa6e-4bfb-a215-896c6a000000
// 16777215 (2^24-1) --> c1cf78b5-fa6e-4bfb-a215-896c6aedd9f0
// 16777216 (2^24)   --> c1cf78b5-fa6e-4bfb-a215-896c6aedd9f1
// 16777217 (2^24+1) --> c1cf78b5-fa6e-4bfb-a215-896c6aedd9f2
//
// This function CHECK-fails if the provided base auction nonce is not valid.
String CombineAuctionNonce(base::Uuid base_auction_nonce,
                           uint32_t auction_nonce_counter) {}
}  // namespace

ScriptPromise<IDLString> NavigatorAuction::createAuctionNonce(
    ScriptState* script_state,
    ExceptionState& exception_state) {}

/* static */
ScriptPromise<IDLString> NavigatorAuction::createAuctionNonce(
    ScriptState* script_state,
    Navigator& navigator,
    ExceptionState& exception_state) {}

ScriptPromise<IDLNullable<V8UnionFencedFrameConfigOrUSVString>>
NavigatorAuction::runAdAuction(ScriptState* script_state,
                               AuctionAdConfig* mutable_config,
                               ExceptionState& exception_state,
                               base::TimeTicks start_time) {}

/* static */
ScriptPromise<IDLNullable<V8UnionFencedFrameConfigOrUSVString>>
NavigatorAuction::runAdAuction(ScriptState* script_state,
                               Navigator& navigator,
                               AuctionAdConfig* config,
                               ExceptionState& exception_state) {}

/* static */
Vector<String> NavigatorAuction::adAuctionComponents(
    ScriptState* script_state,
    Navigator& navigator,
    uint16_t num_ad_components,
    ExceptionState& exception_state) {}

ScriptPromise<IDLUSVString> NavigatorAuction::deprecatedURNToURL(
    ScriptState* script_state,
    const String& uuid_url_string,
    bool send_reports,
    ExceptionState& exception_state) {}

ScriptPromise<IDLUSVString> NavigatorAuction::deprecatedURNToURL(
    ScriptState* script_state,
    Navigator& navigator,
    const V8UnionFencedFrameConfigOrUSVString* urn_or_config,
    bool send_reports,
    ExceptionState& exception_state) {}

ScriptPromise<IDLUndefined> NavigatorAuction::deprecatedReplaceInURN(
    ScriptState* script_state,
    const String& uuid_url_string,
    const Vector<std::pair<String, String>>& replacements,
    ExceptionState& exception_state) {}

ScriptPromise<IDLUndefined> NavigatorAuction::deprecatedReplaceInURN(
    ScriptState* script_state,
    Navigator& navigator,
    const V8UnionFencedFrameConfigOrUSVString* urn_or_config,
    const Vector<std::pair<String, String>>& replacements,
    ExceptionState& exception_state) {}

ScriptPromise<Ads> NavigatorAuction::createAdRequest(
    ScriptState* script_state,
    const AdRequestConfig* config,
    ExceptionState& exception_state) {}

/* static */
ScriptPromise<Ads> NavigatorAuction::createAdRequest(
    ScriptState* script_state,
    Navigator& navigator,
    const AdRequestConfig* config,
    ExceptionState& exception_state) {}

void NavigatorAuction::AdsRequested(ScriptPromiseResolver<Ads>* resolver,
                                    const WTF::String&) {}

ScriptPromise<IDLString> NavigatorAuction::finalizeAd(
    ScriptState* script_state,
    const Ads* ads,
    const AuctionAdConfig* config,
    ExceptionState& exception_state) {}

/* static */
ScriptPromise<IDLString> NavigatorAuction::finalizeAd(
    ScriptState* script_state,
    Navigator& navigator,
    const Ads* ads,
    const AuctionAdConfig* config,
    ExceptionState& exception_state) {}

void NavigatorAuction::FinalizeAdComplete(
    ScriptPromiseResolver<IDLString>* resolver,
    const std::optional<KURL>& creative_url) {}

void NavigatorAuction::StartJoin(PendingJoin&& pending_join) {}

void NavigatorAuction::JoinComplete(
    bool is_cross_origin,
    ScriptPromiseResolver<IDLUndefined>* resolver,
    bool failed_well_known_check) {}

void NavigatorAuction::StartLeave(PendingLeave&& pending_leave) {}

void NavigatorAuction::LeaveComplete(
    bool is_cross_origin,
    ScriptPromiseResolver<IDLUndefined>* resolver,
    bool failed_well_known_check) {}

void NavigatorAuction::StartClear(PendingClear&& pending_clear) {}

void NavigatorAuction::ClearComplete(
    bool is_cross_origin,
    ScriptPromiseResolver<IDLUndefined>* resolver,
    bool failed_well_known_check) {}

void NavigatorAuction::AuctionHandle::AuctionComplete(
    ScriptPromiseResolver<IDLNullable<V8UnionFencedFrameConfigOrUSVString>>*
        resolver,
    std::unique_ptr<ScopedAbortState> scoped_abort_state,
    base::TimeTicks start_time,
    bool is_server_auction,
    bool aborted_by_script,
    const std::optional<FencedFrame::RedactedFencedFrameConfig>&
        result_config) {}

bool NavigatorAuction::AuctionHandle::MaybeResolveAuction() {}

void NavigatorAuction::GetURLFromURNComplete(
    ScriptPromiseResolver<IDLUSVString>* resolver,
    const std::optional<KURL>& decoded_url) {}

void NavigatorAuction::ReplaceInURNComplete(
    ScriptPromiseResolver<IDLUndefined>* resolver) {}

bool NavigatorAuction::canLoadAdAuctionFencedFrame(ScriptState* script_state) {}

/* static */
bool NavigatorAuction::canLoadAdAuctionFencedFrame(ScriptState* script_state,
                                                   Navigator& navigator) {}

bool NavigatorAuction::deprecatedRunAdAuctionEnforcesKAnonymity(
    ScriptState* script_state,
    Navigator&) {}

// static
ProtectedAudience* NavigatorAuction::protectedAudience(
    ScriptState* script_state,
    Navigator& navigator) {}

ScriptPromise<AdAuctionData> NavigatorAuction::getInterestGroupAdAuctionData(
    ScriptState* script_state,
    const AdAuctionDataConfig* config,
    ExceptionState& exception_state,
    base::TimeTicks start_time) {}

void NavigatorAuction::GetInterestGroupAdAuctionDataComplete(
    base::TimeTicks start_time,
    ScriptPromiseResolver<AdAuctionData>* resolver,
    mojo_base::BigBuffer data,
    const std::optional<base::Uuid>& request_id,
    const WTF::String& error_message) {}

/* static */
ScriptPromise<AdAuctionData> NavigatorAuction::getInterestGroupAdAuctionData(
    ScriptState* script_state,
    Navigator& navigator,
    const AdAuctionDataConfig* config,
    ExceptionState& exception_state) {}

}  // namespace blink