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,213 @@
1
+ import {expect} from 'chai';
2
+ import {spec, BIDDER_CODE, ADPLUS_ENDPOINT, } from 'modules/adplusBidAdapter.js';
3
+ import {newBidder} from 'src/adapters/bidderFactory.js';
4
+
5
+ describe('AplusBidAdapter', function () {
6
+ const adapter = newBidder(spec);
7
+
8
+ describe('inherited functions', function () {
9
+ it('exists and is a function', function () {
10
+ expect(adapter.callBids).to.be.exist.and.to.be.a('function');
11
+ });
12
+ });
13
+
14
+ describe('isBidRequestValid', function () {
15
+ it('should return true when required params found', function () {
16
+ let validRequest = {
17
+ mediaTypes: {
18
+ banner: {
19
+ sizes: [[300, 250]]
20
+ }
21
+ },
22
+ params: {
23
+ inventoryId: '30',
24
+ adUnitId: '1',
25
+ }
26
+ };
27
+ expect(spec.isBidRequestValid(validRequest)).to.equal(true);
28
+ });
29
+
30
+ it('should return false when required params are not passed', function () {
31
+ let validRequest = {
32
+ mediaTypes: {
33
+ banner: {
34
+ sizes: [[300, 250]]
35
+ }
36
+ },
37
+ params: {
38
+ inventoryId: '30',
39
+ }
40
+ };
41
+ expect(spec.isBidRequestValid(validRequest)).to.equal(false);
42
+ });
43
+
44
+ it('should return false when required param types are wrong', function () {
45
+ let validRequest = {
46
+ mediaTypes: {
47
+ banner: {
48
+ sizes: [[300, 250]]
49
+ }
50
+ },
51
+ params: {
52
+ inventoryId: 30,
53
+ adUnitId: '1',
54
+ }
55
+ };
56
+ expect(spec.isBidRequestValid(validRequest)).to.equal(false);
57
+ });
58
+
59
+ it('should return false when size is not exists', function () {
60
+ let validRequest = {
61
+ params: {
62
+ inventoryId: 30,
63
+ adUnitId: '1',
64
+ }
65
+ };
66
+ expect(spec.isBidRequestValid(validRequest)).to.equal(false);
67
+ });
68
+
69
+ it('should return false when size is wrong', function () {
70
+ let validRequest = {
71
+ mediaTypes: {
72
+ banner: {
73
+ sizes: [[300]]
74
+ }
75
+ },
76
+ params: {
77
+ inventoryId: 30,
78
+ adUnitId: '1',
79
+ }
80
+ };
81
+ expect(spec.isBidRequestValid(validRequest)).to.equal(false);
82
+ });
83
+ });
84
+
85
+ describe('buildRequests', function () {
86
+ let validRequest = [
87
+ {
88
+ bidder: BIDDER_CODE,
89
+ mediaTypes: {
90
+ banner: {
91
+ sizes: [[300, 250]]
92
+ }
93
+ },
94
+ params: {
95
+ inventoryId: '-1',
96
+ adUnitId: '-3',
97
+ },
98
+ bidId: '2bdcb0b203c17d'
99
+ },
100
+ ];
101
+
102
+ let bidderRequest = {
103
+ refererInfo: {
104
+ referer: 'https://test.domain'
105
+ }
106
+ };
107
+
108
+ it('bidRequest HTTP method', function () {
109
+ const request = spec.buildRequests(validRequest, bidderRequest);
110
+ expect(request[0].method).to.equal('GET');
111
+ });
112
+
113
+ it('bidRequest url', function () {
114
+ const request = spec.buildRequests(validRequest, bidderRequest);
115
+ expect(request[0].url).to.equal(ADPLUS_ENDPOINT);
116
+ });
117
+
118
+ it('tests bidRequest data is clean and has the right values', function () {
119
+ const request = spec.buildRequests(validRequest, bidderRequest);
120
+
121
+ expect(request[0].data.bidId).to.equal('2bdcb0b203c17d');
122
+ expect(request[0].data.inventoryId).to.equal('-1');
123
+ expect(request[0].data.adUnitId).to.equal('-3');
124
+ expect(request[0].data.adUnitWidth).to.equal(300);
125
+ expect(request[0].data.adUnitHeight).to.equal(250);
126
+ expect(request[0].data.sdkVersion).to.equal('1');
127
+ expect(typeof request[0].data.session).to.equal('string');
128
+ expect(request[0].data.session).length(36);
129
+ expect(request[0].data.interstitial).to.equal(0);
130
+ expect(request[0].data).to.not.have.deep.property('extraData');
131
+ expect(request[0].data).to.not.have.deep.property('yearOfBirth');
132
+ expect(request[0].data).to.not.have.deep.property('gender');
133
+ expect(request[0].data).to.not.have.deep.property('categories');
134
+ expect(request[0].data).to.not.have.deep.property('latitude');
135
+ expect(request[0].data).to.not.have.deep.property('longitude');
136
+ });
137
+ });
138
+
139
+ describe('interpretResponse', function () {
140
+ const requestData = {
141
+ language: window.navigator.language,
142
+ screenWidth: 1440,
143
+ screenHeight: 900,
144
+ sdkVersion: '1',
145
+ inventoryId: '-1',
146
+ adUnitId: '-3',
147
+ adUnitWidth: 300,
148
+ adUnitHeight: 250,
149
+ domain: 'tassandigi.com',
150
+ pageUrl: 'https%3A%2F%2Ftassandigi.com%2Fserafettin%2Fads.html',
151
+ interstitial: 0,
152
+ session: '1c02db03-5289-932a-93af-7b4022611fec',
153
+ token: '1c02db03-5289-937a-93df-7b4022611fec',
154
+ secure: 1,
155
+ bidId: '2bdcb0b203c17d',
156
+ };
157
+ const bidRequest = {
158
+ 'method': 'GET',
159
+ 'url': ADPLUS_ENDPOINT,
160
+ 'data': requestData,
161
+ };
162
+
163
+ const bidResponse = {
164
+ body: [
165
+ {
166
+ 'ad': '<div>ad</div>',
167
+ 'advertiserDomains': [
168
+ 'advertiser.com'
169
+ ],
170
+ 'categoryIDs': [
171
+ 'IAB-111'
172
+ ],
173
+ 'cpm': 3.57,
174
+ 'creativeID': '1',
175
+ 'currency': 'TRY',
176
+ 'dealID': '1',
177
+ 'height': 300,
178
+ 'mediaType': 'banner',
179
+ 'netRevenue': true,
180
+ 'requestID': '2bdcb0b203c17d',
181
+ 'ttl': 300,
182
+ 'width': 250
183
+ }
184
+ ],
185
+ headers: {}
186
+ };
187
+
188
+ const emptyBidResponse = {
189
+ body: null,
190
+ };
191
+
192
+ it('returns an empty array when the result body is not valid', function () {
193
+ const result = spec.interpretResponse(emptyBidResponse, bidRequest);
194
+ expect(result).to.deep.equal([]);
195
+ });
196
+
197
+ it('result is correct', function () {
198
+ const result = spec.interpretResponse(bidResponse, bidRequest);
199
+ expect(result[0].requestId).to.equal('2bdcb0b203c17d');
200
+ expect(result[0].cpm).to.equal(3.57);
201
+ expect(result[0].width).to.equal(250);
202
+ expect(result[0].height).to.equal(300);
203
+ expect(result[0].creativeId).to.equal('1');
204
+ expect(result[0].currency).to.equal('TRY');
205
+ expect(result[0].dealId).to.equal('1');
206
+ expect(result[0].mediaType).to.equal('banner');
207
+ expect(result[0].netRevenue).to.equal(true);
208
+ expect(result[0].ttl).to.equal(300);
209
+ expect(result[0].meta.advertiserDomains).to.deep.equal(['advertiser.com']);
210
+ expect(result[0].meta.secondaryCatIds).to.deep.equal(['IAB-111']);
211
+ });
212
+ });
213
+ });
@@ -590,6 +590,32 @@ describe('Adyoulike Adapter', function () {
590
590
  expect(payload.gdprConsent.consentRequired).to.be.null;
591
591
  });
592
592
 
593
+ it('should add userid eids information to the request', function () {
594
+ let bidderRequest = {
595
+ 'auctionId': '1d1a030790a475',
596
+ 'bidderRequestId': '22edbae2733bf6',
597
+ 'timeout': 3000,
598
+ 'userId': {
599
+ pubcid: '01EAJWWNEPN3CYMM5N8M5VXY22',
600
+ unsuported: '666'
601
+ }
602
+ };
603
+
604
+ bidderRequest.bids = bidRequestWithSinglePlacement;
605
+
606
+ const request = spec.buildRequests(bidRequestWithSinglePlacement, bidderRequest);
607
+ const payload = JSON.parse(request.data);
608
+
609
+ expect(payload.userId).to.exist;
610
+ expect(payload.userId).to.deep.equal([{
611
+ 'source': 'pubcid.org',
612
+ 'uids': [{
613
+ 'atype': 1,
614
+ 'id': '01EAJWWNEPN3CYMM5N8M5VXY22'
615
+ }]
616
+ }]);
617
+ });
618
+
593
619
  it('sends bid request to endpoint with single placement', function () {
594
620
  const request = spec.buildRequests(bidRequestWithSinglePlacement, bidderRequest);
595
621
  const payload = JSON.parse(request.data);
@@ -1004,12 +1004,16 @@ describe('AppNexusAdapter', function () {
1004
1004
 
1005
1005
  describe('interpretResponse', function () {
1006
1006
  let bfStub;
1007
+ let bidderSettingsStorage;
1008
+
1007
1009
  before(function() {
1008
1010
  bfStub = sinon.stub(bidderFactory, 'getIabSubCategory');
1011
+ bidderSettingsStorage = $$PREBID_GLOBAL$$.bidderSettings;
1009
1012
  });
1010
1013
 
1011
1014
  after(function() {
1012
1015
  bfStub.restore();
1016
+ $$PREBID_GLOBAL$$.bidderSettings = bidderSettingsStorage;
1013
1017
  });
1014
1018
 
1015
1019
  let response = {
@@ -1077,6 +1081,15 @@ describe('AppNexusAdapter', function () {
1077
1081
  'adUnitCode': 'code',
1078
1082
  'appnexus': {
1079
1083
  'buyerMemberId': 958
1084
+ },
1085
+ 'meta': {
1086
+ 'dchain': {
1087
+ 'ver': '1.0',
1088
+ 'complete': 0,
1089
+ 'nodes': [{
1090
+ 'bsid': '958'
1091
+ }]
1092
+ }
1080
1093
  }
1081
1094
  }
1082
1095
  ];
@@ -1085,11 +1098,46 @@ describe('AppNexusAdapter', function () {
1085
1098
  bidId: '3db3773286ee59',
1086
1099
  adUnitCode: 'code'
1087
1100
  }]
1088
- }
1101
+ };
1089
1102
  let result = spec.interpretResponse({ body: response }, {bidderRequest});
1090
1103
  expect(Object.keys(result[0])).to.have.members(Object.keys(expectedResponse[0]));
1091
1104
  });
1092
1105
 
1106
+ it('should reject 0 cpm bids', function () {
1107
+ let zeroCpmResponse = deepClone(response);
1108
+ zeroCpmResponse.tags[0].ads[0].cpm = 0;
1109
+
1110
+ let bidderRequest = {
1111
+ bidderCode: 'appnexus'
1112
+ };
1113
+
1114
+ let result = spec.interpretResponse({ body: zeroCpmResponse }, { bidderRequest });
1115
+ expect(result.length).to.equal(0);
1116
+ });
1117
+
1118
+ it('should allow 0 cpm bids if allowZeroCpmBids setConfig is true', function () {
1119
+ $$PREBID_GLOBAL$$.bidderSettings = {
1120
+ appnexus: {
1121
+ allowZeroCpmBids: true
1122
+ }
1123
+ };
1124
+
1125
+ let zeroCpmResponse = deepClone(response);
1126
+ zeroCpmResponse.tags[0].ads[0].cpm = 0;
1127
+
1128
+ let bidderRequest = {
1129
+ bidderCode: 'appnexus',
1130
+ bids: [{
1131
+ bidId: '3db3773286ee59',
1132
+ adUnitCode: 'code'
1133
+ }]
1134
+ };
1135
+
1136
+ let result = spec.interpretResponse({ body: zeroCpmResponse }, { bidderRequest });
1137
+ expect(result.length).to.equal(1);
1138
+ expect(result[0].cpm).to.equal(0);
1139
+ });
1140
+
1093
1141
  it('handles nobid responses', function () {
1094
1142
  let response = {
1095
1143
  'version': '0.0.1',
@@ -1,6 +1,7 @@
1
1
  import { expect } from 'chai';
2
2
  import { spec, VIDEO_ENDPOINT, BANNER_ENDPOINT, OUTSTREAM_SRC, DEFAULT_MIMES } from 'modules/beachfrontBidAdapter.js';
3
- import { parseUrl } from 'src/utils.js';
3
+ import { config } from 'src/config.js';
4
+ import { parseUrl, deepAccess } from 'src/utils.js';
4
5
 
5
6
  describe('BeachfrontAdapter', function () {
6
7
  let bidRequests;
@@ -556,6 +557,69 @@ describe('BeachfrontAdapter', function () {
556
557
  });
557
558
  });
558
559
 
560
+ describe('with first-party data', function () {
561
+ let sandbox
562
+
563
+ beforeEach(function () {
564
+ sandbox = sinon.sandbox.create();
565
+ });
566
+
567
+ afterEach(function () {
568
+ sandbox.restore();
569
+ });
570
+
571
+ it('must add first-party data to the video bid request', function () {
572
+ sandbox.stub(config, 'getConfig').callsFake(key => {
573
+ const cfg = {
574
+ ortb2: {
575
+ site: {
576
+ keywords: 'test keyword'
577
+ },
578
+ user: {
579
+ data: 'some user data'
580
+ }
581
+ }
582
+ };
583
+ return deepAccess(cfg, key);
584
+ });
585
+ const bidRequest = bidRequests[0];
586
+ bidRequest.mediaTypes = { video: {} };
587
+ const bidderRequest = {
588
+ refererInfo: {
589
+ referer: 'http://example.com/page.html'
590
+ }
591
+ };
592
+ const requests = spec.buildRequests([ bidRequest ], bidderRequest);
593
+ const data = requests[0].data;
594
+ expect(data.user.data).to.equal('some user data');
595
+ expect(data.site.keywords).to.equal('test keyword');
596
+ expect(data.site.page).to.equal('http://example.com/page.html');
597
+ expect(data.site.domain).to.equal('example.com');
598
+ });
599
+
600
+ it('must add first-party data to the banner bid request', function () {
601
+ sandbox.stub(config, 'getConfig').callsFake(key => {
602
+ const cfg = {
603
+ ortb2: {
604
+ site: {
605
+ keywords: 'test keyword'
606
+ },
607
+ user: {
608
+ data: 'some user data'
609
+ }
610
+ }
611
+ };
612
+ return deepAccess(cfg, key);
613
+ });
614
+ const bidRequest = bidRequests[0];
615
+ bidRequest.mediaTypes = { banner: {} };
616
+ const requests = spec.buildRequests([ bidRequest ]);
617
+ const data = requests[0].data;
618
+ expect(data.ortb2.user.data).to.equal('some user data');
619
+ expect(data.ortb2.site.keywords).to.equal('test keyword');
620
+ });
621
+ });
622
+
559
623
  describe('for multi-format bids', function () {
560
624
  it('should create a POST request for each bid format', function () {
561
625
  const width = 300;