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
@@ -0,0 +1,95 @@
1
+ import {fillNativeImp, fillNativeResponse} from '../../../libraries/ortbConverter/processors/native.js';
2
+ import {BANNER, NATIVE} from '../../../src/mediaTypes.js';
3
+
4
+ describe('pbjs -> ortb native requests', () => {
5
+ function toNative(bidRequest, context) {
6
+ const imp = {};
7
+ fillNativeImp(imp, bidRequest, context);
8
+ return imp;
9
+ }
10
+
11
+ it('should do nothing if request has no nativeOrtbRequest', () => {
12
+ expect(toNative({}, {})).to.eql({});
13
+ });
14
+
15
+ it('should set imp.native according to nativeOrtbRequest', () => {
16
+ const nativeOrtbRequest = {ver: 'version', prop: 'value', assets: [{}]};
17
+ const imp = toNative({nativeOrtbRequest}, {});
18
+ expect(imp.native.ver).to.eql('version');
19
+ expect(JSON.parse(imp.native.request)).to.eql(nativeOrtbRequest);
20
+ });
21
+
22
+ it('should do nothing if context.mediaType is set but is not NATIVE', () => {
23
+ expect(toNative({nativeOrtbRequest: {ver: 'version'}}, {mediaType: BANNER})).to.eql({})
24
+ });
25
+
26
+ it('should merge context.nativeRequest', () => {
27
+ const nativeOrtbRequest = {ver: 'version', eventtrackers: [{tracker: 'req'}], assets: [{}]};
28
+ const nativeDefaults = {eventtrackers: [{tracker: 'default'}], other: 'other'};
29
+ const imp = toNative({nativeOrtbRequest}, {nativeRequest: nativeDefaults});
30
+ expect(imp.native.ver).to.eql('version');
31
+ expect(JSON.parse(imp.native.request)).to.eql({
32
+ assets: [{}],
33
+ ver: 'version',
34
+ eventtrackers: [{tracker: 'req'}],
35
+ other: 'other'
36
+ });
37
+ });
38
+
39
+ it('should keep ortb2Imp.native', () => {
40
+ const imp = {
41
+ native: {
42
+ something: 'orother'
43
+ }
44
+ }
45
+ fillNativeImp(imp, {nativeOrtbRequest: {ver: 'version'}}, {});
46
+ expect(imp.native.something).to.eql('orother')
47
+ });
48
+
49
+ it('should do nothing if there are no assets', () => {
50
+ const imp = {};
51
+ fillNativeImp(imp, {nativeOrtbRequest: {assets: []}}, {});
52
+ expect(imp).to.eql({});
53
+ })
54
+ });
55
+
56
+ describe('ortb -> ortb native response', () => {
57
+ const MOCK_NATIVE_RESPONSE = {
58
+ property: 'value',
59
+ assets: [
60
+ {
61
+ id: 0
62
+ }
63
+ ]
64
+ }
65
+ Object.entries({
66
+ 'serialized': JSON.stringify(MOCK_NATIVE_RESPONSE),
67
+ 'an object': MOCK_NATIVE_RESPONSE
68
+ }).forEach(([t, adm]) => {
69
+ describe(`when adm is ${t}`, () => {
70
+ let bid;
71
+ beforeEach(() => {
72
+ bid = {adm};
73
+ })
74
+ it('should set bidResponse.native', () => {
75
+ const bidResponse = {
76
+ mediaType: NATIVE
77
+ };
78
+ fillNativeResponse(bidResponse, bid, {});
79
+ expect(bidResponse.native).to.eql({ortb: MOCK_NATIVE_RESPONSE});
80
+ });
81
+ });
82
+ it('should throw if response has no assets', () => {
83
+ expect(() => fillNativeResponse({mediaType: NATIVE}, {adm: {...MOCK_NATIVE_RESPONSE, assets: null}}, {})).to.throw;
84
+ })
85
+ it('should do nothing if bidResponse.mediaType is not NATIVE', () => {
86
+ const bidResponse = {
87
+ mediaType: BANNER
88
+ };
89
+ fillNativeResponse(bidResponse, {adm: MOCK_NATIVE_RESPONSE}, {});
90
+ expect(bidResponse).to.eql({
91
+ mediaType: BANNER
92
+ })
93
+ })
94
+ })
95
+ });
@@ -0,0 +1,67 @@
1
+ import {
2
+ DEFAULT,
3
+ PBS,
4
+ PROCESSOR_TYPES,
5
+ processorRegistry,
6
+ REQUEST
7
+ } from '../../../src/pbjsORTB.js';
8
+
9
+ describe('pbjsORTB register / get processors', () => {
10
+ let registerOrtbProcessor, getProcessors;
11
+ beforeEach(() => {
12
+ ({registerOrtbProcessor, getProcessors} = processorRegistry());
13
+ })
14
+ PROCESSOR_TYPES.forEach(type => {
15
+ it(`can get and set ${type} processors`, () => {
16
+ const proc = function () {};
17
+ registerOrtbProcessor({
18
+ type,
19
+ name: 'test',
20
+ fn: proc
21
+ });
22
+ expect(getProcessors(DEFAULT)).to.eql({
23
+ [type]: {
24
+ test: {
25
+ priority: 0,
26
+ fn: proc
27
+ }
28
+ }
29
+ });
30
+ });
31
+ });
32
+
33
+ it('throws on wrong type', () => {
34
+ expect(() => registerOrtbProcessor({
35
+ type: 'incorrect',
36
+ name: 'test',
37
+ fn: function () {}
38
+ })).to.throw();
39
+ });
40
+
41
+ it('can set priority', () => {
42
+ const proc = function () {};
43
+ registerOrtbProcessor({type: REQUEST, name: 'test', fn: proc, priority: 10});
44
+ expect(getProcessors(DEFAULT)).to.eql({
45
+ [REQUEST]: {
46
+ test: {
47
+ priority: 10,
48
+ fn: proc
49
+ }
50
+ }
51
+ })
52
+ });
53
+
54
+ it('can assign processors to specific dialects', () => {
55
+ const proc = function () {};
56
+ registerOrtbProcessor({type: REQUEST, name: 'test', fn: proc, dialects: [PBS]});
57
+ expect(getProcessors(DEFAULT)).to.eql({});
58
+ expect(getProcessors(PBS)).to.eql({
59
+ [REQUEST]: {
60
+ test: {
61
+ priority: 0,
62
+ fn: proc
63
+ }
64
+ }
65
+ })
66
+ });
67
+ });
@@ -0,0 +1,57 @@
1
+ import {setRequestExtPrebidAliases} from '../../../../libraries/pbsExtensions/processors/aliases.js';
2
+
3
+ describe('PBS - ortb ext.prebid.aliases', () => {
4
+ let aliasRegistry, bidderRegistry;
5
+
6
+ function setAliases(bidderRequest) {
7
+ const req = {}
8
+ setRequestExtPrebidAliases(req, bidderRequest, {}, {
9
+ am: {
10
+ bidderRegistry,
11
+ aliasRegistry
12
+ }
13
+ });
14
+ return req;
15
+ }
16
+
17
+ beforeEach(() => {
18
+ aliasRegistry = {};
19
+ bidderRegistry = {};
20
+ })
21
+
22
+ describe('has no effect if', () => {
23
+ it('bidder is not an alias', () => {
24
+ expect(setAliases({bidderCode: 'not-an-alias'})).to.eql({});
25
+ });
26
+
27
+ it('bidder sets skipPbsAliasing', () => {
28
+ aliasRegistry['alias'] = 'bidder';
29
+ bidderRegistry['alias'] = {
30
+ getSpec() {
31
+ return {
32
+ skipPbsAliasing: true
33
+ }
34
+ }
35
+ };
36
+ expect(setAliases({bidderCode: 'alias'})).to.eql({});
37
+ });
38
+ });
39
+
40
+ it('sets ext.prebid.aliases.BIDDER', () => {
41
+ aliasRegistry['alias'] = 'bidder';
42
+ bidderRegistry['alias'] = {
43
+ getSpec() {
44
+ return {}
45
+ }
46
+ };
47
+ expect(setAliases({bidderCode: 'alias'})).to.eql({
48
+ ext: {
49
+ prebid: {
50
+ aliases: {
51
+ alias: 'bidder'
52
+ }
53
+ }
54
+ }
55
+ })
56
+ });
57
+ })
@@ -0,0 +1,96 @@
1
+ import {setImpBidParams} from '../../../../libraries/pbsExtensions/processors/params.js';
2
+
3
+ describe('pbjs -> ortb bid params to imp[].ext.prebid.BIDDER', () => {
4
+ let bidderRegistry, index, adUnit;
5
+ beforeEach(() => {
6
+ bidderRegistry = {};
7
+ adUnit = {code: 'mockAdUnit'};
8
+ index = {
9
+ getAdUnit() {
10
+ return adUnit;
11
+ }
12
+ }
13
+ });
14
+
15
+ function setParams(bidRequest, context, deps = {}) {
16
+ const imp = {};
17
+ setImpBidParams(imp, bidRequest, context, Object.assign({bidderRegistry, index}, deps))
18
+ return imp;
19
+ }
20
+
21
+ it('sets params in ext.prebid.bidder.BIDDER', () => {
22
+ expect(setParams({bidder: 'mockBidder', params: {a: 'param'}})).to.eql({
23
+ ext: {
24
+ prebid: {
25
+ bidder: {
26
+ mockBidder: {
27
+ a: 'param'
28
+ }
29
+ }
30
+ }
31
+ }
32
+ })
33
+ });
34
+
35
+ it('has no effect if bidRequest has no params', () => {
36
+ expect(setParams({bidder: 'mockBidder'})).to.eql({});
37
+ })
38
+
39
+ describe('when adapter provides transformBidParams', () => {
40
+ let transform, bidderRequest;
41
+ beforeEach(() => {
42
+ bidderRequest = {bidderCode: 'mockBidder'};
43
+ transform = sinon.stub().callsFake((p) => Object.assign({transformed: true}, p));
44
+ bidderRegistry.mockBidder = {
45
+ getSpec() {
46
+ return {
47
+ transformBidParams: transform
48
+ }
49
+ }
50
+ }
51
+ })
52
+
53
+ it('runs params through transform', () => {
54
+ expect(setParams({bidder: 'mockBidder', params: {a: 'param'}}, {bidderRequest})).to.eql({
55
+ ext: {
56
+ prebid: {
57
+ bidder: {
58
+ mockBidder: {
59
+ a: 'param',
60
+ transformed: true
61
+ }
62
+ }
63
+ }
64
+ }
65
+ });
66
+ });
67
+
68
+ it('runs through transform even if bid has no params', () => {
69
+ expect(setParams({bidder: 'mockBidder'}, {bidderRequest})).to.eql({
70
+ ext: {
71
+ prebid: {
72
+ bidder: {
73
+ mockBidder: {
74
+ transformed: true
75
+ }
76
+ }
77
+ }
78
+ }
79
+ })
80
+ })
81
+
82
+ it('by default, passes adUnit from index, bidderRequest from context', () => {
83
+ const params = {a: 'param'};
84
+ setParams({bidder: 'mockBidder', params}, {bidderRequest});
85
+ sinon.assert.calledWith(transform, params, true, adUnit, [bidderRequest])
86
+ });
87
+
88
+ it('uses provided adUnit, bidderRequests', () => {
89
+ const adUnit = {code: 'other-ad-unit'};
90
+ const bidderRequests = [{bidderCode: 'one'}, {bidderCode: 'two'}];
91
+ const params = {a: 'param'};
92
+ setParams({bidder: 'mockBidder', params}, {}, {adUnit, bidderRequests});
93
+ sinon.assert.calledWith(transform, params, true, adUnit, bidderRequests);
94
+ })
95
+ });
96
+ });
@@ -0,0 +1,52 @@
1
+ import {setBidResponseVideoCache} from '../../../../libraries/pbsExtensions/processors/video.js';
2
+
3
+ describe('pbjs - ortb videoCacheKey based on ext.prebid', () => {
4
+ const EXT_PREBID_CACHE = {
5
+ ext: {
6
+ prebid: {
7
+ cache: {
8
+ vastXml: {
9
+ cacheId: 'id',
10
+ url: 'url'
11
+ }
12
+ }
13
+ }
14
+ }
15
+ }
16
+
17
+ function setCache(bid) {
18
+ const bidResponse = {mediaType: 'video'};
19
+ setBidResponseVideoCache(bidResponse, bid);
20
+ return bidResponse;
21
+ }
22
+
23
+ it('has no effect if mediaType is not video', () => {
24
+ const resp = {mediaType: 'banner'};
25
+ setBidResponseVideoCache(resp, EXT_PREBID_CACHE);
26
+ expect(resp).to.eql({mediaType: 'banner'});
27
+ });
28
+
29
+ it('sets videoCacheKey, vastUrl from ext.prebid.cache.vastXml', () => {
30
+ sinon.assert.match(setCache(EXT_PREBID_CACHE), {
31
+ videoCacheKey: 'id',
32
+ vastUrl: 'url'
33
+ });
34
+ });
35
+
36
+ it('sets videoCacheKey, vastUrl from ext.prebid.targeting', () => {
37
+ sinon.assert.match(setCache({
38
+ ext: {
39
+ prebid: {
40
+ targeting: {
41
+ hb_uuid: 'id',
42
+ hb_cache_host: 'host',
43
+ hb_cache_path: '/path'
44
+ }
45
+ }
46
+ }
47
+ }), {
48
+ vastUrl: 'https://host/path?uuid=id',
49
+ videoCacheKey: 'id'
50
+ })
51
+ });
52
+ });
@@ -0,0 +1,143 @@
1
+ import {config} from 'src/config.js';
2
+ import {setOrtbExtPrebidFloors, setOrtbImpBidFloor} from '../../../modules/priceFloors.js';
3
+ import 'src/prebid.js';
4
+
5
+ describe('pbjs - ortb imp floor params', () => {
6
+ before(() => {
7
+ config.resetConfig();
8
+ });
9
+
10
+ afterEach(() => {
11
+ config.resetConfig();
12
+ });
13
+
14
+ Object.entries({
15
+ 'has no getFloor': {},
16
+ 'has getFloor that throws': {
17
+ getFloor: sinon.stub().callsFake(() => { throw new Error() }),
18
+ },
19
+ 'returns invalid floor': {
20
+ getFloor: sinon.stub().callsFake(() => ({floor: NaN, currency: null}))
21
+ }
22
+ }).forEach(([t, req]) => {
23
+ it(`has no effect if bid ${t}`, () => {
24
+ const imp = {};
25
+ setOrtbImpBidFloor(imp, {}, {});
26
+ expect(imp).to.eql({});
27
+ })
28
+ })
29
+
30
+ it('sets bidfoor and bidfloorcur according to getFloor', () => {
31
+ const imp = {};
32
+ const req = {
33
+ getFloor() {
34
+ return {
35
+ currency: 'EUR',
36
+ floor: '1.23'
37
+ }
38
+ }
39
+ };
40
+ setOrtbImpBidFloor(imp, req, {});
41
+ expect(imp).to.eql({
42
+ bidfloor: 1.23,
43
+ bidfloorcur: 'EUR'
44
+ })
45
+ });
46
+
47
+ Object.entries({
48
+ 'missing currency': {floor: 1.23},
49
+ 'missing floor': {currency: 'USD'},
50
+ 'not a number': {floor: 'abc', currency: 'USD'}
51
+ }).forEach(([t, floor]) => {
52
+ it(`should not set bidfloor if floor is ${t}`, () => {
53
+ const imp = {};
54
+ const req = {
55
+ getFloor: () => floor
56
+ }
57
+ setOrtbImpBidFloor(imp, req, {});
58
+ expect(imp).to.eql({});
59
+ })
60
+ })
61
+
62
+ describe('asks for floor in currency', () => {
63
+ let req;
64
+ beforeEach(() => {
65
+ req = {
66
+ getFloor(opts) {
67
+ return {
68
+ floor: 1.23,
69
+ currency: opts.currency
70
+ }
71
+ }
72
+ }
73
+ })
74
+
75
+ it('from context.currency', () => {
76
+ const imp = {};
77
+ setOrtbImpBidFloor(imp, req, {currency: 'JPY'});
78
+ config.setConfig({
79
+ currency: {
80
+ adServerCurrency: 'EUR'
81
+ }
82
+ })
83
+ expect(imp.bidfloorcur).to.eql('JPY');
84
+ });
85
+
86
+ it('from config', () => {
87
+ const imp = {};
88
+ config.setConfig({
89
+ currency: {
90
+ adServerCurrency: 'EUR'
91
+ }
92
+ });
93
+ setOrtbImpBidFloor(imp, req, {});
94
+ expect(imp.bidfloorcur).to.eql('EUR');
95
+ });
96
+
97
+ it('defaults to USD', () => {
98
+ const imp = {};
99
+ setOrtbImpBidFloor(imp, req, {});
100
+ expect(imp.bidfloorcur).to.eql('USD');
101
+ })
102
+ });
103
+
104
+ it('asks for specific mediaType if context.mediaType is set', () => {
105
+ let reqMediaType;
106
+ const req = {
107
+ getFloor(opts) {
108
+ reqMediaType = opts.mediaType;
109
+ }
110
+ }
111
+ setOrtbImpBidFloor({}, req, {mediaType: 'banner'});
112
+ expect(reqMediaType).to.eql('banner');
113
+ })
114
+ });
115
+
116
+ describe('setOrtbExtPrebidFloors', () => {
117
+ before(() => {
118
+ config.setConfig({floors: {}});
119
+ })
120
+ after(() => {
121
+ config.setConfig({floors: {enabled: false}});
122
+ });
123
+
124
+ it('should set ext.prebid.floors.enabled to false', () => {
125
+ const req = {};
126
+ setOrtbExtPrebidFloors(req);
127
+ expect(req.ext.prebid.floors.enabled).to.equal(false);
128
+ })
129
+
130
+ it('should respect fpd', () => {
131
+ const req = {
132
+ ext: {
133
+ prebid: {
134
+ floors: {
135
+ enabled: true
136
+ }
137
+ }
138
+ }
139
+ }
140
+ setOrtbExtPrebidFloors(req);
141
+ expect(req.ext.prebid.floors.enabled).to.equal(true);
142
+ })
143
+ })
@@ -0,0 +1,33 @@
1
+ import {setOrtbSourceExtSchain} from '../../../modules/schain.js';
2
+
3
+ describe('pbjs - ortb source.ext.schain', () => {
4
+ it('sets schain from request', () => {
5
+ const req = {};
6
+ setOrtbSourceExtSchain(req, {}, {
7
+ bidRequests: [{schain: {s: 'chain'}}]
8
+ });
9
+ expect(req.source.ext.schain).to.eql({s: 'chain'});
10
+ });
11
+
12
+ it('does not set it if missing', () => {
13
+ const req = {};
14
+ setOrtbSourceExtSchain(req, {}, {bidRequests: [{}]});
15
+ expect(req).to.eql({});
16
+ })
17
+
18
+ it('does not set it if already in request', () => {
19
+ const req = {
20
+ source: {
21
+ ext: {
22
+ schain: {s: 'chain'}
23
+ }
24
+ }
25
+ }
26
+ setOrtbSourceExtSchain(req, {}, {
27
+ bidRequests: [{
28
+ schain: {other: 'chain'}
29
+ }]
30
+ });
31
+ expect(req.source.ext.schain).to.eql({s: 'chain'});
32
+ })
33
+ });
@@ -0,0 +1,21 @@
1
+ import {setOrtbUserExtEids} from '../../../modules/userId/index.js';
2
+
3
+ describe('pbjs - ortb user eids', () => {
4
+ it('sets user.ext.eids from request', () => {
5
+ const req = {};
6
+ setOrtbUserExtEids(req, {}, {
7
+ bidRequests: [
8
+ {
9
+ userIdAsEids: {e: 'id'}
10
+ }
11
+ ]
12
+ });
13
+ expect(req.user.ext.eids).to.eql({e: 'id'});
14
+ });
15
+
16
+ it('has no effect if requests have no eids', () => {
17
+ const req = {};
18
+ setOrtbUserExtEids(req, {}, [{}]);
19
+ expect(req).to.eql({});
20
+ })
21
+ })
@@ -0,0 +1,15 @@
1
+ import {setOrtbUsp} from '../../../modules/consentManagementUsp.js';
2
+
3
+ describe('pbjs - ortb usp', () => {
4
+ it('sets regs.ext.us_privacy from bidderRequest', () => {
5
+ const req = {};
6
+ setOrtbUsp(req, {uspConsent: '1NN'});
7
+ expect(req.regs.ext.us_privacy).to.eql('1NN');
8
+ });
9
+
10
+ it('does not set if missing', () => {
11
+ const req = {};
12
+ setOrtbUsp(req, {});
13
+ expect(req).to.eql({});
14
+ });
15
+ })