prebid.js 7.22.0 → 7.23.1

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 (273) hide show
  1. package/dist/33acrossBidAdapter.js +1 -1
  2. package/dist/aaxBlockmeterRtdProvider.js +1 -0
  3. package/dist/adagioBidAdapter.js +1 -1
  4. package/dist/adbookpspBidAdapter.js +1 -1
  5. package/dist/adgenerationBidAdapter.js +1 -1
  6. package/dist/adrelevantisBidAdapter.js +1 -1
  7. package/dist/adtrgtmeBidAdapter.js +1 -1
  8. package/dist/adxcgBidAdapter.js +1 -1
  9. package/dist/ajaBidAdapter.js +1 -1
  10. package/dist/amxBidAdapter.js +1 -1
  11. package/dist/amxIdSystem.js +1 -1
  12. package/dist/analyticsAdapter.js +1 -1
  13. package/dist/appierAnalyticsAdapter.js +1 -1
  14. package/dist/appnexusBidAdapter.js +1 -1
  15. package/dist/asoBidAdapter.js +1 -1
  16. package/dist/axonixBidAdapter.js +1 -1
  17. package/dist/bidViewability.js +1 -1
  18. package/dist/bidViewabilityIO.js +1 -1
  19. package/dist/bidglassBidAdapter.js +1 -1
  20. package/dist/big-richmediaBidAdapter.js +1 -1
  21. package/dist/bridgewellBidAdapter.js +1 -1
  22. package/dist/brightMountainMediaBidAdapter.js +1 -1
  23. package/dist/browsiRtdProvider.js +1 -1
  24. package/dist/carodaBidAdapter.js +1 -1
  25. package/dist/chtnwBidAdapter.js +1 -0
  26. package/dist/cleanioRtdProvider.js +1 -1
  27. package/dist/concertBidAdapter.js +1 -1
  28. package/dist/connectadBidAdapter.js +1 -1
  29. package/dist/consentManagement.js +1 -1
  30. package/dist/consentManagementUsp.js +1 -1
  31. package/dist/consumableBidAdapter.js +1 -1
  32. package/dist/conversantBidAdapter.js +1 -1
  33. package/dist/craftBidAdapter.js +1 -1
  34. package/dist/criteoBidAdapter.js +1 -1
  35. package/dist/currency.js +1 -1
  36. package/dist/dependencies.json +19 -0
  37. package/dist/dfpAdServerVideo.js +1 -1
  38. package/dist/dgkeywordRtdProvider.js +1 -1
  39. package/dist/dspxBidAdapter.js +1 -1
  40. package/dist/eplanningBidAdapter.js +1 -1
  41. package/dist/finativeBidAdapter.js +1 -1
  42. package/dist/gdprEnforcement.js +1 -1
  43. package/dist/glimpseBidAdapter.js +1 -1
  44. package/dist/gmosspBidAdapter.js +1 -1
  45. package/dist/goldbachBidAdapter.js +1 -1
  46. package/dist/googleAnalyticsAdapter.js +1 -1
  47. package/dist/gridBidAdapter.js +1 -1
  48. package/dist/gridNMBidAdapter.js +1 -1
  49. package/dist/gumgumBidAdapter.js +1 -1
  50. package/dist/h12mediaBidAdapter.js +1 -1
  51. package/dist/id5AnalyticsAdapter.js +1 -1
  52. package/dist/id5IdSystem.js +1 -1
  53. package/dist/improvedigitalBidAdapter.js +1 -1
  54. package/dist/inmarBidAdapter.js +1 -1
  55. package/dist/insticatorBidAdapter.js +1 -1
  56. package/dist/instreamTracking.js +1 -1
  57. package/dist/ixBidAdapter.js +1 -1
  58. package/dist/justpremiumBidAdapter.js +1 -1
  59. package/dist/jwplayerVideoProvider.js +1 -0
  60. package/dist/kargoBidAdapter.js +1 -1
  61. package/dist/konduitAnalyticsAdapter.js +1 -1
  62. package/dist/kueezBidAdapter.js +1 -1
  63. package/dist/lassoBidAdapter.js +1 -1
  64. package/dist/lifestreetBidAdapter.js +1 -1
  65. package/dist/liveyieldAnalyticsAdapter.js +1 -1
  66. package/dist/logicadBidAdapter.js +1 -1
  67. package/dist/loglyliftBidAdapter.js +1 -1
  68. package/dist/magniteAnalyticsAdapter.js +1 -1
  69. package/dist/malltvAnalyticsAdapter.js +1 -1
  70. package/dist/marsmediaBidAdapter.js +1 -1
  71. package/dist/mediafuseBidAdapter.js +1 -1
  72. package/dist/mediasquareBidAdapter.js +1 -1
  73. package/dist/mgidBidAdapter.js +1 -1
  74. package/dist/minutemediaBidAdapter.js +1 -1
  75. package/dist/multibid.js +1 -1
  76. package/dist/not-for-prod/prebid.js +141 -132
  77. package/dist/oguryBidAdapter.js +1 -1
  78. package/dist/onetagBidAdapter.js +1 -1
  79. package/dist/ooloAnalyticsAdapter.js +1 -1
  80. package/dist/openxOrtbBidAdapter.js +1 -1
  81. package/dist/ortbConverter.js +1 -0
  82. package/dist/outbrainBidAdapter.js +1 -1
  83. package/dist/oxxionRtdProvider.js +1 -0
  84. package/dist/parrableIdSystem.js +1 -1
  85. package/dist/pbsExtensions.js +1 -0
  86. package/dist/pixfutureBidAdapter.js +1 -1
  87. package/dist/prebid-core.js +1 -1
  88. package/dist/prebidServerBidAdapter.js +1 -1
  89. package/dist/priceFloors.js +1 -1
  90. package/dist/pubCommonId.js +1 -1
  91. package/dist/publinkIdSystem.js +1 -1
  92. package/dist/pubmaticBidAdapter.js +1 -1
  93. package/dist/pubwiseAnalyticsAdapter.js +1 -1
  94. package/dist/pxyzBidAdapter.js +1 -1
  95. package/dist/quantcastBidAdapter.js +1 -1
  96. package/dist/readpeakBidAdapter.js +1 -1
  97. package/dist/relaidoBidAdapter.js +1 -1
  98. package/dist/rhythmoneBidAdapter.js +1 -1
  99. package/dist/riseBidAdapter.js +1 -1
  100. package/dist/rtdModule.js +1 -1
  101. package/dist/rubiconAnalyticsAdapter.js +1 -1
  102. package/dist/rubiconBidAdapter.js +1 -1
  103. package/dist/schain.js +1 -1
  104. package/dist/seedingAllianceBidAdapter.js +1 -1
  105. package/dist/seedtagBidAdapter.js +1 -1
  106. package/dist/sharethroughAnalyticsAdapter.js +1 -1
  107. package/dist/sharethroughBidAdapter.js +1 -1
  108. package/dist/shinezBidAdapter.js +1 -1
  109. package/dist/smaatoBidAdapter.js +1 -1
  110. package/dist/smartadserverBidAdapter.js +1 -1
  111. package/dist/smartxBidAdapter.js +1 -1
  112. package/dist/smilewantedBidAdapter.js +1 -1
  113. package/dist/sonobiBidAdapter.js +1 -1
  114. package/dist/sovrnAnalyticsAdapter.js +1 -1
  115. package/dist/sovrnBidAdapter.js +1 -1
  116. package/dist/spotxBidAdapter.js +1 -1
  117. package/dist/sspBCBidAdapter.js +1 -1
  118. package/dist/sublimeBidAdapter.js +1 -1
  119. package/dist/synacormediaBidAdapter.js +1 -1
  120. package/dist/targetVideoBidAdapter.js +1 -1
  121. package/dist/teadsBidAdapter.js +1 -1
  122. package/dist/teadsIdSystem.js +1 -1
  123. package/dist/trionBidAdapter.js +1 -1
  124. package/dist/tripleliftBidAdapter.js +1 -1
  125. package/dist/ttdBidAdapter.js +1 -1
  126. package/dist/ucfunnelAnalyticsAdapter.js +1 -1
  127. package/dist/underdogmediaBidAdapter.js +1 -1
  128. package/dist/undertoneBidAdapter.js +1 -1
  129. package/dist/userId.js +1 -1
  130. package/dist/vidazooBidAdapter.js +1 -1
  131. package/dist/video.js +1 -0
  132. package/dist/videoModule.js +1 -0
  133. package/dist/videobyteBidAdapter.js +1 -1
  134. package/dist/videojsVideoProvider.js +1 -0
  135. package/dist/visxBidAdapter.js +1 -1
  136. package/dist/vuukleBidAdapter.js +1 -1
  137. package/dist/widespaceBidAdapter.js +1 -1
  138. package/dist/winrBidAdapter.js +1 -1
  139. package/dist/yahoosspBidAdapter.js +1 -1
  140. package/dist/yieldmoBidAdapter.js +1 -1
  141. package/dist/yieldoneAnalyticsAdapter.js +1 -1
  142. package/integrationExamples/videoModule/jwplayer/bidMarkedAsUsed.html +98 -0
  143. package/integrationExamples/videoModule/jwplayer/bidRequestScheduling.html +89 -0
  144. package/integrationExamples/videoModule/jwplayer/eventListeners.html +244 -0
  145. package/integrationExamples/videoModule/jwplayer/gamAdServerMediation.html +122 -0
  146. package/integrationExamples/videoModule/jwplayer/mediaMetadata.html +80 -0
  147. package/integrationExamples/videoModule/jwplayer/playlist.html +122 -0
  148. package/integrationExamples/videoModule/videojs/bidMarkedAsUsed.html +126 -0
  149. package/integrationExamples/videoModule/videojs/bidRequestScheduling.html +132 -0
  150. package/integrationExamples/videoModule/videojs/eventListeners.html +238 -0
  151. package/integrationExamples/videoModule/videojs/gamAdServerMediation.html +138 -0
  152. package/integrationExamples/videoModule/videojs/mediaMetadata.html +103 -0
  153. package/integrationExamples/videoModule/videojs/playlist.html +151 -0
  154. package/libraries/ortbConverter/README.md +378 -0
  155. package/libraries/ortbConverter/converter.js +135 -0
  156. package/libraries/ortbConverter/lib/composer.js +43 -0
  157. package/libraries/ortbConverter/lib/mergeProcessors.js +9 -0
  158. package/libraries/ortbConverter/lib/sizes.js +14 -0
  159. package/libraries/ortbConverter/processors/banner.js +40 -0
  160. package/libraries/ortbConverter/processors/default.js +167 -0
  161. package/libraries/ortbConverter/processors/mediaType.js +21 -0
  162. package/libraries/ortbConverter/processors/native.js +37 -0
  163. package/libraries/ortbConverter/processors/video.js +66 -0
  164. package/libraries/pbsExtensions/pbsExtensions.js +12 -0
  165. package/libraries/pbsExtensions/processors/aliases.js +17 -0
  166. package/libraries/pbsExtensions/processors/mediaType.js +23 -0
  167. package/libraries/pbsExtensions/processors/params.js +22 -0
  168. package/libraries/pbsExtensions/processors/pbs.js +99 -0
  169. package/libraries/pbsExtensions/processors/requestExtPrebid.js +30 -0
  170. package/libraries/pbsExtensions/processors/video.js +23 -0
  171. package/libraries/video/constants/enums.js +5 -0
  172. package/libraries/video/constants/events.js +97 -0
  173. package/libraries/video/constants/ortb.js +169 -0
  174. package/libraries/video/constants/vendorCodes.js +6 -0
  175. package/libraries/video/shared/eventHandler.js +18 -0
  176. package/libraries/video/shared/parentModule.js +82 -0
  177. package/libraries/video/shared/state.js +47 -0
  178. package/libraries/video/shared/vastXmlBuilder.js +77 -0
  179. package/libraries/video/shared/vastXmlEditor.js +115 -0
  180. package/modules/.submodules.json +6 -1
  181. package/modules/aaxBlockmeterRtdProvider.js +59 -0
  182. package/modules/aaxBlockmeterRtdProvider.md +48 -0
  183. package/modules/appnexusBidAdapter.js +38 -1
  184. package/modules/chtnwBidAdapter.js +110 -0
  185. package/modules/chtnwBidAdapter.md +31 -0
  186. package/modules/concertBidAdapter.js +44 -2
  187. package/modules/consentManagement.js +22 -1
  188. package/modules/consentManagementUsp.js +29 -7
  189. package/modules/criteoBidAdapter.js +25 -5
  190. package/modules/currency.js +9 -0
  191. package/modules/dgkeywordRtdProvider.js +3 -3
  192. package/modules/gridNMBidAdapter.js +10 -14
  193. package/modules/improvedigitalBidAdapter.js +191 -470
  194. package/modules/ixBidAdapter.js +24 -64
  195. package/modules/jwplayerVideoProvider.js +929 -0
  196. package/modules/jwplayerVideoProvider.md +25 -0
  197. package/modules/kargoBidAdapter.js +1 -1
  198. package/modules/multibid/index.js +12 -0
  199. package/modules/openxOrtbBidAdapter.js +120 -275
  200. package/modules/oxxionRtdProvider.js +119 -0
  201. package/modules/oxxionRtdProvider.md +48 -0
  202. package/modules/prebidServerBidAdapter/index.js +19 -716
  203. package/modules/prebidServerBidAdapter/ortbConverter.js +274 -0
  204. package/modules/priceFloors.js +73 -1
  205. package/modules/rtdModule/index.js +22 -1
  206. package/modules/schain.js +24 -1
  207. package/modules/spotxBidAdapter.js +16 -15
  208. package/modules/synacormediaBidAdapter.js +1 -1
  209. package/modules/teadsIdSystem.js +5 -0
  210. package/modules/userId/index.js +64 -6
  211. package/modules/videoModule/addingSubmodule.md +521 -0
  212. package/modules/videoModule/coreVideo.js +234 -0
  213. package/modules/videoModule/gamAdServerSubmodule.js +27 -0
  214. package/modules/videoModule/index.js +244 -0
  215. package/modules/videoModule/videoImpressionVerifier.js +206 -0
  216. package/modules/videojsVideoProvider.js +854 -0
  217. package/modules/videojsVideoProvider.md +17 -0
  218. package/package.json +5 -1
  219. package/src/adapterManager.js +56 -7
  220. package/src/adloader.js +2 -1
  221. package/src/auction.js +5 -0
  222. package/src/events.js +5 -1
  223. package/src/pbjsORTB.js +35 -0
  224. package/src/prebid.js +137 -112
  225. package/src/targeting.js +10 -2
  226. package/src/utils/currency.js +16 -0
  227. package/src/utils.js +21 -0
  228. package/test/spec/auctionmanager_spec.js +6 -0
  229. package/test/spec/modules/aaxBlockmeter_spec.js +58 -0
  230. package/test/spec/modules/chtnwBidAdapter_spec.js +105 -0
  231. package/test/spec/modules/concertBidAdapter_spec.js +56 -0
  232. package/test/spec/modules/consentManagementUsp_spec.js +64 -18
  233. package/test/spec/modules/criteoBidAdapter_spec.js +28 -0
  234. package/test/spec/modules/dgkeywordRtdProvider_spec.js +3 -3
  235. package/test/spec/modules/improvedigitalBidAdapter_spec.js +231 -211
  236. package/test/spec/modules/ixBidAdapter_spec.js +230 -371
  237. package/test/spec/modules/openxOrtbBidAdapter_spec.js +77 -49
  238. package/test/spec/modules/oxxionRtdProvider_spec.js +142 -0
  239. package/test/spec/modules/prebidServerBidAdapter_spec.js +139 -137
  240. package/test/spec/modules/realTimeDataModule_spec.js +65 -0
  241. package/test/spec/modules/userId_spec.js +67 -1
  242. package/test/spec/modules/videoModule/coreVideo_spec.js +98 -0
  243. package/test/spec/modules/videoModule/pbVideo_spec.js +362 -0
  244. package/test/spec/modules/videoModule/shared/parentModule_spec.js +73 -0
  245. package/test/spec/modules/videoModule/shared/state_spec.js +26 -0
  246. package/test/spec/modules/videoModule/shared/vastXmlBuilder_spec.js +103 -0
  247. package/test/spec/modules/videoModule/shared/vastXmlEditor_spec.js +209 -0
  248. package/test/spec/modules/videoModule/submodules/jwplayerVideoProvider_spec.js +846 -0
  249. package/test/spec/modules/videoModule/submodules/videojsVideoProvider_spec.js +391 -0
  250. package/test/spec/modules/videoModule/videoImpressionVerifier_spec.js +112 -0
  251. package/test/spec/ortbConverter/banner_spec.js +203 -0
  252. package/test/spec/ortbConverter/composer_spec.js +69 -0
  253. package/test/spec/ortbConverter/converter_spec.js +283 -0
  254. package/test/spec/ortbConverter/currency_spec.js +40 -0
  255. package/test/spec/ortbConverter/default_processors_spec.js +61 -0
  256. package/test/spec/ortbConverter/gdpr_spec.js +38 -0
  257. package/test/spec/ortbConverter/mediaTypes_spec.js +67 -0
  258. package/test/spec/ortbConverter/mergeProcessors_spec.js +59 -0
  259. package/test/spec/ortbConverter/multibid_spec.js +35 -0
  260. package/test/spec/ortbConverter/native_spec.js +95 -0
  261. package/test/spec/ortbConverter/pbjsORTB_spec.js +67 -0
  262. package/test/spec/ortbConverter/pbsExtensions/aliases_spec.js +57 -0
  263. package/test/spec/ortbConverter/pbsExtensions/params_spec.js +96 -0
  264. package/test/spec/ortbConverter/pbsExtensions/video_spec.js +52 -0
  265. package/test/spec/ortbConverter/priceFloors_spec.js +143 -0
  266. package/test/spec/ortbConverter/schain_spec.js +33 -0
  267. package/test/spec/ortbConverter/userId_spec.js +21 -0
  268. package/test/spec/ortbConverter/usp_spec.js +15 -0
  269. package/test/spec/ortbConverter/video_spec.js +189 -0
  270. package/test/spec/unit/core/adapterManager_spec.js +102 -0
  271. package/test/spec/unit/core/targeting_spec.js +34 -0
  272. package/test/spec/unit/pbjs_api_spec.js +124 -45
  273. package/test/spec/utils_spec.js +45 -1
@@ -286,6 +286,44 @@ describe('IndexexchangeAdapter', function () {
286
286
  }
287
287
  ];
288
288
 
289
+ const DEFAULT_VIDEO_VALID_BID_MEDIUM_SIZE = [
290
+ {
291
+ bidder: 'ix',
292
+ params: {
293
+ siteId: '456',
294
+ video: {
295
+ skippable: false,
296
+ mimes: [
297
+ 'video/mp4',
298
+ 'video/webm'
299
+ ],
300
+ minduration: 0,
301
+ maxduration: 60,
302
+ protocols: [2]
303
+ },
304
+ size: [640, 480]
305
+ },
306
+ sizes: [[640, 480], [200, 400]],
307
+ mediaTypes: {
308
+ video: {
309
+ context: 'instream',
310
+ playerSize: [[640, 480], [200, 400]]
311
+ }
312
+ },
313
+ ortb2Imp: {
314
+ ext: {
315
+ tid: '173f49a8-7549-4218-a23c-e7ba59b47230'
316
+ }
317
+ },
318
+ adUnitCode: 'div-gpt-ad-1460505748562-0',
319
+ transactionId: '173f49a8-7549-4218-a23c-e7ba59b47230',
320
+ bidId: '1a2b3c4e',
321
+ bidderRequestId: '11a22b33c44e',
322
+ auctionId: '1aa2bb3cc4de',
323
+ schain: SAMPLE_SCHAIN
324
+ }
325
+ ];
326
+
289
327
  const DEFAULT_MULTIFORMAT_BANNER_VALID_BID = [
290
328
  {
291
329
  bidder: 'ix',
@@ -400,7 +438,7 @@ describe('IndexexchangeAdapter', function () {
400
438
  }
401
439
  },
402
440
  nativeOrtbRequest: {
403
- assets: [{id: 0, required: 0, img: {type: 1}}, {id: 1, required: 1, title: {len: 140}}, {id: 2, required: 1, data: {type: 2}}, {id: 3, required: 1, img: {type: 3}}, {id: 4, required: false, video: {mimes: ['video/mp4', 'video/webm'], minduration: 0, maxduration: 120, protocols: [2, 3, 5, 6]}}]
441
+ assets: [{ id: 0, required: 0, img: { type: 1 } }, { id: 1, required: 1, title: { len: 140 } }, { id: 2, required: 1, data: { type: 2 } }, { id: 3, required: 1, img: { type: 3 } }, { id: 4, required: false, video: { mimes: ['video/mp4', 'video/webm'], minduration: 0, maxduration: 120, protocols: [2, 3, 5, 6] } }]
404
442
  },
405
443
  adUnitCode: 'div-gpt-ad-1460505748563-0',
406
444
  transactionId: '173f49a8-7549-4218-a23c-e7ba59b47231',
@@ -441,7 +479,7 @@ describe('IndexexchangeAdapter', function () {
441
479
  }
442
480
  },
443
481
  nativeOrtbRequest: {
444
- assets: [{id: 0, required: 0, img: {type: 1}}, {id: 1, required: 1, title: {len: 140}}, {id: 2, required: 1, data: {type: 2}}, {id: 3, required: 1, img: {type: 3}}, {id: 4, required: false, video: {mimes: ['video/mp4', 'video/webm'], minduration: 0, maxduration: 120, protocols: [2, 3, 5, 6]}}]
482
+ assets: [{ id: 0, required: 0, img: { type: 1 } }, { id: 1, required: 1, title: { len: 140 } }, { id: 2, required: 1, data: { type: 2 } }, { id: 3, required: 1, img: { type: 3 } }, { id: 4, required: false, video: { mimes: ['video/mp4', 'video/webm'], minduration: 0, maxduration: 120, protocols: [2, 3, 5, 6] } }]
445
483
  },
446
484
  adUnitCode: 'div-gpt-ad-1460505748562-0',
447
485
  transactionId: '173f49a8-7549-4218-a23c-e7ba59b47230',
@@ -633,31 +671,6 @@ describe('IndexexchangeAdapter', function () {
633
671
  }
634
672
  };
635
673
 
636
- const DEFAULT_BIDDER_REQUEST_DATA = {
637
- ac: 'j',
638
- r: JSON.stringify({
639
- id: '345',
640
- imp: [
641
- {
642
- id: '1a2b3c4e',
643
- video: {
644
- w: 640,
645
- h: 480,
646
- placement: 1
647
- }
648
- }
649
- ],
650
- site: {
651
- ref: 'https://ref.com/ref.html',
652
- page: 'https://page.com'
653
- },
654
- }),
655
- s: '21',
656
- sd: 1,
657
- t: 1000,
658
- v: 8.1
659
- };
660
-
661
674
  const DEFAULT_USERID_DATA = {
662
675
  idl_env: '1234-5678-9012-3456', // Liveramp
663
676
  netId: 'testnetid123', // NetId
@@ -724,6 +737,8 @@ describe('IndexexchangeAdapter', function () {
724
737
  lotamePanoramaId: 'bd738d136bdaa841117fe9b331bb4'
725
738
  };
726
739
 
740
+ const extractPayload = function (bidRequest) { return bidRequest.data }
741
+
727
742
  describe('inherited functions', function () {
728
743
  it('should exists and is a function', function () {
729
744
  const adapter = newBidder(spec);
@@ -778,7 +793,7 @@ describe('IndexexchangeAdapter', function () {
778
793
  syncsPerBidder: 3
779
794
  }
780
795
  });
781
- let userSync = spec.getUserSyncs(syncOptions, [{'body': {'ext': {'publishersyncsperbidderoverride': 0}}}]);
796
+ let userSync = spec.getUserSyncs(syncOptions, [{ 'body': { 'ext': { 'publishersyncsperbidderoverride': 0 } } }]);
782
797
  expect(userSync.length).to.equal(0);
783
798
  });
784
799
 
@@ -792,7 +807,7 @@ describe('IndexexchangeAdapter', function () {
792
807
  syncsPerBidder: 3
793
808
  }
794
809
  });
795
- let userSync = spec.getUserSyncs(syncOptions, [{'body': {'ext': {'publishersyncsperbidderoverride': 2}}}]);
810
+ let userSync = spec.getUserSyncs(syncOptions, [{ 'body': { 'ext': { 'publishersyncsperbidderoverride': 2 } } }]);
796
811
  expect(userSync[0].type).to.equal('image');
797
812
  const USER_SYNC_URL_0 = 'https://dsum.casalemedia.com/pbusermatch?origin=prebid&site_id=123&p=2&i=0&gdpr=1&gdpr_consent=3huaa11=qu3198ae&us_privacy=';
798
813
  const USER_SYNC_URL_1 = 'https://dsum.casalemedia.com/pbusermatch?origin=prebid&site_id=123&p=2&i=1&gdpr=1&gdpr_consent=3huaa11=qu3198ae&us_privacy=';
@@ -811,7 +826,7 @@ describe('IndexexchangeAdapter', function () {
811
826
  syncsPerBidder: 3
812
827
  }
813
828
  });
814
- let userSync = spec.getUserSyncs(syncOptions, [{'body': {'ext': {'publishersyncsperbidderoverride': 4}}}]);
829
+ let userSync = spec.getUserSyncs(syncOptions, [{ 'body': { 'ext': { 'publishersyncsperbidderoverride': 4 } } }]);
815
830
  expect(userSync[0].type).to.equal('image');
816
831
  const USER_SYNC_URL_0 = 'https://dsum.casalemedia.com/pbusermatch?origin=prebid&site_id=123&p=3&i=0&gdpr=1&gdpr_consent=3huaa11=qu3198ae&us_privacy=';
817
832
  const USER_SYNC_URL_1 = 'https://dsum.casalemedia.com/pbusermatch?origin=prebid&site_id=123&p=3&i=1&gdpr=1&gdpr_consent=3huaa11=qu3198ae&us_privacy=';
@@ -832,7 +847,7 @@ describe('IndexexchangeAdapter', function () {
832
847
  syncsPerBidder: 0
833
848
  }
834
849
  });
835
- let userSync = spec.getUserSyncs(syncOptions, [{'body': {'ext': {'publishersyncsperbidderoverride': 2}}}]);
850
+ let userSync = spec.getUserSyncs(syncOptions, [{ 'body': { 'ext': { 'publishersyncsperbidderoverride': 2 } } }]);
836
851
  expect(userSync[0].type).to.equal('image');
837
852
  const USER_SYNC_URL_0 = 'https://dsum.casalemedia.com/pbusermatch?origin=prebid&site_id=123&p=2&i=0&gdpr=1&gdpr_consent=3huaa11=qu3198ae&us_privacy=';
838
853
  const USER_SYNC_URL_1 = 'https://dsum.casalemedia.com/pbusermatch?origin=prebid&site_id=123&p=2&i=1&gdpr=1&gdpr_consent=3huaa11=qu3198ae&us_privacy=';
@@ -868,7 +883,7 @@ describe('IndexexchangeAdapter', function () {
868
883
  const bid = utils.deepClone(DEFAULT_VIDEO_VALID_BID[0]);
869
884
  bid.mediaTypes.video.renderer = {
870
885
  url: 'test',
871
- render: () => {}
886
+ render: () => { }
872
887
  };
873
888
  bid.mediaTypes.video.context = 'outstream';
874
889
  bid.mediaTypes.video.playerSize = [[300, 249]];
@@ -1080,7 +1095,7 @@ describe('IndexexchangeAdapter', function () {
1080
1095
  bid.nativeOrtbRequest = {}
1081
1096
  expect(spec.isBidRequestValid(bid)).to.be.false;
1082
1097
 
1083
- bid.nativeOrtbRequest = {assets: []}
1098
+ bid.nativeOrtbRequest = { assets: [] }
1084
1099
  expect(spec.isBidRequestValid(bid)).to.be.false;
1085
1100
  });
1086
1101
  });
@@ -1104,7 +1119,7 @@ describe('IndexexchangeAdapter', function () {
1104
1119
  const cloneValidBid = utils.deepClone(validBid);
1105
1120
  cloneValidBid[0].userIdAsEids = utils.deepClone(DEFAULT_USERIDASEIDS_DATA);
1106
1121
  const request = spec.buildRequests(cloneValidBid, ALIAS_OPTIONS);
1107
- const payload = JSON.parse(request[0].data.r);
1122
+ const payload = extractPayload(request[0]);
1108
1123
  expect(request).to.be.an('array');
1109
1124
  expect(request).to.have.lengthOf.above(0); // should be 1 or more
1110
1125
  expect(payload.user.eids).to.have.lengthOf(6);
@@ -1115,7 +1130,7 @@ describe('IndexexchangeAdapter', function () {
1115
1130
 
1116
1131
  describe('buildRequestsIdentity', function () {
1117
1132
  let request;
1118
- let query;
1133
+ let payload;
1119
1134
  let testCopy;
1120
1135
 
1121
1136
  beforeEach(function () {
@@ -1124,7 +1139,7 @@ describe('IndexexchangeAdapter', function () {
1124
1139
  return testCopy;
1125
1140
  };
1126
1141
  request = spec.buildRequests(DEFAULT_BANNER_VALID_BID, DEFAULT_OPTION)[0];
1127
- query = request.data;
1142
+ payload = extractPayload(request);
1128
1143
  });
1129
1144
 
1130
1145
  afterEach(function () {
@@ -1137,8 +1152,6 @@ describe('IndexexchangeAdapter', function () {
1137
1152
  });
1138
1153
 
1139
1154
  it('payload should have correct format and value (single identity partner)', function () {
1140
- const payload = JSON.parse(query.r);
1141
-
1142
1155
  expect(payload.user).to.exist;
1143
1156
  expect(payload.user.eids).to.exist;
1144
1157
  expect(payload.user.eids).to.be.an('array');
@@ -1146,7 +1159,7 @@ describe('IndexexchangeAdapter', function () {
1146
1159
  });
1147
1160
 
1148
1161
  it('identity data in impression should have correct format and value (single identity partner)', function () {
1149
- const impression = JSON.parse(query.r).user.eids;
1162
+ const impression = payload.user.eids;
1150
1163
  expect(impression[0].source).to.equal(testCopy.IdentityIp.data.source);
1151
1164
  expect(impression[0].uids[0].id).to.equal(testCopy.IdentityIp.data.uids[0].id);
1152
1165
  });
@@ -1166,8 +1179,6 @@ describe('IndexexchangeAdapter', function () {
1166
1179
  });
1167
1180
 
1168
1181
  it('payload should have correct format and value (single identity w/ multi ids)', function () {
1169
- const payload = JSON.parse(query.r);
1170
-
1171
1182
  expect(payload.user).to.exist;
1172
1183
  expect(payload.user.eids).to.exist;
1173
1184
  expect(payload.user.eids).to.be.an('array');
@@ -1175,7 +1186,7 @@ describe('IndexexchangeAdapter', function () {
1175
1186
  });
1176
1187
 
1177
1188
  it('identity data in impression should have correct format and value (single identity w/ multi ids)', function () {
1178
- const impression = JSON.parse(query.r).user.eids;
1189
+ const impression = payload.user.eids;
1179
1190
 
1180
1191
  expect(impression[0].source).to.equal(testCopy.IdentityIp.data.source);
1181
1192
  expect(impression[0].uids).to.have.lengthOf(3);
@@ -1210,8 +1221,6 @@ describe('IndexexchangeAdapter', function () {
1210
1221
  });
1211
1222
 
1212
1223
  it('payload should have correct format and value (multiple identity partners)', function () {
1213
- const payload = JSON.parse(query.r);
1214
-
1215
1224
  expect(payload.user).to.exist;
1216
1225
  expect(payload.user.eids).to.exist;
1217
1226
  expect(payload.user.eids).to.be.an('array');
@@ -1219,7 +1228,7 @@ describe('IndexexchangeAdapter', function () {
1219
1228
  });
1220
1229
 
1221
1230
  it('identity data in impression should have correct format and value (multiple identity partners)', function () {
1222
- const impression = JSON.parse(query.r).user.eids;
1231
+ const impression = payload.user.eids;
1223
1232
 
1224
1233
  expect(impression[0].source).to.equal(testCopy.IdentityIp.data.source);
1225
1234
  expect(impression[0].uids).to.have.lengthOf(1);
@@ -1242,8 +1251,7 @@ describe('IndexexchangeAdapter', function () {
1242
1251
  return undefined;
1243
1252
  };
1244
1253
  request = spec.buildRequests(DEFAULT_BANNER_VALID_BID, DEFAULT_OPTION)[0];
1245
- query = request.data;
1246
- const payload = JSON.parse(query.r);
1254
+ payload = extractPayload(request);
1247
1255
 
1248
1256
  expect(payload.user).to.exist;
1249
1257
  expect(payload.user.eids).to.not.exist;
@@ -1255,8 +1263,7 @@ describe('IndexexchangeAdapter', function () {
1255
1263
  data: {}
1256
1264
  }
1257
1265
  request = spec.buildRequests(DEFAULT_BANNER_VALID_BID, DEFAULT_OPTION)[0];
1258
- query = request.data;
1259
- const payload = JSON.parse(query.r);
1266
+ payload = extractPayload(request);
1260
1267
 
1261
1268
  expect(payload.user).to.exist;
1262
1269
  expect(payload.user.eids).to.exist;
@@ -1265,8 +1272,7 @@ describe('IndexexchangeAdapter', function () {
1265
1272
  it('payload should not have any user eids if identity data is pending for all partners', function () {
1266
1273
  testCopy.IdentityIp.responsePending = true;
1267
1274
  request = spec.buildRequests(DEFAULT_BANNER_VALID_BID, DEFAULT_OPTION)[0];
1268
- query = request.data;
1269
- const payload = JSON.parse(query.r);
1275
+ payload = extractPayload(request);
1270
1276
 
1271
1277
  expect(payload.user).to.exist;
1272
1278
  expect(payload.user.eids).to.not.exist;
@@ -1276,8 +1282,7 @@ describe('IndexexchangeAdapter', function () {
1276
1282
  testCopy.IdentityIp.responsePending = false;
1277
1283
  testCopy.IdentityIp.data = {};
1278
1284
  request = spec.buildRequests(DEFAULT_BANNER_VALID_BID, DEFAULT_OPTION)[0];
1279
- query = request.data;
1280
- const payload = JSON.parse(query.r);
1285
+ payload = extractPayload(request);
1281
1286
 
1282
1287
  expect(payload.user).to.exist;
1283
1288
  expect(payload.user.eids).to.not.exist;
@@ -1304,7 +1309,7 @@ describe('IndexexchangeAdapter', function () {
1304
1309
  const cloneValidBid = utils.deepClone(DEFAULT_VIDEO_VALID_BID);
1305
1310
  cloneValidBid[0].userIdAsEids = utils.deepClone(DEFAULT_USERIDASEIDS_DATA);
1306
1311
  const request = spec.buildRequests(cloneValidBid, DEFAULT_OPTION)[0];
1307
- const payload = JSON.parse(request.data.r);
1312
+ const payload = extractPayload(request);
1308
1313
 
1309
1314
  expect(payload.user.eids).to.have.lengthOf(6);
1310
1315
  expect(payload.user.eids).to.have.deep.members(DEFAULT_USERID_PAYLOAD);
@@ -1401,7 +1406,7 @@ describe('IndexexchangeAdapter', function () {
1401
1406
  cloneValidBid[0].userIdAsEids = utils.deepClone(DEFAULT_USERIDASEIDS_DATA);
1402
1407
 
1403
1408
  const request = spec.buildRequests(cloneValidBid, DEFAULT_OPTION)[0];
1404
- const payload = JSON.parse(request.data.r);
1409
+ const payload = extractPayload(request);
1405
1410
 
1406
1411
  validUserIdPayload = utils.deepClone(DEFAULT_USERID_PAYLOAD);
1407
1412
  validUserIdPayload.push({
@@ -1480,7 +1485,7 @@ describe('IndexexchangeAdapter', function () {
1480
1485
  }]
1481
1486
  });
1482
1487
 
1483
- const payload = JSON.parse(request.data.r);
1488
+ const payload = extractPayload(request);
1484
1489
  expect(payload.user.eids).to.have.lengthOf(7);
1485
1490
  expect(payload.user.eids).to.have.deep.members(validUserIdPayload);
1486
1491
  });
@@ -1503,7 +1508,7 @@ describe('IndexexchangeAdapter', function () {
1503
1508
  bid.userId = DEFAULT_USERID_BID_DATA;
1504
1509
 
1505
1510
  const request = spec.buildRequests([bid], DEFAULT_OPTION)[0];
1506
- const r = JSON.parse(request.data.r);
1511
+ const r = extractPayload(request);
1507
1512
 
1508
1513
  expect(r.ext.ixdiag.userIds).to.be.an('array');
1509
1514
  expect(r.ext.ixdiag.userIds.should.not.include('lotamePanoramaId'));
@@ -1514,8 +1519,8 @@ describe('IndexexchangeAdapter', function () {
1514
1519
 
1515
1520
  describe('First party data', function () {
1516
1521
  it('should not set ixdiag.fpd value if not defined', function () {
1517
- const request = spec.buildRequests(DEFAULT_BANNER_VALID_BID, {ortb2: {}})[0];
1518
- const r = JSON.parse(request.data.r);
1522
+ const request = spec.buildRequests(DEFAULT_BANNER_VALID_BID, { ortb2: {} })[0];
1523
+ const r = extractPayload(request);
1519
1524
 
1520
1525
  expect(r.ext.ixdiag.fpd).to.be.undefined;
1521
1526
  });
@@ -1531,8 +1536,8 @@ describe('IndexexchangeAdapter', function () {
1531
1536
  }
1532
1537
  };
1533
1538
 
1534
- const request = spec.buildRequests(DEFAULT_BANNER_VALID_BID, {ortb2})[0];
1535
- const r = JSON.parse(request.data.r);
1539
+ const request = spec.buildRequests(DEFAULT_BANNER_VALID_BID, { ortb2 })[0];
1540
+ const r = extractPayload(request);
1536
1541
 
1537
1542
  expect(r.ext.ixdiag.fpd).to.exist;
1538
1543
  });
@@ -1543,7 +1548,7 @@ describe('IndexexchangeAdapter', function () {
1543
1548
  });
1544
1549
 
1545
1550
  const request = spec.buildRequests(DEFAULT_BANNER_VALID_BID)[0];
1546
- const r = JSON.parse(request.data.r);
1551
+ const r = extractPayload(request);
1547
1552
 
1548
1553
  expect(r.ext.ixdiag.tmax).to.equal(250);
1549
1554
  });
@@ -1553,7 +1558,7 @@ describe('IndexexchangeAdapter', function () {
1553
1558
  bidderTimeout: null
1554
1559
  })
1555
1560
  const request = spec.buildRequests(DEFAULT_BANNER_VALID_BID)[0];
1556
- const r = JSON.parse(request.data.r);
1561
+ const r = extractPayload(request);
1557
1562
 
1558
1563
  expect(r.ext.ixdiag.tmax).to.be.undefined
1559
1564
  });
@@ -1571,8 +1576,8 @@ describe('IndexexchangeAdapter', function () {
1571
1576
  }
1572
1577
  };
1573
1578
 
1574
- const request = spec.buildRequests(DEFAULT_BANNER_VALID_BID, {ortb2})[0];
1575
- const r = JSON.parse(request.data.r);
1579
+ const request = spec.buildRequests(DEFAULT_BANNER_VALID_BID, { ortb2 })[0];
1580
+ const r = extractPayload(request);
1576
1581
 
1577
1582
  expect(r.site.keywords).to.exist;
1578
1583
  expect(r.site.search).to.exist;
@@ -1595,8 +1600,8 @@ describe('IndexexchangeAdapter', function () {
1595
1600
  const bid = utils.deepClone(DEFAULT_BANNER_VALID_BID[0]);
1596
1601
  bid.mediaTypes.banner.sizes = LARGE_SET_OF_SIZES;
1597
1602
 
1598
- const request = spec.buildRequests([bid], {ortb2})[0];
1599
- const r = JSON.parse(request.data.r);
1603
+ const request = spec.buildRequests([bid], { ortb2 })[0];
1604
+ const r = extractPayload(request);
1600
1605
 
1601
1606
  expect(r.site.ref).to.exist;
1602
1607
  expect(r.site.keywords).to.be.undefined;
@@ -1608,33 +1613,25 @@ describe('IndexexchangeAdapter', function () {
1608
1613
  let request = spec.buildRequests(DEFAULT_BANNER_VALID_BID, DEFAULT_OPTION)[0];
1609
1614
  const requestUrl = request.url;
1610
1615
  const requestMethod = request.method;
1611
- const query = request.data;
1616
+ const payloadData = request.data;
1612
1617
 
1613
1618
  const bidWithoutSchain = utils.deepClone(DEFAULT_BANNER_VALID_BID);
1614
1619
  delete bidWithoutSchain[0].schain;
1615
1620
  const requestWithoutSchain = spec.buildRequests(bidWithoutSchain, DEFAULT_OPTION)[0];
1616
- const queryWithoutSchain = requestWithoutSchain.data;
1621
+ const payloadWithoutSchain = extractPayload(requestWithoutSchain);
1617
1622
  const GPID = '/19968336/some-adunit-path';
1618
1623
 
1619
- it('request should be made to IX endpoint with GET method', function () {
1620
- expect(requestMethod).to.equal('GET');
1621
- expect(requestUrl).to.equal(IX_SECURE_ENDPOINT);
1624
+ it('request should be made to IX endpoint with POST method and siteId in query param', function () {
1625
+ expect(requestMethod).to.equal('POST');
1626
+ expect(requestUrl).to.equal(IX_SECURE_ENDPOINT + '?s=' + DEFAULT_BANNER_VALID_BID[0].params.siteId);
1627
+ expect(request.option.contentType).to.equal('text/plain')
1622
1628
  });
1623
1629
 
1624
1630
  it('auction type should be set correctly', function () {
1625
- const at = JSON.parse(query.r).at;
1631
+ const at = payloadData.at;
1626
1632
  expect(at).to.equal(1);
1627
1633
  })
1628
1634
 
1629
- it('query object (version, siteID and request) should be correct', function () {
1630
- expect(query.v).to.equal(BANNER_ENDPOINT_VERSION);
1631
- expect(query.s).to.equal(DEFAULT_BANNER_VALID_BID[0].params.siteId);
1632
- expect(query.r).to.exist;
1633
- expect(query.ac).to.equal('j');
1634
- expect(query.sd).to.equal(1);
1635
- expect(query.nf).not.to.exist;
1636
- });
1637
-
1638
1635
  it('should send dfp_adunit_code in request if ortb2Imp.ext.data.adserver.adslot exists', function () {
1639
1636
  const AD_UNIT_CODE = '/19968336/some-adunit-path';
1640
1637
  const validBids = utils.deepClone(DEFAULT_BANNER_VALID_BID);
@@ -1649,7 +1646,7 @@ describe('IndexexchangeAdapter', function () {
1649
1646
  }
1650
1647
  };
1651
1648
  const requests = spec.buildRequests(validBids, DEFAULT_OPTION);
1652
- const { ext: { dfp_ad_unit_code } } = JSON.parse(requests[0].data.r).imp[0];
1649
+ const { ext: { dfp_ad_unit_code } } = extractPayload(requests[0]).imp[0];
1653
1650
  expect(dfp_ad_unit_code).to.equal(AD_UNIT_CODE);
1654
1651
  });
1655
1652
 
@@ -1661,7 +1658,7 @@ describe('IndexexchangeAdapter', function () {
1661
1658
  }
1662
1659
  };
1663
1660
  const requests = spec.buildRequests(validBids, DEFAULT_OPTION);
1664
- const { ext: { gpid } } = JSON.parse(requests[0].data.r).imp[0];
1661
+ const { ext: { gpid } } = extractPayload(requests[0]).imp[0];
1665
1662
  expect(gpid).to.equal(GPID);
1666
1663
  });
1667
1664
 
@@ -1673,7 +1670,7 @@ describe('IndexexchangeAdapter', function () {
1673
1670
  }
1674
1671
  };
1675
1672
  const requests = spec.buildRequests(validBids, DEFAULT_OPTION);
1676
- const { ext: { gpid } } = JSON.parse(requests[0].data.r).imp[0];
1673
+ const { ext: { gpid } } = extractPayload(requests[0]).imp[0];
1677
1674
  expect(gpid).to.equal(GPID);
1678
1675
  });
1679
1676
 
@@ -1686,7 +1683,7 @@ describe('IndexexchangeAdapter', function () {
1686
1683
  }
1687
1684
  };
1688
1685
  const requests = spec.buildRequests(validBids, DEFAULT_OPTION);
1689
- const imp = JSON.parse(requests[0].data.r).imp[0];
1686
+ const imp = extractPayload(requests[0]).imp[0];
1690
1687
  expect(deepAccess(imp, 'ext.dfp_ad_unit_code')).to.not.exist;
1691
1688
  });
1692
1689
 
@@ -1704,7 +1701,7 @@ describe('IndexexchangeAdapter', function () {
1704
1701
  }
1705
1702
  };
1706
1703
  const requests = spec.buildRequests(validBids, DEFAULT_OPTION);
1707
- const imp = JSON.parse(requests[0].data.r).imp[0];
1704
+ const imp = extractPayload(requests[0]).imp[0];
1708
1705
  expect(deepAccess(imp, 'ext.gpid')).to.not.exist;
1709
1706
  });
1710
1707
 
@@ -1724,13 +1721,13 @@ describe('IndexexchangeAdapter', function () {
1724
1721
  }
1725
1722
  };
1726
1723
  const requests = spec.buildRequests(validBids, DEFAULT_OPTION);
1727
- const imp = JSON.parse(requests[0].data.r).imp[0];
1724
+ const imp = extractPayload(requests[0]).imp[0];
1728
1725
  expect(deepAccess(imp, 'ext.gpid')).to.equal(GPID);
1729
1726
  expect(deepAccess(imp, 'ext.dfp_ad_unit_code')).to.equal(AD_UNIT_CODE);
1730
1727
  });
1731
1728
 
1732
1729
  it('payload should have correct format and value', function () {
1733
- const payload = JSON.parse(query.r);
1730
+ const payload = payloadData;
1734
1731
  expect(payload.id).to.equal(DEFAULT_BANNER_VALID_BID[0].bidderRequestId);
1735
1732
  expect(payload.id).to.be.a('string');
1736
1733
  expect(payload.site.page).to.equal(DEFAULT_OPTION.refererInfo.page);
@@ -1748,7 +1745,7 @@ describe('IndexexchangeAdapter', function () {
1748
1745
 
1749
1746
  request = spec.buildRequests(bidWithIntId, DEFAULT_OPTION)[0];
1750
1747
 
1751
- const payload = JSON.parse(request.data.r);
1748
+ const payload = extractPayload(request);
1752
1749
  expect(bidWithIntId[0].bidderRequestId).to.be.a('number');
1753
1750
  expect(payload.id).to.equal(bidWithIntId[0].bidderRequestId.toString());
1754
1751
  expect(payload.id).to.be.a('string');
@@ -1760,19 +1757,21 @@ describe('IndexexchangeAdapter', function () {
1760
1757
 
1761
1758
  request = spec.buildRequests(bidWithIntId, DEFAULT_OPTION)[0];
1762
1759
 
1763
- const payload = JSON.parse(request.data.r);
1760
+ const payload = extractPayload(request);
1764
1761
  expect(bidWithIntId[0].bidderRequestId).to.be.a('number');
1765
1762
  expect(payload.id).to.equal(bidWithIntId[0].bidderRequestId.toString());
1766
1763
  expect(payload.id).to.be.a('string');
1767
1764
  });
1768
1765
 
1769
1766
  it('payload should not include schain when not provided', function () {
1770
- const payload = JSON.parse(queryWithoutSchain.r);
1771
- expect(payload.source.schain).to.not.exist; // source object currently only written for schain
1767
+ const payload = payloadWithoutSchain;
1768
+
1769
+ const actualSchain = (((payload || {}).source || {}).ext || {}).schain;
1770
+ expect(actualSchain).to.not.exist;
1772
1771
  });
1773
1772
 
1774
1773
  it('impression should have correct format and value', function () {
1775
- const impression = JSON.parse(query.r).imp[0];
1774
+ const impression = payloadData.imp[0];
1776
1775
  const sidValue = DEFAULT_BANNER_VALID_BID[0].params.id;
1777
1776
 
1778
1777
  expect(impression.id).to.equal(DEFAULT_BANNER_VALID_BID[0].bidId);
@@ -1797,7 +1796,7 @@ describe('IndexexchangeAdapter', function () {
1797
1796
 
1798
1797
  request = spec.buildRequests([bid], DEFAULT_OPTION)[0];
1799
1798
 
1800
- const payload = JSON.parse(request.data.r);
1799
+ const payload = extractPayload(request);
1801
1800
  payload.imp[0].banner.format.forEach((imp) => {
1802
1801
  expect(imp.ext.siteID).to.be.a('string');
1803
1802
  });
@@ -1813,7 +1812,7 @@ describe('IndexexchangeAdapter', function () {
1813
1812
  const expectedFloor = 3.25;
1814
1813
  bid.getFloor = () => ({ floor: expectedFloor, currency });
1815
1814
  const request = spec.buildRequests([bid], {})[0];
1816
- const impression = JSON.parse(request.data.r).imp[0];
1815
+ const impression = extractPayload(request).imp[0];
1817
1816
 
1818
1817
  expect(impression.bidfloor).to.equal(expectedFloor);
1819
1818
  expect(impression.bidfloorcur).to.equal(currency);
@@ -1825,7 +1824,7 @@ describe('IndexexchangeAdapter', function () {
1825
1824
  const expectedFloor = 3.25;
1826
1825
  bid.getFloor = () => ({ floor: expectedFloor, currency });
1827
1826
  const request = spec.buildRequests([bid], {})[0];
1828
- const impression = JSON.parse(request.data.r).imp[0];
1827
+ const impression = extractPayload(request).imp[0];
1829
1828
 
1830
1829
  expect(impression.bidfloor).to.equal(expectedFloor);
1831
1830
  expect(impression.bidfloorcur).to.equal(currency);
@@ -1837,7 +1836,7 @@ describe('IndexexchangeAdapter', function () {
1837
1836
  bid.params.bidFloor = highFloor;
1838
1837
  bid.params.bidFloorCur = 'USD'
1839
1838
  const request = spec.buildRequests([bid], {})[0];
1840
- const impression = JSON.parse(request.data.r).imp[0];
1839
+ const impression = extractPayload(request).imp[0];
1841
1840
 
1842
1841
  expect(impression.bidfloor).to.equal(highFloor);
1843
1842
  expect(impression.bidfloorcur).to.equal(bid.params.bidFloorCur);
@@ -1851,7 +1850,7 @@ describe('IndexexchangeAdapter', function () {
1851
1850
  const expectedFloor = highFloor;
1852
1851
  bid.getFloor = () => ({ floor: expectedFloor, currency });
1853
1852
  const requestBidFloor = spec.buildRequests([bid], {})[0];
1854
- const impression = JSON.parse(requestBidFloor.data.r).imp[0];
1853
+ const impression = extractPayload(requestBidFloor).imp[0];
1855
1854
 
1856
1855
  expect(impression.bidfloor).to.equal(highFloor);
1857
1856
  expect(impression.bidfloorcur).to.equal(bid.params.bidFloorCur);
@@ -1863,7 +1862,7 @@ describe('IndexexchangeAdapter', function () {
1863
1862
  bid.params.bidFloor = 50;
1864
1863
  bid.params.bidFloorCur = 'USD';
1865
1864
  const requestBidFloor = spec.buildRequests([bid], {})[0];
1866
- const impression = JSON.parse(requestBidFloor.data.r).imp[0];
1865
+ const impression = extractPayload(requestBidFloor).imp[0];
1867
1866
 
1868
1867
  expect(impression.bidfloor).to.equal(bid.params.bidFloor);
1869
1868
  expect(impression.bidfloorcur).to.equal(bid.params.bidFloorCur);
@@ -1875,7 +1874,7 @@ describe('IndexexchangeAdapter', function () {
1875
1874
  bid.params.bidFloor = 50;
1876
1875
  bid.params.bidFloorCur = 'USD';
1877
1876
  const requestBidFloor = spec.buildRequests([bid], {})[0];
1878
- const impression = JSON.parse(requestBidFloor.data.r).imp[0];
1877
+ const impression = extractPayload(requestBidFloor).imp[0];
1879
1878
 
1880
1879
  expect(impression.bidfloor).to.equal(bid.params.bidFloor);
1881
1880
  expect(impression.bidfloorcur).to.equal(bid.params.bidFloorCur);
@@ -1900,7 +1899,7 @@ describe('IndexexchangeAdapter', function () {
1900
1899
  expect(bid.getFloor.getCall(1).args[0].size[0]).to.equal(500);
1901
1900
  expect(bid.getFloor.getCall(1).args[0].size[1]).to.equal(400);
1902
1901
 
1903
- const impression = JSON.parse(requestBidFloor.data.r).imp[0];
1902
+ const impression = extractPayload(requestBidFloor).imp[0];
1904
1903
  expect(impression.bidfloor).to.equal(expectedFloor);
1905
1904
  expect(impression.bidfloorcur).to.equal(currency);
1906
1905
  });
@@ -1930,7 +1929,7 @@ describe('IndexexchangeAdapter', function () {
1930
1929
  expect(bid.getFloor.getCall(0).args[0].size[0]).to.equal(300);
1931
1930
  expect(bid.getFloor.getCall(0).args[0].size[1]).to.equal(250);
1932
1931
 
1933
- const impression = JSON.parse(requestBidFloor.data.r).imp[0];
1932
+ const impression = extractPayload(requestBidFloor).imp[0];
1934
1933
  expect(impression.bidfloor).to.equal(expectedFloor);
1935
1934
  expect(impression.bidfloorcur).to.equal(currency);
1936
1935
  });
@@ -1940,7 +1939,7 @@ describe('IndexexchangeAdapter', function () {
1940
1939
  const bid = utils.deepClone(DEFAULT_BANNER_VALID_BID[0]);
1941
1940
  bid.params.id = 50;
1942
1941
  const requestBidFloor = spec.buildRequests([bid], {})[0];
1943
- const impression = JSON.parse(requestBidFloor.data.r).imp[0];
1942
+ const impression = extractPayload(requestBidFloor).imp[0];
1944
1943
 
1945
1944
  expect(impression.id).to.equal(DEFAULT_BANNER_VALID_BID[0].bidId);
1946
1945
  expect(impression.banner.format[0].w).to.equal(DEFAULT_BANNER_VALID_BID[0].params.size[0]);
@@ -1954,7 +1953,7 @@ describe('IndexexchangeAdapter', function () {
1954
1953
  const bid = utils.deepClone(DEFAULT_BANNER_VALID_BID[0]);
1955
1954
  bid.params.id = 'abc';
1956
1955
  const requestBidFloor = spec.buildRequests([bid], {})[0];
1957
- const impression = JSON.parse(requestBidFloor.data.r).imp[0];
1956
+ const impression = extractPayload(requestBidFloor).imp[0];
1958
1957
 
1959
1958
  expect(impression.id).to.equal(DEFAULT_BANNER_VALID_BID[0].bidId);
1960
1959
  expect(impression.banner.format[0].w).to.equal(DEFAULT_BANNER_VALID_BID[0].params.size[0]);
@@ -1982,7 +1981,7 @@ describe('IndexexchangeAdapter', function () {
1982
1981
  });
1983
1982
 
1984
1983
  const requestWithFirstPartyData = spec.buildRequests(DEFAULT_BANNER_VALID_BID, DEFAULT_OPTION)[0];
1985
- const pageUrl = JSON.parse(requestWithFirstPartyData.data.r).site.page;
1984
+ const pageUrl = extractPayload(requestWithFirstPartyData).site.page;
1986
1985
  const expectedPageUrl = DEFAULT_OPTION.refererInfo.page + '?ab=123&cd=123%23ab&e%2Ff=456&h%3Fg=456%23cd';
1987
1986
  expect(pageUrl).to.equal(expectedPageUrl);
1988
1987
  });
@@ -1995,7 +1994,7 @@ describe('IndexexchangeAdapter', function () {
1995
1994
  });
1996
1995
 
1997
1996
  const requestFirstPartyDataNumber = spec.buildRequests(DEFAULT_BANNER_VALID_BID, DEFAULT_OPTION)[0];
1998
- const pageUrl = JSON.parse(requestFirstPartyDataNumber.data.r).site.page;
1997
+ const pageUrl = extractPayload(requestFirstPartyDataNumber).site.page;
1999
1998
 
2000
1999
  expect(pageUrl).to.equal(DEFAULT_OPTION.refererInfo.page);
2001
2000
  });
@@ -2006,7 +2005,7 @@ describe('IndexexchangeAdapter', function () {
2006
2005
  });
2007
2006
 
2008
2007
  const requestWithoutConfig = spec.buildRequests(DEFAULT_BANNER_VALID_BID, DEFAULT_OPTION)[0];
2009
- const pageUrl = JSON.parse(requestWithoutConfig.data.r).site.page;
2008
+ const pageUrl = extractPayload(requestWithoutConfig).site.page;
2010
2009
 
2011
2010
  expect(pageUrl).to.equal(DEFAULT_OPTION.refererInfo.page);
2012
2011
  expect(requestWithoutConfig.data.t).to.be.undefined;
@@ -2014,13 +2013,13 @@ describe('IndexexchangeAdapter', function () {
2014
2013
 
2015
2014
  it('should not set first party or timeout if it is setConfig is not called', function () {
2016
2015
  const requestWithoutConfig = spec.buildRequests(DEFAULT_BANNER_VALID_BID, DEFAULT_OPTION)[0];
2017
- const pageUrl = JSON.parse(requestWithoutConfig.data.r).site.page;
2016
+ const pageUrl = extractPayload(requestWithoutConfig).site.page;
2018
2017
 
2019
2018
  expect(pageUrl).to.equal(DEFAULT_OPTION.refererInfo.page);
2020
2019
  expect(requestWithoutConfig.data.t).to.be.undefined;
2021
2020
  });
2022
2021
 
2023
- it('should set timeout if publisher set it through setConfig', function () {
2022
+ it('should no longer set timeout even if publisher set it through setConfig', function () {
2024
2023
  config.setConfig({
2025
2024
  ix: {
2026
2025
  timeout: 500
@@ -2028,10 +2027,10 @@ describe('IndexexchangeAdapter', function () {
2028
2027
  });
2029
2028
  const requestWithTimeout = spec.buildRequests(DEFAULT_BANNER_VALID_BID, {})[0];
2030
2029
 
2031
- expect(requestWithTimeout.data.t).to.equal(500);
2030
+ expect(requestWithTimeout.data.t).to.be.undefined;
2032
2031
  });
2033
2032
 
2034
- it('should set timeout if timeout is a string', function () {
2033
+ it('should no longer set timeout even if timeout is a string', function () {
2035
2034
  config.setConfig({
2036
2035
  ix: {
2037
2036
  timeout: '500'
@@ -2046,11 +2045,10 @@ describe('IndexexchangeAdapter', function () {
2046
2045
  describe('request should contain both banner and video requests', function () {
2047
2046
  const request = spec.buildRequests([DEFAULT_BANNER_VALID_BID[0], DEFAULT_VIDEO_VALID_BID[0]], {});
2048
2047
  it('should have banner request', () => {
2049
- const bannerImpression = JSON.parse(request[0].data.r).imp[0];
2048
+ const bannerImpression = extractPayload(request[0]).imp[0];
2050
2049
  const sidValue = DEFAULT_BANNER_VALID_BID[0].params.id;
2051
2050
 
2052
- expect(JSON.parse(request[0].data.r).imp).to.have.lengthOf(1);
2053
- expect(JSON.parse(request[0].data.v)).to.equal(BANNER_ENDPOINT_VERSION);
2051
+ expect(extractPayload(request[0]).imp).to.have.lengthOf(1);
2054
2052
  expect(bannerImpression.id).to.equal(DEFAULT_BANNER_VALID_BID[0].bidId);
2055
2053
 
2056
2054
  expect(bannerImpression.banner.format).to.be.length(2);
@@ -2067,9 +2065,8 @@ describe('IndexexchangeAdapter', function () {
2067
2065
  });
2068
2066
 
2069
2067
  it('should have video request', () => {
2070
- const videoImpression = JSON.parse(request[1].data.r).imp[0];
2068
+ const videoImpression = extractPayload(request[1]).imp[0];
2071
2069
 
2072
- expect(JSON.parse(request[1].data.v)).to.equal(VIDEO_ENDPOINT_VERSION);
2073
2070
  expect(videoImpression.id).to.equal(DEFAULT_VIDEO_VALID_BID[0].bidId);
2074
2071
  expect(videoImpression.video.w).to.equal(DEFAULT_VIDEO_VALID_BID[0].params.size[0]);
2075
2072
  expect(videoImpression.video.h).to.equal(DEFAULT_VIDEO_VALID_BID[0].params.size[1]);
@@ -2080,11 +2077,10 @@ describe('IndexexchangeAdapter', function () {
2080
2077
  const request = spec.buildRequests([DEFAULT_BANNER_VALID_BID[0], DEFAULT_NATIVE_VALID_BID[0]]);
2081
2078
 
2082
2079
  it('should have banner request', () => {
2083
- const bannerImpression = JSON.parse(request[0].data.r).imp[0];
2080
+ const bannerImpression = extractPayload(request[0]).imp[0];
2084
2081
  const sidValue = DEFAULT_BANNER_VALID_BID[0].params.id;
2085
2082
 
2086
- expect(JSON.parse(request[0].data.r).imp).to.have.lengthOf(1);
2087
- expect(JSON.parse(request[0].data.v)).to.equal(BANNER_ENDPOINT_VERSION);
2083
+ expect(extractPayload(request[0]).imp).to.have.lengthOf(1);
2088
2084
  expect(bannerImpression.id).to.equal(DEFAULT_BANNER_VALID_BID[0].bidId);
2089
2085
 
2090
2086
  expect(bannerImpression.banner.format).to.be.length(2);
@@ -2101,7 +2097,7 @@ describe('IndexexchangeAdapter', function () {
2101
2097
  });
2102
2098
 
2103
2099
  it('should have native request', () => {
2104
- const nativeImpression = JSON.parse(request[1].data.r).imp[0];
2100
+ const nativeImpression = extractPayload(request[1]).imp[0];
2105
2101
 
2106
2102
  expect(request[1].data.hasOwnProperty('v')).to.equal(false);
2107
2103
  expect(nativeImpression.id).to.equal(DEFAULT_NATIVE_VALID_BID[0].bidId);
@@ -2133,8 +2129,6 @@ describe('IndexexchangeAdapter', function () {
2133
2129
  const requests = spec.buildRequests([bid, DEFAULT_BANNER_VALID_BID[0]], DEFAULT_OPTION);
2134
2130
  expect(requests).to.be.an('array');
2135
2131
  expect(requests).to.have.lengthOf(2);
2136
- expect(requests[0].data.sn).to.be.equal(0);
2137
- expect(requests[1].data.sn).to.be.equal(1);
2138
2132
  });
2139
2133
 
2140
2134
  it('6 ad units should generate only 4 requests', function () {
@@ -2168,10 +2162,7 @@ describe('IndexexchangeAdapter', function () {
2168
2162
  for (var i = 0; i < requests.length; i++) {
2169
2163
  const reqSize = `${requests[i].url}?${utils.parseQueryStringParameters(requests[i].data)}`.length;
2170
2164
  expect(reqSize).to.be.lessThan(8000);
2171
- let payload = JSON.parse(requests[i].data.r);
2172
- if (requests.length > 1) {
2173
- expect(requests[i].data.sn).to.equal(i);
2174
- }
2165
+ let payload = extractPayload(requests[i]);
2175
2166
  expect(payload.source.ext.schain).to.deep.equal(SAMPLE_SCHAIN);
2176
2167
  }
2177
2168
  });
@@ -2196,7 +2187,7 @@ describe('IndexexchangeAdapter', function () {
2196
2187
  expect(requests).to.be.an('array');
2197
2188
  expect(requests).to.have.lengthOf(1);
2198
2189
 
2199
- const impressions = JSON.parse(requests[0].data.r).imp;
2190
+ const impressions = extractPayload(requests[0]).imp;
2200
2191
  expect(impressions).to.be.an('array');
2201
2192
  expect(impressions).to.have.lengthOf(3);
2202
2193
  expect(requests[0].data.sn).to.be.undefined;
@@ -2212,7 +2203,7 @@ describe('IndexexchangeAdapter', function () {
2212
2203
  bid2.params.bidId = '2b3c4d5e';
2213
2204
 
2214
2205
  const request = spec.buildRequests([bid, bid2], DEFAULT_OPTION)[0];
2215
- const impression = JSON.parse(request.data.r).imp[0];
2206
+ const impression = extractPayload(request).imp[0];
2216
2207
  const sidValue = bid.params.id;
2217
2208
 
2218
2209
  expect(impression.id).to.equal(bid.bidId);
@@ -2242,7 +2233,7 @@ describe('IndexexchangeAdapter', function () {
2242
2233
  const bids = [DEFAULT_BANNER_VALID_BID[0], bid];
2243
2234
  const request = spec.buildRequests(bids, DEFAULT_OPTION)[0];
2244
2235
 
2245
- const impressions = JSON.parse(request.data.r).imp;
2236
+ const impressions = extractPayload(request).imp;
2246
2237
  expect(impressions).to.be.an('array');
2247
2238
  expect(impressions).to.have.lengthOf(2);
2248
2239
  expect(request.data.sn).to.be.undefined;
@@ -2267,7 +2258,7 @@ describe('IndexexchangeAdapter', function () {
2267
2258
 
2268
2259
  it('request should not contain the extra video ad sizes that IX is not configured for', function () {
2269
2260
  const request = spec.buildRequests(DEFAULT_VIDEO_VALID_BID, DEFAULT_OPTION);
2270
- const impressions = JSON.parse(request[0].data.r).imp;
2261
+ const impressions = extractPayload(request[0]).imp;
2271
2262
 
2272
2263
  expect(impressions).to.be.an('array');
2273
2264
  expect(impressions).to.have.lengthOf(1);
@@ -2280,7 +2271,7 @@ describe('IndexexchangeAdapter', function () {
2280
2271
 
2281
2272
  const requests = spec.buildRequests([bid1, DEFAULT_BANNER_VALID_BID[0]], DEFAULT_OPTION);
2282
2273
 
2283
- const impressions = JSON.parse(requests[0].data.r).imp;
2274
+ const impressions = extractPayload(requests[0]).imp;
2284
2275
 
2285
2276
  expect(impressions).to.be.an('array');
2286
2277
  expect(impressions).to.have.lengthOf(1);
@@ -2290,24 +2281,15 @@ describe('IndexexchangeAdapter', function () {
2290
2281
 
2291
2282
  describe('buildRequestVideo', function () {
2292
2283
  const request = spec.buildRequests(DEFAULT_VIDEO_VALID_BID, DEFAULT_OPTION);
2293
- const query = request[0].data;
2294
-
2295
- it('query object (version, siteID and request) should be correct', function () {
2296
- expect(query.v).to.equal(VIDEO_ENDPOINT_VERSION);
2297
- expect(query.s).to.equal(DEFAULT_VIDEO_VALID_BID[0].params.siteId);
2298
- expect(query.r).to.exist;
2299
- expect(query.ac).to.equal('j');
2300
- expect(query.sd).to.equal(1);
2301
- expect(query.nf).to.equal(1);
2302
- });
2284
+ const payloadData = request[0].data;
2303
2285
 
2304
2286
  it('auction type should be set correctly', function () {
2305
- const at = JSON.parse(query.r).at;
2287
+ const at = payloadData.at;
2306
2288
  expect(at).to.equal(1);
2307
2289
  })
2308
2290
 
2309
2291
  it('impression should have correct format and value', function () {
2310
- const impression = JSON.parse(query.r).imp[0];
2292
+ const impression = payloadData.imp[0];
2311
2293
 
2312
2294
  expect(impression.id).to.equal(DEFAULT_VIDEO_VALID_BID[0].bidId);
2313
2295
  expect(impression.video.w).to.equal(DEFAULT_VIDEO_VALID_BID[0].params.size[0]);
@@ -2326,7 +2308,7 @@ describe('IndexexchangeAdapter', function () {
2326
2308
  bid.mediaTypes.video.context = 'outstream';
2327
2309
  bid.mediaTypes.video.placement = 2;
2328
2310
  const request = spec.buildRequests([bid], {})[0];
2329
- const impression = JSON.parse(request.data.r).imp[0];
2311
+ const impression = extractPayload(request).imp[0];
2330
2312
 
2331
2313
  expect(impression.id).to.equal(DEFAULT_VIDEO_VALID_BID[0].bidId);
2332
2314
  expect(impression.video.placement).to.equal(2);
@@ -2336,7 +2318,7 @@ describe('IndexexchangeAdapter', function () {
2336
2318
  const bid = utils.deepClone(DEFAULT_VIDEO_VALID_BID[0]);
2337
2319
  bid.params.id = 50;
2338
2320
  const request = spec.buildRequests([bid], {})[0];
2339
- const impression = JSON.parse(request.data.r).imp[0];
2321
+ const impression = extractPayload(request).imp[0];
2340
2322
 
2341
2323
  expect(impression.ext.sid).to.equal('50');
2342
2324
  });
@@ -2345,7 +2327,7 @@ describe('IndexexchangeAdapter', function () {
2345
2327
  const bid = utils.deepClone(DEFAULT_VIDEO_VALID_BID[0]);
2346
2328
  bid.mediaTypes.video.context = 'instream';
2347
2329
  const request = spec.buildRequests([bid], {})[0];
2348
- const impression = JSON.parse(request.data.r).imp[0];
2330
+ const impression = extractPayload(request).imp[0];
2349
2331
 
2350
2332
  expect(impression.id).to.equal(DEFAULT_VIDEO_VALID_BID[0].bidId);
2351
2333
  expect(impression.video.placement).to.equal(1);
@@ -2355,7 +2337,7 @@ describe('IndexexchangeAdapter', function () {
2355
2337
  const bid = utils.deepClone(DEFAULT_VIDEO_VALID_BID[0]);
2356
2338
  bid.mediaTypes.video.context = 'outstream';
2357
2339
  const request = spec.buildRequests([bid], {})[0];
2358
- const impression = JSON.parse(request.data.r).imp[0];
2340
+ const impression = extractPayload(request).imp[0];
2359
2341
 
2360
2342
  expect(impression.id).to.equal(DEFAULT_VIDEO_VALID_BID[0].bidId);
2361
2343
  expect(impression.video.placement).to.equal(4);
@@ -2365,7 +2347,7 @@ describe('IndexexchangeAdapter', function () {
2365
2347
  const bid = utils.deepClone(DEFAULT_VIDEO_VALID_BID[0]);
2366
2348
  bid.mediaTypes.video.context = 'not-valid';
2367
2349
  const request = spec.buildRequests([bid], {})[0];
2368
- const impression = JSON.parse(request.data.r).imp[0];
2350
+ const impression = extractPayload(request).imp[0];
2369
2351
  expect(impression.video.placement).to.be.undefined;
2370
2352
  });
2371
2353
 
@@ -2375,7 +2357,7 @@ describe('IndexexchangeAdapter', function () {
2375
2357
  bid.mediaTypes.video.protocols = [1];
2376
2358
  bid.mediaTypes.video.mimes = ['video/override'];
2377
2359
  const request = spec.buildRequests([bid], {})[0];
2378
- const impression = JSON.parse(request.data.r).imp[0];
2360
+ const impression = extractPayload(request).imp[0];
2379
2361
 
2380
2362
  expect(impression.video.protocols[0]).to.equal(2);
2381
2363
  expect(impression.video.mimes[0]).to.not.equal('video/override');
@@ -2386,7 +2368,7 @@ describe('IndexexchangeAdapter', function () {
2386
2368
  bid.mediaTypes.video.context = 'outstream';
2387
2369
  bid.mediaTypes.video.random = true;
2388
2370
  const request = spec.buildRequests([bid], {})[0];
2389
- const impression = JSON.parse(request.data.r).imp[0];
2371
+ const impression = extractPayload(request).imp[0];
2390
2372
 
2391
2373
  expect(impression.video.random).to.not.exist;
2392
2374
  });
@@ -2401,7 +2383,7 @@ describe('IndexexchangeAdapter', function () {
2401
2383
  bid.mediaTypes.video.api = 2;
2402
2384
  bid.mediaTypes.video.pos = 0;
2403
2385
  const request = spec.buildRequests([bid], {})[0];
2404
- const impression = JSON.parse(request.data.r).imp[0];
2386
+ const impression = extractPayload(request).imp[0];
2405
2387
 
2406
2388
  expect(impression.video.protocols[0]).to.equal(6);
2407
2389
  expect(impression.video.api).to.equal(2);
@@ -2418,15 +2400,14 @@ describe('IndexexchangeAdapter', function () {
2418
2400
  }
2419
2401
  };
2420
2402
  const requests = spec.buildRequests(validBids, DEFAULT_OPTION);
2421
- const { ext: { gpid } } = JSON.parse(requests[0].data.r).imp[0];
2403
+ const { ext: { gpid } } = extractPayload(requests[0]).imp[0];
2422
2404
  expect(gpid).to.equal(GPID);
2423
2405
  });
2424
2406
 
2425
2407
  it('should build video request when if video obj is not provided at params level', () => {
2426
2408
  const request = spec.buildRequests([DEFAULT_VIDEO_VALID_BID_NO_VIDEO_PARAMS[0]], {});
2427
- const videoImpression = JSON.parse(request[0].data.r).imp[0];
2409
+ const videoImpression = extractPayload(request[0]).imp[0];
2428
2410
 
2429
- expect(JSON.parse(request[0].data.v)).to.equal(VIDEO_ENDPOINT_VERSION);
2430
2411
  expect(videoImpression.id).to.equal(DEFAULT_VIDEO_VALID_BID_NO_VIDEO_PARAMS[0].bidId);
2431
2412
  expect(videoImpression.video.w).to.equal(DEFAULT_VIDEO_VALID_BID_NO_VIDEO_PARAMS[0].mediaTypes.video.playerSize[0][0]);
2432
2413
  expect(videoImpression.video.h).to.equal(DEFAULT_VIDEO_VALID_BID_NO_VIDEO_PARAMS[0].mediaTypes.video.playerSize[0][1]);
@@ -2440,23 +2421,18 @@ describe('IndexexchangeAdapter', function () {
2440
2421
  };
2441
2422
 
2442
2423
  const request = spec.buildRequests([bid]);
2443
- const videoImpression = JSON.parse(request[0].data.r).imp[0];
2424
+ const videoImpression = extractPayload(request[0]).imp[0];
2444
2425
 
2445
2426
  expect(videoImpression.video.placement).to.eq(5);
2446
2427
  })
2447
2428
  });
2448
2429
 
2449
2430
  describe('buildRequestNative', function () {
2450
- it('should build request with expected params', function() {
2451
- const request = spec.buildRequests(DEFAULT_NATIVE_VALID_BID, DEFAULT_OPTION);
2452
- const query = request[0].data;
2431
+ it('should build request with expected params', function () {
2432
+ const request = spec.buildRequests(DEFAULT_NATIVE_VALID_BID, DEFAULT_OPTION)[0];
2453
2433
 
2454
- expect(query.hasOwnProperty('v')).to.equal(false);
2455
- expect(query.s).to.equal(DEFAULT_NATIVE_VALID_BID[0].params.siteId);
2456
- expect(query.r).to.exist;
2457
- expect(query.ac).to.equal('j');
2458
- expect(query.sd).to.equal(1);
2459
- expect(JSON.parse(query.r).at).to.equal(1);
2434
+ expect(request.data).to.exist;
2435
+ expect(request.method).to.equal('POST')
2460
2436
  });
2461
2437
 
2462
2438
  it('should send gpid in request if ortb2Imp.ext.gpid exists', function () {
@@ -2468,40 +2444,40 @@ describe('IndexexchangeAdapter', function () {
2468
2444
  }
2469
2445
  };
2470
2446
  const requests = spec.buildRequests(bids, DEFAULT_OPTION);
2471
- const { ext: { gpid } } = JSON.parse(requests[0].data.r).imp[0];
2447
+ const { ext: { gpid } } = extractPayload(requests[0]).imp[0];
2472
2448
  expect(gpid).to.equal(GPID);
2473
2449
  });
2474
2450
 
2475
- it('should build request with required asset properties with default values', function() {
2451
+ it('should build request with required asset properties with default values', function () {
2476
2452
  const request = spec.buildRequests(DEFAULT_NATIVE_VALID_BID, DEFAULT_OPTION);
2477
- const nativeImpression = JSON.parse(request[0].data.r).imp[0];
2453
+ const nativeImpression = extractPayload(request[0]).imp[0];
2478
2454
 
2479
2455
  expect(request[0].data.hasOwnProperty('v')).to.equal(false);
2480
2456
  expect(nativeImpression.id).to.equal(DEFAULT_NATIVE_VALID_BID[0].bidId);
2481
2457
  expect(nativeImpression.native).to.deep.equal(DEFAULT_NATIVE_IMP);
2482
2458
  });
2483
2459
 
2484
- it('should set imp.ext.sid for native imps if params.id exist', function() {
2460
+ it('should set imp.ext.sid for native imps if params.id exist', function () {
2485
2461
  const bid = utils.deepClone(DEFAULT_NATIVE_VALID_BID);
2486
2462
  bid[0].params.id = 'abc'
2487
2463
  const request = spec.buildRequests(bid, DEFAULT_OPTION);
2488
- const nativeImpression = JSON.parse(request[0].data.r).imp[0];
2464
+ const nativeImpression = extractPayload(request[0]).imp[0];
2489
2465
 
2490
2466
  expect(nativeImpression.id).to.equal(DEFAULT_NATIVE_VALID_BID[0].bidId);
2491
2467
  expect(nativeImpression.ext.sid).to.equal('abc');
2492
2468
  });
2493
2469
 
2494
- it('should build request with given asset properties', function() {
2470
+ it('should build request with given asset properties', function () {
2495
2471
  let bid = utils.deepClone(DEFAULT_NATIVE_VALID_BID)
2496
2472
  bid[0].nativeOrtbRequest = {
2497
- assets: [{id: 0, required: 0, title: {len: 140}}, {id: 1, required: 0, video: {mimes: ['javascript'], minduration: 10, maxduration: 60, protocols: [1]}}]
2473
+ assets: [{ id: 0, required: 0, title: { len: 140 } }, { id: 1, required: 0, video: { mimes: ['javascript'], minduration: 10, maxduration: 60, protocols: [1] } }]
2498
2474
  }
2499
2475
  const request = spec.buildRequests(bid, DEFAULT_OPTION);
2500
- const nativeImpression = JSON.parse(request[0].data.r).imp[0];
2501
- expect(nativeImpression.native).to.deep.equal({request: '{"assets":[{"id":0,"required":0,"title":{"len":140}},{"id":1,"required":0,"video":{"mimes":["javascript"],"minduration":10,"maxduration":60,"protocols":[1]}}],"eventtrackers":[{"event":1,"methods":[1,2]}],"privacy":1}', ver: '1.2'});
2476
+ const nativeImpression = extractPayload(request[0]).imp[0];
2477
+ expect(nativeImpression.native).to.deep.equal({ request: '{"assets":[{"id":0,"required":0,"title":{"len":140}},{"id":1,"required":0,"video":{"mimes":["javascript"],"minduration":10,"maxduration":60,"protocols":[1]}}],"eventtrackers":[{"event":1,"methods":[1,2]}],"privacy":1}', ver: '1.2' });
2502
2478
  });
2503
2479
 
2504
- it('should build request with all possible Prebid asset properties', function() {
2480
+ it('should build request with all possible Prebid asset properties', function () {
2505
2481
  let bid = utils.deepClone(DEFAULT_NATIVE_VALID_BID)
2506
2482
  bid[0].nativeOrtbRequest = {
2507
2483
  'ver': '1.2',
@@ -2626,17 +2602,16 @@ describe('IndexexchangeAdapter', function () {
2626
2602
  ]
2627
2603
  }
2628
2604
  const request = spec.buildRequests(bid, DEFAULT_OPTION);
2629
- const nativeImpression = JSON.parse(request[0].data.r).imp[0];
2630
- expect(nativeImpression.native).to.deep.equal({request: '{"ver":"1.2","assets":[{"id":0,"required":0,"title":{"len":140}},{"id":1,"required":0,"data":{"type":2}},{"id":2,"required":0,"data":{"type":10}},{"id":3,"required":0,"data":{"type":1}},{"id":4,"required":0,"img":{"type":1}},{"id":5,"required":0,"img":{"type":3}},{"id":6,"required":0},{"id":7,"required":0,"data":{"type":11}},{"id":8,"required":0},{"id":9,"required":0},{"id":10,"required":0,"data":{"type":12}},{"id":11,"required":0,"data":{"type":3}},{"id":12,"required":0,"data":{"type":5}},{"id":13,"required":0,"data":{"type":4}},{"id":14,"required":0,"data":{"type":6}},{"id":15,"required":0,"data":{"type":7}},{"id":16,"required":0,"data":{"type":9}},{"id":17,"required":0,"data":{"type":8}}],"eventtrackers":[{"event":1,"methods":[1,2]}],"privacy":1}', ver: '1.2'});
2605
+ const nativeImpression = extractPayload(request[0]).imp[0];
2606
+ expect(nativeImpression.native).to.deep.equal({ request: '{"ver":"1.2","assets":[{"id":0,"required":0,"title":{"len":140}},{"id":1,"required":0,"data":{"type":2}},{"id":2,"required":0,"data":{"type":10}},{"id":3,"required":0,"data":{"type":1}},{"id":4,"required":0,"img":{"type":1}},{"id":5,"required":0,"img":{"type":3}},{"id":6,"required":0},{"id":7,"required":0,"data":{"type":11}},{"id":8,"required":0},{"id":9,"required":0},{"id":10,"required":0,"data":{"type":12}},{"id":11,"required":0,"data":{"type":3}},{"id":12,"required":0,"data":{"type":5}},{"id":13,"required":0,"data":{"type":4}},{"id":14,"required":0,"data":{"type":6}},{"id":15,"required":0,"data":{"type":7}},{"id":16,"required":0,"data":{"type":9}},{"id":17,"required":0,"data":{"type":8}}],"eventtrackers":[{"event":1,"methods":[1,2]}],"privacy":1}', ver: '1.2' });
2631
2607
  })
2632
2608
  });
2633
2609
 
2634
2610
  describe('buildRequestMultiFormat', function () {
2635
2611
  it('only banner bidder params set', function () {
2636
2612
  const request = spec.buildRequests(DEFAULT_MULTIFORMAT_BANNER_VALID_BID, {})
2637
- const bannerImpression = JSON.parse(request[0].data.r).imp[0];
2638
- expect(JSON.parse(request[0].data.r).imp).to.have.lengthOf(1);
2639
- expect(JSON.parse(request[0].data.v)).to.equal(BANNER_ENDPOINT_VERSION);
2613
+ const bannerImpression = extractPayload(request[0]).imp[0];
2614
+ expect(extractPayload(request[0]).imp).to.have.lengthOf(1);
2640
2615
  expect(bannerImpression.id).to.equal(DEFAULT_MULTIFORMAT_BANNER_VALID_BID[0].bidId);
2641
2616
  expect(bannerImpression.banner.format[0].w).to.equal(DEFAULT_MULTIFORMAT_BANNER_VALID_BID[0].params.size[0]);
2642
2617
  expect(bannerImpression.banner.format[0].h).to.equal(DEFAULT_MULTIFORMAT_BANNER_VALID_BID[0].params.size[1]);
@@ -2645,9 +2620,8 @@ describe('IndexexchangeAdapter', function () {
2645
2620
  describe('only video bidder params set', function () {
2646
2621
  it('should generate video impression', function () {
2647
2622
  const request = spec.buildRequests(DEFAULT_MULTIFORMAT_VIDEO_VALID_BID, {});
2648
- const videoImp = JSON.parse(request[1].data.r).imp[0];
2649
- expect(JSON.parse(request[1].data.r).imp).to.have.lengthOf(1);
2650
- expect(JSON.parse(request[1].data.v)).to.equal(VIDEO_ENDPOINT_VERSION);
2623
+ const videoImp = extractPayload(request[1]).imp[0];
2624
+ expect(extractPayload(request[1]).imp).to.have.lengthOf(1);
2651
2625
  expect(videoImp.id).to.equal(DEFAULT_MULTIFORMAT_VIDEO_VALID_BID[0].bidId);
2652
2626
  expect(videoImp.video.w).to.equal(DEFAULT_MULTIFORMAT_VIDEO_VALID_BID[0].params.size[0]);
2653
2627
  expect(videoImp.video.h).to.equal(DEFAULT_MULTIFORMAT_VIDEO_VALID_BID[0].params.size[1]);
@@ -2659,10 +2633,9 @@ describe('IndexexchangeAdapter', function () {
2659
2633
  const request = spec.buildRequests(bids, {});
2660
2634
 
2661
2635
  it('should return valid banner requests', function () {
2662
- const impressions = JSON.parse(request[0].data.r).imp;
2636
+ const impressions = extractPayload(request[0]).imp;
2663
2637
 
2664
2638
  expect(impressions).to.have.lengthOf(2);
2665
- expect(JSON.parse(request[0].data.v)).to.equal(BANNER_ENDPOINT_VERSION);
2666
2639
 
2667
2640
  impressions.map((impression, index) => {
2668
2641
  const bid = bids[index];
@@ -2682,17 +2655,16 @@ describe('IndexexchangeAdapter', function () {
2682
2655
  });
2683
2656
 
2684
2657
  it('should return valid banner and video requests', function () {
2685
- const videoImpression = JSON.parse(request[1].data.r).imp[0];
2658
+ const videoImpression = extractPayload(request[1]).imp[0];
2686
2659
 
2687
- expect(JSON.parse(request[1].data.r).imp).to.have.lengthOf(1);
2688
- expect(JSON.parse(request[1].data.v)).to.equal(VIDEO_ENDPOINT_VERSION);
2660
+ expect(extractPayload(request[1]).imp).to.have.lengthOf(1);
2689
2661
  expect(videoImpression.id).to.equal(DEFAULT_MULTIFORMAT_VIDEO_VALID_BID[0].bidId);
2690
2662
  expect(videoImpression.video.w).to.equal(DEFAULT_MULTIFORMAT_VIDEO_VALID_BID[0].mediaTypes.video.playerSize[0][0]);
2691
2663
  expect(videoImpression.video.h).to.equal(DEFAULT_MULTIFORMAT_VIDEO_VALID_BID[0].mediaTypes.video.playerSize[0][1]);
2692
2664
  });
2693
2665
 
2694
2666
  it('should contain all correct IXdiag properties', function () {
2695
- const diagObj = JSON.parse(request[0].data.r).ext.ixdiag;
2667
+ const diagObj = extractPayload(request[0]).ext.ixdiag;
2696
2668
  expect(diagObj.iu).to.equal(0);
2697
2669
  expect(diagObj.nu).to.equal(0);
2698
2670
  expect(diagObj.ou).to.equal(2);
@@ -2709,6 +2681,17 @@ describe('IndexexchangeAdapter', function () {
2709
2681
  });
2710
2682
 
2711
2683
  describe('interpretResponse', function () {
2684
+ // generate bidderRequest with real buildRequest logic for intepretResponse testing
2685
+ let bannerBidderRequest
2686
+ let videoBidderRequest
2687
+ let nativeBidderRequest
2688
+
2689
+ beforeEach(() => {
2690
+ bannerBidderRequest = spec.buildRequests(DEFAULT_BANNER_VALID_BID, {})[0]
2691
+ videoBidderRequest = spec.buildRequests(DEFAULT_VIDEO_VALID_BID_MEDIUM_SIZE, {})[0]
2692
+ nativeBidderRequest = spec.buildRequests(DEFAULT_NATIVE_VALID_BID, {})[0]
2693
+ });
2694
+
2712
2695
  it('should get correct bid response for banner ad', function () {
2713
2696
  const expectedParse = [
2714
2697
  {
@@ -2730,7 +2713,7 @@ describe('IndexexchangeAdapter', function () {
2730
2713
  }
2731
2714
  }
2732
2715
  ];
2733
- const result = spec.interpretResponse({ body: DEFAULT_BANNER_BID_RESPONSE }, { data: DEFAULT_BIDDER_REQUEST_DATA, validBidRequests: [] });
2716
+ const result = spec.interpretResponse({ body: DEFAULT_BANNER_BID_RESPONSE }, bannerBidderRequest);
2734
2717
  expect(result[0]).to.deep.equal(expectedParse[0]);
2735
2718
  });
2736
2719
 
@@ -2754,7 +2737,7 @@ describe('IndexexchangeAdapter', function () {
2754
2737
  }
2755
2738
  }
2756
2739
  ];
2757
- const result = spec.interpretResponse({ body: DEFAULT_BANNER_BID_RESPONSE_WITHOUT_ADOMAIN }, { data: DEFAULT_BIDDER_REQUEST_DATA, validBidRequests: [] });
2740
+ const result = spec.interpretResponse({ body: DEFAULT_BANNER_BID_RESPONSE_WITHOUT_ADOMAIN }, bannerBidderRequest);
2758
2741
  expect(result[0]).to.deep.equal(expectedParse[0]);
2759
2742
  });
2760
2743
 
@@ -2781,7 +2764,7 @@ describe('IndexexchangeAdapter', function () {
2781
2764
  }
2782
2765
  }
2783
2766
  ];
2784
- const result = spec.interpretResponse({ body: bidResponse }, { data: DEFAULT_BIDDER_REQUEST_DATA, validBidRequests: [] });
2767
+ const result = spec.interpretResponse({ body: bidResponse }, bannerBidderRequest);
2785
2768
  });
2786
2769
 
2787
2770
  it('should set Japanese price correctly', function () {
@@ -2807,7 +2790,7 @@ describe('IndexexchangeAdapter', function () {
2807
2790
  }
2808
2791
  }
2809
2792
  ];
2810
- const result = spec.interpretResponse({ body: bidResponse }, { data: DEFAULT_BIDDER_REQUEST_DATA, validBidRequests: [] });
2793
+ const result = spec.interpretResponse({ body: bidResponse }, bannerBidderRequest);
2811
2794
  expect(result[0]).to.deep.equal(expectedParse[0]);
2812
2795
  });
2813
2796
 
@@ -2836,7 +2819,7 @@ describe('IndexexchangeAdapter', function () {
2836
2819
  }
2837
2820
  }
2838
2821
  ];
2839
- const result = spec.interpretResponse({ body: bidResponse }, { data: DEFAULT_BIDDER_REQUEST_DATA, validBidRequests: [] });
2822
+ const result = spec.interpretResponse({ body: bidResponse }, bannerBidderRequest);
2840
2823
 
2841
2824
  expect(result[0].dealId).to.equal(expectedParse[0].dealId);
2842
2825
  });
@@ -2863,7 +2846,7 @@ describe('IndexexchangeAdapter', function () {
2863
2846
  }
2864
2847
  }
2865
2848
  ];
2866
- const result = spec.interpretResponse({ body: bidResponse }, { data: DEFAULT_BIDDER_REQUEST_DATA, validBidRequests: [] });
2849
+ const result = spec.interpretResponse({ body: bidResponse }, bannerBidderRequest);
2867
2850
  expect(result[0]).to.deep.equal(expectedParse[0]);
2868
2851
  });
2869
2852
 
@@ -2891,7 +2874,7 @@ describe('IndexexchangeAdapter', function () {
2891
2874
  }
2892
2875
  }
2893
2876
  ];
2894
- const result = spec.interpretResponse({ body: bidResponse }, { data: DEFAULT_BIDDER_REQUEST_DATA, validBidRequests: [] });
2877
+ const result = spec.interpretResponse({ body: bidResponse }, bannerBidderRequest);
2895
2878
  expect(result[0].dealId).to.deep.equal(expectedParse[0].dealId);
2896
2879
  });
2897
2880
 
@@ -2928,7 +2911,7 @@ describe('IndexexchangeAdapter', function () {
2928
2911
  }
2929
2912
  ];
2930
2913
  const result = spec.interpretResponse({ body: DEFAULT_VIDEO_BID_RESPONSE }, {
2931
- data: DEFAULT_BIDDER_REQUEST_DATA, validBidRequests: ONE_VIDEO
2914
+ data: videoBidderRequest.data, validBidRequests: ONE_VIDEO
2932
2915
  });
2933
2916
 
2934
2917
  expect(result[0]).to.deep.equal(expectedParse[0]);
@@ -2936,14 +2919,14 @@ describe('IndexexchangeAdapter', function () {
2936
2919
 
2937
2920
  it('should set bid[].renderer if renderer not defined at mediaType.video level', function () {
2938
2921
  const bid = spec.interpretResponse({ body: DEFAULT_VIDEO_BID_RESPONSE }, {
2939
- data: DEFAULT_BIDDER_REQUEST_DATA, validBidRequests: DEFAULT_MULTIFORMAT_BANNER_VALID_BID
2922
+ data: videoBidderRequest.data, validBidRequests: DEFAULT_MULTIFORMAT_BANNER_VALID_BID
2940
2923
  });
2941
2924
  expect(bid[0].renderer).to.exist;
2942
2925
  });
2943
2926
 
2944
2927
  it('should set renderer URL by parsing video response', function () {
2945
2928
  const bid = spec.interpretResponse({ body: DEFAULT_VIDEO_BID_RESPONSE }, {
2946
- data: DEFAULT_BIDDER_REQUEST_DATA, validBidRequests: DEFAULT_MULTIFORMAT_BANNER_VALID_BID
2929
+ data: videoBidderRequest.data, validBidRequests: DEFAULT_MULTIFORMAT_BANNER_VALID_BID
2947
2930
  });
2948
2931
  expect(bid[0].renderer.url).to.equal(DEFAULT_VIDEO_BID_RESPONSE.ext.videoplayerurl);
2949
2932
  });
@@ -2952,10 +2935,10 @@ describe('IndexexchangeAdapter', function () {
2952
2935
  let outstreamAdUnit = utils.deepClone(DEFAULT_MULTIFORMAT_BANNER_VALID_BID);
2953
2936
  outstreamAdUnit[0].mediaTypes.video.renderer = {
2954
2937
  url: 'test',
2955
- render: function() {}
2938
+ render: function () { }
2956
2939
  };
2957
2940
  const bid = spec.interpretResponse({ body: DEFAULT_VIDEO_BID_RESPONSE }, {
2958
- data: DEFAULT_BIDDER_REQUEST_DATA, validBidRequests: outstreamAdUnit
2941
+ data: videoBidderRequest.data, validBidRequests: outstreamAdUnit
2959
2942
  });
2960
2943
  expect(bid[0].renderer).to.be.undefined;
2961
2944
  });
@@ -2964,10 +2947,10 @@ describe('IndexexchangeAdapter', function () {
2964
2947
  let outstreamAdUnit = utils.deepClone(DEFAULT_MULTIFORMAT_BANNER_VALID_BID);
2965
2948
  outstreamAdUnit[0].renderer = {
2966
2949
  url: 'test',
2967
- render: function() {}
2950
+ render: function () { }
2968
2951
  };
2969
2952
  const bid = spec.interpretResponse({ body: DEFAULT_VIDEO_BID_RESPONSE }, {
2970
- data: DEFAULT_BIDDER_REQUEST_DATA, validBidRequests: outstreamAdUnit
2953
+ data: videoBidderRequest.data, validBidRequests: outstreamAdUnit
2971
2954
  });
2972
2955
  expect(bid[0].renderer).to.be.undefined;
2973
2956
  });
@@ -2978,7 +2961,7 @@ describe('IndexexchangeAdapter', function () {
2978
2961
  url: 'test'
2979
2962
  };
2980
2963
  const bid = spec.interpretResponse({ body: DEFAULT_VIDEO_BID_RESPONSE }, {
2981
- data: DEFAULT_BIDDER_REQUEST_DATA, validBidRequests: outstreamAdUnit
2964
+ data: videoBidderRequest.data, validBidRequests: outstreamAdUnit
2982
2965
  });
2983
2966
  expect(bid[0].renderer).to.exist;
2984
2967
  });
@@ -2987,11 +2970,11 @@ describe('IndexexchangeAdapter', function () {
2987
2970
  let outstreamAdUnit = utils.deepClone(DEFAULT_MULTIFORMAT_BANNER_VALID_BID);
2988
2971
  outstreamAdUnit[0].mediaTypes.video.renderer = {
2989
2972
  url: 'test',
2990
- render: function() {},
2973
+ render: function () { },
2991
2974
  backupOnly: true
2992
2975
  };
2993
2976
  const bid = spec.interpretResponse({ body: DEFAULT_VIDEO_BID_RESPONSE }, {
2994
- data: DEFAULT_BIDDER_REQUEST_DATA, validBidRequests: outstreamAdUnit
2977
+ data: videoBidderRequest.data, validBidRequests: outstreamAdUnit
2995
2978
  });
2996
2979
  expect(bid[0].renderer).to.exist;
2997
2980
  });
@@ -3029,7 +3012,7 @@ describe('IndexexchangeAdapter', function () {
3029
3012
  }
3030
3013
  ];
3031
3014
  const result = spec.interpretResponse({ body: DEFAULT_VIDEO_BID_RESPONSE_WITH_MTYPE_SET }, {
3032
- data: DEFAULT_BIDDER_REQUEST_DATA, validBidRequests: ONE_VIDEO
3015
+ data: videoBidderRequest.data, validBidRequests: ONE_VIDEO
3033
3016
  });
3034
3017
 
3035
3018
  expect(result[0]).to.deep.equal(expectedParse[0]);
@@ -3038,10 +3021,11 @@ describe('IndexexchangeAdapter', function () {
3038
3021
  it('bidrequest should not have page if options is undefined', function () {
3039
3022
  const options = {};
3040
3023
  const validBidWithoutreferInfo = spec.buildRequests(DEFAULT_BANNER_VALID_BID, options);
3041
- const requestWithoutreferInfo = JSON.parse(validBidWithoutreferInfo[0].data.r);
3024
+ const requestWithoutreferInfo = extractPayload(validBidWithoutreferInfo[0]);
3042
3025
 
3026
+ const expectedURL = IX_SECURE_ENDPOINT + '?s=' + DEFAULT_BANNER_VALID_BID[0].params.siteId
3043
3027
  expect(requestWithoutreferInfo.site.page).to.be.undefined;
3044
- expect(validBidWithoutreferInfo[0].url).to.equal(IX_SECURE_ENDPOINT);
3028
+ expect(validBidWithoutreferInfo[0].url).to.equal(expectedURL);
3045
3029
  });
3046
3030
 
3047
3031
  it('bidrequest should not have page if options.refererInfo is an empty object', function () {
@@ -3049,10 +3033,11 @@ describe('IndexexchangeAdapter', function () {
3049
3033
  refererInfo: {}
3050
3034
  };
3051
3035
  const validBidWithoutreferInfo = spec.buildRequests(DEFAULT_BANNER_VALID_BID, options);
3052
- const requestWithoutreferInfo = JSON.parse(validBidWithoutreferInfo[0].data.r);
3036
+ const requestWithoutreferInfo = extractPayload(validBidWithoutreferInfo[0]);
3053
3037
 
3038
+ const expectedURL = IX_SECURE_ENDPOINT + '?s=' + DEFAULT_BANNER_VALID_BID[0].params.siteId
3054
3039
  expect(requestWithoutreferInfo.site.page).to.be.undefined;
3055
- expect(validBidWithoutreferInfo[0].url).to.equal(IX_SECURE_ENDPOINT);
3040
+ expect(validBidWithoutreferInfo[0].url).to.equal(expectedURL);
3056
3041
  });
3057
3042
 
3058
3043
  it('bidrequest should sent to secure endpoint if page url is secure', function () {
@@ -3062,10 +3047,11 @@ describe('IndexexchangeAdapter', function () {
3062
3047
  }
3063
3048
  };
3064
3049
  const validBidWithoutreferInfo = spec.buildRequests(DEFAULT_BANNER_VALID_BID, options);
3065
- const requestWithoutreferInfo = JSON.parse(validBidWithoutreferInfo[0].data.r);
3050
+ const requestWithoutreferInfo = extractPayload(validBidWithoutreferInfo[0]);
3066
3051
 
3052
+ const expectedURL = IX_SECURE_ENDPOINT + '?s=' + DEFAULT_BANNER_VALID_BID[0].params.siteId
3067
3053
  expect(requestWithoutreferInfo.site.page).to.equal(options.refererInfo.page);
3068
- expect(validBidWithoutreferInfo[0].url).to.equal(IX_SECURE_ENDPOINT);
3054
+ expect(validBidWithoutreferInfo[0].url).to.equal(expectedURL);
3069
3055
  });
3070
3056
 
3071
3057
  it('should set bid[].ttl to seatbid[].bid[].exp value from response', function () {
@@ -3073,16 +3059,16 @@ describe('IndexexchangeAdapter', function () {
3073
3059
  const VIDEO_RESPONSE_WITH_EXP = utils.deepClone(DEFAULT_VIDEO_BID_RESPONSE);
3074
3060
  VIDEO_RESPONSE_WITH_EXP.seatbid[0].bid[0].exp = 200;
3075
3061
  BANNER_RESPONSE_WITH_EXP.seatbid[0].bid[0].exp = 100;
3076
- const bannerResult = spec.interpretResponse({ body: BANNER_RESPONSE_WITH_EXP }, { data: DEFAULT_BIDDER_REQUEST_DATA, validBidRequests: [] });
3077
- const videoResult = spec.interpretResponse({ body: VIDEO_RESPONSE_WITH_EXP }, { data: DEFAULT_BIDDER_REQUEST_DATA, validBidRequests: [] });
3062
+ const bannerResult = spec.interpretResponse({ body: BANNER_RESPONSE_WITH_EXP }, bannerBidderRequest);
3063
+ const videoResult = spec.interpretResponse({ body: VIDEO_RESPONSE_WITH_EXP }, videoBidderRequest);
3078
3064
 
3079
3065
  expect(bannerResult[0].ttl).to.equal(100);
3080
3066
  expect(videoResult[0].ttl).to.equal(200);
3081
3067
  });
3082
3068
 
3083
3069
  it('should default bid[].ttl if seat[].bid[].exp is not in the resposne', function () {
3084
- const bannerResult = spec.interpretResponse({ body: DEFAULT_BANNER_BID_RESPONSE }, { data: DEFAULT_BIDDER_REQUEST_DATA, validBidRequests: [] });
3085
- const videoResult = spec.interpretResponse({ body: DEFAULT_VIDEO_BID_RESPONSE }, { data: DEFAULT_BIDDER_REQUEST_DATA, validBidRequests: [] });
3070
+ const bannerResult = spec.interpretResponse({ body: DEFAULT_BANNER_BID_RESPONSE }, bannerBidderRequest);
3071
+ const videoResult = spec.interpretResponse({ body: DEFAULT_VIDEO_BID_RESPONSE }, videoBidderRequest);
3086
3072
 
3087
3073
  expect(bannerResult[0].ttl).to.equal(300);
3088
3074
  expect(videoResult[0].ttl).to.equal(3600);
@@ -3174,7 +3160,7 @@ describe('IndexexchangeAdapter', function () {
3174
3160
  ttl: 3600
3175
3161
  }
3176
3162
  ];
3177
- const result = spec.interpretResponse({ body: DEFAULT_NATIVE_BID_RESPONSE }, { data: DEFAULT_BIDDER_REQUEST_DATA, validBidRequests: [] });
3163
+ const result = spec.interpretResponse({ body: DEFAULT_NATIVE_BID_RESPONSE }, nativeBidderRequest);
3178
3164
  expect(result[0]).to.deep.equal(expectedParse[0]);
3179
3165
  });
3180
3166
  });
@@ -3182,7 +3168,7 @@ describe('IndexexchangeAdapter', function () {
3182
3168
  describe('bidrequest consent', function () {
3183
3169
  it('should have consent info if gdprApplies and consentString exist', function () {
3184
3170
  const validBidWithConsent = spec.buildRequests(DEFAULT_BANNER_VALID_BID, DEFAULT_OPTION);
3185
- const requestWithConsent = JSON.parse(validBidWithConsent[0].data.r);
3171
+ const requestWithConsent = extractPayload(validBidWithConsent[0]);
3186
3172
 
3187
3173
  expect(requestWithConsent.regs.ext.gdpr).to.equal(1);
3188
3174
  expect(requestWithConsent.user.ext.consent).to.equal('3huaa11=qu3198ae');
@@ -3196,7 +3182,7 @@ describe('IndexexchangeAdapter', function () {
3196
3182
  }
3197
3183
  };
3198
3184
  const validBidWithConsent = spec.buildRequests(DEFAULT_BANNER_VALID_BID, options);
3199
- const requestWithConsent = JSON.parse(validBidWithConsent[0].data.r);
3185
+ const requestWithConsent = extractPayload(validBidWithConsent[0]);
3200
3186
 
3201
3187
  expect(requestWithConsent.regs.ext.gdpr).to.equal(1);
3202
3188
  expect(requestWithConsent.user).to.be.undefined;
@@ -3210,7 +3196,7 @@ describe('IndexexchangeAdapter', function () {
3210
3196
  }
3211
3197
  };
3212
3198
  const validBidWithConsent = spec.buildRequests(DEFAULT_BANNER_VALID_BID, options);
3213
- const requestWithConsent = JSON.parse(validBidWithConsent[0].data.r);
3199
+ const requestWithConsent = extractPayload(validBidWithConsent[0]);
3214
3200
 
3215
3201
  expect(requestWithConsent.regs).to.be.undefined;
3216
3202
  expect(requestWithConsent.user.ext.consent).to.equal('3huaa11=qu3198ae');
@@ -3219,7 +3205,7 @@ describe('IndexexchangeAdapter', function () {
3219
3205
  it('should not have consent info if options.gdprConsent is undefined', function () {
3220
3206
  const options = {};
3221
3207
  const validBidWithConsent = spec.buildRequests(DEFAULT_BANNER_VALID_BID, options);
3222
- const requestWithConsent = JSON.parse(validBidWithConsent[0].data.r);
3208
+ const requestWithConsent = extractPayload(validBidWithConsent[0]);
3223
3209
 
3224
3210
  expect(requestWithConsent.regs).to.be.undefined;
3225
3211
  expect(requestWithConsent.user).to.be.undefined;
@@ -3230,7 +3216,7 @@ describe('IndexexchangeAdapter', function () {
3230
3216
  uspConsent: '1YYN'
3231
3217
  };
3232
3218
  const validBidWithUspConsent = spec.buildRequests(DEFAULT_BANNER_VALID_BID, options);
3233
- const requestWithUspConsent = JSON.parse(validBidWithUspConsent[0].data.r);
3219
+ const requestWithUspConsent = extractPayload(validBidWithUspConsent[0]);
3234
3220
 
3235
3221
  expect(requestWithUspConsent.regs.ext.us_privacy).to.equal('1YYN');
3236
3222
  });
@@ -3238,7 +3224,7 @@ describe('IndexexchangeAdapter', function () {
3238
3224
  it('should not have us_privacy if uspConsent undefined', function () {
3239
3225
  const options = {};
3240
3226
  const validBidWithUspConsent = spec.buildRequests(DEFAULT_BANNER_VALID_BID, options);
3241
- const requestWithUspConsent = JSON.parse(validBidWithUspConsent[0].data.r);
3227
+ const requestWithUspConsent = extractPayload(validBidWithUspConsent[0]);
3242
3228
 
3243
3229
  expect(requestWithUspConsent.regs).to.be.undefined;
3244
3230
  });
@@ -3252,7 +3238,7 @@ describe('IndexexchangeAdapter', function () {
3252
3238
  uspConsent: '1YYN'
3253
3239
  };
3254
3240
  const validBidWithConsent = spec.buildRequests(DEFAULT_BANNER_VALID_BID, options);
3255
- const requestWithConsent = JSON.parse(validBidWithConsent[0].data.r);
3241
+ const requestWithConsent = extractPayload(validBidWithConsent[0]);
3256
3242
  expect(requestWithConsent.regs.ext.gdpr).to.equal(1);
3257
3243
  expect(requestWithConsent.regs.ext.us_privacy).to.equal('1YYN');
3258
3244
  });
@@ -3266,7 +3252,7 @@ describe('IndexexchangeAdapter', function () {
3266
3252
  };
3267
3253
 
3268
3254
  const validBidWithConsent = spec.buildRequests(DEFAULT_BANNER_VALID_BID, options);
3269
- const requestWithConsent = JSON.parse(validBidWithConsent[0].data.r);
3255
+ const requestWithConsent = extractPayload(validBidWithConsent[0]);
3270
3256
  expect(requestWithConsent.user.ext.consented_providers_settings.consented_providers).to.equal('1~1.35.41.101');
3271
3257
  expect(requestWithConsent.user.ext.consent).to.equal('3huaa11=qu3198ae');
3272
3258
  });
@@ -3279,7 +3265,7 @@ describe('IndexexchangeAdapter', function () {
3279
3265
  };
3280
3266
 
3281
3267
  const validBidWithConsent = spec.buildRequests(DEFAULT_BANNER_VALID_BID, options);
3282
- const requestWithConsent = JSON.parse(validBidWithConsent[0].data.r);
3268
+ const requestWithConsent = extractPayload(validBidWithConsent[0]);
3283
3269
  expect(utils.deepAccess(requestWithConsent, 'user.ext.consented_providers_settings')).to.not.exist;
3284
3270
  expect(utils.deepAccess(requestWithConsent, 'user.ext.consent')).to.not.exist;
3285
3271
  });
@@ -3287,21 +3273,21 @@ describe('IndexexchangeAdapter', function () {
3287
3273
  it('should set coppa to 1 in config when enabled', () => {
3288
3274
  config.setConfig({ coppa: true })
3289
3275
  const bid = spec.buildRequests(DEFAULT_BANNER_VALID_BID, DEFAULT_OPTION);
3290
- const r = JSON.parse(bid[0].data.r);
3276
+ const r = extractPayload(bid[0]);
3291
3277
 
3292
3278
  expect(r.regs.coppa).to.equal(1);
3293
3279
  });
3294
3280
  it('should not set coppa in config when disabled', () => {
3295
3281
  config.setConfig({ coppa: false })
3296
3282
  const bid = spec.buildRequests(DEFAULT_BANNER_VALID_BID, DEFAULT_OPTION);
3297
- const r = JSON.parse(bid[0].data.r);
3283
+ const r = extractPayload(bid[0]);
3298
3284
 
3299
3285
  expect(r.regs.coppa).to.be.undefined;
3300
3286
  });
3301
3287
  it('should not set coppa when not specified in config', () => {
3302
3288
  config.resetConfig();
3303
3289
  const bid = spec.buildRequests(DEFAULT_BANNER_VALID_BID, DEFAULT_OPTION);
3304
- const r = JSON.parse(bid[0].data.r);
3290
+ const r = extractPayload(bid[0]);
3305
3291
 
3306
3292
  expect(r.regs.coppa).to.be.undefined;
3307
3293
  });
@@ -3402,127 +3388,6 @@ describe('IndexexchangeAdapter', function () {
3402
3388
  expect(FEATURE_TOGGLES.isFeatureEnabled('test')).to.be.undefined;
3403
3389
  expect(FEATURE_TOGGLES.featureToggles).to.deep.equal({});
3404
3390
  });
3405
-
3406
- it('should create POST request when pbjs_enable_post feature is active', () => {
3407
- sandbox.stub(storage, 'localStorageIsEnabled').returns(true);
3408
- serverResponse.body.ext.features.pbjs_enable_post = {
3409
- activated: true
3410
- };
3411
- FEATURE_TOGGLES.setFeatureToggles(serverResponse);
3412
- const builtRequests = {
3413
- banner: {
3414
- request: spec.buildRequests(DEFAULT_BANNER_VALID_BID, DEFAULT_OPTION)[0],
3415
- siteId: DEFAULT_BANNER_VALID_BID[0].params.siteId
3416
- },
3417
- video: {
3418
- request: spec.buildRequests(DEFAULT_VIDEO_VALID_BID, DEFAULT_OPTION)[0],
3419
- siteId: DEFAULT_VIDEO_VALID_BID[0].params.siteId
3420
- },
3421
- native: {
3422
- request: spec.buildRequests(DEFAULT_NATIVE_VALID_BID, DEFAULT_OPTION)[0],
3423
- siteId: DEFAULT_NATIVE_VALID_BID[0].params.siteId
3424
- }
3425
- };
3426
-
3427
- Object.keys(builtRequests).forEach((reqType) => {
3428
- const request = builtRequests[reqType].request;
3429
- const siteId = builtRequests[reqType].siteId;
3430
- expect(request.method).to.equal('POST');
3431
- expect(request.option.contentType).to.equal('text/plain');
3432
- expect(request.url).to.be.equal(`${IX_SECURE_ENDPOINT}?s=${siteId}`);
3433
- expect(request.data.r).to.be.undefined;
3434
- expect(request.data.ac).to.be.undefined;
3435
- expect(request.data.sd).to.be.undefined;
3436
- expect(request.data.v).to.be.undefined;
3437
- expect(request.data.nf).to.be.undefined;
3438
- });
3439
- });
3440
-
3441
- it('should create GET request when pbjs_enable_post feature is disabled', () => {
3442
- sandbox.stub(storage, 'localStorageIsEnabled').returns(true);
3443
- serverResponse.body.ext.features.pbjs_enable_post = {
3444
- activated: false
3445
- };
3446
- FEATURE_TOGGLES.setFeatureToggles(serverResponse);
3447
- const builtRequests = {
3448
- banner: {
3449
- request: spec.buildRequests(DEFAULT_BANNER_VALID_BID, DEFAULT_OPTION)[0],
3450
- siteId: DEFAULT_BANNER_VALID_BID[0].params.siteId
3451
- },
3452
- video: {
3453
- request: spec.buildRequests(DEFAULT_VIDEO_VALID_BID, DEFAULT_OPTION)[0],
3454
- siteId: DEFAULT_VIDEO_VALID_BID[0].params.siteId
3455
- },
3456
- native: {
3457
- request: spec.buildRequests(DEFAULT_NATIVE_VALID_BID, DEFAULT_OPTION)[0],
3458
- siteId: DEFAULT_NATIVE_VALID_BID[0].params.siteId
3459
- }
3460
- };
3461
-
3462
- Object.keys(builtRequests).forEach((reqType) => {
3463
- const request = builtRequests[reqType].request;
3464
- const siteId = builtRequests[reqType].siteId;
3465
- expect(request.method).to.equal('GET');
3466
- expect(request.url).to.equal(IX_SECURE_ENDPOINT);
3467
- expect(request.data.r).to.exist;
3468
- expect(request.data.ac).to.equal('j');
3469
- expect(request.data.sd).to.equal(1);
3470
- expect(request.data.s).to.equal(siteId);
3471
- if (reqType == 'video') {
3472
- expect(request.data.nf).to.equal(1);
3473
- }
3474
-
3475
- if (reqType === 'native') {
3476
- expect(request.data.v).to.be.undefined;
3477
- }
3478
- });
3479
- });
3480
-
3481
- it('should interpertResponse correctly when pbjs_enable_post feature is active', function () {
3482
- serverResponse.body.ext.features.pbjs_enable_post = {
3483
- activated: true
3484
- };
3485
- FEATURE_TOGGLES.setFeatureToggles(serverResponse);
3486
- const postBiddderRequestData = {
3487
- id: '345',
3488
- imp: [
3489
- {
3490
- id: '1a2b3c4e',
3491
- banner: {
3492
- w: 300,
3493
- h: 250,
3494
- placement: 1
3495
- }
3496
- }
3497
- ],
3498
- site: {
3499
- ref: 'https://ref.com/ref.html',
3500
- page: 'https://page.com'
3501
- },
3502
- };
3503
- const expectedParse = [
3504
- {
3505
- requestId: '1a2b3c4d',
3506
- cpm: 1,
3507
- creativeId: '12345',
3508
- width: 300,
3509
- height: 250,
3510
- mediaType: 'banner',
3511
- ad: '<a target="_blank" href="https://www.indexexchange.com"></a>',
3512
- currency: 'USD',
3513
- ttl: 300,
3514
- netRevenue: true,
3515
- meta: {
3516
- networkId: 50,
3517
- brandId: 303325,
3518
- brandName: 'OECTA',
3519
- advertiserDomains: ['www.abc.com']
3520
- }
3521
- }
3522
- ];
3523
- const result = spec.interpretResponse({ body: DEFAULT_BANNER_BID_RESPONSE }, { data: postBiddderRequestData, validBidRequests: [] });
3524
- expect(result[0]).to.deep.equal(expectedParse[0]);
3525
- });
3526
3391
  });
3527
3392
 
3528
3393
  describe('LocalStorage error codes', () => {
@@ -3640,7 +3505,7 @@ describe('IndexexchangeAdapter', function () {
3640
3505
  };
3641
3506
 
3642
3507
  expect(spec.isBidRequestValid(bid)).to.be.true;
3643
- spec.buildRequests([bid], {ortb2});
3508
+ spec.buildRequests([bid], { ortb2 });
3644
3509
  expect(JSON.parse(localStorageValues[key])).to.deep.equal({ [TODAY]: { [ERROR_CODES.PB_FPD_EXCEEDS_MAX_SIZE]: 2 } });
3645
3510
  });
3646
3511
 
@@ -3694,30 +3559,24 @@ describe('IndexexchangeAdapter', function () {
3694
3559
  expect(spec.isBidRequestValid(request)).to.be.true;
3695
3560
 
3696
3561
  const data = {
3697
- ...utils.deepClone(DEFAULT_BIDDER_REQUEST_DATA[0]),
3698
- r: JSON.stringify({
3699
- id: '345',
3700
- imp: [
3701
- {
3702
- id: '1a2b3c4e',
3703
- }
3704
- ],
3705
- ext: {
3706
- ixdiag: {
3707
- err: {
3708
- '4': 8
3709
- }
3562
+ id: '345',
3563
+ imp: [
3564
+ {
3565
+ id: '1a2b3c4e',
3566
+ }
3567
+ ],
3568
+ ext: {
3569
+ ixdiag: {
3570
+ err: {
3571
+ '4': 8
3710
3572
  }
3711
3573
  }
3712
- }),
3574
+ }
3713
3575
  };
3714
3576
 
3715
- const validBidRequests = [
3716
- DEFAULT_MULTIFORMAT_BANNER_VALID_BID[0],
3717
- DEFAULT_MULTIFORMAT_VIDEO_VALID_BID[0]
3718
- ];
3577
+ const validBidRequest = DEFAULT_MULTIFORMAT_BANNER_VALID_BID[0];
3719
3578
 
3720
- spec.interpretResponse({ body: DEFAULT_BANNER_BID_RESPONSE }, { data, validBidRequests });
3579
+ spec.interpretResponse({ body: DEFAULT_BANNER_BID_RESPONSE }, { data, validBidRequest });
3721
3580
 
3722
3581
  expect(localStorageValues[key]).to.be.undefined;
3723
3582
  });