prebid.js 8.40.0 → 8.41.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 (199) hide show
  1. package/dist/33acrossAnalyticsAdapter.js +1 -1
  2. package/dist/33acrossBidAdapter.js +1 -1
  3. package/dist/33acrossIdSystem.js +1 -1
  4. package/dist/BTBidAdapter.js +1 -1
  5. package/dist/adagioAnalyticsAdapter.js +1 -1
  6. package/dist/adagioBidAdapter.js +1 -1
  7. package/dist/adbookpspBidAdapter.js +1 -1
  8. package/dist/adgenerationBidAdapter.js +1 -1
  9. package/dist/adkernelBidAdapter.js +1 -1
  10. package/dist/adqueryBidAdapter.js +1 -1
  11. package/dist/adrelevantisBidAdapter.js +1 -1
  12. package/dist/adstirBidAdapter.js +1 -1
  13. package/dist/adtrgtmeBidAdapter.js +1 -1
  14. package/dist/adxcgBidAdapter.js +1 -1
  15. package/dist/adyoulikeBidAdapter.js +1 -1
  16. package/dist/agmaAnalyticsAdapter.js +1 -1
  17. package/dist/ajaBidAdapter.js +1 -1
  18. package/dist/amxBidAdapter.js +1 -1
  19. package/dist/amxIdSystem.js +1 -1
  20. package/dist/appierAnalyticsAdapter.js +1 -1
  21. package/dist/appnexusBidAdapter.js +1 -1
  22. package/dist/asoBidAdapter.js +1 -1
  23. package/dist/automatadAnalyticsAdapter.js +1 -1
  24. package/dist/axonixBidAdapter.js +1 -1
  25. package/dist/bidglassBidAdapter.js +1 -1
  26. package/dist/big-richmediaBidAdapter.js +1 -1
  27. package/dist/bridBidAdapter.js +1 -1
  28. package/dist/bridgewellBidAdapter.js +1 -1
  29. package/dist/brightMountainMediaBidAdapter.js +1 -1
  30. package/dist/carodaBidAdapter.js +1 -1
  31. package/dist/chtnwBidAdapter.js +1 -1
  32. package/dist/concertBidAdapter.js +1 -1
  33. package/dist/connectadBidAdapter.js +1 -1
  34. package/dist/consumableBidAdapter.js +1 -1
  35. package/dist/conversantAnalyticsAdapter.js +1 -1
  36. package/dist/conversantBidAdapter.js +1 -1
  37. package/dist/craftBidAdapter.js +1 -1
  38. package/dist/criteoBidAdapter.js +1 -1
  39. package/dist/cwireBidAdapter.js +1 -1
  40. package/dist/discoveryBidAdapter.js +1 -1
  41. package/dist/dspxBidAdapter.js +1 -1
  42. package/dist/dxkultureBidAdapter.js +1 -1
  43. package/dist/eplanningBidAdapter.js +1 -1
  44. package/dist/euidIdSystem.js +1 -1
  45. package/dist/feedadBidAdapter.js +1 -1
  46. package/dist/finativeBidAdapter.js +1 -1
  47. package/dist/freewheel-sspBidAdapter.js +1 -1
  48. package/dist/gmosspBidAdapter.js +1 -1
  49. package/dist/goldbachBidAdapter.js +1 -1
  50. package/dist/greenbidsAnalyticsAdapter.js +1 -1
  51. package/dist/greenbidsRtdProvider.js +1 -1
  52. package/dist/gridBidAdapter.js +1 -1
  53. package/dist/gumgumBidAdapter.js +1 -1
  54. package/dist/h12mediaBidAdapter.js +1 -1
  55. package/dist/hypelabBidAdapter.js +1 -1
  56. package/dist/id5IdSystem.js +1 -1
  57. package/dist/illuminBidAdapter.js +1 -1
  58. package/dist/imdsBidAdapter.js +1 -1
  59. package/dist/improvedigitalBidAdapter.js +1 -1
  60. package/dist/insticatorBidAdapter.js +1 -1
  61. package/dist/ixBidAdapter.js +1 -1
  62. package/dist/jixieBidAdapter.js +1 -1
  63. package/dist/justpremiumBidAdapter.js +1 -1
  64. package/dist/kargoBidAdapter.js +1 -1
  65. package/dist/kimberliteBidAdapter.js +1 -1
  66. package/dist/konduitAnalyticsAdapter.js +1 -1
  67. package/dist/kueezBidAdapter.js +1 -1
  68. package/dist/kueezRtbBidAdapter.js +1 -1
  69. package/dist/lassoBidAdapter.js +1 -1
  70. package/dist/lifestreetBidAdapter.js +1 -1
  71. package/dist/liveIntentIdSystem.js +1 -1
  72. package/dist/logicadBidAdapter.js +1 -1
  73. package/dist/loglyliftBidAdapter.js +1 -1
  74. package/dist/luceadBidAdapter.js +1 -1
  75. package/dist/magniteAnalyticsAdapter.js +1 -1
  76. package/dist/malltvAnalyticsAdapter.js +1 -1
  77. package/dist/marsmediaBidAdapter.js +1 -1
  78. package/dist/mediafuseBidAdapter.js +1 -1
  79. package/dist/mediasquareBidAdapter.js +1 -1
  80. package/dist/mgidBidAdapter.js +1 -1
  81. package/dist/minutemediaBidAdapter.js +1 -1
  82. package/dist/minutemediaplusBidAdapter.js +1 -1
  83. package/dist/missenaBidAdapter.js +1 -1
  84. package/dist/nextMillenniumBidAdapter.js +1 -1
  85. package/dist/nexx360BidAdapter.js +1 -1
  86. package/dist/not-for-prod/prebid.js +155 -153
  87. package/dist/oguryBidAdapter.js +1 -1
  88. package/dist/onetagBidAdapter.js +1 -1
  89. package/dist/ooloAnalyticsAdapter.js +1 -1
  90. package/dist/openxBidAdapter.js +1 -1
  91. package/dist/optidigitalBidAdapter.js +1 -1
  92. package/dist/outbrainBidAdapter.js +1 -1
  93. package/dist/parrableIdSystem.js +1 -1
  94. package/dist/pixfutureBidAdapter.js +1 -1
  95. package/dist/prebid-core.js +1 -1
  96. package/dist/pstudioBidAdapter.js +1 -0
  97. package/dist/publinkIdSystem.js +1 -1
  98. package/dist/publirBidAdapter.js +1 -0
  99. package/dist/pubmaticAnalyticsAdapter.js +1 -1
  100. package/dist/pubmaticBidAdapter.js +1 -1
  101. package/dist/pubwiseAnalyticsAdapter.js +1 -1
  102. package/dist/pxyzBidAdapter.js +1 -1
  103. package/dist/quantcastBidAdapter.js +1 -1
  104. package/dist/rasBidAdapter.js +1 -1
  105. package/dist/readpeakBidAdapter.js +1 -1
  106. package/dist/relaidoBidAdapter.js +1 -1
  107. package/dist/retailspotBidAdapter.js +1 -1
  108. package/dist/rhythmoneBidAdapter.js +1 -1
  109. package/dist/riseBidAdapter.js +1 -1
  110. package/dist/rtbhouseBidAdapter.js +1 -1
  111. package/dist/rubiconBidAdapter.js +1 -1
  112. package/dist/seedingAllianceBidAdapter.js +1 -1
  113. package/dist/seedtagBidAdapter.js +1 -1
  114. package/dist/sharethroughAnalyticsAdapter.js +1 -1
  115. package/dist/sharethroughBidAdapter.js +1 -1
  116. package/dist/shinezBidAdapter.js +1 -1
  117. package/dist/shinezRtbBidAdapter.js +1 -1
  118. package/dist/smaatoBidAdapter.js +1 -1
  119. package/dist/smartadserverBidAdapter.js +1 -1
  120. package/dist/smartxBidAdapter.js +1 -1
  121. package/dist/smartyadsBidAdapter.js +1 -1
  122. package/dist/smilewantedBidAdapter.js +1 -1
  123. package/dist/sonobiBidAdapter.js +1 -1
  124. package/dist/sovrnAnalyticsAdapter.js +1 -1
  125. package/dist/sovrnBidAdapter.js +1 -1
  126. package/dist/sspBCBidAdapter.js +1 -1
  127. package/dist/stnBidAdapter.js +1 -1
  128. package/dist/stvBidAdapter.js +1 -1
  129. package/dist/sublimeBidAdapter.js +1 -1
  130. package/dist/taboolaBidAdapter.js +1 -1
  131. package/dist/tagorasBidAdapter.js +1 -1
  132. package/dist/targetVideoBidAdapter.js +1 -1
  133. package/dist/teadsBidAdapter.js +1 -1
  134. package/dist/themoneytizerBidAdapter.js +1 -1
  135. package/dist/trionBidAdapter.js +1 -1
  136. package/dist/tripleliftBidAdapter.js +1 -1
  137. package/dist/ttdBidAdapter.js +1 -1
  138. package/dist/ucfunnelAnalyticsAdapter.js +1 -1
  139. package/dist/uid2IdSystem.js +1 -1
  140. package/dist/underdogmediaBidAdapter.js +1 -1
  141. package/dist/undertoneBidAdapter.js +1 -1
  142. package/dist/unrulyBidAdapter.js +1 -1
  143. package/dist/userId.js +1 -1
  144. package/dist/vidazooBidAdapter.js +1 -1
  145. package/dist/videobyteBidAdapter.js +1 -1
  146. package/dist/visxBidAdapter.js +1 -1
  147. package/dist/vuukleBidAdapter.js +1 -1
  148. package/dist/weboramaRtdProvider.js +1 -1
  149. package/dist/widespaceBidAdapter.js +1 -1
  150. package/dist/winrBidAdapter.js +1 -1
  151. package/dist/yahoosspBidAdapter.js +1 -1
  152. package/dist/yieldmoBidAdapter.js +1 -1
  153. package/dist/yieldoneAnalyticsAdapter.js +1 -1
  154. package/dist/zeta_global_sspBidAdapter.js +1 -1
  155. package/integrationExamples/gpt/publir_hello_world.html +84 -0
  156. package/modules/adkernelBidAdapter.js +2 -1
  157. package/modules/automatadAnalyticsAdapter.js +31 -22
  158. package/modules/discoveryBidAdapter.js +5 -4
  159. package/modules/hypelabBidAdapter.js +31 -5
  160. package/modules/kargoBidAdapter.js +25 -13
  161. package/modules/kueezRtbBidAdapter.js +1 -1
  162. package/modules/nextMillenniumBidAdapter.js +52 -33
  163. package/modules/nexx360BidAdapter.js +2 -3
  164. package/modules/onetagBidAdapter.js +2 -1
  165. package/modules/pstudioBidAdapter.js +435 -0
  166. package/modules/pstudioBidAdapter.md +148 -0
  167. package/modules/publirBidAdapter.js +391 -0
  168. package/modules/publirBidAdapter.md +47 -0
  169. package/modules/pubmaticAnalyticsAdapter.js +7 -2
  170. package/modules/rasBidAdapter.js +178 -22
  171. package/modules/rasBidAdapter.md +2 -2
  172. package/modules/rtbhouseBidAdapter.js +2 -1
  173. package/modules/sharethroughBidAdapter.js +4 -0
  174. package/modules/smartyadsBidAdapter.js +10 -2
  175. package/modules/sovrnBidAdapter.js +15 -8
  176. package/modules/sspBCBidAdapter.js +22 -17
  177. package/modules/taboolaBidAdapter.js +1 -1
  178. package/modules/userId/index.js +1 -1
  179. package/modules/weboramaRtdProvider.js +99 -36
  180. package/modules/weboramaRtdProvider.md +13 -4
  181. package/modules/zeta_global_sspBidAdapter.js +26 -1
  182. package/package.json +1 -1
  183. package/test/spec/modules/automatadAnalyticsAdapter_spec.js +102 -15
  184. package/test/spec/modules/discoveryBidAdapter_spec.js +1 -1
  185. package/test/spec/modules/hypelabBidAdapter_spec.js +5 -1
  186. package/test/spec/modules/kargoBidAdapter_spec.js +29 -11
  187. package/test/spec/modules/nextMillenniumBidAdapter_spec.js +34 -3
  188. package/test/spec/modules/nexx360BidAdapter_spec.js +5 -5
  189. package/test/spec/modules/onetagBidAdapter_spec.js +4 -1
  190. package/test/spec/modules/pstudioBidAdapter_spec.js +514 -0
  191. package/test/spec/modules/publirBidAdapter_spec.js +488 -0
  192. package/test/spec/modules/pubmaticAnalyticsAdapter_spec.js +12 -1
  193. package/test/spec/modules/rasBidAdapter_spec.js +364 -2
  194. package/test/spec/modules/sharethroughBidAdapter_spec.js +35 -0
  195. package/test/spec/modules/sovrnBidAdapter_spec.js +39 -0
  196. package/test/spec/modules/sspBCBidAdapter_spec.js +1 -1
  197. package/test/spec/modules/taboolaBidAdapter_spec.js +1 -1
  198. package/test/spec/modules/weboramaRtdProvider_spec.js +114 -0
  199. package/test/spec/modules/zeta_global_sspBidAdapter_spec.js +4 -4
@@ -31,18 +31,24 @@ const REPORT_ENDPOINT = 'https://report2.hb.brainlyads.com/statistics/metric';
31
31
  const TIME_TO_LIVE = 360;
32
32
  const DEFAULT_CURRENCY = 'USD';
33
33
 
34
- const VIDEO_PARAMS = [
35
- 'api',
36
- 'linearity',
37
- 'maxduration',
38
- 'mimes',
39
- 'minduration',
40
- 'placement',
41
- 'playbackmethod',
42
- 'protocols',
43
- 'startdelay',
44
- ];
34
+ const VIDEO_PARAMS_DEFAULT = {
35
+ api: undefined,
36
+ linearity: undefined,
37
+ maxduration: undefined,
38
+ mimes: [
39
+ 'video/mp4',
40
+ 'video/x-ms-wmv',
41
+ 'application/javascript',
42
+ ],
43
+
44
+ minduration: undefined,
45
+ placement: undefined,
46
+ playbackmethod: undefined,
47
+ protocols: undefined,
48
+ startdelay: undefined,
49
+ };
45
50
 
51
+ const VIDEO_PARAMS = Object.keys(VIDEO_PARAMS_DEFAULT);
46
52
  const ALLOWED_ORTB2_PARAMETERS = [
47
53
  'site.pagecat',
48
54
  'site.content.cat',
@@ -267,33 +273,46 @@ export function getImp(bid, id, mediaTypes) {
267
273
  },
268
274
  };
269
275
 
270
- if (banner) {
271
- if (banner.bidfloorcur) imp.bidfloorcur = banner.bidfloorcur;
272
- if (banner.bidfloor) imp.bidfloor = banner.bidfloor;
276
+ getImpBanner(imp, banner);
277
+ getImpVideo(imp, video);
273
278
 
274
- const format = (banner.data?.sizes || []).map(s => { return {w: s[0], h: s[1]} })
275
- const {w, h} = (format[0] || {})
276
- imp.banner = {
277
- w,
278
- h,
279
- format,
280
- };
281
- };
279
+ return imp;
280
+ };
282
281
 
283
- if (video) {
284
- if (video.bidfloorcur) imp.bidfloorcur = video.bidfloorcur;
285
- if (video.bidfloor) imp.bidfloor = video.bidfloor;
282
+ export function getImpBanner(imp, banner) {
283
+ if (!banner) return;
286
284
 
287
- imp.video = getDefinedParams(video, VIDEO_PARAMS);
288
- if (video.data.playerSize) {
289
- imp.video = Object.assign(imp.video, parseGPTSingleSizeArrayToRtbSize(video.data.playerSize) || {});
290
- } else if (video.w && video.h) {
291
- imp.video.w = video.w;
292
- imp.video.h = video.h;
293
- };
285
+ if (banner.bidfloorcur) imp.bidfloorcur = banner.bidfloorcur;
286
+ if (banner.bidfloor) imp.bidfloor = banner.bidfloor;
287
+
288
+ const format = (banner.data?.sizes || []).map(s => { return {w: s[0], h: s[1]} })
289
+ const {w, h} = (format[0] || {})
290
+ imp.banner = {
291
+ w,
292
+ h,
293
+ format,
294
294
  };
295
+ };
295
296
 
296
- return imp;
297
+ export function getImpVideo(imp, video) {
298
+ if (!video) return;
299
+
300
+ if (video.bidfloorcur) imp.bidfloorcur = video.bidfloorcur;
301
+ if (video.bidfloor) imp.bidfloor = video.bidfloor;
302
+
303
+ imp.video = getDefinedParams(video.data, VIDEO_PARAMS);
304
+ Object.keys(VIDEO_PARAMS_DEFAULT)
305
+ .filter(videoParamName => VIDEO_PARAMS_DEFAULT[videoParamName])
306
+ .forEach(videoParamName => {
307
+ if (typeof imp.video[videoParamName] === 'undefined') imp.video[videoParamName] = VIDEO_PARAMS_DEFAULT[videoParamName];
308
+ });
309
+
310
+ if (video.data.playerSize) {
311
+ imp.video = Object.assign(imp.video, parseGPTSingleSizeArrayToRtbSize(video.data?.playerSize) || {});
312
+ } else if (video.data.w && video.data.h) {
313
+ imp.video.w = video.data.w;
314
+ imp.video.h = video.data.h;
315
+ };
297
316
  };
298
317
 
299
318
  export function setConsentStrings(postBody = {}, bidderRequest) {
@@ -22,7 +22,7 @@ const OUTSTREAM_RENDERER_URL = 'https://acdn.adnxs.com/video/outstream/ANOutstre
22
22
  const BIDDER_CODE = 'nexx360';
23
23
  const REQUEST_URL = 'https://fast.nexx360.io/booster';
24
24
  const PAGE_VIEW_ID = generateUUID();
25
- const BIDDER_VERSION = '3.0';
25
+ const BIDDER_VERSION = '4.0';
26
26
  const GVLID = 965;
27
27
  const NEXXID_KEY = 'nexx360_storage';
28
28
 
@@ -151,7 +151,6 @@ function isBidRequestValid(bid) {
151
151
  /**
152
152
  * Make a server request from the list of BidRequests.
153
153
  *
154
- * @param {validBidRequests[]} - an array of bids
155
154
  * @return ServerRequest Info describing the request to the server.
156
155
  */
157
156
 
@@ -208,7 +207,7 @@ function interpretResponse(serverResponse) {
208
207
  response.adUrl = bid.ext.adUrl;
209
208
  }
210
209
  }
211
- if ([INSTREAM, OUTSTREAM].includes(bid.ext.mediaType)) response.vastXml = bid.ext.vastXml;
210
+ if ([INSTREAM, OUTSTREAM].includes(bid.ext.mediaType)) response.vastXml = bid.adm;
212
211
 
213
212
  if (bid.ext.mediaType === OUTSTREAM) {
214
213
  response.renderer = createRenderer(bid, OUTSTREAM_RENDERER_URL);
@@ -63,7 +63,8 @@ function buildRequests(validBidRequests, bidderRequest) {
63
63
  if (bidderRequest && bidderRequest.gdprConsent) {
64
64
  payload.gdprConsent = {
65
65
  consentString: bidderRequest.gdprConsent.consentString,
66
- consentRequired: bidderRequest.gdprConsent.gdprApplies
66
+ consentRequired: bidderRequest.gdprConsent.gdprApplies,
67
+ addtlConsent: bidderRequest.gdprConsent.addtlConsent
67
68
  };
68
69
  }
69
70
  if (bidderRequest && bidderRequest.gppConsent) {
@@ -0,0 +1,435 @@
1
+ import { registerBidder } from '../src/adapters/bidderFactory.js';
2
+ import { BANNER, VIDEO } from '../src/mediaTypes.js';
3
+ import {
4
+ deepAccess,
5
+ isArray,
6
+ isNumber,
7
+ generateUUID,
8
+ isEmpty,
9
+ isFn,
10
+ isPlainObject,
11
+ } from '../src/utils.js';
12
+ import { getStorageManager } from '../src/storageManager.js';
13
+
14
+ const BIDDER_CODE = 'pstudio';
15
+ const ENDPOINT = 'https://exchange.pstudio.tadex.id/prebid-bid'
16
+ const TIME_TO_LIVE = 300;
17
+ // in case that the publisher limits number of user syncs, thisse syncs will be discarded from the end of the list
18
+ // so more improtant syncing calls should be at the start of the list
19
+ const USER_SYNCS = [
20
+ // PARTNER_UID is a partner user id
21
+ {
22
+ type: 'img',
23
+ url: 'https://match.adsrvr.org/track/cmf/generic?ttd_pid=k1on5ig&ttd_tpi=1&ttd_puid=%PARTNER_UID%&dsp=ttd',
24
+ macro: '%PARTNER_UID%',
25
+ },
26
+ {
27
+ type: 'img',
28
+ url: 'https://dsp.myads.telkomsel.com/api/v1/pixel?uid=%USERID%',
29
+ macro: '%USERID%',
30
+ },
31
+ ];
32
+ const COOKIE_NAME = '__tadexid';
33
+ const COOKIE_TTL_DAYS = 365;
34
+ const DAY_IN_MS = 24 * 60 * 60 * 1000;
35
+ const SUPPORTED_MEDIA_TYPES = [BANNER, VIDEO];
36
+ const VIDEO_PARAMS = [
37
+ 'mimes',
38
+ 'minduration',
39
+ 'maxduration',
40
+ 'protocols',
41
+ 'startdelay',
42
+ 'placement',
43
+ 'skip',
44
+ 'skipafter',
45
+ 'minbitrate',
46
+ 'maxbitrate',
47
+ 'delivery',
48
+ 'playbackmethod',
49
+ 'api',
50
+ 'linearity',
51
+ ];
52
+
53
+ export const storage = getStorageManager({ bidderCode: BIDDER_CODE });
54
+
55
+ export const spec = {
56
+ code: BIDDER_CODE,
57
+ supportedMediaTypes: SUPPORTED_MEDIA_TYPES,
58
+
59
+ isBidRequestValid: function (bid) {
60
+ const params = bid.params || {};
61
+ return !!params.pubid && !!params.floorPrice && isVideoRequestValid(bid);
62
+ },
63
+
64
+ buildRequests: function (validBidRequests, bidderRequest) {
65
+ return validBidRequests.map((bid) => ({
66
+ method: 'POST',
67
+ url: ENDPOINT,
68
+ data: JSON.stringify(buildRequestData(bid, bidderRequest)),
69
+ options: {
70
+ contentType: 'application/json',
71
+ withCredentials: true,
72
+ },
73
+ }));
74
+ },
75
+
76
+ interpretResponse: function (serverResponse, bidRequest) {
77
+ const bidResponses = [];
78
+
79
+ if (!serverResponse.body.bids) return [];
80
+ const { id } = JSON.parse(bidRequest.data);
81
+
82
+ serverResponse.body.bids.map((bid) => {
83
+ const { cpm, width, height, currency, ad, meta } = bid;
84
+ let bidResponse = {
85
+ requestId: id,
86
+ cpm,
87
+ width,
88
+ height,
89
+ creativeId: bid.creative_id,
90
+ currency,
91
+ netRevenue: bid.net_revenue,
92
+ ttl: TIME_TO_LIVE,
93
+ meta: {
94
+ advertiserDomains: meta.advertiser_domains,
95
+ },
96
+ };
97
+
98
+ if (bid.vast_url || bid.vast_xml) {
99
+ bidResponse.vastUrl = bid.vast_url;
100
+ bidResponse.vastXml = bid.vast_xml;
101
+ bidResponse.mediaType = VIDEO;
102
+ } else {
103
+ bidResponse.ad = ad;
104
+ }
105
+
106
+ bidResponses.push(bidResponse);
107
+ });
108
+
109
+ return bidResponses;
110
+ },
111
+
112
+ getUserSyncs(_optionsType, _serverResponse, _gdprConsent, _uspConsent) {
113
+ const syncs = [];
114
+
115
+ let userId = readUserIdFromCookie(COOKIE_NAME);
116
+
117
+ if (!userId) {
118
+ userId = generateId();
119
+ writeIdToCookie(COOKIE_NAME, userId);
120
+ }
121
+
122
+ USER_SYNCS.map((userSync) => {
123
+ if (userSync.type === 'img') {
124
+ syncs.push({
125
+ type: 'image',
126
+ url: userSync.url.replace(userSync.macro, userId),
127
+ });
128
+ }
129
+ });
130
+
131
+ return syncs;
132
+ },
133
+ };
134
+
135
+ function buildRequestData(bid, bidderRequest) {
136
+ let payloadObject = buildBaseObject(bid, bidderRequest);
137
+
138
+ if (bid.mediaTypes.banner) {
139
+ return buildBannerObject(bid, payloadObject);
140
+ } else if (bid.mediaTypes.video) {
141
+ return buildVideoObject(bid, payloadObject);
142
+ }
143
+ }
144
+
145
+ function buildBaseObject(bid, bidderRequest) {
146
+ const firstPartyData = prepareFirstPartyData(bidderRequest.ortb2);
147
+ const { pubid, bcat, badv, bapp } = bid.params;
148
+ const { userId } = bid;
149
+ const uid2Token = userId?.uid2?.id;
150
+
151
+ if (uid2Token) {
152
+ if (firstPartyData.user) {
153
+ firstPartyData.user.uid2_token = uid2Token;
154
+ } else {
155
+ firstPartyData.user = { uid2_token: uid2Token };
156
+ }
157
+ }
158
+ const userCookieId = readUserIdFromCookie(COOKIE_NAME);
159
+ if (userCookieId) {
160
+ if (firstPartyData.user) {
161
+ firstPartyData.user.id = userCookieId;
162
+ } else {
163
+ firstPartyData.user = { id: userCookieId };
164
+ }
165
+ }
166
+
167
+ return {
168
+ id: bid.bidId,
169
+ pubid,
170
+ floor_price: getBidFloor(bid),
171
+ adtagid: bid.adUnitCode,
172
+ ...(bcat && { bcat }),
173
+ ...(badv && { badv }),
174
+ ...(bapp && { bapp }),
175
+ ...firstPartyData,
176
+ };
177
+ }
178
+
179
+ function buildBannerObject(bid, payloadObject) {
180
+ const { sizes, pos, name } = bid.mediaTypes.banner;
181
+
182
+ payloadObject.banner_properties = {
183
+ name,
184
+ sizes,
185
+ pos,
186
+ };
187
+
188
+ return payloadObject;
189
+ }
190
+
191
+ function buildVideoObject(bid, payloadObject) {
192
+ const { context, playerSize, w, h } = bid.mediaTypes.video;
193
+
194
+ payloadObject.video_properties = {
195
+ context,
196
+ w: w || playerSize[0][0],
197
+ h: h || playerSize[0][1],
198
+ };
199
+
200
+ for (const param of VIDEO_PARAMS) {
201
+ const paramValue = deepAccess(bid, `mediaTypes.video.${param}`);
202
+
203
+ if (paramValue) {
204
+ payloadObject.video_properties[param] = paramValue;
205
+ }
206
+ }
207
+
208
+ return payloadObject;
209
+ }
210
+
211
+ function readUserIdFromCookie(key) {
212
+ try {
213
+ const storedValue = storage.getCookie(key);
214
+
215
+ if (storedValue !== null) {
216
+ return storedValue;
217
+ }
218
+ } catch (error) {
219
+ }
220
+ }
221
+
222
+ function generateId() {
223
+ return generateUUID();
224
+ }
225
+
226
+ function daysToMs(days) {
227
+ return days * DAY_IN_MS;
228
+ }
229
+
230
+ function writeIdToCookie(key, value) {
231
+ if (storage.cookiesAreEnabled()) {
232
+ const expires = new Date(
233
+ Date.now() + daysToMs(parseInt(COOKIE_TTL_DAYS))
234
+ ).toUTCString();
235
+ storage.setCookie(key, value, expires, '/');
236
+ }
237
+ }
238
+
239
+ function prepareFirstPartyData({ user, device, site, app, regs }) {
240
+ let userData;
241
+ let deviceData;
242
+ let siteData;
243
+ let appData;
244
+ let regsData;
245
+
246
+ if (user) {
247
+ userData = {
248
+ yob: user.yob,
249
+ gender: user.gender,
250
+ };
251
+ }
252
+
253
+ if (device) {
254
+ deviceData = {
255
+ ua: device.ua,
256
+ dnt: device.dnt,
257
+ lmt: device.lmt,
258
+ ip: device.ip,
259
+ ipv6: device.ipv6,
260
+ devicetype: device.devicetype,
261
+ make: device.make,
262
+ model: device.model,
263
+ os: device.os,
264
+ osv: device.osv,
265
+ js: device.js,
266
+ language: device.language,
267
+ carrier: device.carrier,
268
+ connectiontype: device.connectiontype,
269
+ ifa: device.ifa,
270
+ ...(device.geo && {
271
+ geo: {
272
+ lat: device.geo.lat,
273
+ lon: device.geo.lon,
274
+ country: device.geo.country,
275
+ region: device.geo.region,
276
+ regionfips104: device.geo.regionfips104,
277
+ metro: device.geo.metro,
278
+ city: device.geo.city,
279
+ zip: device.geo.zip,
280
+ type: device.geo.type,
281
+ },
282
+ }),
283
+ ...(device.ext && {
284
+ ext: {
285
+ ifatype: device.ext.ifatype,
286
+ },
287
+ }),
288
+ };
289
+ }
290
+
291
+ if (site) {
292
+ siteData = {
293
+ id: site.id,
294
+ name: site.name,
295
+ domain: site.domain,
296
+ page: site.page,
297
+ cat: site.cat,
298
+ sectioncat: site.sectioncat,
299
+ pagecat: site.pagecat,
300
+ ref: site.ref,
301
+ ...(site.publisher && {
302
+ publisher: {
303
+ name: site.publisher.name,
304
+ cat: site.publisher.cat,
305
+ domain: site.publisher.domain,
306
+ },
307
+ }),
308
+ ...(site.content && {
309
+ content: {
310
+ id: site.content.id,
311
+ episode: site.content.episode,
312
+ title: site.content.title,
313
+ series: site.content.series,
314
+ artist: site.content.artist,
315
+ genre: site.content.genre,
316
+ album: site.content.album,
317
+ isrc: site.content.isrc,
318
+ season: site.content.season,
319
+ },
320
+ }),
321
+ mobile: site.mobile,
322
+ };
323
+ }
324
+
325
+ if (app) {
326
+ appData = {
327
+ id: app.id,
328
+ name: app.name,
329
+ bundle: app.bundle,
330
+ domain: app.domain,
331
+ storeurl: app.storeurl,
332
+ cat: app.cat,
333
+ sectioncat: app.sectioncat,
334
+ pagecat: app.pagecat,
335
+ ver: app.ver,
336
+ privacypolicy: app.privacypolicy,
337
+ paid: app.paid,
338
+ ...(app.publisher && {
339
+ publisher: {
340
+ name: app.publisher.name,
341
+ cat: app.publisher.cat,
342
+ domain: app.publisher.domain,
343
+ },
344
+ }),
345
+ keywords: app.keywords,
346
+ ...(app.content && {
347
+ content: {
348
+ id: app.content.id,
349
+ episode: app.content.episode,
350
+ title: app.content.title,
351
+ series: app.content.series,
352
+ artist: app.content.artist,
353
+ genre: app.content.genre,
354
+ album: app.content.album,
355
+ isrc: app.content.isrc,
356
+ season: app.content.season,
357
+ },
358
+ }),
359
+ };
360
+ }
361
+
362
+ if (regs) {
363
+ regsData = { coppa: regs.coppa };
364
+ }
365
+
366
+ return cleanObject({
367
+ user: userData,
368
+ device: deviceData,
369
+ site: siteData,
370
+ app: appData,
371
+ regs: regsData,
372
+ });
373
+ }
374
+
375
+ function cleanObject(data) {
376
+ for (let key in data) {
377
+ if (typeof data[key] == 'object') {
378
+ cleanObject(data[key]);
379
+
380
+ if (isEmpty(data[key])) delete data[key];
381
+ }
382
+
383
+ if (data[key] === undefined) delete data[key];
384
+ }
385
+
386
+ return data;
387
+ }
388
+
389
+ function isVideoRequestValid(bidRequest) {
390
+ if (bidRequest.mediaTypes.video) {
391
+ const { w, h, playerSize, mimes, protocols } = deepAccess(
392
+ bidRequest,
393
+ 'mediaTypes.video',
394
+ {}
395
+ );
396
+
397
+ const areSizesValid =
398
+ (isNumber(w) && isNumber(h)) || validateSizes(playerSize);
399
+ const areMimesValid = isArray(mimes) && mimes.length > 0;
400
+ const areProtocolsValid =
401
+ isArray(protocols) && protocols.length > 0 && protocols.every(isNumber);
402
+
403
+ return areSizesValid && areMimesValid && areProtocolsValid;
404
+ }
405
+
406
+ return true;
407
+ }
408
+
409
+ function validateSizes(sizes) {
410
+ return (
411
+ isArray(sizes) &&
412
+ sizes.length > 0 &&
413
+ sizes.every(
414
+ (size) => isArray(size) && size.length === 2 && size.every(isNumber)
415
+ )
416
+ );
417
+ }
418
+
419
+ function getBidFloor(bid) {
420
+ if (!isFn(bid.getFloor)) {
421
+ return bid.params.floorPrice ? bid.params.floorPrice : null;
422
+ }
423
+
424
+ let floor = bid.getFloor({
425
+ currency: 'USD',
426
+ mediaType: '*',
427
+ size: '*',
428
+ });
429
+ if (isPlainObject(floor) && !isNaN(floor.floor) && floor.currency === 'USD') {
430
+ return floor.floor;
431
+ }
432
+ return null;
433
+ }
434
+
435
+ registerBidder(spec);