prebid.js 9.7.0 → 9.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (255) hide show
  1. package/.github/codeql/codeql-config.yml +3 -0
  2. package/.github/codeql/queries/deviceMemory.ql +14 -0
  3. package/.github/codeql/queries/hardwareConcurrency.ql +14 -0
  4. package/.github/codeql/queries/prebid.qll +36 -0
  5. package/.github/codeql/queries/qlpack.yml +8 -0
  6. package/.github/workflows/jscpd.yml +1 -1
  7. package/dist/33acrossAnalyticsAdapter.js +1 -1
  8. package/dist/33acrossBidAdapter.js +1 -1
  9. package/dist/33acrossIdSystem.js +1 -1
  10. package/dist/BTBidAdapter.js +1 -1
  11. package/dist/adagioAnalyticsAdapter.js +1 -1
  12. package/dist/adagioBidAdapter.js +1 -1
  13. package/dist/adagioUtils.js +1 -1
  14. package/dist/addefendBidAdapter.js +1 -1
  15. package/dist/adgenerationBidAdapter.js +1 -1
  16. package/dist/adlooxRtdProvider.js +1 -1
  17. package/dist/admixerBidAdapter.js +1 -1
  18. package/dist/adqueryBidAdapter.js +1 -1
  19. package/dist/adrelevantisBidAdapter.js +1 -1
  20. package/dist/adstirBidAdapter.js +1 -1
  21. package/dist/adtrgtmeBidAdapter.js +1 -1
  22. package/dist/adxcgAnalyticsAdapter.js +1 -1
  23. package/dist/adxcgBidAdapter.js +1 -1
  24. package/dist/adyoulikeBidAdapter.js +1 -1
  25. package/dist/agmaAnalyticsAdapter.js +1 -1
  26. package/dist/ajaBidAdapter.js +1 -1
  27. package/dist/amxBidAdapter.js +1 -1
  28. package/dist/amxIdSystem.js +1 -1
  29. package/dist/appierAnalyticsAdapter.js +1 -1
  30. package/dist/appnexusBidAdapter.js +1 -1
  31. package/dist/asoBidAdapter.js +1 -1
  32. package/dist/axonixBidAdapter.js +1 -1
  33. package/dist/bidglassBidAdapter.js +1 -1
  34. package/dist/big-richmediaBidAdapter.js +1 -1
  35. package/dist/bridBidAdapter.js +1 -1
  36. package/dist/bridgewellBidAdapter.js +1 -1
  37. package/dist/brightMountainMediaBidAdapter.js +1 -1
  38. package/dist/carodaBidAdapter.js +1 -1
  39. package/dist/ccxBidAdapter.js +1 -1
  40. package/dist/chtnwBidAdapter.js +1 -1
  41. package/dist/chunk-core.js +1 -1
  42. package/dist/concertBidAdapter.js +1 -1
  43. package/dist/connectadBidAdapter.js +1 -1
  44. package/dist/consumableBidAdapter.js +1 -1
  45. package/dist/contxtfulRtdProvider.js +1 -1
  46. package/dist/conversantAnalyticsAdapter.js +1 -1
  47. package/dist/conversantBidAdapter.js +1 -1
  48. package/dist/craftBidAdapter.js +1 -1
  49. package/dist/criteoBidAdapter.js +1 -1
  50. package/dist/cwireBidAdapter.js +1 -1
  51. package/dist/dailymotionBidAdapter.js +1 -1
  52. package/dist/dependencies.json +19 -4
  53. package/dist/discoveryBidAdapter.js +1 -1
  54. package/dist/docereeAdManagerBidAdapter.js +1 -1
  55. package/dist/dspxBidAdapter.js +1 -1
  56. package/dist/dxkultureBidAdapter.js +1 -1
  57. package/dist/eclickadsBidAdapter.js +1 -0
  58. package/dist/eightPodAnalyticsAdapter.js +1 -1
  59. package/dist/eplanningBidAdapter.js +1 -1
  60. package/dist/euidIdSystem.js +1 -1
  61. package/dist/exadsBidAdapter.js +1 -1
  62. package/dist/feedadBidAdapter.js +1 -1
  63. package/dist/finativeBidAdapter.js +1 -1
  64. package/dist/freewheel-sspBidAdapter.js +1 -1
  65. package/dist/gmosspBidAdapter.js +1 -1
  66. package/dist/goldbachBidAdapter.js +1 -1
  67. package/dist/greenbidsAnalyticsAdapter.js +1 -1
  68. package/dist/greenbidsRtdProvider.js +1 -1
  69. package/dist/gridBidAdapter.js +1 -1
  70. package/dist/gumgumBidAdapter.js +1 -1
  71. package/dist/h12mediaBidAdapter.js +1 -1
  72. package/dist/hypelabBidAdapter.js +1 -1
  73. package/dist/id5AnalyticsAdapter.js +1 -1
  74. package/dist/id5IdSystem.js +1 -1
  75. package/dist/imdsBidAdapter.js +1 -1
  76. package/dist/improvedigitalBidAdapter.js +1 -1
  77. package/dist/insticatorBidAdapter.js +1 -1
  78. package/dist/intentIqAnalyticsAdapter.js +1 -1
  79. package/dist/ixBidAdapter.js +1 -1
  80. package/dist/jixieBidAdapter.js +1 -1
  81. package/dist/justpremiumBidAdapter.js +1 -1
  82. package/dist/kargoBidAdapter.js +1 -1
  83. package/dist/kimberliteBidAdapter.js +1 -1
  84. package/dist/konduitAnalyticsAdapter.js +1 -1
  85. package/dist/kueezBidAdapter.js +1 -1
  86. package/dist/lassoBidAdapter.js +1 -1
  87. package/dist/lifestreetBidAdapter.js +1 -1
  88. package/dist/limelightDigitalBidAdapter.js +1 -1
  89. package/dist/liveIntentIdSystem.js +1 -1
  90. package/dist/logicadBidAdapter.js +1 -1
  91. package/dist/loglyliftBidAdapter.js +1 -1
  92. package/dist/luceadBidAdapter.js +1 -1
  93. package/dist/mabidderBidAdapter.js +1 -1
  94. package/dist/magniteAnalyticsAdapter.js +1 -1
  95. package/dist/malltvAnalyticsAdapter.js +1 -1
  96. package/dist/marsmediaBidAdapter.js +1 -1
  97. package/dist/mediafuseBidAdapter.js +1 -1
  98. package/dist/mediagoBidAdapter.js +1 -1
  99. package/dist/medianetAnalyticsAdapter.js +1 -1
  100. package/dist/medianetBidAdapter.js +1 -1
  101. package/dist/mediasquareBidAdapter.js +1 -1
  102. package/dist/mgidBidAdapter.js +1 -1
  103. package/dist/mgidUtils.js +1 -0
  104. package/dist/mgidXBidAdapter.js +1 -1
  105. package/dist/missenaBidAdapter.js +1 -1
  106. package/dist/mobianRtdProvider.js +1 -1
  107. package/dist/naveggIdSystem.js +1 -1
  108. package/dist/navigatorData.js +1 -0
  109. package/dist/nexx360BidAdapter.js +1 -1
  110. package/dist/nobidAnalyticsAdapter.js +1 -1
  111. package/dist/nobidBidAdapter.js +1 -1
  112. package/dist/not-for-prod/prebid.js +174 -169
  113. package/dist/oguryBidAdapter.js +1 -1
  114. package/dist/omsBidAdapter.js +1 -1
  115. package/dist/onetagBidAdapter.js +1 -1
  116. package/dist/ooloAnalyticsAdapter.js +1 -1
  117. package/dist/openxBidAdapter.js +1 -1
  118. package/dist/optidigitalBidAdapter.js +1 -1
  119. package/dist/orbidderBidAdapter.js +1 -1
  120. package/dist/outbrainBidAdapter.js +1 -1
  121. package/dist/pixfutureBidAdapter.js +1 -1
  122. package/dist/pstudioBidAdapter.js +1 -1
  123. package/dist/publinkIdSystem.js +1 -1
  124. package/dist/pubmaticAnalyticsAdapter.js +1 -1
  125. package/dist/pubmaticBidAdapter.js +1 -1
  126. package/dist/pubriseBidAdapter.js +1 -0
  127. package/dist/pubwiseAnalyticsAdapter.js +1 -1
  128. package/dist/pubxaiAnalyticsAdapter.js +1 -1
  129. package/dist/pubxaiRtdProvider.js +1 -1
  130. package/dist/pxyzBidAdapter.js +1 -1
  131. package/dist/quantcastBidAdapter.js +1 -1
  132. package/dist/readpeakBidAdapter.js +1 -1
  133. package/dist/redtramBidAdapter.js +1 -1
  134. package/dist/relaidoBidAdapter.js +1 -1
  135. package/dist/retailspotBidAdapter.js +1 -1
  136. package/dist/rhythmoneBidAdapter.js +1 -1
  137. package/dist/richaudienceBidAdapter.js +1 -1
  138. package/dist/riseUtils.js +1 -1
  139. package/dist/rubiconBidAdapter.js +1 -1
  140. package/dist/seedingAllianceBidAdapter.js +1 -1
  141. package/dist/seedtagBidAdapter.js +1 -1
  142. package/dist/sharethroughAnalyticsAdapter.js +1 -1
  143. package/dist/sharethroughBidAdapter.js +1 -1
  144. package/dist/smaatoBidAdapter.js +1 -1
  145. package/dist/smartadserverBidAdapter.js +1 -1
  146. package/dist/smarthubBidAdapter.js +1 -1
  147. package/dist/smartxBidAdapter.js +1 -1
  148. package/dist/smilewantedBidAdapter.js +1 -1
  149. package/dist/snigelBidAdapter.js +1 -1
  150. package/dist/sonobiBidAdapter.js +1 -1
  151. package/dist/sovrnBidAdapter.js +1 -1
  152. package/dist/sspBCBidAdapter.js +1 -1
  153. package/dist/stvBidAdapter.js +1 -1
  154. package/dist/sublimeBidAdapter.js +1 -1
  155. package/dist/taboolaBidAdapter.js +1 -1
  156. package/dist/tappxBidAdapter.js +1 -1
  157. package/dist/targetVideoAdServerVideo.js +1 -0
  158. package/dist/targetVideoBidAdapter.js +1 -1
  159. package/dist/teadsBidAdapter.js +1 -1
  160. package/dist/teqblazeUtils.js +1 -1
  161. package/dist/terceptAnalyticsAdapter.js +1 -1
  162. package/dist/themoneytizerBidAdapter.js +1 -1
  163. package/dist/trionBidAdapter.js +1 -1
  164. package/dist/tripleliftBidAdapter.js +1 -1
  165. package/dist/ttdBidAdapter.js +1 -1
  166. package/dist/ucfunnelAnalyticsAdapter.js +1 -1
  167. package/dist/uid2IdSystem.js +1 -1
  168. package/dist/underdogmediaBidAdapter.js +1 -1
  169. package/dist/undertoneBidAdapter.js +1 -1
  170. package/dist/unrulyBidAdapter.js +1 -1
  171. package/dist/userId.js +1 -1
  172. package/dist/vidazooUtils.js +1 -1
  173. package/dist/videobyteBidAdapter.js +1 -1
  174. package/dist/visxBidAdapter.js +1 -1
  175. package/dist/vuukleBidAdapter.js +1 -1
  176. package/dist/widespaceBidAdapter.js +1 -1
  177. package/dist/winrBidAdapter.js +1 -1
  178. package/dist/yahooAdsBidAdapter.js +1 -1
  179. package/dist/yieldmoBidAdapter.js +1 -1
  180. package/dist/yieldoneAnalyticsAdapter.js +1 -1
  181. package/libraries/mgidUtils/mgidUtils.js +73 -0
  182. package/{src/fpd/navigator.js → libraries/navigatorData/navigatorData.js} +1 -1
  183. package/libraries/riseUtils/index.js +1 -1
  184. package/libraries/teqblazeUtils/bidderUtils.js +1 -1
  185. package/modules/admixerBidAdapter.js +12 -5
  186. package/modules/appnexusBidAdapter.js +1 -1
  187. package/modules/ccxBidAdapter.js +6 -2
  188. package/modules/contxtfulRtdProvider.js +15 -12
  189. package/modules/cwireBidAdapter.js +13 -9
  190. package/modules/cwireBidAdapter.md +29 -10
  191. package/modules/dailymotionBidAdapter.js +1 -1
  192. package/modules/dailymotionBidAdapter.md +11 -7
  193. package/modules/discoveryBidAdapter.js +1 -3
  194. package/modules/docereeAdManagerBidAdapter.js +14 -8
  195. package/modules/eclickadsBidAdapter.js +80 -0
  196. package/modules/eclickadsBidAdapter.md +55 -0
  197. package/modules/eightPodAnalyticsAdapter.js +13 -1
  198. package/modules/gumgumBidAdapter.js +6 -2
  199. package/modules/ixBidAdapter.js +0 -1
  200. package/modules/limelightDigitalBidAdapter.js +1 -1
  201. package/modules/mediagoBidAdapter.js +2 -4
  202. package/modules/mgidBidAdapter.js +30 -109
  203. package/modules/mgidXBidAdapter.js +2 -66
  204. package/modules/mobianRtdProvider.js +12 -8
  205. package/modules/naveggIdSystem.js +62 -58
  206. package/modules/naveggIdSystem.md +8 -0
  207. package/modules/oguryBidAdapter.js +5 -2
  208. package/modules/omsBidAdapter.js +1 -1
  209. package/modules/openxBidAdapter.js +1 -6
  210. package/modules/pstudioBidAdapter.js +5 -8
  211. package/modules/pstudioBidAdapter.md +6 -4
  212. package/modules/pubriseBidAdapter.js +19 -0
  213. package/modules/pubriseBidAdapter.md +79 -0
  214. package/modules/pubxaiAnalyticsAdapter.js +9 -4
  215. package/modules/pubxaiRtdProvider.js +38 -18
  216. package/modules/pubxaiRtdProvider.md +2 -2
  217. package/modules/redtramBidAdapter.js +2 -6
  218. package/modules/richaudienceBidAdapter.js +8 -1
  219. package/modules/rubiconBidAdapter.js +3 -3
  220. package/modules/smarthubBidAdapter.js +2 -0
  221. package/modules/targetVideoAdServerVideo.js +96 -0
  222. package/modules/targetVideoAdServerVideo.md +26 -0
  223. package/modules/teadsBidAdapter.js +4 -3
  224. package/modules/undertoneBidAdapter.js +1 -19
  225. package/modules/userId/index.js +1 -1
  226. package/package.json +1 -1
  227. package/src/adRendering.js +3 -0
  228. package/src/adapterManager.js +4 -0
  229. package/src/utils/focusTimeout.js +17 -6
  230. package/src/utils/ttlCollection.js +1 -1
  231. package/src/utils.js +28 -0
  232. package/test/spec/modules/admixerBidAdapter_spec.js +2 -2
  233. package/test/spec/modules/ccxBidAdapter_spec.js +81 -0
  234. package/test/spec/modules/contxtfulRtdProvider_spec.js +19 -19
  235. package/test/spec/modules/dailymotionBidAdapter_spec.js +12 -12
  236. package/test/spec/modules/discoveryBidAdapter_spec.js +1 -47
  237. package/test/spec/modules/docereeAdManagerBidAdapter_spec.js +87 -9
  238. package/test/spec/modules/eclickadsBidAdapter_spec.js +214 -0
  239. package/test/spec/modules/ixBidAdapter_spec.js +8 -1
  240. package/test/spec/modules/mobianRtdProvider_spec.js +32 -15
  241. package/test/spec/modules/naveggIdSystem_spec.js +141 -31
  242. package/test/spec/modules/oguryBidAdapter_spec.js +50 -4
  243. package/test/spec/modules/openxBidAdapter_spec.js +16 -49
  244. package/test/spec/modules/pstudioBidAdapter_spec.js +5 -5
  245. package/test/spec/modules/pubriseBidAdapter_spec.js +514 -0
  246. package/test/spec/modules/pubxaiAnalyticsAdapter_spec.js +9 -4
  247. package/test/spec/modules/pubxaiRtdProvider_spec.js +37 -5
  248. package/test/spec/modules/richaudienceBidAdapter_spec.js +62 -0
  249. package/test/spec/modules/rubiconBidAdapter_spec.js +10 -0
  250. package/test/spec/modules/targetVideoAdServerVideo_spec.js +179 -0
  251. package/test/spec/modules/trafficgateBidAdapter_spec.js +1 -1
  252. package/test/spec/ortbConverter/userId_spec.js +23 -2
  253. package/test/spec/unit/adRendering_spec.js +27 -1
  254. package/test/spec/unit/core/adapterManager_spec.js +10 -0
  255. package/test/spec/unit/utils/focusTimeout_spec.js +33 -6
@@ -0,0 +1,514 @@
1
+ import { expect } from 'chai';
2
+ import { spec } from '../../../modules/pubriseBidAdapter.js';
3
+ import { BANNER, VIDEO, NATIVE } from '../../../src/mediaTypes.js';
4
+ import { getUniqueIdentifierStr } from '../../../src/utils.js';
5
+
6
+ const bidder = 'pubrise';
7
+
8
+ describe('PubriseBidAdapter', function () {
9
+ const userIdAsEids = [{
10
+ source: 'test.org',
11
+ uids: [{
12
+ id: '01**********',
13
+ atype: 1,
14
+ ext: {
15
+ third: '01***********'
16
+ }
17
+ }]
18
+ }];
19
+ const bids = [
20
+ {
21
+ bidId: getUniqueIdentifierStr(),
22
+ bidder: bidder,
23
+ mediaTypes: {
24
+ [BANNER]: {
25
+ sizes: [[300, 250]]
26
+ }
27
+ },
28
+ params: {
29
+ placementId: 'testBanner'
30
+ },
31
+ userIdAsEids
32
+ },
33
+ {
34
+ bidId: getUniqueIdentifierStr(),
35
+ bidder: bidder,
36
+ mediaTypes: {
37
+ [VIDEO]: {
38
+ playerSize: [[300, 300]],
39
+ minduration: 5,
40
+ maxduration: 60
41
+ }
42
+ },
43
+ params: {
44
+ placementId: 'testVideo'
45
+ },
46
+ userIdAsEids
47
+ },
48
+ {
49
+ bidId: getUniqueIdentifierStr(),
50
+ bidder: bidder,
51
+ mediaTypes: {
52
+ [NATIVE]: {
53
+ native: {
54
+ title: {
55
+ required: true
56
+ },
57
+ body: {
58
+ required: true
59
+ },
60
+ icon: {
61
+ required: true,
62
+ size: [64, 64]
63
+ }
64
+ }
65
+ }
66
+ },
67
+ params: {
68
+ placementId: 'testNative'
69
+ },
70
+ userIdAsEids
71
+ }
72
+ ];
73
+
74
+ const invalidBid = {
75
+ bidId: getUniqueIdentifierStr(),
76
+ bidder: bidder,
77
+ mediaTypes: {
78
+ [BANNER]: {
79
+ sizes: [[300, 250]]
80
+ }
81
+ },
82
+ params: {
83
+
84
+ }
85
+ }
86
+
87
+ const bidderRequest = {
88
+ uspConsent: '1---',
89
+ gdprConsent: {
90
+ consentString: 'COvFyGBOvFyGBAbAAAENAPCAAOAAAAAAAAAAAEEUACCKAAA.IFoEUQQgAIQwgIwQABAEAAAAOIAACAIAAAAQAIAgEAACEAAAAAgAQBAAAAAAAGBAAgAAAAAAAFAAECAAAgAAQARAEQAAAAAJAAIAAgAAAYQEAAAQmAgBC3ZAYzUw',
91
+ vendorData: {}
92
+ },
93
+ refererInfo: {
94
+ referer: 'https://test.com',
95
+ page: 'https://test.com'
96
+ },
97
+ ortb2: {
98
+ device: {
99
+ w: 1512,
100
+ h: 982,
101
+ language: 'en-UK'
102
+ }
103
+ },
104
+ timeout: 500
105
+ };
106
+
107
+ describe('isBidRequestValid', function () {
108
+ it('Should return true if there are bidId, params and key parameters present', function () {
109
+ expect(spec.isBidRequestValid(bids[0])).to.be.true;
110
+ });
111
+ it('Should return false if at least one of parameters is not present', function () {
112
+ expect(spec.isBidRequestValid(invalidBid)).to.be.false;
113
+ });
114
+ });
115
+
116
+ describe('buildRequests', function () {
117
+ let serverRequest = spec.buildRequests(bids, bidderRequest);
118
+
119
+ it('Creates a ServerRequest object with method, URL and data', function () {
120
+ expect(serverRequest).to.exist;
121
+ expect(serverRequest.method).to.exist;
122
+ expect(serverRequest.url).to.exist;
123
+ expect(serverRequest.data).to.exist;
124
+ });
125
+
126
+ it('Returns POST method', function () {
127
+ expect(serverRequest.method).to.equal('POST');
128
+ });
129
+
130
+ it('Returns valid URL', function () {
131
+ expect(serverRequest.url).to.equal('https://backend.pubrise.ai/pbjs');
132
+ });
133
+
134
+ it('Returns general data valid', function () {
135
+ let data = serverRequest.data;
136
+ expect(data).to.be.an('object');
137
+ expect(data).to.have.all.keys(
138
+ 'deviceWidth',
139
+ 'deviceHeight',
140
+ 'language',
141
+ 'secure',
142
+ 'host',
143
+ 'page',
144
+ 'placements',
145
+ 'coppa',
146
+ 'ccpa',
147
+ 'gdpr',
148
+ 'tmax'
149
+ );
150
+ expect(data.deviceWidth).to.be.a('number');
151
+ expect(data.deviceHeight).to.be.a('number');
152
+ expect(data.language).to.be.a('string');
153
+ expect(data.secure).to.be.within(0, 1);
154
+ expect(data.host).to.be.a('string');
155
+ expect(data.page).to.be.a('string');
156
+ expect(data.coppa).to.be.a('number');
157
+ expect(data.gdpr).to.be.a('object');
158
+ expect(data.ccpa).to.be.a('string');
159
+ expect(data.tmax).to.be.a('number');
160
+ expect(data.placements).to.have.lengthOf(3);
161
+ });
162
+
163
+ it('Returns valid placements', function () {
164
+ const { placements } = serverRequest.data;
165
+ for (let i = 0, len = placements.length; i < len; i++) {
166
+ const placement = placements[i];
167
+ expect(placement.placementId).to.be.oneOf(['testBanner', 'testVideo', 'testNative']);
168
+ expect(placement.adFormat).to.be.oneOf([BANNER, VIDEO, NATIVE]);
169
+ expect(placement.bidId).to.be.a('string');
170
+ expect(placement.schain).to.be.an('object');
171
+ expect(placement.bidfloor).to.exist.and.to.equal(0);
172
+ expect(placement.type).to.exist.and.to.equal('publisher');
173
+ expect(placement.eids).to.exist.and.to.be.deep.equal(userIdAsEids);
174
+
175
+ if (placement.adFormat === BANNER) {
176
+ expect(placement.sizes).to.be.an('array');
177
+ }
178
+ switch (placement.adFormat) {
179
+ case BANNER:
180
+ expect(placement.sizes).to.be.an('array');
181
+ break;
182
+ case VIDEO:
183
+ expect(placement.playerSize).to.be.an('array');
184
+ expect(placement.minduration).to.be.an('number');
185
+ expect(placement.maxduration).to.be.an('number');
186
+ break;
187
+ case NATIVE:
188
+ expect(placement.native).to.be.an('object');
189
+ break;
190
+ }
191
+ }
192
+ });
193
+
194
+ it('Returns valid endpoints', function () {
195
+ const bids = [
196
+ {
197
+ bidId: getUniqueIdentifierStr(),
198
+ bidder: bidder,
199
+ mediaTypes: {
200
+ [BANNER]: {
201
+ sizes: [[300, 250]]
202
+ }
203
+ },
204
+ params: {
205
+ endpointId: 'testBanner',
206
+ },
207
+ userIdAsEids
208
+ }
209
+ ];
210
+
211
+ let serverRequest = spec.buildRequests(bids, bidderRequest);
212
+
213
+ const { placements } = serverRequest.data;
214
+ for (let i = 0, len = placements.length; i < len; i++) {
215
+ const placement = placements[i];
216
+ expect(placement.endpointId).to.be.oneOf(['testBanner', 'testVideo', 'testNative']);
217
+ expect(placement.adFormat).to.be.oneOf([BANNER, VIDEO, NATIVE]);
218
+ expect(placement.bidId).to.be.a('string');
219
+ expect(placement.schain).to.be.an('object');
220
+ expect(placement.bidfloor).to.exist.and.to.equal(0);
221
+ expect(placement.type).to.exist.and.to.equal('network');
222
+ expect(placement.eids).to.exist.and.to.be.deep.equal(userIdAsEids);
223
+
224
+ if (placement.adFormat === BANNER) {
225
+ expect(placement.sizes).to.be.an('array');
226
+ }
227
+ switch (placement.adFormat) {
228
+ case BANNER:
229
+ expect(placement.sizes).to.be.an('array');
230
+ break;
231
+ case VIDEO:
232
+ expect(placement.playerSize).to.be.an('array');
233
+ expect(placement.minduration).to.be.an('number');
234
+ expect(placement.maxduration).to.be.an('number');
235
+ break;
236
+ case NATIVE:
237
+ expect(placement.native).to.be.an('object');
238
+ break;
239
+ }
240
+ }
241
+ });
242
+
243
+ it('Returns data with gdprConsent and without uspConsent', function () {
244
+ delete bidderRequest.uspConsent;
245
+ serverRequest = spec.buildRequests(bids, bidderRequest);
246
+ let data = serverRequest.data;
247
+ expect(data.gdpr).to.exist;
248
+ expect(data.gdpr).to.be.a('object');
249
+ expect(data.gdpr).to.have.property('consentString');
250
+ expect(data.gdpr).to.not.have.property('vendorData');
251
+ expect(data.gdpr.consentString).to.equal(bidderRequest.gdprConsent.consentString);
252
+ expect(data.ccpa).to.not.exist;
253
+ delete bidderRequest.gdprConsent;
254
+ });
255
+
256
+ it('Returns data with uspConsent and without gdprConsent', function () {
257
+ bidderRequest.uspConsent = '1---';
258
+ delete bidderRequest.gdprConsent;
259
+ serverRequest = spec.buildRequests(bids, bidderRequest);
260
+ let data = serverRequest.data;
261
+ expect(data.ccpa).to.exist;
262
+ expect(data.ccpa).to.be.a('string');
263
+ expect(data.ccpa).to.equal(bidderRequest.uspConsent);
264
+ expect(data.gdpr).to.not.exist;
265
+ });
266
+ });
267
+
268
+ describe('gpp consent', function () {
269
+ it('bidderRequest.gppConsent', () => {
270
+ bidderRequest.gppConsent = {
271
+ gppString: 'abc123',
272
+ applicableSections: [8]
273
+ };
274
+
275
+ let serverRequest = spec.buildRequests(bids, bidderRequest);
276
+ let data = serverRequest.data;
277
+ expect(data).to.be.an('object');
278
+ expect(data).to.have.property('gpp');
279
+ expect(data).to.have.property('gpp_sid');
280
+
281
+ delete bidderRequest.gppConsent;
282
+ })
283
+
284
+ it('bidderRequest.ortb2.regs.gpp', () => {
285
+ bidderRequest.ortb2 = bidderRequest.ortb2 || {};
286
+ bidderRequest.ortb2.regs = bidderRequest.ortb2.regs || {};
287
+ bidderRequest.ortb2.regs.gpp = 'abc123';
288
+ bidderRequest.ortb2.regs.gpp_sid = [8];
289
+
290
+ let serverRequest = spec.buildRequests(bids, bidderRequest);
291
+ let data = serverRequest.data;
292
+ expect(data).to.be.an('object');
293
+ expect(data).to.have.property('gpp');
294
+ expect(data).to.have.property('gpp_sid');
295
+
296
+ bidderRequest.ortb2;
297
+ })
298
+ });
299
+
300
+ describe('interpretResponse', function () {
301
+ it('Should interpret banner response', function () {
302
+ const banner = {
303
+ body: [{
304
+ mediaType: 'banner',
305
+ width: 300,
306
+ height: 250,
307
+ cpm: 0.4,
308
+ ad: 'Test',
309
+ requestId: '23fhj33i987f',
310
+ ttl: 120,
311
+ creativeId: '2',
312
+ netRevenue: true,
313
+ currency: 'USD',
314
+ dealId: '1',
315
+ meta: {
316
+ advertiserDomains: ['google.com'],
317
+ advertiserId: 1234
318
+ }
319
+ }]
320
+ };
321
+ let bannerResponses = spec.interpretResponse(banner);
322
+ expect(bannerResponses).to.be.an('array').that.is.not.empty;
323
+ let dataItem = bannerResponses[0];
324
+ expect(dataItem).to.have.all.keys('requestId', 'cpm', 'width', 'height', 'ad', 'ttl', 'creativeId',
325
+ 'netRevenue', 'currency', 'dealId', 'mediaType', 'meta');
326
+ expect(dataItem.requestId).to.equal(banner.body[0].requestId);
327
+ expect(dataItem.cpm).to.equal(banner.body[0].cpm);
328
+ expect(dataItem.width).to.equal(banner.body[0].width);
329
+ expect(dataItem.height).to.equal(banner.body[0].height);
330
+ expect(dataItem.ad).to.equal(banner.body[0].ad);
331
+ expect(dataItem.ttl).to.equal(banner.body[0].ttl);
332
+ expect(dataItem.creativeId).to.equal(banner.body[0].creativeId);
333
+ expect(dataItem.netRevenue).to.be.true;
334
+ expect(dataItem.currency).to.equal(banner.body[0].currency);
335
+ expect(dataItem.meta).to.be.an('object').that.has.any.key('advertiserDomains');
336
+ });
337
+ it('Should interpret video response', function () {
338
+ const video = {
339
+ body: [{
340
+ vastUrl: 'test.com',
341
+ mediaType: 'video',
342
+ cpm: 0.5,
343
+ requestId: '23fhj33i987f',
344
+ ttl: 120,
345
+ creativeId: '2',
346
+ netRevenue: true,
347
+ currency: 'USD',
348
+ dealId: '1',
349
+ meta: {
350
+ advertiserDomains: ['google.com'],
351
+ advertiserId: 1234
352
+ }
353
+ }]
354
+ };
355
+ let videoResponses = spec.interpretResponse(video);
356
+ expect(videoResponses).to.be.an('array').that.is.not.empty;
357
+
358
+ let dataItem = videoResponses[0];
359
+ expect(dataItem).to.have.all.keys('requestId', 'cpm', 'vastUrl', 'ttl', 'creativeId',
360
+ 'netRevenue', 'currency', 'dealId', 'mediaType', 'meta');
361
+ expect(dataItem.requestId).to.equal('23fhj33i987f');
362
+ expect(dataItem.cpm).to.equal(0.5);
363
+ expect(dataItem.vastUrl).to.equal('test.com');
364
+ expect(dataItem.ttl).to.equal(120);
365
+ expect(dataItem.creativeId).to.equal('2');
366
+ expect(dataItem.netRevenue).to.be.true;
367
+ expect(dataItem.currency).to.equal('USD');
368
+ expect(dataItem.meta).to.be.an('object').that.has.any.key('advertiserDomains');
369
+ });
370
+ it('Should interpret native response', function () {
371
+ const native = {
372
+ body: [{
373
+ mediaType: 'native',
374
+ native: {
375
+ clickUrl: 'test.com',
376
+ title: 'Test',
377
+ image: 'test.com',
378
+ impressionTrackers: ['test.com'],
379
+ },
380
+ ttl: 120,
381
+ cpm: 0.4,
382
+ requestId: '23fhj33i987f',
383
+ creativeId: '2',
384
+ netRevenue: true,
385
+ currency: 'USD',
386
+ meta: {
387
+ advertiserDomains: ['google.com'],
388
+ advertiserId: 1234
389
+ }
390
+ }]
391
+ };
392
+ let nativeResponses = spec.interpretResponse(native);
393
+ expect(nativeResponses).to.be.an('array').that.is.not.empty;
394
+
395
+ let dataItem = nativeResponses[0];
396
+ expect(dataItem).to.have.keys('requestId', 'cpm', 'ttl', 'creativeId', 'netRevenue', 'currency', 'mediaType', 'native', 'meta');
397
+ expect(dataItem.native).to.have.keys('clickUrl', 'impressionTrackers', 'title', 'image')
398
+ expect(dataItem.requestId).to.equal('23fhj33i987f');
399
+ expect(dataItem.cpm).to.equal(0.4);
400
+ expect(dataItem.native.clickUrl).to.equal('test.com');
401
+ expect(dataItem.native.title).to.equal('Test');
402
+ expect(dataItem.native.image).to.equal('test.com');
403
+ expect(dataItem.native.impressionTrackers).to.be.an('array').that.is.not.empty;
404
+ expect(dataItem.native.impressionTrackers[0]).to.equal('test.com');
405
+ expect(dataItem.ttl).to.equal(120);
406
+ expect(dataItem.creativeId).to.equal('2');
407
+ expect(dataItem.netRevenue).to.be.true;
408
+ expect(dataItem.currency).to.equal('USD');
409
+ expect(dataItem.meta).to.be.an('object').that.has.any.key('advertiserDomains');
410
+ });
411
+ it('Should return an empty array if invalid banner response is passed', function () {
412
+ const invBanner = {
413
+ body: [{
414
+ width: 300,
415
+ cpm: 0.4,
416
+ ad: 'Test',
417
+ requestId: '23fhj33i987f',
418
+ ttl: 120,
419
+ creativeId: '2',
420
+ netRevenue: true,
421
+ currency: 'USD',
422
+ dealId: '1'
423
+ }]
424
+ };
425
+
426
+ let serverResponses = spec.interpretResponse(invBanner);
427
+ expect(serverResponses).to.be.an('array').that.is.empty;
428
+ });
429
+ it('Should return an empty array if invalid video response is passed', function () {
430
+ const invVideo = {
431
+ body: [{
432
+ mediaType: 'video',
433
+ cpm: 0.5,
434
+ requestId: '23fhj33i987f',
435
+ ttl: 120,
436
+ creativeId: '2',
437
+ netRevenue: true,
438
+ currency: 'USD',
439
+ dealId: '1'
440
+ }]
441
+ };
442
+ let serverResponses = spec.interpretResponse(invVideo);
443
+ expect(serverResponses).to.be.an('array').that.is.empty;
444
+ });
445
+ it('Should return an empty array if invalid native response is passed', function () {
446
+ const invNative = {
447
+ body: [{
448
+ mediaType: 'native',
449
+ clickUrl: 'test.com',
450
+ title: 'Test',
451
+ impressionTrackers: ['test.com'],
452
+ ttl: 120,
453
+ requestId: '23fhj33i987f',
454
+ creativeId: '2',
455
+ netRevenue: true,
456
+ currency: 'USD',
457
+ }]
458
+ };
459
+ let serverResponses = spec.interpretResponse(invNative);
460
+ expect(serverResponses).to.be.an('array').that.is.empty;
461
+ });
462
+ it('Should return an empty array if invalid response is passed', function () {
463
+ const invalid = {
464
+ body: [{
465
+ ttl: 120,
466
+ creativeId: '2',
467
+ netRevenue: true,
468
+ currency: 'USD',
469
+ dealId: '1'
470
+ }]
471
+ };
472
+ let serverResponses = spec.interpretResponse(invalid);
473
+ expect(serverResponses).to.be.an('array').that.is.empty;
474
+ });
475
+ });
476
+
477
+ describe('getUserSyncs', function() {
478
+ it('Should return array of objects with proper sync config , include GDPR', function() {
479
+ const syncData = spec.getUserSyncs({}, {}, {
480
+ consentString: 'ALL',
481
+ gdprApplies: true,
482
+ }, {});
483
+ expect(syncData).to.be.an('array').which.is.not.empty;
484
+ expect(syncData[0]).to.be.an('object')
485
+ expect(syncData[0].type).to.be.a('string')
486
+ expect(syncData[0].type).to.equal('image')
487
+ expect(syncData[0].url).to.be.a('string')
488
+ expect(syncData[0].url).to.equal('https://sync.pubrise.ai/image?pbjs=1&gdpr=1&gdpr_consent=ALL&coppa=0')
489
+ });
490
+ it('Should return array of objects with proper sync config , include CCPA', function() {
491
+ const syncData = spec.getUserSyncs({}, {}, {}, {
492
+ consentString: '1---'
493
+ });
494
+ expect(syncData).to.be.an('array').which.is.not.empty;
495
+ expect(syncData[0]).to.be.an('object')
496
+ expect(syncData[0].type).to.be.a('string')
497
+ expect(syncData[0].type).to.equal('image')
498
+ expect(syncData[0].url).to.be.a('string')
499
+ expect(syncData[0].url).to.equal('https://sync.pubrise.ai/image?pbjs=1&ccpa_consent=1---&coppa=0')
500
+ });
501
+ it('Should return array of objects with proper sync config , include GPP', function() {
502
+ const syncData = spec.getUserSyncs({}, {}, {}, {}, {
503
+ gppString: 'abc123',
504
+ applicableSections: [8]
505
+ });
506
+ expect(syncData).to.be.an('array').which.is.not.empty;
507
+ expect(syncData[0]).to.be.an('object')
508
+ expect(syncData[0].type).to.be.a('string')
509
+ expect(syncData[0].type).to.equal('image')
510
+ expect(syncData[0].url).to.be.a('string')
511
+ expect(syncData[0].url).to.equal('https://sync.pubrise.ai/image?pbjs=1&gpp=abc123&gpp_sid=8&coppa=0')
512
+ });
513
+ });
514
+ });
@@ -31,9 +31,10 @@ describe('pubxai analytics adapter', () => {
31
31
  });
32
32
 
33
33
  describe('track', () => {
34
+ const pubxId = '6c415fc0-8b0e-4cf5-be73-01526a4db625';
34
35
  let initOptions = {
35
36
  samplingRate: '1',
36
- pubxId: '6c415fc0-8b0e-4cf5-be73-01526a4db625',
37
+ pubxId: pubxId,
37
38
  };
38
39
 
39
40
  let originalVS;
@@ -148,7 +149,7 @@ describe('pubxai analytics adapter', () => {
148
149
  timeout: 1000,
149
150
  config: {
150
151
  samplingRate: '1',
151
- pubxId: '6c415fc0-8b0e-4cf5-be73-01526a4db625',
152
+ pubxId: pubxId,
152
153
  },
153
154
  },
154
155
  bidRequested: {
@@ -529,7 +530,7 @@ describe('pubxai analytics adapter', () => {
529
530
  null,
530
531
  auctionId: 'bc3806e4-873e-453c-8ae5-204f35e923b4',
531
532
  sizes: '300x250',
532
- renderStatus: 2,
533
+ bidType: 2,
533
534
  requestTimestamp: 1616654312804,
534
535
  creativeId: 96846035,
535
536
  currency: 'USD',
@@ -651,7 +652,7 @@ describe('pubxai analytics adapter', () => {
651
652
  placementId: 13144370,
652
653
  renderedSize: '300x250',
653
654
  sizes: '300x250',
654
- renderStatus: 4,
655
+ bidType: 4,
655
656
  responseTimestamp: 1616654313071,
656
657
  requestTimestamp: 1616654312804,
657
658
  status: 'rendered',
@@ -764,6 +765,7 @@ describe('pubxai analytics adapter', () => {
764
765
  auctionTimestamp: '1616654312804',
765
766
  pubxaiAnalyticsVersion: 'v2.0.0',
766
767
  prebidVersion: '$prebid.version$',
768
+ pubxId: pubxId,
767
769
  });
768
770
  expect(expectedData.type).to.equal('text/json');
769
771
  expect(JSON.parse(await readBlobSafariCompat(expectedData))).to.deep.equal([
@@ -807,6 +809,7 @@ describe('pubxai analytics adapter', () => {
807
809
  auctionTimestamp: '1616654312804',
808
810
  pubxaiAnalyticsVersion: 'v2.0.0',
809
811
  prebidVersion: '$prebid.version$',
812
+ pubxId: pubxId,
810
813
  });
811
814
 
812
815
  // Step 9: check that the data sent in the request is correct
@@ -932,6 +935,7 @@ describe('pubxai analytics adapter', () => {
932
935
  auctionTimestamp: '1616654312804',
933
936
  pubxaiAnalyticsVersion: 'v2.0.0',
934
937
  prebidVersion: '$prebid.version$',
938
+ pubxId: pubxId,
935
939
  });
936
940
  expect(expectedData.type).to.equal('text/json');
937
941
  expect(JSON.parse(await readBlobSafariCompat(expectedData))).to.deep.equal([
@@ -1048,6 +1052,7 @@ describe('pubxai analytics adapter', () => {
1048
1052
  auctionTimestamp: '1616654312804',
1049
1053
  pubxaiAnalyticsVersion: 'v2.0.0',
1050
1054
  prebidVersion: '$prebid.version$',
1055
+ pubxId: pubxId,
1051
1056
  });
1052
1057
  expect(expectedData.type).to.equal('text/json');
1053
1058
  expect(JSON.parse(await readBlobSafariCompat(expectedData))).to.deep.equal([
@@ -1,6 +1,7 @@
1
1
  import * as priceFloors from '../../../modules/priceFloors';
2
2
  import {
3
3
  FLOORS_END_POINT,
4
+ storage,
4
5
  FLOORS_EVENT_HANDLE,
5
6
  FloorsApiStatus,
6
7
  beforeInit,
@@ -45,6 +46,7 @@ const resetGlobals = () => {
45
46
  window.__pubxFloorsConfig__ = undefined;
46
47
  window.__pubxFloorsApiStatus__ = undefined;
47
48
  window.__pubxFloorRulesPromise__ = null;
49
+ localStorage.removeItem('pubx:dynamicFloors');
48
50
  };
49
51
 
50
52
  const fakeServer = (
@@ -119,7 +121,7 @@ describe('pubxaiRtdProvider', () => {
119
121
  stub.restore();
120
122
  });
121
123
  it('createFloorsDataForAuction called once before and once after __pubxFloorRulesPromise__. Also getBidRequestData executed only once', async () => {
122
- pubxaiSubmodule.getBidRequestData(reqBidsConfigObj, () => {});
124
+ pubxaiSubmodule.getBidRequestData(reqBidsConfigObj, () => { });
123
125
  assert(priceFloors.createFloorsDataForAuction.calledOnce);
124
126
  await window.__pubxFloorRulesPromise__;
125
127
  assert(priceFloors.createFloorsDataForAuction.calledTwice);
@@ -129,7 +131,7 @@ describe('pubxaiRtdProvider', () => {
129
131
  reqBidsConfigObj.auctionId
130
132
  )
131
133
  );
132
- pubxaiSubmodule.getBidRequestData(reqBidsConfigObj, () => {});
134
+ pubxaiSubmodule.getBidRequestData(reqBidsConfigObj, () => { });
133
135
  await window.__pubxFloorRulesPromise__;
134
136
  assert(priceFloors.createFloorsDataForAuction.calledTwice);
135
137
  });
@@ -137,6 +139,16 @@ describe('pubxaiRtdProvider', () => {
137
139
  describe('fetchFloorRules', () => {
138
140
  const providerConfig = getConfig();
139
141
  const floorsResponse = getFloorsResponse();
142
+ let storageStub;
143
+
144
+ beforeEach(() => {
145
+ storageStub = sinon.stub(storage, 'getDataFromSessionStorage');
146
+ });
147
+
148
+ afterEach(() => {
149
+ storageStub.restore();
150
+ });
151
+
140
152
  it('success with floors response', (done) => {
141
153
  const promise = fetchFloorRules(providerConfig);
142
154
  fakeServer(floorsResponse);
@@ -145,6 +157,7 @@ describe('pubxaiRtdProvider', () => {
145
157
  done();
146
158
  });
147
159
  });
160
+
148
161
  it('success with no floors response', (done) => {
149
162
  const promise = fetchFloorRules(providerConfig);
150
163
  fakeServer(undefined);
@@ -153,6 +166,7 @@ describe('pubxaiRtdProvider', () => {
153
166
  done();
154
167
  });
155
168
  });
169
+
156
170
  it('API call error', (done) => {
157
171
  const promise = fetchFloorRules(providerConfig);
158
172
  fakeServer(undefined, undefined, 404);
@@ -167,6 +181,7 @@ describe('pubxaiRtdProvider', () => {
167
181
  done();
168
182
  });
169
183
  });
184
+
170
185
  it('Wrong API response', (done) => {
171
186
  const promise = fetchFloorRules(providerConfig);
172
187
  fakeServer('floorsResponse');
@@ -181,6 +196,25 @@ describe('pubxaiRtdProvider', () => {
181
196
  done();
182
197
  });
183
198
  });
199
+
200
+ it('success with local data response', (done) => {
201
+ const localFloorsResponse = getFloorsResponse();
202
+ storageStub.withArgs('pubx:dynamicFloors').returns(JSON.stringify(localFloorsResponse));
203
+ const promise = fetchFloorRules({ params: {} });
204
+ promise.then((res) => {
205
+ expect(res).to.deep.equal(localFloorsResponse);
206
+ done();
207
+ });
208
+ });
209
+
210
+ it('no local data response', (done) => {
211
+ storageStub.withArgs('pubx:dynamicFloors').returns(null);
212
+ const promise = fetchFloorRules({ params: {} });
213
+ promise.then((res) => {
214
+ expect(res).to.deep.equal(null);
215
+ done();
216
+ });
217
+ });
184
218
  });
185
219
  describe('setPriceFloors', () => {
186
220
  const providerConfig = getConfig();
@@ -383,9 +417,7 @@ describe('pubxaiRtdProvider', () => {
383
417
  expect(FLOORS_END_POINT).to.equal('https://floor.pbxai.com/');
384
418
  });
385
419
  it('standard case', () => {
386
- expect(getUrl(provider)).to.equal(
387
- `https://floor.pbxai.com/?pubxId=12345&page=${window.location.href}`
388
- );
420
+ expect(getUrl(provider)).to.equal(null);
389
421
  });
390
422
  it('custom url provided', () => {
391
423
  provider.params.endpoint = 'https://custom.floor.com/';