1. Introduction
This section is non-normative.
The Protected Audience API facilitates selecting an advertisement to display to a user based on a previous interaction with the advertiser or advertising network.
When a userโs interactions with an advertiser indicate an interest in something, the advertiser can
ask the browser to record this interest on-device by calling navigator
.joinAdInterestGroup()
. Later, when a website wants to select an
advertisement to show to the user, the website can call navigator
.runAdAuction()
to ask the browser to conduct an auction where each of these on-device recorded interests are given the chance to
calculate a bid to display their advertisement.
2. Joining Interest Groups
This first introductory paragraph is non-normative.
When a userโs interactions with a website indicate that the user may have a particular interest, an
advertiser or someone working on behalf of the advertiser (e.g. a demand side platform, DSP) can ask
the userโs browser to record this interest on-device by calling navigator
.joinAdInterestGroup()
. This indicates an intent to display an
advertisement relevant to this interest to this user in the future. The user agent has an interest group set, a list of interest groups in which owner / name pairs are unique.
2.1. joinAdInterestGroup()
TODO: Currently, several of the IDL fields in AuctionAdInterestGroup
are specified to use
USVString rather than DOMString, only because the initial implementation currently does. This may
contradict the recommended use of
DOMString.
(WICG/turtledove#1250)
[SecureContext ]partial interface Navigator {Promise <undefined >joinAdInterestGroup (AuctionAdInterestGroup ); };
group dictionary {
AuctionAd required USVString ;
renderURL USVString ;
sizeGroup any ;
metadata USVString ;
buyerReportingId USVString ;
buyerAndSellerReportingId sequence <USVString >;
selectableBuyerAndSellerReportingIds sequence <USVString >;
allowedReportingOrigins DOMString ;
adRenderId USVString ; };
creativeScanningMetadata dictionary {
AuctionAdInterestGroupSize required USVString ;
width required USVString ; };
height dictionary {
GenerateBidInterestGroup required USVString ;
owner required USVString ;
name boolean =
enableBiddingSignalsPrioritization false ;record <DOMString ,double >;
priorityVector record <USVString ,sequence <DOMString >>;
sellerCapabilities DOMString = "compatibility";
executionMode USVString ;
biddingLogicURL USVString ;
biddingWasmHelperURL USVString ;
updateURL USVString ;
trustedBiddingSignalsURL sequence <USVString >;
trustedBiddingSignalsKeys DOMString = "none";
trustedBiddingSignalsSlotSizeMode long ;
maxTrustedBiddingSignalsURLLength USVString ;
trustedBiddingSignalsCoordinator any ;
userBiddingSignals sequence <AuctionAd >;
ads sequence <AuctionAd >;
adComponents record <DOMString ,AuctionAdInterestGroupSize >;
adSizes record <DOMString ,sequence <DOMString >>; };
sizeGroups dictionary {
ProtectedAudiencePrivateAggregationConfig USVString ; };
aggregationCoordinatorOrigin dictionary :
AuctionAdInterestGroup GenerateBidInterestGroup {double = 0.0;
priority record <DOMString ,double >;
prioritySignalsOverrides required double ;
lifetimeMs DOMString ;
additionalBidKey ProtectedAudiencePrivateAggregationConfig ; };
privateAggregationConfig
AuctionAdInterestGroup
is used by navigator
.joinAdInterestGroup()
, and
when an interest group is stored to interest group set. priority
and prioritySignalsOverrides
are not passed to generateBid()
because they can be
modified by generatedBid()
calls, so could theoretically be used to create a cross-site profile of
a user accessible to generateBid()
methods, otherwise. lifetimeMs
is not passed to generateBid()
because itโs ambiguous what should be passed: the lifetime when the group was joined, or the
remaining lifetime. Providing the remaining lifetime would also potentially give access to more
granular timing information than the API would otherwise allow, when state is shared across interest
groups.
The joinAdInterestGroup(group)
method steps are:
Temporarily, Chromium does not include the required keyword
for lifetimeMs
, and instead starts this algorithm with the step
-
If group["
lifetimeMs
"] does not exist, throw aTypeError
.
This is detectable because it can change the set of fields that are read from the argument when a TypeError
is eventually thrown, but it will never change whether the call succeeds or fails.
-
Let global be thisโs relevant global object.
-
If globalโs associated Document is not allowed to use the "join-ad-interest-group" policy-controlled feature, then throw a "
NotAllowedError
"DOMException
. -
Let settings be thisโs relevant settings object.
-
Assert that settingsโs origin is not an opaque origin and its scheme is "
https
". -
Let interestGroup be a new interest group.
-
Validate the given group and set interestGroupโs fields accordingly.
-
Set interestGroupโs expiry to the current coarsened wall time plus group["
lifetimeMs
"] milliseconds. -
Set interestGroupโs next update after to the current coarsened wall time plus 24 hours.
-
Set interestGroupโs last updated to the current coarsened wall time.
-
Set interestGroupโs owner to the result of parsing an https origin on group["
owner
"]. -
If interestGroupโs owner is failure, then throw a
TypeError
. -
Optionally, throw a "
NotAllowedError
"DOMException
.Note: This implementation-defined condition is intended to allow user agents to decline for a number of reasons, for example the ownerโs site not being enrolled.
-
Set interestGroupโs enable bidding signals prioritization to group["
enableBiddingSignalsPrioritization
"]. -
If group["
priorityVector
"] exists, then set interestGroupโs priority vector to group["priorityVector
"]. -
If group["
prioritySignalsOverrides
"] exists, then set interestGroupโs priority signals overrides to group["prioritySignalsOverrides
"]. -
If group["
privateAggregationConfig
"] exists:-
Let aggregationCoordinator be the result of obtaining the coordinator from a Private Aggregation config given group["
privateAggregationConfig
"]. -
If aggregationCoordinator is a
DOMException
, then throw aggregationCoordinator. -
Set interestGroupโs Private Aggregation coordinator to aggregationCoordinator.
-
-
If group["
sellerCapabilities
"] exists, for each sellerString โ capabilities of group["sellerCapabilities
"]:-
Let sellerCapabilities be a new set of seller capabilities.
-
For each capabilityString of capabilities:
-
If sellerString is "
*
", then set interestGroupโs all sellers capabilities to sellerCapabilities. -
Otherwise:
-
If interestGroupโs seller capabilities is null, then set interestGroupโs seller capabilities to a new ordered map whose keys are origins and whose values are sets of seller capabilities.
-
Let sellerUrl be the result of running the URL parser on sellerString.
-
If sellerUrl is not failure:
-
Let seller be sellerUrlโs origin.
-
If interestGroupโs seller capabilities does not contain seller, then set interestGroupโs seller capabilities[seller] to sellerCapabilities.
-
-
-
-
If group["
executionMode
"] is "compatibility
", "frozen-context
", or "group-by-origin
", then set interestGroupโs execution mode to it. -
For each groupMember and interestGroupField in the following table
Group member Interest group field " biddingLogicURL
"bidding url " biddingWasmHelperURL
"bidding wasm helper url " updateURL
"update url -
If group contains groupMember:
-
Let parsedUrl be the result of running parse and verify a bidding code or update URL on group[groupMember] and interestGroupโs owner.
-
Set interestGroupโs interestGroupField to parsedUrl.
-
-
-
If group["
trustedBiddingSignalsURL
"] exists:-
Let parsedUrl be the result of running parse and verify a trusted signals URL on group[
trustedBiddingSignalsURL
]. -
Set interestGroupโs trusted bidding signals url to parsedUrl.
-
-
If group["
trustedBiddingSignalsKeys
"] exists, then set interestGroupโs trusted bidding signals keys to group["trustedBiddingSignalsKeys
"]. -
If group["
maxTrustedBiddingSignalsURLLength
"] exists:-
If group["
maxTrustedBiddingSignalsURLLength
"] โฅ 0, set interestGroupโs max trusted bidding signals url length to group["maxTrustedBiddingSignalsURLLength
"], otherwise throw aTypeError
.
-
-
If group["
trustedBiddingSignalsCoordinator
"] exists:-
Let parsedCoordinator be the result of parsing an https origin on group["
trustedBiddingSignalsCoordinator
"]. -
Set interestGroupโs trusted bidding signals coordinator to parsedCoordinator.
-
-
If group["
userBiddingSignals
"] exists:-
Set interestGroupโs user bidding signals to the result of serializing a JavaScript value to a JSON string, given group["
userBiddingSignals
"]. This can throw aTypeError
.
-
-
If group["
trustedBiddingSignalsSlotSizeMode
"] is one of "none", "slot-size", or "all-slots-requested-sizes", set interestGroupโs trusted bidding signals slot size mode to group["trustedBiddingSignalsSlotSizeMode
"]. -
Let adSizes be a new map whose keys are strings and values are ad sizes.
-
Let sizeGroups be a new map whose keys are strings and values are lists of strings
-
If group["
sizeGroups
"] exists:-
For each sizeGroupName โ sizeList of group["
sizeGroups
"]: -
Set interestGroupโs size groups to sizeGroups.
-
-
For each groupMember and interestGroupField in the following table
Group member Interest group field " ads
"ads " adComponents
"ad components -
If group contains groupMember, for each ad of group[groupMember]:
-
Let igAd be a new interest group ad.
-
Let renderURL be the result of running the URL parser on ad["
renderURL
"]. -
Throw a
TypeError
if any of the following conditions hold:-
renderURL is failure;
-
renderURL scheme is not "
https
"; -
renderURL includes credentials.
-
-
Set igAdโs render url to renderURL.
-
If ad["
metadata
"] exists, then let igAdโs metadata be the result of serializing a JavaScript value to a JSON string, given ad["metadata
"]. This can throw aTypeError
. -
If ad["
adRenderId
"] exists:-
If ad["
adRenderId
"]'s length > 12, throw aTypeError
. -
If any code point in ad["
adRenderId
"] is not an ASCII code point, throw aTypeError
. -
Set igAdโs ad render id to ad["
adRenderId
"].
-
-
If ad["
creativeScanningMetadata
"] exists, then set igAdโs creative scanning metadata to it. -
If groupMember is "
ads
":-
If ad["
buyerReportingId
"] exists, then set igAdโs buyer reporting ID to it. -
If ad["
buyerAndSellerReportingId
"] exists, then set igAdโs buyer and seller reporting ID to it. -
If ad["
selectableBuyerAndSellerReportingIds
"] exists, then set igAdโs selectable buyer and seller reporting IDs to it. -
If ad["
allowedReportingOrigins
"] exists:-
For each originStr in ad["
allowedReportingOrigins
"]: -
Set igAdโs allowed reporting origins to allowedReportingOrigins.
-
-
Append igAd to interestGroupโs interestGroupField.
-
-
-
If group["
additionalBidKey
"] exists:-
Let decodedKey be the result of running forgiving-base64 decode with group["
additionalBidKey
"]. -
Set interestGroupโs additional bid key to decodedKey.
-
-
-
If interestGroupโs estimated size > 1048576 bytes, then throw a
TypeError
. -
Let p be a new promise.
-
Let queue be the result of starting a new parallel queue.
-
Enqueue the following steps to queue:
-
Let permission be the result of checking interest group permissions with interestGroupโs owner, settings, and "
join
". -
If permission is false, then queue a global task on DOM manipulation task source, given global, to reject p with a "
NotAllowedError
"DOMException
and abort these steps. -
Queue a global task on DOM manipulation task source, given global, to resolve p with
undefined
. -
If the browser is currently storing an interest group with
owner
andname
that matches interestGroup, then set the bid counts, join counts, and previous wins of interestGroup to the values of the currently stored one and remove the currently stored one from the browser. -
Set interestGroupโs joining origin to thisโs relevant settings objectโs top-level origin.
-
Set interestGroupโs join time to the current coarsened wall time.
-
If the most recent entry in interestGroupโs join counts corresponds to the current day in UTC, increment its count. If not, insert a new tuple the time set to the current UTC day and a count of 1.
-
Store interestGroup in the user agentโs interest group set.
-
Run update k-anonymity cache for interest group for interestGroup.
-
-
Return p.
2.2. Interest Group Storage Maintenance
There is a job that periodically performs storage maintenance on the user agentโs interest group set. It performs operations such as removing expired or excess interest groups. An interest group set must respect the following limits. Implementations may define their own values for the below constants, however we supply the below values as a starting point, inspired by what the initial implementation of this specification uses:
-
Interest group set max owners is 1000, which defines the max number of owners in the user agentโs interest group set.
-
Max regular interest groups per owner is 2000, which defines the max number of regular interest groups in the user agentโs interest group set for an owner.
-
Max negative interest groups per owner is 20000, which defines the max number of negative interest groups in the user agentโs interest group set for an owner.
-
Max interest groups total size per owner is
10*1024*1024
, which defines the max total sizes of interest groups in the user agentโs interest group set for an owner. It includes both regular interest groups and negative interest groups.
-
Let ownersAndExpiry be a new ordered map whose keys are origins and values are moments.
Note: The key is from owner, and value is from expiry. Itโs used to determine a set of owners whose interest groups will be removed from the user agentโs interest group set because the number of distinct owners exceeds the Interest group set max owners limit. Itโs sorted based on their values (expiry) in descending order, in order to remove interest groups of owners expiring soonest first.
-
Let now be the current coarsened wall time.
-
For each ig of the user agentโs interest group set:
-
Let owner be igโs owner.
-
If igโs expiry is before now, then remove ig from the user agentโs interest group set and continue.
-
If ownersAndExpiry[owner] exists, then set ownersAndExpiry[owner] to igโs expiry if it comes after ownersAndExpiry[owner].
-
-
If ownersAndExpiryโs size > interest group set max owners, then set ownersAndExpiry to ownersAndExpiry sorted in descending order with a being less than b if aโs value comes before bโs value, where values are expiry.
-
Let owners be the keys of ownersAndExpiry.
-
For each i in the range from 0 to ownersโs size, exclusive:
-
If i โฅ interest group set max owners, then remove interest groups from the user agentโs interest group set whose owner is owners[i], and continue.
-
Let regularIgs be a list of regular interest groups in the user agentโs interest group set whose owner is owners[i].
-
If regularIgsโs size > max regular interest groups per owner, then clear excess interest groups with regularIgs and max regular interest groups per owner.
-
Let negativeIgs be a list of negative interest groups in the user agentโs interest group set whose owner is owners[i].
-
If negativeIgsโs size > max negative interest groups per owner, then clear excess interest groups with negativeIgs and max negative interest groups per owner.
-
-
For each owner of owners:
-
Let igs be a list of interest groups in the user agentโs interest group set whose owner is owner, sorted in descending order with a being less than b if aโs expiry comes before bโs expiry.
-
Let cumulativeSize be 0.
-
For each ig of igs:
-
If the sum of cumulativeSize and igโs estimated size > max interest groups total size per owner, then remove ig from the user agentโs interest group set.
-
Otherwise, increment cumulativeSize by igโs estimated size.
-
-
-
Let sortedIgs be igs sorted in descending order with a being less than b if aโs expiry comes before bโs expiry.
Note: In order to remove interest groups expiring soonest first, sort interest groups based on their expiry in descending order.
-
For each i in the range from maxIgs to igsโs size, exclusive:
-
Remove sortedIgs[i] from the user agentโs interest group set.
-
3. Leaving Interest Groups
3.1. leaveAdInterestGroup()
This first introductory paragraph is non-normative.
navigator
.leaveAdInterestGroup()
removes a user from a particular interest
group.
[SecureContext ]partial interface Navigator {Promise <undefined >leaveAdInterestGroup (optional AuctionAdInterestGroupKey = {}); };
group dictionary {
AuctionAdInterestGroupKey required USVString ;
owner required USVString ; };
name
The leaveAdInterestGroup(group)
method steps are:
-
Let global be thisโs relevant global object.
-
Let settings be thisโs relevant settings object.
-
Let frameOrigin be settingsโs origin.
-
Assert that frameOrigin is not an opaque origin and its scheme is "
https
". -
Let p be a new promise.
-
If group is empty:
-
Let instance be globalโs browsing contextโs fenced frame config instance.
-
If instance is null, then return.
-
Let interestGroup be instanceโs interest group descriptor.
-
Run these steps in parallel:
-
Queue a global task on DOM manipulation task source, given global, to resolve p with
undefined
. -
If interestGroup is not null:
-
Let owner be interestGroupโs owner.
-
If owner is same origin with frameOrigin, then remove interest groups from the user agentโs interest group set whose owner is owner and name is interestGroupโs name.
-
-
-
-
Otherwise:
-
If globalโs associated Document is not allowed to use the "join-ad-interest-group" policy-controlled feature, then throw a "
NotAllowedError
"DOMException
.Note: Both joining and leaving interest groups use the "join-ad-interest-group" feature.
-
Let owner be the result of parsing an https origin with group["
owner
"]. -
Run these steps in parallel:
-
Let permission be the result of checking interest group permissions with owner, settings, and "
leave
". -
If permission is false, then queue a global task on DOM manipulation task source, given global, to reject p with a "
NotAllowedError
"DOMException
and abort these steps. -
Queue a global task on DOM manipulation task source, given global, to resolve p with
undefined
. -
Remove interest groups from the user agentโs interest group set whose owner is owner and name is group["
name
"].
-
-
-
Return p.
3.2. clearOriginJoinedAdInterestGroups()
This first introductory paragraph is non-normative.
navigator
.clearOriginJoinedAdInterestGroups()
removes a user from interest groups whose joining origin is the associated Navigator
โs relevant settings objectโs top-level origin.
[SecureContext ]partial interface Navigator {Promise <undefined >clearOriginJoinedAdInterestGroups (USVString ,
owner optional sequence <USVString >= []); };
interestGroupsToKeep
The clearOriginJoinedAdInterestGroups(owner, interestGroupsToKeep)
method steps are:
-
Let settings be thisโs relevant settings object.
-
Let frameOrigin be settingsโs origin.
-
Assert that frameOrigin is not an opaque origin and its scheme is "
https
". -
Let p be a new promise.
-
Let global be thisโs relevant global object.
-
If globalโs associated Document is not allowed to use the "join-ad-interest-group" policy-controlled feature, then throw a "
NotAllowedError
"DOMException
.Note: Both joining and leaving interest groups use the "join-ad-interest-group" feature.
-
Let ownerOrigin be the result of parsing an https origin with owner.
-
Run these steps in parallel:
-
Let permission be the result of checking interest group permissions with ownerOrigin, settings, and "
leave
". -
If permission is false, then queue a global task on the DOM manipulation task source given global, reject p with a "
NotAllowedError
"DOMException
and abort these steps. -
Queue a global task on the DOM manipulation task source given global, to resolve p with
undefined
. -
Remove interest groups from the user agentโs interest group set whose owner is ownerOrigin, whose joining origin is frameOrigin, and whose name is not in interestGroupsToKeep.
-
-
Return p.
4. Running Ad Auctions
This first introductory paragraph is non-normative.
When a website or someone working on behalf of the website (e.g. a supply side platform, SSP) wants
to conduct an auction to select an advertisement to display to the user, they can call the navigator
.runAdAuction()
function, providing an auction configuration that
tells the browser how to conduct the auction and which on-device recorded interests are allowed to
bid in the auction for the chance to display their advertisement.
4.1. runAdAuction()
[SecureContext ]partial interface Navigator {Promise <(USVString or FencedFrameConfig )?>runAdAuction (AuctionAdConfig );
config readonly attribute boolean ; };
deprecatedRunAdAuctionEnforcesKAnonymity dictionary {
AuctionReportBuyersConfig required bigint ;
bucket required double ; };
scale dictionary {
AuctionReportBuyerDebugModeConfig boolean =
enabled false ; // Must only be provided if `enabled` is true.bigint ?; };
debugKey dictionary {
AuctionRealTimeReportingConfig required DOMString ; };
type dictionary {
AuctionAdConfig required USVString ;
seller required USVString ;
decisionLogicURL USVString ;
trustedScoringSignalsURL long ;
maxTrustedScoringSignalsURLLength USVString ;
trustedScoringSignalsCoordinator boolean ;
sendCreativeScanningMetadata sequence <USVString >;
interestGroupBuyers Promise <any >;
auctionSignals Promise <any >;
sellerSignals Promise <DOMString ?>;
directFromSellerSignalsHeaderAdSlot Promise <record <USVString ,USVString >?>;
deprecatedRenderURLReplacements unsigned long long ;
sellerTimeout unsigned short ;
sellerExperimentGroupId Promise <record <USVString ,any >?>;
perBuyerSignals Promise <record <USVString ,unsigned long long >?>;
perBuyerTimeouts Promise <record <USVString ,unsigned long long >?>;
perBuyerCumulativeTimeouts unsigned long long ;
reportingTimeout USVString ;
sellerCurrency Promise <record <USVString ,USVString >?>;
perBuyerCurrencies record <USVString ,unsigned short >;
perBuyerMultiBidLimits record <USVString ,unsigned short >;
perBuyerGroupLimits record <USVString ,unsigned short >;
perBuyerExperimentGroupIds record <USVString ,record <USVString ,double >>;
perBuyerPrioritySignals sequence <bigint >;
auctionReportBuyerKeys record <DOMString ,AuctionReportBuyersConfig >;
auctionReportBuyers AuctionReportBuyerDebugModeConfig ;
auctionReportBuyerDebugModeConfig sequence <DOMString >;
requiredSellerCapabilities ProtectedAudiencePrivateAggregationConfig ;
privateAggregationConfig record <DOMString ,DOMString >;
requestedSize sequence <record <DOMString ,DOMString >>;
allSlotsRequestedSizes Promise <undefined >;
additionalBids DOMString ;
auctionNonce AuctionRealTimeReportingConfig ;
sellerRealTimeReportingConfig record <USVString ,AuctionRealTimeReportingConfig >;
perBuyerRealTimeReportingConfig sequence <AuctionAdConfig >= [];
componentAuctions AbortSignal ?;
signal Promise <boolean >;
resolveToConfig Promise <Uint8Array >;
serverResponse USVString ; };
requestId
Note: To help with ease of adoption, the browser will support the attribute navigator
.deprecatedRunAdAuctionEnforcesKAnonymity
while k-anonymity enforcement is being rolled out. This attribute is true
when navigator
.runAdAuction()
enforces ยงโฏ7 K-anonymity when running an auction and false otherwise. The attribute
is not useful once k-anonymity enforcement is fully rolled out, and hence
this attribute will be deprecated and removed some time after this point.
See https://developers.google.com/privacy-sandbox/relevance/protected-audience-api/k-anonymity for
more up to date information.
The runAdAuction(config)
method steps are:
-
Let global be thisโs relevant global object.
-
Let settings be thisโs relevant settings object.
-
If globalโs associated Document is not allowed to use the "run-ad-auction" policy-controlled feature, then throw a "
NotAllowedError
"DOMException
. -
Let privateAggregationAllowed be the result of determining whether globalโs associated Document is allowed to use the "
private-aggregation
" policy-controlled feature. -
Let auctionConfig be the result of running validate and convert auction ad config with config and true.
-
Optionally, throw a "
NotAllowedError
"DOMException
.Note: This implementation-defined condition is intended to allow user agents to decline for a number of reasons, for example the sellerโs site not being enrolled.
-
Let p be a new promise.
-
Let configMapping be globalโs associated Documentโs node navigableโs traversable navigableโs fenced frame config mapping.
-
Let pendingConfig be the result of constructing a pending fenced frame config with auctionConfig.
-
Let urn be the result of running store a pending config on configMapping with pendingConfig.
-
If urn is failure, then resolve p with null and return p.
-
Let bidIgs be a new list of interest groups.
-
If config["
signal
"] exists, then:-
Let signal be config["
signal
"]. -
If signal is aborted, then reject p with signalโs abort reason and return p.
-
Otherwise add the following abort steps to signal:
-
Set auctionConfigโs aborted to true.
-
Set auctionConfigโs abort reason to signalโs abort reason.
-
For each auction in auctionConfigโs component auctions:
-
Set auctionโs aborted to true.
-
-
-
-
Assert that settingsโs origin is not an opaque origin and its scheme is "
https
". -
Let queue be the result of starting a new parallel queue.
-
Enqueue the following steps to queue:
-
Let reportingContextMap be the result of creating a reporting context map given auctionConfig and privateAggregationAllowed.
-
If auctionConfigโs server response is not null:
-
Let winnerInfo be the result of running parse and validate server response with auctionConfig, null, global, bidIgs, and reportingContextMap.
-
-
Otherwise:
-
Let realTimeContributionsMap be a new real time reporting contributions map.
-
Let winnerInfo be the result of running generate and score bids with auctionConfig, null, global, bidIgs, reportingContextMap, and realTimeContributionsMap.
-
-
Let auctionReportInfo be a new auction report info.
-
If winnerInfo is not failure, then:
-
Set auctionReportInfo to the result of running collect forDebuggingOnly reports with reportingContextMap, auctionConfigโs seller, and winnerInfo.
-
Set auctionReportInfoโs real time reporting contributions map to realTimeContributionsMap.
-
-
If auctionConfigโs aborted is true:
-
Queue a global task on the DOM manipulation task source, given global, to reject p with auctionConfigโs abort reason.
-
-
Otherwise if winnerInfo is failure, then queue a global task on DOM manipulation task source, given global, to reject p with a "
TypeError
". -
Otherwise if winnerInfo is null or winnerInfoโs leading bid is null:
-
Queue a global task on DOM manipulation task source, given global, to resolve p with null.
-
For each reportUrl of auctionReportInfoโs debug loss report urls:
-
Send report with reportUrl and settings.
-
-
Send real time reports with auctionReportInfoโs real time reporting contributions map and settings.
-
Process the Private Aggregation contributions given auctionConfig, reportingContextMap.
-
-
Otherwise:
-
Let winner be winnerInfoโs leading bid.
-
Let fencedFrameConfig be the result of filling in a pending fenced frame config with pendingConfig, auctionConfig, reportingContextMap, winnerInfo, auctionReportInfo, and settings.
-
Finalize a pending config on configMapping with urn and fencedFrameConfig.
-
Wait until auctionConfigโs resolve to config is a boolean.
-
Let result be fencedFrameConfig.
-
If auctionConfigโs resolve to config is false, then set result to urn.
-
Queue a global task on the DOM manipulation task source, given global, to resolve p with result.
-
Run update previous wins with winner.
-
-
Run interest group update with auctionConfigโs interest group buyers and settingsโs policy container.
-
Run update bid counts with bidIgs.
-
-
Return p.
To construct a pending fenced frame config given an auction config config:
-
Return a fenced frame config with the following items:
- mapped url
-
a struct with the following items:
- value
-
"about:blank"
- visibility
-
"
opaque
"
- container size
-
the result of
converting configโs requested size to pixel values (WICG/turtledove#986)
- content size
-
null
- interest group descriptor
- on navigate callback
-
null
- effective sandboxing flags
-
a struct with the following items:
- value
-
TODO: fill this in once fenced frame sandbox flags are more fully specified
- visibility
-
"
opaque
"
- effective enabled permissions
- fenced frame reporting metadata
-
null
- exfiltration budget metadata
-
null
- nested configs
-
a struct with the following items:
- value
-
an empty list ยซยป
- visibility
-
"
opaque
"
- embedder shared storage context
-
null
To fill in a pending fenced frame config given a fenced frame config pendingConfig, auction config auctionConfig, reporting context map reportingContextMap, leading bid info winningBidInfo, auction report info auctionReportInfo, and an environment settings object settings:
-
Let winningBid be winningBidInfoโs leading bid.
-
Let replacements be an ordered map whose keys are strings and whose values are strings.
-
For each replacement in auctionConfigโs deprecated render url replacements:
-
Let k be replacementโs match.
-
Let v be replacementโs replacement.
-
Set replacements[k] to v.
-
-
Let replacedAdURL be the result of running substitute macros with replacements and winningBidโs ad descriptorโs url.
-
Set pendingConfigโs mapped urlโs value to replacedAdURL.
-
Let adSize be winningBidโs ad descriptorโs size.
-
Let concreteAdSize be the result of
resolving screen-relative sizes to pixel values for adSize. (WICG/turtledove#986)
-
Let adWidthString and adHeightString be the result of
converting concreteAdSize to strings. (WICG/turtledove#986)
-
Let sizeMacroMap be the ordered map ยซ[ "{%AD_WIDTH%}" โ adWidthString, "{%AD_HEIGHT%}" โ adHeightString, "${AD_WIDTH}" โ adWidthString, "${AD_HEIGHT}" โ adHeightString]ยป
-
Set pendingConfigโs mapped urlโs value to the result of substituting macros with sizeMacroMap into winningBidโs ad descriptorโs url.
-
If adSize is not null:
-
Set pendingConfigโs content size to a struct with the following items:
- value
-
concreteAdSize.
Cast concreteAdSize into the format that is eventually chosen for value. (WICG/turtledove#986)
- visibility
-
"
opaque
"
-
-
Set pendingConfigโs interest group descriptorโs value to a struct with the following items:
- owner
-
winningBidโs interest groupโs owner
- name
-
winningBidโs interest groupโs name
-
Let fencedFrameReportingMap be the map ยซ[ "
buyer
" โ ยซยป, "seller
" โ ยซยป ]ยป. -
If auctionConfigโs component auctions is empty, then set fencedFrameReportingMap["
component-seller
"] to an empty list ยซยป. -
Set pendingConfigโs fenced frame reporting metadata to a struct with the following items:
- value
-
A struct with the following items:
- fenced frame reporting map
-
fencedFrameReportingMap
- direct seller is seller
-
true if auctionConfigโs component auctions is empty, false otherwise
- allowed reporting origins
-
winningBidโs bid adโs allowed reporting origins
- visibility
-
"
opaque
"
-
Set pendingConfigโs on navigate callback to an algorithm with these steps:
-
Asynchronously finish reporting with pendingConfigโs fenced frame reporting metadataโs valueโs fenced frame reporting map, auctionConfig, reportingContextMap, winningBidInfo, auctionReportInfo and settings.
-
-
Let adComponentDescriptorsWithReplacements be a new list of ad descriptors.
-
If winningBidโs ad component descriptors is not null:
-
For each adComponentDescriptor of winningBidโs ad component descriptors:
-
Let descriptorWithReplacement be a new ad descriptor.
-
Set descriptorWithReplacementโs size to adComponentDescriptorโs size.
-
Set descriptorWithReplacementโs url to the result of running substitute macros with replacements and adComponentDescriptorโs url.
-
Append descriptorWithReplacement to adComponentDescriptorsWithReplacements.
-
-
-
Set pendingConfigโs nested configsโs value to the result of running create nested configs with adComponentDescriptorsWithReplacements.
-
Return pendingConfig.
To asynchronously finish reporting given a fenced frame reporting map reportingMap, auction config auctionConfig, reporting context map reportingContextMap, leading bid info leadingBidInfo, auction report info auctionReportInfo, and an environment settings object settings:
-
Increment a winning bidโs k-anonymity count given leadingBidInfoโs leading bid.
-
If leadingBidInfoโs leading non-k-anon-enforced bid is not null, and leadingBidInfoโs leading non-k-anon-enforced bidโs reporting id โ leadingBidInfoโs leading bidโs reporting id, increment a winning bidโs k-anonymity count given leadingBidInfoโs leading non-k-anon-enforced bid.
-
Let buyerDone, sellerDone, and componentSellerDone be booleans, initially false.
-
If leadingBidInfoโs component seller is null, set componentSellerDone to true.
-
-
If buyerDone, sellerDone, and componentSellerDone are all true, then break.
-
Wait until one of the following fields of leadingBidInfo being not null:
-
If buyerDone is false and leadingBidInfoโs buyer reporting result is not null:
-
Let buyerMap be leadingBidInfoโs buyer reporting resultโs reporting beacon map.
-
If buyerMap is null, set buyerMap to an empty map ยซ[]ยป.
-
Let macroMap be leadingBidInfoโs buyer reporting resultโs reporting macro map.
-
Finalize a reporting destination with reportingMap,
buyer
, buyerMap, and macroMap. -
Send report with leadingBidInfoโs buyer reporting resultโs report url and settings.
-
Set buyerDone to true.
-
-
If sellerDone is false and leadingBidInfoโs seller reporting result is not null:
-
Let sellerMap be leadingBidInfoโs seller reporting resultโs reporting beacon map.
-
If sellerMap is null, set sellerMap to an empty map ยซ[]ยป.
-
Finalize a reporting destination with reportingMap,
seller
, and sellerMap. -
Send report with leadingBidInfoโs seller reporting resultโs report url and settings.
-
Set sellerDone to true.
-
-
If componentSellerDone is false and leadingBidInfoโs component seller reporting result is not null:
-
Let componentSellerMap be leadingBidInfoโs component seller reporting resultโs reporting beacon map.
-
If componentSellerMap is null, set componentSellerMap to an empty map ยซ[]ยป.
-
Finalize a reporting destination with reportingMap,
component-seller
, and componentSellerMap. -
Send report with leadingBidInfoโs component seller reporting resultโs report url and settings.
-
Set componentSellerDone to true.
-
-
-
For each reportUrl of auctionReportInfoโs debug win report urls:
-
Send report with report and settings.
-
-
For each reportUrl of auctionReportInfoโs debug loss report urls:
-
Send report with report and settings.
-
-
Send real time reports with auctionReportInfoโs real time reporting contributions map and settings.
-
Process the Private Aggregation contributions given auctionConfig, reportingContextMap.
To create nested configs given ad component descriptors adComponentDescriptors:
-
Let nestedConfigs be an empty list ยซยป.
-
If adComponentDescriptors is null:
-
Return nestedConfigs.
-
-
For each adComponentDescriptor of adComponentDescriptors:
-
Let fencedFrameConfig be a fenced frame config with the following items:
- mapped url
-
a struct with the following items:
- value
-
adComponentDescriptorโs url
- visibility
-
"
opaque
"
- container size
-
null
- content size
-
If adComponentDescriptorโs size is null, then null. Otherwise, a struct with the following items:
- value
-
adComponentDescriptorโs size TODO: Resolve screen-relative sizes and macros and cast this properly.
- visibility
-
"
opaque
"
- interest group descriptor
-
null
- on navigate callback
-
null
- effective sandboxing flags
-
a struct with the following items:
- value
-
TODO: fill this in once fenced frame sandbox flags are more fully specified
- visibility
-
"
opaque
"
- effective enabled permissions
- fenced frame reporting metadata
-
null
- exfiltration budget metadata
-
null
- nested configs
-
a struct with the following items:
- value
-
an empty list ยซยป
- visibility
-
"
opaque
"
- embedder shared storage context
-
null
-
Append fencedFrameConfig to nestedConfigs.
-
-
Return nestedConfigs.
To validate and convert auction ad config given an AuctionAdConfig
config and a boolean isTopLevel:
-
Assert that these steps are not running in parallel.
-
Let auctionConfig be a new auction config.
-
Let seller be the result of parsing an https origin with config["
seller
"]. -
If seller is failure, then return failure.
-
Set auctionConfigโs seller to seller.
-
If config["
serverResponse
"] exists:-
If config["
requestId
"] does not exist, then throw aTypeError
. -
Let resolvedAndTypeChecked be the promise representing performing the following steps upon fulfillment of config["
serverResponse
"] with result:-
Set auctionConfigโs server response to the transferred result.
-
Set auctionConfigโs server response id to config["
requestId
"].
-
-
Upon rejection of resolvedAndTypeChecked:
-
Set auctionConfigโs server response to failure.
-
Note: The JavaScript code calling
runAdAuction()
is responsible for not resolving config["serverResponse
"] until server responses have been retrieved from one or more `Ad-Auction-Result
` and `Ad-Auction-Result-Nonce
` headers, as resolving this Promise early would cause a race condition in which the script runners might run without the server responses that it needs. There are two ways that server responses can be retrieved.
(1) The JavaScript code issues a request whose initiator type is"fetch"
and whoseadAuctionHeaders
option is set totrue
. The JavaScript code has to resolve config["serverResponse
"] after the corresponding call tofetch()
has resolved to a response. The JavaScript code can also choose to wait to callrunAdAuction()
until after the corresponding call tofetch()
has resolved to a response, and can then immediately resolve config["serverResponse
"];
(2) issue an iframe navigation request with theadauctionheaders
content attribute set totrue
. In this case, the JavaScript code is retrieved as part of the iframe navigation response, at which point the JavaScript code in the iframe makes the call torunAdAuction()
, and config["serverResponse
"] can be specified directly without a Promise. -
-
Otherwise:
-
If config["
decisionLogicURL
"] exists:-
Let decisionLogicURL be the result of running the URL parser on config["
decisionLogicURL
"]. -
If decisionLogicURL is failure, or it is not same origin with auctionConfigโs seller, then return failure.
-
Set auctionConfigโs decision logic url to decisionLogicURL.
-
-
If config["
trustedScoringSignalsURL
"] exists:-
Let trustedScoringSignalsURL be the result of parse and verify a trusted signals URL on config["
trustedScoringSignalsURL
"]. -
If trustedScoringSignalsURL is failure, return failure.
-
Set auctionConfigโs trusted scoring signals url to trustedScoringSignalsURL.
-
-
If config["
maxTrustedScoringSignalsURLLength
"] exists:-
If config["
maxTrustedScoringSignalsURLLength
"] โฅ 0, set auctionConfigโs max trusted scoring signals url length to config["maxTrustedScoringSignalsURLLength
"], otherwise throw aTypeError
.
-
-
If config["
trustedScoringSignalsCoordinator
"] exists:-
Let parsedCoordinator be the result of parsing an https origin on config["
trustedScoringSignalsCoordinator
"]. -
Set auctionConfigโs trusted scoring signals coordinator to parsedCoordinator.
-
-
If config["
sendCreativeScanningMetadata
"] exists:-
Set auctionConfigโs send creative scanning metadata to config["
sendCreativeScanningMetadata
"].
-
-
If config["
interestGroupBuyers
"] exists:-
Let buyers be a new empty list.
-
For each buyerString in config["
interestGroupBuyers
"]:-
Let buyer be the result of parsing an https origin with buyerString.
-
If buyer is failure, then return failure.
-
Append buyer to buyers.
-
-
Set auctionConfigโs interest group buyers to buyers.
-
-
If config["
auctionSignals
"] exists:-
Set auctionConfigโs auction signals to config["
auctionSignals
"]. -
Handle an input promise in configuration given auctionConfig and auctionConfigโs auction signals:
-
To parse the value result:
-
If result is
undefined
or null, set auctionConfigโs auction signals to null. -
Otherwise, set auctionConfigโs auction signals to the result of serializing a JavaScript value to a JSON string given result.
-
-
To handle an error, set auctionConfigโs auction signals to failure.
-
-
-
If config["
requestedSize
"] exists:-
Let adSize be the result from running parse an AdRender ad size with config["
requestedSize
"] -
Set auctionConfigโs requested size to adSize.
-
-
If config["
allSlotsRequestedSizes
"] exists:-
If config["
allSlotsRequestedSizes
"] is empty, throw aTypeError
. -
Set auctionConfigโs all slots requested sizes to a new set.
-
For each adSizeValue in config["
allSlotsRequestedSizes
"]:-
Let adSize be the result of running parse an AdRender ad size with adSizeValue.
-
If auctionConfigโs all slots requested sizes contains adSize, throw a
TypeError
. -
Append adSize to auctionConfigโs all slots requested sizes.
-
-
If auctionConfigโs requested size is not null, and auctionConfigโs all slots requested sizes does not contain auctionConfigโs requested size, throw a
TypeError
.
-
-
If config["
sellerSignals
"] exists:-
Set auctionConfigโs seller signals to config["
sellerSignals
"]. -
Handle an input promise in configuration given auctionConfig and auctionConfigโs seller signals:
-
To parse the value result:
-
If result is
undefined
or null, set auctionConfigโs seller signals to null. -
Otherwise, set auctionConfigโs seller signals to the result of serializing a JavaScript value to a JSON string, given result.
-
-
To handle an error, set auctionConfigโs seller signals to failure.
-
-
-
If config["
auctionNonce
"] exists, then set auctionConfigโs auction nonce to the result of running get uuid from string with config["auctionNonce
"]. -
If config["
additionalBids
"] exists:-
Throw a
TypeError
if any of the following conditions hold:-
config["
auctionNonce
"] does not exist; -
config["
interestGroupBuyers
"] does not exist, or is empty; -
config["
componentAuctions
"] is not empty.
-
-
Set auctionConfigโs expects additional bids to true.
-
Handle an input promise in configuration given auctionConfig and config["
additionalBids
"]:Note: The JavaScript code calling
runAdAuction()
is responsible for not resolving config["additionalBids
"] until additional bids have been retrieved from one or more `Ad-Auction-Additional-Bid
` headers, as resolving this Promise early would cause a race condition in which additional bids might not be included in the auction. There are two ways that additional bids can be retrieved.
(1) The JavaScript code issues a request whose initiator type is"fetch"
and whoseadAuctionHeaders
option is set totrue
. The JavaScript code has to resolve config["additionalBids
"] after the corresponding call tofetch()
has resolved to a response. The JavaScript code can also choose to wait to callrunAdAuction()
until after the corresponding call tofetch()
has resolved to a response, and can then immediately resolve config["additionalBids
"];
(2) issue an iframe navigation request with theadauctionheaders
content attribute set totrue
. In this case, the JavaScript code is retrieved as part of the iframe navigation response, at which point the JavaScript code in the iframe makes the call torunAdAuction()
, and config["additionalBids
"] can be immediately resolved.-
To parse the value result:
-
Set auctionConfigโs expects additional bids to false.
-
-
To handle an error:
-
Set auctionConfigโs expects additional bids to failure.
-
-
-
-
If config["
directFromSellerSignalsHeaderAdSlot
"] exists:-
Handle an input promise in configuration given auctionConfig and config["
directFromSellerSignalsHeaderAdSlot
"]:Note: The JavaScript code calling
runAdAuction()
is responsible for not resolving config["directFromSellerSignalsHeaderAdSlot
"] until direct from seller signals have been retrieved from one or more `Ad-Auction-Signals
` headers, as resolving this Promise early would cause a race condition in which the script runners might run without the direct from seller signals that it needs. There are two ways that direct from seller signals can be retrieved.
(1) The JavaScript code issues a request whose initiator type is"fetch"
and whoseadAuctionHeaders
option is set totrue
. The JavaScript code has to resolve config["directFromSellerSignalsHeaderAdSlot
"] after the corresponding call tofetch()
has resolved to a response. The JavaScript code can also choose to wait to callrunAdAuction()
until after the corresponding call tofetch()
has resolved to a response, and can then immediately resolve config["directFromSellerSignalsHeaderAdSlot
"];
(2) issue an iframe navigation request with theadauctionheaders
content attribute set totrue
. In this case, the JavaScript code is retrieved as part of the iframe navigation response, at which point the JavaScript code in the iframe makes the call torunAdAuction()
, and config["directFromSellerSignalsHeaderAdSlot
"] can be specified directly without a Promise.-
To parse the value result:
-
Set auctionConfigโs direct from seller signals header ad slot to result.
-
-
To handle an error:
-
Set auctionConfigโs direct from seller signals header ad slot to failure.
-
-
-
-
If config["
deprecatedRenderURLReplacements
"] exists:-
Set auctionConfigโs deprecated render url replacements to config["
deprecatedRenderURLReplacements
"]. -
Handle an input promise in configuration given auctionConfig and auctionConfigโs deprecated render url replacements:
-
To parse the value result:
-
Let renderUrlReplacements be a new empty list of ad keyword replacements.
-
If result is not null:
-
Set auctionConfigโs deprecated render url replacements to renderUrlReplacements.
-
-
To handle an error, set auctionConfigโs deprecated render url replacements to failure.
-
-
-
If config["
sellerTimeout
"] exists, set auctionConfigโs seller timeout to config["sellerTimeout
"] in milliseconds or 500, whichever is smaller. -
Let reportingTimeout be config["
reportingTimeout
"] if it exists, 50 otherwise. -
Set config["
reportingTimeout
"] to reportingTimeout in milliseconds or 5000, whichever is smaller. -
If config["
sellerExperimentGroupId
"] exists, then set auctionConfigโs seller experiment group id to config["sellerExperimentGroupId
"]. -
If config["
sellerCurrency
"] exists:-
If the result of checking whether a string is a valid currency tag on config["
sellerCurrency
"] is false, then return failure. -
Set auctionConfigโs seller currency to config["
sellerCurrency
"].
-
-
If config["
perBuyerSignals
"] exists:-
Set auctionConfigโs per buyer signals to config["
perBuyerSignals
"]. -
Handle an input promise in configuration given auctionConfig and auctionConfigโs per buyer signals:
-
To parse the value result:
-
If result is null:
-
Set auctionConfigโs per buyer signals to null.
-
-
Otherwise:
-
Set auctionConfigโs per buyer signals to a new ordered map whose keys are origins and whose values are strings.
-
For each key โ value of result:
-
Let buyer be the result of parsing an https origin with key. If buyer is failure, throw a
TypeError
. -
Let signalsString be the result of serializing a JavaScript value to a JSON string, given value.
-
Set auctionConfigโs per buyer signals[buyer] to signalsString.
-
-
-
-
To handle an error, set auctionConfigโs per buyer signals to failure.
-
-
-
For each idlTimeoutMember, perBuyerTimeoutField, allBuyersTimeoutField in the following table
IDL timeout member Per buyer timeout field All buyers timeout field " perBuyerTimeouts
"per buyer timeouts all buyers timeout " perBuyerCumulativeTimeouts
"per buyer cumulative timeouts all buyers cumulative timeout -
If config contains idlTimeoutMember:
-
Set auctionConfigโs perBuyerTimeoutField to config[idlTimeoutMember].
-
Handle an input promise in configuration given auctionConfig and auctionConfigโs perBuyerTimeoutField:
-
To parse the value result:
-
If result is null:
-
Set auctionConfigโs perBuyerTimeoutField to null.
-
-
Otherwise:
-
Set auctionConfigโs perBuyerTimeoutField to a new ordered map whose keys are origins and whose values are durations in milliseconds.
-
For each key โ value of result:
-
If perBuyerTimeoutField is "
perBuyerTimeouts
", and value > 500, then set value to 500. -
If key is "*", then set auctionConfigโs allBuyersTimeoutField to value in milliseconds, and continue.
-
Let buyer be the result of parsing an https origin with key. If buyer is failure, throw a
TypeError
. -
Set auctionConfigโs perBuyerTimeoutField[buyer] to value in milliseconds.
-
-
-
-
To handle an error, set auctionConfigโs perBuyerTimeoutField to failure.
-
-
-
-
If config["
perBuyerGroupLimits
"] exists, for each key โ value of config["perBuyerGroupLimits
"]:-
If value is 0, then return failure.
-
If key is "*", then set auctionConfigโs all buyers group limit to value, and continue.
-
Let buyer be the result of parsing an https origin with key.
-
If buyer is failure, then return failure.
-
Set auctionConfigโs per buyer group limits[buyer] to value.
-
-
If config["
perBuyerExperimentGroupIds
"] exists, for each key โ value of config["perBuyerExperimentGroupIds
"]:-
If key is "*", then set auctionConfigโs all buyer experiment group id to value, and continue.
-
Let buyer the result of parsing an https origin with key.
-
If buyer is failure, then return failure.
-
Set auctionConfigโs per buyer experiment group ids[buyer] to value.
-
-
If config["
perBuyerMultiBidLimits
"] exists, for each key โ value of config["perBuyerMultiBidLimits
"]:-
If key is "*", then set auctionConfigโs all buyers multi-bid limit to value, and continue.
-
Let buyer the result of parsing an https origin with key.
-
If buyer is failure, then return failure.
-
Set auctionConfigโs per buyer multi-bid limits[buyer] to value.
-
-
If config["
perBuyerPrioritySignals
"] exists, for each key โ value of config["perBuyerPrioritySignals
"]:-
Let signals be an ordered map whose keys are strings and whose values are
double
. -
for each k โ v of value:
-
If k starts with "browserSignals.", throw a
TypeError
. -
Set signals[k] to v.
-
-
If key is "*", then set auctionConfigโs all buyers priority signals to value, and continue.
-
Let buyer be the result of parsing an https origin with key.
-
If buyer is failure, then return failure.
-
Set auctionConfigโs per buyer priority signals[buyer] to signals.
-
-
If config["
auctionReportBuyerKeys
"] exists:-
Let interestGroupBuyers be auctionConfigโs interest group buyers.
-
If interestGroupBuyers is null, set interestGroupBuyers to a new list.
-
For each index of the range 0 to config[ "
auctionReportBuyerKeys
"]'s size, exclusive:-
Let key be config["
auctionReportBuyerKeys
"][index]. -
If key is not contained in the range 0 to 2128, exclusive, throw a
TypeError
. -
If index โฅ interestGroupBuyersโ size, continue.
Note: Continue is used (instead of break) to validate all given buyer keys.
-
Let origin be interestGroupBuyers[index].
-
Set auctionConfigโs auction report buyer keys[origin] to key.
Check behavior when an origin is repeated in
interestGroupBuyers
. -
-
-
If config["
auctionReportBuyers
"] exists:-
For each reportType โ reportBuyerConfig of config[ "
auctionReportBuyers
"]:-
If ยซ "
interestGroupCount
", "bidCount
", "totalGenerateBidLatency
", "totalSignalsFetchLatency
" ยป does not contain reportType, continue.Note: No error is thrown to allow forward compatibility if additional report types are added later.
-
If reportBuyerConfig["
bucket
"] is not contained in the range 0 to 2128, exclusive, throw aTypeError
.Consider validating the case where the bucket used (after summing) is too large. Currently, the implementation appears to overflow. (WICG/turtledove#1040)
-
Set auctionConfigโs auction report buyers[reportType] to reportBuyerConfig.
-
-
-
If config["
auctionReportBuyerDebugModeConfig
"] exists:-
Let debugModeConfig be config["
auctionReportBuyerDebugModeConfig
"]. -
Let enabled be debugModeConfig["
enabled
"]. -
Let debugKey be debugModeConfig["
debugKey
"]. -
If debugKey is not null:
-
Set auctionConfigโs auction report buyer debug details to a new debug details with the items:
-
-
If config["
requiredSellerCapabilities
"] exists:-
Let sellerCapabilities be a new set of seller capabilities.
-
For each capabilityString of config["
requiredSellerCapabilities
"]: -
Set auctionConfigโs required seller capabilities to sellerCapabilities.
-
-
If config["
privateAggregationConfig
"] exists:-
Let aggregationCoordinator be the result of obtaining the coordinator from a Private Aggregation config given config["
privateAggregationConfig
"]. -
If aggregationCoordinator is a
DOMException
, return failure. -
Set auctionConfigโs seller Private Aggregation coordinator to aggregationCoordinator.
-
-
If config["
perBuyerCurrencies
"] exists:-
Set auctionConfigโs per buyer currencies to config["
perBuyerCurrencies
"] -
Handle an input promise in configuration given auctionConfig and auctionConfigโs per buyer currencies:
-
To parse the value result:
-
If result is null:
-
Set auctionConfigโs per buyer currencies to null.
-
-
Otherwise:
-
Set auctionConfigโs per buyer currencies to a new ordered map whose keys are origins and whose values are currency tags.
-
for each key โ value of result:
-
If the result of checking whether a string is a valid currency tag given value is false, throw a
TypeError
. -
If key is "*", then set auctionConfigโs all buyers currency to value, and continue.
-
Let buyer be the result of parsing an https origin with key. If buyer is failure, throw a
TypeError
. -
Set auctionConfigโs per buyer currencies[buyer] to value.
-
-
-
-
To handle an error, set auctionConfigโs per buyer currencies to failure.
-
-
-
If config["
sellerRealTimeReportingConfig
"] exists:-
If config["
sellerRealTimeReportingConfig
"]["type"] is "default-local-reporting
", then set auctionConfigโs seller real time reporting config to "default-local-reporting
".
-
-
If config["
perBuyerRealTimeReportingConfig
"] exists, For each key โ value of config["perBuyerRealTimeReportingConfig
"]:-
Let buyer the result of parsing an https origin with key.
-
If buyer is failure, then return failure.
-
If value["type"] is "
default-local-reporting
", then set auctionConfigโs per buyer real time reporting config[buyer] to "default-local-reporting
".
-
-
If config["
componentAuctions
"] is not empty:-
If config["
interestGroupBuyers
"] exists and is not empty, then return failure. -
If config["
deprecatedRenderURLReplacements
"] exists, then throw aTypeError
.
-
-
For each component in config["
componentAuctions
"]:-
If isTopLevel is false, then return failure.
-
Let componentAuction be the result of running validate and convert auction ad config with component and false.
-
If componentAuction is failure, then return failure.
-
Append componentAuction to auctionConfigโs component auctions.
-
-
Set auctionConfigโs config idl to config.
-
If config["
resolveToConfig
"] exists:-
Let auctionConfigโs resolve to config be config["
resolveToConfig
"]. -
TODO: What should happen if this rejects?
-
Upon fulfillment of auctionConfigโs resolve to config with resolveToConfig, set auctionConfigโs resolve to config to resolveToConfig.
-
-
Return auctionConfig.
To validate a url macro given a string macro:
-
Return true if any of the following conditions hold:
-
macro starts with "'${'" and ends with "'}'";
-
macro starts with "'%%'" and ends with "'%%'".
-
-
Otherwise, return false.
To update bid count given a list of interest groups igs:
-
For each ig in igs:
-
Let loadedIg be the interest group from the user agentโs interest group set whose owner is igโs owner and whose name is igโs name, continue if none found.
-
If the most recent entry in loadedIgโs bid counts corresponds to the current day in UTC, increment its count. If not, insert a new tuple of the time set to the current UTC day and a count of 1.
-
Replace the interest group that has loadedIgโs owner and name in the user agentโs interest group set with loadedIg.
-
To update previous wins given a generated bid bid:
-
Let ig be bidโs interest group.
-
Let loadedIg be the interest group from the user agentโs interest group set whose owner is igโs owner and whose name is igโs name, return if none found.
-
Let win be a new previous win.
-
Set winโs time to the current coarsened wall time.
-
Let ad be a new interest group ad with the following items:
- render url
-
bidโs bid adโs render url
- metadata
- ad render ID
-
bidโs bid adโs ad render ID
-
Set winโs ad to ad.
-
Append win to loadedIgโs previous wins.
-
Replace the interest group that has loadedIgโs owner and name in the user agentโs interest group set with loadedIg.
To build bid generators map given an auction config auctionConfig:
-
Let bidGenerators be a new ordered map whose keys are origins and whose values are per buyer bid generators.
-
Let negativeTargetInfo be a new negative target info.
-
For each buyer in auctionConfigโs interest group buyers:
-
For each ig of the user agentโs interest group set whose owner is buyer:
-
Let igName be igโs name.
-
If igโs additional bid key is not null:
-
Set negativeTargetInfo[(buyer, igName)] to (igโs joining origin, igโs additional bid key).
-
-
Continue if any of the following conditions hold:
-
igโs bidding url is null;
-
the result of running check if required seller capabilities are permitted with auctionConfig and ig is false.
-
-
Let signalsUrl be igโs trusted bidding signals url.
-
Let slotSizeQueryParam be the result of calculating the ad slot size query param given ig and auctionConfig.
-
Let joiningOrigin be igโs joining origin.
-
If bidGenerators does not contain buyer:
-
Let perBuyerGenerator be a new per buyer bid generator.
-
Let perSignalsUrlGenerator be a new per signals url bid generator.
-
Set perSignalsUrlGenerator[joiningOrigin] to ยซ ig ยป.
-
Set perSlotSizeQueryParam[slotSizeQueryParam] to perSignalsUrlGenerator.
-
Set perBuyerGenerator[signalsUrl] to perSlotSizeQueryParam.
-
Set bidGenerators[buyer] to perBuyerGenerator.
-
TODO: add a perBiddingScriptUrlGenerator layer that replaces the list of IGs with a map from biddingScriptUrl to a list of IGs.
-
-
Otherwise:
-
Let perBuyerGenerator be bidGenerators[buyer].
-
If perBuyerGenerator does not contain signalsUrl:
-
Let perSignalsUrlGenerator be a new per signals url bid generator.
-
Set perSignalsUrlGenerator[joiningOrigin] to ยซ ig ยป.
-
Set perSlotSizeQueryParam[slotSizeQueryParam] to perSignalsUrlGenerator.
-
Set perBuyerGenerator[signalsUrl] to perSlotSizeQueryParam.
-
-
Otherwise:
-
Let perSlotSizeQueryParam be perBuyerGenerator[signalsUrl].
-
If perSlotSizeQueryParam does not contain slotSizeQueryParam:
-
Let perSignalsUrlGenerator be a new per signals url bid generator.
-
Set perSignalsUrlGenerator[joiningOrigin] to ยซ ig ยป.
-
Set perSlotSizeQueryParam[slotSizeQueryParam] to perSignalsUrlGenerator.
-
-
Otherwise:
-
-
-
-
-
Return ยซ bidGenerators, negativeTargetInfo ยป.
To check if required seller capabilities are permitted given an auction config auctionConfig and an interest group ig:
-
Let seller be auctionConfigโs seller.
-
Let requiredSellerCapabilities be auctionConfigโs required seller capabilities.
-
Return true if all of the following conditions hold:
-
igโs seller capabilities is not null;
-
igโs seller capabilities[seller] exists;
-
requiredSellerCapabilities is a subset of igโs seller capabilities[seller].
-
-
Return false.
ProtectedAudiencePrivateAggregationConfig
config, perform the following
steps. They return an aggregation coordinator, null or a DOMException
.
-
If config["
aggregationCoordinatorOrigin
"] does not exist, return null. -
Return the result of obtaining the Private Aggregation coordinator given config["
aggregationCoordinatorOrigin
"].
To generate potentially multiple bids given an ordered map-or-null allTrustedBiddingSignals, and an origin-or-null crossOriginTrustedBiddingSignalsOrigin,
a string auctionSignals, a BiddingBrowserSignals
browserSignals, a string-or-null perBuyerSignals,
a DirectFromSellerSignalsForBuyer
directFromSellerSignalsForBuyer, a duration perBuyerTimeout in milliseconds, a currency tag expectedCurrency, an unsigned short
multiBidLimit, an interest group ig, a reporting context reportingContext, a moment auctionStartTime, and an environment settings object settings, perform the
following steps. They return a failure if failing to fetch the script or wasm, otherwise a tuple of (list of generated bids, bid debug reporting info, list of real time reporting contributions, Private Aggregation contributions, execution metrics).
-
Let igGenerateBid be the result of building an interest group passed to generateBid with ig.
-
Set browserSignals["
joinCount
"] to the sum of igโs join counts for all days within the last 30 days. -
Set browserSignals["
recency
"] to the current coarsened wall time minus igโs join time, in milliseconds. -
Set browserSignals["
bidCount
"] to the sum of igโs bid counts for all days within the last 30 days. -
Set browserSignals["
adComponentsLimit
"] to 40. -
Set browserSignals["
multiBidLimit
"] to multiBidLimit. -
Let prevWins be a new
sequence<
.PreviousWin
> -
For each prevWin of igโs previous wins for all days within the the last 30 days:
-
Let timeDelta be auctionStartTime minus prevWinโs time.
-
Set timeDelta to 0 if timeDelta is negative, timeDeltaโs nearest second (rounding down) otherwise.
-
Let prevWinAdIDL be a new
AuctionAd
with the following items:renderURL
-
the serialization of prevWinโs render url
metadata
-
prevWinโs metadata
adRenderId
-
prevWinโs ad render ID
-
Let prevWinElement be the
sequence<
ยซtimeDelta, prevWinAdIDLยป.PreviousWinElement
> -
Append prevWinElement to prevWins.
-
-
Set browserSignals["
prevWinsMs
"] to prevWins. -
Let metrics be a new execution metrics.
-
Let biddingScriptFetcher be the result of creating a new script fetcher with igโs bidding url, and settings.
-
Let biddingScript be the result of waiting for script body from a fetcher given biddingScriptFetcher.
-
Add a sample to an averager given metricsโs code fetch time averager and biddingScriptFetcherโs fetch duration.
-
If biddingScript is failure, return failure.
-
If igโs bidding wasm helper url is not null:
-
Let wasmFetchStart be settingsโs current monotonic time.
-
Let wasmModuleObject be the result of fetching WebAssembly with igโs bidding wasm helper url and settings.
-
Let wasmFetchDuration be the duration from wasmFetchStart to settingsโs current monotonic time, in milliseconds.
-
Add a sample to an averager given metricsโs code fetch time averager and wasmFetchDuration.
-
If wasmModuleObject is not failure, then set browserSignals["
wasmHelper
"] to wasmModuleObject. -
Otherwise, return failure.
-
-
Let trustedBiddingSignals be null.
-
If allTrustedBiddingSignals is not null:
-
Assert that igโs trusted bidding signals keys is not null.
-
Set trustedBiddingSignals to an ordered map whose keys are strings and whose values are
any
. -
For each key of igโs trusted bidding signals keys:
-
-
Let sameOriginTrustedBiddingSignals be null.
-
Let crossOriginTrustedBiddingSignals be null.
-
If trustedBiddingSignals is not null:
-
If crossOriginTrustedBiddingSignalsOrigin is null, then set sameOriginTrustedBiddingSignals to trustedBiddingSignals.
-
Otherwise:
-
Set crossOriginTrustedBiddingSignals to a new ordered map whose keys are strings and whose values are
any
. -
Let originKey be the serialization of crossOriginTrustedBiddingSignalsOrigin.
-
Set crossOriginTrustedBiddingSignalsOrigin[originKey] to trustedBiddingSignals.
-
-
-
Return the result of evaluating a bidding script with biddingScript, multiBidLimit, ig, reportingContext, metrics, expectedCurrency, igGenerateBid, auctionSignals, perBuyerSignals, sameOriginTrustedBiddingSignals, crossOriginTrustedBiddingSignals, browserSignals, directFromSellerSignalsForBuyer and perBuyerTimeout.
To generate and score bids given an auction config auctionConfig, an auction config-or-null topLevelAuctionConfig, a global object global, a list of interest groups bidIgs, a reporting context map reportingContextMap, and a real time reporting contributions map realTimeContributionsMap:
-
Assert that these steps are running in parallel.
-
Let settings be globalโs relevant settings object.
-
Let policyContainer be settingsโs policy container.
-
Let topLevelOrigin be settingsโs top-level origin.
-
Let seller be auctionConfigโs seller.
-
Let auctionStartTime be the current coarsened wall time.
-
Let decisionLogicFetcher be the result of creating a new script fetcher with auctionConfigโs decision logic url and settings.
-
Let trustedScoringSignalsBatcher be the result of creating a trusted scoring signals batcher with auctionConfigโs max trusted scoring signals url length.
-
Let ยซ bidGenerators, negativeTargetInfo ยป be the result of running build bid generators map with auctionConfig.
-
If auctionConfigโs aborted is true, return failure.
-
Let leadingBidInfo be a new leading bid info.
-
Let queue be the result of starting a new parallel queue.
-
Let capturedAuctionSignalsHeaders be globalโs associated Documentโs node navigableโs traversable navigableโs captured ad auction signals headers.
-
If auctionConfigโs component auctions are not empty:
-
Assert topLevelAuctionConfig is null.
-
Let pendingComponentAuctions be auctionConfigโs component auctionsโs size.
-
Let topLevelDirectFromSellerSignalsForSeller be null.
-
Let topLevelDirectFromSellerSignalsRetrieved be false.
-
For each component in auctionConfigโs component auctions, enqueue the following steps to queue:
-
If componentโs server response is not null:
-
Let compWinnerInfo be the result of running parse and validate server response with component, auctionConfig, global, bidIgs, and reportingContextMap.
-
-
Otherwise:
-
Let compWinnerInfo be the result of running generate and score bids with component, auctionConfig, global, bidIgs, reportingContextMap, and realTimeContributionsMap.
-
-
If recursively wait until configuration input promises resolve given auctionConfig does not return failure, and compWinnerInfo is not failure, then:
-
If topLevelDirectFromSellerSignalsRetrieved is false:
-
Let topLevelDirectFromSellerSignals be the result of running get direct from seller signals given seller, auctionConfigโs direct from seller signals header ad slot, and capturedAuctionSignalsHeaders.
-
Set topLevelDirectFromSellerSignalsForSeller to the result of running get direct from seller signals for a seller given topLevelDirectFromSellerSignals.
-
Set topLevelDirectFromSellerSignalsRetrieved to true.
-
-
If compWinnerInfoโs leading bid is not null, then run score and rank a bid with auctionConfig, reportingContextMap[auctionConfig], compWinnerInfoโs leading bid, leadingBidInfo, decisionLogicFetcher, trustedScoringSignalsBatcher, null, "top-level-auction", null, topLevelOrigin, realTimeContributionsMap, and policyContainer.
-
If compWinnerInfoโs leading non-k-anon-enforced bid is not null, then run score and rank a bid with auctionConfig, reportingContextMap[ auctionConfig], compWinnerInfoโs leading non-k-anon-enforced bid, leadingBidInfo, decisionLogicFetcher, trustedScoringSignalsBatcher, topLevelDirectFromSellerSignalsForSeller, null, "top-level-auction", null, topLevelOrigin, realTimeContributionsMap, and policyContainer.
-
-
Decrement pendingComponentAuctions by 1.
-
-
Wait until pendingComponentAuctions is 0.
-
If auctionConfigโs aborted is true, return failure.
-
Set reportingContextMap[auctionConfig]'s local leader info to a copy of leadingBidInfo.
-
If leadingBidInfoโs leading bid is null, return null.
-
Let winningComponentConfig be leadingBidInfoโs auction config.
-
Set leadingBidInfoโs auction config to auctionConfig.
-
Set leadingBidInfoโs component seller to winningComponentConfigโs seller.
-
Let ยซ topLevelSellerSignals, unusedTopLevelReportResultBrowserSignals ยป be the result of running report result with leadingBidInfo, reportingContextMap[auctionConfig], topLevelDirectFromSellerSignalsForSeller, winningComponentConfig, and global.
-
Set leadingBidInfoโs auction config to winningComponentConfig.
-
Set leadingBidInfoโs component seller to null.
-
Set leadingBidInfoโs top level seller to seller.
-
Set leadingBidInfoโs top level seller signals to topLevelSellerSignals.
-
Let directFromSellerSignals be the result of running get direct from seller signals given winningComponentConfigโs seller, winningComponentConfigโs direct from seller signals header ad slot, and capturedAuctionSignalsHeaders.
-
Let directFromSellerSignalsForSeller be the result of running get direct from seller signals for a seller given directFromSellerSignals.
-
Let directFromSellerSignalsForBuyer be the result of running get direct from seller signals for a buyer with directFromSellerSignals, and leadingBidInfoโs leading bidโs interest groupโs owner.
-
Let ยซ sellerSignals, reportResultBrowserSignals ยป be the result of running report result with leadingBidInfo, reportingContextMap[winningComponentConfig], directFromSellerSignalsForSeller, null, and global.
-
Run report win with leadingBidInfo, reportingContextMap[winningComponentConfig], sellerSignals, reportResultBrowserSignals, directFromSellerSignalsForBuyer, and settings.
-
Set reportingContextMap[auctionConfig]'s winner reporting id to leadingBidInfoโs leading bidโs reporting id.
-
Set reportingContextMap[winningComponentConfig]'s winner reporting id to leadingBidInfoโs leading bidโs reporting id.
-
Return leadingBidInfo.
-
-
If waiting until configuration input promises resolve given auctionConfig returns failure, then return failure.
-
Let allBuyersExperimentGroupId be auctionConfigโs all buyer experiment group id.
-
Let allBuyersGroupLimit be auctionConfigโs all buyers group limit.
-
Let auctionSignals be auctionConfigโs auction signals.
-
Let directFromSellerSignals be the result of running get direct from seller signals given seller, auctionConfigโs direct from seller signals header ad slot, and capturedAuctionSignalsHeaders.
-
Let directFromSellerSignalsForSeller be the result of running get direct from seller signals for a seller given directFromSellerSignals.
-
Let browserSignals be a
BiddingBrowserSignals
. -
Let topLevelHost be the result of running the host serializer on topLevelOriginโs host.
-
Set browserSignals["
topWindowHostname
"] to topLevelHost. -
Set browserSignals["
seller
"] to the serialization of seller. -
If auctionConfigโs requested size is not null, set browserSignals["
requestedSize
"] to the result of running convert an ad size to a map with auctionConfigโs requested size. -
Let auctionLevel be "single-level-auction".
-
Let reportingContext be reportingContextMap[auctionConfig].
-
Let componentAuctionExpectedCurrency be null.
-
If topLevelAuctionConfig is not null:
-
Set browserSignals["
topLevelSeller
"]] to the serialization of topLevelAuctionConfigโs seller. -
Set auctionLevel to "component-auction".
-
Set componentAuctionExpectedCurrency to the result of looking up per-buyer currency with topLevelAuctionConfig and seller.
-
-
Let pendingBuyers be bidGeneratorsโs size.
-
Let additionalBids be the result of running validate and convert additional bids with auctionConfig, topLevelAuctionConfig, negativeTargetInfo, reportingContextMap and global.
-
Let pendingAdditionalBids be the size of additionalBids.
-
For each additionalBid of additionalBids, run the following steps in parallel:
-
Score and rank a bid with auctionConfig, reportingContext additionalBidโs bid, leadingBidInfo, decisionLogicFetcher, trustedScoringSignalsBatcher, directFromSellerSignalsForSeller, null, auctionLevel, componentAuctionExpectedCurrency, topLevelOrigin, realTimeContributionsMap, and policyContainer.
-
Decrement pendingAdditionalBids by 1.
-
-
For each buyer โ perBuyerGenerator of bidGenerators, enqueue the following steps to queue:
-
Let cumulativeTimeoutTracker be the result of creating a cumulative timeout tracker given auctionConfig and buyer.
-
Let buyerExperimentGroupId be allBuyersExperimentGroupId.
-
Let perBuyerExperimentGroupIds be auctionConfigโs per buyer experiment group ids.
-
If perBuyerExperimentGroupIds is not null and perBuyerExperimentGroupIds[buyer] exists, then set buyerExperimentGroupId to perBuyerExperimentGroupIds[buyer].
-
Let metrics be the result of accessing per-participant metrics for reportingContext, buyer, generate-bid.
-
Apply interest groups limits to prioritized list:
-
Let buyerGroupLimit be allBuyersGroupLimit.
-
Let perBuyerGroupLimits be auctionConfigโs per buyer group limits.
-
If perBuyerGroupLimits is not null and perBuyerGroupLimits[buyer] exists, then set buyerGroupLimit to perBuyerGroupLimits[buyer].
-
Let igs be a new list of interest groups.
-
For each signalsUrl โ perSlotSizeQueryParam of perBuyerGenerator:
-
Update storage metrics given metrics and igs.
Note: This is done before any filtering, since it represents storage resource usage.
-
Sort in descending order igs, with a being less than b if aโs priority is less than bโs priority.
-
Remove the first buyerGroupLimit items from igs.
-
For each signalsUrl โ perSlotSizeQueryParam of perBuyerGenerator:
-
For each slotSizeQueryParam โ perSignalsUrlGenerator of perSlotSizeQueryParam:
-
For each joiningOrigin โ groups of perSignalsUrlGenerator:
-
Remove from groups any interest group contained in igs.
-
Increment metricsโs participating interest group count by size of groups.
-
-
-
-
-
Let perBuyerSignals be null.
-
If auctionConfigโs per buyer signals is not null and per buyer signals[buyer] exists, then set perBuyerSignals to auctionConfigโs per buyer signals[buyer].
-
Let perBuyerTimeout be auctionConfigโs all buyers timeout.
-
If auctionConfigโs per buyer timeouts is not null and per buyer timeouts[buyer] exists, then set perBuyerTimeout to auctionConfigโs per buyer timeouts[buyer].
-
Let expectedCurrency be the result of looking up per-buyer currency with auctionConfig and buyer.
-
Let multiBidLimit be the result of looking up per-buyer multi-bid limit with auctionConfig and buyer.
-
Set browserSignals["
forDebuggingOnlyInCooldownOrLockout
"] to the result of running is debugging only in cooldown or lockout with buyer. -
Let optedInForRealTimeReporting be true if auctionConfigโs per buyer real time reporting config[buyer] is "
default-local-reporting
", false otherwise. -
For each slotSizeQueryParam โ perSlotSizeQueryParam of perBuyerGenerator:
-
For each signalsUrl โ perSignalsUrlGenerator of perSlotSizeQueryParam:
-
Let crossOriginTrustedBiddingSignalsOrigin be null.
-
If buyer is not same origin with signalsUrlโs origin, then set crossOriginTrustedBiddingSignalsOrigin to signalsUrlโs origin.
-
Let trustedBiddingSignalsBatcher be a new trusted bidding signals batcher.
-
Let fetchSignalStartTime be settingsโs current monotonic time.
-
For each joiningOrigin โ groups of perSignalsUrlGenerator:
-
For each ig of groups:
-
Batch or fetch trusted bidding signals given trustedBiddingSignalsBatcher, ig, signalsUrl, buyerExperimentGroupId, topLevelOrigin, slotSizeQueryParam, and policyContainer.
-
-
Fetch the current outstanding trusted signals batch given trustedBiddingSignalsBatcher, signalsUrl, buyer, buyerExperimentGroupId, topLevelOrigin, and slotSizeQueryParam.
-
Fetch the trusted key value signals batch given trustedBiddingSignalsBatcher, signalsUrl, buyer, buyerExperimentGroupId, topLevelOrigin, and slotSizeQueryParam.
-
-
Process updateIfOlderThanMs with buyer, and trustedBiddingSignalsBatcherโs all per interest group data.
-
Let fetchSignalDuration be the duration from fetchSignalStartTime to settingsโs current monotonic time, in milliseconds.
-
Expend cumulative timeout time given cumulativeTimeoutTracker and fetchSignalDuration.
-
For each joiningOrigin โ groups of perSignalsUrlGenerator:
-
For each ig of groups:
-
If cumulativeTimeoutTracker is expired then increment metricsโs cumulative timeouts occurred by 1 and continue.
-
If igโs bidding url is null, continue.
-
Let effectiveBuyerTimeout be the result of computing effective timeout given cumulativeTimeoutTracker and perBuyerTimeout.
-
Let generateBidStartTime be settingsโs current monotonic time.
-
Let directFromSellerSignalsForBuyer be the result of running get direct from seller signals for a buyer with directFromSellerSignals, and igโs owner.
-
Let dataVersion be null.
-
Let allTrustedBiddingSignals be an ordered map-or-null, initially null.
-
Let igName be igโs name.
-
If trustedBiddingSignalsBatcherโs no signals flags[igName] does not exist:
-
Set dataVersion to trustedBiddingSignalsBatcherโs data versions[igName].
-
Set allTrustedBiddingSignals to all trusted bidding signals.
-
-
Otherwise if trustedBiddingSignalsBatcherโs no signals flags[igName] is "fetch-failed", and optedInForRealTimeReporting is true, then:
-
Add a platform contribution with trusted bidding signals failure bucket, realTimeContributionsMap, and igName.
-
-
Remove browserSignals["
dataVersion
"]. -
Remove browserSignals["
crossOriginDataVersion
"]. -
If dataVersion is not null:
-
If crossOriginTrustedBiddingSignalsOrigin is not null, then set browserSignals["
crossOriginDataVersion
"] to dataVersion. -
Otherwise, set browserSignals["
dataVersion
"] to dataVersion.
-
-
Let generateBidResult be the result of generate potentially multiple bids given allTrustedBiddingSignals, crossOriginTrustedBiddingSignalsOrigin, auctionSignals, a clone of browserSignals, perBuyerSignals, directFromSellerSignalsForBuyer, effectiveBuyerTimeout, expectedCurrency, multiBidLimit, ig, reportingContext, auctionStartTime, and settings.
-
If generateBidResult is failure, then:
-
If optedInForRealTimeReporting is true, then add a platform contribution with bidding script failure bucket, realTimeContributionsMap and buyer.
-
-
Let (bidsBatch, bidDebugReportInfo, realTimeContributions, paContributions, executionMetrics) be generateBidResult.
-
Let generateBidDuration be the duration from generateBidStartTime to settingsโs current monotonic time, in milliseconds.
-
Expend cumulative timeout time given cumulativeTimeoutTracker and generateBidDuration.
-
If cumulativeTimeoutTracker is expired then:
-
Increment metricsโs cumulative timeouts occurred by 1.
-
-
Let bidsToScore be the result of applying adjust bid list based on k-anonymity to bidsBatch.
-
Let foundKAnonBids be false.
-
For each generatedBid of bidsToScore:
-
If generatedBidโs for k-anon auction is true, set foundKAnonBids to true.
-
-
If bidsToScore is not empty but foundKAnonBids is false:
Note: generate potentially multiple bids is now rerun with only k-anonymous ads to give the buyer a chance to generate potentially multiple bids for k-anonymous ads. Allowing the buyer to first generate potentially multiple bids for non-k-anonymous ads provides a mechanism to bootstrap the k-anonymity count, otherwise no ads would ever trigger increment k-anonymity count and all ads would fail query k-anonymity count.
-
Let kAnonRestrictedIG be the result of running create a k-anon restricted deep copy of the interest group given ig.
-
Let effectiveBuyerTimeout be the result of computing effective timeout given cumulativeTimeoutTracker and perBuyerTimeout.
-
Let generateBidStartTime be settingsโs current monotonic time.
-
Set (generatedBids, bidDebugReportInfo, realTimeContributions, paContributions, executionMetrics) to the result of running generate potentially multiple bids with allTrustedBiddingSignals, crossOriginTrustedBiddingSignalsOrigin, auctionSignals, a clone of browserSignals, perBuyerSignals, directFromSellerSignalsForBuyer, effectiveBuyerTimeout, expectedCurrency, 1 (for multiBidLimit), kAnonRestrictedIG, reportingContext, auctionStartTime, and settings.
Note: passing 1 for multiBidLimit limits the rerun to producing at most a single bid.
-
Let generateBidDuration be the duration from generateBidStartTime to settingsโs current monotonic time, in milliseconds.
-
Expend cumulative timeout time given cumulativeTimeoutTracker and generateBidDuration.
-
If cumulativeTimeoutTracker is expired then:
-
Increment metricsโs cumulative timeouts occurred by 1.
-
-
For each generatedBid of generatedBids:
-
Assert that query generated bid k-anonymity count given generatedBid returns true.
-
Apply any component ads target to a bid given generatedBid.
-
Append generatedBid to bidsToScore.
-
-
-
Register bids for reporting given bidsToScore, ig, bidDebugReportInfo, paContributions, executionMetrics, and reportingContext.
-
If auctionConfigโs per buyer real time reporting config[buyer] is "
default-local-reporting
", then insert entries to map given realTimeContributionsMap, buyer, and realTimeContributions. -
For each bidToScore of bidsToScore:
-
If bidToScoreโs for k-anon auction is true, append bidToScoreโs interest group to bidIgs.
-
Score and rank a bid with auctionConfig, reportingContext, bidToScore, leadingBidInfo, decisionLogicFetcher, trustedScoringSignalsBatcher, directFromSellerSignalsForSeller, dataVersion, auctionLevel, componentAuctionExpectedCurrency, topLevelOrigin, realTimeContributionsMap, and policyContainer.
-
-
-
-
-
-
Update cumulative buyer time metrics given metrics and cumulativeTimeoutTracker.
-
Decrement pendingBuyers by 1.
-
-
Wait until both pendingBuyers and pendingAdditionalBids are 0.
-
If auctionConfigโs aborted is true, return failure.
-
Set reportingContextโs local leader info to leadingBidInfo.
-
If leadingBidInfoโs leading bid is null, return null.
-
If topLevelAuctionConfig is null:
-
Let ยซ sellerSignals, reportResultBrowserSignals ยป be the result of running report result with leadingBidInfo, reportingContext, directFromSellerSignalsForSeller, null, and global.
-
Let directFromSellerSignalsForWinner be the result of running get direct from seller signals for a buyer with directFromSellerSignals, and leadingBidInfoโs leading bidโs interest groupโs owner.
-
Run report win with leadingBidInfo, reportingContext, sellerSignals, reportResultBrowserSignals, directFromSellerSignalsForWinner, and settings.
-
Set reportingContextโs winner reporting id to leadingBidInfoโs leading bidโs reporting id.
-
-
Let replacements be an ordered map whose keys are strings and whose values are strings.
-
For each ad keyword replacement, replacement, within deprecated render url replacements:
-
Let k be replacementโs match.
-
Let v be replacementโs replacement.
-
Set replacements[k] to v.
-
-
-
Set leadingBidInfoโs leading bidโs ad descriptor to the result of substitute macros with replacements and leading bidโs ad descriptor.
-
If leadingBidInfoโs leading bidโs ad descriptors is not null:
-
For each ad descriptor, adDescriptor, within leading bidโs ad descriptors:
-
Set adDescriptor to the result of substitute macros with replacements and adDescriptor.
-
-
-
Return leadingBidInfo.
-
Let igGenerateBid be a new
GenerateBidInterestGroup
with the following fields:owner
- The serialization of igโs owner
name
- igโs name
enableBiddingSignalsPrioritization
- igโs enable bidding signals prioritization
priorityVector
- igโs priority vector if not null, otherwise not set.
executionMode
- igโs execution mode
biddingLogicURL
- The serialization-or-undefined of igโs bidding url
biddingWasmHelperURL
- The serialization of igโs bidding wasm helper url
updateURL
- The serialization of igโs update url
trustedBiddingSignalsURL
- The serialization of igโs trusted bidding signals url
trustedBiddingSignalsKeys
- igโs trusted bidding signals keys, if not null, otherwise not set.
trustedBiddingSignalsSlotSizeMode
- igโs trusted bidding signals slot size mode
maxTrustedBiddingSignalsURLLength
- igโs max trusted bidding signals url length
trustedBiddingSignalsCoordinator
- The serialization of igโs trusted bidding signals coordinator
userBiddingSignals
- Parse a JSON string to a JavaScript value given igโs user bidding signals
ads
- igโs ads converted to an AuctionAd sequence
adComponents
- igโs ad components converted to an AuctionAd sequence
-
Return igGenerateBid.
-
If ads is null, then return
undefined
. -
For each ad of ads:
-
Let adIDL be a new
AuctionAd
. -
Set adIDL["
renderURL
"] to the serialization of adโs render url. -
If adโs selectable buyer and seller reporting IDs is not null:
-
Set adIDL["
selectableBuyerAndSellerReportingIds
"] to adโs selectable buyer and seller reporting IDs. -
If adโs buyer and seller reporting id is not null then set adIDL["
buyerAndSellerReportingId
"] to adโs buyer and seller reporting id. -
If adโs buyer reporting id is not null then set adIDL["
buyerReportingId
"] to adโs buyer reporting id.
-
-
If adโs size group is not null, then set adIDL["
sizeGroup
"] to adโs size group. -
If adโs metadata is not null, then set adIDL["
metadata
"] to the result of parsing a JSON string to a JavaScript value given adโs metadata. -
If adโs creative scanning metadata is not null, then set adIDL["
creativeScanningMetadata
"] to it. -
Append adIDL to adsIDL.
-
-
Return adsIDL.
-
Let isCrossOrigin be false.
-
Let sameOriginTrustedScoringSignals be null.
-
Let crossOriginTrustedScoringSignals be null.
-
Let scoringDataVersion be null.
-
Let sendCreativeScanningMetadata be auctionConfigโs send creative scanning metadata.
-
If auctionConfigโs trusted scoring signals coordinator is not null, set sendCreativeScanningMetadata to false.
-
Let owner be generatedBidโs interest groupโs owner.
-
Let mainAd be the result of filling in creative info given sendCreativeScanningMetadata, generatedBidโs ad descriptor, owner, bid ad.
-
Let adComponents be a new empty set.
-
for each i in the range from 0 to bid ad componentsโs size - 1, inclusive:
-
Let adComponentCreativeInfo be the result of filling in creative info given sendCreativeScanningMetadata, generatedBidโs ad component descriptors[i], owner, generatedBidโs bid ad components[i].
-
Append adComponentCreativeInfo to adComponents.
-
-
If auctionConfigโs trusted scoring signals url is not null:
-
Let request be a new trusted scoring signals request with the following items:
- send creative scanning metadata
-
sendCreativeScanningMetadata.
- seller
-
auctionConfigโs seller
- seller script fetcher
-
decisionLogicFetcher
- base url
-
auctionConfigโs trusted scoring signals url
- seller experiment group id
-
auctionConfigโs seller experiment group id
- top level origin
-
topLevelOrigin
- ad
-
mainAd
- ad components
-
adComponents
- policy container
-
policyContainer
- signal coordinator
-
auctionConfigโs trusted scoring signals coordinator
- owner origin
-
owner
- joining origin
-
generatedBidโs interest groupโs joining origin
-
If auctionConfigโs trusted scoring signals urlโs origin is not same origin with auctionConfigโs seller, then set isCrossOrigin to true.
-
Let result be the result of fetching trusted scoring signals with batching with batcher and request.
-
If result is not failure:
-
Let allTrustedScoringSignals be resultโs all trusted scoring signals:
-
Set scoringDataVersion to resultโs data version.
-
Let trustedScoringSignals be a new empty map.
-
If allTrustedScoringSignals["
renderURLs
"] exists and allTrustedScoringSignals["renderURLs
"][renderURL] exists, then set trustedScoringSignals["renderURL
"][renderURL] to allTrustedScoringSignals["renderURLs
"][renderURL]. -
If adComponentRenderURLs is not empty:
-
If isCrossOrigin is false, set sameOriginTrustedScoringSignals to trustedScoringSignals.
-
Otherwise:
-
Set crossOriginTrustedScoringSignals to a new map.
-
Let originKey be the serialization given auctionConfigโs trusted scoring signals urlโs origin.
-
Set crossOriginTrustedScoringSignals[originKey] to trustedScoringSignals.
-
-
-
Otherwise if auctionConfigโs seller real time reporting config is "
default-local-reporting
",then:-
Add a platform contribution with trusted scoring signals failure bucket, realTimeContributionsMap, and auctionConfigโs seller.
-
-
-
Return ยซisCrossOrigin, sameOriginTrustedScoringSignals, crossOriginTrustedScoringSignals, scoringDataVersionยป
DirectFromSellerSignalsForSeller
directFromSellerSignalsForSeller, an unsigned long
-or-null biddingDataVersion, an enum auctionLevel, which is "single-level-auction", "top-level-auction",
or "component-auction", a currency tag componentAuctionExpectedCurrency, an origin topLevelOrigin, a real time reporting contributions map realTimeContributionsMap, and
a policy container policyContainer:
-
Let ยซtrustedScoringSignalsAreCrossOrigin, sameOriginTrustedScoringSignals, crossOriginTrustedScoringSignals, scoringDataVersionยป be the result of fetch and decode trusted scoring signals given trustedScoringSignalsBatcher, auctionConfig, generatedBid, decisionLogicFetcher, topLevelOrigin, realTimeContributionsMap, and policyContainer.
-
Let adMetadata be generatedBidโs ad.
-
Let bidValue be generatedBidโs bid.
-
If generatedBidโs modified bid is not null, then set bidValue to generatedBidโs modified bid.
-
Let owner be generatedBidโs interest groupโs owner.
-
Let browserSignals be a
ScoringBrowserSignals
with the following fields:topWindowHostname
- The result of running the host serializer on topLevelOriginโs host
interestGroupOwner
- Serialized owner
renderURL
- The result of running the URL serializer on generatedBidโs ad descriptorโs url
renderSize
- The result of running convert an ad size to a map with generatedBidโs ad descriptorโs size if it is not null,
undefined
otherwise biddingDurationMsec
- generatedBidโs bid duration
bidCurrency
- The result of serializing a currency tag with generatedBidโs bidโs currency
dataVersion
- scoringDataVersion if it is not null and trustedScoringSignalsAreCrossOrigin is false, unset otherwise.
crossOriginDataVersion
- scoringDataVersion if it is not null and trustedScoringSignalsAreCrossOrigin is true, unset otherwise.
adComponents
- generatedBidโs ad component descriptors converted to a string sequence
forDebuggingOnlyInCooldownOrLockout
- The result of running is debugging only in cooldown or lockout with seller
creativeScanningMetadata
- generatedBidโs bid adโs creative scanning metadata if non-null, unset otherwise.
adComponentsCreativeScanningMetadata
- Unset if generatedBidโs bid ad components is empty; the result of extracting component ad creative scanning metadata given generatedBidโs bid ad components otherwise.
-
Let decisionLogicScript be the result of wait for script body from a fetcher given decisionLogicFetcher.
-
If decisionLogicScript is failure, then:
-
If auctionConfigโs seller real time reporting config is "
default-local-reporting
", then add a platform contribution with scoring script failure bucket, realTimeContributionsMap and seller. -
Return.
-
-
Let metrics be the result of access per-participant metrics given reportingContext, auctionConfigโs seller, score-ad.
-
Add a sample to an averager given metricsโs code fetch time averager and decisionLogicFetcherโs fetch duration.
-
Let ยซ scoreAdResult, debugWinReportUrl, debugLossReportUrl, realTimeContributions, paContributions, executionMetrics ยป be the result of evaluating a scoring script with decisionLogicScript, adMetadata, bidValueโs value, auctionConfig, reportingContext, sameOriginTrustedScoringSignals, crossOriginTrustedScoringSignals, browserSignals, directFromSellerSignalsForSeller, and auctionConfigโs seller timeout.
-
Increment metricsโs script executions attempted by 1.
-
If executionMetricsโs script timed out is true, increment metricsโs script timeouts occurred by 1.
-
If generatedBidโs for k-anon auction is true:
Note: Non-k-anonymous bids do not participate in reporting (except for platform real-time contributions, and some special handling of private aggregation requests involving reject-reason); as it would be problematic to report a winner that didnโt actually win.
-
Let reportingId be generatedBidโs reporting id.
-
If reportingContextโs debug reporting info[reportingId] does not exist, set it to a new bid debug reporting info.
-
Let bidDebugReportInfo be reportingContextโs debug reporting info [reportingId].
-
If auctionLevel is "top-level-auction":
-
Set bidDebugReportInfoโs top level seller debug loss report url to debugLossReportUrl.
-
Set bidDebugReportInfoโs top level seller debug win report url to debugWinReportUrl.
-
-
Otherwise:
-
Set bidDebugReportInfoโs seller debug loss report url to debugLossReportUrl.
-
Set bidDebugReportInfoโs seller debug win report url to debugWinReportUrl.
-
-
If auctionLevel is "component-auction", then set bidDebugReportInfoโs component seller to seller.
-
If auctionConfigโs seller real time reporting config is "
default-local-reporting
", then insert entries to map given realTimeContributionsMap, seller, and realTimeContributions. -
Insert reportingId into reportingContextโs seller participants.
-
Commit private aggregation contributions given paContributions, reportingId, and reportingContext.
-
-
Let scoreAdOutput be result of processing scoreAd output with scoreAdResult.
-
Return if any of the following conditions hold:
-
scoreAdOutput is failure;
-
auctionLevel is not "single-level-auction", and scoreAdOutput ["
allowComponentAuction
"] is false; -
scoreAdOutput["
desirability
"] โค 0.
-
-
If auctionLevel is "component-auction":
-
Set generatedBidโs component seller to seller.
-
Let bidToCheck be generatedBidโs bid.
-
If scoreAdOutput["
bid
"] exists:-
Let modifiedBidValue be scoreAdOutput["
bid
"]. -
If modifiedBidValue โค 0, return.
-
Let modifiedBidCurrency be null.
-
If scoreAdOutput["
bidCurrency
] exists, then set modifiedBidCurrency to scoreAdOutput["bidCurrency
]. -
Set generatedBidโs modified bid to a bid with currency with value modifiedBidValue and currency modifiedBidCurrency.
-
Set bidToCheck to generatedBidโs modified bid.
-
-
If the result of checking a currency tag with componentAuctionExpectedCurrency and bidToCheckโs currency is false, return.
-
If the result of checking a currency tag with auctionConfigโs seller currency and bidToCheckโs currency is false, return.
-
-
If auctionConfigโs seller currency is not null:
-
If generatedBidโs bidโs currency is equal to auctionConfigโs seller currency:
-
Set generatedBidโs bid in seller currency to generatedBidโs bidโs value.
-
If scoreAdOutput["
incomingBidInSellerCurrency
"] exists and does not equal generatedBidโs bid in seller currency, return.
-
-
Otherwise if scoreAdOutput["
incomingBidInSellerCurrency
"] exists, then set generatedBidโs bid in seller currency to scoreAdOutput["incomingBidInSellerCurrency
"].
-
-
Let score be scoreAdOutput["
desirability
"]. -
If generatedBidโs for k-anon auction is false:
-
Let updateLeadingNonKAnonEnforcedBid be false.
-
If leadingBidInfoโs leading non-k-anon-enforced bid is null, or score > leadingBidInfoโs top non-k-anon-enforced score:
-
Set updateLeadingNonKAnonEnforcedBid to true.
-
Set leadingBidInfoโs top non-k-anon-enforced bids count to 1.
-
-
If leadingBidInfoโs leading non-k-anon-enforced bid is not null and score = leadingBidInfoโs top non-k-anon-enforced score:
-
Increment leadingBidInfoโs top non-k-anon-enforced bids count by 1.
-
Set updateLeadingNonKAnonEnforcedBid to true with 1 in leadingBidInfoโs top non-k-anon-enforced bids count chance.
-
-
If updateLeadingNonKAnonEnforcedBid is true:
-
Set leadingBidInfoโs top non-k-anon-enforced score to score.
-
Set leadingBidInfoโs leading non-k-anon-enforced bid to generatedBid.
-
-
Return.
-
-
Let updateLeadingBid be false.
-
If leadingBidInfoโs leading bid is null, or score > leadingBidInfoโs top score:
-
Set updateLeadingBid to true.
-
Set leadingBidInfoโs top bids count to 1.
-
Set leadingBidInfoโs at most one top bid owner to true.
-
-
Otherwise if score equals leadingBidInfoโs top score:
-
Increment leadingBidInfoโs top bids count by 1.
-
Set updateLeadingBid to true with 1 in leadingBidInfoโs top bids count chance.
-
If updateLeadingBid is false, then update highest scoring other bid with score, leadingBidInfoโs leading bid, and leadingBidInfo.
-
If owner is not same origin with leadingBidInfoโs leading bidโs interest groupโs owner, then set leadingBidInfoโs at most one top bid owner to false.
-
-
Otherwise if score is greater than or equal to leadingBidInfoโs second highest score, then update highest scoring other bid with score, bidValue, and leadingBidInfo.
-
If updateLeadingBid is true:
-
If leadingBidInfoโs leading bid is not null, then update highest scoring other bid with leadingBidInfoโs top score, leadingBidInfoโs leading bid, and leadingBidInfo.
-
Set leadingBidInfoโs top score to score.
-
Set leadingBidInfoโs leading bid to generatedBid.
-
Set leadingBidInfoโs auction config to auctionConfig.
-
Set leadingBidInfoโs bidding data version to biddingDataVersion.
-
Set leadingBidInfoโs scoring data version to scoringDataVersion.
-
-
For each componentAd of bidAdComponents:
-
Append componentAdโs creative scanning metadata to result.
-
-
Return result.
double
score, a generated bid-or-null bid, and a leading bid info leadingBidInfo:
-
If bid is null, return.
-
Let owner be bidโs interest groupโs owner.
-
If score is greater than leadingBidInfoโs second highest score:
-
Set leadingBidInfoโs highest scoring other bid to bid.
-
Set leadingBidInfoโs highest scoring other bids count to 1.
-
Set leadingBidInfoโs second highest score to score.
-
Set leadingBidInfoโs highest scoring other bid owner to owner if leadingBidInfoโs at most one top bid owner is true, null otherwise.
-
-
Otherwise if score is equal to leadingBidInfoโs second highest score:
-
Increment leadingBidInfoโs highest scoring other bids count by 1.
-
Set leadingBidInfoโs highest scoring other bid to bid with 1 in leadingBidInfoโs highest scoring other bids count chance.
-
If leadingBidInfoโs highest scoring other bid owner is not null and owner is not same origin with leadingBidInfoโs highest scoring other bid owner, then set leadingBidInfoโs highest scoring other bid owner to null.
-
The Ad-Auction-Allowed
HTTP response header is a structured header whose value must be a boolean.
-
If getting `
Ad-Auction-Allowed
` and "item
" from responseโs header list does not return a true value, return false. -
Return true.
-
If responseBody is null or failure, return false.
-
Let headerMimeType be the result of extracting a MIME type from responseโs header list.
-
Return false if any of the following conditions hold:
-
headerMimeType is failure;
-
mimeType is "
text/javascript
" and headerMimeType is not a JavaScript MIME type; -
mimeType is "
application/json
" and headerMimeType is not a JSON MIME type. -
mimeType is "
application/wasm
" and the result of getting "Content-Type
" from responseโs header list is null or not byte-case-insensitive equal to "application/wasm
". -
mimeType is "
message/ad-auction-trusted-signals-response
" and the result of getting "Content-Type
" from responseโs header list is null or not byte-case-insensitive equal to "message/ad-auction-trusted-signals-response
".Note: This was intended to match the behavior of compiling a potential WebAssembly response, but diverges by failing to remove leading and trailing HTTP tab or space bytes.
-
-
If mimeType is not "
application/wasm
":-
Let mimeTypeCharset be "utf-8".
-
If headerMimeTypeโs parameters["
charset
"] exists, set mimeTypeCharset to headerMimeTypeโs parameters["charset
"]. -
Return true if any of the following conditions hold:
-
mimeTypeCharset is "utf-8", and responseBody is UTF-8 encoded;
-
mimeTypeCharset is "us-ascii", and all bytes in responseBody are ASCII bytes.
-
-
Return false.
-
-
Return true.
-
If the result of validating fetching response headers given response is false, then return false.
-
If the result of validating fetching response mime and body given response, responseBody, mimeType is false, then return false.
-
Return true.
-
Let request be a new request with the following properties:
- URL
-
url
- header list
-
ยซ
Accept
:application/wasm
ยป - client
-
null
- origin
-
settingsโs origin
- mode
-
"
no-cors
" - referrer
-
"
no-referrer
" - credentials mode
-
"
omit
" - redirect mode
-
"
error
" - service-workers mode
-
"
none
" - policy container
-
A new policy container whose IP address space is settingsโs policy containerโs IP address space
Stop using "
no-cors
" mode where possible (WICG/turtledove#667). -
Let moduleObject be null.
-
Fetch request with processResponseConsumeBody set to the following steps given a response response and null, failure, or a byte sequence responseBody:
-
If validate fetching response with response, responseBody and "
application/wasm
" returns false, set moduleObject to failure and return. -
Let module be the result of compiling a WebAssembly module response.
-
If module is error, set moduleObject to failure.
-
Otherwise, set moduleObject to module.
-
-
Wait for moduleObject to be set.
-
Return moduleObject.
The Data-Version
HTTP response header is a structured header whose value must be an integer.
The X-fledge-bidding-signals-format-version
HTTP response header
is a structured header whose value must be an integer.
-
Let request be a new request with the following properties:
- URL
-
url
- origin
-
scriptOrigin
- header list
-
ยซ
Accept
:application/json
ยป - client
-
null
- mode
-
"
cors
" - referrer
-
"
no-referrer
" - credentials mode
-
"
omit
" - redirect mode
-
"
error
" - service-workers mode
-
"
none
" - policy container
-
A new policy container whose IP address space is policyContainerโs IP address space
-
Let signals be null.
-
Let dataVersion be null.
-
Let formatVersion be null.
-
Let perInterestGroupData be an ordered map whose keys are name strings and whose values are bidding signals per interest group data.
-
Fetch request with useParallelQueue set to true, and processResponseConsumeBody set to the following steps given a response response and null, failure, or a byte sequence responseBody:
-
If validate fetching response with response, responseBody and "
application/json
" returns false, set signals to failure and return. -
Let headers be responseโs header list.
-
Set dataVersion to the result of getting a structured field value given `
Data-Version
` and "item
" from headers. -
If dataVersion is not null:
-
If dataVersion is not an integer, or is less than 0 or more than 232โ1, set signals to failure and return.
-
-
If isBiddingSignal is true, then set formatVersion to the result of getting a structured field value given `
X-fledge-bidding-signals-format-version
` and "item
" from headers. -
Set signals to the result of parsing JSON bytes to an Infra value responseBody.
-
-
Wait for signals to be set.
-
If signals is a parsing exception, or if signals is not an ordered map, return a tuple (null, null, null).
-
If formatVersion is 2:
-
If signals["
keys
"] does not exist, tuple (null, null, null ). -
Set signals to signals["
keys
"]. -
If signals is not an ordered map, return a tuple (null, null, null).
-
If signals["
perInterestGroupData
"] exists and is an ordered map:-
Assert isBiddingSignal is true.
-
Let perInterestGroupData be signals["
perInterestGroupData
"].
-
-
-
For each key โ value of signals:
-
Set signals[key] to the result of serializing an Infra value to a JSON string given value.
-
-
Return a tuple (signals, perInterestGroupData, dataVersion).
-
Let request be a new request with the following properties:
- URL
-
url
- method
-
POST
- body
-
body
- origin
-
scriptOrigin
- header list
-
ยซ
Content-Type
:message/ad-auction-trusted-signals-request
,Accept
:message/ad-auction-trusted-signals-response
ยป - client
-
null
- mode
-
"
cors
" - referrer
-
"
no-referrer
" - credentials mode
-
"
omit
" - redirect mode
-
"
error
" - service-workers mode
-
"
none
" - policy container
-
A new policy container whose IP address space is policyContainerโs IP address space
-
Let signals be null.
-
Let signalsMap be an empty map, whose keys are strings and values are maps.
-
Let dataVersion be an empty ordered map, whose keys are strings and values are integers.
-
Let perInterestGroupData be an ordered map whose keys are name strings and whose values are bidding signals per interest group data.
-
Fetch request with useParallelQueue set to true, and processResponseConsumeBody set to the following steps given a response response and null, failure, or a byte sequence responseBody:
-
If validate fetching response with response, responseBody and "
message/ad-auction-trusted-signals-response
" returns false, return ยซ failure, null, null ยป. -
Let resultList be the result of deserializing responseBody using context. The deserialization method may follow that described in Section 2.3.6 of the Protected Audience Key Value Services.
-
For each result in resultList:
-
If result contains "
dataVersion
":-
If result["dataVersion"] is not an integer, or is less than 0 or more than 232โ1, return ยซ failure, null, null ยป.
-
-
If isBiddingSignal is true:
-
Otherwise:
-
-
-
If signalsMap is not empty, set signals to signalsMap.
-
Return ยซ signals, perInterestGroupData, dataVersion ยป.
Add "message/ad-auction-trusted-signals-request
" to mimeTypeโs essence check list under "content-type
" in CORS-safelisted request-header.
To encode trusted signals keys given a list of strings keys:
-
For each keyStr in keys:
-
Append the result of UTF-8 percent-encoding keyStr using component percent-encode set to escapedKeys.
The Chrome implementation encodes 0x20 (SP) to U+002B (+), while UTF-8 percent-encoding encodes it to "%20".
-
-
Return the result of concatenating escapedKeys with separator set to ",".
To convert an ad size to a string given an ad size adSize.
-
Let sizeList be an empty list.
-
Let jsWidth be adSizeโs width, converted to an ECMAScript value.
-
Append adSizeโs width units to sizeList.
-
Append "," to sizeList.
-
Let jsHeight be adSizeโs height, converted to an ECMAScript value.
-
Append adSizeโs height units to sizeList.
-
Return the result of concatenating sizeList.
To calculate the ad slot size query param given an interest group ig and auction config config:
-
Switch on igโs trusted bidding signals slot size mode:
- "
none
" -
-
Return "".
-
- "
slot-size
" -
-
If configโs requested size is null, then return "".
-
Otherwise:
-
Let adSizeString the result of running convert an ad size to a string on configโs requested size.
-
Return the result of concatenating ยซ "&slotSize=", adSizeString ยป.
-
-
- "
all-slots-requested-sizes
" -
-
If configโs all slots requested sizes is null, then return "".
-
For each adSize in configโs all slots requested sizes:
-
Let adSizeString the result of running convert an ad size to a string on adSize.
-
Append adSizeString to allSizesList.
-
-
Let allSizes be the result of concatenating allSizesList, with "," as a separator.
-
Return the result of concatenating ยซ "&allSlotsRequestedSizes=", allSizes ยป.
-
- "
-
Let request be a new request with the following properties:
- URL
-
url
- client
-
null
- origin
-
settingsโs origin
- mode
-
"
no-cors
" - referrer
-
"
no-referrer
" - credentials mode
-
"
omit
" - redirect mode
-
"
error
" - service-workers mode
-
"
none
" - policy container
-
A new policy container whose IP address space is settingsโs policy containerโs IP address space
Stop using "
no-cors
" mode where possible (WICG/turtledove#667). -
Fetch request with useParallelQueue set to true.
-
If adSlot is not a string, then return null.
-
Let directFromSellerSignals be null.
-
Let directFromSellerSignalsKey be a new direct from seller signals key with its seller set to seller, and ad slot set to adSlot.
-
If capturedAuctionSignalsHeaders[directFromSellerSignalsKey] exists:
-
Set directFromSellerSignals to capturedAuctionSignalsHeaders[directFromSellerSignalsKey].
-
-
Return directFromSellerSignals.
-
Let directFromSellerSignalsForSeller be a new
DirectFromSellerSignalsForSeller
. -
If directFromSellerSignals is null, then return directFromSellerSignalsForSeller.
-
Set directFromSellerSignalsForSeller["auctionSignals"] to the result of running parse a JSON string to an Infra value given directFromSellerSignalsโs auction signals.
-
Set directFromSellerSignalsForSeller["sellerSignals"] to the result of running parse a JSON string to an Infra value given directFromSellerSignalsโs seller signals.
-
Return directFromSellerSignalsForSeller.
-
Let directFromSellerSignalsForBuyer be a new
DirectFromSellerSignalsForBuyer
. -
If directFromSellerSignals is null, then return directFromSellerSignalsForBuyer.
-
Set directFromSellerSignalsForBuyer["auctionSignals"] to the result of running parse a JSON string to an Infra value given directFromSellerSignalsโs auction signals.
-
If directFromSellerSignalsโs per buyer signals[owner] exists:
-
Set directFromSellerSignalsForBuyer["perBuyerSignals"] to the result of running parse a JSON string to an Infra value given directFromSellerSignalsโs per buyer signals[owner].
-
-
Return directFromSellerSignalsForBuyer.
-
Let config be leadingBidInfoโs auction config.
-
Let bidCurrency be null.
-
If winningComponentConfig is not null:
-
Assert that leadingBidInfoโs component seller is not null.
-
Set bidCurrency to winningComponentConfigโs seller currency.
-
If bidCurrency is null, then set bidCurrency to the result of looking up per-buyer currency with config and leadingBidInfoโs component seller.
-
-
Otherwise, set bidCurrency to the result of looking up per-buyer currency with config and leadingBidInfoโs leading bidโs interest groupโs owner.
-
Let winner be leadingBidInfoโs leading bid.
-
Let sellerCurrency be leadingBidInfoโs auction configโs seller currency.
-
Let highestScoringOtherBid be leadingBidInfoโs highest scoring other bidโs bid in seller currency (or 0 if encountered a null).
-
If sellerCurrency is null, then set highestScoringOtherBid to leadingBidInfoโs highest scoring other bidโs bidโs value (or 0 if encountered a null).
-
Let modifiedBid be null.
-
If winnerโs modified bid is not null:
-
If leadingBidInfoโs component seller is not null, then set bid to winnerโs modified bid.
-
Otherwise, set modifiedBid to winnerโs modified bid.
-
-
Let browserSignals be a
ReportResultBrowserSignals
with the following fields:topWindowHostname
- The result of running the host serializer on globalโs top-level originโs host.
interestGroupOwner
- Serialized winnerโs interest groupโs owner.
renderURL
- Serialized winnerโs ad descriptorโs url
bid
- Stochastically rounded bid
bidCurrency
- The result of serializing a currency tag with bidCurrency
highestScoringOtherBid
- highestScoringOtherBid
highestScoringOtherBidCurrency
- sellerCurrency if it is not null, "
???
" otherwise topLevelSeller
- leadingBidInfoโs top level seller if it is not null,
undefined
otherwise componentSeller
- leadingBidInfoโs component seller if it is not null,
undefined
otherwise desirability
- Stochastically rounded leadingBidInfoโs top score
topLevelSellerSignals
- leadingBidInfoโs top level seller signals if it is not null,
undefined
otherwise modifiedBid
- Stochastically rounded modifiedBid if it is not null,
undefined
otherwise dataVersion
- leadingBidInfoโs scoring data version if it is not null,
undefined
otherwise
-
Let igAd be the interest group ad from winnerโs interest groupโs ads whose render url is winnerโs ad descriptorโs url.
-
If the winnerโs selected buyer and seller reporting ID is not null:
-
Assert that the result of running query reporting ID k-anonymity count with winnerโs interest group, igAd, and winnerโs selected buyer and seller reporting ID is true.
Note: The winning interest group ad is expected to be k-anonymous for reporting because any bid that included a selected buyer and seller reporting ID wouldnโt be considered k-anonymous, and thus couldnโt win the auction and wouldnโt be reported, unless that bid was k-anonymous for reporting with that selected buyer and seller reporting ID.
-
Set browserSignals["
selectedBuyerAndSellerReportingId
"] to winnerโs selected buyer and seller reporting ID. -
If igAdโs buyer and seller reporting ID is not null, set browserSignals["
buyerAndSellerReportingId
"] to it.
-
-
Otherwise, if the result of running query reporting ID k-anonymity count with winnerโs interest group, igAd, and null is true:
-
If igAdโs buyer and seller reporting ID is not null, set browserSignals["
buyerAndSellerReportingId
"] to it.
-
-
Let metrics be the result of access per-participant metrics given reportingContext, configโs seller, report-result.
-
Let sellerReportingScriptFetcher be the result of creating a new script fetcher with configโs decision logic url and globalโs relevant settings object.
-
Let sellerReportingScript be the result of waiting for script body from a fetcher given sellerReportingScriptFetcher.
-
Add a sample to an averager given metricsโs code fetch time averager and sellerReportingScriptFetcherโs fetch duration.
-
Let ยซ sellerSignals, reportUrl, reportingBeaconMap, ignored, paContributions, executionMetrics ยป be the result of evaluating a reporting script with sellerReportingScript, "
reportResult
", reportingContext, configโs seller, configโs seller Private Aggregation coordinator, configโs config idlโsreportingTimeout
, and ยซ configโs config idl, browserSignals, directFromSellerSignals ยป. -
Set metricsโs script executions attempted to 1.
-
If executionMetricsโs script timed out is true, set metricsโs script timeouts occurred to 1.
-
Let reportingResult be a reporting result with the following items:
- report url
-
reportUrl
- reporting beacon map
-
reportingBeaconMap
-
If leadingBidInfoโs top level seller is null (i.e., if we are reporting for a component seller), set leadingBidInfoโs component seller reporting result to reportingResult.
-
Otherwise, set leadingBidInfoโs seller reporting result to reportingResult.
-
Commit private aggregation contributions given paContributions, winnerโs reporting id and reportingContext.
-
Remove browserSignals["
desirability
"]. -
Remove browserSignals["
modifiedBid
"]. -
Remove browserSignals["
topLevelSellerSignals
"]. -
Remove browserSignals["
dataVersion
"].Note: Remove fields specific to
ReportResultBrowserSignals
which only sellers can learn about, so that they are not passed to "reportWin()
". -
Return ยซ sellerSignals, browserSignals ยป.
ReportingBrowserSignals
browserSignals, a direct from seller signals-or-null directFromSellerSignals, and an environment settings object settings:
-
Let config be leadingBidInfoโs auction config.
-
Let winner be leadingBidInfoโs leading bid.
-
Let perBuyerSignals be configโs per buyer signals.
-
Let buyer be winnerโs interest groupโs owner.
-
Let perBuyerSignalsForBuyer be perBuyerSignals[buyer] if that member exists, and null otherwise.
-
Let reportWinBrowserSignals be a
ReportWinBrowserSignals
with the members that are declared onReportingBrowserSignals
initialized to their values in browserSignals. -
Add the following fields to reportWinBrowserSignals:
dataVersion
- leadingBidInfoโs bidding data version if it is not null,
undefined
otherwise. adCost
- Rounded winnerโs ad cost
seller
- Serialized configโs seller
madeHighestScoringOtherBid
- Set to true if leadingBidInfoโs highest scoring other bid owner is not null, and buyer is same origin with leadingBidInfoโs highest scoring other bid owner, false otherwise
modelingSignals
- winnerโs modeling signals if it is not null,
undefined
otherwise (TODO: noise and bucket this signal)
-
Let ig be winnerโs interest group.
-
Let metrics be the result of access per-participant metrics given reportingContext, igโs owner, report-win.
-
Let igAd be the interest group ad from igโs ads whose render url is winnerโs ad descriptorโs url.
-
If winnerโs selected buyer and seller reporting ID is not null:
Note: If the winning bid has a selected buyer and seller reporting ID, it would have already been set by the preceding call to report result, and provided to this algorithm in the
ReportingBrowserSignals
returned by that algorithm and provided to this one.-
Assert that reportWinBrowserSignalsโs ["
selectedBuyerAndSellerReportingId
"] is equal to winnerโs selected buyer and seller reporting ID. -
Assert that the result of running query reporting ID k-anonymity count with winnerโs interest group, igAd, and selected buyer and seller reporting ID is true.
-
-
Otherwise if igAdโs buyer and seller reporting ID is not null:
Note: If the winning interest group ad has a buyer and seller reporting ID, it would have already been set by the preceding call to report result, and provided to this algorithm in the
ReportingBrowserSignals
returned by that algorithm and provided to this one.-
Assert that reportWinBrowserSignalsโs ["
buyerAndSellerReportingId
"] is equal to igAdโs buyer and seller reporting ID. -
Assert that the result of running query reporting ID k-anonymity count with winnerโs interest group, igAd, and null is true.
-
-
Otherwise if the result of running query reporting ID k-anonymity count with winnerโs interest group, igAd, and null is true:
-
If igAdโs buyer reporting ID is not null, set reportWinBrowserSignals["
buyerReportingId
"] to igAdโs buyer reporting ID. -
Otherwise, set reportWinBrowserSignals["
interestGroupName
"] to winnerโs interest group name.
-
-
Let buyerReportingScriptFetcher be the result of creating a new script fetcher with winnerโs interest groupโs bidding url and settings.
-
Let buyerReportingScript be the result of waiting for script body from a fetcher given buyerReportingScriptFetcher.
-
Add a sample to an averager given metricsโs code fetch time averager and buyerReportingScriptFetcherโs fetch duration.
-
Let reportFunctionName be "
reportWin
". -
If winnerโs provided as additional bid is true:
-
Set reportFunctionName be "
reportAdditionalBidWin
".
-
-
Let ยซ ignored, resultUrl, reportingBeaconMap, reportingMacroMap, paContributions, executionMetrics ยป be the result of evaluating a reporting script with buyerReportingScript, reportFunctionName, reportingContext, igโs owner, igโs Private Aggregation coordinator, leadingBidInfoโs auction configโs config idlโs
reportingTimeout
, and ยซ leadingBidInfoโs auction configโs config idlโsauctionSignals
, perBuyerSignalsForBuyer, sellerSignals, reportWinBrowserSignals, directFromSellerSignals ยป. -
Set metricsโs script executions attempted to 1.
-
If executionMetricsโs script timed out is true, set metricsโs script timeouts occurred to 1.
-
Commit private aggregation contributions given paContributions, winnerโs reporting id and reportingContext.
-
Set leadingBidInfoโs buyer reporting result to a reporting result with the following items:
- report url
-
resultUrl
- reporting beacon map
-
reportingBeaconMap
- reporting macro map
-
reportingMacroMap
-
Assert that these steps are running in parallel.
-
If waiting until server response promise resolves given auctionConfig returns failure, then return failure.
-
Let requestId be the value of auctionConfigโs server response id.
-
Let requestContexts be the value of globalโs associated Documentโs node navigableโs traversable navigableโs saved Bidding and Auction request context.
-
If requestContexts[(seller,requestId)] does not exist, return null.
-
Let requestContext be requestContexts[(seller,requestId)].
-
Let response be the server auction response which is the result of deserializing auctionConfigโs server response with requestContext according to Section 2.3.5 of the Bidding and Auction Services IETF standard.
-
-
Let capturedAuctionNonceHeaders be globalโs associated Documentโs node navigableโs traversable navigableโs captured ad auction result nonce headers.
-
Let seller be auctionConfigโs seller.
-
If capturedAuctionNonceHeaders[seller] does not exist or does not contain the ASCII lowercase string representation of responseโs nonce, then return failure.
-
-
Otherwise:
-
Let hash be the SHA-256 of auctionConfigโs server response.
-
Let capturedAuctionResultHeaders be globalโs associated Documentโs node navigableโs traversable navigableโs captured ad auction result headers.
-
Let seller be auctionConfigโs seller.
-
If capturedAuctionResultHeaders[seller] does not exist or does not contain hash, then return failure.
-
-
If response is failure, then return failure.
-
If responseโs top level seller is not null:
-
If topLevelAuctionConfig is null return failure.
-
If topLevelAuctionConfigโs seller is not equal to responseโs top level seller, return failure.
-
-
Otherwise if topLevelAuctionConfig is not null, return failure.
-
Let kAnonWinningGroup be the interest group in the user agentโs interest group set whose owner is responseโs interest group owner and name is responseโs interest group name. Return failure if none found.
-
If kAnonWinningGroupโs ads is null, then return failure.
-
Let kAnonWinningAd be null.
-
For each ad of kAnonWinningGroupโs ads:
-
If responseโs ad render url is adโs render url, then set kAnonWinningAd to ad, and break.
-
-
Return failure if any of the following conditions hold:
-
kAnonWinningAd is null;
-
responseโs buyer and seller reporting id is not null and not kAnonWinningAdโs buyer and seller reporting ID;
-
responseโs buyer reporting id is not null and not kAnonWinningAdโs buyer reporting ID;
-
responseโs selected buyer and seller reporting ID is not null, kAnonWinningAdโs selectable buyer and seller reporting IDs is null.
-
responseโs selected buyer and seller reporting ID is not null, kAnonWinningAdโs selectable buyer and seller reporting IDs is not null and it does not contain responseโs selected buyer and seller reporting ID.
-
-
If responseโs winner join candidates is not null:
-
If responseโs winner join candidatesโs ad render url hash is not equal to the result of running compute the key hash of ad on kAnonWinningGroup and kAnonWinningAd, return failure.
-
If responseโs winner join candidatesโs reporting id hash is not equal to the result of running compute the key hash of reporting ID on kAnonWinningGroup, kAnonWinningAd, and responseโs selected buyer and seller reporting id, return failure.
-
-
Let kAnonWinningAdDescriptor be a new ad descriptor whose url is responseโs ad render url.
-
Let kAnonWinningAdComponents be a new list of ad descriptors.
-
For each componentAd in responseโs ad components:
-
Let ad be the interest group ad from kAnonWinningGroupโs ad components where the render url equals componentAd. If there is no matching element, return failure.
-
If responseโs winner join candidates is not null and responseโs winner join candidatesโs ad component render url hashes does not contain the result from compute the key hash of component ad on ad, then return failure.
-
Append a new ad descriptor whose url is componentAd to kAnonWinningAdComponents.
-
-
Let bidDebugReportingInfo be a new bid debug reporting info.
-
For each key โ maybeDebugReportUrl in responseโs component win debugging only reports:
-
If maybeDebugReportUrlโs scheme is not "
https
", then continue. -
If keyโs from seller is true:
-
Set bidDebugReportingInfoโs component seller to seller.
-
If keyโs is debug win is true, then set bidDebugReportingInfoโs seller debug win report url to maybeDebugReportUrl.
-
Otherwise, set bidDebugReportingInfoโs seller debug loss report url to maybeDebugReportUrl.
-
-
Otherwise,
-
Set bidDebugReportingInfoโs interest group owner to responseโs interest group owner.
-
If keyโs is debug win is true, then set bidDebugReportingInfoโs bidder debug win report url to maybeDebugReportUrl.
-
Otherwise, set bidDebugReportingInfoโs bidder debug loss report url to maybeDebugReportUrl.
-
-
-
Set bidDebugReportingInfoโs server filtered debugging only reports to responseโs server filtered debugging only reports.
-
Let reportingContext be reportingContextMap[auctionConfig].
-
Set reportingContextโs debug reporting info to bidDebugReportingInfo.
-
Let reportingId be a reporting bid key with the following items:
- context
-
reportingContext
- source
- bidder origin
-
responseโs interest group owner
- bid identifier
-
responseโs interest group name
-
Handle server response private aggregation fields given response, requestContext and reportingId.
-
Let kAnonWinningBid be a new generated bid with the following items:
- reporting id
-
reportingId
- bid
-
responseโs bid
- bid in seller currency
-
Null
- ad
-
responseโs ad metadata
- ad descriptor
-
kAnonWinningAdDescriptor
- ad component descriptors
-
kAnonWinningAdComponents
- ad cost
-
Null
- modeling signals
-
Null
- interest group
-
kAnonWinningGroup
- bid ad
-
kAnonWinningAd
- modified bid
-
Null if topLevelAuctionConfig is null, otherwise responseโs bid
- bid duration
-
0
- component seller
-
Null
-
Let buyerReportingResult be a new reporting result with the following items:
- report url
-
The value of responseโs buyer reportingโs reporting url.
- reporting beacon map
-
The value of responseโs buyer reportingโs beacon urls.
-
Let sellerReportingResult be a new reporting result with the following items:
- report url
-
The value of responseโs top level seller reportingโs reporting url.
- reporting beacon map
-
The value of responseโs top level seller reportingโs beacon urls.
-
Let componentSellerReportingResult be a new reporting result with the following items:
- report url
-
The value of responseโs component seller reportingโs reporting url.
- reporting beacon map
-
The value of responseโs component seller reportingโs beacon urls.
-
Let kAnonWinningScore be 0.0 if responseโs score is null, responseโs score otherwise.
-
If responseโs ghost winner is not null:
-
Let nonKAnonWinningBid be the result of running parse and validate a ghost winner on auctionConfig, reportingContextMap, and responseโs ghost winner.
-
If nonKAnonWinningBid is failure, set nonKAnonWinningBid to kAnonWinningBid.
-
-
Otherwise:
-
Set nonKAnonWinningBid to kAnonWinningBid.
-
-
Let winningBidInfo be a new leading bid info with the following items:
- top score
-
kAnonWinningScore
- top non-k-anon-enforced score
-
0
- top bids count
-
1
- top non-k-anon-enforced bids count
-
1
- leading bid
-
kAnonWinningBid
- leading non-k-anon-enforced bid
-
nonKAnonWinningBid
- auction config
-
auctionConfig
- highest scoring other bid
-
Null
- top level seller
-
Null if topLevelAuctionConfig is null, otherwise topLevelAuctionConfigโs seller.
- top level seller signals
-
Null
- component seller
-
Null if topLevelAuctionConfig is null, otherwise auctionConfigโs seller.
- bidding data version
-
Null
- scoring data version
-
Null
- buyer reporting result
-
buyerReportingResult
- seller reporting result
-
sellerReportingResult
- component seller reporting result
-
componentSellerReportingResult
-
For each igId in responseโs bidding groups:
-
Let ig be the interest group in the user agentโs interest group set whose owner is igIdโs owner and name is igIdโs name. Continue if none found.
-
Append ig to bidIgs.
-
-
For each igId โ updateIfOlderThan of responseโs update groups:
-
Let ig be the interest group in the user agentโs interest group set whose owner is igIdโs owner and name is igIdโs name. Continue if none found.
-
If updateIfOlderThan is less than 10 mintues, set it to 10 minutes.
-
If current coarsened wall time โ igโs last updated โฅ updateIfOlderThan, set igโs next update after to the current coarsened wall time + updateIfOlderThan.
-
-
Return winningBidInfo.
-
Assert that these steps are running in parallel.
-
Commit server response private aggregation contributions given responseโs component win private aggregation contributions, reportingContext, and reportingId.
-
Commit server response private aggregation contributions given responseโs server filtered private aggregation reserved contributions, reportingContext, and reportingId.
-
Commit server response private aggregation contributions given responseโs server filtered private aggregation non reserved contributions, reportingContext, and reportingId.
-
For each key โ contributions of contributionsMap:
-
Let reportingOrigin be keyโs reporting origin.
-
Let event be keyโs event.
-
Let coordinator be keyโs coordinator.
-
If coordinator is null, set coordinator to the default aggregation coordinator.
-
Let eventToContributionsMap be a new Private Aggregation contributions.
-
Let batchingScope be null.
-
If event starts with "
reserved.
", set batchingScope to the result of running get or create a batching scope given reportingOrigin, coordinator and reportingContext.Note: Each non-reserved event will have a different batching scope that is created later.
-
For each contribution of contributions:
-
Assert contribution["
bucket
"] is abigint
and is contained in the range 0 to 2128, exclusive. -
Assert contribution["
value
"] is along
.Note: All
bucket
andvalue
have been calculated on server side already. -
Let entry be a new on event contribution entry with the items:
- contribution
-
contribution
- batching scope
-
batchingScope
- debug scope
-
A new debug scope.
- worklet function
-
"
generate-bid
" (it does not matter for server returned contributions) - origin
-
reportingOrigin
-
If eventToContributionsMap[event] does not exist, set eventToContributionsMap[event] to ยซ entry ยป.
-
Otherwise, append entry to eventToContributionsMap[event].
-
-
-
Commit private aggregation contributions given eventToContributionsMap, reportingId and reportingContext.
-
Let nonKAnonWinningGroup be the interest group in the user agentโs interest group set whose owner is ghostWinnerโs interest group owner and name is ghostWinnerโs interest group name. Return failure if none found.
-
If nonKAnonWinningGroupโs ads is null, then return failure.
-
Let nonKAnonWinningAd be null.
-
For each ad of nonKAnonWinningGroupโs ads:
-
If ghostWinnerโs candidatesโs ad render url hash is equal to the result of running compute the key hash of ad on nonKAnonWinningGroup and ad:
-
Set nonKAnonWinningAd to ad.
-
-
-
If nonKAnonWinningAd is null, return failure.
-
Let nonKAnonWinningAdDescriptor be a new ad descriptor whose url is nonKAnonWinningAdโs render url.
-
Let nonKAnonWinningAdComponents be a new list of ad descriptors.
-
For each componentAdHash in ghostWinnerโs candidatesโs [server auction join candidate/ad component render url hashes=]:
-
Let matchingAd be null.
-
For each componentAd in nonKAnonWinningGroupโs ad components:
-
If componentAdHash equals the result of running compute the key hash of component ad on componentAd:
-
Set matchingAd to componentAd.
-
-
-
If matchingAd is null, return failure.
-
Append a new ad descriptor whose url is matchingAdโs render url to nonKAnonWinningAdComponents.
-
-
Let selectedBuyerAndSellerReportingId be null.
-
If ghostWinnerโs candidatesโs reporting id hash is not equal to the result of running compute the key hash of reporting ID on nonKAnonWinningGroup, nonKAnonWinningAd, and null:
-
For each selectedReportingId in nonKAnonWinningAdโs selectable buyer and seller reporting IDs:
-
If ghostWinnerโs candidatesโs reporting id hash is equal to the result of running compute the key hash of reporting ID on nonKAnonWinningGroup, nonKAnonWinningAd, and selectedReportingId:
-
Set selectedBuyerAndSellerReportingId to selectedReportingId.
-
-
-
If selectedBuyerAndSellerReportingId is null, return failure.
-
-
Let reportingId be a reporting bid key with the following items:
- context
-
reportingContextMap[auctionConfig]
- source
- bidder origin
-
ghostWinnerโs interest group owner
- bid identifier
-
ghostWinnerโs interest group name
-
Set reportingContextMap[auctionConfig]'s debug reporting info to a new bid debug reporting info.
-
Let bid be 0.
-
Let adMetadata be null.
-
If ghostWinnerโs ghost winner bid info is not null:
-
If nonKAnonWinningAdโs render url is not equal to ghostWinnerโs ghost winner bid infoโs ad render url, return failure.
-
If the size of nonKAnonWinningAdComponents is not equal to the size of ghostWinnerโs ghost winner bid infoโs ad components, return failure.
-
For each idx in get the indices of nonKAnonWinningAdComponents:
-
If nonKAnonWinningAdComponents[idx]'s render url is not equal to ghostWinnerโs ghost winner bid infoโs ad components[idx], return failure.
-
-
Set bid to ghostWinnerโs ghost winner bid infoโs modified bid.
-
Set adMetadataโs ghostWinnerโs ghost winner bid infoโs ad metadata.
-
If nonKAnonWinningAdโs buyer reporting id is not equal to ghostWinnerโs ghost winner bid infoโs buyer reporting id, return failure.
-
If nonKAnonWinningAdโs buyer and seller reporting id is not equal to ghostWinnerโs ghost winner bid infoโs buyer and seller reporting id, return failure.
-
If nonKAnonWinningAdโs selectable buyer and seller reporting IDs is null and ghostWinnerโs ghost winner bid infoโs selected buyer and seller reporting id is not null, return failure.
-
If nonKAnonWinningAdโs selectable buyer and seller reporting IDs is not null and does not contain ghostWinnerโs ghost winner bid infoโs selected buyer and seller reporting id, return failure.
-
-
Let nonKAnonWinningBid be a new generated bid with the following items:
- reporting id
-
reportingId
- bid
-
bid
- bid in seller currency
-
Null
- ad
-
adMetadata
- ad descriptor
-
nonKAnonWinningAdDescriptor
- ad component descriptors
-
nonKAnonWinningAdComponents
- ad cost
-
Null
- modeling signals
-
Null
- interest group
-
nonKAnonWinningGroup
- bid ad
-
nonKAnonWinningAd
- modified bid
-
Null
- bid duration
-
0
- component seller
-
Null
-
Return nonKAnonWinningBid.
4.2. canLoadAdAuctionFencedFrame()
This first introductory paragraph is non-normative.
The process of running an ad auction through navigator
.runAdAuction()
is an
expensive operation. To prevent wasted cycles if the resulting ad cannot be loaded in the current
context, navigator
.canLoadAdAuctionFencedFrame()
is provided as a method to
determine, before the ad auction begins, whether an ad auction-created fencedframe
is allowed to
be loaded in the current context. A fencedframe
has restrictions on where and how it can be
loaded that do not exist with iframe
s.
[SecureContext ]partial interface Navigator {boolean canLoadAdAuctionFencedFrame (); };
The canLoadAdAuctionFencedFrame()
method steps are:
-
Let global be thisโs relevant global object.
-
If globalโs browsing contextโs required CSP is not null, then return false.
Note: CSPEE lets arbitrary data flow from an embedder into a
fencedframe
via the policies it sets. Since this goes against the privacy guarantees of a Protected Audience-createdfencedframe
, this is disallowed. -
Let CSPList be thisโs relevant settings objectโs policy containerโs CSP list.
-
For each policy of CSPList:
-
For each directive of policyโs directive set:
-
-
Let sandboxFlags be globalโs associated Documentโs active sandboxing flag set.
-
If the intersection of sandboxFlags and TBD is not empty, then return false.
TODO: Get the mandatory unsandboxed sandboxing flag set once it exists in the fenced frame spec. This will then determine the intersection between that and the sandboxFlags. (WICG/turtledove#1206)
-
Return true.
4.3. getInterestGroupAdAuctionData()
This first introductory paragraph is non-normative.
When a website or someone working on behalf of the website (e.g. a supply side platform, SSP) wants
to conduct an auction using a trusted auction server to select an advertisement to display to the
user, they can call the navigator
.getInterestGroupAdAuctionData()
function.
This function returns an opaque Uint8Array
as the request and a request ID string. The request
can be sent to a trusted auction server through the JS [FETCH] API, which returns a response.
The response along with the request ID can be then passed as part of an auction configuration to navigator
.runAdAuction()
to extract the results of the auction.
[SecureContext ]partial interface Navigator {Promise <AdAuctionData >getInterestGroupAdAuctionData (optional AdAuctionDataConfig = {}); };
config dictionary {
AdAuctionPerSellerData required USVString ;
seller Uint8Array ;
request DOMString ; };
error dictionary {
AdAuctionData required USVString ;
requestId Uint8Array ;
request sequence <AdAuctionPerSellerData >; };
requests
dictionary {
AdAuctionOneSeller required USVString ;
seller USVString ; };
coordinatorOrigin dictionary {
AdAuctionDataConfig USVString ;
seller USVString ;
coordinatorOrigin sequence <AdAuctionOneSeller >;
sellers unsigned long ;
requestSize record <USVString ,AdAuctionDataBuyerConfig >; };
perBuyerConfig
seller
- The seller that will be used as the
seller
in the followingAuctionAdConfig
passed tonavigator
.runAdAuction()
. Can not be specified with thesellers
field. Exactly one ofseller
andsellers
must be specified. coordinatorOrigin
- The origin of the coordinator hosting public encryption keys for the server
running the ad auction. The scheme must be "
https
". An implementation may select which coordinators are acceptable. Can not be specified with thesellers
field. sellers
- A list of seller origins and, optionally, their corresponding coordinators.
When present, the
AdAuctionData
provided when thePromise
returned bygetInterestGroupAdAuctionData
resolves contains therequests
field instead of therequest
field. Can not be specified with theseller
orcoordinatorOrigin
fields. Exactly one ofseller
andsellers
must be specified. requestSize
- The desired size for the returned
request
. If any buyers are specified inperBuyerConfig
, this will be the exact size of the returnedrequest
. Otherwise the returnedrequest
โs size will be at most therequestSize
. perBuyerConfig
- Keys are serialized origins of
buyers that should be included in the returned request. Values are
AdAuctionDataBuyerConfig
for that buyer.
dictionary {
AdAuctionDataBuyerConfig unsigned long ; };
targetSize
targetSize
- The size of the request to allocate for this buyer. Required when
AdAuctionDataConfig
โsrequestSize
is not specified.
A server auction is an auction executed on a trusted auction server.
A server auction interest group is a struct with the following items:
- name
-
A string that uniquely defines each interest group, as in name.
- bidding signals keys
-
Null or a list of string, as in trusted bidding signals keys
- user bidding signals
-
Null or a string, as in user bidding signals
- ads
-
A list of strings containing the corresponding ad render IDs from the ads field.
- components
-
A list of strings containing the corresponding ad render IDs from the ad components field.
- browser signals
- priority
-
A
double
. Used to select which interest groups for a given buyer are excluded from the serialized request due to space limitations.
A server auction browser signals is a struct with the following items:
- bid count
-
A count of the number of bids for this interest group in the last 30 days. Calculated by summing the bid counts for all days within the last 30 days.
- join count
-
A count of the number of joins for this interest group in the last 30 days. Calculated by summing the join counts.
- recency ms
-
A duration, in milliseconds, representing the current coarsened wall time at the time this object was constructed minus the corresponding interest groupโs join time, in milliseconds.
- previous wins
A server auction previous win is a struct with the following items:
- time delta
-
A duration, in milliseconds, representing the current coarsened wall time at the time this object was constructed minus the corresponding previous winโs time, in seconds.
- ad render ID
-
A string containing the ad render ID for the ad represented by this entry.
A server auction request context is a struct with the following items:
- request ID
-
A unique identifier associated with this and only this invocation of
navigator
.getInterestGroupAdAuctionData()
. This is used to look-up a specific request context. - request context
-
An opaque context used to handle the request, such as that returned from Section 2.2.4 of Bidding and Auction Services
A server auction response is a struct that contains auction result from a server auction. It has the following items:
- nonce
-
version 4 UUID. A nonce to match against the `
Ad-Auction-Result-Nonce
` header in a fetch response from the seller. Used as a method of authorizing the response. - ad render url
-
URL. The leading bidโs ad descriptorโs url from the auction.
- ad components
-
A list of URLs. A list of winning bidโs ad component descriptorsโs urls from the auction.
- interest group name
- interest group owner
- bidding groups
-
A list of tuples consisting of an origin owner and a string name for each interest group that bid in the auction.
- update groups
-
A map. Its keys are tuples consisting of an origin for owner and a string for name. Its values are durations indicating the desired maximum time since the interest group was last updated.
- score
-
Null or
double
. Null if the server auction is not a component auction, otherwise thedesirability
of component auctionโs winning bid. - bid
-
Null or bid with currency. Null when the server auction is not a component auction. For component auctions, contains the winning bidโs modified bid when not null, otherwise the winning bidโs bid.
- top level seller
-
Null or an origin. Null when the server auction is not a component auction. Otherwise the value is the expected top-level seller origin for that auction. This should match the seller for the top-level auction config.
- ad metadata
-
Null or a JSON string. Null when the server auction is not a component auction. Otherwise the value contains the component auctionโs winning bidโs ad.
- buyer reporting id
-
Null or a string. When not null, this will be verified with the winning bidโs adโs buyer reporting ID.
- buyer and seller reporting id
-
Null or a string. When not null, this will be verified with the winning bidโs adโs buyer and seller reporting ID.
- selected buyer and seller reporting id
-
Null or a string, initially null. When not null, this will be verified with the winning bidโs adโs selectable buyer and seller reporting IDs.
- winner join candidate
-
Null or server auction join candidate. When not null, contains the k-anonymity hashes corresponding to the winning bid and indicates which k-anonymity hashes were used for k-anonymity enforcement on the server.
- ghost winner
-
Null or server auction ghost winner. When not null, contains information about the non-k-anonymous winner of a server auction.
- error
-
Null or string. When not null, contains an error message from the auction executed on the trusted auction server. May be used to provide additional context for the result of an auction.
- buyer reporting
- top level seller reporting
-
Null or server auction reporting info.
- component seller reporting
-
Null or server auction reporting info.
- component win private aggregation contributions
-
A map whose keys are server auction private aggregation contribution keys, and whose values are lists of on event contribution entries. Private aggregation contributions from winners of component auctions run on trusted auction servers. These need to be filtered by the client based on the top level auctionโs outcome.
- server filtered private aggregation reserved contributions
-
A map whose keys are server auction private aggregation contribution keys, and whose values are lists of on event contribution entries. Server filtered private aggregation contributions with reserved event types (already set to "reserved.always"), which are not dependent on the final auction result and should always be reported.
- server filtered private aggregation non reserved contributions
-
A map whose keys are server auction private aggregation contribution keys, and whose values are lists of on event contribution entries. Server filtered private aggregation contributions with non reserved event types, which are not dependent on the final auction result and should always be reported.
- component win debugging only reports
-
A map whose keys are server auction debug report keys, and whose values are urls.
- server filtered debugging only reports
-
A map whose keys are origins and whose values are lists of urls.
server auction join candidate is a struct with the following items:
- ad render url hash
-
A SHA-256 hash of the k-anonymity key for the ad in the winning bid, as calculated using compute the key hash of ad.
- ad component render url hashes
-
A list of SHA-256 hashes of k-anonymity keys for each of the ad components in the winning bid, as calculated using compute the key hash of component ad.
- reporting id hash
-
A SHA-256 hash of the k-anonymity key for the reporting ID in the winning bid, as calculated using compute the key hash of reporting ID.
server auction ghost winner is a struct with the following items:
- candidate
-
server auction join candidate associated with this winner.
- interest group owner
-
An origin. The leading non-k-anon-enforced bidโs interest groupโs owner.
- interest group name
-
A string. The leading non-k-anon-enforced bidโs interest groupโs name.
- ghost winner bid info
-
Null or a server auction ghost winner bid info, initially null. Contains information needed for ghost winners in component auctions.
A server auction ghost winner bid info is a struct with the following items:
- ad render url
-
A URL. The leading non-k-anon-enforced bidโs ad descriptorโs url from the auction.
- ad components
-
A list of URLs. A list of the leading non-k-anon-enforced bidโs ad component descriptorsโs urls from the server auction.
- modified bid
-
bid with currency. Contains the leading non-k-anon-enforced bidโs modified bid when not null, otherwise the leading non-k-anon-enforced bidโs bid.
- ad metadata
-
Null or a JSON string, initially null. Contains the component auctionโs leading non-k-anon-enforced bidโs ad.
- buyer reporting id
-
Null or a string, initially null. When not null, this will be verified with the leading non-k-anon-enforced bidโs adโs buyer reporting ID.
- buyer and seller reporting id
-
Null or a string, initially null. When not null, this will be verified with the leading non-k-anon-enforced bidโs adโs buyer and seller reporting ID.
- selected buyer and seller reporting id
-
Null or a string, initially null. When not null, this will be verified with the leading non-k-anon-enforced bidโs adโs selectable buyer and seller reporting IDs.
A server auction reporting info is a struct with the following items:
- reporting url
-
Null or a URL
- beacon urls
-
ordered map whose keys are strings and whose values are URLs whose schemes are "
https
".
a server auction debug report key is a struct with the following items:
a server auction private aggregation contribution key is a struct with the following items:
- reporting origin
-
The origin of the script that contributed the contribution.
- coordinator
-
Null or an aggregation coordinator.
- event
-
A string.
The getInterestGroupAdAuctionData(configIDL)
method steps are:
-
Let global be thisโs relevant global object.
-
If globalโs associated Document is not allowed to use the "run-ad-auction" policy-controlled feature, then throw a "
NotAllowedError
"DOMException
. -
Let settings be thisโs relevant settings object.
-
Let configs be the result of running parse and verify ad auction data config on configIDL and settingsโs top-level origin.
-
Let p be a new promise.
-
Let queue be the result of starting a new parallel queue.
-
Enqueue the following steps to queue:
-
Let igMap be a new map whose keys are origins and values are lists.
-
Let igPAggCoordinatorMap be a new map whose keys are tuples of (origins, strings) and values are origins.
-
Let startTime be a moment equal to the current coarsened wall time.
-
For each ig of the user agentโs interest group set:
-
Let owner be igโs owner.
-
Let name be igโs name.
-
If igMap[owner] does not exist, then set igMap[owner] to a new list.
-
Let ads be a new list.
-
For each ad in igโs ads, append adโs ad render ID to ads.
-
Let components be a new list.
-
For each component in igโs ad components, append componentโs ad render ID to components.
-
Let prevWins be a new
sequence<server auction previous win>
. -
For each prevWin of igโs previous wins for all days within the the last 30 days:
-
Let timeDelta be startTime minus prevWinโs time.
-
Set timeDelta to 0 if timeDelta is negative, timeDeltaโs nearest second (rounding down) otherwise.
-
Let serverPrevWin be a new server auction previous win with the following items:
- time delta
-
timeDelta
- ad render ID
-
the value of the ad render ID field in prevWinโs ad, or the empty string if not present
-
Append serverPrevWin to prevWins.
-
-
Let browserSignals be a new server auction browser signals with the following items:
- bid count
-
the sum of igโs bid counts with a bid day within the last 30 days
- join count
-
the sum of igโs join counts with a join day within the last 30 days
- recency ms
-
the current coarsened wall time minus igโs join time in millseconds
- previous wins
-
prevWins
-
Let serverIg be a new server auction interest group with the following items:
- name
-
name
- bidding signals keys
-
igโs trusted bidding signals keys
- user bidding signals
-
igโs user bidding signals
- ads
-
ads
- components
-
components
- browser signals
-
browserSignals
- priority
-
igโs priority
-
Append serverIg to igMap[owner].
-
If igโs Private Aggregation coordinator is not null, then set igPAggCoordinatorMap[(owner, name)] to it.
-
Let results be a new list of auction data per seller results.
-
Let requestId be the string representation of a version 4 UUID.
-
For each config of configs:
-
Let seller be configโs seller.
-
If configโs coordinator is not one of the implementation-defined Bidding and Auction Services coordinators supported by this user agent:
-
Let keyInfo be the result of looking up the server encryption key with configโs seller and sellerโs coordinator.
-
If keyInfo is failure:
-
Let (key, keyId) be keyInfo.
-
Set configโs encryption key to key.
-
Set configโs encryption key id to keyId.
-
Let (requestBlob, context) be the result of serializing igMap with config and igPAggCoordinatorMap. The serialization method may follow that described in Section 2.2.4 of Bidding and Auction Services.
-
Let result be a new auction data per seller result with the following items:
-
Append result to results.
-
Let requestContext be a new server auction request context.
-
Set requestContextโs request ID field to requestId.
-
Set requestContextโs request context field to context.
-
Set globalโs associated Documentโs node navigableโs traversable navigableโs saved Bidding and Auction request context[(seller,requestId)] to requestContext.
-
-
Let IDLresults be a new
AdAuctionData
. -
-
Let sellerResult be results[0].
-
If sellerResultโs error is not null:
-
Queue a global task on the DOM manipulation task source, given global, to reject p with a
TypeError
. -
Abort these steps.
-
-
Set IDLresults["
request
"] to requestBlob.
-
-
Otherwise:
-
For each sellerResult in results:
-
Let IDLresult be a new
AdAuctionPerSellerData
whoseseller
is the serialization of sellerResultโs seller. -
If sellerResultโs error is not null:
-
Otherwise:
-
-
-
Queue a global task on the DOM manipulation task source, given global, to resolve p with IDLresults.
-
-
Return p.
AdAuctionDataConfig
configIDL and origin top_level_origin:
-
Let configs be a new list of auction data configs.
-
Let perBuyerConfigs be the result of running parse per buyer auction data configs on configIDL["
perBuyerConfig
"]. -
Let requestSize be configIDL["
requestSize
"] if it exists, null otherwise. -
If perBuyerConfigs is not empty and requestSize is null:
-
If configIDL["
seller
"] exists:-
Let seller be the result of running parse an https origin on configIDL["
seller
"]. -
If configIDL["
coordinatorOrigin
"] exists:-
Let coordinator be the result of running parse an https origin on configIDL["
coordinatorOrigin
"].
-
-
Otherwise
-
Let coordinator be the user agentโs default Bidding and Auction Services coordinator.
-
-
If seller or coordinator are failure, then throw a
TypeError
. -
Let config be a new auction data config with the following items:
- publisher
-
top_level_origin
- seller
-
seller
- coordinator
-
coordinator
- request size
-
requestSize
- per buyer config
-
perBuyerConfigs
-
Append config to configs.
-
-
Otherwise:
-
If configIDL["
sellers
"] does not exist, then throw aTypeError
. -
If configIDL["
coordinatorOrigin
"] exists, then throw aTypeError
. -
For each sellerConfig in configIDL["
sellers
"]:-
Let seller be the result of running parse an https origin on sellerConfig["
seller
"]. -
If configs contains an auction data config whose seller is equal to seller, then throw a
TypeError
. -
If sellerConfig["
coordinatorOrigin
"] exists:-
Let coordinator be the result of running parse an https origin on sellerConfig["
coordinatorOrigin
"].
-
-
Otherwise:
-
Let coordinator be the user agentโs default Bidding and Auction Services coordinator.
-
-
If seller or coordinator are failure, then throw a
TypeError
. -
Let config be a new auction data config with the following items:
- publisher
-
top_level_origin
- seller
-
seller
- coordinator
-
coordinator
- request size
-
requestSize
- per buyer config
-
perBuyerConfigs
-
Append config to configs.
-
-
-
Return configs.
AdAuctionDataBuyerConfig
perBuyerConfigIDL:
-
Let configs be a new ordered map whose keys are origins and whose values are auction data configs.
-
For each buyerIDL โ buyerConfigIDL of perBuyerConfigIDL:
-
Let buyerConfig be a new auction data buyer config.
-
Set buyerConfigโs size to buyerConfigIDL["
targetSize
"] if it exists, null otherwise. -
Let buyer be the result of running parse an https origin on buyerIDL.
-
Set configs[buyer] to buyerConfig.
-
-
Return configs.
-
Let keys be a list of (byte sequence, byte) tuples returned from looking up the HPKE public key encryption keys and their corresponding key IDs for origin specified by coordinator. The actual implementation of this lookup is implementation-defined, and may consist of fetching the keys from a known URL.
-
If keys is failure or keys is empty, return failure.
-
Return an element from keys, chosen at random.
5. Reporting
5.1. Common types and algorithms
A reporting bid source is an enum with the following possible values:
generate-bid
-
Bid produced by an invocation of
generateBid()
. additional-bid
-
Bid provided via the additional bids mechanism.
bidding-and-auction-services
-
Bid provided via Bidding and Auction Services mechanism.
A reporting bid key is a struct with the following items:
Note: This struct exists only to uniquely identify places bids came from, avoiding confusion
in cases like bids made by the same interest group in different component auctions, or additional
bids reusing names of regular interest groups. Implementations can likely find a more efficient
way of achieving the same effect. Note that bids returned when generateBid()
returns multiple
items all share a key, as they share reporting information, too.
- context
-
The reporting context corresponding to the component (or single-level) auction the bid originated in.
- source
-
A reporting bid source describing where the bid came from.
- bidder origin
-
The origin of the bidder.
- bid identifier
-
A string distinguishing this source of reports from others of the same origin in the same context.
A reporting context is a struct with the following items:
- debug reporting info
-
A map from reporting bid key to bid debug reporting info.
- private aggregation batching scope map
-
A map from a tuple consisting of an origin (an origin) and a coordinator (an aggregation coordinator) to a batching scope.
Note: Does not include batching scopes for contributions conditional on non-reserved events.
- private aggregation on event contributions
-
A map from a tuple of (reporting bid key, string) to a list of on event contribution entries.
- private aggregation allowed
-
A boolean, initially false.
- local leader info
-
A leading bid info, describing information on what, if anything, won the particular auction this reporting context is for.
- winner reporting id
-
A reporting bid key or null, initially null. This can be null even if local leader info has a leader set, in case this context is for a component auction that lost at top-level.
- bidder participants
-
A set of reporting bid keys, representing interest groups that got a chance to generate bids for the auction. This will be empty in top-level auctions, as the relevant state will be in the component auctions.
- seller participants
-
A set of reporting bid keys, representing various
scoreAd()
executions. Note that some of these may be based on bids that started as additional bids or from component auctions run by Bidding and Auction services, and not interest groups, so this list may be quite different from bidder participants. - participant metrics
-
A map from a pair (origin, worklet function) to per participant metrics.
-
Let key be (origin, workletFunction).
-
If reportingContextโs participant metrics[key] does not exist, set it to a new per participant metrics.
-
Return reportingContextโs participant metrics[key].
A reporting context map is a map from auction config to reporting context.
-
Let reportingContextMap be a new reporting context map.
-
Set reportingContextMap[auctionConfig] to a new reporting context.
-
For each component in auctionConfigโs component auctions, set reportingContextMap[component] to a new reporting context.
-
For each _ โ reportingContext of reportingContextMap:
-
Set reportingContextโs private aggregation allowed to privateAggregationAllowed
-
-
Return reportingContextMap.
-
Let id be a new reporting bid key with the following items:
- context
-
reportingContext
- source
- bidder origin
-
igโs owner
- bid identifier
-
igโs name
-
Set reportingContextโs debug reporting info[id] to bidDebugReportInfo.
-
Let metrics be the result of access per-participant metrics given reportingContext, igโs owner, generate-bid.
-
Merge samples to an averager given metricsโs code fetch time averager and executionMetricsโs code fetch time averager.
-
Set metricsโs script executions attempted to metricsโs participating interest group count.
-
If executionMetricsโs script timed out is true, increment metricsโs script timeouts occurred by 1.
-
Insert id into reportingContextโs bidder participants.
-
Commit private aggregation contributions given paContributions, id and reportingContext.
-
For each generatedBid of generatedBids:
-
Set generatedBidโs reporting id to id.
-
5.2. forDebuggingOnly
This first introductory paragraph is non-normative.
"generateBid()
" and "scoreAd()
" can call forDebuggingOnly
โs reportAdAuctionWin(url)
and reportAdAuctionLoss(url)
methods for event-level forDebuggingOnly reports for winning and losing bids.
Note: While the browser is experimenting with third party cookie deprecation (before they have
been fully removed), the forDebuggingOnly
reporting APIs supply temporary labels indicating when a particular instance would have been
downsampled instead of using the following steps to downsample it.
-
If reportUrl is null, or the result of running is debugging only in cooldown or lockout with invokingOrigin is true, then return.
-
If the result of running sample a debug report with invokingOrigin and fromServer is true, then append reportUrl to debugReportUrls.
-
Let auctionReportInfo be a new auction report info.
-
Let winningBid be winnerInfoโs leading bid if winnerInfo is not null, null otherwise.
-
For each _ โ reportingContext of reportingContextMap:
-
For each reportingId -> bidDebugReportInfo of reportingContextโs debug reporting info:
-
Let fromServer be true if reportingIdโs source is bidding-and-auction-services, false otherwise.
-
If winningBid is not null and reportingId is equal to winningBidโs reporting id:
-
Assert that winningBidโs reporting id is not null.
-
Collect a single forDebuggingOnly report with bidDebugReportInfoโs bidder debug win report url, bidDebugReportInfoโs interest group owner, fromServer, and auctionReportInfoโs debug win report urls.
-
If bidDebugReportInfoโs component seller is null:
-
Collect a single forDebuggingOnly report with bidDebugReportInfoโs seller debug win report url, seller, fromServer, and auctionReportInfoโs debug win report urls.
-
-
Otherwise:
-
Collect a single forDebuggingOnly report with bidDebugReportInfoโs seller debug win report url, bidDebugReportInfoโs component seller, fromServer, and auctionReportInfoโs debug win report urls.
-
Collect a single forDebuggingOnly report with bidDebugReportInfoโs top level seller debug win report url, seller, fromServer, and auctionReportInfoโs debug win report urls.
-
-
-
Otherwise:
-
Collect a single forDebuggingOnly report with bidDebugReportInfoโs bidder debug loss report url, bidDebugReportInfoโs interest group owner, fromServer, and auctionReportInfoโs debug loss report urls.
-
If bidDebugReportInfoโs component seller is null:
-
Collect a single forDebuggingOnly report with bidDebugReportInfoโs seller debug loss report url, seller, fromServer, and auctionReportInfoโs debug loss report urls.
-
-
Otherwise:
-
Collect a single forDebuggingOnly report with bidDebugReportInfoโs seller debug loss report url, bidDebugReportInfoโs component seller, fromServer, auctionReportInfoโs debug loss report urls.
-
Collect a single forDebuggingOnly report with bidDebugReportInfoโs top level seller debug loss report url, seller, fromServer, and auctionReportInfoโs debug loss report urls.
-
-
-
For each invokingOrigin โ debugURLs of bidDebugReportInfoโs server filtered debugging only reports:
-
If debugURLs is empty:
-
If the result of running is debugging only in cooldown or lockout with invokingOrigin is false, then update debug report cooldown with invokingOrigin.
Note: An entry for invokingOrigin is still needed when debugURLs is empty. It could happen when forDebuggingOnly API is called but the bidding and auction server filtered the debug report URL out with the downsampling algorithm. In this case the client still needs to know that forDebuggingOnly API was called and update its cooldown information. This is different from forDebuggingOnly API not being called by one origin, in which case the list wonโt have an entry for that origin.
-
-
For each url of debugURLs:
-
Collect a single forDebuggingOnly report with url, invokingOrigin, fromServer (true), and auctionReportInfoโs debug loss report urls.
Note: For server filtered ones, post auction signals were filled on the server side, so itโs fine to collect them all to debug loss report urls without the need of getting post auction signals for debug win urls.
-
-
-
-
-
Return auctionReportInfo.
5.2.1. Downsampling
This first introductory paragraph is non-normative.
Implementations may define their own values for the below constants based on their privacy goal, however we supply the below values as a starting point, inspired by what the initial implementation of this specification uses:
-
sampling rate is 1/1000, which means only sending reports with a 1/1000 chance.
-
lockout period is 3 years.
-
long cooldown rate is 1/10, which means 10% of the time putting an adtech in a long cooldown period if the adtech calls the API.
-
long cooldown period is 1 year.
-
short cooldown period is 2 weeks.
Note: More details of how these numbers are determined can be found in comments here: (WICG/turtledove#632).
The design of downsampling forDebuggingOnly reports has three main goals:
-
Prevent sending debug reports very often to protect user privacy:
-
Only sending debug reports with a sampling rate chance;
-
if a report is sent, "lock-out" all adtechs out of sending a report for lockout period;
-
if an adtech calls the API, put them in a "cool-down" period where calls to the API by that given adtech are not able to send reports.
-
-
Prevent one adtech from substantially compromising a different adtechโs access to debugging information. The "cool-down" period means that any particular adtech can only cause a very small fraction of people to send debug reports and be removed from the potential debugging pool.
-
Prevent adtechs who accidentally (e.g. due to a bug in their code) call the API repeatedly for all users, from locking themselves out of sending any more reports for years. This is accomplished by only long cooldown rate of the time putting that adtech in a long cooldown period, and rest of the time putting that adtech in a short cooldown period.
The user agent has a debug report lockout until, which is null or a moment, and a debug report cooldown, which is null or a map whose keys are origins and values are moments at which the cool down for the origin key expires.
-
If user agentโs debug report lockout until is not null, and current coarsened wall time is less than user agentโs debug report lockout until, return true.
-
If user agentโs debug report cooldown is null, then return false.
-
If user agentโs debug report cooldown[origin] exists and current coarsened wall time is less than user agentโs debug report cooldown[origin], then return true.
-
Return false.
Note: forDebuggingOnly reports from server auction response were downsampled on trusted auction servers, so do not downsample them again on client.
-
Let canSendAfterSampled be false.
-
Let sampleRand be a random
long
, 0 โค sampleRand < 1000, so each possible long would be chosen with a probability equal to sampling rate. -
If fromServer is true or sampleRand is 0:
-
Set canSendAfterSampled to true.
-
Set user agentโs debug report lockout until to current coarsened wall time plus lockout period.
-
-
Update debug report cooldown with origin.
-
Return canSendAfterSampled.
-
Let cooldownRand be a random
long
โฅ 0 and < 10, which corresponds to long cooldown rate. -
Let cooldownPeriod be long cooldown period if cooldownRand is 0, short cooldown period otherwise.
-
Set user agentโs debug report cooldown[origin] to current coarsened wall time plus cooldownPeriod.
5.3. realTimeReporting
This first introductory paragraph is non-normative.
The goal of real-time reporting is to get auction monitoring data to the buyer and seller as quickly
as possible (e.g. < 5 mins). The primary use-case is rapid error detection i.e. detecting quickly
whether there are major problems with unexpected behavior in generateBid()
, scoreAd()
, or
fetching of bidding or scoring scripts or trusted signals.
Initial implementation of this specification defines
-
number of user buckets is 1024, which means buckets 0 to 1023 are supported by
realTimeReporting
API. -
number of platform buckets is 4, which are buckets for errors that are not visible in either
scoreAd()
orgenerateBid()
.
Each real time report is a CBOR message using the following data structure:
{ "version" : 1 , "histogram" : { "buckets" : [ 5 , 32 , 0 , 1 , ..., 129 ], // 128 elements. "length" : 1024 // 1024 buckets before bit packing. }, "platformHistogram" : { "buckets" : [ 192 ], "length" : 4 // 4 buckets before bit packing. } }
-
If contributions is empty, then return null.
-
Let priorityWeightSum be 0.
-
For each contribution of contributions:
-
Increment priorityWeightSum by contributionโs priority weight.
-
-
Let sampleRand be a random
double
, 0 โค sampleRand < 1. -
Set sampleRand to sampleRand multiplied by priorityWeightSum.
-
Set priorityWeightSum to 0.
-
Let selectedBucket be -1.
-
For each contribution of contributions:
-
Increment priorityWeightSum by contributionโs priority weight.
-
If priorityWeightSum โฅ sampleRand, then set selectedBucket to contributionโs bucket, and break;
-
-
Assert selectedBucket is not -1.
-
Return selectedBucket.
-
Let inputSize be inputโs size.
-
Let currentByte be 0.
-
Let numBits be 0.
-
For each i in the range from 0 to inputSize, exclusive:
-
Set currentByte to currentByte * 2 + input[i].
-
Increment numBits by 1.
-
If numBits is 8, then:
-
Append currentByte to packed.
-
Set currentByte to 0 and numBits to 0.
-
-
Otherwise if i is inputSize - 1, then:
-
-
Return packed.
-
Let totalBuckets be the sum of number of user buckets and number of platform buckets.
-
Let userHistogram and platformHistogram be new lists of booleans.
-
Let body be a new ordered map of the following entries:
- "version"
-
1
- "histogram"
-
a new ordered map of the following entries:
- "buckets"
-
the result of bit packing with userHistogram
- "length"
- "platformHistogram"
-
a new ordered map of the following entries:
- "buckets"
-
the result of bit packing with platformHistogram
- "length"
-
Let request be a new request with the following properties:
- URL
-
url
- header list
-
ยซ
Content-Type
:application/cbor
ยป - method
-
POST
- body
-
the byte sequence resulting from CBOR encoding body
- client
-
null
- origin
-
settingsโs origin
- mode
-
"
no-cors
" - referrer
-
"
no-referrer
" - credentials mode
-
"
omit
" - redirect mode
-
"
error
" - service-workers mode
-
"
none
" - policy container
-
A new policy container whose IP address space is settingsโs policy containerโs IP address space
Stop using "
no-cors
" mode where possible (WICG/turtledove#667). -
Fetch request with useParallelQueue set to true.
-
For each origin โ contributions of contributionsMap:
-
Let maybeBucket be the result of sampling real time contributions with contributions.
-
Let histogram be the result of applying RAPPOR noise with maybeBucket.
-
Send a real time report with reportUrl, histogram and settings.
TODO: Spec rate limiting. (WICG/turtledove#1215)
-
5.3.1. Platform contribution
This first introductory paragraph is non-normative.
There are some errors not visible in either scoreAd()
or generateBid()
, like failures to fetch
the bidding or scoring script, trusted bidding or scoring signals. Certain buckets are used for
these errors.
The initial implementation supports four platform contribution buckets starting from number of user buckets:
-
bidding script failure bucket: number of user buckets
-
scoring script failure bucket: number of user buckets plus 1
-
trusted bidding signals failure bucket: number of user buckets plus 2
-
trusted scoring signals failure bucket: number of user buckets plus 3
Platform contributions have a hardcoded platform contribution priority weight. The initial implementation uses a value of 1.
long
bucket, a real time reporting contributions map realTimeContributionsMap, and an origin origin:
-
Assert bucket is one of platform contribution buckets.
-
Let contribution be a new real time reporting contribution with the following items:
-
Insert entries to map given realTimeContributionsMap, origin, and ยซ contribution ยป .
5.3.2. Apply noise (RAPPOR)
This first introductory paragraph is non-normative.
Basic RAPPOR noises each coordinate of the bit vector independently, and it is parameterized by epsilon, a measure of privacy loss. The initial implementation uses an epsilon value of 1, yielding a flipping probability of ~0.378.
-
Let totalBuckets be the sum of number of user buckets and number of platform buckets.
-
Let histogram be a new list of booleans, whose size is totalBuckets.
-
If maybeBucket is not null:
-
Assert 0 โค maybeBucket < totalBuckets.
-
Set histogram[maybeBucket] to true.
-
-
Let f be
2.0/(1+eepsilon/2.0)
. -
For each i in the range from 0 to totalBuckets, exclusive:
-
Let rand be a random
double
, 0 โค rand < 1 -
If rand < f / 2.0, then:
-
Let flipped be false if histogram[i] is true, otherwise true.
-
Set histogram[i] to flipped.
-
-
-
Return histogram.
5.4. privateAggregation
This first introductory paragraph is non-normative.
For metrics that can be interpreted as histograms aggregated over the entire population, Protected
Audience provides integration with the Private Aggregation API.
In addition to its contributeToHistogram(contribution)
method, the API is
extended with contributeToHistogramOnEvent(event, contribution) which permits histogram contributions to be conditional and to incorporate values not accessible to
the running script, like values of auction winning bids and various performance metrics.
5.4.1. Signal base value
A signal base value is one of the following:- "
winning-bid
" -
The numeric value is the bid value of the winning bid.
- "
highest-scoring-other-bid
" -
The numeric value is the bid value of the highest scoring bid that did not win.
- "
script-run-time
" -
The numeric value is the number of milliseconds of CPU time the calling function (e.g.
generateBid()
) took to run. - "
signals-fetch-time
" -
The numeric value is the number of milliseconds it took for the trusted bidding or scoring signals fetch to complete, when called from
generateBid()
orscoreAd()
, respectively. In other functions it evaluates to 0. - "
bid-reject-reason
" -
The numeric value is an integer representing the reason a bid was rejected.
Note: this mapping to an integer is defined in determine a signalโs numeric value.
- "
average-code-fetch-time
" -
The numeric value is the average time it took to fetch code resources (JavaScript or WebAssembly) for this particular worklet function, for this participant.
- "
participating-ig-count
" -
The numeric value is the number of interest groups for the buyer actually participating in the auction, after considering prioritization and capabilities. Interest groups included in this might not actually get to bid if the cumulative timeout expires, or the script fails to load, etc; or might decide not to bid, but they would have gotten a chance if nothing went wrong.
- "
percent-scripts-timeout
" -
The numeric value is percentage of executions of this script that hit their individual timeout, out of all executions that were expected to happen.
- "
regular-igs-count
" -
Number of regular interest groups for the given buyer. (0 if this is used by a seller).
- "
percent-regular-ig-count-quota-used
" -
Ratio of number of regular interest groups for the given buyer and Max regular interest groups per owner expressed as a percentage, capped to 110.
- "
negative-igs-count
" -
Number of negative interest groups for the given buyer. (0 if this is used by a seller).
- "
percent-negative-ig-count-quota-used
" -
Ratio of number of negative interest groups for the given buyer and Max negative interest groups per owner expressed as a percentage, capped to 110.
- "
ig-storage-used
" -
Bytes of storage used by the given buyer. (0 if this is used by a seller).
- "
percent-ig-storage-quota-used
" -
Percentage of max interest groups total size per owner used by the given buyer, capped to 110.
- "
cumulative-buyer-time
" -
Time spent by the buyer from their cumulative buyer timeout limit; if the limit has been exceeded returns the limit + 1000; if this is used by a seller, or no cumulative buyer timeout is configured, returns 0.
- "
percent-igs-cumulative-timeout
" -
Percentage of participating interest groups that did not get a chance to actually bid in the auction due to a cumulative buyer timeout occurring.
5.4.2. On event contribution entry
An on event contribution entry is a struct with the following items:- contribution
- batching scope
-
A batching scope or null
- debug scope
- debug details
-
A debug details or null (default null)
- worklet function
- origin
-
The origin of the script that contributed the entry.
5.4.3. Worklet function
A worklet function is one of the following:- "
generate-bid
" -
The
generateBid()
function. - "
score-ad
" -
The
scoreAd()
function. - "
report-result
" -
The
reportResult()
function. - "
report-win
" -
The
reportWin()
function, orreportAdditionalBidWin()
for additional bids.
1.Switch on fn:
- generate-bid
-
Return generate-bid.
- score-ad
-
Return score-ad.
- report-result
-
Return score-ad.
- report-win
-
Return generate-bid.
5.4.4. Averager
An averager is a a struct with the following items:5.4.5. Metrics structures
An execution metrics is a struct with the following items, representing metrics collected from a single execution of a worklet function:- code fetch time averager
-
An averager.
- script timed out
-
A boolean, initially false. This refers to the script hitting its own time out, and does not include the cumulative timeout affecting buyers.
A per participant metrics is a struct with the following items, representing metrics aggregated over a particular participant (e.g. bidder or seller). It has:
- participating interest group count
-
A
long
, initially 0. See "participating-ig-count
". - code fetch time averager
-
An averager. Used to compute "
average-code-fetch-time
". - script timeouts occurred
-
A
long
, initially 0. Used to compute "percent-scripts-timeout
". - cumulative timeouts occurred
-
A
long
, initially 0. Number of interest groups affected by the cumulative timeout happening. Used to compute "percent-igs-cumulative-timeout
". - cumulative buyer time
-
A duration in milliseconds, initially 0. See "
cumulative-buyer-time
". - script executions attempted
-
A
long
, initially 0. The denominator for computation of some percentage metrics, such as "percent-scripts-timeout
" and "percent-igs-cumulative-timeout
". - regular interest group count
-
A
long
, initially 0. See "regular-igs-count
" and "percent-regular-ig-count-quota-used
". - negative interest group count
-
A
long
, initially 0. See "negative-igs-count
" and "percent-negative-ig-count-quota-used
". - storage quota used
-
A
long
, initially 0. See "ig-storage-used
" and "percent-ig-storage-quota-used
".
5.4.6. Private Aggregation contributions
Private Aggregation contributions is a map from string to a list of on event contribution entries.5.4.7. Algorithms
InterestGroupScriptRunnerGlobalScope
global, a worklet function workletFunction,
a reporting context reportingContext, and origins origin and aggregationCoordinator:
-
Let debugScope be a new debug scope.
-
Set globalโs worklet function to workletFunction.
-
Set globalโs origin to origin.
-
Set globalโs private aggregation to a new PrivateAggregation with the following items:
- allowed to use
-
reportingContextโs private aggregation allowed.
- scoping details
-
a new scoping details with the items:
- get batching scope steps
-
An algorithm that performs the following steps:
-
If aggregationCoordinator is null, set aggregationCoordinator to the default aggregation coordinator.
-
Return the result of running get or create a batching scope given origin, aggregationCoordinator and reportingContext.
-
- get debug scope steps
-
An algorithm that returns debugScope.
- should perform default contributeToHistogramOnEvent() processing
-
The algorithm determine whether to perform default contributeToHistogramOnEvent() processing.
InterestGroupScriptRunnerGlobalScope
global:
-
Let debugScope be the result of running globalโs
privateAggregation
โs scoping detailsโs get debug scope steps. -
Let debugDetails be the result of get a debug details given debugScope.
-
Let onEventContributionMap be globalโs on event contribution map.
-
For each event โ entries of onEventContributionMap:
-
For each onEventEntry of entries:
-
If onEventEntryโs debug scope is debugScope, set onEventEntryโs debug details to debugDetails.
-
-
-
Mark a debug scope complete given debugScope.
InterestGroupScriptRunnerGlobalScope
global:
-
Return globalโs on event contribution map.
TODO: regular histograms need to work the same way, too, so they get discarded for k-anon runs; this method exists as an abstraction to help add that.
-
For each event โ contributions of onEventMap:
-
Let key be (bidKey, event).
-
If reportingContextโs private aggregation on event contributions[key] does not exist, set it to a new list.
-
Extend reportingContextโs private aggregation on event contributions[key] with contributions.
-
-
Let batchingScopeMap be reportingContextโs private aggregation batching scope map.
-
Let tuple be (origin, aggregationCoordinator).
-
If batchingScopeMap[tuple] does not exist:
-
Set batchingScopeMap[tuple] to a new batching scope.
-
If aggregationCoordinator is not null, set the aggregation coordinator for a batching scope given aggregationCoordinator and batchingScopeMap[tuple].
-
-
Return batchingScopeMap[tuple].
PrivateAggregation
this, a DOMString
event and a map (with DOMString
keys) contribution, perform the following steps. They return a boolean (only false) or an exception.
-
Let global be thisโs relevant global object.
-
Let function be globalโs worklet function.
-
Let origin be globalโs origin.
-
If thisโs allowed to use is false, return a
TypeError
. -
Set contribution to the result of converting contributionโs JavaScript value to the IDL type
PAExtendedHistogramContribution
, catching any exception that is thrown. If an exception is caught, return it.Note: This returns a
TypeError
if contribution is not compatible. -
Let scopingDetails be thisโs scoping details
-
If event starts with "
reserved.
" and ยซ "reserved.always
", "reserved.loss
", "reserved.win
", "reserved.once
" ยป does not contain event, return false.Note: No error is thrown to allow forward compatibility if additional reserved event types are added later.
-
If event is "
reserved.once
" and function is report-result or report-win, return aTypeError
. -
Let bucket be contribution["
bucket
"]. -
If bucket is a
PASignalValue
: -
Otherwise, if contribution["
bucket
"] is not contained in the range 0 to 2128, exclusive, return aTypeError
.Make the error type consistent with
contributeToHistogram(contribution)
. -
Let value be contribution["
value
"]. -
If value is a
PASignalValue
: -
Otherwise, if contribution["
value
"] is negative, return aTypeError
. -
If contribution["
filteringId
"] is not contained in the range 0 to 256default filtering ID max bytes, exclusive, return aTypeError
.Make the error types on validation issues here and above consistent with
contributeToHistogram(contribution)
.Note: It is not currently possible to set a non-default filtering ID max bytes for Protected Audience.
-
If event does not start with "
reserved.
", and function is score-ad or report-result, return false. -
Let batchingScope be null.
-
If event starts with "
reserved.
", set batchingScope to the result of running scopingDetailsโ get batching scope steps.Note: Each non-reserved event will have a different batching scope that is created later.
-
Let entry be a new on event contribution entry with the items:
- contribution
-
contribution
- batching scope
-
batchingScope
- debug scope
-
The result of running scopingDetailsโ get debug scope steps.
- worklet function
-
function
- origin
-
origin
-
Let onEventContributionMap be globalโs on event contribution map.
-
If onEventContributionMap[event] does not exist, set onEventContributionMap[event] to a new list.
-
Append entry to onEventContributionMap[event].
-
Return false.
Note: This algorithm never returns true as the default processing is never used.
-
Process the Private Aggregation contributions for an auction given auctionConfig, reportingContextMap[auctionConfig].
-
For each componentAuction in auctionConfigโs component auctions:
-
Process the Private Aggregation contributions for an auction given componentAuction, reportingContextMap[componentAuction].
-
-
If auctionConfigโs aborted is true, return.
-
Let winnerId be reportingContextโs winner reporting id
-
Let leadingBidInfo be reportingContextโs local leader info.
-
Let bidderOnceRep be null.
-
If reportingContextโs bidder participants is not empty, set bidderOnceRep to a random item of bidder participants.
-
Let sellerOnceRep be null.
-
If reportingContextโs seller participants is not empty, set sellerOnceRep to a random item of seller participants.
-
For each (bidId, event) โ contributions of reportingContextโs private aggregation on event contributions:
-
For each onEventEntry of contributions:
-
Continue if any of the following conditions hold:
-
event is "
reserved.win
" and bidId is not winnerId; -
event does not start with "
reserved.
" and bidId is not winnerId; -
event is "
reserved.loss
" and bidId is winnerId.
-
-
If event is "
reserved.once
":-
If onEventEntryโs worklet function is generate-bid:
-
If bidId โ bidderOnceRep, continue.
-
-
Otherwise:
-
If bidId โ sellerOnceRep, continue.
-
-
-
Let filledInContribution be the result of filling in the contribution given reportingContext, onEventEntry and leadingBidInfo.
Once WICG/turtledove#627 is resolved, align 'filling in' logic with
forDebuggingOnly
. -
If event does not start with "
reserved.
":-
Store event, filledInContribution, onEventEntryโs debug details in the
FencedFrameConfig
as appropriate.
Note: Each non-reserved event will have a different batching scope.
Once WICG/turtledove#616 and any successors are landed, align integration and fill in fenced frameโs report a private aggregation event.
-
-
Otherwise:
-
Let entry be a new contribution cache entry with the items:
- contribution
-
filledInContribution
- batching scope
-
onEventEntryโs batching scope
- debug scope
-
onEventEntryโs debug scope
- debug details
-
onEventEntryโs debug details
-
Append entry to the contribution cache.
-
-
-
-
Let sellerBatchingScope be the result of getting or creating a batching scope given auctionConfigโs seller, auctionConfigโs seller Private Aggregation coordinator, and reportingContext.
-
Let auctionReportBuyersDebugScope be a new debug scope.
-
For each reportType โ reportBuyerConfig of auctionConfigโs auction report buyers:
-
For each buyerOrigin โ buyerOffset of auctionConfigโs auction report buyer keys:
-
Let bucket be the sum of buyerOffset and reportBuyerConfigโs
bucket
.Handle overflow here or in validation. See WICG/turtledove#1040.
-
Let value be the result (a
double
) of switching on reportType:- "
interestGroupCount
" -
The number of interest groups in the user agentโs interest group set whose owner is buyerOrigin.
- "
bidCount
" -
The number of valid bids generated by interest groups whose owner is buyerOrigin.
- "
totalGenerateBidLatency
" -
The sum of execution time in milliseconds for all
generateBid()
calls in the auction for interest groups whose owner is buyerOrigin. - "
totalSignalsFetchLatency
" -
The total time spent fetching trusted buyer signals in milliseconds, or 0 if the interest group didnโt fetch any trusted signals.
- None of the above values
-
Assert: false, as this enum value is validated in validate and convert auction ad config
- "
-
Set value to the result of multiplying reportBuyerConfigโs
scale
with value. -
Set value to the maximum of 0.0 and value.
-
Set value to the result of converting value to an integer by truncating its fractional part.
-
Set value to the minimum of value and 231โ1.
-
Let contribution be a new
PAHistogramContribution
with the items:bucket
-
bucket
value
-
value
filteringId
-
0
-
For each ig of the user agentโs interest group set whose owner is buyerOrigin:
-
If seller capabilities of ig donโt allow this reporting, continue.
Align behavior with seller capabilities handling once WICG/turtledove#966 is resolved.
-
Let entry be a new contribution cache entry with the items:
- contribution
-
contribution
- batching scope
-
sellerBatchingScope
- debug scope
-
auctionReportBuyersDebugScope
-
Append entry to the contribution cache.
-
-
-
-
Mark a debug scope complete given auctionReportBuyersDebugScope and auctionConfigโs auction report buyer debug details.
-
For each (origin, aggregationCoordinator) โ batchingScope of reportingContextโs private aggregation batching scope map:
-
Process contributions for a batching scope given batchingScope, origin, "
protected-audience
" and null.
-
PAHistogramContribution
:
-
Let contribution be onEventEntryโs contribution.
-
Let bucket be contribution["
bucket
"]. -
If bucket is a
PASignalValue
, set bucket to the result of filling in the signal value given reportingContext, onEventEntry, bucket, 2128โ1 and leadingBidInfo. -
Let value be contribution["
value
"]. -
If value is a
PASignalValue
, set value to the result of filling in the signal value given reportingContext, onEventEntry, value, 231โ1 and leadingBidInfo. -
Let filledInContribution be a new
PAHistogramContribution
with the items:bucket
-
bucket
value
-
value
filteringId
-
contribution["
filteringId
"]
-
Return filledInContribution.
PASignalValue
value, an
integer maxAllowed and a leading bid info leadingBidInfo, perform the following steps.
They return an integer.
-
Assert: value["
baseValue
"] is a valid signal base value. -
Let returnValue be the result of determining a signalโs numeric value given reportingContext, onEventEntry, value["
baseValue
"] and leadingBidInfo. -
If value["
scale
"] exists, set returnValue to the result of multiplying value["scale
"] with returnValue. -
Set returnValue to the result of converting returnValue to an integer by truncating its fractional part.
-
If value["
offset
"] exists, set returnValue to the result of adding returnValue to value["offset
"]. -
Clamp returnValue to the range 0 to maxAllowed, inclusive, and return the result.
double
.
-
Let metrics be the result of access per-participant metrics given reportingContext, onEventEntryโs origin, worklet function.
-
Let bidAndScoreMetrics be the result of access per-participant metrics given reportingContext, onEventEntryโs origin, and the result of find corresponding bid and score phase function given worklet function.
-
If signalBaseValue is:
- "
winning-bid
" -
-
If leadingBidInfoโs leading bid is null, return 0.
-
Otherwise, return leadingBidInfoโs leading bidโs bid.
-
- "
highest-scoring-other-bid
": -
-
If leadingBidInfoโs highest scoring other bid is null, return 0.
-
Otherwise, return leadingBidInfoโs highest scoring other bidโs bid.
-
- "
script-run-time
" -
Return the number of milliseconds of CPU time that the calling function (e.g.
generateBid()
) took to run. - "
signals-fetch-time
" -
Switch on the associated worklet function:
generate-bid
-
Return the number of milliseconds it took for the trusted bidding signals fetch to complete, or 0 if no fetch was made.
score-ad
-
Return the number of milliseconds it took for the trusted scoring signals fetch to complete or 0 if no fetch was made.
report-result
report-win
-
Return 0.
- "
bid-reject-reason
" -
-
If the bid did not succeed purely because it didnโt meet the required k-anonymity threshold, return 8.
-
Let bidRejectReason be "
not-available
". -
If the seller provided a reject reason, set bidRejectReason to that value.
-
If bidRejectReason is:
- "
not-available
" -
Return 0.
- "
invalid-bid
" -
Return 1.
- "
bid-below-auction-floor
" -
Return 2.
- "
pending-approval-by-exchange
" -
Return 3.
- "
disapproved-by-exchange
" -
Return 4.
- "
blocked-by-publisher
" -
Return 5.
- "
language-exclusions
" -
Return 6.
- "
category-exclusions
" -
Return 7.
- None of the above values
-
Assert: false
Note: this enum value is validated in
scoreAd()
.Verify this once WICG/turtledove#627 is resolved.
There are some automatically generated values that are not described here.
- "
-
- "
average-code-fetch-time
" -
Return the result of getting the value to report from an averager given metricsโs code fetch time averager.
- "
participating-ig-count
" -
Return bidAndScoreMetricsโs participating interest group count.
- "
percent-scripts-timeout
" -
Return the result of computing a percentage metric given metricsโs script timeouts occurred and metricsโs script executions attempted.
- "
regular-igs-count
" -
Return bidAndScoreMetricsโs regular interest group count.
- "
percent-regular-ig-count-quota-used
" -
Return the result of computing a percentage metric given bidAndScoreMetricsโs regular interest group count and max regular interest groups per owner.
- "
negative-igs-count
" -
Return bidAndScoreMetricsโs negative interest group count.
- "
percent-negative-ig-count-quota-used
" -
Return the result of computing a percentage metric given bidAndScoreMetricsโs negative interest group count and max negative interest groups per owner.
- "
ig-storage-used
" -
Return bidAndScoreMetricsโs storage quota used.
- "
percent-ig-storage-quota-used
" -
Return the result of computing a percentage metric given bidAndScoreMetricsโs storage quota used and max interest groups total size per owner.
- "
cumulative-buyer-time
" -
Return bidAndScoreMetricsโs cumulative buyer time.
- "
percent-igs-cumulative-timeout
" -
Return the result of computing a percentage metric given bidAndScoreMetricsโs cumulative timeouts occurred and bidAndScoreMetricsโs script executions attempted.
- "
long
s numerator and denominator:
-
If denominator is 0, return 0.
-
Let result be 100.0 * numerator / denominator, performing the computation with
double
s. -
If result > 110.0, set result to 110.0
Note: Since Interest Group Storage Maintenance happens periodically, metrics measuring storage utilization may report values that exceed 100%. The 110% cap exists to make it easier to allocate histogram bucket space for those metrics, by providing a predictable upper bound.
-
Return result.
-
For each ig of igs:
-
If additional bid key is null, increment metricsโs regular interest group count by 1.
-
Otherwise, increment metricsโs negative interest group count by 1.
-
Increment metricsโs storage quota used by igโs estimated size
-
-
If trackerโs limit is null, return.
-
If tracker is expired, set metricsโs cumulative buyer time to trackerโs limit + 1000ms.
-
Otherwise, set metricsโs cumulative buyer time to trackerโs limit - trackerโs remaining.
5.5. Get storage interest groups for owner
This first introductory paragraph is non-normative.
The get storage interest groups for owner algorithm returns a Web IDL array of interest groups. This allows a Protected Audience buyer within a shared storage worklet to gain insights into their users and to send Private Aggregation reports.
dictionary :
StorageInterestGroup AuctionAdInterestGroup {unsigned long long ;
joinCount unsigned long long ;
bidCount sequence <PreviousWin >;
prevWinsMs USVString ;
joiningOrigin long long ;
timeSinceGroupJoinedMs long long ;
lifetimeRemainingMs long long ;
timeSinceLastUpdateMs long long ;
timeUntilNextUpdateMs unsigned long long ; };
estimatedSize
-
Let resultIgs be an empty list.
-
Let now be a moment equal to the current coarsened wall time.
-
For each ig of user agentโs interest group set:
-
Let resultIg be an empty
StorageInterestGroup
dictionary. -
Set resultIg["
owner
"] to the serialization of igโs owner. -
Set resultIg["
enableBiddingSignalsPrioritization
"] to igโs enable bidding signals prioritization. -
If igโs priority vector is not null:
-
Set resultIg["
priorityVector
"] to igโs priority vector.
-
-
If igโs seller capabilities is not null:
-
Let resultSellerCapabilities be an ordered map.
-
For each origin โ originSellerCapabilities of igโs seller capabilities:
-
Let serializedOrigin be the serialization of origin.
-
Set resultSellerCapabilities[serializedOrigin] to originSellerCapabilities.
-
-
Set resultIg["
sellerCapabilities
"] to resultSellerCapabilities.
-
-
Set resultIg["
executionMode
"] to igโs execution mode. -
Set resultIg["
biddingLogicURL
"] to the serialization of igโs bidding url. -
Set resultIg["
biddingWasmHelperURL
"] to the serialization of igโs bidding wasm helper url. -
Set resultIg["
updateURL
"] to the serialization of igโs update url. -
Set resultIg["
trustedBiddingSignalsURL
"] to the serialization of igโs trusted bidding signals url. -
If igโs trusted bidding signals keys is not null:
-
Set resultIg["
trustedBiddingSignalsKeys
"] to igโs trusted bidding signals keys.
-
-
Set resultIg["
trustedBiddingSignalsSlotSizeMode
"] to igโs trusted bidding signals slot size mode. -
Set resultIg["
maxTrustedBiddingSignalsURLLength
"] to igโs max trusted bidding signals url length. -
If igโs user bidding signals is not null:
-
Let parsedUserBiddingSignals be igโs user bidding signals parsed to a JavaScript value.
-
If an exception was thrown, then return failure.
-
Set resultIg["
userBiddingSignals
"] to parsedUserBiddingSignals.
-
-
If igโs ads is not null:
-
Set resultIg["
ads
"] to igโs ads converted to an AuctionAd sequence. -
If an exception was thrown, then return failure.
-
-
If igโs ad components is not null:
-
Set resultIg["
adComponents
"] to igโs ad components converted to an AuctionAd sequence. -
If an exception was thrown, then return failure.
-
-
If igโs ad sizes is not null:
-
Let resultAdSizes be an ordered map.
-
For each sizeName โ adSize of igโs ad sizes:
-
Set resultAdSizes[sizeName] to adSize converted to a map.
-
-
-
If igโs size groups is not null:
-
Set resultIg["
sizeGroups
"] to igโs size groups.
-
-
If igโs priority signals overrides is not null:
-
Set resultIg["
prioritySignalsOverrides
"] to igโs priority signals overrides.
-
-
If igโs additional bid key is not null:
-
Let encoded be the result of running forgiving-base64 encode with igโs additional bid key.
-
If encoded is failure, then return failure.
-
Set resultIg["
additionalBidKey
"] to the result of running forgiving-base64 encode with igโs additional bid key.
-
-
Set resultIg["
joinCount
"] to the sum of igโs join counts for all days within the last 30 days. -
Set resultIg["
bidCount
"] to the sum of igโs bid counts for all days within the last 30 days. -
Let resultPrevWins be a new
sequence<
.PreviousWin
> -
For each prevWin of igโs previous wins for all days within the the last 30 days:
-
Let timeDelta be (now โ prevWinโs time) in millseconds.
-
Set timeDelta to 0 if timeDelta is negative, timeDeltaโs nearest second (rounding down) otherwise.
-
Let metadata be prevWinโs metadata parsed to a JavaScript value.
-
If an exception was thrown, then return failure.
-
Let prevWinAdIDL be a new
AuctionAd
with the following items:renderURL
-
the serialization of prevWinโs render url
metadata
-
metadata.
adRenderId
-
prevWinโs ad render ID
-
Let prevWinElement be the
sequence<
ยซtimeDelta, prevWinAdIDLยป.PreviousWinElement
> -
Append prevWinElement to resultPrevWins.
-
-
Set resultIg["
prevWinsMs
"] to resultPrevWins. -
Set resultIg["
joiningOrigin
"] to the serialization of igโs joining origin. -
Set resultIg["
timeSinceGroupJoinedMs
"] to (now โ igโs join time) in millseconds. -
Set resultIg["
lifetimeRemainingMs
"] to (igโs expiry โ now) in millseconds. -
Set resultIg["
timeSinceLastUpdateMs
"] to (now โ igโs last updated) in millseconds. -
Set resultIg["
timeUntilNextUpdateMs
"] to (igโs next update after โ now) in millseconds. -
Set resultIg["
estimatedSize
"] to igโs estimated size. -
Append resultIg to resultIgs.
-
Return resultIgs.
6. Additional Bids and Negative Targeting
6.1. createAuctionNonce()
This first introductory paragraph is non-normative.
navigator
.createAuctionNonce()
creates an auction nonce, which
is a one-time canonical string representation of a version 4 UUID that is uniquely
associated with a single call to navigator
.runAdAuction()
. For multi-seller
auctions, a distinct auction nonce can be uniquely associated with each of the componentAuctions
. The auction nonce(s) will need to be passed back in via a
subsequent call to navigator
.runAdAuction()
via the AuctionAdConfig
.
This is currently only needed for auctions that use additional bids, in which the auction
nonce is combined with a seller nonce to construct a bid
nonce that must be included in each additional bid. For backwards compatibility, additional bids may include an auction nonce directly in place of a bid nonce.
[SecureContext ]partial interface Navigator {Promise <DOMString >createAuctionNonce (); };
createAuctionNonce()
method steps are:
-
Let p be a new promise.
-
Run the following steps in parallel:
-
Let nonce be the string representation of a version 4 UUID.
Because weโre going in parallel:-
There is no guarantee that the promise will be resolved before other tasks get queued on the main thread;
-
...which gives browsers the freedom to generate this UUID in another process, and asynchronously send it back to the main thread at an arbitrary future time.
-
Queue a global task on DOM manipulation task source, given thisโs relevant global object, to resolve p with nonce.
-
-
Return p.
6.2. Additional Bids
This first introductory paragraph is non-normative.
In addition to bids generated by interest groups, sellers can enable buyers to introduce bids generated outside of the auction, which are called additional bids. Additional bids are commonly triggered using contextual signals. Buyers compute the additional bids, likely as part of a contextual auction. Buyers need to package up each additional bid using a new data structure that encapsulates all of the information needed for the additional bid to compete against other bids in a Protected Audience auction.
Each additional bid is expressed using the following JSON data structure:
const additionalBid= { "bid" : { "ad" : 'ad-metadata' , "adCost" : 2.99 , "bid" : 1.99 , "bidCurrency" : "USD" , "render" : "https://www.example-dsp.com/ad/123.jpg" , "adComponents" : [ adComponent1, adComponent2], "allowComponentAuction" : true , "modelingSignals" : 123 , }, "interestGroup" : { "owner" : "https://www.example-dsp.com" "name" : "campaign123" , "biddingLogicURL" : "https://www.example-dsp.com/bid_logic.js" }, "negativeInterestGroups" : { joiningOrigin: "https://www.example-advertiser.com" , interestGroupNames: [ "example_advertiser_negative_interest_group_a" , "example_advertiser_negative_interest_group_b" , ] }, "auctionNonce" : "12345678-90ab-cdef-fedcba09876543210" , "seller" : "https://www.example-ssp.com" , "topLevelSeller" : "https://www.another-ssp.com" }
-
Assert that these steps are running in parallel.
-
Assert that auctionConfigโs auction nonce is not null.
-
Let auctionNonce be the string representation of auctionConfigโs auction nonce.
-
Let capturedAdditionalBidsHeaders be globalโs associated Documentโs node navigableโs traversable navigableโs captured ad auction additional bids headers.
-
Let additionalBids be a new list of decoded additional bids.
-
For each encodedSignedAdditionalBidWithMetadata of capturedAdditionalBidsHeaders[auctionNonce]:
-
Let signedAdditionalBid be the result of running forgiving-base64 decode with encodedSignedAdditionalBidWithMetadataโs signed additional bid.
-
If signedAdditionalBid is failure, then continue.
-
Let additionalBid be the result of running parse a signed additional bid given signedAdditionalBid, reportingContextMap, encodedSignedAdditionalBidWithMetadataโs seller nonce, auctionConfig, topLevelAuctionConfig, and negativeTargetInfo.
-
If additionalBid is not null:
-
Append additionalBid to additionalBids.
-
Let bidCopy be a clone of additionalBid.
-
Set bidCopyโs for k-anon auction to false.
-
-
-
Return additionalBids.
-
Assert that these steps are running in parallel.
-
Let parsedSignedAdditionalBid be the result of running parse a JSON string to an infra value given signedAdditionalBid.
-
Return null if any of the following conditions hold:
-
Let signatures be a new list of signed additional bid signatures.
-
Let decodeSignatureFailed be false.
-
For each sig of parsedSignedAdditionalBid["signatures"]:
-
Set decodeSignatureFailed to true and break if any of the following conditions hold:
-
Let maybeKey be the result of running forgiving-base64 decode with sig["key"].
-
Let maybeSignature be the result of running forgiving-base64 decode with sig["signature"].
-
Set decodeSignatureFailed to true and break if any of the following conditions hold:
-
Let signature be a signed additional bid signatures, whose key is maybeKey, and signature is maybeSignature.
-
Append signature to signatures.
-
-
If decodeSignatureFailed is true, then return null.
-
Let decodedAdditionalBid be the result of decode an additional bid json given parsedSignedAdditionalBid["bid"], reportingContextMap, auctionConfig, topLevelAuctionConfig, and sellerNonce.
-
Return null if any of the following conditions hold:
-
decodedAdditionalBid is failure;
-
The result of checking a currency tag with decodedAdditionalBidโs bidโs bidโs currency and the result of running look up per-buyer currency with auctionConfig.
-
-
Let verifiedSignatureKeys be a new set of byte sequences.
-
For each signature of signatures:
-
If the result of checking whether negative targeted given decodedAdditionalBid, verifiedSignatureKeys and negativeTargetInfo is true, then return null.
-
Return decodedAdditionalBid.
-
Assert that these steps are running in parallel.
-
Let parsedAdditionalBid be the result of parse a JSON string to an infra value given additionalBidJson.
-
If parsedAdditionalBid is not a map, then return failure.
-
Let result be a new decoded additional bid.
-
Return failure if any of the following conditions hold:
-
parsedAdditionalBid["auctionNonce"] exists and parsedAdditionalBid["bidNonce"] exists;
-
parsedAdditionalBid["auctionNonce"] does not exist and parsedAdditionalBid["bidNonce"] does not exist;
-
parsedAdditionalBid["seller"] does not exist;
-
The result of running the parse an https origin with parsedAdditionalBid["seller"] is failure, or not same origin with auctionConfigโs seller.
-
-
If sellerNonce is not null:
-
Return failure if any of the following conditions hold:
-
parsedAdditionalBid["bidNonce"] does not exist;
-
parsedAdditionalBid["bidNonce"] is not the result of calculate expected bid nonce given the string representation of auctionConfigโs auction nonce and sellerNonce.
-
-
-
Otherwise:
-
Return failure if any of the following conditions hold:
-
parsedAdditionalBid["auctionNonce"] does not exist;
-
parsedAdditionalBid["auctionNonce"] is not the string representation of auctionConfigโs auction nonce;
-
-
-
If topLevelAuctionConfig is null:
-
If parsedAdditionalBid["topLevelSeller"] exists, then return failure.
-
-
Otherwise:
-
If parsedAdditionalBid["topLevelSeller"] does not exist, then return failure.
-
Let bidTopLevelSeller be the result of running the parse an https origin with parsedAdditionalBid["topLevelSeller"].
-
If bidTopLevelSeller is failure, or bidTopLevelSeller is not same origin with topLevelAuctionConfigโs seller, then return failure.
-
-
If parsedAdditionalBid["interestGroup"] does not exist, then return failure.
-
Let igMap be parsedAdditionalBid["interestGroup"].
-
Return failure if any the following conditions hold:
-
Let igOwner be the result of running parse an https origin given igMap["owner"].
-
Let igName be igMap["name"].
-
Let igBiddingUrl be the result of running url parser on igMap["biddingLogicURL"].
-
Return failure if any of the following conditions hold:
-
igOwner is failure;
-
auctionConfigโs interest group buyers does not contain igOwner;
-
igBiddingUrl is failure;
-
igOwner is not same origin with igBiddingUrl.
-
-
Let ig be a new interest group with the following properties:
- owner
-
igOwner
- name
-
igName
- bidding url
-
igBiddingUrl
-
If parsedAdditionalBid["bid"] does not exist, or is not a map, return failure.
-
Let bidMap be parsedAdditionalBid["bid"].
-
If bidMap["render"] does not exist or is not a string, then return failure.
-
Let renderUrl be the result of running URL parser on bidMap["render"].
-
If renderUrl is failure, then return failure.
-
Let ad be a new interest group ad whose render url is renderUrl.
-
Set igโs ads to ยซ ad ยป.
-
Let bidVal be bidMap["bid"] if it exists, otherwise return failure.
-
If bidVal is not a
double
, or is less than or equal to 0, then return failure. -
Let adMetadata be "null".
-
If bidMap["ad"] exists:
-
Set adMetadata to the result of running serialize an Infra value to a JSON string with bidMap["ad"].
-
-
Let bidCurrency be null.
-
If bidMap["bidCurrency"] exists:
-
If bidMap["bidCurrency"] is not a string, or the result of checking whether a string is a valid currency tag is failure, then return failure.
-
Set bidCurrency to bidMap["bidCurrency"].
-
-
Let adCost be null.
-
If bidMap["adCost"] exists:
-
If bidMap["adCost"] is not a
double
, then return failure. -
Set adCost to bidMap["adCost"].
-
-
Let modelingSignals be null.
-
If bidMap["modelingSignals"] exists:
-
If bidMap["modelingSignals"] is not a
double
, then return failure. -
If bidMap["modelingSignals"] โฅ 0, and < 4096, then set modelingSignals to bidMap["modelingSignals"].
-
-
Let adComponents be a new list of ad descriptors.
-
If bidMap["adComponents"] exists:
-
If bidMap["adComponents"] is not a list, then return failure.
-
For each component of bidMap["adComponents"]:
-
If component is not a string, then return failure.
-
Let componentUrl be the result of running URL parser on component.
-
If componentUrl is failure, then return failure.
-
Let componentDescriptor be a new ad descriptor whose url is componentUrl.
-
Append componentDescriptor to adComponents.
-
-
Set igโs ad components to adComponents.
-
-
If parsedAdditionalBid["negativeInterestGroup"] exists:
-
If parsedAdditionalBid["negativeInterestGroups"] exists, or parsedAdditionalBid["negativeInterestGroup"] is not a string, then return failure.
-
Append parsedAdditionalBid["negativeInterestGroup"] to resultโs negative target interest group names.
-
-
If parsedAdditionalBid["negativeInterestGroups"] exists:
-
Let multipleNegativeIg be parsedAdditionalBid["negativeInterestGroups"].
-
Return failure if any of the following conditions hold:
-
Let joiningOrigin be the result of running parse an https origin with multipleNegativeIg["joiningOrigin"].
-
If joiningOrigin is failure, then return failure.
-
Set resultโs negative target joining origin to joiningOrigin.
-
For each igName of multipleNegativeIg["interestGroupNames"]:
-
If igName is not a string, then return failure.
-
Append igName to resultโs negative target interest group names.
-
-
-
Set resultโs bid to a new generated bid with the following properties:
- reporting id
-
A reporting bid key with the following items:
- context
-
reportingContextMap[auctionConfig]
- source
- bidder origin
-
igโs owner
- bid identifier
-
A string representation of a new globably unique identifier. This is needed since igName may not be unique.
- bid
-
A bid with currency whose value is bidVal, and currency is bidCurrency
- ad
-
adMetadata
- ad descriptor
-
An ad descriptor whose url is renderUrl
- ad component descriptors
-
adComponents
- ad cost
-
adCost
- modeling signals
-
modelingSignals
- interest group
-
ig
- bid ad
-
A interest group ad whose render url is renderUrl, and metadata is adMetadata
- provided as additional bid
-
true
-
Return result.
-
Return the result of forgiving-base64 encoding the SHA-256 hash of the result of concatenating ยซauctionNonce, sellerNonceยป.
A signed additional bid signature is a struct with the following items:
- key
-
A byte sequence of length 32.
- signature
-
A byte sequence of length 64.
A decoded additional bid is a struct with the following items:
- bid
-
A generated bid. Fields analogous to those returned by
generateBid()
. - negative target interest group names
- negative target joining origin
-
Null or an origin. Required if there is more than one entry in negative target interest group names.
6.3. Negative Targeting
This first introductory paragraph is non-normative.
In online ad auctions for ad space, itโs sometimes useful to prevent showing an ad to certain
audiences, a concept known as negative targeting. To facilitate negative targeting in
Protected Audience auctions, each additional bid is allowed to identify one or more negative interest groups. If the user has been joined to any of the identified negative interest groups, the additional bid is dropped; otherwise it participates in the auction, competing alongside bids created by calls to generateBid()
. An additional bid that specifies no negative interest groups is always accepted into the auction.
-
Assert that these steps are running in parallel.
-
Let negativeTargeted be false.
-
Let additionalBidBuyer be additionalBidโs bidโs interest groupโs owner.
-
For each igName of additionalBidโs negative target interest group names:
-
If negativeTargetInfo[(additionalBidBuyer, igName)] exists:
-
Let (joiningOrigin, additionalBidKey) be negativeTargetInfo[(additionalBidBuyer, igName)].
-
If verifiedSignatureKeys contains additionalBidKey:
-
If joiningOrigin is not null:
-
If joiningOrigin is not same origin with additionalBidโs negative target joining origin, then continue.
-
-
Set negativeTargeted to true, and break.
-
-
-
Note: If the signature doesnโt verify successfully, the additional bid proceeds as if the negative interest group is not present. This ensures that only the owner of the negative interest group, who created the additionalBidKey
, is allowed to negatively target the interest group, and that nobody else can learn
whether the interest group set contains the interest group.
-
Return negativeTargeted.
A negative target info is a map. Its keys are tuples consisting of an origin for owner and a string for name. Its values are tuples consisting of an origin for joining origin and a byte sequence for additional bid key.
6.3.1. Negative Interest Groups
This section is non-normative.
Though negative interest groups are joined using the same joinAdInterestGroup()
API as regular interest groups, they remain distinct from one another. Only negative interest groupsโs additional bid key can be non-null, while only regular interest groupsโs ads can be non-null. Because the subset of fields
used by a negative interest group cannot be meaningfully updated, a negative interest groupโs update url must be null, otherwise a TypeError
will be thrown by joinAdInterestGroup()
API.
Additional bids specify the negative interest groups theyโre negatively targeting against using at most one of the following two fields in their JSON data structure:
-
negativeInterestGroup, for a single negative interest group;
-
negativeInterestGroups, for more than one negative interest groups.
If an additional bid needs to specify more than one negative interest groups, all of those negative interest groups must be joined from the same origin, and that origin must be
identified ahead of time in the additional bidโs joiningOrigin
field. Any negative interest group that wasnโt joined from that identified origin is ignored for negative targeting.
Use negativeInterestGroup
in additional bidโs JSON:
const additionalBid= { ... "negativeInterestGroup" : "example_advertiser_negative_interest_group" , ... }
Use negativeInterestGroups
in additional bidโs JSON:
const additionalBid= { ... "negativeInterestGroups" : { joiningOrigin: "https://example-advertiser.com" , interestGroupNames: [ "example_advertiser_negative_interest_group_a" , "example_advertiser_negative_interest_group_b" , ] }, ... }
7. K-anonymity
Two goals of this specification rely on applying k-anonymity thresholds:
-
To prevent cross-site leaks: Inputs to event-level reporting functions,
reportWin()
andreportResult()
, only contain limited cross-site information. As described in ยงโฏ16 Privacy Considerations, part of this limiting is done by applying k-anonymity requirements to the ad URLs. -
To ensure that the same ad or ad component is being shown to at least some minimum number of people: The browser applies k-anonymity requirements on the ad URLs.
The browser enforces these k-anonymity requirements by maintaining counts of how many times each ad and ad component has been shown to users. These counts are maintained across users, so the counting must be done on a central k-anonymity server. This specification relies on two operations to query and increment the counts: query k-anonymity count and increment k-anonymity count.
The details of how the k-anonymity server is operated and accessed are implementation-defined but it should be done in a way that prevents the server operator from joining the identity of two query or increment requests. One way to help prevent this is by making accesses to the server go through an HTTP proxy that prevents the server from seeing the browsers' IP addresses.
The browser should choose a k-anonymity threshold, otherwise known as the value for "k", and a k-anonymity duration depending on the projected sizes of interest groups and the browserโs privacy goals. For example an implementation might choose to require a k-anonymity threshold of fifty users over a seven day period. The server will maintain the count over the chosen duration and compare the count to the chosen k-anonymity threshold when responding to query k-anonymity count.
The user agent must maintain a k-anonymity cache as a map whose keys are SHA-256 hashes of the k-anonymity keys for all of the ads and ad components in the user agentโs interest group set and whose values are k-anonymity records. This allows the browser to rerun portions of an auction without incurring the delay (and added side channels) from querying the server during an auction.
-
Let kAnonRestrictedIG be a deep copy of ig.
-
If igโs ads is not null:
-
Set kAnonRestrictedIGโs ads to an empty list of interest group ad.
-
-
Let adHashCode be the result of running compute the key hash of ad given ig and igAd.
-
If query k-anonymity cache for igโs owner, igโs name, andadHashCode returns true:
-
If igAdโs selectable buyer and seller reporting IDs is not null:
-
Let kAnonRestrictedSelectableReportingIds be a new empty list of strings.
-
For each selectableReportingId in igAdโs selectable buyer and seller reporting IDs:
-
Let reportingHashCode be the result of query reporting ID k-anonymity count given ig, igAd, and selectableReportingId.
-
If query k-anonymity cache for igโs owner, igโs name, andreportingHashCode returns true, then append selectableReportingId to kAnonRestrictedSelectableReportingIds.
-
-
Set igAdโs selectable buyer and seller reporting IDs to kAnonRestrictedSelectableReportingIds.
-
-
-
-
-
If igโs ad components is not null:
-
Set kAnonRestrictedIGโs ad components to an empty list of interest group ad.
-
For each igAdComponent of igโs ad components:
-
Let adComponentHashCode be the result of running compute the key hash of component ad given ig and igAdComponent.
-
If query k-anonymity cache for igโs owner, igโs name, and adComponentHashCode returns true:
-
Append igAdComponent to kAnonRestrictedIGโs ad components.
-
-
-
-
Return kAnonRestrictedIG.
-
If the k-anonymity server has recorded at least k-anonymity threshold users seeing hashCode over the last k-anonymity duration, return true. Otherwise, return false.
-
Return true if it is above the threshold, otherwise return false.
-
If the difference between current coarsened wall time and recordโs timestamp is more than 7 days then return false.
-
Return recordโs is k-anonymous.
-
If the user agentโs k-anonymity overrides contains the tuple (owner,name):
-
If the user agentโs k-anonymity overrides[(owner,name)] does not contain hashCode, then return false.
-
Let record be the user agentโs k-anonymity overrides[(owner,name)][hashCode].
-
Return the result of checking a k-anonymity record with record.
-
-
Otherwise:
-
If the user agentโs k-anonymity cache does not contain hashCode, then return false.
-
Let record be the user agentโs k-anonymity cache[hashCode].
-
Return the result of checking a k-anonymity record with record.
-
-
Let keyString be the k-anonymity key formed from the concatenation of the following strings separated with U+000A LF:
-
"AdBid"
-
the serialization of igโs owner
-
the serialization of igโs bidding url
-
the serialization of igAdโs render url.
-
-
Return the SHA-256 hash of the ASCII encoding of keyString.
-
If reportingId is null, then return the concatenation of the following:
-
U+0000 (NUL)
-
U+0000 (NUL)
-
U+0000 (NUL)
-
U+0000 (NUL)
-
U+0000 (NUL)
-
-
Otherwise, return the concatenation of the following:
-
U+0001 (SOH)
-
The size of reportingId, interpreted as four 8-bit big-endian numbers, appended as bytes.
-
reportingId
-
-
Let middle be the concatenation of the following strings separated with U+000A (LF):
-
the serialization of igโs owner
-
the serialization of igโs bidding url
-
the serialization of igAdโs render url
-
-
Let keyString be an empty string.
-
If selectedReportingId is not null, then set the keyString to be the concatenation of the following strings separated with U+000A (LF):
-
"SelectedBuyerAndSellerReportId"
-
middle
-
The result of compute the key part for one of multiple reporting ids given selectedReportingId
-
The result of compute the key part for one of multiple reporting ids given igAdโs buyer and seller reporting ID
-
The result of compute the key part for one of multiple reporting ids given igAdโs buyer reporting ID
-
-
Otherwise:
-
If igAdโs buyer and seller reporting ID is not null, set keyString to be the concatenation of the following strings separated with U+000A (LF):
-
"BuyerAndSellerReportId"
-
middle
-
igAdโs buyer and seller reporting ID
-
-
Otherwise if igAdโs buyer reporting ID is not null, set keyString to be the concatenation of the following strings separated with U+000A (LF):
-
"BuyerReportId"
-
middle
-
igAdโs buyer reporting ID
-
-
Otherwise set keyString to be the concatenation of the following strings separated with U+000A (LF):
-
"NameReport"
-
middle
-
igAdโs name
-
-
-
Return the SHA-256 hash of the ASCII encoding of keyString.
-
Let keyString be the concatenation of the following strings separated with U+000A LF:
-
"ComponentBid"
-
the serialization of igAd.
-
-
Return the SHA-256 hash of the ASCII encoding of keyString.
-
Let ig be the bidโs interest group.
-
Compute the adHashCode following compute the key hash of ad with ig and bidโs ad descriptor.
-
If query k-anonymity cache for igโs owner, igโs name, and adHashCode returns false, return false.
-
If bidโs ad component descriptors is not null:
-
For each adComponentDescriptor in bidโs ad component descriptors:
-
Compute the componentAdHashCode by getting the result of compute the key hash of component ad with adComponentDescriptorโs url.
-
If query k-anonymity cache for igโs owner, igโs name, and componentAdHashCode returns false, return false.
-
-
-
If bidโs selected buyer and seller reporting ID is not null:
-
Let isKAnon the result of running query reporting ID k-anonymity count with ig, bidโs ad, and bidโs selected buyer and seller reporting ID.
-
If isKAnon is false, return false.
-
-
Return true.
-
Let keyHash be the result of computing the key hash of reporting ID given ig, igAd, and selectedReportingId.
-
Return the result of query k-anonymity cache given igโs owner, igโs name, and keyHash.
-
Assert that these steps are running in parallel.
-
Let record be a new k-anonymity record.
-
Set recordโs timestamp field to the current coarsened wall time.
-
Set recordโs is k-anonymous field to the result of executing query k-anonymity count for hashCode.
-
Set record[hashCode] to record.
-
Assert that these steps are running in parallel.
-
-
Let adHashCode be the result of running compute the key hash of ad given ig and igAd.
-
Run update k-anonymity cache for key on adHashCode.
-
Let adReportingHashCode be the result of computing the key hash of reporting ID given ig, igAd, and null.
-
Run update k-anonymity cache for key on adReportingHashCode.
-
If igAdโs selectable buyer and seller reporting IDs is not null:
-
For each selectableReportingId in igAdโs selectable buyer and seller reporting IDs:
-
Set adReportingHashCode be the result of computing the key hash of reporting ID given ig, igAd, and selectableReportingId.
-
Run update k-anonymity cache for key on adReportingHashCode.
-
-
-
-
For each componentAd of igโs ad components:
-
Let componentAdHashCode be the result of running compute the key hash of component ad given componentAd.
-
Run update k-anonymity cache for key on componentAdHashCode.
-
-
Ask the k-anonymity server to record that this user agent has seen hashCode.
-
Let keyString be the concatenation of the following strings separated with U+000A LF:
-
"AdBid"
-
the serialization of igโs owner
-
the serialization of igโs bidding url
-
the serialization of ad.
-
-
Let keyHash be the SHA-256 hash of the ASCII encoding of keyString.
-
Increment k-anonymity count given keyHash.
-
Let keyString be the concatenation of the following strings separated with U+000A LF:
-
"ComponentBid"
-
the serialization of ad.
-
-
Let keyHash be the SHA-256 hash of the ASCII encoding of keyString.
-
Increment k-anonymity count given keyHash.
-
Let igAd be the interest group ad from igโs ads whose render url is ad.
-
Let keyHash be the result of computing the key hash of reporting ID given ig and igAd.
-
Increment k-anonymity count given keyHash.
-
Increment ad k-anonymity count given winnerโs interest group and winnerโs ad descriptorโs url.
-
If winnerโs ad component descriptors is not null:
-
For each adComponentDescriptor in winnerโs ad component descriptors:
-
Increment component ad k-anonymity count given adComponentDescriptorโs url.
-
-
-
Increment reporting ID k-anonymity count given winnerโs interest group and winnerโs ad descriptorโs url.
8. Script Runners
This introduction sub-section is non-normative.
This specification defines a new type of script execution environment called a script runner. On the surface, these are similar to Worklets in that they too are used for running scripts independent of the main execution environment with a flexible implementation model.
However, some key differences from traditional Worklets motivate us to create a new kind of script execution environment. In particular, they:
-
Are not scoped to a particular
Document
, but are rather scoped to a user agent, as they are spun up by interest groups in the user agentโs interest group set. -
Consequently have a different, more flexible agent cluster allocation model โโspecifically, they need not execute in the same agent cluster as any
Document
, and for privacy reasons implementations may be motivated to enjoy this flexibility. -
Do not have any other WebIDL interfaces exposed to their global besides the ones defined in this specification, unlike other Worklet types.
-
Have a restricted set of ECMAScript APIs exposed to them; for example
Date
is not exposed in these environments. -
Are not module scripts, and are instead evaluated as if they were classic scripts.
-
Are not scripts in the [HTML] sense, and as such:
-
Their agent does not have an event loop
-
Their realm does not have a settings object, and therefore functions inside them are not run with the familiar [WebIDL] invocation mechanism.
-
They do not perform a microtask checkpoints.
-
8.1. Realm and agent
-
Let signifier be a new unique internal value.
-
Let candidateExecution be a new candidate execution.
-
Return a new agent whose [[CanBlock]] is false, [[Signifier]] is signifier, [[CandidateExecution]] is candidateExecution, and [[IsLockFree1]], [[IsLockFree2]], and [[LittleEndian]] are set at the implementationโs discretion.
Note: This algorithm is almost identical to [HTML]โs create an agent algorithm, with the exception that we do not give the returned agent a new event loop, since it does not process tasks within task sources in the usual way.
-
Let agentCluster be a new agent cluster.
-
Let agent be the result of creating a new script runner agent.
-
Add agent to agentCluster.
-
Return agent.
-
Assert that these steps are running in parallel.
-
Let agent be the result of obtaining a script runner agent given null, true, and false. Run the rest of these steps in agent.
This exclusively creates a new agent cluster for a given script to run in, but we should make this work with execution mode somehow.
-
Let realmExecutionContext be the result of creating a new realm given agent and the following customizations:
-
For the global object, create a new object of type globalType.
-
-
Let realm be realmExecutionContextโs Realm component.
-
Let global be realmโs global object, and run these steps:
-
Perform !global.[[Delete]]("
Date
"). -
If !global.[[HasProperty]]("
Temporal
") is true, then perform !global.[[Delete]]("Temporal
").
This is not the best way to perform such API neutering (see tc39/ecma262#1357), but at the moment itโs the way that host environments do this.
Note: Removing time-referencing APIs from the global object is imperative for privacy, as a script might otherwise be able to more easily exfiltrate data by using more accurate time measurements.
-
-
Return realm.
8.2. Script evaluation
Concretely, a script runner is a JavaScript execution environment instantiated with one of the following global objects:
unsigned short
multiBidLimit, an interest group ig, a reporting context reportingContext,
an execution metrics executionMetrics,
a currency tag expectedCurrency, a GenerateBidInterestGroup
igGenerateBid,
a string-or-null auctionSignals, a string-or-null perBuyerSignals,
an ordered map-or-null sameOriginTrustedBiddingSignals, an ordered map-or-null crossOriginTrustedBiddingSignals, a BiddingBrowserSignals
browserSignals,
a DirectFromSellerSignalsForBuyer
directFromSellerSignalsForBuyer, and an integer
millisecond duration timeout, perform the following steps. They return a tuple (list of generated bids, bid debug reporting info, list of real time reporting contributions, Private Aggregation contributions, execution metrics).
-
Let realm be the result of creating a new script runner realm given
InterestGroupBiddingScriptRunnerGlobalScope
. -
Let global be realmโs global object.
-
Let settings be realmโs settings object.
WICG/turtledove#676 needs to be fixed in order to get realmโs settings object.
-
Set globalโs group has ad components to true if igโs ad components is not null, or false otherwise.
-
Set globalโs expected currency to expectedCurrency.
-
Prepare for private aggregation given global, generate-bid, reportingContext, igโs owner and igโs Private Aggregation coordinator.
-
Let isComponentAuction be true if browserSignals["
topLevelSeller
"] is not null, or false otherwise. -
Set globalโs is component auction to isComponentAuction.
-
Set globalโs multi-bid limit to multiBidLimit.
-
Set globalโs interest group to ig.
-
Let igJS be the result of converting to ECMAScript values given igGenerateBid.
-
Let auctionSignalsJS be the result of parsing a JSON string to a JavaScript value given auctionSignals if auctionSignals is not null, otherwise
undefined
. -
Let perBuyerSignalsJS be the result of parsing a JSON string to a JavaScript value given perBuyerSignals if perBuyerSignals is not null, otherwise
undefined
. -
Let sameOriginTrustedBiddingSignalsJS be sameOriginTrustedBiddingSignals converted to ECMAScript values.
-
Let browserSignalsJS be browserSignals converted to ECMAScript values.
-
Let directFromSellerSignalsJS be directFromSellerSignalsForBuyer converted to ECMAScript values.
-
Let crossOriginTrustedBiddingSignalsJS be crossOriginTrustedBiddingSignals converted to ECMAScript values.
-
Let startTime be settingsโs current monotonic time.
-
Let (result, executionMetricsโs script timed out) be the result of evaluating a script with realm, script, "
generateBid
", ยซ igJS, auctionSignalsJS, perBuyerSignalsJS, sameOriginTrustedBiddingSignalsJS, browserSignalsJS, directFromSellerSignalsJS, crossOriginTrustedBiddingSignalsJS ยป, and timeout. -
Let duration be settingsโs current monotonic time minus startTime in milliseconds.
-
If globalโs priority is not null and not failure:
-
Replace the interest group that has igโs owner and name in the user agentโs interest group set with ig.
-
If globalโs priority signals is not empty:
-
For each k โ v of globalโs priority signals:
-
If v is null, remove igโs priority signals overrides[k].
-
Otherwise, set igโs priority signals overrides[k] to v.
-
-
Replace the interest group that has igโs owner and name in the user agentโs interest group set with ig.
-
-
Let generatedBids be globalโs bids.
-
If result is a normal completion:
-
Let generatedBidIDL be the result of converting resultโs [[Value]] to a (
GenerateBidOutput
or sequence<GenerateBidOutput
>). -
If no exception was thrown in the previous step, set generatedBids to the result of converting one or many GenerateBidOutputs to a list of generated bids with generatedBidIDL, multiBidLimit, ig, expectedCurrency, isComponentAuction, and globalโs group has ad components.
-
Otherwise, set generatedBids to failure.
-
-
If generatedBids is not a list of generated bids, set generatedBids to a new list of generated bids.
-
Let bidDebugReportInfo be a new bid debug reporting info.
-
Set bidDebugReportInfoโs interest group owner to igโs owner.
-
Let debugLossReportUrl be globalโs debug loss report url if itโs not failure, null otherwise.
-
Set bidDebugReportInfoโs bidder debug loss report url to debugLossReportUrl.
-
If generatedBids is not empty:
-
Let debugWinReportUrl be globalโs debug win report url if itโs not failure, null otherwise.
-
Set bidDebugReportInfoโs bidder debug win report url to debugWinReportUrl.
-
For each generatedBid in generatedBids:
-
Set generatedBidโs bid duration to duration, interest group to ig.
-
-
-
Let realTimeContributions be a new list of real time reporting contributions.
-
For each contribution of globalโs real time reporting contributions:
-
If contributionโs latency threshold is not null, and โฅ duration, then continue.
-
Append contribution to realTimeContributions.
-
-
Finalize private aggregation debug info given global.
-
Let paContributions be the result of extracting private aggregation contributions given global.
-
Return a tuple (generatedBids, bidDebugReportInfo, realTimeContributions, paContributions, executionMetrics).
double
bidValue, an auction config auctionConfig, a reporting context reportingContext, an ordered map-or-null sameOriginTrustedScoringSignals,
an ordered map-or-null crossOriginTrustedScoringSignals, ScoringBrowserSignals
browserSignals, a DirectFromSellerSignalsForSeller
directFromSellerSignalsForSeller, and an integer millisecond duration timeout:
-
Let realm be the result of creating a new script runner realm given
InterestGroupScoringScriptRunnerGlobalScope
. -
Let global be realmโs global object.
-
Let settings be realmโs settings object.
-
Prepare for private aggregation given global, score-ad, reportingContext, auctionConfigโs seller and auctionConfigโs seller Private Aggregation coordinator.
-
Let browserSignalsJS be browserSignals converted to ECMAScript values.
-
Let auctionConfigJS be auctionConfigโs config idl converted to ECMAScript values.
-
Let sameOriginTrustedScoringSignalsJS be sameOriginTrustedScoringSignals converted to ECMAScript values.
-
Let crossOriginTrustedScoringSignalsJS be crossOriginTrustedScoringSignals converted to ECMAScript values.
-
Let directFromSellerSignalsJs be directFromSellerSignalsForSeller converted to ECMAScript values.
-
Let startTime be settingsโs current monotonic time.
-
Let executionMetrics be a new execution metrics.
-
Let (scoreAdResult, executionMetricsโs script timed out) be the result of evaluating a script with realm, script, "
scoreAd
", ยซadMetadata, bidValue, auctionConfigJS, sameOriginTrustedScoringSignalsJS, browserSignalsJS, directFromSellerSignalsJs, crossOriginTrustedScoringSignalsJSยป, and timeout. -
Let duration be settingsโs current monotonic time minus startTime in milliseconds.
-
Let debugWinReportUrl be globalโs debug win report url if itโs not failure, null otherwise.
-
Let debugLossReportUrl be globalโs debug loss report url if itโs not failure, null otherwise.
-
Let realTimeContributions be a new list of real time reporting contributions.
-
For each contribution of globalโs real time reporting contributions:
-
If contributionโs latency threshold is not null, and โฅ duration, then continue.
-
Append contribution to realTimeContributions.
-
-
Finalize private aggregation debug info given global.
-
Let paContributions be the result of extracting private aggregation contributions given global.
-
Return ยซ scoreAdResult, debugWinReportUrl, debugLossReportUrl, realTimeContributions, paContributions, executionMetrics ยป.
-
Let realm be the result of creating a new script runner realm given
InterestGroupReportingScriptRunnerGlobalScope
. -
Let global be realmโs global object.
-
Let function be report-win
-
If functionName is
"reportResult"
, set function to report-result. -
Prepare for private aggregation given global, function, reportingContext, origin, and privateAggregationCoordinator.
-
Let argumentsJS be the result of converting arguments to an ECMAScript arguments list. If this throws an exception, return ยซ "null", null, null, null, a new Private Aggregation Contributions, executionMetrics ยป.
-
Let executionMetrics be a new execution metrics.
-
Let (result, executionMetricsโs script timed out) be the result of evaluating a script with realm, script, functionName, argumentsJS, and timeout.
-
If result is an abrupt completion, return ยซ "null", null, null, null ยป.
-
Let resultJSON be "null".
-
If functionName is "
reportResult
", then set resultJSON to the result of serializing a JavaScript value to a JSON string given result.Note: Consider a return value that canโt be converted to JSON a valid result, so if an exception was thrown in the previous step, keep resultJSON as "null".
-
Let reportURL be globalโs report url
-
If reportURL is failure, set reportURL to null.
-
Let macroMap be globalโs reporting macro map if functionName is "
reportWin
" or "reportAdditionalBidWin
", null otherwise. -
Finalize private aggregation debug info given global.
-
Let paContributions be the result of extracting private aggregation contributions given global.
-
Return ยซ resultJSON, reportURL, globalโs reporting beacon map, macroMap, paContributions, executionMetrics ยป.
-
Assert that these steps are running in parallel.
-
If timeout โค 0, return (new throw completion given null, true).
-
Let timedOut be false.
-
Let global be realmโs global object, and run these steps in realmโs agent:
-
Let result be ParseScript(script, realm,
empty
).Note: The resulting Script Record will have no [[HostDefined]] component, unlike traditional scripts on the web platform.
-
If result is a list of errors, return (Completion { [[Type]]:
throw
, [[Value]]: result, [[Target]]:empty
}, false). -
Assert: result is a Script Record.
-
Prepare to run script: Push realmExecutionContext onto the JavaScript execution context stack; it is now the running JavaScript execution context.
-
Let evaluationStatus be the result of ScriptEvaluation(result).
In timeout milliseconds, if the invocation of ScriptEvaluation has not completed, immediately interrupt the execution, set finalCompletion to a new throw completion given null, set timedOut to true, and jump to the step labeled return.
-
If evaluationStatus is an abrupt completion, jump to the step labeled return.
-
Let F be Get(global, functionName). If that returns a throw completion, set finalCompletion to F and jump to the step labeled return.
-
Set finalCompletion be Completion(Call(F,
undefined
, arguments)).In timeout milliseconds minus the execution time of ScriptEvaluation, if the invocation of Call has not completed, immediately interrupt the execution, set finalCompletion to a new throw completion given null, and set timedOut to true.
-
Return: at this point finalCompletion will be set to a Completion Record.
-
Clean up after script: Assert realmExecutionContext is the running JavaScript execution context, and remove it from the JavaScript execution context stack.
-
Return (finalCompletion, timedOut).
-
8.3. Global scopes
An additional requirement to the interest group script runner globals defined in this specification is that they must not expose any interfaces from other specifications whose own exposure set is the special value "*". The only interfaces that can be exposed inside of the globals defined in this specification are those that explicitly list the global names provided here.
[Exposed =InterestGroupScriptRunnerGlobalScope ]interface {
InterestGroupScriptRunnerGlobalScope readonly attribute PrivateAggregation ?privateAggregation ;readonly attribute ProtectedAudienceUtilities protectedAudience ; };dictionary {
PASignalValue required DOMString ;
baseValue double ; (
scale bigint or long ); };
offset dictionary {
PAExtendedHistogramContribution required (PASignalValue or bigint );
bucket required (PASignalValue or long );
value bigint = 0; }; [
filteringId Exposed =InterestGroupScriptRunnerGlobalScope ]interface {
ProtectedAudienceUtilities Uint8Array encodeUtf8 (USVString );
input USVString decodeUtf8 (Uint8Array ); };
bytes
Each InterestGroupScriptRunnerGlobalScope
has a
- private aggregation
-
Null, or a PrivateAggregation. Initially null.
- protected audience utilities
-
Initially a
ProtectedAudienceUtilities
. - on event contribution map
-
A map from string to a list of on event contribution entries.
- worklet function
-
A worklet function. Affects some Private Aggregation API functionality.
- origin
-
The origin of the script being executed.
privateAggregation
getter steps are:
-
Return thisโs relevant global objectโs private aggregation.
protectedAudience
getter steps are:
-
Return thisโs relevant global objectโs protected audience utilities.
encodeUtf8(USVString input)
method steps are:
-
Follow the steps of
TextEncoder.encode(input)
.
decodeUtf8(Uint8Array bytes)
method steps are
a simplified version of TextDecoder.decode(bytes)
,
with a UTF-8 decoder and ignoreBOM
set to true:
-
Let ioQueue be an I/O queue of bytes ยซ end-of-queue ยป.
-
Push bytes to ioQueue.
-
Let output be an I/O queue of bytes ยซ end-of-queue ยป.
-
While true:
-
Let serializationSettings be a new
TextDecoderCommon
with following fields:- encoding
- UTF-8
- ignore BOM
- true
- decoder
- decoder
-
Return the result of running serialize I/O queue with serializationSettings and output.
[Exposed =InterestGroupBiddingAndScoringScriptRunnerGlobalScope ]interface {
ForDebuggingOnly undefined reportAdAuctionWin (USVString );
url undefined reportAdAuctionLoss (USVString ); }; [
url Exposed =InterestGroupBiddingAndScoringScriptRunnerGlobalScope ]interface {
RealTimeReporting undefined contributeToHistogram (RealTimeContribution ); };
contribution dictionary {
RealTimeContribution required long ;
bucket required double ;
priorityWeight long ; }; [
latencyThreshold Exposed =InterestGroupBiddingAndScoringScriptRunnerGlobalScope ,Global =InterestGroupBiddingAndScoringScriptRunnerGlobalScope ]interface :
InterestGroupBiddingAndScoringScriptRunnerGlobalScope InterestGroupScriptRunnerGlobalScope {readonly attribute ForDebuggingOnly forDebuggingOnly ;readonly attribute RealTimeReporting realTimeReporting ; };
Each InterestGroupBiddingAndScoringScriptRunnerGlobalScope
has an associated ForDebuggingOnly
instance forDebuggingOnly, and
an associated RealTimeReporting
instance realTimeReporting, which are
created alongside the InterestGroupBiddingAndScoringScriptRunnerGlobalScope
.
forDebuggingOnly
getter steps are:
-
Return thisโs relevant global objectโs forDebuggingOnly.
Each InterestGroupBiddingAndScoringScriptRunnerGlobalScope
has a
- debug win report url
-
Null, failure, or a URL whose scheme is "
https
". Initially null. - debug loss report url
-
Null, failure, or a URL whose scheme is "
https
". Initially null.
reportAdAuctionWin(url)
method steps are:
-
Let global be thisโs relevant global object.
-
Let parsedUrl be the result of running the URL parser on url.
-
If parsedUrl is failure, or parsedUrlโs scheme is not "
https
", then set globalโs debug win report url to failure. -
Optionally, return.
Note: This implementation-defined condition is intended to allow user agents to decline for a number of reasons, for example the parsedUrlโs site not being enrolled.
-
Set globalโs debug win report url to parsedUrl.
reportAdAuctionLoss(url)
method steps are:
-
Let global be thisโs relevant global object.
-
Let parsedUrl be the result of running the URL parser on url.
-
If parsedUrl is failure, or parsedUrlโs scheme is not "
https
", then set globalโs debug loss report url to failure. -
Optionally, return.
Note: This implementation-defined condition is intended to allow user agents to decline for a number of reasons, for example the parsedUrlโs site not being enrolled.
-
Set globalโs debug loss report url to parsedUrl.
realTimeReporting
getter steps are:
-
Return thisโs relevant global objectโs realTimeReporting.
Each InterestGroupBiddingAndScoringScriptRunnerGlobalScope
has a
- real time reporting contributions
contributeToHistogram(RealTimeContribution
contribution)
method steps are:
-
Let global be thisโs relevant global object.
-
If contribution["
bucket
"] โฅ number of user buckets or is negative, then return;Note: For forward compatibility with new values, donโt throw.
-
If contribution["
priorityWeight
"] โค 0, then throw aTypeError
. -
Let contributionEntry be a new real time reporting contribution with the following items:
- bucket
-
contribution["
bucket
"] - priority weight
-
contribution["
priorityWeight
"] - latency threshold
-
contribution["
latencyThreshold
"] if it exists, null otherwise
-
Append contributionEntry to globalโs real time reporting contributions.
8.3.1. InterestGroupBiddingScriptRunnerGlobalScope
[Exposed =InterestGroupBiddingScriptRunnerGlobalScope ,Global =(InterestGroupScriptRunnerGlobalScope ,InterestGroupBiddingScriptRunnerGlobalScope )]interface :
InterestGroupBiddingScriptRunnerGlobalScope InterestGroupBiddingAndScoringScriptRunnerGlobalScope {boolean setBid (optional (GenerateBidOutput or sequence <GenerateBidOutput >)= []);
oneOrManyBids undefined setPriority (double );
priority undefined setPrioritySignalsOverride (DOMString ,
key optional double ?); };
priority dictionary {
AdRender required DOMString ;
url DOMString ;
width DOMString ; };
height dictionary {
GenerateBidOutput double = -1;
bid DOMString ; (
bidCurrency DOMString or AdRender );
render any ;
ad USVString ;
selectedBuyerAndSellerReportingId sequence <(DOMString or AdRender )>;
adComponents double ;
adCost unrestricted double ;
modelingSignals boolean =
allowComponentAuction false ;unsigned long ;
targetNumAdComponents unsigned long = 0; };
numMandatoryAdComponents
Each InterestGroupBiddingScriptRunnerGlobalScope
has a
- bids
-
A list of generated bids, initially empty.
- priority
-
Null, failure, or a
double
, initially null. - priority signals
-
An ordered map whose keys are strings and whose values are
double
or null. - interest group
- expected currency
- is component auction
-
A boolean
- group has ad components
-
A boolean
- multi-bid limit
-
An
unsigned short
.
GenerateBidOutput
or sequence<GenerateBidOutput
>) oneOrManyBids, an unsigned short
multiBidLimit, an interest group ig, a currency tag expectedCurrency, a boolean isComponentAuction and a boolean groupHasAdComponents:
-
Let bidSequence be sequence<
GenerateBidOutput
>. -
If the specific type of oneOrManyBids is
GenerateBidOutput
, then set bidSequence to ยซ oneOrManyBids ยป. -
Otherwise, set bidSequence to oneOrManyBids.
-
If bidSequenceโs size > multiBidLimit, then return failure.
-
Let bids be a new list of generated bids.
-
for each bidOutput of bidSequence:
-
Let bid be the result of converting GenerateBidOutput to generated bid given bidOutput, ig, expectedCurrency, isComponentAuction, groupHasAdComponents.
-
If bid is failure, return failure.
-
If bid is null, continue.
-
Append bid to bids.
-
-
Return bids.
To convert GenerateBidOutput to generated bid given a GenerateBidOutput
generateBidOutput, an interest group ig, a currency tag expectedCurrency, a boolean isComponentAuction and a boolean groupHasAdComponents:
-
If generateBidOutput["
bid
"] โค 0, then return null. -
Let bid be a new generated bid.
-
If generateBidOutput["
render
"] does not exist, return failure. -
If isComponentAuction is true, and generateBidOutput["
allowComponentAuction
"] is false, then return failure. -
Let bidCurrency be null.
-
If generateBidOutput["
bidCurrency
"] is specified:-
If the result of checking whether a string is a valid currency tag on generateBidOutput["
bidCurrency
"] is true, then set bidCurrency to generateBidOutput["bidCurrency
"], otherwise return failure.
-
-
If the result of checking a currency tag with expectedCurrency and bidCurrency is false, return failure.
-
Set bidโs bid to a bid with currency with value generateBidOutput["
bid
"] and currency bidCurrency. -
If generateBidOutput["
ad
"] exists:-
Let adJSON be the result of serializing a JavaScript value to a JSON string, given generateBidOutput["
ad
"]. -
If adJSON is failure, return failure.
-
Set bidโs ad to adJSON.
-
-
Let adDescriptor be a new ad descriptor.
-
If generateBidOutput["
render
"] is aDOMString
:-
Let adUrl be the result of running the URL parser on generateBidOutput["
render
"]. -
If adUrl is failure, return failure.
-
Set adDescriptorโs url to adUrl.
-
-
Otherwise:
-
Set adDescriptor to the result of converting an ad render given generateBidOutput["
render
"]. -
If adDescriptor is failure, return failure.
-
-
Let bidAd be the result of finding matching ad given adDescriptor, ig, and false.
-
If bidAd is null, return failure.
-
Set bidโs ad descriptor to adDescriptor.
-
Set bidโs bid ad to bidAd.
-
If generateBidOutput["
selectedBuyerAndSellerReportingId
"] exists:-
If bidAdโs selectable buyer and seller reporting IDs is null, or does not contain generateBidOutput["
selectedBuyerAndSellerReportingId
"], return failure. -
Set bidโs selected buyer and seller reporting ID to generateBidOutput["
selectedBuyerAndSellerReportingId
"].
-
-
If generateBidOutput["
adComponents
"] exists:-
Let adComponents be generateBidOutput["
adComponents
"]. -
Return failure if any of the following conditions hold:
-
groupHasAdComponents is false;
-
adComponentsโs size is greater than 40 and generateBidOutput["
targetNumAdComponents
"] does not exist.
-
-
Let adComponentDescriptors be a new list of ad descriptors.
-
For component in adComponents:
-
Let componentDescriptor be a new ad descriptor.
-
If component is
DOMString
:-
Let componentUrl be the result of running the URL parser on component.
-
If componentUrl is failure, return failure.
-
Set componentDescriptorโs url to componentUrl.
-
-
Otherwise:
-
Set componentDescriptor to the result of converting an ad render given component.
-
If componentDescriptor is failure, return failure.
-
-
Let bidComponentAd be result of finding matching ad given componentUrl, ig, and true.
-
If bidComponentAd is null, return failure.
-
Append bidComponentAd to bidโs bid ad components.
-
Append componentDescriptor to adComponentDescriptors.
-
-
Set bidโs ad component descriptors to adComponentDescriptors.
-
-
If generateBidOutput["
targetNumAdComponents
"] exists:-
If generateBidOutput["
targetNumAdComponents
"] is equal to 0 or greater than 40, then return failure. -
If bidโs ad component descriptors is null, or bidโs ad component descriptorsโs size < generateBidOutput["
targetNumAdComponents
"], return failure. -
If generateBidOutput["
targetNumAdComponents
"] < generateBidOutput["numMandatoryAdComponents
"], return failure. -
Set bidโs target number of ad components to generateBidOutput["
targetNumAdComponents
"]. -
Set bidโs number of mandatory ad components to generateBidOutput["
numMandatoryAdComponents
"].
-
-
If generateBidOutput["
adCost
"] exists, then set bidโs ad cost to generateBidOutput["adCost
"]. -
If generateBidOutput["
modelingSignals
"] exists:-
Let modelingSignals be generateBidOutput["
modelingSignals
"]. -
If modelingSignals โฅ 0 and modelingSignals < 4096, then set bidโs modeling signals to the result of converting the ECMAScript value represented by modelingSignals to an
unsigned short
.
-
-
Return bid.
-
Let position be a position variable, initially pointing at the start of input.
-
Strip leading and trailing ASCII whitespace from input.
-
If input starts with "
0
" but is not "0
" and does not start with "0.
", then return null as the dimension and the empty string as the dimension unit. -
Collect a sequence of code points that are ASCII digits or U+002E (.), given position. Let that be dimensionString.
-
If dimensionString is the empty string, then return null as the dimension and the empty string as the dimension unit.
-
Let dimension be the result of parsing dimensionString using the rules for parsing floating-point number values.
-
If dimension is an error, then return null as the dimension and the empty string as the dimension unit.
-
If dimension is less than 0, then return null as the dimension and the empty string as the dimension unit.
-
Collect a sequence of code points that are ASCII lower alpha, given position. Let that be dimensionUnit.
-
If position is not past the end of input, then return null as the dimension and the empty string as the dimension unit.
-
If dimensionUnit is the empty string, then set dimensionUnit to "px".
-
If dimensionUnit is not "px", "sh", or "sw", then return null as the dimension and the empty string as the dimension unit.
-
Return dimension as the dimension and dimensionUnit as the dimension unit.
AdRender
adRender:
-
Let adUrl be the result of running the URL parser on adRender["
url
"]. -
If adUrl is failure, return failure.
-
Let adDescriptor be a new ad descriptor.
-
Set adDescriptorโs url to adUrl.
-
-
Let width and widthUnit be the dimension and dimension unit that results from running parse an AdRender dimension value with adRender["
width
"], respectively. -
If width is null, return failure.
-
Let height and heightUnit be the dimension and dimension unit that results from running parse an AdRender dimension value with adRender["
height
"], respectively. -
If height is null, return failure.
-
Let adSize be a new ad size.
-
Set adSizeโs width to width, width units to widthUnit, height to height, height units to heightUnit.
-
Set adDescriptorโs size to adSize.
-
Return adDescriptor.
-
Let adUrl be adDescriptorโs url.
-
If adUrlโs scheme is not "
https
", return null. -
Let maybeMatchingAd be an interest group ad-or null, set to null.
-
Let adSize be adDescriptorโs size.
-
Let adList be igโs ad components if isComponent, otherwise igโs ads.
-
For each ad in adList:
-
If adโs render url does not equal adUrl, continue.
-
If adโs size group is null and adSize is null, set maybeMatchingAd to ad, and break.
-
If one of adโs size group OR adSize is null, set maybeMatchingAd to ad, and break.
Note: When only one of the two ads has a size specification, they are considered matching. The caller is responsible for discarding the extraneous size information.
-
For each igSize in (igโs size groups)[adโs size group]:
-
If igSize equals adSize, set maybeMatchingAd to ad, and break.
-
-
-
Return null.
setBid(oneOrManyBids)
method steps are:
-
Let global be thisโs relevant global object.
-
Let ig be globalโs interest group.
-
Let expectedCurrency be globalโs expected currency.
-
Let bidsToSet be the result of converting one or many GenerateBidOutputs to a list of generated bids with oneOrManyBids, globalโs multi-bid limit, ig, expectedCurrency, globalโs is component auction, and globalโs group has ad components.
-
Set globalโs bids to bidsToSet.
setPriority(priority)
method steps are:
setPrioritySignalsOverride(key, priority)
method steps are:
-
Set thisโs relevant global objectโs priority signals[key] to priority.
8.3.2. InterestGroupScoringScriptRunnerGlobalScope
[Exposed =InterestGroupScoringScriptRunnerGlobalScope ,Global =(InterestGroupScriptRunnerGlobalScope ,InterestGroupScoringScriptRunnerGlobalScope )]interface :
InterestGroupScoringScriptRunnerGlobalScope InterestGroupBiddingAndScoringScriptRunnerGlobalScope { };
8.3.3. InterestGroupReportingScriptRunnerGlobalScope
[Exposed =InterestGroupReportingScriptRunnerGlobalScope ,Global =(InterestGroupScriptRunnerGlobalScope ,InterestGroupReportingScriptRunnerGlobalScope )]interface :
InterestGroupReportingScriptRunnerGlobalScope InterestGroupScriptRunnerGlobalScope {undefined sendReportTo (DOMString );
url undefined registerAdBeacon (record <DOMString ,USVString >);
map undefined registerAdMacro (DOMString ,
name USVString ); };
value
Note: registerAdMacro(name, value)
is only
available in report win, but not report result.
Each InterestGroupReportingScriptRunnerGlobalScope
has a
- report url
-
Null, failure, or a URL whose scheme is "
https
". Initially null. - reporting beacon map
-
Null or an ordered map whose keys are strings and whose values are URLs whose schemes are "
https
". Initially null. - reporting macro map
-
Null or an ordered map whose keys are strings and whose values are strings. Initially null.
sendReportTo(url)
method steps are:
-
Let global be thisโs relevant global object.
-
If globalโs report url is not null, then set globalโs report url to failure, and throw a
TypeError
. -
Let parsedUrl be the result of running the URL parser on url.
-
If parsedUrl is failure, or parsedUrlโs scheme is not "
https
", set globalโs report url to failure, and throw aTypeError
. -
Optionally, return.
Note: This implementation-defined condition is intended to allow user agents to decline for a number of reasons, for example the parsedUrlโs site not being enrolled.
-
Set globalโs report url to parsedUrl.
registerAdBeacon(map)
method steps are:
-
If thisโs relevant global objectโs reporting beacon map is not null, then Throw a
TypeError
. -
For each type โ url of map:
-
If type starts with "
reserved.
" and type does not match one of the automatic beacon event type values, throw aTypeError
. -
Let parsedURL be the result of running URL parser on url.
-
Throw a
TypeError
if any of the following conditions hold:-
parsedURL is failure;
-
parsedURLโs scheme is not "
https
".
-
-
-
Set thisโs relevant global objectโs reporting beacon map to map.
registerAdMacro(name, value)
method steps are:
-
-
Throw a
TypeError
if both of the following conditions hold:-
c is not an unreserved percent encoding character;
-
c is not "
%
".
-
-
-
For each code unit c in value:
-
Throw a
TypeError
if both of the following conditions hold:-
c is not an unreserved percent encoding character;
-
c is not "
%
".
-
-
-
Set thisโs relevant global objectโs reporting macro map[name] to value.
9. Interest Group Updates
This first introductory paragraph is non-normative.
Interest groups have an update url field that allows updating the
interest group definition stored on disk with information periodically retrieved from the update url. The interest group update steps are triggered during runAdAuction()
and by calls to updateAdInterestGroups()
API:
[SecureContext ]partial interface Navigator {undefined updateAdInterestGroups (); };
The updateAdInterestGroups()
method steps are:
-
Let settings be thisโs relevant settings object.
-
In parallel, run interest group update with ยซ settingsโs top-level origin ยป, and settingsโs policy container.
Implementations can consider aborting all updating if updating has been running for too long. This can avoid continuing to reveal coarse IP location information to update servers long after navigating to another page. Some implementations, such as Chromium, have chosen a 10 minute limit.
-
For each owner of owners:
-
For each originalInterestGroup of the user agentโs interest group set whose owner is owner and next update after is before the current coarsened wall time and whose update url is not null:
Note: Implementations can consider loading only a portion of these interest groups at a time to avoid issuing too many requests at once.
-
Let ig be a deep copy of originalInterestGroup.
-
Let request be a new request with the following properties:
- URL
-
igโs update url
- header list
-
ยซ
Accept
:application/json
ยป - client
-
null
- origin
-
owner
- mode
-
"
no-cors
" - referrer
-
"
no-referrer
" - credentials mode
-
"
omit
" - redirect mode
-
"
error
" - service-workers mode
-
"
none
" - policy container
-
A new policy container whose IP address space is policyContainerโs IP address space
Stop using "
no-cors
" mode where possible (WICG/turtledove#667). -
Let update be null.
-
Fetch request with useParallelQueue set to true, and processResponseConsumeBody set to the following steps given a response response and null, failure, or a byte sequence responseBody:
-
If validate fetching response with response, responseBody and "
application/json
" returns false, set update to failure and return. -
Set update to responseBody.
-
-
Wait for update to be set.
-
If update is failure, continue.
-
Let parsedUpdate be the result of parsing JSON bytes to an Infra value, given update.
-
If parsedUpdate is failure, continue.
-
If parsedUpdate is not an ordered map, continue.
-
If parsedUpdate["
name
"] exists and doesnโt match igโs name, continue. -
If parsedUpdate["
owner
"] exists and doesnโt match igโs owner, continue. -
For each key โ value of parsedUpdate:
-
Switch on key:
- "
priority
" -
-
Otherwise, jump to the step labeled Abort update.
- "
enableBiddingSignalsPrioritization
" -
-
If value is a
boolean
, set igโs enable bidding signals prioritization to value. -
Otherwise, jump to the step labeled Abort update.
-
- "
priorityVector
" -
-
If value is null or an ordered map whose keys are strings and whose values are
double
, set igโs priority vector to value. -
Otherwise, jump to the step labeled Abort update.
-
- "
prioritySignalsOverrides
" -
-
If value is an ordered map whose keys are strings and whose values are
double
or null:-
For each pvKey โ pvValue of value:
-
If pvValue is null, remove igโs priority signals overrides[pvKey].
-
Otherwise, set igโs priority signals overrides[pvKey] to pvValue.
-
-
-
Otherwise, jump to the step labeled Abort update.
-
- "
privateAggregationConfig
" -
-
If value is not a map whose keys are strings, jump to the step labeled Abort update.
-
If value["
aggregationCoordinatorOrigin
"] exists:-
If value["
aggregationCoordinatorOrigin
"] is not a string, jump to the step labeled Abort update. -
Let aggregationCoordinator be the result of obtaining the Private Aggregation coordinator given value["
aggregationCoordinatorOrigin
"]. -
If aggregationCoordinator is a
DOMException
, jump to the step labeled Abort update. -
Otherwise, set igโs Private Aggregation coordinator to aggregationCoordinator.
-
-
- "
sellerCapabilities
" -
-
If value is an ordered map whose keys are strings and whose values are lists of strings, for each sellerString โ capabilities of value:
-
Let sellerCapabilities be a new set of seller capabilities.
-
For each capabilityString of capabilities:
-
If sellerString is "
*
", then set igโs all sellers capabilities to sellerCapabilities. -
Otherwise:
-
If igโs seller capabilities is null, then set igโs seller capabilities to a new ordered map whose keys are origins and whose values are sets of seller capabilities.
-
Let sellerUrl be the result of running the URL parser on sellerString.
-
If sellerUrl is not failure:
-
Let seller be sellerUrlโs origin.
-
If igโs seller capabilities does not contain seller, then set igโs seller capabilities[seller] to sellerCapabilities.
-
-
-
-
Otherwise, jump to the step labeled Abort update.
-
- "
executionMode
" -
-
If value is "
compatibility
", "frozen-context
", or "group-by-origin
", then set igโs execution mode to value. -
Otherwise, set igโs execution mode to "
compatibility
".
-
- "
biddingLogicURL
" - "
biddingWasmHelperURL
" - "
updateURL
" -
-
For each groupMember and interestGroupField, in the following table
Group member Interest group field " biddingLogicURL
"bidding url " biddingWasmHelperURL
"bidding wasm helper url " updateURL
"update url -
If key is not groupMember, continue.
-
If value is a string:
-
Let parsedURL be the result of parse and verify a bidding code or update URL on value and igโs owner.
-
If parsedURL is failure, jump to the step labeled Abort update
-
Set igโs interestGroupField to parsedURL.
-
-
-
- "
trustedBiddingSignalsURL
" -
-
If value is a string:
-
Let parsedURL be the result of parse and verify a trusted signals URL on value.
-
If parsedURL is failure, jump to the step labeled Abort update
-
Set igโs trusted bidding signals url to parsedURL.
-
-
- "
trustedBiddingSignalsKeys
" -
-
If value is a list of strings, set igโs trusted bidding signals keys to value.
-
Otherwise, jump to the step labeled Abort update.
-
- "
trustedBiddingSignalsSlotSizeMode
" -
-
If value is one of "none", "slot-size", or "all-slots-requested-sizes", set igโs trusted bidding signals slot size mode to value.
-
Otherwise, set trusted bidding signals slot size mode to "none".
-
- "
maxTrustedBiddingSignalsURLLength
" -
-
If value is a Number:
-
Let convertedValue be the result of converting value to a
long
. -
If convertedValue โฅ 0, then set igโs max trusted bidding signals url length to convertedValue.
-
-
Otherwise, jump to the step labeled Abort update.
-
- "
trustedBiddingSignalsCoordinator
" -
-
If value is null:
-
Set igโs trusted bidding signals coordinator to null.
-
-
If value is a string:
-
Let parsedCoordinator be the result of parsing an https origin on value.
-
If parsedCoordinator is a failure, jump to the step labeled Abort update.
-
Set igโs trusted bidding signals coordinator to parsedCoordinator.
-
-
- "
userBiddingSignals
" -
-
Set igโs user bidding signals to the result of serialize an Infra value to JSON bytes given value.
-
Otherwise, jump to the step labeled Abort update.
Serializing an Infra value to JSON bytes expects to be called within a valid ES realm. See infra/625
-
- "
adSizes
" -
-
Let adSizes be a new map whose keys are strings and values are ad sizes.
-
For each sizeName โ size of value:
-
If sizeName is "", jump to the step labeled Abort update.
-
Let adSize be the result from running parse an AdRender ad size with size.
-
If adSize is null, jump to the step labeled Abort update.
-
Set adSizes[sizeName] to adSize.
-
-
Set igโs ad sizes to adSizes.
-
- "
sizeGroups
" -
-
Let adSizes be igโs ad sizes.
-
Let sizeGroups be a new map whose keys are strings and values are strings.
-
For each sizeGroupName โ sizeList of value:
-
If sizeGroupName is "", jump to the step labeled Abort update.
-
For each sizeName of sizeList:
-
If sizeName is "" or adSizes[sizeName] does not exist, jump to the step labeled Abort update.
-
-
Set sizeGroups[sizeGroupName] to sizeList.
-
-
Set igโs size groups to sizeGroups.
-
- "
ads
" - "
adComponents
" -
-
For each groupMember and interestGroupField in the following table
Group member Interest group field " ads
"ads " adComponents
"ad components -
If key is not groupMember, continue.
-
If value is not a list of
AuctionAd
, jump to the step labeled Abort update. -
Let igAds be a new list of interest group ads.
-
For each ad of value:
-
Let igAd be a new interest group ad.
-
Let renderURL be the result of running the URL parser on ad["
renderURL
"]. -
Jump to the step labeled Abort update if any of the following conditions hold:
-
renderURL is failure;
-
renderURL scheme is not "
https
"; -
renderURL includes credentials.
-
-
Set igAdโs render url to renderURL.
-
-
Let sizeGroup be ad["
sizeGroup
}]. -
Jump to the step labeled Abort update if none of the following conditions hold:
-
Set igAdโs size group to sizeGroup.
-
-
If ad["
metadata
"] exists, then let igAdโs metadata be the result of serializing a JavaScript value to a JSON string, given ad["metadata
"]. If this throws, jump to the step labeled Abort update. -
If ad["
creativeScanningMetadata
"] exists, then set igAdโs creative scanning metadata to it. -
If groupMember is "
ads
":-
If ad["
buyerReportingId
"] exists then set igAdโs buyer reporting ID to it. -
If ad["
buyerAndSellerReportingId
"] exists then set igAdโs buyer and seller reporting ID to it. -
If ad["
selectableBuyerAndSellerReportingIds
"] exists then set igAdโs selectable buyer and seller reporting IDs to it.
-
-
Append igAd to igAds.
-
-
If igAds is not is empty:
-
Set igโs interestGroupField to igAds.
-
-
-
- "
additionalBidKey
" -
-
Let decodedKey be the result of running forgiving-base64 decode with value.
-
Jump to the step labeled Abort update if any of the following conditions hold:
-
decodedKey is a failure;
-
decodedKeyโs length is not 32;
-
-
Set igโs additional bid key to decodedKey.
-
- "
-
-
Jump to the step labeled Abort update if any of the following conditions hold:
-
igโs ads is not null, and igโs additional bid key is not null;
-
igโs estimated size is greater than 1048576 bytes.
-
-
Set igโs next update after to the current coarsened wall time plus 24 hours.
-
Set igโs last updated to the current coarsened wall time.
-
Replace the interest group that has igโs owner and name in the user agentโs interest group set with ig.
-
Run update k-anonymity cache for interest group for ig.
-
Abort update: We jump here if some part of the interest group update failed. Continue to the next interest group update.
-
-
To process updateIfOlderThanMs given an origin buyer, and an ordered map perInterestGroupData whose keys are name strings and whose values are bidding signals per interest group data:
-
For each igName โ perIgData of perInterestGroupData, the following steps should be done:
-
If perIgDataโs update if older than ms is null, continue.
-
Let updateIfOlderThan be a duration of perIgDataโs update if older than ms milliseconds.
-
Let ig be the interest group of the user agentโs interest group set whose owner is buyer and whose name is igName, or null if interest group set does not have such an interest group.
-
If ig is not null and the current coarsened wall time โ igโs last updated โฅ updateIfOlderThan:
-
Set igโs next update after to current coarsened wall time + updateIfOlderThan.
-
Replace the interest group that has igโs owner and name in the user agentโs interest group set with ig.
-
-
10. Feature Detection
The queryFeatureSupport()
method permits checking what functionality is
available in the current implementation, in order to help deploy new features. The return values
specified in this specification are for an implementation that fully implements it.
[SecureContext ]partial interface Navigator { [SameObject ]readonly attribute ProtectedAudience ; }; [
protectedAudience SecureContext ,Exposed =Window ]interface {
ProtectedAudience any queryFeatureSupport (DOMString ); };
feature
The queryFeatureSupport(feature)
method steps are:
-
Let featuresTable be an ordered map whose keys are
DOMString
s and whose values areboolean
s orlong
s, with the following entries:- "adComponentsLimit"
-
40
- "deprecatedRenderURLReplacements"
-
true
- "permitCrossOriginTrustedSignals"
-
true
- "realTimeReporting"
-
true
- "reportingTimeout"
-
true
- "trustedSignalsKVv2"
-
true
-
If feature is "*", then return featuresTable.
-
If featuresTable[feature] exists, then return featuresTable[feature].
-
Return
undefined
.
11. Common Algorithms
The following algorithms are some helper algorithms used in this specification.
The estimated size of an interest group ig is the sum of:
-
The length of the serialization of igโs owner.
-
8, which is the size of igโs priority.
-
4, which is the size of igโs execution mode.
Note: Each of execution modeโs value represents a
long
integer, so 4 bytes. -
2, which is the size of igโs enable bidding signals prioritization.
-
If igโs priority vector is not null, for each key โ value of priority vector:
-
The length of key.
-
8, which is the size of value.
-
-
If igโs priority signals overrides is not null, for each key โ value of priority signals overrides:
-
The length of key.
-
8, which is the size of value.
-
-
The length of the serialization of igโs Private Aggregation coordinator if the field is not null.
-
If igโs seller capabilities is not null, then for each seller โ capabilities of igโs seller capabilities:
-
The length of the serialization of seller.
-
4, which is capabilitiesโs underlying number of enum bytes.
-
-
The length of the serialization of igโs bidding url, if the field is not null.
-
The length of the serialization of igโs bidding wasm helper url, if the field is not null.
-
The length of the serialization of igโs update url, if the field is not null.
-
The length of the serialization of igโs trusted bidding signals url, if the field is not null.
-
4, which is the size of igโs trusted bidding signals slot size mode.
Note: Each of trusted bidding signals slot size modeโs value represents a
long
integer, so 4 bytes. -
If igโs trusted bidding signals keys is not null, for each key of it:
-
The length of key.
-
-
If igโs max trusted bidding signals url length is not null:
-
4, which is the size of igโs max trusted bidding signals url length.
-
-
If igโs trusted bidding signals coordinator is not null:
-
The length of the serialization of igโs trusted bidding signals coordinator.
-
-
The length of igโs user bidding signals.
-
If igโs ads is not null, for each ad of it:
-
The length of the serialization of adโs render url.
-
The length of adโs size group if the field is not null.
-
The length of adโs buyer reporting ID if the field is not null.
-
The length of adโs buyer and seller reporting ID if the field is not null.
-
If adโs selectable buyer and seller reporting IDs is not null, for each id of it:
-
The length of id.
-
-
If adโs allowed reporting origins is not null, for each origin of it:
-
The length of the serialization of origin.
-
-
The length of adโs creative scanning metadata if the field is not null.
-
-
If igโs ad components is not null, for each ad of it:
-
The length of the serialization of adโs render url.
-
The length of adโs size group if the field is not null.
-
The length of adโs creative scanning metadata if the field is not null.
-
-
If igโs ad sizes is not null, for each sizeName โ size of it:
-
The sum of the length of sizeName and 18 (representing the fixed length of size).
Note: 10 represents the size of 2 doubles for width and height (each 8 bytes), and 2 bytes for enums for width units and height units (each 1 byte).
-
-
If igโs size groups is not null, for each sizeGroupName โ sizeList of it:
-
If igโs additional bid key is not null:
-
32, which is its size (number of bytes).
-
-
Let url be the result of running the URL parser on input.
-
If url is failure, or its scheme is not "
https
", then return failure. -
Return urlโs origin.
-
If url is null, then return
undefined
. -
Return the serialization of url.
-
Let parsedUrl be the result of running the URL parser on input.
-
Return failure if any of the following conditions hold:
-
parsedUrl is failure;
-
parsedUrlโs origin is not same origin with igOwner;
-
parsedUrl includes credentials;
-
parsedUrlโs fragment is not null.
-
-
Return parsedUrl.
-
Let parsedUrl be the result of running the URL parser on input.
-
Return failure if any of the following conditions hold:
-
parsedUrl is failure;
-
parsedUrlโs scheme is not "
https
"; -
parsedUrl includes credentials;
-
parsedUrlโs fragment is not null;
-
parsedUrlโs query is not null.
-
-
Return parsedUrl.
double
value:
-
If value is not a valid floating-point number, return value.
-
Let valueExp be valueโs IEEE 754 biased exponent field minus 1023.
-
Let normValue be value multiplied by 2(โ1 ร valueExp).
-
If valueExp < โ128:
-
If value < 0, return โ0.
-
Otherwise, return 0.
-
-
If valueExp > 127:
-
If value < 0, return โโ.
-
Otherwise, return โ.
-
-
Let precisionScaledValue be normValue multiplied by 256.
-
Let noisyScaledValue be precisionScaledValue plus a random
double
value greater than or equal to 0 but less than 1. -
Let truncatedScaledValue be the largest integer not greater than noisyScaledValue.
-
Return truncatedScaledValue multiplied by 2(valueExp โ 8).
This would ideally be replaced by a more descriptive algorithm in Infra. See infra/201
-
Let uuidStr be an empty string.
-
For each i in the range from 1 to 36, inclusive:
-
Let unit be inputโs ith code unit.
-
If ยซ 8, 13, 18, 23 ยป contains i:
-
If unit is not 0x002D (-), then return an empty string.
-
-
Otherwise:
-
If unit is not an ASCII lower hex digit, then return an empty string.
-
Append unit to the end of uuidStr.
-
-
-
Return ASCII encoded uuidStr.
12. Permissions Policy Integration
This specification defines two policy-controlled features identified by the strings
"join-ad-interest-group
", and
"run-ad-auction
". Their default allowlists are "*
".
Move from "*
" to "self
"
(WICG/turtledove#522).
To check interest group permissions given an origin ownerOrigin, an environment settings object settings, and an enum joinOrLeave which is "join
" or "leave
":
-
If ownerOrigin is same origin with frameOrigin, then return true.
-
Let encodedFrameOrigin be the result of UTF-8 percent-encoding the serialized frameOrigin using component percent-encode set.
-
Let request be a new request with the following properties:
- URL
-
permissionsUrl
- header list
-
ยซ
Accept
:application/json
ยป - client
-
settings
- origin
-
"
client
" - mode
-
"
cors
" - referrer
-
"
no-referrer
" - credentials mode
-
"
omit
" - redirect mode
-
"
error
" - service-workers mode
-
none
- policy container
-
"
client
"
-
Let resource be null.
-
Fetch request with useParallelQueue set to true, and processResponseConsumeBody set to the following steps given a response response and null, failure, or a byte sequence responseBody:
-
If responseBody is null or failure, set resource to failure and return.
-
Let headers be responseโs header list.
-
Let mimeType be the result of extracting a MIME type from headers.
-
If mimeType is failure or is not a JSON MIME Type, set resource to failure and return.
-
Set resource to responseBody.
-
-
Wait for resource to be set.
-
If resource is failure, then return false.
-
Let permissions be the result of parsing JSON bytes to an Infra value with resource, returning false on failure.
-
If permissions is not an ordered map, then return false.
-
If joinOrLeave is "
join
" and permissions["joinAdInterestGroup
"] exists, then return permissions["joinAdInterestGroup
"]. -
If joinOrLeave is "
leave
" and permissions["leaveAdInterestGroup
"] exists, then return permissions["leaveAdInterestGroup
"]. -
Return false.
The browser may cache requests for permissionsUrl within a network partition.
In order to prevent leaking data, the browser must request permissionsUrl regardless of whether the user is a member of the ad interest group. This prevents a leak of the userโs ad interest group membership to the server.
13. Fetch Patch for Auction Headers
This section specifies a manner by which some data, including additional bids and direct from seller signals, may be provided to auctions such that the data is only used within their intended auction.
Any Document
in a traversable navigable may run a Protected Audience auction (with navigator
.runAdAuction()
) whose script runners functions receive signal
objects derived from JSON from an `Ad-Auction-Signals
` header, or additional bids derived from
an `Ad-Auction-Additional-Bid
` header, or response blobโs base64url encoded SHA-256 hash
derived from an `Ad-Auction-Result
` header, captured by a fetch()
call
(using the adAuctionHeaders
option) initiated by any other Document
in the same traversable navigable, or from an iframe navigation request (using the adauctionheaders
content attribute on the iframe
element).
Each traversable navigable has a captured ad auction signals headers, which is a map whose keys are direct from seller signals keys and whose values are direct from seller signals.
NOTE: This is only captured during a request whose initiator type is "fetch"
, made
with the adAuctionHeaders
option set to true
, or during an iframe navigation request with the adauctionheaders
content attribute set to true
, as described in the
`Ad-Auction-Signals
` header description.
Each traversable navigable has a captured ad auction additional bids headers, which is a map whose keys are auction nonces and whose values are lists of signed additional bid with metadata.
NOTE: This is only captured during a request whose initiator type is "fetch"
, made
with the adAuctionHeaders
option set to true
, or during an iframe navigation request with the adauctionheaders
content attribute set to true
, as described in the `Ad-Auction-Additional-Bid
` header description.
Each traversable navigable has a saved Bidding and Auction request context, which is a map. The mapโs keys are tuples consisting of the seller (origin) and the request ID (string representation of a version 4 UUID). The mapโs values are server auction request contexts.
Each traversable navigable has a captured ad auction result headers, which is a map whose keys are origins and values are strings.
Each traversable navigable has a captured ad auction result nonce headers, which is a map whose keys are origins and values are strings.
A request has an associated boolean capture-ad-auction-headers. Unless stated otherwise it is false.
RequestInit
dictionary to add an adAuctionHeaders attribute:
partial dictionary RequestInit {boolean ; };
adAuctionHeaders
new Request (input, init)
constructor steps, before
step "Set thisโs request to request":
-
If init["
adAuctionHeaders
"] exists, then set requestโs capture-ad-auction-headers to it.
iframe
element to add a adauctionheaders
content attribute.
The IDL attribute adAuctionHeaders
reflects the adauctionheaders
content attribute.
partial interface HTMLIFrameElement { [CEReactions ]attribute boolean ; };
adAuctionHeaders
-
If navigableโs container is an
iframe
element, and if it has aadauctionheaders
content attribute, then set requestโs capture-ad-auction-headers to true.
-
If requestโs capture-ad-auction-headers is true, then set a structured field value given ยซ`
Sec-Ad-Auction-Fetch
`, the boolean?1
ยป in httpRequestโs header list.
13.1. The `Sec-Ad-Auction-Fetch
` HTTP
request header
The `Sec-Ad-Auction-Fetch
` request header is an optional structured header with of type boolean. `Sec-Ad-Auction-Fetch
` will only
be set on a request whose initiator type is "fetch"
, made with the adAuctionHeaders
option set to true
, or on an iframe navigation request with the adauctionheaders
content attribute set to true
. If `Sec-Ad-Auction-Fetch
` is equal to ?1
,
the user agent will remove any `Ad-Auction-Signals
` or `Ad-Auction-Additional-Bid
` from the
returned response -- the `Ad-Auction-Signals
` or `Ad-Auction-Additional-Bid
` value will
instead only be used in Protected Audiences auctions.
13.2. The `Ad-Auction-Signals
` HTTP
response header
The `Ad-Auction-Signals
` response header provides value
of a JSON array of dictionaries, each with an adSlot
key. Protected Audience non-component,
component, and top-level auctions may specify which signals to load by the adSlot
key.
13.3. The `Ad-Auction-Additional-Bid
`
HTTP response header.
The `Ad-Auction-Additional-Bid
` response header provides value
of a string in the format of <auction nonce>:<seller nonce>:<base64-encoding of the signed additional bid>
, or the legacy format of <auction nonce>:<base64-encoding of the signed additional bid>
, either of which corresponds to a single additional bid. In the format that provides a
seller nonce, the seller nonce must be as described in seller nonce. The response may include more than one additional bid by specifying multiple instances
of the `Ad-Auction-Additional-Bid
` response header.
13.4. The `Ad-Auction-Result
`
HTTP response header.
The `Ad-Auction-Result
` response header provides the base64url encoded SHA-256 hash of the response blob. Multiple hashes can be included in a
response by either repeating the header or by specifying multiple hashes separated by a ",
" character.
Ad- Auction- Result: ungWv48Bz- pBQUDeXa4iI7ADYaOWF3qctBD_YfIAFa0= , 9 UTB- u- WshX66Xqz5DNCpEK9z- x5oCS5SXvgyeoRB1k=
is equivalent to
Ad- Auction- Result: ungWv48Bz- pBQUDeXa4iI7ADYaOWF3qctBD_YfIAFa0= Ad- Auction- Result: 9 UTB- u- WshX66Xqz5DNCpEK9z- x5oCS5SXvgyeoRB1k=
13.5. The `Ad-Auction-Result-Nonce
`
HTTP response header.
The `Ad-Auction-Result-Nonce
` response header provides the
canonical string representation of a version 4 UUID serving as a nonce. Multiple nonces
can be included in a response by either repeating the header or by specifying multiple
nonces separated by a ",
" character.
Ad- Auction- Result- Nonce: 7 d444840- 9 dc0- 11 d1- b245- 5 ffdce74fad2, e902893a- 9 d22- 3 c7e- a7b8- d6e313b71d9f
is equivalent to
Ad- Auction- Result- Nonce: 7 d444840- 9 dc0- 11 d1- b245- 5 ffdce74fad2 Ad- Auction- Result- Nonce: e902893a- 9 d22- 3 c7e- a7b8- d6e313b71d9f
-
Delete "`
Ad-Auction-Signals
`" from responseโs header list. -
Delete "`
Ad-Auction-Additional-Bid
`" from responseโs header list.
-
If response is not null, responseโs status is not a redirect status, fetchParamsโs task destination is a global object thatโs a
Window
object, and requestโs capture-ad-auction-headers istrue
:-
Let navigable be fetchParamsโs task destinationโs associated Documentโs node navigableโs traversable navigable.
-
Run update captured headers with navigableโs captured ad auction signals headers, navigableโs captured ad auction additional bids headers, navigableโs captured ad auction result headers, navigableโs captured ad auction result nonce headers, responseโs header list, and requestโs URLโs origin.
-
To update captured headers with a captured ad auction signals headers storedSignalsHeaders, captured ad auction additional bids headers storedAdditionalBidsHeaders, captured ad auction result headers storedAuctionResultHeaders, captured ad auction result nonce headers storedAuctionResultNonceHeaders, header list responseHeaders, and origin requestOrigin:
-
Let adAuctionSignals be the result of getting `
Ad-Auction-Signals
` from responseHeaders. -
If adAuctionSignals is not null:
-
Delete "`
Ad-Auction-Signals
`" from responseHeaders.NOTE: This step prevents the header value from being used outside the intended auctions โโthat is, scripts making the
fetch()
request arenโt able to load the header value. -
Handle ad auction signals header value given adAuctionSignals, storedSignalsHeaders and requestOrigin.
-
-
Let additionalBids be the result of getting, decoding, and splitting `
Ad-Auction-Additional-Bid
` from responseHeaders. -
If additionalBids is not null:
-
Delete "`
Ad-Auction-Additional-Bid
`" from responseHeaders.NOTE: This step prevents the header value from being used outside the intended auctions โโthat is, scripts making the
fetch()
request arenโt able to load the header value. -
For each bid of additionalBids:
-
Let parts be the result of strictly splitting bid on U+003A (:).
-
Let bidWithMetadata be a new signed additional bid with metadata.
-
If partsโs size is 3:
-
Let auctionNonce be parts[0].
-
Let sellerNonce be parts[1].
-
Let bidWithMetadataโs seller nonce be sellerNonce.
-
Let bidWithMetadataโs signed additional bid be parts[2].
-
Append bidWithMetadata to storedAdditionalBidsHeaders[auctionNonce].
-
-
Otherwise, if partsโs size is 2:
-
Let auctionNonce be parts[0].
-
Let bidWithMetadataโs signed additional bid be parts[1].
-
Append bidWithMetadata to storedAdditionalBidsHeaders[auctionNonce].
-
-
-
-
Let adAuctionResults be the result of getting, decoding, and splitting `
Ad-Auction-Result
` from responseHeaders. -
If adAuctionResults is not null, for each result of adAuctionResults:
-
Strip leading and trailing ASCII whitespace from result.
-
If result is "", or contains code points U+002B (
+
) or U+002F (/
), then continue. -
Replace every U+2212 (
-
) code point in result with U+002B (+
). -
Replace every U+005F(
_
) code point in result with U+002F (/
). -
Let hash be the result of running forgiving-base64 decode with result.
-
If hash is not failure, and hashโs length is 32:
-
-
Let adAuctionResultNonces be the result of getting, decoding, and splitting `
Ad-Auction-Result-Nonce
` from responseHeaders. -
Delete "`
Ad-Auction-Result-Nonce
`" from responseHeaders.NOTE: This step prevents the header value from being used outside the intended auctions โโthat is, scripts making the
fetch()
request arenโt able to load the header value. -
If adAuctionResultNonces is not null, for each result of adAuctionResultNonces:
-
Strip leading and trailing ASCII whitespace from result.
-
Let nonce be the result of getting uuid from string on result.
-
If nonce is "", then continue.
-
Let nonceString be the string representation of nonce.
-
If storedAuctionResultNonceHeaders[requestOrigin] exists, then append nonceString to storedAuctionResultNonceHeaders.
-
Otherwise, set storedAuctionResultNonceHeaders[requestOrigin] to ยซ nonceString ยป.
-
-
Let parsedSignals be the result of parsing JSON bytes to an Infra value, given adAuctionSignals.
-
If parsedSignals is failure or not a list, return.
-
Let headerAdSlots be a new ordered set.
-
For each signal of parsedSignals:
-
If signal is not an ordered map, continue.
-
If signal["
adSlot
"] doesnโt exist, continue. -
If headerAdSlots contains signal["
adSlot
"], continue. Optionally, report a warning to the console with a diagnostic error message indicating that a duplicate `Ad-Auction-Signals
`adSlot
dictionary was ignored. -
Append signal["
adSlot
"] to headerAdSlots. -
Let signalsKey be a new direct from seller signals key, with its seller set to requestOrigin and its ad slot set to signal["
adSlot
"]. -
Let processedSignals be a new direct from seller signals.
-
Remove signal["
adSlot
"]. -
For each key โ value of signal:
-
Switch on key:
- "
sellerSignals
" -
-
Set processedSignalsโs seller signals to the result of serializing an Infra value to a JSON string, given value.
-
- "
auctionSignals
" -
-
Set processedSignalsโs auction signals to the result of serializing an Infra value to a JSON string, given value.
-
- "
perBuyerSignals
" -
-
If value is not an ordered map, continue.
-
For each buyer โ buyerSignals of value:
-
Let buyerOrigin be the result of parsing an https origin on buyer.
-
If buyerOrigin is failure, continue.
-
Let buyerSignalsString be the result of serializing an Infra value to a JSON string, given buyerSignals.
-
Set processedSignalsโs per buyer signals[buyerOrigin] to buyerSignalsString.
-
-
- "
-
-
Set storedSignalsHeaders[signalsKey] to processedSignals.
-
14. Structures
typedef (long long or AuctionAd );
PreviousWinElement typedef sequence <PreviousWinElement >;
PreviousWin dictionary {
BiddingBrowserSignals required DOMString ;
topWindowHostname required USVString ;
seller required long ;
joinCount required long ;
bidCount required long ;
recency required long ;
adComponentsLimit required unsigned short ;
multiBidLimit record <DOMString ,DOMString >;
requestedSize USVString ;
topLevelSeller sequence <PreviousWin >;
prevWinsMs object ;
wasmHelper unsigned long ;
dataVersion unsigned long ;
crossOriginDataVersion boolean =
forDebuggingOnlyInCooldownOrLockout false ; };dictionary {
ScoringBrowserSignals required DOMString ;
topWindowHostname required USVString ;
interestGroupOwner required USVString ;
renderURL required unsigned long ;
biddingDurationMsec required DOMString ;
bidCurrency record <DOMString ,DOMString >;
renderSize unsigned long ;
dataVersion unsigned long ;
crossOriginDataVersion sequence <USVString >;
adComponents boolean =
forDebuggingOnlyInCooldownOrLockout false ;USVString ;
creativeScanningMetadata sequence <USVString ?>; };
adComponentsCreativeScanningMetadata
-
Let dict be a new empty map.
-
Let jsWidth be adSizeโs width, converted to an ECMAScript value.
-
Set dict["width"] to the result of concatenating ยซ ToString(jsWidth), adSizeโs width units ยป.
-
Let jsHeight be adSizeโs height, converted to an ECMAScript value.
-
Set dict["height"] to the result of concatenating ยซ ToString(jsHeight), adSizeโs height units ยป.
-
Return dict.
Note: ScoringBrowserSignals
โs adComponents
is undefined
when ad component descriptors is null or an empty list. It cannot be
an empty list.
dictionary {
ReportingBrowserSignals required DOMString ;
topWindowHostname required USVString ;
interestGroupOwner required USVString ;
renderURL required double ;
bid required double ;
highestScoringOtherBid DOMString ;
bidCurrency DOMString ;
highestScoringOtherBidCurrency USVString ;
topLevelSeller USVString ;
componentSeller USVString ;
buyerAndSellerReportingId USVString ; };
selectedBuyerAndSellerReportingId
ReportingBrowserSignals
includes browser signals both reportResult()
and reportWin()
get.
topWindowHostname
- Top-level originโs host
interestGroupOwner
- The winning interest groupโs owner.
renderURL
- The render URL returned by "
generateBid()
". It is k-anonymous bid
- Stochastically rounded winning bid. This is always in the bidderโs own currency
highestScoringOtherBid
- The stochastically rounded value of the bid that got the second highest score, or 0 if itโs not available. 0 for top-level auctions with components
bidCurrency
- The currency the
bid
is in highestScoringOtherBidCurrency
- The currency the
highestScoringOtherBid
is in topLevelSeller
- Copied from top level seller
componentSeller
- Copied from component seller
buyerAndSellerReportingId
-
There are two scenerios in which this can be set:
-
Set if the winning ad had a buyer and seller reporting ID and the winning bid did not have selected buyer and seller reporting ID set, and that value was jointly k-anonymous combined with interest group owner, bidding script URL, ad creative URL, and null.
-
Set if the wining bid had a selected buyer and seller reporting ID and the winning ad had a buyer and seller reporting ID set in its listing in the interest group, and that value was jointly k-anonymous combined with interest group owner, bidding script URL, ad creative URL, the and winning bidโs selected buyer and seller reporting ID.
-
selectedBuyerAndSellerReportingId
- A selected reporting id returned by "
generateBid()
". Set if the winning bid had a selected buyer and seller reporting ID set, and that value was jointly k-anonymous combined with buyer and seller reporting ID, interest group owner, bidding script URL, and ad creative URL.
dictionary :
ReportResultBrowserSignals ReportingBrowserSignals {required double ;
desirability DOMString ;
topLevelSellerSignals double ;
modifiedBid unsigned long ; };
dataVersion
desirability
- The stochastically rounded value of the score returned by "
scoreAd()
" for the winning bid topLevelSellerSignals
- Metadata returned by the top-level sellerโs "
reportResult()
", as JSON modifiedBid
- The stochastically rounded value of the bid value returned by the component
sellerโs "
scoreAd()
" method dataVersion
- Set to the value of the `
Data-Version
` header from the trusted scoring signals server, if any.
dictionary :
ReportWinBrowserSignals ReportingBrowserSignals {double ;
adCost USVString ;
seller boolean ;
madeHighestScoringOtherBid DOMString ;
interestGroupName DOMString ;
buyerReportingId unsigned short ;
modelingSignals unsigned long ;
dataVersion KAnonStatus ; };
kAnonStatus enum {
KAnonStatus ,
"passedAndEnforced" ,
"passedNotEnforced" ,
"belowThreshold" };
"notCalculated"
adCost
- Stochastically rounded winnerโs ad cost.
seller
- The origin of the seller running the ad auction
madeHighestScoringOtherBid
- True if the interest group owner was the only bidder that made bids with the second highest score
interestGroupName
-
Only set if all of the following are true:
-
The combination of the owner, name, bidding url, ad creative URL, and null are jointly k-anonymous.
-
The winning adโs buyer and seller reporting ID and buyer reporting ID are null.
-
The winning bidโs selected buyer and seller reporting ID is null.
-
buyerReportingId
-
There are two scenerios in which this can be set:
-
Set if the winning ad had a buyer reporting ID but not a buyer and seller reporting ID set in its listing in the interest group, and the winning bid did not have selected buyer and seller reporting ID set, and that value was jointly k-anonymous combined with interest group owner, bidding script URL, ad creative URL, and null.
-
Set if the wining bid had a selected buyer and seller reporting ID and the winning ad had a buyer reporting ID set in its listing in the interest group, and that value was jointly k-anonymous combined with interest group owner, bidding script URL, ad creative URL, buyer and seller reporting ID, and selected buyer and seller reporting ID.
-
modelingSignals
- A 0-4095 integer (12-bits) passed to
reportWin()
, with noising dataVersion
- Only set if the Data-Version header was provided in the response headers from the trusted bidding signals server
kAnonStatus
-
Indicate the k-anonymity status of the ad with the following
KAnonStatus
enums:-
passedAndEnforced
: The ad was k-anonymous and k-anonymity was required to win the auction. -
passedNotEnforced
: The ad was k-anonymous though k-anonymity was not required to win the auction. -
belowThreshold
: The ad was not k-anonymous but k-anonymity was not required to win the auction. -
notCalculated
: The browser did not calculate the k-anonymity status of the ad, and k-anonymity was not required to win the auction.
From a long-term perspective, the status will always be set to
passedAndEnforced
after k-anonymity is enforced. However, as a temporary solution, current implementations may setkAnonStatus
to one of the other three statuses to allow API users to assess the future impact of enforcing that ads are k-anonymous. -
dictionary {
DirectFromSellerSignalsForBuyer any =
auctionSignals null ;any =
perBuyerSignals null ; };
dictionary {
DirectFromSellerSignalsForSeller any =
auctionSignals null ;any =
sellerSignals null ; };
14.1. Interest group
An interest group is a struct with the following items:
- expiry
-
A moment at which the browser will forget about this interest group.
- owner
-
An origin. Frames that join interest groups owned by owner must either be served from owner, or another origin delegated by owner (See checking interest group permissions for details). The scheme must be "
https
". - name
-
A string. The (owner, name) tuple is a key that uniquely defines each interest group.
- priority
-
A
double
, initially 0.0. Used to select which interest groups participate in an auction when the number of interest groups are limited byperBuyerGroupLimits
. See applying interest groups limits to prioritized list. - enable bidding signals prioritization
-
A boolean, initially false. Being true if the interest groupโs priority should be calculated using vectors from bidding signals fetch.
- priority vector
-
Null or an ordered map whose keys are strings and whose values are
double
. Its dot product with theperBuyerPrioritySignals
will be used in place of priority, if set. - priority signals overrides
-
Null or an ordered map whose keys are strings and whose values are
double
. Overrides theAuctionAdConfig
โs corresponding priority signals. - seller capabilities
-
Null or an ordered map whose keys are origins and whose values are sets of seller capabilities. The seller capabilities this interest group grants to each seller.
- all sellers capabilities
-
Null or a set of seller capabilities. The default seller capabilities granted to sellers not listed in seller capabilities.
- Private Aggregation coordinator
-
An aggregation coordinator or null; where null specifies the default aggregation coordinator.
- execution mode
-
One of three possible values: "
compatibility
", "frozen-context
", or "group-by-origin
". Initially "compatibility
". Each value reprensents along
integer. TODO: Define spec for these execution modes, link to it from here and explain these modes. - bidding url
-
Null or a URL. The URL to fetch the buyerโs JavaScript from.
When non-null, the bidding urlโs origin will always be same origin with owner.
- bidding wasm helper url
-
Null or a URL. Lets the bidder provide computationally-expensive subroutines in WebAssembly, in addition to JavaScript, to be driven from the JavaScript function provided by bidding url.
When non-null, the bidding wasm helper urlโs origin will always be same origin with owner.
- update url
-
Null or a URL. Provides a mechanism for the groupโs owner to periodically update the attributes of the interest group. See ยงโฏ9 Interest Group Updates. Must be null if additional bid key is not null.
When non-null, the update urlโs origin will always be same origin with owner.
- trusted bidding signals url
-
Null or a URL. Provide a mechanism for making real-time data available for use at bidding time. See building trusted bidding signals url.
- trusted bidding signals keys
-
Null or a list of strings. See building trusted bidding signals url.
- trusted bidding signals slot size mode
-
"
none
", "slot-size
" or "all-slots-requested-sizes
". Initially "none
". Each value reprensents along
integer. See calculate the ad slot size query param. - max trusted bidding signals url length
-
A
long
integer, initially 0. Indicates the maximum trusted bidding signals fetch url length for the interest group. 0 means no limit. - trusted bidding signals coordinator
-
Null or an origin, initially null. This is used to specify where to obtain the public key used for encryption and decryption in communication with a trusted bidding signal server running in a Trust Execution Environment (TEE). When this field is specified, the request will be sent to a trusted bidding signals server running in a TEE, and the value of max trusted bidding signals url length is ignored.
- user bidding signals
-
Null or a string. Additional metadata that the owner can use during on-device bidding.
- ads
-
Null or a list of interest group ad. Contains various ads that the interest group might show. Must be null if additional bid key is not null.
- ad components
-
Null or a list of interest group ad. Contains various ad components (or "products") that can be used to construct ads composed of multiple pieces โ a top-level ad template "container" which includes some slots that can be filled in with specific "products".
- ad sizes
-
Null or a map whose keys are strings and values are ad sizes. Contains named sizes (width and height) that can be bound to ads to specify their render size.
- size groups
-
Null or a map whose keys are strings and values are lists of strings. Contains named collections of ad sizes that can be used to declare a bundle of possible sizes which all apply to one ad url.
- additional bid key
-
Null or a byte sequence of length 32. Must be null if ads or update url is not null. The Ed25519 public key (a 256-bit EdDSA public key) used to guarantee that this interest group, if used by an additional bid for a negative targeting, can only be used by its owner.
- joining origin
-
An origin. The top level page origin from where the interest group was joined.
- join counts
-
A list containing tuples of the day and per day join count. The day is calculated based on UTC time. The join count is a count of the number of times
joinAdInterestGroup()
was called for this interest group on the corresponding day. - join time
-
A moment at which the browser joined this interest group, updated upon each join and re-join.
- bid counts
-
A list containing tuples of the day and per day bid count. The day is calculated based on UTC time. The bid count is a count of the number of times the bid calculated during
runAdAuction()
was greater than 0. - previous wins
-
A list of previous wins.
- last updated
-
A moment when the interest group was last joined or successfully updated, whichever came later.
- next update after
-
A moment at which the browser will permit updating this interest group. See interest group updates.
A regular interest group is an interest group whose additional bid key is null.
A negative interest group is an interest group whose additional bid key is not null.
An interest group ad is a struct with the following items:
- render url
-
A URL. If this ad wins the auction, this URL (or a urn uuid that maps to this URL) will be returned by
runAdAuction()
. This URL is intended to be loaded into an adiframe
(or afencedframe
). - size group
-
Null or a string, initially null. The name of the size group (collection of render sizes) bound to this ad.
- metadata
-
Null or a string. Extra arbitary information about this ad, passed to
generateBid()
. - buyer reporting ID
-
Null or a string. Will be passed in place of interest group name to report win, or alongside the selected buyer and seller reporting ID, subject to k-anonymity checks. Only meaningful in ads, but ignored in ad components.
- buyer and seller reporting ID
-
Null or a string. Will be passed in place of interest group name or buyer reporting ID, or alongside the selected buyer and seller reporting ID, to report win and report result, subject to k-anonymity checks. Also passed alongside selected buyer and seller reporting ID to
scoreAd()
if selected buyer and seller reporting ID is present. Only meaningful in ads, but ignored in ad components. - selectable buyer and seller reporting IDs
-
Null or a list of strings. A list of reporting ids which will be sent to
generateBid()
, in order to allowgenerateBid()
to return a selected buyer and seller reporting ID. Only meaningful in ads, but ignored in ad components. - allowed reporting origins
-
Null or a list of origins. A list of up to 10 reporting origins that can receive reports with registered macros. Each originโs scheme must be "
https
" and each origin must be enrolled. Only meaningful in ads, but ignored in ad components. - ad render ID
-
A string containing up to 12 ASCII bytes uniquely identifying this ad. Sent instead of the full interest group ad for auctions executed on a server.
- creative scanning metadata
-
Null or a string, initially null. Sent with trusted scoring signals requests if send creative scanning metadata is true, and the basic HTTP GET based protocol, rather than encrypted one for TEE, is used.
A previous win is the interest groupโs auction win history, to allow on-device frequency capping. Itโs a struct with the following items:
- time
-
A moment. Approximate time the interest group won an auction.
- ad
-
An interest group ad. The ad that won the auction. Items except render url, metadata and ad render ID are excluded.
A seller capability is a permission granted by an interest group to sellers. Itโs
"interest-group-counts
" or "latency-stats
". Each value represents a single bit in a 4-byte byte sequence. The 4-byte byte sequence can store no more than 32 capabilities.
Note: More than 2 values, but probably not more than 32 values are planned, at least for a while. This way, there is not need to reserve more space for a while.
14.2. Currency tag
A currency tag is a string containing exactly 3 upper-case ASCII letters, or null. The null value is used to denote that the currency is unspecified.-
If currency is null, return "???".
-
Return currency.
-
If length of currencyString is not 3, return false.
-
If currencyString[0] is not a ASCII upper alpha code point, return false.
-
If currencyString[1] is not a ASCII upper alpha code point, return false.
-
If currencyString[2] is not a ASCII upper alpha code point, return false.
-
Return true.
-
If expected is null, return true.
-
If actual is null, return true.
-
If actual is equal to expected, return true.
-
Return false.
14.3. Auction config
An auction config is a struct with the following items:
- seller
-
An origin. The origin of the seller running the ad auction. The scheme must be "
https
". - decision logic url
-
Null or a URL. The URL to fetch the sellerโs JavaScript from. May be null when a server response is specified, otherwise is required.
The decision logic urlโs origin will always be same origin with seller.
- trusted scoring signals url
-
Null or a URL. Provide a mechanism for making real-time data (information about a specific ad creative) available for use at scoring time, e.g. the results of some ad scanning system.
- max trusted scoring signals url length
-
A
long
integer, initially 0. Indicates the maximum trusted scoring signals fetch url length for the auction config. 0 means no limit. - trusted scoring signals coordinator
-
Null or an origin, initially null. This is used to specify where to obtain the public key used for encryption and decryption in communication with a trusted scoring signal server running in a Trust Execution Environment (TEE). When this field is specified, the request will be sent to a trusted scoring signals server running in a TEE, and the value of max trusted scoring signals url length is ignored.
- send creative scanning metadata
-
A boolean, initially false. This controls whether additional fields used for creative scanning are passed with trusted scoring signals requests as query parameters (when the basic HTTP GET based protocol, rather than encrypted one for TEE, is used)
- interest group buyers
-
Null or a list of origins. Owners of interest groups allowed to participate in the auction. Each originโs scheme must be "
https
". - auction signals
-
Null, a string, a
Promise
, or failure. Opaque JSON data passed to both sellers' and buyers' script runners. - requested size
-
Null or an ad size, initially null. The size of the frame for the ad being selected by the auction.
- all slots requested sizes
-
Null or a non-empty ordered set of ad sizes, initially null. The sizes of all frames for ads being selected by any auction in the frame.
- seller signals
-
Null, a string, a
Promise
, or failure. Opaque JSON data passed to the sellerโs script runner. - seller timeout
-
A duration in milliseconds, initially 50 milliseconds. Restricts the runtime of the sellerโs
scoreAd()
script. If scoring does not complete before the timeout, the bid being scored is not considered further. - per buyer signals
-
Null, a
Promise
, failure, or an ordered map whose keys are origins and whose values are strings. Keys are buyers whose schemes must be "https
". Values are opaque JSON data passed to corresponding buyerโs script runner. - per buyer timeouts
-
Null, a
Promise
, failure, or an ordered map whose keys are origins and whose values are durations in milliseconds. Keys are buyers whose schemes must be "https
". Values restrict the runtime of corresponding buyerโsgenerateBid()
script. If the timeout expires, only the bid submitted viasetBid()
is considered. - all buyers timeout
-
A duration in milliseconds, initially 50 milliseconds. Restricts the
generateBid()
scriptโs runtime for all buyers without a timeout specified in per buyer timeouts. If the timeout expires, only the bid submitted viasetBid()
is considered. - per buyer cumulative timeouts
-
Null, a
Promise
, failure, or an ordered map whose keys are origins and whose values are durations in milliseconds. Keys are buyers whose schemes must be "https
". Values are collective timeouts for all interest groups of the buyer represented by the key. Includes the time of loading scripts and signals, and running thegenerateBid()
functions. Once the timer expires, the affected buyerโs interest groups may no longer generate any bids. All bids generated before the timeout will continue to participate in the auction. Implementations should attempt, on a best-effort basis, to generate bids for each buyer in priority order, so lower priority interest groups are the ones more likely to be timed out. IfPromise
s are passed in to the auction config for fields that support them, wait until configuration input promises resolve before starting the timer. - all buyers cumulative timeout
-
Null or a duration in milliseconds, initially null. Restricts a buyerโs cumulative timeout for all buyers without one specified in per buyer cumulative timeouts.
- per buyer group limits
-
Null or an ordered map whose keys are origins and whose values are
unsigned short
s. Keys are buyers whose schemes must be "https
". Values restrict the number of bidding interest groups for a particular buyer that can participate in an auction. - all buyers group limit
-
An
unsigned short
, initially 65535. Limit on the number of bidding interest groups for all buyers without a limit specified in per buyer group limits. - per buyer priority signals
-
Null or an ordered map whose keys are origins and whose values are ordered maps, whose keys are strings and whose values are
double
. Per-buyer sparse vector whose dot product with priority vector is used to calculate interest group priorities. No signalโs key starts with "browserSignals.", which is reserved for values coming from the browser. - all buyers priority signals
-
Null or an ordered map whose keys are strings and whose values are
double
. Merged with per buyer priority signals before calculating per-interest group priorities. In the case both have entries with the same key, the entry inper_buyer_priority_signals
takes precedence. No signals key start with "browserSignals.", which is reserved for values coming from the browser. - seller Private Aggregation coordinator
-
An aggregation coordinator, initially the default aggregation coordinator.
- required seller capabilities
-
A set of seller capabilities. The seller capabilities that each interest group must declare to participate in the auction. Interest groups that donโt declare all these capabilities will not participate in the auction.
- auction report buyer keys
-
A map from buyer origins to
bigint
s. For buyer metrics delegated to be reported to the seller via the Private Aggregation API, this determines the base bucket number used for a particular buyerโs information. - auction report buyers
-
A map from strings to
AuctionReportBuyersConfig
s. For buyer metrics delegated to be reported to the seller via the Private Aggregation API, this determines how each metric bucket is chosen inside the buyerโs space, and how to scale it. - auction report buyer debug details
-
A debug details, initially a new one. Configures Private Aggregation debugging functionality for buyer metrics delegated to be reported to the seller.
- component auctions
-
A list of auction configs. Nested auctions whose results will also participate in a top level auction. Only the top level auction config can have component auctions.
- deprecated render url replacements
-
Null, a
Promise
, failure, or a list of ad keyword replacements, each containing a single match and replacement. Render url replacements can only happen within a single seller auction config or within the component auction configs. - seller experiment group id
-
Null or an
unsigned short
, initially null. Optional identifier for an experiment group to support coordinated experiments with the sellerโs trusted server. - per buyer experiment group ids
-
An ordered map whose keys are origins and whose values are
unsigned short
s. Keys are buyers whose schemes must be "https
". Values are identifiers for experiment groups, to support coordinated experiments with buyers' trusted servers. - all buyer experiment group id
-
Null or an
unsigned short
, initially null. Optional identifier for an experiment group to support coordinated experiments with buyers' trusted servers for buyers without a specified experiment group. - pending promise count
-
An integer, initially 0. The number of things that are pending that are needed to score everything. It includes waiting for
Promise
s auction signals, per buyer signals, per buyer currencies, per buyer timeouts, direct from seller signals header ad slot, seller signals, oradditionalBids
whosePromise
s are not yet resolved. - config idl
- resolve to config
-
A boolean or a
Promise
, initially false. Whether the ad should be returned as aFencedFrameConfig
, or otherwise as a urn uuid. - seller currency
-
A currency tag. Specifies the currency bids returned by
scoreAd()
are expected to use, and which reporting for this auction will agree on. - per buyer currencies
-
A
Promise
or failure or an ordered map whose keys are origins and whose values are currency tags. Specifies the currency bids returned bygenerateBid()
orscoreAd()
in component auctions are expected to use. The initial value is an empty map. - all buyers currency
-
A currency tag. Specifies the currency bids returned by
generateBid()
orscoreAd()
in component auctions are expected to use if per buyer currencies does not specify a particular value. - per buyer multi-bid limits
-
An ordered map who keys keys are origins and whose values are
unsigned short
s.Specifies how many bids
generateBid()
is permitted to return at once for a particular buyer origin. The initial value is an empty map. - all buyers multi-bid limit
-
An
unsigned short
. Initially 1. Specifies how many bidsgenerateBid()
is permitted to return at once for buyers without a value in per buyer multi-bid limits. - direct from seller signals header ad slot
- auction nonce
-
Null or a version 4 UUID, initially null. A unique identifier associated with this and only this invocation of
navigator
.runAdAuction()
. For multi-seller auctions, this ID is uniquely associated with allcomponentAuctions
. This must come from a prior call tonavigator
.createAuctionNonce()
. This is only required for auctions that provide additional bids, and each of those additional bids must include the bid nonce derived from that auction nonce as computed by calculate expected bid nonce to ensure that each additional bid was intended for this and only this auction. For backwards compatibility, an additional bid may include the auction nonce directly in place of a bid nonce. - expects additional bids
-
A boolean or failure, initially false. Specifies whether some bids will be provided as signed exchanges. Sets to failure if the
additionalBids
Promise
is rejected. - seller real time reporting config
-
Null, or a string, initially null. Sellerโs real time reporting type. Currently the only supported type is "default-local-reporting" indicating local differential privacy. If not null, the seller opted in to receive real time reports.
- per buyer real time reporting config
-
An ordered map, whose keys are origins, and whose values are strings. Each buyerโs real time reporting type. Currently the only supported type is "default-local-reporting" indicating local differential privacy. All buyers in the map opted in to receive real time reports.
- server response
-
Null or a
Promise
or aUint8Array
containing an encrypted response from the trusted auction server. - server response id
-
Null or a version 4 UUID A UUID used to match a request from
navigator
.getInterestGroupAdAuctionData()
to the encrypted response stored in auction configโs server response field. Must be null when auction configโs server response is null, and non-null otherwise. - aborted
-
A boolean indicating whether the auction has been aborted, initially false.
- abort reason
-
any
.
-
Wait until either auctionConfigโs pending promise count is 0 or auctionConfigโs aborted is true.
-
If auctionConfigโs aborted is true, return failure.
-
Assert auctionConfigโs auction signals, seller signals, per buyer signals, per buyer currencies, per buyer timeouts, per buyer cumulative timeouts, deprecated render url replacements, and direct from seller signals header ad slot are not
Promise
s, and expects additional bids is false. -
If auctionConfigโs auction signals, seller signals, per buyer signals, per buyer currencies, per buyer timeouts, per buyer cumulative timeouts, deprecated render url replacements, or direct from seller signals header ad slot is failure, return failure.
-
Return.
-
For each componentAuctionConfig in auctionConfigโs component auctions:
-
If the result of waiting until configuration input promises resolve given componentAuctionConfig is failure, return failure.
-
-
Return the result of waiting until configuration input promises resolve given auctionConfig.
Promise
p, and two sequences of steps, covering the parsing of the value and error-handling:
-
Increment auctionConfigโs pending promise count.
-
Let resolvedAndTypeChecked be the promise representing performing the following steps upon fulfillment of p with result:
-
Execute the steps to be run for parsing of the value given result.
-
If no exception was thrown in the previous step, then decrement auctionConfigโs pending promise count.
-
-
Upon rejection of resolvedAndTypeChecked:
-
Execute the steps for error-handling.
-
Decrement auctionConfigโs pending promise count.
-
-
Wait until either auctionConfigโs server response is not a
Promise
, or auctionConfigโs aborted is true. -
If auctionConfigโs aborted is true, return failure.
-
If auctionConfigโs server response is failure, return failure.
-
Return.
-
Let perBuyerCurrency be auctionConfigโs all buyers currency
-
Assert that auctionConfigโs per buyer currencies is an ordered map.
-
If auctionConfigโs per buyer currencies[buyer] exists, then set perBuyerCurrency to auctionConfigโs per buyer currencies[buyer].
-
Return perBuyerCurrency
-
Let multiBidLimit be auctionConfigโs all buyers multi-bid limit.
-
If auctionConfigโs per buyer multi-bid limits[buyer] exists, then set multiBidLimit to auctionConfigโs per buyer multi-bid limits[buyer].
-
If multiBidLimit < 1, set multiBidLimit to 1.
-
Return multiBidLimit.
14.4. Bid generator
A per buyer bid generator is an ordered map whose keys are URLs or null representing trusted bidding signals urls, and whose values are per signals url bid generators. The key of null is used for interest groups that do not specify a trusted bidding signals url.
A per signals url bid generator is an ordered map whose keys are origins representing joining origins, and whose values are lists of interest groups.
14.5. Script fetcher
A script fetcher helps manage asynchronous fetching of scripts and handling of their headers. Itโs a struct with the following items:
- script body
-
A byte sequence, null, or failure. Initially null. The body of the script.
- origins authorized for cross origin trusted signals
-
A list of origins or null. Initially null. Parsed value of `
Ad-Auction-Allow-Trusted-Scoring-Signals-From
`. - fetch duration
-
A duration in milliseconds, denoting how long it took the fetch to complete.
-
Let fetcher be a new script fetcher.
-
Let queue be the result of starting a new parallel queue.
-
Enqueue the following steps to queue:
-
Fetch script given url, settings and fetcher.
-
-
Return fetcher.
-
Wait until fetcherโs script body is not null.
-
Return fetcherโs script body.
-
Wait until fetcherโs origins authorized for cross origin trusted signals is not null.
-
Return fetcherโs origins authorized for cross origin trusted signals.
The Ad-Auction-Allow-Trusted-Scoring-Signals-From
HTTP response
header is a structured header whose value must be a list of strings.
-
Let parsedHeader be the result of getting a structured field value given `
Ad-Auction-Allow-Trusted-Scoring-Signals-From
` and "list
" from headerList. -
If parsedHeader is null, return an empty list.
-
For each entry in parsedHeader:
-
Let parsedEntry be the result of parsing an https origin on entry.
-
If parsedEntry is failure, return an empty list.
-
Append parsedEntry to result.
-
Return result.
-
Let request be a new request with the following properties:
- URL
-
url
- header list
-
ยซ
Accept
:text/javascript
ยป - client
-
null
- origin
-
settingsโs origin
- mode
-
"
no-cors
" - referrer
-
"
no-referrer
" - credentials mode
-
"
omit
" - redirect mode
-
"
error
" - service-workers mode
-
"
none
" - policy container
-
A new policy container whose IP address space is settingsโs policy containerโs IP address space
Stop using "
no-cors
" mode where possible (WICG/turtledove#667). -
Let fetchStart be settingsโs current monotonic time.
-
Let fetchController be the result of fetching request with useParallelQueue set to true, and processResponse set to the following steps given a response response:
-
If the result of validating fetching response headers given response is false:
-
Abort fetchController.
-
Set fetcherโs origins authorized for cross origin trusted signals to an empty list of origins.
-
Set fetcherโs fetch duration to the duration from fetchStart to settingsโs current monotonic time, in milliseconds.
-
Set fetcherโs script body to failure.
-
Return.
-
-
Set fetcherโs origins authorized for cross origin trusted signals to the result of parsing allowed trusted scoring signals origins given responseโs header list.
-
Let bodyReader be result of getting a reader from bodyStream.
-
Let successSteps be a set of steps that take a byte sequence responseBody, and perform the following:
-
Set fetcherโs fetch duration to the duration from fetchStart to settingsโs current monotonic time, in milliseconds.
-
If validate fetching response mime and body with response, responseBody and "
text/javascript
" returns false, set fetcherโs script body to failure. -
Otherwise, set fetcherโs script body to responseBody.
-
-
Let failureSteps be a set of steps that take an exception e, and perform the following:
-
Set fetcherโs script body to failure.
-
-
Read all bytes from bodyReader, given successSteps and failureSteps.
-
14.6. Trusted bidding signals batcher
A trusted bidding signals batcher helps manage merging multiple trusted bidding signals into smaller number of fetches. Itโs a struct with the following items:
- all trusted bidding signals
-
An ordered map whose keys are strings, and values are strings. Contains all trusted bidding signals collected thus far.
- all per interest group data
-
An ordered map whose keys are name strings and whose values are bidding signals per interest group data.
- no signals flags
-
An ordered map whose keys are name strings and whose values are enums "no-fetch" or "fetch-failed". This is set to "not-fetched" if given interest group did not request any trusted bidding signals keys, or "fetch-failed" if its trusted signals fetch failed.
- data versions
-
An ordered map who keys are name strings and values are
unsigned long
or null. This contains data version returned by a fetch that provided the values for a given interest group name. - keys
-
An ordered set of strings. Describes the keys collected to be fetched in the current batch thus far.
- ig names
-
An ordered set of strings. Describes the interest group names to be fetched in the current batch thus far.
- length limit
-
A
long
, initially 2147483647 (the maximum value that it can hold). Describes the URL length limit the current batch is limited to, the smallest of the limits of the interest groups included. - key value interest groups
-
An ordered map whose keys are tuples of (an origin for joining origin, an origin for owner) and whose values are sets of interest groups.
A bidding signals per interest group data is a struct with the following items:
- update if older than ms
-
Null or a
double
. If non-null, it is the duration in milliseconds after which the interest group is eligible for an update, if it hasnโt been joined or updated within that duration. When eligible, the update is performed either following a call torunAdAuction()
, for each of the passedinterestGroupBuyers
, or explicitly by theupdateAdInterestGroups()
method.
A bidding compression group is a collection of bidding partitions that can be compressed together in the signals response. Itโs a struct with the following items:
- compression group id
-
An integer indicates the index of this compression group.
- partitions
-
A list of bidding partition. Contains all the bidding partitions belong to this compression group.
A bidding partition is a collection of keys and ig names that can be processed together by the service without any potential privacy leakage. Itโs a struct with the following items:
- id
-
An integer indicates the index of this partition.
- namespace
-
A map, whose keys are strings and values are list of strings. A namespace contains all names and trusted bidding signals keys in the partition.
- metadata
To append to a bidding signals per-interest group data map given an ordered map sourceMap, an ordered set igNames, and an ordered map destinationMap:
-
For each sourceKey โ sourceValue of sourceMap:
-
Let perGroupData be a new bidding signals per interest group data.
-
handle priority vector (WICG/turtledove#1144).
-
If sourceValue is not an ordered map, continue.
-
If sourceValue["
updateIfOlderThanMs
"] is adouble
:-
Let updateIfOlderThanMs be sourceValue["
updateIfOlderThanMs
"]. -
If updateIfOlderThanMs < 600,000, set updateIfOlderThanMs to 600,000.
Note: 600,000 milliseconds is 10 minutes.
-
Set perGroupDataโs update if older than ms to updateIfOlderThanMs.
-
-
If perGroupDataโs update if older than ms is not null, then set destinationMap[sourceKey] to perGroupData.
To build trusted bidding signals url given a URL signalsUrl, an ordered set of strings keys, an ordered set of strings igNames, an unsigned short
-or-null experimentGroupId, an origin topLevelOrigin, and a string slotSizeQueryParam:
-
Let queryParamsList be a new empty list.
Note: These steps create a query of the form "
&<name>=<values in comma-delimited list>
". E.g., "hostname=publisher1.com&keys=key1,key2&interestGroupNames=ad+platform,name2&experimentGroupId=1234
".
These steps donโt use the application/x-www-form-urlencoded serializer to construct the query string because it repeats a key if it has multiple values instead of a comma-demilited list (e.g., "keys=key1&keys=key2
", instead of "keys=key1,key2
"), and it also uses a different percent encode set from the Chrome implementation. -
Append "hostname=" to queryParamsList.
-
Append the result of UTF-8 percent-encoding the serialized topLevelOrigin using component percent-encode set to queryParamsList.
-
If keys is not empty:
-
Append "
&keys=
" to queryParamsList. -
Append to queryParamsList the result of encode trusted signals keys with keys.
-
-
If igNames is not empty:
-
Append "
&interestGroupNames=
" to queryParamsList. -
Append to queryParamsList the result of encode trusted signals keys with igNames.
-
-
If experimentGroupId is not null:
-
Append "
&experimentGroupId=
" to queryParamsList. -
Append serialized experimentGroupId to queryParamsList.
-
-
Append slotSizeQueryParam to queryParamsList.
-
Let fullSignalsUrl be signalsUrl.
-
Set fullSignalsUrlโs query to the result of concatenating queryParamsList.
-
Return fullSignalsUrl.
unsigned short
-or-null experimentGroupId, an origin topLevelOrigin, a string slotSizeQueryParam, and a policy container policyContainer:
-
If signalsUrl is null, return.
-
Let biddingSignalsUrl be the result of building trusted bidding signals url with signalsUrl, trustedBiddingSignalsBatcherโs keys, trustedBiddingSignalsBatcherโs ig names, experimentGroupId, topLevelOrigin, and slotSizeQueryParam.
-
Let ยซ partialTrustedBiddingSignals, partialPerInterestGroupData, dataVersion ยป be the result of fetching trusted signals with biddingSignalsUrl, scriptOrigin, policyContainer and true.
-
If partialTrustedBiddingSignals is not null:
-
For each key โ value in partialTrustedBiddingSignals, set trustedBiddingSignalsBatcherโs all trusted bidding signals[key] to value.
-
For each igName of trustedBiddingSignalsBatcherโs ig names, set trustedBiddingSignalsBatcherโs data versions[igName] to dataVersion.
-
Append to a bidding signals per-interest group data map with partialPerInterestGroupData, trustedBiddingSignalsBatcherโs ig names, and trustedBiddingSignalsBatcherโs all per interest group data.
-
-
Otherwise, for each igName of trustedBiddingSignalsBatcherโs ig names:
-
Set trustedBiddingSignalsBatcherโs no signals flags[igName] to "fetch-failed".
-
unsigned short
-or-null experimentGroupId, an origin topLevelOrigin, a string slotSizeQueryParam, and a policy container policyContainer:
-
Let igName be igโs name.
-
If signalsUrl is null:
-
Set trustedBiddingSignalsBatcherโs no signals flags [igName] to "no-fetch".
-
Return.
-
-
Set trustedBiddingSignalsBatcherโs no signals flags[igName] to "no-fetch" if igโs trusted bidding signals keys is null or is empty.
Note: An interest group with no trusted signals keys requests would still fetch and process per-interest group data like priorityVector and update if older than ms, but it will get null passed in to its bidding function.
-
If igโs trusted bidding signals coordinator is null:
-
Let putativeKeys be a clone of trustedBiddingSignalsBatcherโs keys.
-
Let putativeIgNames be a clone of trustedBiddingSignalsBatcherโs ig names.
-
Let putativeLengthLimit be igโs max trusted bidding signals url length.
-
If igโs max trusted bidding signals url length is 0 or > trustedBiddingSignalsBatcherโs length limit, then set putativeLengthLimit to trustedBiddingSignalsBatcherโs length limit.
-
If igโs trusted bidding signals keys is not null, extend putativeKeys with igโs trusted bidding signals keys.
-
Append igName to putativeIgNames.
-
Let biddingSignalsUrl be the result of building trusted bidding signals url with signalsUrl, putativeKeys, putativeIgNames, experimentGroupId, topLevelOrigin, and slotSizeQueryParam.
-
If serialized biddingSignalsUrlโs length โค putativeLengthLimit:
-
Set trustedBiddingSignalsBatcherโs keys to putativeKeys.
-
Set trustedBiddingSignalsBatcherโs ig names to putativeIgNames.
-
Set trustedBiddingSignalsBatcherโs length limit to putativeLengthLimit.
-
-
Otherwise:
-
Fetch the current outstanding trusted signals batch given trustedBiddingSignalsBatcher, signalsUrl, scriptOrigin, experimentGroupId, topLevelOrigin, slotSizeQueryParam, and policyContainer.
-
If igโs trusted bidding signals keys is not null, set trustedBiddingSignalsBatcherโs keys to a clone of igโs trusted bidding signals keys.
-
Otherwise, set trustedBiddingSignalsBatcherโs keys to a new list.
-
Set trustedBiddingSignalsBatcherโs ig names to ยซ igName ยป.
-
Set trustedBiddingSignalsBatcherโs length limit to igโs max trusted bidding signals url length.
-
-
-
Otherwise:
-
Let keyValueInterestGroups be trustedBiddingSignalsBatcherโs key value interest groups.
-
Let key be tuple of (igโs joining origin, igโs owner).
-
If keyValueInterestGroups contains key, append ig to keyValueInterestGroups[key].
-
Otherwise, set keyValueInterestGroups[key] to a set ยซ ig ยป.
-
To build trusted key value bidding signals request body given a set interestGroups,
an unsigned short
-or-null experimentGroupId, an origin topLevelOrigin, a string slotSizeQueryParam, an origin coordinator, and an origin owner:
-
Let compressionGroups be an empty list, whose items are bidding compression groups.
-
Let compressionGroupMap be an empty map, where the keys are integers as compression group id, and the values are maps with integers as keys for id, and bidding partitions as their values.
-
Let compressionIdMap be an empty map, whose keys are origins and values are integers.
-
Let interestGroupIdMap be an empty map, whose keys are strings and values are tuples of (integer, integer).
-
Let slotSizeParams be the result of strictly splitting slotSizeQueryParam on U+003D (=).
-
Let nextCompressionGroupId be 0.
-
For each group of interestGroups:
-
Let joiningOrigin be groupโs joining origin.
-
If compressionIdMap does not contain joiningOrigin:
-
Set compressionIdMap[joiningOrigin] to nextCompressionGroupId.
-
Increment nextCompressionGroupId by 1.
-
-
Let compressionGroupId be compressionIdMap[joiningOrigin].
-
If compressionGroupMap does not contain compressionGroupId:
-
Let partitionId be 0.
-
If groupโs execution mode is not "
group-by-origin
": -
Set interestGroupIdMap[groupโs name] to tuple of (compressionGroupId, partitionId).
-
If compressionGroupMap[compressionGroupId] does not contain partitionId, set compressionGroupMap[compressionGroupId][partitionId] to a bidding partition with the following items:
- id
-
partitionId
- namespace
-
The ordered map ยซ[ "interestGroupNames" โ ยซ groupโs name ยป, "biddingKeys" โ groupโs trusted bidding signals keys ]ยป
- metadata
-
The ordered map ยซ[ "experimentGroupId" โ experimentGroupId, slotSizeParams[0] โ slotSizeParams[1] ]ยป
-
Otherwise:
-
Append groupโs name into compressionGroupMap[compressionGroupId] [partitionId]["interest_group_names"].
-
Append groupโs trusted bidding signals keys into compressionGroupMap[compressionGroupId][partitionId]["bidding_keys"].
-
-
-
For each id โ group in compressionGroupMap:
-
Let compressionGroup be a bidding compression group, whose compression group id is id, and partition is an empty list.
-
Append compressionGroup to compressionGroups.
-
-
Let metadata be an empty map, whose keys and values are strings.
-
Let hostname be the result of UTF-8 percent-encoding the serialized topLevelOrigin using component percent-encode set.
-
Set metadata["hostname"] to hostname.
-
Let keyInfo be the result of looking up the server encryption key with owner and coordinator.
-
If keyInfo is failure, then return ยซ null, null, null ยป.
-
Let (requestBlob, context) be the result of generating request with keyInfo, metadata and compressionGroups. The generation method may follow that described in Section 2.2.4 of the Protected Audience Key Value Services.
-
Return ยซ requestBlob, interestGroupIdMap, context ยป.
unsigned short
-or-null experimentGroupId, an origin topLevelOrigin, a string slotSizeQueryParam, and a policy container policyContainer:
-
If signalsUrl is null, return.
-
For each (joiningOrigin, owner) โ interestGroups of key value interest groups:
-
Let ยซ requestBody, interestGroupIdMap, context ยป be the result of building trusted key value bidding signals request body with interestGroups, experimentGroupId, topLevelOrigin, slotSizeQueryParam, joiningOrigin and owner.
-
If requestBody is not null:
-
Let ยซ partialTrustedBiddingSignals, partialPerInterestGroupData, dataVersion ยป be the result of fetching trusted key value signals with signalsUrl, requestBody, context, scriptOrigin, policyContainer, interestGroupIdMap and true.
-
-
If partialTrustedBiddingSignals is not null:
-
For each key โ value in partialTrustedBiddingSignals, set trustedBiddingSignalsBatcherโs all trusted bidding signals[key] to value.
-
Let igNames be interestGroupIdMapโs keys.
-
For each igName of igNames, set trustedBiddingSignalsBatcherโs data versions[igName] to dataVersion[igName].
-
Append to a bidding signals per-interest group data map with partialPerInterestGroupData, igNames, and trustedBiddingSignalsBatcherโs all per interest group data.
-
-
Otherwise, for each igName of igNames:
-
Set trustedBiddingSignalsBatcherโs no signals flags[igName] to "fetch-failed".
-
-
14.7. Trusted scoring signals batcher
A trusted scoring signals batcher helps manage merging multiple trusted scoring signals requests into smaller number of fetches. Itโs a struct with the following items:
- request queue
-
A list of trusted scoring signals requests that hasnโt yet been organized to aid batching.
- request map
-
A map from a tuple of script fetcher, a URL representing the trusted signals base URL,
unsigned short
or null for experiment ID, origin or null for coordinator, and origin, representing the top frameโs origin, and a boolean representing whether to send creative scanning info, to a list of trusted scoring signals requests. This organizes fetches that can possibly be merged together. - url length limit
-
A
long
denoting a user-configured limit which should not be exceeded due to combining of fetches. 0 denotes no limit, and is the initial value.
A creative info is a struct with the following items:
- ad descriptor
-
An ad descriptor.
- creative scanning metadata
-
A string, initially empty.
- interest group owner
-
origin, or null.
- buyer or seller reporting id
-
A string, initially empty.
-
Let result be a new creative info.
-
If sendCreativeScanningMetadata is true:
-
Set resultโs ad descriptor to adDescriptor.
-
If bidAdโs creative scanning metadata is not null, set resultโs creative scanning metadata to it.
-
Set resultโs interest group owner to ownerOrigin.
-
If bidAdโs buyer and seller reporting ID is not null, set resultโs buyer or seller reporting id to it.
-
-
Otherwise:
-
Set resultโs ad descriptor to a new ad descriptor whose url to adDescriptorโs url.
-
-
Return result.
A trusted scoring signals request is a struct with the following items, representing all information needed to produce a trusted scoring signals fetch for a single scoring invocation:
- send creative scanning metadata
-
A boolean, to determine whether creative scanning metadata should be added to requests using the basic HTTP GET based protocol (rather than encrypted one for TEE).
- seller
-
An origin of the seller the fetch is on behalf of.
- seller script fetcher.
-
A script fetcher for the sellerโs decision logic script.
- base url
-
A URL, the base URL for trusted seller signals to fetch.
- seller experiment group id
-
Null or an
unsigned short
, initially null. - top level origin
-
An origin. The origin of top-level frame in the hierarchy containing the document running the auction.
- ad
-
The creative info for main ad to pass with the fetch.
- ad components
-
A set of creative info, information about component ads to pass with the fetch.
- policy container
-
A policy container to use for the network fetch.
- signal coordinator
-
An origin to use for the public key fetch.
- owner origin
-
An origin of the owner on behalf of the initial interest group.
- joining origin
-
An origin of the ownerโs joining origin on behalf of the initial interest group.
- reply
-
A trusted scoring signals reply, null, or failure. Initially null. Set to a non-null value when the fetch has been completed.
A trusted scoring signals reply is a struct with the following items
- all trusted scoring signals
-
A ordered map or failure.
- data version
-
An
unsigned long
or null.
A scoring compression group is a collection of scoring partitions that can be compressed together in the signals response. Itโs a struct with the following items:
- compression group id
-
An integer indicates the index of this compression group.
- partitions
-
A list of scoring partition. Contains all the scoring partitions belong to this compression group.
A scoring partition is a collection of ad and ad component render URLs that can be processed together by the service without any potential privacy leakage. Itโs a struct with the following items:
- id
-
An integer indicates the index of this partition.
- namespace
-
A map, whose keys are strings and values are list of strings. A namespace contains all URLs of ads and component ads in the partition.
- metadata
To create a trusted scoring signals batcher given a long
urlLengthLimit:
-
Let batcher be a new trusted scoring signals batcher.
-
Set batcherโs url length limit to urlLengthLimit.
-
Let queue be the result of starting a new parallel queue.
-
Enqueue the following steps to queue:
-
Batch and fetch trusted scoring signals given batcher.
-
-
Return batcher.
To fetch trusted scoring signals with batching given a trusted scoring signals batcher batcher and a trusted scoring signals request request:
-
Append request to batcherโs request queue.
-
Wait until requestโs reply is non-null.
-
Return requestโs reply.
-
For each creativeInfo in creativeInfoSet:
-
Append serialized creativeInfoโs ad descriptorโs url to result.
-
-
Return result.
-
For each creativeInfo in creativeInfoSet:
-
Append creativeInfoโs creative scanning metadata to result.
-
-
Return result.
-
For each creativeInfo in creativeInfoSet:
-
Append the serialization of creativeInfoโs interest group owner to result.
-
-
Return result.
-
For each creativeInfo in creativeInfoSet:
-
Append creativeInfoโs buyer or seller reporting id to result.
-
-
Return result.
-
If input is not empty:
-
Append param to queryParamsList.
-
Append the result of encode trusted signals keys of input to queryParamsList.
-
-
If input is not empty:
-
Append param to queryParamsList.
-
For each creative of input:
-
If creativeโs ad descriptorโs size is null, append "
,
" to sizes. -
Otherwise, append the result of converting an ad size to a string given creativeโs ad descriptorโs size to sizes.
-
-
Append the result of concatenating sizes with separator set to "," to queryParamsList.
Note: this works differently from other query parameters since it has a comma that we do not want to escape, and none of the other characters used to represent the width and height of each ad need to be escaped either.
-
unsigned short
experimentGroupId, and an origin topLevelOrigin:
Note: When trusted scoring signals fetches are not batched, adsโs size is 1.
-
Let queryParamsList be a new empty list.
-
Append "hostname=" to queryParamsList.
-
Append the result of UTF-8 percent-encoding topLevelOrigin using component percent-encode set to queryParamsList.
-
Let renderURLs be the result of extracting URLs from creative info given ads.
-
Add trusted signals param if needed given "
&renderURLs=
", renderURLs, queryParamsList. -
Let adComponentRenderURLs be the result of extracting URLs from creative info given componentAds.
-
If adComponentRenderURLs is not empty:
-
Add trusted signals param if needed given "
&adComponentRenderURLs=
", adComponentRenderURLs, queryParamsList. -
If experimentGroupId is not null:
-
Append "
&experimentGroupId=
" to queryParamsList. -
Append serialized experimentGroupId to queryParamsList.
-
-
If sendCreativeScanningMetadata is true:
-
Add trusted signals param if needed given "
&adCreativeScanningMetadata=
", the result of extracting creative scanning metadata given ads, queryParamsList. -
Add trusted signals param if needed given "
&adComponentCreativeScanningMetadata=
", the result of extracting creative scanning metadata given componentAds, queryParamsList. -
Add trusted signals size param if needed given "
&adSizes=
", ads, queryParamsList. -
Add trusted signals size param if needed given "
&adComponentSizes=
", componentAds, queryParamsList. -
Add trusted signals param if needed given "
&adBuyer=
", the result of extracting buyers given ads, queryParamsList. -
Add trusted signals param if needed given "
&adComponentBuyer=
", the result of extracting buyers given componentAds, queryParamsList. -
Add trusted signals param if needed given "
&adBuyerAndSellerReportingIds=
", the result of extracting buyer and seller reporting ids given ads, queryParamsList.
-
-
Set signalsUrlโs query to the result of concatenating queryParamsList.
-
Return signalsUrl.
-
Let firstEntry be entriesToBatch[0].
-
Let ads be an empty ordered set of creative info.
-
Let componentAds be an empty ordered set of creative info.
-
For each entry of entriesToBatch:
-
Assert that entryโs base URL is equal to firstEntryโs base URL.
-
Assert that entryโs seller experiment group id is equal to firstEntryโs seller experiment group id.
-
Assert that entryโs top level origin is equal to firstEntryโs top level origin.
-
Assert that entryโs seller script fetcher is equal to firstEntryโs seller script fetcher.
-
Assert that entryโs policy container is equal to firstEntryโs policy container.
-
Assert that entryโs send creative scanning metadata is equal to firstEntryโs send creative scanning metadata.
-
Extend componentAds with entryโs ad components.
-
-
Return the result of building trusted scoring signals url with firstEntryโs send creative scanning metadata, firstEntryโs base URL, ads, componentAds, firstEntryโs seller experiment group id, firstEntryโs top level origin.
-
If the size of entriesToBatch is 1, return true.
-
If batcherโs url length limit is 0, return true.
-
Return whether the length of the result of building batched trusted scoring signals url for entriesToBatch โค batcherโs url length limit.
To build trusted key value scoring signals request body given a non-empty list of trusted scoring signals requests entriesToBatch:
-
Let firstRequest be entriesToBatch[0].
-
Let compressionGroups be an empty list, whose items are scoring compression groups.
-
Let compressionGroupMap be an empty map, where the keys are integers as compression group id, and the values are maps with integers as keys for id, and scoring partitions as their values.
-
Let compressionIdMap be an empty map, whose keys are tuples of (origin, origin) and values are integers.
-
Let renderUrlIdMap be an empty map, whose keys are URLs and values are tuples of (interger, integer).
-
Let nextCompressionGroupId be 0.
-
For each request of entriesToBatch:
-
Let mapKey be a tuple of (requestโs owner origin, requestโs joining origin).
-
If compressionIdMap does not contain mapKey:
-
Set compressionIdMap[mapKey] to nextCompressionGroupId.
-
Increment nextCompressionGroupId by 1.
-
-
Let compressionGroupId be compressionIdMap[mapKey].
-
If compressionGroupMap does not contain compressionGroupId, then set compressionGroupMap[compressionGroupId] to an empty map, whose keys are integers.
-
Let partitionId be size of compressionGroupMap[compressionGroupId].
-
Let renderURL be requestโs adโs ad descriptorโs url.
-
Let adComponentRenderURLs be the result of extracting URLs from creative info given requestโs ad components.
-
Set renderUrlIdMap[renderURL] to tuple of (compressionGroupId, partitionId).
-
Set compressionGroupMap[compressionGroupId][partitionId] to a scoring partition with the following items:
- id
-
partitionId
- namespace
-
The ordered map ยซ[ "renderUrls" โ ยซ renderURL ยป, "adComponentRenderUrls" โ adComponentRenderURLs ]ยป
- metadata
-
The ordered map ยซ[ "experimentGroupId" โ firstRequestโs seller experiment group id ]ยป
-
-
For each id โ group in compressionGroupMap:
-
Let compressionGroup be an scoring compression group whose compression group id is id and partition is an empty list.
-
For each partition in groupโs values:
-
Append partition to compressionGroupโs partitions.
-
-
Append compressionGroup to compressionGroups.
-
-
Let metadata be an empty map, whose keys and values are strings.
-
Let hostname be the result of UTF-8 percent-encoding the serialized firstRequestโs top level origin using component percent-encode set.
-
Set metadata["hostname"] to hostname.
-
Let keyInfo be the result of looking up the server encryption key with firstRequestโs seller and firstRequestโs signal coordinator.
-
If keyInfo is failure, then return ยซ null, null, null ยป.
-
Let (requestBlob, context) be the result of generating request with keyInfo, metadata and compressionGroups. The generation method may follow that described in Section 2.2.4 of the Protected Audience Key Value Services.
-
Return ยซ requestBlob, renderUrlIdMap and context ยป.
To build batched trusted key value scoring signals request body given a non-empty list of trusted scoring signals requests entriesToBatch:
-
Let firstEntry be entriesToBatch[0].
-
For each entry of entriesToBatch:
-
Assert that entryโs base URL is equal to firstEntryโs base URL.
-
Assert that entryโs seller is equal to firstEntryโs seller.
-
Assert that entryโs seller experiment group id is equal to firstEntryโs seller experiment group id.
-
Assert that entryโs top level origin is equal to firstEntryโs top level origin.
-
Assert that entryโs seller script fetcher is equal to firstEntryโs seller script fetcher.
-
Assert that entryโs policy container is equal to firstEntryโs policy container.
-
-
Return the result of building trusted key value scoring signals request body with entriesToBatch.
To batch and fetch trusted scoring signals given a trusted scoring signals batcher batcher:
-
Assert that these steps are running in parallel.
-
Until batcher is no longer needed:
-
Wait until at least one of the following is true:
-
batcherโs request queue is not empty.
-
batcherโs request map is not empty and some heuristically chosen amount of time has passed.
-
-
Atomically do:
-
Let incomingRequests be a clone of batcherโs request queue.
-
Empty batcherโs request queue.
Note: the result of atomicity is that any concurrent attempts to modify batcherโs request queue while these steps are running will not result in different items being removed by the Empty operation than were cloned into incomingRequests.
-
-
For each request in incomingRequests:
-
Let key be (requestโs seller script fetcher, requestโs base url, requestโs seller experiment group id, requestโs top level origin, requestโs signal coordinator, requestโs send creative scanning metadata).
-
If batcherโs request map[key] does not exist, then set batcherโs request map[key] to an empty list.
-
Append request to batcherโs request map[key].
-
-
Some number of times, heuristically, select a key from batcherโs request map:
-
If keyโs signal coordinator is null:
-
Select a non-empty subset of batcherโs request map[key], called entriesToBatch, such that checking if trusted scoring signals batch honors URL length limit on batcher and entriesToBatch returns true:
Note: implementations are free to wait to collect more requests to merge (by leaving things in the batcherโs request map), or send them individually, but need to take into account the configured URL length limit if they do combine requests. All entries need to be handled eventually.
-
Remove entriesToBatch from batcherโs request map[key].
-
If batcherโs request map[key] is empty, then remove key from batcherโs request map.
-
Let fullSignalsUrl be the result of building batched trusted scoring signals url for entriesToBatch.
-
Let seller be entriesToBatch[0]'s seller.
-
Let scriptFetcher be entriesToBatch[0]'s seller script fetcher.
-
If fullSignalsUrlโs origin is not same origin with seller then:
-
Let allowCrossOriginTrustedScoringSignalsFrom be the result of wait for cross origin trusted scoring signals authorization from a fetcher given scriptFetcher.
-
If allowCrossOriginTrustedScoringSignalsFrom does not contain fullSignalsUrlโs origin, set fullSignalsUrl to null.
-
-
Let result be failure.
-
If fullSignalsUrl is not null:
-
Let ยซallTrustedScoringSignals, ignored, scoringDataVersionยป be the result of fetching trusted signals with fullSignalsUrl, seller, entriesToBatch[0]'s policy container, and false.
-
If allTrustedScoringSignals is an ordered map:
-
Set result to a new trusted scoring signals reply
-
Set resultโs all trusted scoring signals to allTrustedScoringSignals.
-
Set resultโs data version to scoringDataVersion.
-
-
-
For each entry in entriesToBatch:
-
Set entryโs reply to result.
-
-
-
-
Otherwise:
-
Select a non-empty subset of batcherโs request map[key], called entriesToBatch.
-
Remove key from batcherโs request map.
-
Let ยซ requestBody, renderUrlIdMap, context ยป be the result of building batched trusted key value scoring signals request body for entriesToBatch.
-
Let baseUrl be entriesToBatch[0]'s base url.
-
Let seller be entriesToBatch[0]'s seller.
-
Let scriptFetcher be entriesToBatch[0]'s seller script fetcher.
-
If baseUrlโs origin is not same origin with seller then:
-
Let allowCrossOriginTrustedScoringSignalsFrom be the result of wait for cross origin trusted scoring signals authorization from a fetcher given scriptFetcher.
-
If allowCrossOriginTrustedScoringSignalsFrom does not contain baseUrlโs origin, set baseUrl to null.
-
-
Let allTrustedScoringSignals be failure.
-
If baseUrl and requestBody are not null, let ยซallTrustedScoringSignals, ignored, scoringDataVersionMapยป be the result of fetching trusted key value signals with baseUrl, requestBody, context, seller, entriesToBatch[0]'s policy container, renderUrlIdMap and false.
-
If allTrustedScoringSignals is an ordered map:
-
For each entry in entriesToBatch:
-
Let result be a new trusted scoring signals reply.
-
Set resultโs all trusted scoring signals to allTrustedScoringSignals.
-
If scoringDataVersionMap is not null:
-
Let renderURL be entryโs adโs ad descriptorโs url.
-
Set resultโs data version to scoringDataVersionMap[serialized renderURL].
-
-
Set entryโs reply to result.
-
-
-
Otherwise, for each entry in entriesToBatch:
-
Set entryโs reply to failure.
-
-
-
-
14.8. Generated bid
A generated bid is a bid that needs to be scored by the seller. The bid is either the
result of evaluating a bidding script, or an additional bid provided by the
`Ad-Auction-Additional-Bid
` response headers. Itโs a struct with the following items:
- reporting id
-
A reporting bid key or null, initially null. Used to identify a generated bid.
- for k-anon auction
-
A boolean, initially true. If this is false, the bid is only used to determine the hypothetical winner with no k-anonymity constraints, which would be used to update k-anonymity counts only.
- bid
-
A bid with currency, or null. If not null and the value is zero or negative, then this interest group will not participate in the auction. This field should only be null if the top-level auction is performed on a trusted auction server.
- bid in seller currency
-
A
double
or null. An equivalent of the original bid in sellerโs currency. This is either the original bid if the currency already matched, or a conversion provided byscoreAd()
. - ad
-
A string. JSON string to be passed to the scoring function.
TODO: Check whether ad descriptor can be moved to bid ad to avoid duplication (WICG/turtledove#868).
- ad descriptor
-
An ad descriptor. Render URL and size of the bidโs ad.
- ad component descriptors
-
Null or a list of ad descriptors. Ad components associated with bid, if any. Will be limited to at most 40 items (and if
targetNumAdComponents
was specified, it will have exactly that many items) by the time the bid participates in the auction. Must be null if the interest group making this bid has a null ad components field. - selected buyer and seller reporting ID
-
Null or string. The selected reporting id from the selectable buyer and seller reporting IDs within the interest group. If present, this will be:
-
Passed alongside buyer reporting ID and buyer and seller reporting ID to report win subject to k-anonymity checks.
-
Passed alongside buyer and seller reporting ID to report result subject to k-anonymity checks.
-
Passed alongside buyer and seller reporting ID to
scoreAd()
.
-
- ad cost
-
Null or a
double
. Advertiser click or conversion cost passed fromgenerateBid()
toreportWin()
. Negative values will be ignored and not passed. Will be stochastically rounded when passed. - modeling signals
-
Null or an
unsigned short
. A 0-4095 integer (12-bits) passed toreportWin()
, with noising. - interest group
-
An interest group, whose
generateBid()
invocation generated this bid, or specified by the additional bid. - bid ad
-
The interest group ad within interest group to display.
- bid ad components
-
A list of interest group ad ad components within interest group to display.
- modified bid
-
Null or a bid with currency. Being null for top level auction. The bid value a component auctionโs
scoreAd()
script returns. - bid duration
-
A duration in milliseconds. How long it took to run
generateBid()
. - provided as additional bid
-
A boolean, initially false.
- component seller
-
Null or an origin. Seller in component auction which the interest group is participating. Only set for component auctions, null otherwise.
- target number of ad components
-
Null or
unsigned long
, initially null. Set if the bidder requested ad component descriptors they provided to be reduced to the given target, taking in account k-anonymity. - number of mandatory ad components
-
unsigned long
, initially 0. Only relevant if target number of ad components is set. Requires the first that many given ad components to be included.
To apply any component ads target to a bid, given a generated bid generatedBid:
-
If generatedBidโs target number of ad components is null, return.
-
Assert that generatedBidโs ad component descriptors is not null.
-
While generatedBidโs ad component descriptorsโs size > target number of ad components:
-
Remove the last value from generatedBidโs ad component descriptors.
-
To try to reach component ads target considering k-anonymity, given a generated bid generatedBid:
-
If generatedBidโs target number of ad components is null, return false.
-
Let ig be generatedBidโs interest group.
-
Let selectedComponents be a new list of ad descriptors.
-
For each i of get the indices of generatedBid:
-
Let candidateComponent be generatedBidโs ad component descriptors[i].
-
Compute componentAdHashCode by getting the result of compute the key hash of component ad given candidateComponentโs render url.
-
If query k-anonymity cache given igโs owner, igโs name, and componentAdHashCode returns true:
-
Append candidateComponent to selectedComponents.
-
-
Otherwise:
-
If i < generatedBidโs number of mandatory ad components, return false.
-
-
-
If selectedComponentsโs size < generatedBidโs target number of ad components, return false.
-
Set generatedBidโs ad component descriptors to selectedComponents.
-
Apply any component ads target to a bid given generatedBid.
-
Return query generated bid k-anonymity count given generatedBid.
To adjust bid list based on k-anonymity given a list of generated bids bidsBatch:
-
Let bidsToScore be a new list of generated bids
-
For each generatedBid of bidsBatch:
-
Let bidCopy be a clone of generatedBid.
-
Set bidCopyโs for k-anon auction to false.
-
Apply any component ads target to a bid given bidCopy.
-
Append bidCopy to bidsToScore
-
Let selectedReportingId be a string-or-null that is set to null.
-
If generatedBidโs selected buyer and seller reporting ID is not null, set selectedReportingId to it.
-
Let igAd be the interest group ad from generatedBidโs interest groupโs ads whose render url is generatedBidโs ad descriptorโs url.
-
Let isBidKAnon be the result of query generated bid k-anonymity count given generatedBid.
-
If isBidKAnon is true and running query reporting ID k-anonymity count with generatedBidโs interest group, igAd, selectedReportingId is true:
-
Append generatedBid to bidsToScore.
Note: Conceptually, a bid thatโs already k-anonymous is considered for both the k-anonymous and non-enforcing-k-anonymity leadership, which is represented here in the specification by two separate generated bid objects that get scored independently. An implementation does not, however, actually need to perform the relevant work twice.
-
-
Otherwise, if the result of applying try to reach component ads target considering k-anonymity given generatedBid is true:
-
Append generatedBid to bidsToScore.
-
-
-
Return bidsToScore.
A bid debug reporting info is a struct with the following items:
- component seller
-
Null or an origin. Seller in component auction which was running to produce this reporting information. Only set for component auctions, null otherwise.
- interest group owner
-
An origin. Matches owner of the interest group that was used to call
generateBid()
to produce this reporting information. - bidder debug win report url
-
Null or a URL, initially null. Set by
generateBid()
โsforDebuggingOnly
โsreportAdAuctionWin(url)
. - bidder debug loss report url
-
Null or a URL, initially null. Set by
generateBid()
โsforDebuggingOnly
โsreportAdAuctionLoss(url)
. - seller debug win report url
-
Null or a URL, initially null. In the case of a component auction, these are the values from component seller that the scored ad was created in. Set by
scoreAd()
โsforDebuggingOnly
โsreportAdAuctionWin(url)
. - seller debug loss report url
-
Null or a URL, initially null. In the case of a component auction, these are the values from component seller that the scored ad was created in. Set by
scoreAd()
โsforDebuggingOnly
โsreportAdAuctionLoss(url)
. - top level seller debug win report url
-
Null or a URL, initially null. Set in the case this bid was made in a component auction, won it, and was then scored by the top-level seller. Set by top-level sellerโs
scoreAd()
โsforDebuggingOnly
โsreportAdAuctionWin(url)
. - top level seller debug loss report url
-
Null or a URL, initially null. Set in the case this bid was made in a component auction, won it, and was then scored by the top-level seller. Set by top-level sellerโs
scoreAd()
โsforDebuggingOnly
โsreportAdAuctionLoss(url)
. - server filtered debugging only reports
-
A map whose keys are origins and whose values are lists of urls. forDebuggingOnly reports that have been filtered (also downsampled) by the trusted auction server.
A bid with currency is a struct with the following items:
- value
-
A
double
. The value of the bid. - currency
-
A currency tag. The currency the bid is in.
An ad descriptor is a struct with the following items:
- url
-
A URL, which will be rendered to display the ad creative if this bid wins the auction.
- size
-
Null or an ad size, initially null.
An ad size is a struct with the following items:
- width
-
A
double
. - width units
-
A string. Can only be one of "px" (pixel), "sh" (screen height), and "sw" (screen width).
- height
-
A
double
. - height units
-
A string. Can only be one of "px" (pixel), "sh" (screen height), and "sw" (screen width).
-
If either adSlotSize["height"] or adSlotSize["width"] does not exist, return null.
-
Let width and widthUnit be the dimension and dimension unit that results from running parse an AdRender dimension value with adSlotSize["width"], respectively.
-
If width is null, return null.
-
Let height and heightUnit be the dimension and dimension unit that results from running parse an AdRender dimension value with adSlotSize["height"], respectively.
-
If height is null, return null.
-
Let adSize be a new ad size.
-
Set adSizeโs width to width, width units to widthUnit, height to height, height units to heightUnit.
-
Return adSize.
An ad keyword replacement is a struct with the following items:
- match
-
A string, represents the match within a
renderURL
, that is going to be replaced by replacement. Must be in the format${...}
or%%...%%
. - replacement
14.9. Direct from seller signals
A direct from seller signals key is a struct with the following items:
- seller
-
An origin. Matches the origin that served the captured `
Ad-Auction-Signals
` header. - ad slot
-
A string. Matches the
adSlot
key of the JSON dictionaries in the top-level array of the `Ad-Auction-Signals
` value.
A direct from seller signals is a struct with the following items:
- auction signals
-
Null or a string. Opaque JSON data passed to both buyers' and the sellerโs script runners.
- seller signals
-
Null or a string. Opaque JSON data passed to the sellerโs script runner.
- per buyer signals
-
A map whose keys are origins and whose values are strings. Keys are buyers whose scheme must be "
https
". Values are opaque JSON data passed to corresponding buyerโs script runner.
14.10. Additional bids
A signed additional bid with metadata is a struct with the following items:
- signed additional bid
-
A string for an encoded additional bid.
- seller nonce
-
Null or a string. If present, represents the randomly-generated seller nonce returned in the `
Ad-Auction-Additional-Bid
` response header. This must be 36 characters, and should be the canonoical string representation of a version 4 UUID.
14.11. Score ad output
The output of running a Protected Audience scoreAd()
script, is represented using the following type:
dictionary {
ScoreAdOutput required double ;
desirability double ;
bid DOMString ;
bidCurrency double ;
incomingBidInSellerCurrency boolean =
allowComponentAuction false ; };
Either a dictionary of this type, or a double
, are handled as the return values.
The meanings of the fields are as follows:
desirability
- Numeric score of the bid. Must be positive or the ad will be rejected. The winner of the auction is the bid which was given the highest score.
bid
- Only relevant if this is a component auction. If present, this will be passed to the top-level
sellerโs
scoreAd()
andreportResult()
methods instead of the original bid, if the ad wins the component auction and top-level auction, respectively. bidCurrency
- Only relevant if this is a component auction and
bid
is set. Specifies which currency thebid
field is in. incomingBidInSellerCurrency
- Provides a conversion of the incoming bid to auctionโs seller currency. This is different from
bid
which is the bid the component auction itself produces. allowComponentAuction
- If the bid being scored is from a component auction and this value is not true, the bid is ignored. This field must be present and true both when the component seller scores a bid, and when that bid is being scored by the top-level auction.
TODO: This also has an ad field, which should behave similar to the way bid
affects modified bid, and then affecting the adMetadata parameter to scoreAd.
-
If result is an an abrupt completion, return failure.
-
If result.[[Value]] is a Number:
-
Let checkedScore be the result of converting result.[[Value]] to a
double
. -
If an exception was thrown in the previous step, return failure.
-
Let resultIDL be a new
ScoreAdOutput
. -
Set resultIDLโs
desirability
to checkedScore. -
Return resultIDL.
-
-
Let resultIDL be the result of converting result.[[Value]] to a
ScoreAdOutput
. -
If an exception was thrown in the previous step, return failure.
-
If resultIDL["
bidCurrency
"] exists and result of checking whether a string is a valid currency tag applied to resultIDL["bidCurrency
"] is false, then return failure. -
Return resultIDL.
14.12. Leading bid info
A leading bid info is the information of the auctionโs leading bid so far when ranking scored bids. Itโs a struct with the following items:
- top score
-
A
double
, initially 0.0. The highest score so far. - top non-k-anon-enforced score
-
A
double
, initially 0.0. The highest score so far when disregarding k-anonymity. - top bids count
-
An integer, initially 0. The number of bids with the same
top score
. - top non-k-anon-enforced bids count
-
Number of bids that are tied for leadership when disregarding k-anonymity thus far.
- at most one top bid owner
-
A boolean, initially true. Whether all bids of
top score
are from the same interest group owner. - leading bid
-
Null or a generated bid, initially null. The leading bid of the auction so far.
- leading non-k-anon-enforced bid
-
Null or a generated bid, initially null. The leading bid of the auction disregarding k-anonymity so far.
- auction config
-
An auction config. The auction config of the auction which generated this leading bid.
- second highest score
-
A
double
, initially 0.0. The second highest score so far. If more than one bids tie withtop score
, this will be set totop score
. - highest scoring other bids count
-
An integer, initially 0. The number of bids with the same
second highest score
. - highest scoring other bid
-
Null or a generated bid. The second highest scoring other bid.
- highest scoring other bid owner
-
Null or an origin, initially null. The interest group owner that made bids with the
second highest score
. Set to null if there are more than one owners made bids with thesecond highest score
. - top level seller
-
Null or an origin. The seller in the top level auction. Only set for component auctions, null otherwise.
- top level seller signals
-
Null or a string. Signals from the seller in the top level auction, produced as the output of the top-level sellerโs
reportResult()
method. Only set for component auctions, null otherwise. - component seller
-
Null or an origin. Seller in component auction which generated this leading bid. Only set for the top level auction when component auctions are present, null otherwise.
- bidding data version
-
Null or an
unsigned long
. Data-Version value from the trusted bidding signals serverโs response(s). Will only be not null if the `Data-Version
` header was provided and had a consistent value for all of the trusted bidding signals server responses used to construct the trustedBiddingSignals. - scoring data version
-
Null or an
unsigned long
. Data-Version value from the trusted scoring signals serverโs response. Will only be not null if the `Data-Version
` header was provided in the response headers from the trusted scoring signals server. - buyer reporting result
-
Null or a reporting result, initially null.
- seller reporting result
-
Null or a reporting result, initially null.
- component seller reporting result
-
Null or a reporting result, initially null.
A reporting result is a struct with the following items:
- report url
-
Null or a URL, initially null. Set by
sendReportTo(url)
. - reporting beacon map
-
Null or an ordered map whose keys are strings and whose values are URLs, initially null. Set by
registerAdBeacon(map)
. - reporting macro map
-
Null or an ordered map whose keys are strings and whose values are strings, initially null. Set by
registerAdMacro(name, value)
.
An auction report info is a struct with the following items:
- debug win report urls
-
A list of URLs whose schemes must be "
https
". The winning bidโs generated bidโs debug win report URLs. - debug loss report urls
-
A list of strings whose schemes must be "
https
". Losing bidโs generated bidโs debug loss report URLs.TODO: Change the two lists to a single URL since no more than one debug reports can be sent after downsampling debug reports. While the browser is experimenting with third party cookie deprecation (before they have been fully removed), the
forDebuggingOnly
reporting APIs are not downsampled, so they are still lists. - real time reporting contributions map
A real time reporting contributions map is an ordered map whose keys are origins and whose values are lists of real time reporting contributions.
A real time reporting contribution is a struct with the following items:
- bucket
-
A
long
. Must be greater than 0 and less than the sum of number of user buckets and number of platform buckets. - priority weight
-
A
double
. Must be greater than 0 and less than infinity, dictates the relative likelihood of which bucket will get the contribution. - latency threshold
-
Null or a duration in milliseconds. Initially null. Reports when a latency (e.g.,
generateBid()
execution latency) is greater than this threshold.
14.13. K-Anonymity Records
A k-anonymity key is a string used as a key for tracking k-anonymity status.A k-anonymity record is a timestamped cache of the k-anonymity status for a given k-anonymity key. These records are stored in the user agent.
- is k-anonymous
-
A
boolean
indicating whether the k-anonymity key indicated by this record was reported as k-anonymous. - timestamp
-
The moment when the k-anonymity status in this record was last fetched.
14.14. auction data config
An auction data config is a struct with the following items:
- publisher
-
An origin. The origin of the top level page running the ad auction. The scheme must be "
https
". - seller
-
An origin. The origin of the seller running the ad auction. The scheme must be "
https
". - coordinator
-
The origin of the coordinator hosting public encryption keys for the server running the ad auction. The scheme must be "
https
". - encryption key
-
Null or a byte sequence. The public HPKE encryption key to be used to encrypt the request.
- encryption key id
-
Null or a byte containing the key ID corresponding to the encryption key.
- request size
-
unsigned long
or null. An optional field, containing the desired size for the returned encrypted request blob. - per buyer config
-
A map whose keys are origins and values are auction data buyer config.
An auction data per seller result is a struct with the following items:
- seller
-
The origin of the seller that this result corresponds to. Will match one of the provided auction data configsโs seller.
- request
-
Null or a byte sequence. The encrypted request generated for this seller. Null indicates an error occured and the error field will contain additional information.
- error
-
Null or a string. Null when the request succeeds. Otherwise contains additional information about the failure.
An auction data buyer config is a struct with the following items:
- size
-
unsigned long
or null. An optional field, initially null, containing the size of the request to allocate to this buyer.
14.15. Cumulative timeout tracker
A cumulative timeout tracker is a struct with the following items:
- remaining
-
A duration in milliseconds or null. When non-null, records how much of the timeout remains to be consumed. When null, states there is no limit. Initially null.
- limit
-
A duration in milliseconds, or null (reprensenting no limit).
-
Let tracker be a new cumulative timeout tracker.
-
Set trackerโs limit to auctionConfigโs all buyers cumulative timeout.
-
If auctionConfigโs per buyer cumulative timeouts is not null and per buyer cumulative timeouts contains buyer, then set trackerโs limit to auctionConfigโs per buyer cumulative timeouts[buyer].
-
Return tracker.
15. User Agent Automation
For the purposes of user agent automation and website testing, this document defines the below [WebDriver2] extension commands.
15.1. Set Protected Audience K-Anonymity
The Set Protected Audience K-Anonymity WebDriver extension command instructs the user agent to use the specified hashes as the only k-anonymous sets for the interest group with the given owner and name.
The k-anonymity overrides is a map containing the currently active set of k-anonymity overrides, which is initially empty. The keys of k-anonymity overrides are tuples of (an origin for interest group owner, a string for interest group name). The values of k-anonymity overrides are maps whose keys are SHA-256 hashes and whose values are k-anonymity records. The k-anonymity overrides are checked before and take precedence over the k-anonymity cache.
HTTP Method | URI Template |
---|---|
POST | session/{session id}/protected_audience/set_k_anonymity
|
-
If parameters is not a JSON Object, return a WebDriver error with error code invalid argument.
-
Let owner be the result of getting a property named
"owner"
from parameters. -
If owner is undefined or is not a string, return a WebDriver error with error code invalid argument.
-
Let ownerOrigin be the result running parse an https origin on owner.
-
If ownerOrigin is failure, return a WebDriver error with error code invalid argument.
-
Let name be the result of getting a property named
"name"
from parameters. -
If name is not a string, return a WebDriver error with error code invalid argument.
-
Let hashes be the result of getting a property named
"hashes"
from parameters. -
If hashes is not a list, return a WebDriver error with error code invalid argument.
-
Let override be a map whose keys are SHA-256 hashes and whose values are k-anonymity records.
-
For each hashString of hashes:
-
If hashString is not a string, return a WebDriver error with error code invalid argument.
-
Let hash be the result of running forgiving-base64 decode with hashString.
-
If hash is failure or hashโs length is not 32, return a WebDriver error with error code invalid argument.
-
Let record be a new k-anonymity record.
-
Set recordโs timestamp field to the current coarsened wall time.
-
Set recordโs is k-anonymous field to true.
-
Set override[hash] to record.
-
-
Set the user agentโs k-anonymity overrides[(ownerOrigin,name)] to override.
-
Return success with data
null
.
16. Privacy Considerations
Protected Audience aims to advance the privacy of remarketing and custom audience advertising on the web, so naturally privacy considerations are paramount to Protected Audienceโs design. Partitioning data by site is the central mechanism to prevent joining a userโs identity across sites:
-
Interest group definitions come from just one site, the site that called
joinAdInterestGroup()
. -
Bidding (
generateBid()
) and scoring (scoreAd()
) scripts are exposed to interest group data from the joining site, and data from the site that will display the ad, but these scripts are run in strict isolation to prevent leaking this cross-site information. -
The browser can enforce that trusted bidding and scoring signals are fetched from servers complying with certain privacy requirements, e.g. not performing event-level logging.
-
Ads are rendered in
fencedframe
s that isolate them from the surrounding page to prevent cross-site leakage. -
Reporting is strictly controlled by the browser to prevent cross-site leaks: Inputs to event-level reporting functions,
reportWin()
andreportResult()
, only contain limited cross-site information, e.g. the k-anonymous ad URL. Event-level reporting is meant to be a temporary stepping stone to more private mechanisms like Private Aggregation API. -
If ยงโฏ9 Interest Group Updates are allowed to run after navigating to another page, the source IP address used for those requests can continue to reveal coarse location information about the device. Implementations may wish to implement some form of IP privacy, like a proxy, or limit how long updates can run post-navigation.
17. Security Considerations
Protected Audience involves the browser running untrusted JavaScript downloaded from multiple parties, so security concerns are top of mind. Fortunately Protected Audience is a highly constrained API not attempting to be a general purpose execution environment. Execution of this JavaScript is controlled and limited as follows:
-
Protected Audience requires the origin of the scripts' URLs to match that of the origin of the interest group owner, which is in turn required to match the origin of the context calling the
joinAdInterestGroup()
. -
URL schemes are required to be HTTPS.
-
Redirects are disallowed.
-
Responses are required to contain the
Ad-Auction-Allowed: ?1
header. -
Fetches are uncredentialed.
Protected Audience has the browser pass in several โbrowserSignalsโ to the bidding script that give the script unforgeable information about the context that the script is being executed in. This way bidders and sellers have the choice to only participate in auctions where they are comfortable working with the involved parties.
The execution environment available to these scripts is the absolute minimum necessary to calculate a bid. It supports only ECMAScript. It does not support network, storage, timer, date, DOM, Workers, postMessage, Navigator or Window APIs.
Protected Audience adds Permission-Policies to control access to the Protected Audience APIs to give sites and embedders the ability to clamp down on use of the APIs as they see fit.
Auction config and interest group data are processed as JSON and not via the structured clone algorithm, in part because interest groups are updated via JSON server responses. However, there
is also a security reason to not use the structured clone algorithm, which is that the data may
be shared with other parties -- in particular, the auction config perBuyerSignals
are sent from the seller to each buyer. Supporting structured
cloning here would mean that buyer scripts would have to be prepared to handle arbitrary, complex,
and potentially cyclic objects from the seller.