Skip to content

Commit

Permalink
Merge branch 'prebid:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
krzysztofequativ authored Feb 5, 2025
2 parents d165eee + 2029e09 commit eedd65b
Show file tree
Hide file tree
Showing 147 changed files with 5,341 additions and 2,116 deletions.
37 changes: 29 additions & 8 deletions creative/renderers/native/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,16 @@ function loadScript(url, doc) {
});
}

function getRenderFrames(node) {
return Array.from(node.querySelectorAll('iframe[srcdoc*="render"]'))
}

function getInnerHTML(node) {
const clone = node.cloneNode(true);
getRenderFrames(clone).forEach(node => node.parentNode.removeChild(node));
return clone.innerHTML;
}

export function getAdMarkup(adId, nativeData, replacer, win, load = loadScript) {
const {rendererUrl, assets, ortb, adTemplate} = nativeData;
const doc = win.document;
Expand All @@ -58,21 +68,32 @@ export function getAdMarkup(adId, nativeData, replacer, win, load = loadScript)
return win.renderAd(payload);
});
} else {
return Promise.resolve(replacer(adTemplate ?? doc.body.innerHTML));
return Promise.resolve(replacer(adTemplate ?? getInnerHTML(doc.body)));
}
}

export function render({adId, native}, {sendMessage}, win, getMarkup = getAdMarkup) {
const {head, body} = win.document;
const resize = () => sendMessage(MESSAGE_NATIVE, {
action: ACTION_RESIZE,
height: body.offsetHeight,
width: body.offsetWidth
});
const resize = () => {
// force redraw - for some reason this is needed to get the right dimensions
body.style.display = 'none';
body.style.display = 'block';
sendMessage(MESSAGE_NATIVE, {
action: ACTION_RESIZE,
height: body.offsetHeight,
width: body.offsetWidth
});
}
function replaceMarkup(target, markup) {
// do not remove the rendering logic if it's embedded in this window; things will break otherwise
const renderFrames = getRenderFrames(target);
Array.from(target.childNodes).filter(node => !renderFrames.includes(node)).forEach(node => target.removeChild(node));
target.insertAdjacentHTML('afterbegin', markup);
}
const replacer = getReplacer(adId, native);
head && (head.innerHTML = replacer(head.innerHTML));
replaceMarkup(head, replacer(getInnerHTML(head)));
return getMarkup(adId, native, replacer, win).then(markup => {
body.innerHTML = markup;
replaceMarkup(body, markup);
if (typeof win.postRenderAd === 'function') {
win.postRenderAd({adId, ...native});
}
Expand Down
164 changes: 164 additions & 0 deletions integrationExamples/gpt/liveIntentRtdProviderExample.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
<html>
<head>
<link rel="icon" type="image/png" href="/favicon.png">
<script async src="//www.googletagservices.com/tag/js/gpt.js"></script>
<script async src="../../build/dev/prebid.js"></script>
<script>
var div_1_sizes = [
[300, 250],
[300, 600]
];
var div_2_sizes = [
[728, 90],
[970, 250]
];
var PREBID_TIMEOUT = 1000;
var FAILSAFE_TIMEOUT = 3000;
var adUnits = [
{
code: '/19968336/header-bid-tag-0',
mediaTypes: {
banner: {
sizes: div_1_sizes
}
},
bids: [{
bidder: 'appnexus',
params: {
siteId: 'examplePub123', // required
productId: 'siab|inview' // required
}
}]
},
{
code: '/19968336/header-bid-tag-1',
mediaTypes: {
banner: {
sizes: div_2_sizes
}
},
bids: [{
bidder: 'appnexus',
params: {
siteId: 'examplePub123', // required
productId: 'siab|inview' // required
}
}]
}
];
// ======== DO NOT EDIT BELOW THIS LINE =========== //
var googletag = googletag || {};
googletag.cmd = googletag.cmd || [];
googletag.cmd.push(function() {
googletag.pubads().disableInitialLoad();
});
var pbjs = pbjs || {};
pbjs.que = pbjs.que || [];
pbjs.que.push(function() {
pbjs.setConfig({
debug: true,
realTimeData: {
dataProviders:[{
name: "liveintent",
waitForIt: true
}]
},
"consentManagement": {
"cmpApi": "static",
"consentData": {
"getTCData": {
"tcString": "CO-HDlqO-HDlqAKAXCENBDCsAP_AAH_AACiQHKNd_X_fb39j-_59_9t0eY1f9_7_v20zjgeds-8Nyd_X_L8X42M7vF36pq4KuR4Eu3LBIQFlHOHcTUmw6IkVqTPsak2Mr7NKJ7PEinMbe2dYGHtfn9VTuZKYr97s___z__-__v__75f_r-3_3_vp9V---_fA5QAkw1L4CLMSxwJJo0qhRAhCuJDoAQAUUIwtE1hASuCnZXAR-ggYAIDUBGBECDEFGLIIAAAAAkoiAkAPBAIgCIBAACAFSAhAARoAgsAJAwCAAUA0LACKAIQJCDI4KjlMCAiRaKCeSMASi72MMIQyigBoFH4AAAAA.cAAAAAAAAAAA",
"cmpId": 10,
"cmpVersion": 23,
"tcfPolicyVersion": 2,
"gdprApplies": true,
"cmpStatus": "loaded",
"eventStatus": "tcloaded",
"purpose": {
"consents": {
"1": true,
"2": true
}
},
"vendor": {
"consents": {
// add your GVL ID here and set to true to give consent within pbjs
"148": true, // liveintent
}
}
}
}
},
userSync: {
auctionDelay: 1000,
userIds: [
{
"name": "liveIntentId",
"params": {
"liCollectConfig" : {
"distributorId" : "did-0000"
}
},
"value" : {
"lipbid":
{
"segments": ["asa_1231", "lalo_4311", "liurl_99123"],
}
}
}
]
}
});
pbjs.addAdUnits(adUnits);
pbjs.requestBids({
bidsBackHandler: initAdserver,
timeout: PREBID_TIMEOUT
});
});
function initAdserver() {
if (pbjs.initAdserverSet) return;
pbjs.initAdserverSet = true;
googletag.cmd.push(function() {
pbjs.que.push(function() {
pbjs.setTargetingForGPTAsync();
googletag.pubads().refresh();
});
});
}
// in case PBJS doesn't load
setTimeout(function() {
initAdserver();
}, FAILSAFE_TIMEOUT);
googletag.cmd.push(function() {
googletag.defineSlot('/19968336/header-bid-tag-0', div_1_sizes, 'div-1').addService(googletag.pubads());
googletag.pubads().enableSingleRequest();
googletag.enableServices();
});
googletag.cmd.push(function() {
googletag.defineSlot('/19968336/header-bid-tag-1', div_2_sizes, 'div-2').addService(googletag.pubads());
googletag.pubads().enableSingleRequest();
googletag.enableServices();
});
</script>
</head>
<body>
<h2>Basic Prebid.js Example</h2>
<h5>Div-1</h5>
<div id='div-1'>
<script type='text/javascript'>
googletag.cmd.push(function() {
googletag.display('div-1');
});
</script>
</div>
<br>
<h5>Div-2</h5>
<div id='div-2'>
<script type='text/javascript'>
googletag.cmd.push(function() {
googletag.display('div-2');
});
</script>
</div>
</body>
</html>
6 changes: 3 additions & 3 deletions integrationExamples/gpt/x-domain/creative.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

<script>
pbRender({
adId: '%%PATTERN:hb_adid%%',
pubUrl: '%%PATTERN:url%%',
clickUrl: '%%CLICK_URL_UNESC%%'
adId: "%%PATTERN:hb_adid%%",
pubUrl: "%%PATTERN:url%%",
clickUrl: "%%CLICK_URL_UNESC%%"
});
</script>
2 changes: 1 addition & 1 deletion libraries/creative-renderer-native/renderer.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion libraries/intentIqConstants/intentIqConstants.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ export const OPT_OUT = 'O';
export const BLACK_LIST = 'L';
export const CLIENT_HINTS_KEY = '_iiq_ch';
export const EMPTY = 'EMPTY'
export const VERSION = 0.24
export const VERSION = 0.25
23 changes: 18 additions & 5 deletions libraries/liveIntentId/shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,8 @@ export function composeIdObject(value) {

// old versions stored lipbid in unifiedId. Ensure that we can still read the data.
const lipbid = value.nonId || value.unifiedId
if (lipbid) {
const lipb = { ...value, lipbid };
delete lipb.unifiedId;
result.lipb = lipb;
}
result.lipb = lipbid ? { ...value, lipbid } : value
delete result.lipb?.unifiedId

// Lift usage of uid2 by exposing uid2 if we were asked to resolve it.
// As adapters are applied in lexicographical order, we will always
Expand All @@ -76,6 +73,10 @@ export function composeIdObject(value) {
result.bidswitch = { 'id': value.bidswitch, ext: { provider: LI_PROVIDER_DOMAIN } }
}

if (value.triplelift) {
result.triplelift = { 'id': value.triplelift, ext: { provider: LI_PROVIDER_DOMAIN } }
}

if (value.medianet) {
result.medianet = { 'id': value.medianet, ext: { provider: LI_PROVIDER_DOMAIN } }
}
Expand Down Expand Up @@ -261,6 +262,18 @@ export const eids = {
}
}
},
'triplelift': {
source: 'liveintent.triplelift.com',
atype: 3,
getValue: function(data) {
return data.id;
},
getUidExt: function(data) {
if (data.ext) {
return data.ext;
}
}
},
'vidazoo': {
source: 'liveintent.vidazoo.com',
atype: 3,
Expand Down
33 changes: 26 additions & 7 deletions libraries/mspa/activityControls.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ export function isBasicConsentDenied(cd) {
cd.PersonalDataConsents === 2 ||
// minors 13+ who have not given consent
cd.KnownChildSensitiveDataConsents[0] === 1 ||
// minors 16+ who have not given consent (added in usnat version 2)
cd.KnownChildSensitiveDataConsents[2] === 1 ||
// minors under 13 cannot consent
isApplicable(cd.KnownChildSensitiveDataConsents[1]) ||
// covered cannot be zero
Expand Down Expand Up @@ -53,14 +55,31 @@ export function isConsentDenied(cd) {
}

export const isTransmitUfpdConsentDenied = (() => {
// deny anything that smells like: genetic, biometric, state/national ID, financial, union membership,
// or personal communication data
const cannotBeInScope = [6, 7, 9, 10, 12].map(el => --el);
// require consent for everything else (except geo, which is treated separately)
const allExceptGeo = Array.from(Array(12).keys()).filter((el) => el !== SENSITIVE_DATA_GEO)
const mustHaveConsent = allExceptGeo.filter(el => !cannotBeInScope.includes(el));
const sensitiveFlags = (() => {
// deny anything that smells like: genetic, biometric, state/national ID, financial, union membership,
// personal communication data, status as victim of crime (version 2), status as transgender/nonbinary (version 2)
const cannotBeInScope = [6, 7, 9, 10, 12, 14, 16].map(el => --el);
// require consent for everything else (except geo, which is treated separately)
const allExceptGeo = Array.from(Array(16).keys()).filter((el) => el !== SENSITIVE_DATA_GEO)
const mustHaveConsent = allExceptGeo.filter(el => !cannotBeInScope.includes(el));

return Object.fromEntries(
Object.entries({
1: 12,
2: 16
}).map(([version, cardinality]) => {
const isInVersion = (el) => el < cardinality
return [version, {
cannotBeInScope: cannotBeInScope.filter(isInVersion),
allExceptGeo: allExceptGeo.filter(isInVersion),
mustHaveConsent: mustHaveConsent.filter(isInVersion)
}]
})
)
})()

return function (cd) {
const {cannotBeInScope, mustHaveConsent, allExceptGeo} = sensitiveFlags[cd.Version];
return isConsentDenied(cd) ||
// no notice about sensitive data was given
sensitiveNoticeIs(cd, 2) ||
Expand Down Expand Up @@ -97,7 +116,7 @@ export function mspaRule(sids, getConsent, denies, applicableSids = () => gppDat
if (consent == null) {
return {allow: false, reason: 'consent data not available'};
}
if (consent.Version !== 1) {
if (![1, 2].includes(consent.Version)) {
return {allow: false, reason: `unsupported consent specification version "${consent.Version}"`}
}
if (denies(consent)) {
Expand Down
Loading

0 comments on commit eedd65b

Please sign in to comment.