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.
Files changed (69) hide show
  1. package/README.md +1 -1
  2. package/browsers.json +13 -29
  3. package/karma.conf.maker.js +1 -1
  4. package/modules/admixerBidAdapter.js +2 -1
  5. package/modules/adnuntiusBidAdapter.js +2 -1
  6. package/modules/adplusBidAdapter.js +203 -0
  7. package/modules/adplusBidAdapter.md +39 -0
  8. package/modules/adyoulikeBidAdapter.js +7 -2
  9. package/modules/appnexusBidAdapter.js +19 -2
  10. package/modules/beachfrontBidAdapter.js +14 -17
  11. package/modules/craftBidAdapter.js +5 -3
  12. package/modules/dchain.js +149 -0
  13. package/modules/dchain.md +45 -0
  14. package/modules/emx_digitalBidAdapter.js +9 -1
  15. package/modules/freewheel-sspBidAdapter.js +6 -0
  16. package/modules/goldbachBidAdapter.js +1176 -0
  17. package/modules/goldbachBidAdapter.md +151 -0
  18. package/modules/gumgumBidAdapter.js +5 -1
  19. package/modules/intersectionRtdProvider.js +114 -0
  20. package/modules/invibesBidAdapter.js +15 -9
  21. package/modules/ipromBidAdapter.js +79 -0
  22. package/modules/limelightDigitalBidAdapter.js +2 -1
  23. package/modules/luponmediaBidAdapter.js +570 -0
  24. package/modules/missenaBidAdapter.js +89 -0
  25. package/modules/pubmaticBidAdapter.js +3 -3
  26. package/modules/relaidoBidAdapter.js +86 -65
  27. package/modules/richaudienceBidAdapter.js +1 -1
  28. package/modules/smaatoBidAdapter.js +4 -1
  29. package/modules/smartxBidAdapter.js +17 -1
  30. package/modules/tappxBidAdapter.js +3 -1
  31. package/modules/undertoneBidAdapter.js +8 -1
  32. package/modules/userId/index.js +27 -2
  33. package/modules/ventes.md +71 -0
  34. package/modules/ventesBidAdapter.js +104 -64
  35. package/modules/ventesBidAdapter.md +0 -1
  36. package/modules/visxBidAdapter.js +19 -2
  37. package/modules/visxBidAdapter.md +4 -6
  38. package/modules/yahoosspBidAdapter.md +1 -1
  39. package/modules/yieldoneBidAdapter.js +115 -11
  40. package/package.json +1 -1
  41. package/src/auction.js +3 -2
  42. package/src/targeting.js +2 -2
  43. package/src/utils.js +7 -0
  44. package/test/spec/integration/faker/googletag.js +6 -0
  45. package/test/spec/modules/adnuntiusBidAdapter_spec.js +18 -0
  46. package/test/spec/modules/adplusBidAdapter_spec.js +213 -0
  47. package/test/spec/modules/adyoulikeBidAdapter_spec.js +26 -0
  48. package/test/spec/modules/appnexusBidAdapter_spec.js +49 -1
  49. package/test/spec/modules/beachfrontBidAdapter_spec.js +65 -1
  50. package/test/spec/modules/dchain_spec.js +329 -0
  51. package/test/spec/modules/emx_digitalBidAdapter_spec.js +10 -0
  52. package/test/spec/modules/freewheel-sspBidAdapter_spec.js +19 -0
  53. package/test/spec/modules/goldbachBidAdapter_spec.js +1359 -0
  54. package/test/spec/modules/gumgumBidAdapter_spec.js +6 -0
  55. package/test/spec/modules/intersectionRtdProvider_spec.js +141 -0
  56. package/test/spec/modules/invibesBidAdapter_spec.js +29 -4
  57. package/test/spec/modules/ipromBidAdapter_spec.js +195 -0
  58. package/test/spec/modules/limelightDigitalBidAdapter_spec.js +10 -7
  59. package/test/spec/modules/luponmediaBidAdapter_spec.js +412 -0
  60. package/test/spec/modules/missenaBidAdapter_spec.js +134 -0
  61. package/test/spec/modules/pubmaticBidAdapter_spec.js +1 -1
  62. package/test/spec/modules/relaidoBidAdapter_spec.js +71 -63
  63. package/test/spec/modules/smaatoBidAdapter_spec.js +31 -0
  64. package/test/spec/modules/smartxBidAdapter_spec.js +9 -0
  65. package/test/spec/modules/tappxBidAdapter_spec.js +4 -0
  66. package/test/spec/modules/userId_spec.js +51 -0
  67. package/test/spec/modules/visxBidAdapter_spec.js +120 -4
  68. package/test/spec/modules/yieldoneBidAdapter_spec.js +299 -53
  69. 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) {