prebid.js 7.2.0 → 7.5.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 (251) hide show
  1. package/.circleci/config.yml +11 -6
  2. package/.github/dependabot.yml +6 -0
  3. package/.github/workflows/issue_tracker.yml +5 -0
  4. package/.github/workflows/release-drafter.yml +6 -0
  5. package/README.md +35 -0
  6. package/dist/33acrossBidAdapter.js +1 -1
  7. package/dist/adagioBidAdapter.js +1 -1
  8. package/dist/adbookpspBidAdapter.js +1 -1
  9. package/dist/adgenerationBidAdapter.js +1 -1
  10. package/dist/adkernelBidAdapter.js +1 -1
  11. package/dist/adotBidAdapter.js +1 -1
  12. package/dist/adpod.js +1 -1
  13. package/dist/adqueryBidAdapter.js +1 -1
  14. package/dist/adrelevantisBidAdapter.js +1 -1
  15. package/dist/adxcgBidAdapter.js +1 -1
  16. package/dist/adyoulikeBidAdapter.js +1 -1
  17. package/dist/ajaBidAdapter.js +1 -1
  18. package/dist/amxBidAdapter.js +1 -1
  19. package/dist/amxIdSystem.js +1 -1
  20. package/dist/appierAnalyticsAdapter.js +1 -1
  21. package/dist/appnexusBidAdapter.js +1 -1
  22. package/dist/asoBidAdapter.js +1 -1
  23. package/dist/audiencerunBidAdapter.js +1 -1
  24. package/dist/axonixBidAdapter.js +1 -1
  25. package/dist/bidglassBidAdapter.js +1 -1
  26. package/dist/big-richmediaBidAdapter.js +1 -1
  27. package/dist/bluebillywigBidAdapter.js +1 -1
  28. package/dist/bridgewellBidAdapter.js +1 -1
  29. package/dist/brightMountainMediaBidAdapter.js +1 -1
  30. package/dist/concertBidAdapter.js +1 -1
  31. package/dist/connectadBidAdapter.js +1 -1
  32. package/dist/consumableBidAdapter.js +1 -1
  33. package/dist/conversantBidAdapter.js +1 -1
  34. package/dist/cpexIdSystem.js +1 -1
  35. package/dist/craftBidAdapter.js +1 -1
  36. package/dist/criteoBidAdapter.js +1 -1
  37. package/dist/debugging-standalone.js +1 -1
  38. package/dist/debugging.js +1 -1
  39. package/dist/dianomiBidAdapter.js +1 -0
  40. package/dist/dspxBidAdapter.js +1 -1
  41. package/dist/eplanningBidAdapter.js +1 -1
  42. package/dist/finativeBidAdapter.js +1 -0
  43. package/dist/fpdModule.js +1 -1
  44. package/dist/gdprEnforcement.js +1 -1
  45. package/dist/glimpseBidAdapter.js +1 -1
  46. package/dist/gmosspBidAdapter.js +1 -1
  47. package/dist/goldbachBidAdapter.js +1 -1
  48. package/dist/gridBidAdapter.js +1 -1
  49. package/dist/gridNMBidAdapter.js +1 -1
  50. package/dist/gumgumBidAdapter.js +1 -1
  51. package/dist/h12mediaBidAdapter.js +1 -1
  52. package/dist/hadronIdSystem.js +1 -1
  53. package/dist/hadronRtdProvider.js +1 -1
  54. package/dist/id5IdSystem.js +1 -1
  55. package/dist/impactifyBidAdapter.js +1 -1
  56. package/dist/improvedigitalBidAdapter.js +1 -1
  57. package/dist/inmarBidAdapter.js +1 -1
  58. package/dist/insticatorBidAdapter.js +1 -1
  59. package/dist/ixBidAdapter.js +1 -1
  60. package/dist/jixieBidAdapter.js +1 -1
  61. package/dist/justpremiumBidAdapter.js +1 -1
  62. package/dist/kargoAnalyticsAdapter.js +1 -1
  63. package/dist/kargoBidAdapter.js +1 -1
  64. package/dist/konduitAnalyticsAdapter.js +1 -1
  65. package/dist/kueezBidAdapter.js +1 -1
  66. package/dist/lassoBidAdapter.js +1 -0
  67. package/dist/liveyieldAnalyticsAdapter.js +1 -1
  68. package/dist/logicadBidAdapter.js +1 -1
  69. package/dist/loglyliftBidAdapter.js +1 -1
  70. package/dist/malltvAnalyticsAdapter.js +1 -1
  71. package/dist/marsmediaBidAdapter.js +1 -1
  72. package/dist/mediafuseBidAdapter.js +1 -1
  73. package/dist/mediakeysBidAdapter.js +1 -1
  74. package/dist/medianetBidAdapter.js +1 -1
  75. package/dist/mediasquareBidAdapter.js +1 -1
  76. package/dist/mgidBidAdapter.js +1 -1
  77. package/dist/minutemediaBidAdapter.js +1 -1
  78. package/dist/missenaBidAdapter.js +1 -1
  79. package/dist/nativoBidAdapter.js +1 -1
  80. package/dist/not-for-prod/prebid.js +137 -131
  81. package/dist/oguryBidAdapter.js +1 -1
  82. package/dist/onetagBidAdapter.js +1 -1
  83. package/dist/ooloAnalyticsAdapter.js +1 -1
  84. package/dist/openxOrtbBidAdapter.js +1 -0
  85. package/dist/outbrainBidAdapter.js +1 -1
  86. package/dist/parrableIdSystem.js +1 -1
  87. package/dist/pixfutureBidAdapter.js +1 -1
  88. package/dist/prebid-core.js +2 -2
  89. package/dist/pubCommonId.js +1 -1
  90. package/dist/publinkIdSystem.js +1 -1
  91. package/dist/pubmaticBidAdapter.js +1 -1
  92. package/dist/pubwiseAnalyticsAdapter.js +1 -1
  93. package/dist/pxyzBidAdapter.js +1 -1
  94. package/dist/quantcastBidAdapter.js +1 -1
  95. package/dist/readpeakBidAdapter.js +1 -1
  96. package/dist/relaidoBidAdapter.js +1 -1
  97. package/dist/rhythmoneBidAdapter.js +1 -1
  98. package/dist/riseBidAdapter.js +1 -1
  99. package/dist/rubiconAnalyticsAdapter.js +1 -1
  100. package/dist/rubiconBidAdapter.js +1 -1
  101. package/dist/seedingAllianceBidAdapter.js +1 -1
  102. package/dist/seedtagBidAdapter.js +1 -1
  103. package/dist/sharedIdSystem.js +1 -1
  104. package/dist/sharethroughAnalyticsAdapter.js +1 -1
  105. package/dist/sharethroughBidAdapter.js +1 -1
  106. package/dist/shinezBidAdapter.js +1 -0
  107. package/dist/sizeMappingV2.js +1 -1
  108. package/dist/smaatoBidAdapter.js +1 -1
  109. package/dist/smartadserverBidAdapter.js +1 -1
  110. package/dist/smartxBidAdapter.js +1 -1
  111. package/dist/smilewantedBidAdapter.js +1 -1
  112. package/dist/sonobiBidAdapter.js +1 -1
  113. package/dist/sovrnAnalyticsAdapter.js +1 -1
  114. package/dist/sovrnBidAdapter.js +1 -1
  115. package/dist/sspBCBidAdapter.js +1 -1
  116. package/dist/sublimeBidAdapter.js +1 -1
  117. package/dist/synacormediaBidAdapter.js +1 -1
  118. package/dist/taboolaBidAdapter.js +1 -1
  119. package/dist/targetVideoBidAdapter.js +1 -1
  120. package/dist/teadsBidAdapter.js +1 -1
  121. package/dist/tncIdSystem.js +1 -0
  122. package/dist/trionBidAdapter.js +1 -1
  123. package/dist/tripleliftBidAdapter.js +1 -1
  124. package/dist/ttdBidAdapter.js +1 -1
  125. package/dist/ucfunnelAnalyticsAdapter.js +1 -1
  126. package/dist/underdogmediaBidAdapter.js +1 -1
  127. package/dist/undertoneBidAdapter.js +1 -1
  128. package/dist/userId.js +1 -1
  129. package/dist/ventesBidAdapter.js +1 -1
  130. package/dist/vidazooBidAdapter.js +1 -1
  131. package/dist/videobyteBidAdapter.js +1 -1
  132. package/dist/visxBidAdapter.js +1 -1
  133. package/dist/vrtcalBidAdapter.js +1 -1
  134. package/dist/vuukleBidAdapter.js +1 -1
  135. package/dist/widespaceBidAdapter.js +1 -1
  136. package/dist/winrBidAdapter.js +1 -1
  137. package/dist/yahoosspBidAdapter.js +1 -1
  138. package/dist/yieldlabBidAdapter.js +1 -1
  139. package/dist/yieldmoBidAdapter.js +1 -1
  140. package/dist/yieldoneAnalyticsAdapter.js +1 -1
  141. package/dist/yieldoneBidAdapter.js +1 -1
  142. package/governance.md +5 -11
  143. package/gulpHelpers.js +1 -1
  144. package/gulpfile.js +1 -1
  145. package/karma.conf.maker.js +3 -1
  146. package/modules/.submodules.json +1 -0
  147. package/modules/33acrossBidAdapter.js +5 -1
  148. package/modules/adkernelBidAdapter.js +2 -1
  149. package/modules/adotBidAdapter.js +3 -3
  150. package/modules/adqueryBidAdapter.js +5 -1
  151. package/modules/appnexusBidAdapter.js +3 -3
  152. package/modules/cpexIdSystem.js +7 -8
  153. package/modules/criteoBidAdapter.js +7 -1
  154. package/modules/cwireBidAdapter.md +1 -1
  155. package/modules/debugging/bidInterceptor.js +1 -1
  156. package/modules/debugging/index.js +2 -1
  157. package/modules/dianomiBidAdapter.js +369 -0
  158. package/modules/dianomiBidAdapter.md +73 -0
  159. package/modules/finativeBidAdapter.js +235 -0
  160. package/modules/finativeBidAdapter.md +45 -0
  161. package/modules/fpdModule/index.js +6 -5
  162. package/modules/gdprEnforcement.js +8 -14
  163. package/modules/gumgumBidAdapter.js +2 -0
  164. package/modules/gumgumBidAdapter.md +19 -1
  165. package/modules/hadronAnalyticsAdapter.md +5 -5
  166. package/modules/hadronIdSystem.js +18 -5
  167. package/modules/hadronIdSystem.md +15 -11
  168. package/modules/hadronRtdProvider.js +14 -1
  169. package/modules/hadronRtdProvider.md +17 -13
  170. package/modules/insticatorBidAdapter.js +9 -0
  171. package/modules/ixBidAdapter.js +457 -57
  172. package/modules/ixBidAdapter.md +95 -5
  173. package/modules/kargoAnalyticsAdapter.js +88 -6
  174. package/modules/kargoAnalyticsAdapter.md +33 -0
  175. package/modules/kargoBidAdapter.js +1 -2
  176. package/modules/lassoBidAdapter.js +133 -0
  177. package/modules/lassoBidAdapter.md +29 -0
  178. package/modules/medianetBidAdapter.js +9 -5
  179. package/modules/missenaBidAdapter.js +20 -2
  180. package/modules/nativoBidAdapter.js +19 -7
  181. package/modules/openxBidAdapter.md +3 -1
  182. package/modules/openxOrtbBidAdapter.js +349 -0
  183. package/modules/openxOrtbBidAdapter.md +105 -0
  184. package/modules/pubCommonId.js +1 -2
  185. package/modules/readpeakBidAdapter.js +15 -6
  186. package/modules/relaidoBidAdapter.js +19 -4
  187. package/modules/riseBidAdapter.js +1 -0
  188. package/modules/seedtagBidAdapter.js +33 -1
  189. package/modules/sharedIdSystem.js +11 -5
  190. package/modules/sharethroughBidAdapter.js +9 -24
  191. package/modules/shinezBidAdapter.js +435 -0
  192. package/modules/shinezBidAdapter.md +76 -0
  193. package/modules/sonobiBidAdapter.js +28 -9
  194. package/modules/sovrnBidAdapter.js +16 -10
  195. package/modules/taboolaBidAdapter.js +1 -1
  196. package/modules/taboolaBidAdapter.md +3 -3
  197. package/modules/tncIdSystem.js +63 -0
  198. package/modules/tncIdSystem.md +33 -0
  199. package/modules/userId/eids.js +12 -0
  200. package/modules/userId/eids.md +7 -0
  201. package/modules/userId/userId.md +17 -0
  202. package/modules/ventesBidAdapter.js +1 -1
  203. package/modules/ventesBidAdapter.md +1 -1
  204. package/modules/vrtcalBidAdapter.js +35 -0
  205. package/modules/yieldlabBidAdapter.js +4 -0
  206. package/modules/yieldmoBidAdapter.js +20 -2
  207. package/modules/yieldoneBidAdapter.js +12 -1
  208. package/package.json +1 -1
  209. package/plugins/pbjsGlobals.js +2 -1
  210. package/src/adloader.js +1 -0
  211. package/src/prebid.js +4 -1
  212. package/src/storageManager.js +4 -5
  213. package/test/spec/modules/33acrossBidAdapter_spec.js +39 -0
  214. package/test/spec/modules/appnexusBidAdapter_spec.js +165 -156
  215. package/test/spec/modules/cpexIdSystem_spec.js +5 -5
  216. package/test/spec/modules/criteoBidAdapter_spec.js +15 -5
  217. package/test/spec/modules/debugging_mod_spec.js +7 -0
  218. package/test/spec/modules/dianomiBidAdapter_spec.js +1223 -0
  219. package/test/spec/modules/eids_spec.js +26 -1
  220. package/test/spec/modules/finativeBidAdapter_spec.js +186 -0
  221. package/test/spec/modules/fpdModule_spec.js +28 -1
  222. package/test/spec/modules/gdprEnforcement_spec.js +53 -100
  223. package/test/spec/modules/gumgumBidAdapter_spec.js +5 -0
  224. package/test/spec/modules/hadronIdSystem_spec.js +2 -2
  225. package/test/spec/modules/insticatorBidAdapter_spec.js +22 -1
  226. package/test/spec/modules/ixBidAdapter_spec.js +429 -10
  227. package/test/spec/modules/kargoAnalyticsAdapter_spec.js +42 -0
  228. package/test/spec/modules/kargoBidAdapter_spec.js +1 -0
  229. package/test/spec/modules/lassoBidAdapter_spec.js +177 -0
  230. package/test/spec/modules/medianetBidAdapter_spec.js +24 -1
  231. package/test/spec/modules/missenaBidAdapter_spec.js +36 -14
  232. package/test/spec/modules/nativoBidAdapter_spec.js +67 -17
  233. package/test/spec/modules/openxOrtbBidAdapter_spec.js +1303 -0
  234. package/test/spec/modules/readpeakBidAdapter_spec.js +1 -0
  235. package/test/spec/modules/relaidoBidAdapter_spec.js +29 -2
  236. package/test/spec/modules/riseBidAdapter_spec.js +3 -0
  237. package/test/spec/modules/seedtagBidAdapter_spec.js +4 -0
  238. package/test/spec/modules/sharethroughBidAdapter_spec.js +4 -4
  239. package/test/spec/modules/shinezBidAdapter_spec.js +479 -0
  240. package/test/spec/modules/sonobiBidAdapter_spec.js +38 -23
  241. package/test/spec/modules/sovrnBidAdapter_spec.js +39 -5
  242. package/test/spec/modules/taboolaBidAdapter_spec.js +1 -1
  243. package/test/spec/modules/tncIdSystem_spec.js +109 -0
  244. package/test/spec/modules/userId_spec.js +6 -3
  245. package/test/spec/modules/ventesBidAdapter_spec.js +2 -2
  246. package/test/spec/modules/vrtcalBidAdapter_spec.js +17 -0
  247. package/test/spec/modules/yieldlabBidAdapter_spec.js +4 -0
  248. package/test/spec/modules/yieldmoBidAdapter_spec.js +15 -2
  249. package/test/spec/modules/yieldoneBidAdapter_spec.js +43 -2
  250. package/test/spec/unit/pbjs_api_spec.js +23 -0
  251. package/webpack.conf.js +1 -1
@@ -528,6 +528,7 @@ describe('ReadPeakAdapter', function() {
528
528
  ad: bannerServerResponse.seatbid[0].bid[0].adm,
529
529
  width: bannerServerResponse.seatbid[0].bid[0].w,
530
530
  height: bannerServerResponse.seatbid[0].bid[0].h,
531
+ burl: bannerServerResponse.seatbid[0].bid[0].burl,
531
532
  });
532
533
  expect(bidResponse.meta).to.deep.equal({
533
534
  advertiserDomains: ['readpeak.com'],
@@ -81,8 +81,8 @@ describe('RelaidoAdapter', function () {
81
81
  data: {
82
82
  bids: [{
83
83
  bidId: bidRequest.bidId,
84
- width: bidRequest.mediaTypes.video.playerSize[0][0],
85
- height: bidRequest.mediaTypes.video.playerSize[0][1],
84
+ width: bidRequest.mediaTypes.video.playerSize[0][0] || bidRequest.mediaTypes.video.playerSize[0],
85
+ height: bidRequest.mediaTypes.video.playerSize[0][1] || bidRequest.mediaTypes.video.playerSize[1],
86
86
  mediaType: 'video'}]
87
87
  }
88
88
  };
@@ -98,6 +98,33 @@ describe('RelaidoAdapter', function () {
98
98
  expect(spec.isBidRequestValid(bidRequest)).to.equal(true);
99
99
  });
100
100
 
101
+ it('should return true when not existed mediaTypes.video.playerSize and existed valid params.video.playerSize by video', function () {
102
+ bidRequest.mediaTypes = {
103
+ video: {
104
+ context: 'outstream'
105
+ }
106
+ };
107
+ bidRequest.params = {
108
+ placementId: '100000',
109
+ video: {
110
+ playerSize: [
111
+ [640, 360]
112
+ ]
113
+ }
114
+ };
115
+ expect(spec.isBidRequestValid(bidRequest)).to.equal(true);
116
+ });
117
+
118
+ it('should return even true when the playerSize is Array[Number, Number] by video', function () {
119
+ bidRequest.mediaTypes = {
120
+ video: {
121
+ context: 'outstream',
122
+ playerSize: [640, 360]
123
+ }
124
+ };
125
+ expect(spec.isBidRequestValid(bidRequest)).to.equal(true);
126
+ });
127
+
101
128
  it('should return true when the required params are passed by banner', function () {
102
129
  setUAMobile();
103
130
  bidRequest.mediaTypes = {
@@ -53,6 +53,7 @@ describe('riseAdapter', function () {
53
53
  'org': 'jdye8weeyirk00000001'
54
54
  },
55
55
  'bidId': '299ffc8cca0b87',
56
+ 'loop': 1,
56
57
  'bidderRequestId': '1144f487e563f9',
57
58
  'auctionId': 'bfc420c3-8577-4568-9766-a8a935fb620d',
58
59
  'mediaTypes': {
@@ -71,6 +72,7 @@ describe('riseAdapter', function () {
71
72
  'org': 'jdye8weeyirk00000001'
72
73
  },
73
74
  'bidId': '299ffc8cca0b87',
75
+ 'loop': 1,
74
76
  'bidderRequestId': '1144f487e563f9',
75
77
  'auctionId': 'bfc420c3-8577-4568-9766-a8a935fb620d',
76
78
  'mediaTypes': {
@@ -91,6 +93,7 @@ describe('riseAdapter', function () {
91
93
  'testMode': true
92
94
  },
93
95
  'bidId': '299ffc8cca0b87',
96
+ 'loop': 2,
94
97
  'bidderRequestId': '1144f487e563f9',
95
98
  'auctionId': 'bfc420c3-8577-4568-9766-a8a935fb620d',
96
99
  }
@@ -223,6 +223,7 @@ describe('Seedtag Adapter', function () {
223
223
  });
224
224
 
225
225
  it('Common data request should be correct', function () {
226
+ const now = Date.now();
226
227
  const request = spec.buildRequests(validBidRequests, bidderRequest);
227
228
  const data = JSON.parse(request.data);
228
229
  expect(data.url).to.equal('referer');
@@ -231,6 +232,9 @@ describe('Seedtag Adapter', function () {
231
232
  expect(
232
233
  ['fixed', 'mobile', 'unknown'].indexOf(data.connectionType)
233
234
  ).to.be.above(-1);
235
+ expect(data.auctionStart).to.be.greaterThanOrEqual(now);
236
+ expect(data.ttfb).to.be.greaterThanOrEqual(0);
237
+
234
238
  expect(data.bidRequests[0].adUnitCode).to.equal('adunit-code');
235
239
  });
236
240
 
@@ -601,11 +601,11 @@ describe('sharethrough adapter spec', function () {
601
601
  const serverResponses = [{ body: { cookieSyncUrls: cookieSyncs } }];
602
602
 
603
603
  it('returns an array of correctly formatted user syncs', function () {
604
- const syncArray = spec.getUserSyncs({ pixelEnabled: true }, serverResponses, null, 'fake-privacy-signal');
604
+ const syncArray = spec.getUserSyncs({ pixelEnabled: true }, serverResponses);
605
605
  expect(syncArray).to.deep.equal([
606
- { type: 'image', url: 'cookieUrl1&us_privacy=fake-privacy-signal' },
607
- { type: 'image', url: 'cookieUrl2&us_privacy=fake-privacy-signal' },
608
- { type: 'image', url: 'cookieUrl3&us_privacy=fake-privacy-signal' }],
606
+ { type: 'image', url: 'cookieUrl1' },
607
+ { type: 'image', url: 'cookieUrl2' },
608
+ { type: 'image', url: 'cookieUrl3' }],
609
609
  );
610
610
  });
611
611
 
@@ -0,0 +1,479 @@
1
+ import { expect } from 'chai';
2
+ import { spec } from 'modules/shinezBidAdapter.js';
3
+ import { newBidder } from 'src/adapters/bidderFactory.js';
4
+ import { config } from 'src/config.js';
5
+ import { BANNER, VIDEO } from '../../../src/mediaTypes.js';
6
+ import * as utils from 'src/utils.js';
7
+
8
+ const ENDPOINT = 'https://hb.sweetgum.io/hb-sz-multi';
9
+ const TEST_ENDPOINT = 'https://hb.sweetgum.io/hb-multi-sz-test';
10
+ const TTL = 360;
11
+ /* eslint no-console: ["error", { allow: ["log", "warn", "error"] }] */
12
+
13
+ describe('shinezAdapter', function () {
14
+ const adapter = newBidder(spec);
15
+
16
+ describe('inherited functions', function () {
17
+ it('exists and is a function', function () {
18
+ expect(adapter.callBids).to.exist.and.to.be.a('function');
19
+ });
20
+ });
21
+
22
+ describe('isBidRequestValid', function () {
23
+ const bid = {
24
+ 'bidder': spec.code,
25
+ 'adUnitCode': 'adunit-code',
26
+ 'sizes': [['640', '480']],
27
+ 'params': {
28
+ 'org': 'jdye8weeyirk00000001'
29
+ }
30
+ };
31
+
32
+ it('should return true when required params are passed', function () {
33
+ expect(spec.isBidRequestValid(bid)).to.equal(true);
34
+ });
35
+
36
+ it('should return false when required params are not found', function () {
37
+ const newBid = Object.assign({}, bid);
38
+ delete newBid.params;
39
+ newBid.params = {
40
+ 'org': null
41
+ };
42
+ expect(spec.isBidRequestValid(newBid)).to.equal(false);
43
+ });
44
+ });
45
+
46
+ describe('buildRequests', function () {
47
+ const bidRequests = [
48
+ {
49
+ 'bidder': spec.code,
50
+ 'adUnitCode': 'adunit-code',
51
+ 'sizes': [[640, 480]],
52
+ 'params': {
53
+ 'org': 'jdye8weeyirk00000001'
54
+ },
55
+ 'bidId': '299ffc8cca0b87',
56
+ 'bidderRequestId': '1144f487e563f9',
57
+ 'auctionId': 'bfc420c3-8577-4568-9766-a8a935fb620d',
58
+ 'mediaTypes': {
59
+ 'video': {
60
+ 'playerSize': [[640, 480]],
61
+ 'context': 'instream'
62
+ }
63
+ },
64
+ 'vastXml': '"<VAST version=\\\"2.0\\\">...</VAST>"'
65
+ },
66
+ {
67
+ 'bidder': spec.code,
68
+ 'adUnitCode': 'adunit-code',
69
+ 'sizes': [[300, 250]],
70
+ 'params': {
71
+ 'org': 'jdye8weeyirk00000001'
72
+ },
73
+ 'bidId': '299ffc8cca0b87',
74
+ 'bidderRequestId': '1144f487e563f9',
75
+ 'auctionId': 'bfc420c3-8577-4568-9766-a8a935fb620d',
76
+ 'mediaTypes': {
77
+ 'banner': {
78
+ }
79
+ },
80
+ 'ad': '"<img src=\"https://...\"/>"'
81
+ }
82
+ ];
83
+
84
+ const testModeBidRequests = [
85
+ {
86
+ 'bidder': spec.code,
87
+ 'adUnitCode': 'adunit-code',
88
+ 'sizes': [[640, 480]],
89
+ 'params': {
90
+ 'org': 'jdye8weeyirk00000001',
91
+ 'testMode': true
92
+ },
93
+ 'bidId': '299ffc8cca0b87',
94
+ 'bidderRequestId': '1144f487e563f9',
95
+ 'auctionId': 'bfc420c3-8577-4568-9766-a8a935fb620d',
96
+ }
97
+ ];
98
+
99
+ const bidderRequest = {
100
+ bidderCode: 'shinez',
101
+ }
102
+ const placementId = '12345678';
103
+
104
+ it('sends the placementId to ENDPOINT via POST', function () {
105
+ bidRequests[0].params.placementId = placementId;
106
+ const request = spec.buildRequests(bidRequests, bidderRequest);
107
+ expect(request.data.bids[0].placementId).to.equal(placementId);
108
+ });
109
+
110
+ it('sends bid request to ENDPOINT via POST', function () {
111
+ const request = spec.buildRequests(bidRequests, bidderRequest);
112
+ expect(request.url).to.equal(ENDPOINT);
113
+ expect(request.method).to.equal('POST');
114
+ });
115
+
116
+ it('sends bid request to TEST ENDPOINT via POST', function () {
117
+ const request = spec.buildRequests(testModeBidRequests, bidderRequest);
118
+ expect(request.url).to.equal(TEST_ENDPOINT);
119
+ expect(request.method).to.equal('POST');
120
+ });
121
+
122
+ it('should send the correct bid Id', function () {
123
+ const request = spec.buildRequests(bidRequests, bidderRequest);
124
+ expect(request.data.bids[0].bidId).to.equal('299ffc8cca0b87');
125
+ });
126
+
127
+ it('should send the correct sizes array', function () {
128
+ const request = spec.buildRequests(bidRequests, bidderRequest);
129
+ expect(request.data.bids[0].sizes).to.be.an('array');
130
+ expect(request.data.bids[0].sizes).to.equal(bidRequests[0].sizes)
131
+ expect(request.data.bids[1].sizes).to.be.an('array');
132
+ expect(request.data.bids[1].sizes).to.equal(bidRequests[1].sizes)
133
+ });
134
+
135
+ it('should send the correct media type', function () {
136
+ const request = spec.buildRequests(bidRequests, bidderRequest);
137
+ expect(request.data.bids[0].mediaType).to.equal(VIDEO)
138
+ expect(request.data.bids[1].mediaType).to.equal(BANNER)
139
+ });
140
+
141
+ it('should respect syncEnabled option', function() {
142
+ config.setConfig({
143
+ userSync: {
144
+ syncEnabled: false,
145
+ filterSettings: {
146
+ all: {
147
+ bidders: '*',
148
+ filter: 'include'
149
+ }
150
+ }
151
+ }
152
+ });
153
+ const request = spec.buildRequests(bidRequests, bidderRequest);
154
+ expect(request.data.params).to.be.an('object');
155
+ expect(request.data.params).to.not.have.property('cs_method');
156
+ });
157
+
158
+ it('should respect "iframe" filter settings', function () {
159
+ config.setConfig({
160
+ userSync: {
161
+ syncEnabled: true,
162
+ filterSettings: {
163
+ iframe: {
164
+ bidders: [spec.code],
165
+ filter: 'include'
166
+ }
167
+ }
168
+ }
169
+ });
170
+ const request = spec.buildRequests(bidRequests, bidderRequest);
171
+ expect(request.data.params).to.be.an('object');
172
+ expect(request.data.params).to.have.property('cs_method', 'iframe');
173
+ });
174
+
175
+ it('should respect "all" filter settings', function () {
176
+ config.setConfig({
177
+ userSync: {
178
+ syncEnabled: true,
179
+ filterSettings: {
180
+ all: {
181
+ bidders: [spec.code],
182
+ filter: 'include'
183
+ }
184
+ }
185
+ }
186
+ });
187
+ const request = spec.buildRequests(bidRequests, bidderRequest);
188
+ expect(request.data.params).to.be.an('object');
189
+ expect(request.data.params).to.have.property('cs_method', 'iframe');
190
+ });
191
+
192
+ it('should send the pixel user sync param if userSync is enabled and no "iframe" or "all" configs are present', function () {
193
+ config.resetConfig();
194
+ config.setConfig({
195
+ userSync: {
196
+ syncEnabled: true,
197
+ }
198
+ });
199
+ const request = spec.buildRequests(bidRequests, bidderRequest);
200
+ expect(request.data.params).to.be.an('object');
201
+ expect(request.data.params).to.have.property('cs_method', 'pixel');
202
+ });
203
+
204
+ it('should respect total exclusion', function() {
205
+ config.setConfig({
206
+ userSync: {
207
+ syncEnabled: true,
208
+ filterSettings: {
209
+ image: {
210
+ bidders: [spec.code],
211
+ filter: 'exclude'
212
+ },
213
+ iframe: {
214
+ bidders: [spec.code],
215
+ filter: 'exclude'
216
+ }
217
+ }
218
+ }
219
+ });
220
+ const request = spec.buildRequests(bidRequests, bidderRequest);
221
+ expect(request.data.params).to.be.an('object');
222
+ expect(request.data.params).to.not.have.property('cs_method');
223
+ });
224
+
225
+ it('should have us_privacy param if usPrivacy is available in the bidRequest', function () {
226
+ const bidderRequestWithUSP = Object.assign({uspConsent: '1YNN'}, bidderRequest);
227
+ const request = spec.buildRequests(bidRequests, bidderRequestWithUSP);
228
+ expect(request.data.params).to.be.an('object');
229
+ expect(request.data.params).to.have.property('us_privacy', '1YNN');
230
+ });
231
+
232
+ it('should have an empty us_privacy param if usPrivacy is missing in the bidRequest', function () {
233
+ const request = spec.buildRequests(bidRequests, bidderRequest);
234
+ expect(request.data.params).to.be.an('object');
235
+ expect(request.data.params).to.not.have.property('us_privacy');
236
+ });
237
+
238
+ it('should not send the gdpr param if gdprApplies is false in the bidRequest', function () {
239
+ const bidderRequestWithGDPR = Object.assign({gdprConsent: {gdprApplies: false}}, bidderRequest);
240
+ const request = spec.buildRequests(bidRequests, bidderRequestWithGDPR);
241
+ expect(request.data.params).to.be.an('object');
242
+ expect(request.data.params).to.not.have.property('gdpr');
243
+ expect(request.data.params).to.not.have.property('gdpr_consent');
244
+ });
245
+
246
+ it('should send the gdpr param if gdprApplies is true in the bidRequest', function () {
247
+ const bidderRequestWithGDPR = Object.assign({gdprConsent: {gdprApplies: true, consentString: 'test-consent-string'}}, bidderRequest);
248
+ const request = spec.buildRequests(bidRequests, bidderRequestWithGDPR);
249
+ expect(request.data.params).to.be.an('object');
250
+ expect(request.data.params).to.have.property('gdpr', true);
251
+ expect(request.data.params).to.have.property('gdpr_consent', 'test-consent-string');
252
+ });
253
+
254
+ it('should have schain param if it is available in the bidRequest', () => {
255
+ const schain = {
256
+ ver: '1.0',
257
+ complete: 1,
258
+ nodes: [{ asi: 'indirectseller.com', sid: '00001', hp: 1 }],
259
+ };
260
+ bidRequests[0].schain = schain;
261
+ const request = spec.buildRequests(bidRequests, bidderRequest);
262
+ expect(request.data.params).to.be.an('object');
263
+ expect(request.data.params).to.have.property('schain', '1.0,1!indirectseller.com,00001,1,,,');
264
+ });
265
+
266
+ it('should set flooPrice to getFloor.floor value if it is greater than params.floorPrice', function() {
267
+ const bid = utils.deepClone(bidRequests[0]);
268
+ bid.getFloor = () => {
269
+ return {
270
+ currency: 'USD',
271
+ floor: 3.32
272
+ }
273
+ }
274
+ bid.params.floorPrice = 0.64;
275
+ const request = spec.buildRequests([bid], bidderRequest);
276
+ expect(request.data.bids[0]).to.be.an('object');
277
+ expect(request.data.bids[0]).to.have.property('floorPrice', 3.32);
278
+ });
279
+
280
+ it('should set floorPrice to params.floorPrice value if it is greater than getFloor.floor', function() {
281
+ const bid = utils.deepClone(bidRequests[0]);
282
+ bid.getFloor = () => {
283
+ return {
284
+ currency: 'USD',
285
+ floor: 0.8
286
+ }
287
+ }
288
+ bid.params.floorPrice = 1.5;
289
+ const request = spec.buildRequests([bid], bidderRequest);
290
+ expect(request.data.bids[0]).to.be.an('object');
291
+ expect(request.data.bids[0]).to.have.property('floorPrice', 1.5);
292
+ });
293
+ });
294
+
295
+ describe('interpretResponse', function () {
296
+ const response = {
297
+ params: {
298
+ currency: 'USD',
299
+ netRevenue: true,
300
+ },
301
+ bids: [{
302
+ cpm: 12.5,
303
+ vastXml: '<VAST version="3.0"></VAST>',
304
+ width: 640,
305
+ height: 480,
306
+ requestId: '21e12606d47ba7',
307
+ adomain: ['abc.com'],
308
+ mediaType: VIDEO
309
+ },
310
+ {
311
+ cpm: 12.5,
312
+ ad: '"<img src=\"https://...\"/>"',
313
+ width: 300,
314
+ height: 250,
315
+ requestId: '21e12606d47ba7',
316
+ adomain: ['abc.com'],
317
+ mediaType: BANNER
318
+ }]
319
+ };
320
+
321
+ const expectedVideoResponse = {
322
+ requestId: '21e12606d47ba7',
323
+ cpm: 12.5,
324
+ currency: 'USD',
325
+ width: 640,
326
+ height: 480,
327
+ ttl: TTL,
328
+ creativeId: '21e12606d47ba7',
329
+ netRevenue: true,
330
+ nurl: 'http://example.com/win/1234',
331
+ mediaType: VIDEO,
332
+ meta: {
333
+ mediaType: VIDEO,
334
+ advertiserDomains: ['abc.com']
335
+ },
336
+ vastXml: '<VAST version="3.0"></VAST>',
337
+ };
338
+
339
+ const expectedBannerResponse = {
340
+ requestId: '21e12606d47ba7',
341
+ cpm: 12.5,
342
+ currency: 'USD',
343
+ width: 640,
344
+ height: 480,
345
+ ttl: TTL,
346
+ creativeId: '21e12606d47ba7',
347
+ netRevenue: true,
348
+ nurl: 'http://example.com/win/1234',
349
+ mediaType: BANNER,
350
+ meta: {
351
+ mediaType: BANNER,
352
+ advertiserDomains: ['abc.com']
353
+ },
354
+ ad: '"<img src=\"https://...\"/>"'
355
+ };
356
+
357
+ it('should get correct bid response', function () {
358
+ const result = spec.interpretResponse({ body: response });
359
+ expect(Object.keys(result[0])).to.deep.equal(Object.keys(expectedVideoResponse));
360
+ expect(Object.keys(result[1])).to.deep.equal(Object.keys(expectedBannerResponse));
361
+ });
362
+
363
+ it('video type should have vastXml key', function () {
364
+ const result = spec.interpretResponse({ body: response });
365
+ expect(result[0].vastXml).to.equal(expectedVideoResponse.vastXml)
366
+ });
367
+
368
+ it('banner type should have ad key', function () {
369
+ const result = spec.interpretResponse({ body: response });
370
+ expect(result[1].ad).to.equal(expectedBannerResponse.ad)
371
+ });
372
+ })
373
+
374
+ describe('getUserSyncs', function() {
375
+ const imageSyncResponse = {
376
+ body: {
377
+ params: {
378
+ userSyncPixels: [
379
+ 'https://image-sync-url.test/1',
380
+ 'https://image-sync-url.test/2',
381
+ 'https://image-sync-url.test/3'
382
+ ]
383
+ }
384
+ }
385
+ };
386
+
387
+ const iframeSyncResponse = {
388
+ body: {
389
+ params: {
390
+ userSyncURL: 'https://iframe-sync-url.test'
391
+ }
392
+ }
393
+ };
394
+
395
+ it('should register all img urls from the response', function() {
396
+ const syncs = spec.getUserSyncs({ pixelEnabled: true }, [imageSyncResponse]);
397
+ expect(syncs).to.deep.equal([
398
+ {
399
+ type: 'image',
400
+ url: 'https://image-sync-url.test/1'
401
+ },
402
+ {
403
+ type: 'image',
404
+ url: 'https://image-sync-url.test/2'
405
+ },
406
+ {
407
+ type: 'image',
408
+ url: 'https://image-sync-url.test/3'
409
+ }
410
+ ]);
411
+ });
412
+
413
+ it('should register the iframe url from the response', function() {
414
+ const syncs = spec.getUserSyncs({ iframeEnabled: true }, [iframeSyncResponse]);
415
+ expect(syncs).to.deep.equal([
416
+ {
417
+ type: 'iframe',
418
+ url: 'https://iframe-sync-url.test'
419
+ }
420
+ ]);
421
+ });
422
+
423
+ it('should register both image and iframe urls from the responses', function() {
424
+ const syncs = spec.getUserSyncs({ pixelEnabled: true, iframeEnabled: true }, [iframeSyncResponse, imageSyncResponse]);
425
+ expect(syncs).to.deep.equal([
426
+ {
427
+ type: 'iframe',
428
+ url: 'https://iframe-sync-url.test'
429
+ },
430
+ {
431
+ type: 'image',
432
+ url: 'https://image-sync-url.test/1'
433
+ },
434
+ {
435
+ type: 'image',
436
+ url: 'https://image-sync-url.test/2'
437
+ },
438
+ {
439
+ type: 'image',
440
+ url: 'https://image-sync-url.test/3'
441
+ }
442
+ ]);
443
+ });
444
+
445
+ it('should handle an empty response', function() {
446
+ const syncs = spec.getUserSyncs({ iframeEnabled: true }, []);
447
+ expect(syncs).to.deep.equal([]);
448
+ });
449
+
450
+ it('should handle when user syncs are disabled', function() {
451
+ const syncs = spec.getUserSyncs({ pixelEnabled: false }, [imageSyncResponse]);
452
+ expect(syncs).to.deep.equal([]);
453
+ });
454
+ })
455
+
456
+ describe('onBidWon', function() {
457
+ beforeEach(function() {
458
+ sinon.stub(utils, 'triggerPixel');
459
+ });
460
+ afterEach(function() {
461
+ utils.triggerPixel.restore();
462
+ });
463
+
464
+ it('Should trigger pixel if bid nurl', function() {
465
+ const bid = {
466
+ 'bidder': spec.code,
467
+ 'adUnitCode': 'adunit-code',
468
+ 'sizes': [['640', '480']],
469
+ 'nurl': 'http://example.com/win/1234',
470
+ 'params': {
471
+ 'org': 'jdye8weeyirk00000001'
472
+ }
473
+ };
474
+
475
+ spec.onBidWon(bid);
476
+ expect(utils.triggerPixel.callCount).to.equal(1)
477
+ })
478
+ })
479
+ });