forked from fwadnjar/turtledkoteshrv-googlemeet-telegrambot
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathspec.bs
4920 lines (4340 loc) · 261 KB
/
spec.bs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<pre class="metadata">
Title: Protected Audience (formerly FLEDGE)
Shortname: protected-audience
Repository: WICG/turtledove
Inline Github Issues: true
Group: WICG
Status: CG-DRAFT
Level: 1
URL: https://wicg.github.io/turtledove/
Boilerplate: omit conformance, omit feedback-header
Editor: Paul Jensen, Google https://www.google.com/, [email protected]
Abstract: Provides a privacy advancing API to facilitate interest group based advertising.
!Participate: <a href="https://github.com/WICG/turtledove">GitHub WICG/turtledove</a> (<a href="https://github.com/WICG/turtledove/issues/new">new issue</a>, <a href="https://github.com/WICG/turtledove/issues?state=open">open issues</a>)
!Commits: <a href="https://github.com/WICG/turtledove/commits/main/spec.bs">GitHub spec.bs commits</a>
Complain About: accidental-2119 yes, missing-example-ids yes
Indent: 2
Default Biblio Status: current
Markup Shorthands: markdown yes
Assume Explicit For: yes
</pre>
<pre class="anchors">
urlPrefix: https://fetch.spec.whatwg.org/; spec: Fetch
type: dfn
text: HTTP-network-or-cache fetch; url: #concept-http-network-or-cache-fetch
text: task destination; for: fetch params; url: fetch-params-task-destination
urlPrefix: https://www.ietf.org/rfc/rfc4122.txt
type: dfn; text: urn uuid
type: dfn; text: string representation
type: dfn; text: version 4 UUID
urlPrefix: https://github.com/WICG/turtledove/blob/main/FLEDGE_k_anonymity_server.md
type: dfn; text: k-anonymity; url: what-is-k-anonymity
urlPrefix: https://developer.chrome.com/en/docs/privacy-sandbox/glossary/
type: dfn; text: ad creative; url: ad-creative
spec: RFC6234; urlPrefix: https://www.ietf.org/rfc/rfc6234.txt
type: dfn; text: SHA-256
urlPrefix: https://datatracker.ietf.org/doc/html/rfc8032
type: dfn
text: verify; url: section-5.1.7
spec: html; urlPrefix: https://html.spec.whatwg.org/C
type: dfn
text: create an agent; url: create-an-agent
text: immediately; url: immediately
text: valid floating-point number; url: valid-floating-point-number
spec: infra; urlPrefix: https://infra.spec.whatwg.org/
type: dfn
text: convert an Infra value to a JSON-compatible JavaScript value; url: #convert-an-infra-value-to-a-json-compatible-javascript-value
spec: RFC8941; urlPrefix: https://httpwg.org/specs/rfc8941.html
type: dfn
text: structured header; url: top
for: structured header
text: boolean; url: boolean
text: integer; url: integer
text: boolean; url: boolean
spec: WebAssembly; urlPrefix: https://webassembly.github.io/spec/core/
type: dfn
urlPrefix: appendix/embedding.html
text: error; url: embed-error
spec: WebAssembly-js-api; urlPrefix: https://webassembly.github.io/spec/js-api/
type: dfn
text: compiling a WebAssembly module; url: #compile-a-webassembly-module
spec: WebIDL; urlPrefix: https://webidl.spec.whatwg.org/
type: dfn
text: convert a Web IDL arguments list to an ECMAScript arguments list; url: #web-idl-arguments-list-converting
spec: Fenced Frame; urlPrefix: https://wicg.github.io/fenced-frame/
type: dfn
for: browsing context
text: fenced frame config instance; url: #browsing-context-fenced-frame-config-instance
spec: Private Aggregation API; urlPrefix: https://patcg-individual-drafts.github.io/private-aggregation-api
type: dfn
text: private-aggregation; url: #private-aggregation
spec: Shared Storage API; urlPrefix: https://wicg.github.io/shared-storage
type: dfn
text: shared-storage; url: #permissionspolicy-shared-storage
text: shared-storage-select-url; url: #permissionspolicy-shared-storage-select-url
</pre>
<pre class=link-defaults>
spec:infra; type:dfn; text:user agent
</pre>
<style>
/* Put nice boxes around each algorithm. */
[data-algorithm]:not(.heading) {
padding: .5em;
border: thin solid #ddd; border-radius: .5em;
margin: .5em calc(-0.5em - 1px);
}
[data-algorithm]:not(.heading) > :first-child {
margin-top: 0;
}
[data-algorithm]:not(.heading) > :last-child {
margin-bottom: 0;
}
[data-algorithm] [data-algorithm] {
margin: 1em 0;
}
/* domintro from https://resources.whatwg.org/standard.css */
.domintro {
position: relative;
color: green;
background: #DDFFDD;
margin: 2.5em 0 2em 0;
padding: 1.5em 1em 0.5em 2em;
}
.domintro dt, .domintro dt * {
color: black;
font-size: inherit;
}
.domintro dd {
margin: 0.5em 0 1em 2em; padding: 0;
}
.domintro dd p {
margin: 0.5em 0;
}
.domintro::before {
content: 'For web developers (non-normative)';
background: green;
color: white;
padding: 0.15em 0.25em;
font-style: normal;
position: absolute;
top: -0.8em;
left: -0.8em;
}
</style>
# Introduction # {#intro}
*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
{{Window/navigator}}.{{Navigator/joinAdInterestGroup()}}. Later, when a website wants to select an
advertisement to show to the user, the website can call
{{Window/navigator}}.{{Navigator/runAdAuction()}} to ask the browser to conduct an
<dfn>auction</dfn> where each of these on-device recorded interests are given the chance to
calculate a bid to display their advertisement.
<h2 id="joining-interest-groups">Joining Interest Groups</h2>
*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
{{Window/navigator}}.{{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
<dfn>interest group set</dfn>, a [=list=] of [=interest groups=] in which
[=interest group/owner=] / [=interest group/name=] pairs are unique.
<h3 id="join-ad-interest-groups">navigator.joinAdInterestGroup()</h3>
<xmp class="idl">
[SecureContext]
partial interface Navigator {
Promise<undefined> joinAdInterestGroup(AuctionAdInterestGroup group);
};
dictionary AuctionAd {
required USVString renderURL;
any metadata;
USVString buyerReportingId;
USVString buyerAndSellerReportingId;
sequence<USVString> allowedReportingOrigins;
};
dictionary GenerateBidInterestGroup {
required USVString owner;
required USVString name;
required double lifetimeMs;
boolean enableBiddingSignalsPrioritization = false;
record<DOMString, double> priorityVector;
record<USVString, sequence<DOMString>> sellerCapabilities;
DOMString executionMode = "compatibility";
USVString biddingLogicURL;
USVString biddingWasmHelperURL;
USVString updateURL;
USVString trustedBiddingSignalsURL;
sequence<USVString> trustedBiddingSignalsKeys;
any userBiddingSignals;
sequence<AuctionAd> ads;
sequence<AuctionAd> adComponents;
};
dictionary AuctionAdInterestGroup : GenerateBidInterestGroup {
double priority = 0.0;
record<DOMString, double> prioritySignalsOverrides;
DOMString additionalBidKey;
};
</xmp>
{{AuctionAdInterestGroup}} is used by {{Window/navigator}}.{{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.
<div algorithm="joinAdInterestGroup()">
The <dfn for=Navigator method>joinAdInterestGroup(|group|)</dfn> method steps are:
<div class="note">
Temporarily, Chromium does not include the <a for="dictionary member"><span class="allow-2119">required</span></a> keyword
for {{GenerateBidInterestGroup/lifetimeMs}}, and instead starts this algorithm with the step
1. If |group|["{{GenerateBidInterestGroup/lifetimeMs}}"] does not [=map/exist=], throw a {{TypeError}}.
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.
</div>
1. Let |global| be [=this=]'s [=relevant global object=].
1. If |global|'s [=associated Document=] is not [=allowed to use=] the "[=join-ad-interest-group=]"
[=policy-controlled feature=], then [=exception/throw=] a "{{NotAllowedError}}" {{DOMException}}.
1. Let |frameOrigin| be [=this=]'s [=relevant settings object=]'s [=environment settings object/origin=].
1. [=Assert=] that |frameOrigin| is not an [=opaque origin=] and its [=origin/scheme=] is "`https`".
1. Let |interestGroup| be a new [=interest group=].
1. Validate the given |group| and set |interestGroup|'s fields accordingly.
1. Set |interestGroup|'s [=interest group/expiry=] to the [=current wall time=] plus
|group|["{{GenerateBidInterestGroup/lifetimeMs}}"] milliseconds.
1. Set |interestGroup|'s [=interest group/next update after=] to the [=current wall time=] plus 24
hours.
1. Set |interestGroup|'s [=interest group/owner=] to the result of [=parsing an https origin=] on
|group|["{{GenerateBidInterestGroup/owner}}"].
1. If |interestGroup|'s [=interest group/owner=] is failure, then [=exception/throw=] a {{TypeError}}.
1. Optionally, [=exception/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 [=interest group/owner=]'s [=site=] not being
<a href="https://github.com/privacysandbox/attestation">enrolled</a>.
1. Set |interestGroup|'s [=interest group/name=] to |group|["{{GenerateBidInterestGroup/name}}"].
1. Set |interestGroup|'s [=interest group/priority=] to
|group|["{{AuctionAdInterestGroup/priority}}"].
1. Set |interestGroup|'s [=interest group/enable bidding signals prioritization=] to
|group|["{{GenerateBidInterestGroup/enableBiddingSignalsPrioritization}}"].
1. If |group|["{{GenerateBidInterestGroup/priorityVector}}"] [=map/exists=], then set
|interestGroup|'s [=interest group/priority vector=] to
|group|["{{GenerateBidInterestGroup/priorityVector}}"].
1. If |group|["{{AuctionAdInterestGroup/prioritySignalsOverrides}}"] [=map/exists=], then set
|interestGroup|'s [=interest group/priority signals overrides=] to
|group|["{{AuctionAdInterestGroup/prioritySignalsOverrides}}"].
1. If |group|["{{GenerateBidInterestGroup/sellerCapabilities}}"] [=map/exists=], [=map/for each=]
|key| → |value| of |group|["{{GenerateBidInterestGroup/sellerCapabilities}}"]:
1. If |key| is "*", then set |interestGroup|'s [=interest group/all seller capabilities=] to
|value|.
1. Otherwise, [=map/set=] |interestGroup|'s [=interest group/seller capabilities=][|key|] to
|value|.
1. Set |interestGroup|'s [=interest group/execution mode=] to
|group|["{{GenerateBidInterestGroup/executionMode}}"].
1. For each |groupMember| and |interestGroupField| in the following table
<table class="data">
<thead><tr><th>Group member</th><th>Interest group field</th></tr></thead>
<tr>
<td>"{{GenerateBidInterestGroup/biddingLogicURL}}"</td>
<td>[=interest group/bidding url=]</td>
</tr>
<tr>
<td>"{{GenerateBidInterestGroup/biddingWasmHelperURL}}"</td>
<td>[=interest group/bidding wasm helper url=]</td>
</tr>
<tr>
<td>"{{GenerateBidInterestGroup/updateURL}}"</td>
<td>[=interest group/update url=]</td>
</tr>
<tr>
<td>"{{GenerateBidInterestGroup/trustedBiddingSignalsURL}}"</td>
<td>[=interest group/trusted bidding signals url=]</td>
</tr>
</table>
1. If |group| [=map/contains=] |groupMember|:
1. Let |parsedUrl| be the result of running the [=URL parser=] on |group|[|groupMember|].
1. [=exception/Throw=] a {{TypeError}} if any of the following conditions hold:
* |parsedUrl| is failure;
* |parsedUrl| is not [=same origin=] with |interestGroup|'s [=interest group/owner=];
* |parsedUrl| [=includes credentials=];
* |parsedUrl| [=url/fragment=] is not null.
1. Set |interestGroup|'s |interestGroupField| to |parsedUrl|.
1. If |interestGroup|'s [=interest group/trusted bidding signals url=]'s [=url/query=] is not
null, then [=exception/throw=] a {{TypeError}}.
1. If |group|["{{GenerateBidInterestGroup/trustedBiddingSignalsKeys}}"] [=map/exists=], then set
|interestGroup|'s [=interest group/trusted bidding signals keys=] to
|group|["{{GenerateBidInterestGroup/trustedBiddingSignalsKeys}}"].
1. If |group|["{{GenerateBidInterestGroup/userBiddingSignals}}"] [=map/exists=]:
1. Set |interestGroup|'s [=interest group/user bidding signals=] to the result of
[=serializing a JavaScript value to a JSON string=], given
|group|["{{GenerateBidInterestGroup/userBiddingSignals}}"]. This can [=exception/throw=] a
{{TypeError}}.
1. For each |groupMember| and |interestGroupField| in the following table
<table class="data">
<thead><tr><th>Group member</th><th>Interest group field</th></tr></thead>
<tr>
<td>"{{GenerateBidInterestGroup/ads}}"</td>
<td>[=interest group/ads=]</td>
</tr>
<tr>
<td>"{{GenerateBidInterestGroup/adComponents}}"</td>
<td>[=interest group/ad components=]</td>
</tr>
</table>
1. If |group| [=map/contains=] |groupMember|, [=list/for each=] |ad| of |group|[|groupMember|]:
1. Let |igAd| be a new [=interest group ad=].
1. Let |renderURL| be the result of running the [=URL parser=] on
|ad|["{{AuctionAd/renderURL}}"].
1. [=exception/Throw=] a {{TypeError}} if any of the following conditions hold:
* |renderURL| is failure;
* |renderURL| [=url/scheme=] is not "`https`";
* |renderURL| [=includes credentials=].
1. Set |igAd|'s [=interest group ad/render url=] to |renderURL|.
1. If |ad|["{{AuctionAd/metadata}}"] [=map/exists=], then let
|igAd|'s [=interest group ad/metadata=] be the result of
[=serializing a JavaScript value to a JSON string=], given |ad|["{{AuctionAd/metadata}}"].
This can [=exception/throw=] a {{TypeError}}.
1. If |groupMember| is "{{GenerateBidInterestGroup/ads}}":
1. If |ad|["{{AuctionAd/buyerReportingId}}"] [=map/exists=], then set
|igAd|'s [=interest group ad/buyer reporting ID=] to it.
1. If |ad|["{{AuctionAd/buyerAndSellerReportingId}}"] [=map/exists=],
then set |igAd|'s [=interest group ad/buyer and seller reporting ID=] to it.
1. If |ad|["{{AuctionAd/allowedReportingOrigins}}"] [=map/exists=]:
1. Let |allowedReportingOrigins| be a new [=list=] of [=origins=].
1. [=list/For each=] |originStr| in |ad|["{{AuctionAd/allowedReportingOrigins}}"]:
1. Let |origin| be the result of [=parsing an https origin=] on |originStr|.
1. If |origin| is failure, then [=exception/throw=] a {{TypeError}}.
1. [=list/Append=] |origin| to |allowedReportingOrigins|.
1. If |allowedReportingOrigins|'s [=list/size=] > 10, [=exception/throw=]
a {{TypeError}}.
1. Set |igAd|'s [=interest group ad/allowed reporting origins=] to |allowedReportingOrigins|.
1. [=list/Append=] |igAd| to |interestGroup|'s |interestGroupField|.
1. If |group|["{{AuctionAdInterestGroup/additionalBidKey}}"] [=map/exists=]:
1. Let |decodedKey| be the result of running [=forgiving-base64 decode=] with
|group|["{{AuctionAdInterestGroup/additionalBidKey}}"].
1. [=exception/Throw=] a {{TypeError}} if any of the following conditions hold:
* |decodedKey| is a failure;
* |decodedKey|'s [=byte sequence/length=] is not 32;
* |group|["{{GenerateBidInterestGroup/ads}}"] [=map/exists=];
* |group|["{{GenerateBidInterestGroup/updateURL}}"] [=map/exists=].
1. Set |interestGroup|'s [=interest group/additional bid key=] to |decodedKey|.
1. If |interestGroup|'s [=interest group/estimated size=] > 1048576, then [=exception/throw=] a
{{TypeError}}.
1. Let |p| be [=a new promise=].
1. Let |queue| be the result of [=starting a new parallel queue=].
1. [=parallel queue/enqueue steps|Enqueue the following steps=] to |queue|:
1. Let |permission| be the result of [=checking interest group permissions=] with
|interestGroup|'s [=interest group/owner=], |frameOrigin|, and "`join`".
1. 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.
1. [=Queue a global task=] on [=DOM manipulation task source=], given |global|, to [=resolve=] |p|
with `undefined`.
1. If the browser is currently storing an interest group with `owner` and `name` that matches
|interestGroup|, then set the [=interest group/bid counts=],
[=interest group/join counts=], and [=interest group/previous wins=] of
|interestGroup| to the values of the currently stored one and remove
the currently stored one from the browser.
1. Set |interestGroup|'s [=interest group/joining origin=] to [=this=]'s
[=relevant settings object=]'s [=environment/top-level origin=].
1. Set |interestGroup|'s [=interest group/join time=] to the [=current wall time=].
1. If the most recent entry in |interestGroup|'s [=interest group/join counts=] corresponds to
the current day in UTC, increment its count. If not, [=list/insert=] a new [=tuple=]
the time set to the current UTC day and a count of 1.
1. Store |interestGroup| in the [=user agent=]'s [=interest group set=].
1. Return |p|.
</div>
<div algorithm>
The <dfn for="interest group">estimated size</dfn> of an [=interest group=] |ig| is the sum of:
1. The [=string/length=] of the [=serialization of an origin|serialization=] of |ig|'s
[=interest group/owner=].
1. The [=string/length=] of |ig|'s [=interest group/name=].
1. 8, which is the size of |ig|'s [=interest group/priority=].
1. The [=string/length=] of |ig|'s [=interest group/execution mode=].
1. 2, which is the size of |ig|'s [=interest group/enable bidding signals prioritization=].
1. If |ig|'s [=interest group/priority vector=] is not null, [=map/for each=] |key| → |value| of
[=interest group/priority vector=]:
1. The [=string/length=] of |key|.
1. 8, which is the size of |value|.
1. If |ig|'s [=interest group/priority signals overrides=] is not null, [=map/for each=] |key| → |value| of
[=interest group/priority signals overrides=]:
1. The [=string/length=] of |key|.
1. 8, which is the size of |value|.
1. The [=string/length=] of the [=URL serializer|serialization=] of |ig|'s
[=interest group/bidding url=], if the field is not null.
1. The [=string/length=] of the [=URL serializer|serialization=] of |ig|'s
[=interest group/bidding wasm helper url=], if the field is not null.
1. The [=string/length=] of the [=URL serializer|serialization=] of |ig|'s
[=interest group/update url=], if the field is not null.
1. The [=string/length=] of the [=URL serializer|serialization=] of |ig|'s
[=interest group/trusted bidding signals url=], if the field is not null.
1. [=list/For each=] |key| of |ig|'s [=interest group/trusted bidding signals keys=]:
1. The [=string/length=] of |key|.
1. The [=string/length=] of |ig|'s [=interest group/user bidding signals=].
1. If |ig|'s [=interest group/ads=] is not null, [=list/for each=] |ad| of it:
1. The [=string/length=] of the [=URL serializer|serialization=] of |ad|'s
[=interest group ad/render url=].
1. The [=string/length=] of |ad|'s [=interest group ad/metadata=] if the field is not null.
1. The [=string/length=] of |ad|'s [=interest group ad/buyer reporting ID=] if the field is not null.
1. The [=string/length=] of |ad|'s [=interest group ad/buyer and seller reporting ID=] if the
field is not null.
1. If |ad|'s [=interest group ad/allowed reporting origins=] is not null, [=list/for each=]
|origin| of it:
1. The [=string/length=] of the [=serialization of an origin|serialization=] of |origin|.
1. If |ig|'s [=interest group/ad components=] is not null, [=list/for each=] |ad| of it:
1. The [=string/length=] of the [=URL serializer|serialization=] of |ad|'s
[=interest group ad/render url=].
1. The [=string/length=] of |ad|'s [=interest group ad/metadata=] if the field is not null.
1. If |ig|'s [=interest group/additional bid key=] is not null:
1. 32, which is its size (number of bytes).
</div>
<div algorithm>
To <dfn>check interest group permissions</dfn> given an [=origin=] |ownerOrigin|, an [=origin=]
|frameOrigin|, and an enum |joinOrLeave| which is "`join`" or "`leave`":
1. If |ownerOrigin| is [=same origin=] with |frameOrigin|, then return true.
1. Let |encodedFrameOrigin| be the result of [=string/UTF-8 percent-encoding=] the
[=serialization of an origin|serialized=] |frameOrigin| using [=component percent-encode set=].
1. Let |permissionsUrl| be a new [=URL=] with the following [=struct/items=]:
: [=url/scheme=]
:: |ownerOrigin|'s [=origin/scheme=]
: [=url/host=]
:: |ownerOrigin|'s [=origin/host=]
: [=url/port=]
:: |ownerOrigin|'s [=origin/port=]
: [=url/path=]
:: « ".well-known", "interest-group", "permissions" »
: [=url/query=]
:: The result of [=string/concatenating=] « "origin=", |encodedFrameOrigin| »
1. Let |request| be a new [=request=] with the following properties:
: [=request/URL=]
:: |permissionsUrl|
: [=request/header list=]
:: «`Accept`: `application/json`»
: [=request/client=]
:: `null`
: [=request/origin=]
:: |frameOrigin|
: [=request/mode=]
:: "`cors`"
: [=request/referrer=]
:: "`no-referrer`"
: [=request/credentials mode=]
:: "`omit`"
: [=request/redirect mode=]
:: "`error`"
Issue: One of the side-effects of a `null` client for this subresource request is it neuters all
service worker interceptions, despite not having to set the service workers mode.
1. Let |resource| be null.
1. [=Fetch=] |request| with [=fetch/useParallelQueue=] set to true, and
[=fetch/processResponseConsumeBody=] set to the following steps given a [=response=] |response|
and null, failure, or a [=byte sequence=] |responseBody|:
1. If |responseBody| is null or failure, set |resource| to failure and return.
1. Let |headers| be |response|'s [=response/header list=].
1. Let |mimeType| be the result of [=header list/extracting a MIME type=] from |headers|.
1. If |mimeType| is failure or is not a [=JSON MIME Type=], set |resource| to failure and return.
1. Set |resource| to |responseBody|.
1. Wait for |resource| to be set.
1. If |resource| is failure, then return false.
1. Let |permissions| be the result of [=parsing JSON bytes to an Infra value=] with |resource|,
returning false on failure.
1. If |permissions| is not an [=ordered map=], then return false.
1. If |joinOrLeave| is "`join`" and |permissions|["`joinAdInterestGroup`"] [=map/exists=], then
return |permissions|["`joinAdInterestGroup`"].
1. If |joinOrLeave| is "`leave`" and |permissions|["`leaveAdInterestGroup`"] [=map/exists=], then
return |permissions|["`leaveAdInterestGroup`"].
1. 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.
</div>
<h3 id="interest-group-storage-maintenance">Interest Group Storage Maintenance</h3>
There is a job that periodically [=performs storage maintenance=] on the [=user agent=]'s
[=interest group set=]. It performs operations such as [=list/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:
* <dfn>Interest group set max owners</dfn> is 1000, which defines the max number of
[=interest group/owners=] in the [=user agent=]'s [=interest group set=].
* <dfn>Max regular interest groups per owner</dfn> is 2000, which defines the max number of
[=regular interest groups=] in the [=user agent=]'s [=interest group set=] for an
[=interest group/owner=].
* <dfn>Max negative interest groups per owner</dfn> is 20000, which defines the max number of
[=negative interest groups=] in the [=user agent=]'s [=interest group set=] for an
[=interest group/owner=].
* <dfn>Max interest groups total size per owner</dfn> is <code>10\*1024\*1024</code>, which
defines the max total [=interest group/estimated size|sizes=] of [=interest groups=] in the
[=user agent=]'s [=interest group set=] for an [=interest group/owner=]. It includs both
[=regular interest groups=] and [=negative interest groups=].
<div algorithm>
To <dfn>perform storage maintenance</dfn>:
1. Let |ownersAndExpiry| be a new [=ordered map=] whose [=map/keys=] are [=origins=] and
[=map/values=] are [=moments=].
Note: The [=map/key=] is from [=interest group/owner=], and [=map/value=] is from
[=interest group/expiry=]. It's used to determine a set of [=interest group/owners=] whose
[=interest groups=] will be removed from the [=user agent=]'s [=interest group set=] because the
number of distinct [=interest group/owners=] exceeds the [=Interest group set max owners=] limit.
It's sorted based on their [=map/values=] ([=interest group/expiry=]) in descending order, in
order to remove [=interest groups=] of [=interest group/owners=] expiring soonest first.
1. Let |now| be the [=current wall time=].
1. [=list/For each=] |ig| of the [=user agent=]'s [=interest group set=]:
1. Let |owner| be |ig|'s [=interest group/owner=].
1. If |ig|'s [=interest group/expiry=] is before |now|, then [=list/remove=] |ig| from the
[=user agent=]'s [=interest group set=] and [=iteration/continue=].
1. If |ownersAndExpiry|[|owner|] [=map/exists=], then [=map/set=] |ownersAndExpiry|[|owner|] to
|ig|'s [=interest group/expiry=] if it comes after |ownersAndExpiry|[|owner|].
1. Otherwise, [=map/set=] |ownersAndExpiry|[|owner|] to |ig|'s [=interest group/expiry=].
1. If |ownersAndExpiry|'s [=map/size=] > [=interest group set max owners=], then [=map/set=]
|ownersAndExpiry| to |ownersAndExpiry| [=map/sorted in descending order=] with |a| being less than
|b| if |a|'s [=map/value=] comes before |b|'s [=map/value=], where [=map/values=] are
[=interest group/expiry=].
1. Let |owners| be the [=map/get the keys|keys=] of |ownersAndExpiry|.
1. [=list/For each=] |i| in [=the range=] from 0 to |owners|'s [=set/size=], exclusive:
1. If |i| ≥ [=interest group set max owners=], then [=list/remove=] [=interest groups=] from
the [=user agent=]'s [=interest group set=] whose [=interest group/owner=] is |owners|[|i|], and
[=iteration/continue=].
1. Let |regularIgs| be a [=list=] of [=regular interest groups=] in the [=user agent=]'s
[=interest group set=] whose [=interest group/owner=] is |owners|[|i|].
1. If |regularIgs|'s [=list/size=] > [=max regular interest groups per owner=], then
[=clear excess interest groups=] with |regularIgs| and [=max regular interest groups per owner=].
1. Let |negativeIgs| be a [=list=] of [=negative interest groups=] in the [=user agent=]'s
[=interest group set=] whose [=interest group/owner=] is |owners|[|i|].
1. If |negativeIgs|'s [=list/size=] > [=max negative interest groups per owner=], then
[=clear excess interest groups=] with |negativeIgs| and [=max negative interest groups per owner=].
1. [=list/For each=] |owner| of |owners|:
1. Let |igs| be a [=list=] of [=interest groups=] in the [=user agent=]'s [=interest group set=]
whose [=interest group/owner=] is |owner|, [=list/sorted in descending order=] with |a| being
less than |b| if |a|[=interest group/expiry=] comes before |b|[=interest group/expiry=].
1. Let |cumulativeSize| be 0.
1. [=list/For each=] |ig| of |igs|:
1. If the sum of |cumulativeSize| and |ig|'s [=interest group/estimated size=]
> [=max interest groups total size per owner=], then [=list/remove=] |ig| from the
[=user agent=]'s [=interest group set=].
1. Otherwise, increment |cumulativeSize| by |ig|'s [=interest group/estimated size=].
</div>
<div algorithm>
To <dfn>clear excess interest groups</dfn> with a [=list=] of [=interest groups=] |igs|, and an
integer |maxIgs|:
1. Let |sortedIgs| be |igs| [=list/sorted in descending order=] with |a| being less
than |b| if |a|'s [=interest group/expiry=] comes before |b|'s [=interest group/expiry=].
Note: In order to remove interest groups expiring soonest first, sort interest groups based on
their expiry in descending order.
1. [=list/For each=] |i| in [=the range=] from |maxIgs| to |igs|'s [=list/size=], exclusive:
1. [=list/Remove=] |sortedIgs|[|i|] from the [=user agent=]'s [=interest group set=].
</div>
<h2 id="leaving-interest-groups">Leaving Interest Groups</h2>
<h3 id="leaveadinterestgroup">leaveAdInterestGroup()</h3>
*This first introductory paragraph is non-normative.*
{{Window/navigator}}.{{Navigator/leaveAdInterestGroup()}} removes a user from a particular interest
group.
<xmp class="idl">
[SecureContext]
partial interface Navigator {
Promise<undefined> leaveAdInterestGroup(optional AuctionAdInterestGroupKey group = {});
};
dictionary AuctionAdInterestGroupKey {
required USVString owner;
required USVString name;
};
</xmp>
<div algorithm>
The <dfn for=Navigator method>leaveAdInterestGroup(group)</dfn> method steps are:
1. Let |global| be [=this=]'s [=relevant global object=].
1. Let |frameOrigin| be |global|'s [=environment settings object/origin=].
1. [=Assert=] that |frameOrigin| is not an [=opaque origin=] and its [=origin/scheme=] is "`https`".
1. Let |p| be [=a new promise=].
1. If |group| [=map/is empty=]:
1. Let |instance| be |global|'s [=Window/browsing context=]'s
[=browsing context/fenced frame config instance=].
1. If |instance| is null, then return.
1. Let |interestGroup| be |instance|'s [=fenced frame config instance/interest group descriptor=].
1. Run these steps [=in parallel=]:
1. [=Queue a global task=] on [=DOM manipulation task source=], given |global|, to [=resolve=]
|p| with `undefined`.
1. If |interestGroup| is not null:
1. Let |owner| be |interestGroup|'s [=interest group descriptor/owner=].
1. If |owner| is [=same origin=] with |frameOrigin|, then [=list/remove=] [=interest groups=]
from the [=user agent=]'s [=interest group set=] whose [=interest group/owner=] is |owner| and
[=interest group/name=] is |interestGroup|'s [=interest group descriptor/name=].
1. Otherwise:
1. If |global|'s [=associated Document=] is not [=allowed to use=] the
"[=join-ad-interest-group=]" [=policy-controlled feature=], then [=exception/throw=] a
"{{NotAllowedError}}" {{DOMException}}.
Note: Both joining and leaving interest groups use the "join-ad-interest-group" feature.
1. Let |owner| be the result of [=parsing an https origin=] with
|group|["{{AuctionAdInterestGroupKey/owner}}"].
1. If |owner| is failure, [=exception/throw=] a {{TypeError}}.
1. Run these steps [=in parallel=]:
1. Let |permission| be the result of [=checking interest group permissions=] with
|owner|, |frameOrigin|, and "`leave`".
1. 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.
1. [=Queue a global task=] on [=DOM manipulation task source=], given |global|, to [=resolve=]
|p| with `undefined`.
1. [=list/Remove=] [=interest groups=] from the [=user agent=]'s [=interest group set=] whose
[=interest group/owner=] is |owner| and [=interest group/name=] is
|group|["{{AuctionAdInterestGroupKey/name}}"].
1. Return |p|.
</div>
<h3 id="clearoriginjoinedAdInterestGroups">clearOriginJoinedAdInterestGroups()</h3>
*This first introductory paragraph is non-normative.*
{{Window/navigator}}.{{Navigator/clearOriginJoinedAdInterestGroups()}} removes a user from
[=interest groups=] whose [=interest group/joining origin=] is the associated
{{Navigator}}'s [=relevant settings object=]'s [=environment/top-level origin=].
<xmp class="idl">
[SecureContext]
partial interface Navigator {
Promise<undefined> clearOriginJoinedAdInterestGroups(
USVString owner, optional sequence<USVString> interestGroupsToKeep = []);
};
</xmp>
<div algorithm>
The <dfn for=Navigator method>clearOriginJoinedAdInterestGroups(|owner|, |interestGroupsToKeep|)</dfn>
method steps are:
1. Let |frameOrigin| be [=this=]'s [=relevant settings object=]'s
[=environment settings object/origin=].
1. [=Assert=] that |frameOrigin| is not an [=opaque origin=] and its [=origin/scheme=] is "`https`".
1. Let |p| be [=a new promise=].
1. Let |global| be [=this=]'s [=relevant global object=].
1. If |global|'s [=associated Document=] is not [=allowed to use=] the
"[=join-ad-interest-group=]" [=policy-controlled feature=], then [=exception/throw=] a
"{{NotAllowedError}}" {{DOMException}}.
Note: Both joining and leaving interest groups use the "join-ad-interest-group" feature.
1. Let |ownerOrigin| be the result of [=parsing an https origin=] with |owner|.
1. If |ownerOrigin| is failure, [=exception/throw=] a {{TypeError}}.
1. Run these steps [=in parallel=]:
1. Let |permission| be the result of [=checking interest group permissions=] with
|ownerOrigin|, |frameOrigin|, and "`leave`".
1. 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.
1. [=Queue a global task=] on the [=DOM manipulation task source=] given |global|, to [=resolve=] |p|
with {{undefined}}.
1. [=list/Remove=] [=interest groups=] from the [=user agent=]'s [=interest group set=]
whose [=interest group/owner=] is |ownerOrigin|, whose [=interest group/joining origin=] is
|frameOrigin|, and whose [=interest group/name=] is not in |interestGroupsToKeep|.
1. Return |p|.
</div>
<h2 id="running-ad-auctions">Running Ad Auctions</h2>
*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
{{Window/navigator}}.{{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.
<h3 id="runadauction">runAdAuction()</h3>
<xmp class="idl">
[SecureContext]
partial interface Navigator {
Promise<(USVString or FencedFrameConfig)?> runAdAuction(AuctionAdConfig config);
};
dictionary AuctionAdConfig {
required USVString seller;
required USVString decisionLogicURL;
USVString trustedScoringSignalsURL;
sequence<USVString> interestGroupBuyers;
Promise<any> auctionSignals;
record<DOMString, DOMString> requestedSize;
Promise<any> sellerSignals;
Promise<DOMString> directFromSellerSignalsHeaderAdSlot;
unsigned long long sellerTimeout;
unsigned short sellerExperimentGroupId;
USVString sellerCurrency;
Promise<record<USVString, any>> perBuyerSignals;
Promise<record<USVString, unsigned long long>> perBuyerTimeouts;
Promise<record<USVString, unsigned long long>> perBuyerCumulativeTimeouts;
record<USVString, unsigned short> perBuyerGroupLimits;
record<USVString, unsigned short> perBuyerExperimentGroupIds;
record<USVString, record<USVString, double>> perBuyerPrioritySignals;
Promise<record<USVString, USVString>> perBuyerCurrencies;
sequence<AuctionAdConfig> componentAuctions = [];
Promise<undefined> additionalBids;
DOMString auctionNonce;
AbortSignal? signal;
Promise<boolean> resolveToConfig;
};
</xmp>
<div algorithm="runAdAuction()">
The <dfn for=Navigator method>runAdAuction(|config|)</dfn> method steps are:
1. Let |global| be [=this=]'s [=relevant global object=].
1. Let |settings| be [=this=]'s [=relevant settings object=].
1. If |global|'s [=associated Document=] is not [=allowed to use=] the "[=run-ad-auction=]"
[=policy-controlled feature=], then [=exception/throw=] a "{{NotAllowedError}}" {{DOMException}}.
1. Let |auctionConfig| be the result of running [=validate and convert auction ad config=] with
|config| and true.
1. If |auctionConfig| is failure, then [=exception/throw=] a {{TypeError}}.
1. Optionally, [=exception/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 [=auction config/seller=]'s [=site=] not being
<a href="https://github.com/privacysandbox/attestation">enrolled</a>.
1. Let |p| be [=a new promise=].
1. Let |configMapping| be |global|'s [=associated Document=]'s [=node navigable=]'s
[=navigable/traversable navigable=]'s [=traversable navigable/fenced frame config mapping=].
1. Let |pendingConfig| be the result of [=constructing a pending fenced frame config=] with
|auctionConfig|.
1. Let |urn| be the result of running [=fenced frame config mapping/store a pending config=] on
|configMapping| with |pendingConfig|.
1. If |urn| is failure, then resolve |p| with null and return |p|.
1. Let |bidIgs| be a new [=list=] of [=interest groups=].
1. If |config|["{{AuctionAdConfig/signal}}"] [=map/exists=], then:
1. Let |signal| be |config|["{{AuctionAdConfig/signal}}"].
1. If |signal| is [=AbortSignal/aborted=], then [=reject=] |p| with |signal|'s
[=AbortSignal/abort reason=] and return |p|.
1. [=AbortSignal/Add|Add the following abort steps=] to |signal|:
1. [=Reject=] |p| with |signal|’s [=AbortSignal/abort reason=].
1. Run [=update bid counts=] with |bidIgs|.
1. Run [=interest group update=] with |auctionConfig|'s
[=auction config/interest group buyers=].
1. Let |queue| be the result of [=starting a new parallel queue=].
1. [=parallel queue/enqueue steps|Enqueue the following steps=] to |queue|:
1. Let |winnerInfo| be the result of running [=generate and score bids=] with |auctionConfig|,
null, |global|, |settings|'s [=environment/top-level origin=], and |bidIgs|.
1. If |winnerInfo| is failure, then [=queue a global task=] on [=DOM manipulation task source=],
given |global|, to [=reject=] |p| with a "{{TypeError}}".
1. If |winnerInfo| is null or |winnerInfo|'s [=leading bid info/leading bid=] is null, then
[=queue a global task=] on [=DOM manipulation task source=], given |global|, to resolve |p| with
null.
1. Otherwise:
1. Let |winner| be |winnerInfo|'s [=leading bid info/leading bid=].
1. Let |fencedFrameConfig| be the result of [=filling in a pending fenced frame config=] with
|pendingConfig|, |auctionConfig|, and |winnerInfo|.
1. [=fenced frame config mapping/Finalize a pending config=] on |configMapping| with |urn| and
|fencedFrameConfig|.
1. Wait until |auctionConfig|'s [=auction config/resolve to config=] is a boolean.
1. Let |result| be |fencedFrameConfig|.
1. If |auctionConfig|'s [=auction config/resolve to config=] is false, then set |result| to |urn|.
1. [=Queue a global task=] on the [=DOM manipulation task source=], given |global|, to
resolve |p| with |result|.
1. [=Increment ad k-anonymity count=] given |winner|'s [=generated bid/interest group=] and
|winner|'s [=generated bid/ad descriptor=]'s [=ad descriptor/url=].
1. If |winner|'s [=generated bid/ad component descriptors=] is not null:
1. [=set/For each=] |adComponentDescriptor| in |winner|'s
[=generated bid/ad component descriptors=]:
1. [=Increment component ad k-anonymity count=] given |adComponentDescriptor|'s
[=ad descriptor/url=].
1. [=Increment reporting ID k-anonymity count=] given |winner|'s
[=generated bid/interest group=] and |winner|'s [=generated bid/ad descriptor=]'s
[=ad descriptor/url=].
1. Run [=interest group update=] with |auctionConfig|'s [=auction config/interest group buyers=].
1. Run [=update bid counts=] with |bidIgs|.
1. Run [=update previous wins=] with |winner|.
1. Return |p|.
</div>
<div algorithm>
To <dfn>construct a pending fenced frame config</dfn> given an [=auction config=]
|config|:
1. Return a [=fenced frame config=] with the following [=struct/items=]:
: [=fenced frame config/mapped url=]
:: a [=struct=] with the following [=struct/items=]:
: [=mapped url/value=]
:: `"about:blank"`
: [=mapped url/visibility=]
:: "<a for=visibility>`opaque`</a>"
: [=fenced frame config/container size=]
:: TODO: fill this in once container size is spec'd to be in |config|
: [=fenced frame config/content size=]
:: null
: [=fenced frame config/interest group descriptor=]
:: a [=struct=] with the following [=struct/items=]:
: [=interest group descriptor/value=]
:: a [=struct=] with the following [=struct/items=]:
: [=interest group descriptor/owner=]
:: ""
: [=interest group descriptor/name=]
:: ""
: [=interest group descriptor/visibility=]
:: "<a for=visibility>`opaque`</a>"
: [=fenced frame config/on navigate callback=]
:: null
: [=fenced frame config/effective sandbox flags=]
:: a [=struct=] with the following [=struct/items=]:
: [=effective sandbox flags/value=]
:: TODO: fill this in once fenced frame sandbox flags are more fully specified
: [=effective sandbox flags/visibility=]
:: "<a for=visibility>`opaque`</a>"
: [=fenced frame config/effective enabled permissions=]
:: a [=struct=] with the following [=struct/items=]:
: [=effective enabled permissions/value=]
:: «"<code>{{PermissionPolicy/attribution-reporting}}</code>",
"<code>[=private-aggregation=]</code>", "<code>[=shared-storage=]</code>",
"<code>[=shared-storage-select-url=]</code>"»
: [=effective enabled permissions/visibility=]
:: "<a for=visibility>`opaque`</a>"
: [=fenced frame config/fenced frame reporting metadata=]
:: null
: [=fenced frame config/exfiltration budget metadata=]
:: null
: [=fenced frame config/nested configs=]
:: a [=struct=] with the following [=struct/items=]:
: [=nested configs/value=]
:: an empty [=list=] «»
: [=nested configs/visibility=]
:: "<a for=visibility>`opaque`</a>"
: [=fenced frame config/embedder shared storage context=]
:: null
</div>
<div algorithm>
To <dfn>fill in a pending fenced frame config</dfn> given a [=fenced frame config=]
|pendingConfig|, [=auction config=] |auctionConfig|, and [=leading bid info=] |winningBidInfo|:
1. Let |winningBid| be |winningBidInfo|'s [=leading bid info/leading bid=].
1. Set |pendingConfig|'s [=fenced frame config/mapped url=]'s [=mapped url/value=] to
|winningBid|'s [=generated bid/ad descriptor=]'s [=ad descriptor/url=].
1. Let |adSize| be |winningBid|'s [=generated bid/ad descriptor=]'s [=ad descriptor/size=].
1. If |adSize| is not null:
1. Set |pendingConfig|'s [=fenced frame config/content size=] to a [=struct=] with the following
[=struct/items=]:
: [=content size/value=]
:: |adSize| TODO: Resolve screen-relative sizes and macros and cast this properly.
: [=content size/visibility=]
:: "<a for=visibility>`opaque`</a>"
1. Set |pendingConfig|'s [=fenced frame config/interest group descriptor=]'s
[=interest group descriptor/value=] to a [=struct=] with the following [=struct/items=]:
: owner
:: |winningBid|'s [=generated bid/interest group=]'s [=interest group/owner=]
: name
:: |winningBid|'s [=generated bid/interest group=]'s [=interest group/name=]
1. Let |fencedFrameReportingMap| be the [=map=] «[ "`buyer`" → «», "`seller`" → «» ]».
1. If |auctionConfig|'s [=auction config/component auctions=] is [=list/empty=], then [=map/set=]
|fencedFrameReportingMap|["`component-seller`"] to an empty [=list=] «».
1. Set |pendingConfig|'s [=fenced frame config/fenced frame reporting metadata=] to a [=struct=]
with the following [=struct/items=]:
: [=fenced frame reporting metadata/value=]
:: A [=struct=] with the following [=struct/items=]:
: [=fenced frame reporting metadata/fenced frame reporting map=]
:: |fencedFrameReportingMap|
: [=fenced frame reporting metadata/direct seller is seller=]
:: true if |auctionConfig|'s [=auction config/component auctions=] is [=list/empty=], false
otherwise
: [=fenced frame reporting metadata/allowed reporting origins=]
:: |winningBid|'s [=generated bid/bid ad=]'s [=interest group ad/allowed reporting origins=]
: [=fenced frame reporting metadata/visibility=]
:: "<a for=visibility>`opaque`</a>"
1. Set |pendingConfig|'s [=fenced frame config/on navigate callback=] to an algorithm with these
steps:
1. [=Asynchronously finish reporting=] with |pendingConfig|'s
[=fenced frame config/fenced frame reporting metadata=]'s
[=fenced frame reporting metadata/value=]'s
[=fenced frame reporting metadata/fenced frame reporting map=] and |winningBidInfo|.
1. Set |pendingConfig|'s [=fenced frame config/nested configs=]'s [=nested configs/value=] to
the result of running [=create nested configs=] with |winningBid|'s
[=generated bid/ad component descriptors=].
1. Return |pendingConfig|.
</div>
<div algorithm>
To <dfn>asynchronously finish reporting</dfn> given a
[=fencedframetype/fenced frame reporting map=] |reportingMap| and [=leading bid info=]
|leadingBidInfo|:
1. Let |buyerDone|, |sellerDone|, and |componentSellerDone| be [=booleans=], initially false.
1. If |leadingBidInfo|'s [=leading bid info/component seller=] is null, set |componentSellerDone|
to true.
1. [=iteration/While=]:
1. If |buyerDone|, |sellerDone|, and |componentSellerDone| are all true, then
[=iteration/break=].
1. Wait until one of the following fields of |leadingBidInfo| being not null:
* [=leading bid info/buyer reporting result=];
* [=leading bid info/seller reporting result=];
* [=leading bid info/component seller reporting result=].
1. If |buyerDone| is false and |leadingBidInfo|'s [=leading bid info/buyer reporting result=]
is not null:
1. Let |buyerMap| be |leadingBidInfo|'s [=leading bid info/buyer reporting result=]'s
[=reporting result/reporting beacon map=].
1. If |buyerMap| is null, set |buyerMap| to an empty [=map=] «[]».
1. Let |macroMap| be |leadingBidInfo|'s [=leading bid info/buyer reporting result=]'s
[=reporting result/reporting macro map=].
1. [=Finalize a reporting destination=] with |reportingMap|,
{{FenceReportingDestination/buyer}}, |buyerMap|, and |macroMap|.
1. [=Send report=] to |leadingBidInfo|'s [=leading bid info/buyer reporting result=]'s
[=reporting result/report url=].
1. Set |buyerDone| to true.
1. If |sellerDone| is false and |leadingBidInfo|'s [=leading bid info/seller reporting result=]
is not null:
1. Let |sellerMap| be |leadingBidInfo|'s [=leading bid info/seller reporting result=]'s
[=reporting result/reporting beacon map=].
1. If |sellerMap| is null, set |sellerMap| to an empty [=map=] «[]».
1. [=Finalize a reporting destination=] with |reportingMap|,
{{FenceReportingDestination/seller}}, and |sellerMap|.
1. [=Send report=] to |leadingBidInfo|'s [=leading bid info/seller reporting result=]'s
[=reporting result/report url=].
1. Set |sellerDone| to true.
1. If |componentSellerDone| is false and |leadingBidInfo|'s
[=leading bid info/component seller reporting result=] is not null:
1. Let |componentSellerMap| be |leadingBidInfo|'s
[=leading bid info/component seller reporting result=]'s
[=reporting result/reporting beacon map=].
1. If |componentSellerMap| is null, set |componentSellerMap| to an empty [=map=] «[]».
1. [=Finalize a reporting destination=] with |reportingMap|,
{{FenceReportingDestination/component-seller}}, and |componentSellerMap|.
1. [=Send report=] to |leadingBidInfo|'s [=leading bid info/component seller reporting result=]'s
[=reporting result/report url=].
1. Set |componentSellerDone| to true.
</div>
<div algorithm>
To <dfn>create nested configs</dfn> given [=generated bid/ad component descriptors=]
|adComponentDescriptors|:
1. Let |nestedConfigs| be an empty [=list=] «».
1. If |adComponentDescriptors| is null:
1. Return |nestedConfigs|.
1. [=set/For each=] |adComponentDescriptor| of |adComponentDescriptors|:
1. Let |fencedFrameConfig| be a [=fenced frame config=] with the following [=struct/items=]:
: [=fenced frame config/mapped url=]
:: a [=struct=] with the following [=struct/items=]:
: [=mapped url/value=]
:: |adComponentDescriptor|'s [=ad descriptor/url=]
: [=mapped url/visibility=]
:: "<a for=visibility>`opaque`</a>"