Skip to content

Commit ba054e9

Browse files
Merge pull request #17 from pm-nitin-shirsat/UOE-10758
Update master with latest
2 parents 6cfb9be + 11e3c90 commit ba054e9

File tree

111 files changed

+7174
-7145
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

111 files changed

+7174
-7145
lines changed

.eslintrc.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ module.exports = {
6161
'no-useless-escape': 'off',
6262
'no-console': 'error',
6363
'jsdoc/check-types': 'off',
64+
'jsdoc/no-defaults': 'off',
6465
'jsdoc/newline-after-description': 'off',
6566
'jsdoc/require-jsdoc': 'off',
6667
'jsdoc/require-param': 'off',
@@ -96,7 +97,7 @@ module.exports = {
9697
// code in other packages (such as plugins/eslint) is not "seen" by babel and its parser will complain.
9798
files: 'plugins/*/**/*.js',
9899
parser: 'esprima'
99-
},
100+
},
100101
{
101102
files: '**BidAdapter.js',
102103
rules: {

creative/constants.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// eslint-disable-next-line prebid/validate-imports
2-
import { AD_RENDER_FAILED_REASON, EVENTS, MESSAGES } from '../src/constants.js';
2+
import {AD_RENDER_FAILED_REASON, EVENTS, MESSAGES} from '../src/constants.js';
33

4+
export {PB_LOCATOR} from '../src/constants.js';
45
export const MESSAGE_REQUEST = MESSAGES.REQUEST;
56
export const MESSAGE_RESPONSE = MESSAGES.RESPONSE;
67
export const MESSAGE_EVENT = MESSAGES.EVENT;

creative/crossDomain.js

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import {
22
ERROR_EXCEPTION,
3-
EVENT_AD_RENDER_FAILED, EVENT_AD_RENDER_SUCCEEDED,
3+
EVENT_AD_RENDER_FAILED,
4+
EVENT_AD_RENDER_SUCCEEDED,
45
MESSAGE_EVENT,
56
MESSAGE_REQUEST,
6-
MESSAGE_RESPONSE
7+
MESSAGE_RESPONSE,
8+
PB_LOCATOR
79
} from './constants.js';
810

911
const mkFrame = (() => {
@@ -24,14 +26,24 @@ const mkFrame = (() => {
2426
};
2527
})();
2628

29+
function isPrebidWindow(win) {
30+
return !!win.frames[PB_LOCATOR];
31+
}
32+
2733
export function renderer(win) {
34+
let target = win.parent;
35+
while (target !== win.top && !isPrebidWindow(target)) {
36+
target = target.parent;
37+
}
38+
if (!isPrebidWindow(target)) target = win.parent;
39+
2840
return function ({adId, pubUrl, clickUrl}) {
2941
const pubDomain = new URL(pubUrl, window.location).origin;
3042

3143
function sendMessage(type, payload, responseListener) {
3244
const channel = new MessageChannel();
3345
channel.port1.onmessage = guard(responseListener);
34-
win.parent.postMessage(JSON.stringify(Object.assign({message: type, adId}, payload)), pubDomain, [channel.port2]);
46+
target.postMessage(JSON.stringify(Object.assign({message: type, adId}, payload)), pubDomain, [channel.port2]);
3547
}
3648

3749
function onError(e) {
@@ -77,7 +89,7 @@ export function renderer(win) {
7789
W.Promise.resolve(W.render(data, {sendMessage, mkFrame}, win)).then(
7890
() => sendMessage(MESSAGE_EVENT, {event: EVENT_AD_RENDER_SUCCEEDED}),
7991
onError
80-
)
92+
);
8193
});
8294
win.document.body.appendChild(renderer);
8395
}

integrationExamples/gpt/x-domain/creative.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// creative will be rendered, e.g. GAM delivering a SafeFrame
33

44
// this code is autogenerated, also available in 'build/creative/creative.js'
5-
<script>!function(){"use strict";const e="Prebid Event",n=(()=>{const e={frameBorder:0,scrolling:"no",marginHeight:0,marginWidth:0,topMargin:0,leftMargin:0,allowTransparency:"true"};return(n,t)=>{const r=n.createElement("iframe");return Object.entries(Object.assign({},t,e)).forEach((([e,n])=>r.setAttribute(e,n))),r}})();var t;window.pbRender=(t=window,function({adId:r,pubUrl:s,clickUrl:o}){const i=new URL(s,window.location).origin;function a(e,n,s){const o=new MessageChannel;o.port1.onmessage=d(s),t.parent.postMessage(JSON.stringify(Object.assign({message:e,adId:r},n)),i,[o.port2])}function c(n){a(e,{event:"adRenderFailed",info:{reason:n?.reason||"exception",message:n?.message}}),n?.stack&&console.error(n)}function d(e){return function(){try{return e.apply(this,arguments)}catch(e){c(e)}}}a("Prebid Request",{options:{clickUrl:o}},(function(s){let o;try{o=JSON.parse(s.data)}catch(e){return}if("Prebid Response"===o.message&&o.adId===r){const r=n(t.document,{width:0,height:0,style:"display: none",srcdoc:`<script>${o.renderer}<\/script>`});r.onload=d((function(){const s=r.contentWindow;s.Promise.resolve(s.render(o,{sendMessage:a,mkFrame:n},t)).then((()=>a(e,{event:"adRenderSucceeded"})),c)})),t.document.body.appendChild(r)}}))})}();</script>
5+
<script>(()=>{"use strict";const e="Prebid Event",n=(()=>{const e={frameBorder:0,scrolling:"no",marginHeight:0,marginWidth:0,topMargin:0,leftMargin:0,allowTransparency:"true"};return(n,t)=>{const r=n.createElement("iframe");return Object.entries(Object.assign({},t,e)).forEach((([e,n])=>r.setAttribute(e,n))),r}})();function t(e){return!!e.frames.__pb_locator__}window.pbRender=function(r){let o=r.parent;for(;o!==r.top&&!t(o);)o=o.parent;return t(o)||(o=r.parent),function({adId:t,pubUrl:s,clickUrl:i}){const a=new URL(s,window.location).origin;function c(e,n,r){const s=new MessageChannel;s.port1.onmessage=l(r),o.postMessage(JSON.stringify(Object.assign({message:e,adId:t},n)),a,[s.port2])}function d(n){c(e,{event:"adRenderFailed",info:{reason:n?.reason||"exception",message:n?.message}}),n?.stack&&console.error(n)}function l(e){return function(){try{return e.apply(this,arguments)}catch(e){d(e)}}}c("Prebid Request",{options:{clickUrl:i}},(function(o){let s;try{s=JSON.parse(o.data)}catch(e){return}if("Prebid Response"===s.message&&s.adId===t){const t=n(r.document,{width:0,height:0,style:"display: none",srcdoc:`<script>${s.renderer}<\/script>`});t.onload=l((function(){const o=t.contentWindow;o.Promise.resolve(o.render(s,{sendMessage:c,mkFrame:n},r)).then((()=>c(e,{event:"adRenderSucceeded"})),d)})),r.document.body.appendChild(t)}}))}}(window)})();</script>
66

77
<script>
88
pbRender({

libraries/creative-renderer-display/renderer.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

libraries/creative-renderer-native/renderer.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

libraries/processResponse/index.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { logError } from '../../src/utils.js';
2+
3+
export function getBidFromResponse(respItem, LOG_ERROR_MESS) {
4+
if (!respItem) {
5+
logError(LOG_ERROR_MESS.emptySeatbid);
6+
} else if (!respItem.bid) {
7+
logError(LOG_ERROR_MESS.hasNoArrayOfBids + JSON.stringify(respItem));
8+
} else if (!respItem.bid[0]) {
9+
logError(LOG_ERROR_MESS.noBid);
10+
}
11+
return respItem && respItem.bid && respItem.bid[0];
12+
}

libraries/vidazooUtils/bidderUtils.js

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ export function appendUserIdsToRequestPayload(payloadRef, userIds) {
200200
let key;
201201
_each(userIds, (userId, idSystemProviderName) => {
202202
key = `uid.${idSystemProviderName}`;
203+
203204
switch (idSystemProviderName) {
204205
case 'lipb':
205206
payloadRef[key] = userId.lipbid;
@@ -217,7 +218,7 @@ export function getVidazooSessionId(storage) {
217218
return getStorageItem(storage, SESSION_ID_KEY) || '';
218219
}
219220

220-
export function buildRequestData(bid, topWindowUrl, sizes, bidderRequest, bidderTimeout, webSessionId, storage, bidderVersion, bidderCode, getUniqueRequestData) {
221+
export function buildRequestData(bid, topWindowUrl, sizes, bidderRequest, bidderTimeout, storage, bidderVersion, bidderCode, getUniqueRequestData) {
221222
const {
222223
params,
223224
bidId,
@@ -234,7 +235,7 @@ export function buildRequestData(bid, topWindowUrl, sizes, bidderRequest, bidder
234235
const {ext} = params;
235236
let {bidFloor} = params;
236237
const hashUrl = hashCode(topWindowUrl);
237-
const uniqueRequestData = isFn(getUniqueRequestData) ? getUniqueRequestData(hashUrl) : {};
238+
const uniqueRequestData = isFn(getUniqueRequestData) ? getUniqueRequestData(hashUrl, bid) : {};
238239
const uniqueDealId = getUniqueDealId(storage, hashUrl);
239240
const pId = extractPID(params);
240241
const isStorageAllowed = bidderSettings.get(bidderCode, 'storageAllowed');
@@ -285,7 +286,6 @@ export function buildRequestData(bid, topWindowUrl, sizes, bidderRequest, bidder
285286
bidderRequestsCount: bidderRequestsCount,
286287
bidderWinsCount: bidderWinsCount,
287288
bidderTimeout: bidderTimeout,
288-
webSessionId: webSessionId,
289289
...uniqueRequestData
290290
};
291291

@@ -331,13 +331,13 @@ export function buildRequestData(bid, topWindowUrl, sizes, bidderRequest, bidder
331331
return data;
332332
}
333333

334-
export function createInterpretResponseFn(bidderCode) {
334+
export function createInterpretResponseFn(bidderCode, allowSingleRequest) {
335335
return function interpretResponse(serverResponse, request) {
336336
if (!serverResponse || !serverResponse.body) {
337337
return [];
338338
}
339339

340-
const singleRequestMode = config.getConfig(`${bidderCode}.singleRequest`);
340+
const singleRequestMode = allowSingleRequest && config.getConfig(`${bidderCode}.singleRequest`);
341341
const reqBidId = deepAccess(request, 'data.bidId');
342342
const {results} = serverResponse.body;
343343

@@ -410,12 +410,12 @@ export function createInterpretResponseFn(bidderCode) {
410410
}
411411
}
412412

413-
export function createBuildRequestsFn(createRequestDomain, createUniqueRequestData, webSessionId, storage, bidderCode, bidderVersion) {
413+
export function createBuildRequestsFn(createRequestDomain, createUniqueRequestData, storage, bidderCode, bidderVersion, allowSingleRequest) {
414414
function buildRequest(bid, topWindowUrl, sizes, bidderRequest, bidderTimeout) {
415415
const {params} = bid;
416416
const cId = extractCID(params);
417417
const subDomain = extractSubDomain(params);
418-
const data = buildRequestData(bid, topWindowUrl, sizes, bidderRequest, bidderTimeout, webSessionId, storage, bidderVersion, bidderCode, createUniqueRequestData);
418+
const data = buildRequestData(bid, topWindowUrl, sizes, bidderRequest, bidderTimeout, storage, bidderVersion, bidderCode, createUniqueRequestData);
419419
const dto = {
420420
method: 'POST', url: `${createRequestDomain(subDomain)}/prebid/multi/${cId}`, data: data
421421
};
@@ -428,7 +428,7 @@ export function createBuildRequestsFn(createRequestDomain, createUniqueRequestDa
428428
const subDomain = extractSubDomain(params);
429429
const data = bidRequests.map(bid => {
430430
const sizes = parseSizesInput(bid.sizes);
431-
return buildRequestData(bid, topWindowUrl, sizes, bidderRequest, bidderTimeout, webSessionId, storage, bidderVersion, bidderCode, createUniqueRequestData)
431+
return buildRequestData(bid, topWindowUrl, sizes, bidderRequest, bidderTimeout, storage, bidderVersion, bidderCode, createUniqueRequestData)
432432
});
433433
const chunkSize = Math.min(20, config.getConfig(`${bidderCode}.chunkSize`) || 10);
434434

@@ -445,11 +445,10 @@ export function createBuildRequestsFn(createRequestDomain, createUniqueRequestDa
445445
}
446446

447447
return function buildRequests(validBidRequests, bidderRequest) {
448-
// TODO: does the fallback make sense here?
449448
const topWindowUrl = bidderRequest.refererInfo.page || bidderRequest.refererInfo.topmostLocation;
450449
const bidderTimeout = config.getConfig('bidderTimeout');
451450

452-
const singleRequestMode = config.getConfig('vidazoo.singleRequest');
451+
const singleRequestMode = allowSingleRequest && config.getConfig(`${bidderCode}.singleRequest`);
453452

454453
const requests = [];
455454

modules/.submodules.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@
9797
"reconciliationRtdProvider",
9898
"relevadRtdProvider",
9999
"sirdataRtdProvider",
100+
"symitriDapRtdProvider",
100101
"timeoutRtdProvider",
101102
"weboramaRtdProvider"
102103
],

modules/adagioBidAdapter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ export const spec = {
576576
sessionData.rnd = Math.random()
577577
}
578578

579-
const aucId = deepAccess('bidderRequest', 'ortb2.site.ext.data.adg_rtd.uid') || generateUUID()
579+
const aucId = deepAccess(bidderRequest, 'ortb2.site.ext.data.adg_rtd.uid') || generateUUID()
580580

581581
const adUnits = validBidRequests.map(rawBidRequest => {
582582
const bidRequest = deepClone(rawBidRequest);

modules/adagioRtdProvider.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -278,15 +278,18 @@ function onGetBidRequestData(bidReqConfig, callback, config) {
278278

279279
const adUnits = bidReqConfig.adUnits || getGlobal().adUnits || [];
280280
adUnits.forEach(adUnit => {
281+
adUnit.ortb2Imp = adUnit.ortb2Imp || {};
281282
const ortb2Imp = deepAccess(adUnit, 'ortb2Imp');
283+
282284
// A divId is required to compute the slot position and later to track viewability.
283285
// If nothing has been explicitly set, we try to get the divId from the GPT slot and fallback to the adUnit code in last resort.
284-
if (!deepAccess(ortb2Imp, 'ext.data.divId')) {
285-
const divId = getGptSlotInfoForAdUnitCode(adUnit.code).divId;
286+
let divId = deepAccess(ortb2Imp, 'ext.data.divId')
287+
if (!divId) {
288+
divId = getGptSlotInfoForAdUnitCode(adUnit.code).divId;
286289
deepSetValue(ortb2Imp, `ext.data.divId`, divId || adUnit.code);
287290
}
288291

289-
const slotPosition = getSlotPosition(adUnit);
292+
const slotPosition = getSlotPosition(divId);
290293
deepSetValue(ortb2Imp, `ext.data.adg_rtd.adunit_position`, slotPosition);
291294

292295
// It is expected that the publisher set a `adUnits[].ortb2Imp.ext.data.placement` value.
@@ -430,7 +433,7 @@ function getElementFromTopWindow(element, currentWindow) {
430433
}
431434
};
432435

433-
function getSlotPosition(adUnit) {
436+
function getSlotPosition(divId) {
434437
if (!isSafeFrameWindow() && !canAccessWindowTop()) {
435438
return '';
436439
}
@@ -451,16 +454,15 @@ function getSlotPosition(adUnit) {
451454
// window.top based computing
452455
const wt = getWindowTop();
453456
const d = wt.document;
454-
const adUnitElementId = deepAccess(adUnit, 'ortb2Imp.ext.data.divId');
455457

456458
let domElement;
457459

458460
if (inIframe() === true) {
459461
const ws = getWindowSelf();
460-
const currentElement = ws.document.getElementById(adUnitElementId);
462+
const currentElement = ws.document.getElementById(divId);
461463
domElement = getElementFromTopWindow(currentElement, ws);
462464
} else {
463-
domElement = wt.document.getElementById(adUnitElementId);
465+
domElement = wt.document.getElementById(divId);
464466
}
465467

466468
if (!domElement) {

modules/adfBidAdapter.js

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import {registerBidder} from '../src/adapters/bidderFactory.js';
55
import {BANNER, NATIVE, VIDEO} from '../src/mediaTypes.js';
6-
import {deepAccess, deepClone, deepSetValue, mergeDeep, parseSizesInput} from '../src/utils.js';
6+
import {deepAccess, deepClone, deepSetValue, mergeDeep, parseSizesInput, setOnAny} from '../src/utils.js';
77
import {config} from '../src/config.js';
88
import {Renderer} from '../src/Renderer.js';
99

@@ -255,15 +255,6 @@ export const spec = {
255255

256256
registerBidder(spec);
257257

258-
function setOnAny(collection, key) {
259-
for (let i = 0, result; i < collection.length; i++) {
260-
result = deepAccess(collection[i], key);
261-
if (result) {
262-
return result;
263-
}
264-
}
265-
}
266-
267258
function flatten(arr) {
268259
return [].concat(...arr);
269260
}

modules/adkernelBidAdapter.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@ export const spec = {
9595
{code: 'headbidder'},
9696
{code: 'digiad'},
9797
{code: 'monetix'},
98-
{code: 'hyperbrainz'}
98+
{code: 'hyperbrainz'},
99+
{code: 'globalsun'}
99100
],
100101
supportedMediaTypes: [BANNER, VIDEO, NATIVE],
101102

0 commit comments

Comments
 (0)