prebid.js 6.1.0 → 6.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/browsers.json +13 -29
- package/karma.conf.maker.js +1 -1
- package/modules/admixerBidAdapter.js +2 -1
- package/modules/adnuntiusBidAdapter.js +2 -1
- package/modules/adplusBidAdapter.js +203 -0
- package/modules/adplusBidAdapter.md +39 -0
- package/modules/adyoulikeBidAdapter.js +7 -2
- package/modules/appnexusBidAdapter.js +19 -2
- package/modules/beachfrontBidAdapter.js +14 -17
- package/modules/craftBidAdapter.js +5 -3
- package/modules/dchain.js +149 -0
- package/modules/dchain.md +45 -0
- package/modules/emx_digitalBidAdapter.js +9 -1
- package/modules/freewheel-sspBidAdapter.js +6 -0
- package/modules/goldbachBidAdapter.js +1176 -0
- package/modules/goldbachBidAdapter.md +151 -0
- package/modules/gumgumBidAdapter.js +5 -1
- package/modules/intersectionRtdProvider.js +114 -0
- package/modules/invibesBidAdapter.js +15 -9
- package/modules/ipromBidAdapter.js +79 -0
- package/modules/limelightDigitalBidAdapter.js +2 -1
- package/modules/luponmediaBidAdapter.js +570 -0
- package/modules/missenaBidAdapter.js +89 -0
- package/modules/pubmaticBidAdapter.js +3 -3
- package/modules/relaidoBidAdapter.js +86 -65
- package/modules/richaudienceBidAdapter.js +1 -1
- package/modules/smaatoBidAdapter.js +4 -1
- package/modules/smartxBidAdapter.js +17 -1
- package/modules/tappxBidAdapter.js +3 -1
- package/modules/undertoneBidAdapter.js +8 -1
- package/modules/userId/index.js +27 -2
- package/modules/ventes.md +71 -0
- package/modules/ventesBidAdapter.js +104 -64
- package/modules/ventesBidAdapter.md +0 -1
- package/modules/visxBidAdapter.js +19 -2
- package/modules/visxBidAdapter.md +4 -6
- package/modules/yahoosspBidAdapter.md +1 -1
- package/modules/yieldoneBidAdapter.js +115 -11
- package/package.json +1 -1
- package/src/auction.js +3 -2
- package/src/targeting.js +2 -2
- package/src/utils.js +7 -0
- package/test/spec/integration/faker/googletag.js +6 -0
- package/test/spec/modules/adnuntiusBidAdapter_spec.js +18 -0
- package/test/spec/modules/adplusBidAdapter_spec.js +213 -0
- package/test/spec/modules/adyoulikeBidAdapter_spec.js +26 -0
- package/test/spec/modules/appnexusBidAdapter_spec.js +49 -1
- package/test/spec/modules/beachfrontBidAdapter_spec.js +65 -1
- package/test/spec/modules/dchain_spec.js +329 -0
- package/test/spec/modules/emx_digitalBidAdapter_spec.js +10 -0
- package/test/spec/modules/freewheel-sspBidAdapter_spec.js +19 -0
- package/test/spec/modules/goldbachBidAdapter_spec.js +1359 -0
- package/test/spec/modules/gumgumBidAdapter_spec.js +6 -0
- package/test/spec/modules/intersectionRtdProvider_spec.js +141 -0
- package/test/spec/modules/invibesBidAdapter_spec.js +29 -4
- package/test/spec/modules/ipromBidAdapter_spec.js +195 -0
- package/test/spec/modules/limelightDigitalBidAdapter_spec.js +10 -7
- package/test/spec/modules/luponmediaBidAdapter_spec.js +412 -0
- package/test/spec/modules/missenaBidAdapter_spec.js +134 -0
- package/test/spec/modules/pubmaticBidAdapter_spec.js +1 -1
- package/test/spec/modules/relaidoBidAdapter_spec.js +71 -63
- package/test/spec/modules/smaatoBidAdapter_spec.js +31 -0
- package/test/spec/modules/smartxBidAdapter_spec.js +9 -0
- package/test/spec/modules/tappxBidAdapter_spec.js +4 -0
- package/test/spec/modules/userId_spec.js +51 -0
- package/test/spec/modules/visxBidAdapter_spec.js +120 -4
- package/test/spec/modules/yieldoneBidAdapter_spec.js +299 -53
- package/test/spec/unit/core/targeting_spec.js +44 -0
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import includes from 'core-js-pure/features/array/includes.js';
|
|
2
|
+
import { config } from '../src/config.js';
|
|
3
|
+
import { getHook } from '../src/hook.js';
|
|
4
|
+
import { _each, isStr, isArray, isPlainObject, hasOwn, deepClone, deepAccess, logWarn, logError } from '../src/utils.js';
|
|
5
|
+
|
|
6
|
+
const shouldBeAString = ' should be a string';
|
|
7
|
+
const shouldBeAnObject = ' should be an object';
|
|
8
|
+
const shouldBeAnArray = ' should be an Array';
|
|
9
|
+
const shouldBeValid = ' is not a valid dchain property';
|
|
10
|
+
const MODE = {
|
|
11
|
+
STRICT: 'strict',
|
|
12
|
+
RELAXED: 'relaxed',
|
|
13
|
+
OFF: 'off'
|
|
14
|
+
};
|
|
15
|
+
const MODES = []; // an array of modes
|
|
16
|
+
_each(MODE, mode => MODES.push(mode));
|
|
17
|
+
|
|
18
|
+
export function checkDchainSyntax(bid, mode) {
|
|
19
|
+
let dchainObj = deepClone(bid.meta.dchain);
|
|
20
|
+
let failPrefix = 'Detected something wrong in bid.meta.dchain object for bid:';
|
|
21
|
+
let failMsg = '';
|
|
22
|
+
const dchainPropList = ['ver', 'complete', 'nodes', 'ext'];
|
|
23
|
+
|
|
24
|
+
function appendFailMsg(msg) {
|
|
25
|
+
failMsg += '\n' + msg;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function printFailMsg() {
|
|
29
|
+
if (mode === MODE.STRICT) {
|
|
30
|
+
logError(failPrefix, bid, '\n', dchainObj, failMsg);
|
|
31
|
+
} else {
|
|
32
|
+
logWarn(failPrefix, bid, `\n`, dchainObj, failMsg);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
let dchainProps = Object.keys(dchainObj);
|
|
37
|
+
dchainProps.forEach(prop => {
|
|
38
|
+
if (!includes(dchainPropList, prop)) {
|
|
39
|
+
appendFailMsg(`dchain.${prop}` + shouldBeValid);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
if (dchainObj.complete !== 0 && dchainObj.complete !== 1) {
|
|
44
|
+
appendFailMsg(`dchain.complete should be 0 or 1`);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (!isStr(dchainObj.ver)) {
|
|
48
|
+
appendFailMsg(`dchain.ver` + shouldBeAString);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (hasOwn(dchainObj, 'ext')) {
|
|
52
|
+
if (!isPlainObject(dchainObj.ext)) {
|
|
53
|
+
appendFailMsg(`dchain.ext` + shouldBeAnObject);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (!isArray(dchainObj.nodes)) {
|
|
58
|
+
appendFailMsg(`dchain.nodes` + shouldBeAnArray);
|
|
59
|
+
printFailMsg();
|
|
60
|
+
if (mode === MODE.STRICT) return false;
|
|
61
|
+
} else {
|
|
62
|
+
const nodesPropList = ['asi', 'bsid', 'rid', 'name', 'domain', 'ext'];
|
|
63
|
+
dchainObj.nodes.forEach((node, index) => {
|
|
64
|
+
if (!isPlainObject(node)) {
|
|
65
|
+
appendFailMsg(`dchain.nodes[${index}]` + shouldBeAnObject);
|
|
66
|
+
} else {
|
|
67
|
+
let nodeProps = Object.keys(node);
|
|
68
|
+
nodeProps.forEach(prop => {
|
|
69
|
+
if (!includes(nodesPropList, prop)) {
|
|
70
|
+
appendFailMsg(`dchain.nodes[${index}].${prop}` + shouldBeValid);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (prop === 'ext') {
|
|
74
|
+
if (!isPlainObject(node.ext)) {
|
|
75
|
+
appendFailMsg(`dchain.nodes[${index}].ext` + shouldBeAnObject);
|
|
76
|
+
}
|
|
77
|
+
} else {
|
|
78
|
+
if (!isStr(node[prop])) {
|
|
79
|
+
appendFailMsg(`dchain.nodes[${index}].${prop}` + shouldBeAString);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (failMsg.length > 0) {
|
|
88
|
+
printFailMsg();
|
|
89
|
+
if (mode === MODE.STRICT) {
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return true;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function isValidDchain(bid) {
|
|
97
|
+
let mode = MODE.STRICT;
|
|
98
|
+
const dchainConfig = config.getConfig('dchain');
|
|
99
|
+
|
|
100
|
+
if (dchainConfig && isStr(dchainConfig.validation) && MODES.indexOf(dchainConfig.validation) != -1) {
|
|
101
|
+
mode = dchainConfig.validation;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (mode === MODE.OFF) {
|
|
105
|
+
return true;
|
|
106
|
+
} else {
|
|
107
|
+
return checkDchainSyntax(bid, mode);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export function addBidResponseHook(fn, adUnitCode, bid) {
|
|
112
|
+
const basicDchain = {
|
|
113
|
+
ver: '1.0',
|
|
114
|
+
complete: 0,
|
|
115
|
+
nodes: []
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
if (deepAccess(bid, 'meta.networkId') && deepAccess(bid, 'meta.networkName')) {
|
|
119
|
+
basicDchain.nodes.push({ name: bid.meta.networkName, bsid: bid.meta.networkId.toString() });
|
|
120
|
+
}
|
|
121
|
+
basicDchain.nodes.push({ name: bid.bidderCode });
|
|
122
|
+
|
|
123
|
+
let bidDchain = deepAccess(bid, 'meta.dchain');
|
|
124
|
+
if (bidDchain && isPlainObject(bidDchain)) {
|
|
125
|
+
let result = isValidDchain(bid);
|
|
126
|
+
|
|
127
|
+
if (result) {
|
|
128
|
+
// extra check in-case mode is OFF and there is a setup issue
|
|
129
|
+
if (isArray(bidDchain.nodes)) {
|
|
130
|
+
bid.meta.dchain.nodes.push({ asi: bid.bidderCode });
|
|
131
|
+
} else {
|
|
132
|
+
logWarn('bid.meta.dchain.nodes did not exist or was not an array; did not append prebid dchain.', bid);
|
|
133
|
+
}
|
|
134
|
+
} else {
|
|
135
|
+
// remove invalid dchain
|
|
136
|
+
delete bid.meta.dchain;
|
|
137
|
+
}
|
|
138
|
+
} else {
|
|
139
|
+
bid.meta.dchain = basicDchain;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
fn(adUnitCode, bid);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export function init() {
|
|
146
|
+
getHook('addBidResponse').before(addBidResponseHook, 35);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
init();
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# dchain module
|
|
2
|
+
|
|
3
|
+
Refer:
|
|
4
|
+
- https://iabtechlab.com/buyers-json-demand-chain/
|
|
5
|
+
|
|
6
|
+
## Sample code for dchain setConfig and dchain object
|
|
7
|
+
```
|
|
8
|
+
pbjs.setConfig({
|
|
9
|
+
"dchain": {
|
|
10
|
+
"validation": "strict"
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
bid.meta.dchain: {
|
|
17
|
+
"complete": 0,
|
|
18
|
+
"ver": "1.0",
|
|
19
|
+
"ext": {...},
|
|
20
|
+
"nodes": [{
|
|
21
|
+
"asi": "abc",
|
|
22
|
+
"bsid": "123",
|
|
23
|
+
"rid": "d4e5f6",
|
|
24
|
+
"name": "xyz",
|
|
25
|
+
"domain": "mno",
|
|
26
|
+
"ext": {...}
|
|
27
|
+
}, ...]
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Workflow
|
|
32
|
+
The dchain module is not enabled by default as it may not be necessary for all publishers.
|
|
33
|
+
If required, dchain module can be included as following
|
|
34
|
+
```
|
|
35
|
+
$ gulp build --modules=dchain,pubmaticBidAdapter,openxBidAdapter,rubiconBidAdapter,sovrnBidAdapter
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
The dchain module will validate a bidder's dchain object (if it was defined). Bidders should assign their dchain object into `bid.meta` field. If the dchain object is valid, it will remain in the bid object for later use.
|
|
39
|
+
|
|
40
|
+
If it was not defined, the dchain will create a default dchain object for prebid.
|
|
41
|
+
|
|
42
|
+
## Validation modes
|
|
43
|
+
- ```strict```: It is the default validation mode. In this mode, dchain object will not be accpeted from adapters if it is invalid. Errors are thrown for invalid dchain object.
|
|
44
|
+
- ```relaxed```: In this mode, errors are thrown for an invalid dchain object but the invalid dchain object is still accepted from adapters.
|
|
45
|
+
- ```off```: In this mode, no validations are performed and dchain object is accepted as is from adapters.
|
|
@@ -257,10 +257,18 @@ export const spec = {
|
|
|
257
257
|
tagid,
|
|
258
258
|
secure
|
|
259
259
|
};
|
|
260
|
+
|
|
261
|
+
// adding gpid support
|
|
262
|
+
let gpid = deepAccess(bid, 'ortb2Imp.ext.data.adserver.adslot');
|
|
263
|
+
if (!gpid) {
|
|
264
|
+
gpid = deepAccess(bid, 'ortb2Imp.ext.data.pbadslot');
|
|
265
|
+
}
|
|
266
|
+
if (gpid) {
|
|
267
|
+
data.ext = {gpid: gpid.toString()};
|
|
268
|
+
}
|
|
260
269
|
let typeSpecifics = isVideo ? { video: emxAdapter.buildVideo(bid) } : { banner: emxAdapter.buildBanner(bid) };
|
|
261
270
|
let bidfloorObj = bidfloor > 0 ? { bidfloor, bidfloorcur: DEFAULT_CUR } : {};
|
|
262
271
|
let emxBid = Object.assign(data, typeSpecifics, bidfloorObj);
|
|
263
|
-
|
|
264
272
|
emxImps.push(emxBid);
|
|
265
273
|
});
|
|
266
274
|
|
|
@@ -312,6 +312,12 @@ export const spec = {
|
|
|
312
312
|
requestParams._fw_us_privacy = bidderRequest.uspConsent;
|
|
313
313
|
}
|
|
314
314
|
|
|
315
|
+
// Add schain object
|
|
316
|
+
var schain = currentBidRequest.schain;
|
|
317
|
+
if (schain) {
|
|
318
|
+
requestParams.schain = schain;
|
|
319
|
+
}
|
|
320
|
+
|
|
315
321
|
var vastParams = currentBidRequest.params.vastUrlParams;
|
|
316
322
|
if (typeof vastParams === 'object') {
|
|
317
323
|
for (var key in vastParams) {
|