prebid.js 6.28.0 → 6.29.2

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 (162) hide show
  1. package/dist/33acrossBidAdapter.js +1 -1
  2. package/dist/adagioBidAdapter.js +1 -1
  3. package/dist/adbookpspBidAdapter.js +1 -1
  4. package/dist/adgenerationBidAdapter.js +1 -1
  5. package/dist/adoceanBidAdapter.js +1 -1
  6. package/dist/adrelevantisBidAdapter.js +1 -1
  7. package/dist/adxcgBidAdapter.js +1 -1
  8. package/dist/adyoulikeBidAdapter.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/appierAnalyticsAdapter.js +1 -1
  13. package/dist/appnexusBidAdapter.js +1 -1
  14. package/dist/asoBidAdapter.js +1 -1
  15. package/dist/audiencerunBidAdapter.js +1 -1
  16. package/dist/axonixBidAdapter.js +1 -1
  17. package/dist/bidglassBidAdapter.js +1 -1
  18. package/dist/big-richmediaBidAdapter.js +1 -1
  19. package/dist/bluebillywigBidAdapter.js +1 -1
  20. package/dist/bridgewellBidAdapter.js +1 -1
  21. package/dist/brightMountainMediaBidAdapter.js +1 -1
  22. package/dist/concertBidAdapter.js +1 -1
  23. package/dist/connectIdSystem.js +1 -1
  24. package/dist/connectadBidAdapter.js +1 -1
  25. package/dist/consentManagement.js +1 -1
  26. package/dist/consumableBidAdapter.js +1 -1
  27. package/dist/conversantBidAdapter.js +1 -1
  28. package/dist/craftBidAdapter.js +1 -1
  29. package/dist/criteoBidAdapter.js +1 -1
  30. package/dist/currency.js +1 -1
  31. package/dist/dspxBidAdapter.js +1 -1
  32. package/dist/eplanningBidAdapter.js +1 -1
  33. package/dist/gdprEnforcement.js +1 -1
  34. package/dist/glimpseBidAdapter.js +1 -1
  35. package/dist/gmosspBidAdapter.js +1 -1
  36. package/dist/goldbachBidAdapter.js +1 -1
  37. package/dist/gridBidAdapter.js +1 -1
  38. package/dist/gridNMBidAdapter.js +1 -1
  39. package/dist/gumgumBidAdapter.js +1 -1
  40. package/dist/h12mediaBidAdapter.js +1 -1
  41. package/dist/id5IdSystem.js +1 -1
  42. package/dist/impactifyBidAdapter.js +1 -1
  43. package/dist/improvedigitalBidAdapter.js +1 -1
  44. package/dist/inmarBidAdapter.js +1 -1
  45. package/dist/insticatorBidAdapter.js +1 -1
  46. package/dist/ixBidAdapter.js +1 -1
  47. package/dist/jixieBidAdapter.js +1 -1
  48. package/dist/justpremiumBidAdapter.js +1 -1
  49. package/dist/konduitAnalyticsAdapter.js +1 -1
  50. package/dist/lassoBidAdapter.js +1 -0
  51. package/dist/liveyieldAnalyticsAdapter.js +1 -1
  52. package/dist/logicadBidAdapter.js +1 -1
  53. package/dist/loglyliftBidAdapter.js +1 -1
  54. package/dist/malltvAnalyticsAdapter.js +1 -1
  55. package/dist/marsmediaBidAdapter.js +1 -1
  56. package/dist/mediafuseBidAdapter.js +1 -1
  57. package/dist/mediakeysBidAdapter.js +1 -1
  58. package/dist/mediasquareBidAdapter.js +1 -1
  59. package/dist/merkleIdSystem.js +1 -1
  60. package/dist/mgidBidAdapter.js +1 -1
  61. package/dist/minutemediaBidAdapter.js +1 -1
  62. package/dist/not-for-prod/prebid.js +120 -119
  63. package/dist/oguryBidAdapter.js +1 -1
  64. package/dist/oneVideoBidAdapter.js +1 -1
  65. package/dist/onetagBidAdapter.js +1 -1
  66. package/dist/ooloAnalyticsAdapter.js +1 -1
  67. package/dist/outbrainBidAdapter.js +1 -1
  68. package/dist/parrableIdSystem.js +1 -1
  69. package/dist/pixfutureBidAdapter.js +1 -1
  70. package/dist/prebid-core.js +3 -3
  71. package/dist/pubCommonId.js +1 -1
  72. package/dist/publinkIdSystem.js +1 -1
  73. package/dist/pubmaticAnalyticsAdapter.js +1 -1
  74. package/dist/pubmaticBidAdapter.js +1 -1
  75. package/dist/pubwiseAnalyticsAdapter.js +1 -1
  76. package/dist/pxyzBidAdapter.js +1 -1
  77. package/dist/quantcastBidAdapter.js +1 -1
  78. package/dist/readpeakBidAdapter.js +1 -1
  79. package/dist/relaidoBidAdapter.js +1 -1
  80. package/dist/rhythmoneBidAdapter.js +1 -1
  81. package/dist/riseBidAdapter.js +1 -1
  82. package/dist/rubiconAnalyticsAdapter.js +1 -1
  83. package/dist/rubiconBidAdapter.js +1 -1
  84. package/dist/seedingAllianceBidAdapter.js +1 -1
  85. package/dist/seedtagBidAdapter.js +1 -1
  86. package/dist/sharedIdSystem.js +1 -1
  87. package/dist/sharethroughAnalyticsAdapter.js +1 -1
  88. package/dist/sharethroughBidAdapter.js +1 -1
  89. package/dist/smaatoBidAdapter.js +1 -1
  90. package/dist/smartadserverBidAdapter.js +1 -1
  91. package/dist/smartxBidAdapter.js +1 -1
  92. package/dist/smilewantedBidAdapter.js +1 -1
  93. package/dist/sonobiBidAdapter.js +1 -1
  94. package/dist/sortableBidAdapter.js +1 -1
  95. package/dist/sovrnAnalyticsAdapter.js +1 -1
  96. package/dist/sovrnBidAdapter.js +1 -1
  97. package/dist/sspBCBidAdapter.js +1 -1
  98. package/dist/sublimeBidAdapter.js +1 -1
  99. package/dist/synacormediaBidAdapter.js +1 -1
  100. package/dist/taboolaBidAdapter.js +1 -1
  101. package/dist/targetVideoBidAdapter.js +1 -1
  102. package/dist/teadsBidAdapter.js +1 -1
  103. package/dist/trionBidAdapter.js +1 -1
  104. package/dist/tripleliftBidAdapter.js +1 -1
  105. package/dist/trustxBidAdapter.js +1 -1
  106. package/dist/ttdBidAdapter.js +1 -1
  107. package/dist/ucfunnelAnalyticsAdapter.js +1 -1
  108. package/dist/underdogmediaBidAdapter.js +1 -1
  109. package/dist/undertoneBidAdapter.js +1 -1
  110. package/dist/userId.js +1 -1
  111. package/dist/vidazooBidAdapter.js +1 -1
  112. package/dist/videobyteBidAdapter.js +1 -1
  113. package/dist/visxBidAdapter.js +1 -1
  114. package/dist/vuukleBidAdapter.js +1 -1
  115. package/dist/widespaceBidAdapter.js +1 -1
  116. package/dist/winrBidAdapter.js +1 -1
  117. package/dist/yahoosspBidAdapter.js +1 -1
  118. package/dist/yieldmoBidAdapter.js +1 -1
  119. package/dist/yieldoneAnalyticsAdapter.js +1 -1
  120. package/modules/adoceanBidAdapter.js +29 -1
  121. package/modules/consentManagement.js +20 -10
  122. package/modules/currency.js +2 -2
  123. package/modules/gdprEnforcement.js +15 -9
  124. package/modules/insticatorBidAdapter.js +109 -42
  125. package/modules/ixBidAdapter.js +3 -2
  126. package/modules/ixBidAdapter.md +1 -1
  127. package/modules/lassoBidAdapter.js +133 -0
  128. package/modules/lassoBidAdapter.md +29 -0
  129. package/modules/merkleIdSystem.js +43 -31
  130. package/modules/pubCommonId.js +2 -1
  131. package/modules/pubmaticAnalyticsAdapter.js +49 -33
  132. package/modules/sharedIdSystem.js +5 -11
  133. package/modules/synacormediaBidAdapter.js +11 -2
  134. package/modules/taboolaBidAdapter.js +1 -1
  135. package/modules/userId/eids.js +25 -5
  136. package/modules/userId/index.js +39 -21
  137. package/package.json +1 -1
  138. package/src/auction.js +6 -5
  139. package/src/consentHandler.js +11 -11
  140. package/src/hook.js +2 -2
  141. package/src/storageManager.js +5 -4
  142. package/src/utils/promise.js +96 -21
  143. package/src/utils.js +3 -2
  144. package/test/helpers/consentData.js +2 -1
  145. package/test/spec/auctionmanager_spec.js +1 -6
  146. package/test/spec/modules/adoceanBidAdapter_spec.js +25 -1
  147. package/test/spec/modules/consentManagement_spec.js +75 -16
  148. package/test/spec/modules/eids_spec.js +48 -3
  149. package/test/spec/modules/gdprEnforcement_spec.js +100 -53
  150. package/test/spec/modules/idxIdSystem_spec.js +1 -1
  151. package/test/spec/modules/insticatorBidAdapter_spec.js +46 -1
  152. package/test/spec/modules/ixBidAdapter_spec.js +1 -1
  153. package/test/spec/modules/lassoBidAdapter_spec.js +177 -0
  154. package/test/spec/modules/merkleIdSystem_spec.js +58 -37
  155. package/test/spec/modules/parrableIdSystem_spec.js +2 -1
  156. package/test/spec/modules/pubmaticAnalyticsAdapter_spec.js +117 -0
  157. package/test/spec/modules/synacormediaBidAdapter_spec.js +74 -0
  158. package/test/spec/modules/userId_spec.js +42 -3
  159. package/test/spec/modules/vidazooBidAdapter_spec.js +9 -4
  160. package/test/spec/unit/pbjs_api_spec.js +2 -6
  161. package/test/spec/unit/utils/promise_spec.js +283 -38
  162. package/test/helpers/syncPromise.js +0 -71
@@ -83,6 +83,8 @@ function setMediaTypes(types, bid) {
83
83
  function copyRequiredBidDetails(bid) {
84
84
  return pick(bid, [
85
85
  'bidder',
86
+ 'bidderCode',
87
+ 'adapterCode',
86
88
  'bidId',
87
89
  'status', () => NO_BID, // default a bid to NO_BID until response is recieved or bid is timed out
88
90
  'finalSource as source',
@@ -90,7 +92,7 @@ function copyRequiredBidDetails(bid) {
90
92
  'adUnit', () => pick(bid, [
91
93
  'adUnitCode',
92
94
  'transactionId',
93
- 'sizes as dimensions', sizes => sizes.map(sizeToDimensions),
95
+ 'sizes as dimensions', sizes => sizes && sizes.map(sizeToDimensions),
94
96
  'mediaTypes', (types) => setMediaTypes(types, bid)
95
97
  ])
96
98
  ]);
@@ -185,11 +187,11 @@ function getDevicePlatform() {
185
187
  }
186
188
 
187
189
  function getValueForKgpv(bid, adUnitId) {
188
- if (bid.params.regexPattern) {
190
+ if (bid.params && bid.params.regexPattern) {
189
191
  return bid.params.regexPattern;
190
192
  } else if (bid.bidResponse && bid.bidResponse.regexPattern) {
191
193
  return bid.bidResponse.regexPattern;
192
- } else if (bid.params.kgpv) {
194
+ } else if (bid.params && bid.params.kgpv) {
193
195
  return bid.params.kgpv;
194
196
  } else {
195
197
  return adUnitId;
@@ -218,30 +220,31 @@ function getAdDomain(bidResponse) {
218
220
  function gatherPartnerBidsForAdUnitForLogger(adUnit, adUnitId, highestBid) {
219
221
  highestBid = (highestBid && highestBid.length > 0) ? highestBid[0] : null;
220
222
  return Object.keys(adUnit.bids).reduce(function(partnerBids, bidId) {
221
- let bid = adUnit.bids[bidId];
222
- partnerBids.push({
223
- 'pn': getAdapterNameForAlias(bid.bidder),
224
- 'bc': bid.bidder,
225
- 'bidid': bid.bidId,
226
- 'db': bid.bidResponse ? 0 : 1,
227
- 'kgpv': getValueForKgpv(bid, adUnitId),
228
- 'kgpsv': bid.params.kgpv ? bid.params.kgpv : adUnitId,
229
- 'psz': bid.bidResponse ? (bid.bidResponse.dimensions.width + 'x' + bid.bidResponse.dimensions.height) : '0x0',
230
- 'eg': bid.bidResponse ? bid.bidResponse.bidGrossCpmUSD : 0,
231
- 'en': bid.bidResponse ? bid.bidResponse.bidPriceUSD : 0,
232
- 'di': bid.bidResponse ? (bid.bidResponse.dealId || EMPTY_STRING) : EMPTY_STRING,
233
- 'dc': bid.bidResponse ? (bid.bidResponse.dealChannel || EMPTY_STRING) : EMPTY_STRING,
234
- 'l1': bid.bidResponse ? bid.clientLatencyTimeMs : 0,
235
- 'l2': 0,
236
- 'adv': bid.bidResponse ? getAdDomain(bid.bidResponse) || undefined : undefined,
237
- 'ss': (s2sBidders.indexOf(bid.bidder) > -1) ? 1 : 0,
238
- 't': (bid.status == ERROR && bid.error.code == TIMEOUT_ERROR) ? 1 : 0,
239
- 'wb': (highestBid && highestBid.requestId === bid.bidId ? 1 : 0),
240
- 'mi': bid.bidResponse ? (bid.bidResponse.mi || undefined) : undefined,
241
- 'af': bid.bidResponse ? (bid.bidResponse.mediaType || undefined) : undefined,
242
- 'ocpm': bid.bidResponse ? (bid.bidResponse.originalCpm || 0) : 0,
243
- 'ocry': bid.bidResponse ? (bid.bidResponse.originalCurrency || CURRENCY_USD) : CURRENCY_USD,
244
- 'piid': bid.bidResponse ? (bid.bidResponse.partnerImpId || EMPTY_STRING) : EMPTY_STRING
223
+ adUnit.bids[bidId].forEach(function(bid) {
224
+ partnerBids.push({
225
+ 'pn': getAdapterNameForAlias(bid.adapterCode || bid.bidder),
226
+ 'bc': bid.bidderCode || bid.bidder,
227
+ 'bidid': bid.bidId || bidId,
228
+ 'db': bid.bidResponse ? 0 : 1,
229
+ 'kgpv': getValueForKgpv(bid, adUnitId),
230
+ 'kgpsv': bid.params && bid.params.kgpv ? bid.params.kgpv : adUnitId,
231
+ 'psz': bid.bidResponse ? (bid.bidResponse.dimensions.width + 'x' + bid.bidResponse.dimensions.height) : '0x0',
232
+ 'eg': bid.bidResponse ? bid.bidResponse.bidGrossCpmUSD : 0,
233
+ 'en': bid.bidResponse ? bid.bidResponse.bidPriceUSD : 0,
234
+ 'di': bid.bidResponse ? (bid.bidResponse.dealId || EMPTY_STRING) : EMPTY_STRING,
235
+ 'dc': bid.bidResponse ? (bid.bidResponse.dealChannel || EMPTY_STRING) : EMPTY_STRING,
236
+ 'l1': bid.bidResponse ? bid.clientLatencyTimeMs : 0,
237
+ 'l2': 0,
238
+ 'adv': bid.bidResponse ? getAdDomain(bid.bidResponse) || undefined : undefined,
239
+ 'ss': (s2sBidders.indexOf(bid.bidder) > -1) ? 1 : 0,
240
+ 't': (bid.status == ERROR && bid.error.code == TIMEOUT_ERROR) ? 1 : 0,
241
+ 'wb': (highestBid && highestBid.adId === bid.adId ? 1 : 0),
242
+ 'mi': bid.bidResponse ? (bid.bidResponse.mi || undefined) : undefined,
243
+ 'af': bid.bidResponse ? (bid.bidResponse.mediaType || undefined) : undefined,
244
+ 'ocpm': bid.bidResponse ? (bid.bidResponse.originalCpm || 0) : 0,
245
+ 'ocry': bid.bidResponse ? (bid.bidResponse.originalCurrency || CURRENCY_USD) : CURRENCY_USD,
246
+ 'piid': bid.bidResponse ? (bid.bidResponse.partnerImpId || EMPTY_STRING) : EMPTY_STRING
247
+ });
245
248
  });
246
249
  return partnerBids;
247
250
  }, [])
@@ -307,8 +310,14 @@ function executeBidsLoggerCall(e, highestCpmBids) {
307
310
 
308
311
  function executeBidWonLoggerCall(auctionId, adUnitId) {
309
312
  const winningBidId = cache.auctions[auctionId].adUnitCodes[adUnitId].bidWon;
310
- const winningBid = cache.auctions[auctionId].adUnitCodes[adUnitId].bids[winningBidId];
311
- const adapterName = getAdapterNameForAlias(winningBid.bidder);
313
+ const winningBids = cache.auctions[auctionId].adUnitCodes[adUnitId].bids[winningBidId];
314
+ let winningBid = winningBids[0];
315
+
316
+ if (winningBids.length > 1) {
317
+ winningBid = winningBids.filter(bid => bid.adId === cache.auctions[auctionId].adUnitCodes[adUnitId].bidWonAdId)[0];
318
+ }
319
+
320
+ const adapterName = getAdapterNameForAlias(winningBid.adapterCode || winningBid.bidder);
312
321
  let pixelURL = END_POINT_WIN_BID_LOGGER;
313
322
  pixelURL += 'pubid=' + publisherId;
314
323
  pixelURL += '&purl=' + enc(config.getConfig('pageUrl') || cache.auctions[auctionId].referer || '');
@@ -319,7 +328,7 @@ function executeBidWonLoggerCall(auctionId, adUnitId) {
319
328
  pixelURL += '&pdvid=' + enc(profileVersionId);
320
329
  pixelURL += '&slot=' + enc(adUnitId);
321
330
  pixelURL += '&pn=' + enc(adapterName);
322
- pixelURL += '&bc=' + enc(winningBid.bidder);
331
+ pixelURL += '&bc=' + enc(winningBid.bidderCode || winningBid.bidder);
323
332
  pixelURL += '&en=' + enc(winningBid.bidResponse.bidPriceUSD);
324
333
  pixelURL += '&eg=' + enc(winningBid.bidResponse.bidGrossCpmUSD);
325
334
  pixelURL += '&kgpv=' + enc(getValueForKgpv(winningBid, adUnitId));
@@ -362,16 +371,22 @@ function bidRequestedHandler(args) {
362
371
  dimensions: bid.sizes
363
372
  };
364
373
  }
365
- cache.auctions[args.auctionId].adUnitCodes[bid.adUnitCode].bids[bid.bidId] = copyRequiredBidDetails(bid);
374
+ cache.auctions[args.auctionId].adUnitCodes[bid.adUnitCode].bids[bid.bidId] = [copyRequiredBidDetails(bid)];
366
375
  })
367
376
  }
368
377
 
369
378
  function bidResponseHandler(args) {
370
- let bid = cache.auctions[args.auctionId].adUnitCodes[args.adUnitCode].bids[args.requestId];
379
+ let bid = cache.auctions[args.auctionId].adUnitCodes[args.adUnitCode].bids[args.requestId][0];
371
380
  if (!bid) {
372
381
  logError(LOG_PRE_FIX + 'Could not find associated bid request for bid response with requestId: ', args.requestId);
373
382
  return;
374
383
  }
384
+
385
+ if (bid.bidder && args.bidderCode && bid.bidder !== args.bidderCode) {
386
+ bid = copyRequiredBidDetails(args);
387
+ cache.auctions[args.auctionId].adUnitCodes[args.adUnitCode].bids[args.requestId].push(bid)
388
+ }
389
+ bid.adId = args.adId;
375
390
  bid.source = formatSource(bid.source || args.source);
376
391
  setBidStatus(bid, args);
377
392
  bid.clientLatencyTimeMs = Date.now() - cache.auctions[args.auctionId].timestamp;
@@ -397,6 +412,7 @@ function bidderDoneHandler(args) {
397
412
  function bidWonHandler(args) {
398
413
  let auctionCache = cache.auctions[args.auctionId];
399
414
  auctionCache.adUnitCodes[args.adUnitCode].bidWon = args.requestId;
415
+ auctionCache.adUnitCodes[args.adUnitCode].bidWonAdId = args.adId;
400
416
  executeBidWonLoggerCall(args.auctionId, args.adUnitCode);
401
417
  }
402
418
 
@@ -413,7 +429,7 @@ function bidTimeoutHandler(args) {
413
429
  // db = 0 and t = 1 means bidder did respond with a bid but post timeout
414
430
  args.forEach(badBid => {
415
431
  let auctionCache = cache.auctions[badBid.auctionId];
416
- let bid = auctionCache.adUnitCodes[badBid.adUnitCode].bids[ badBid.bidId || badBid.requestId ];
432
+ let bid = auctionCache.adUnitCodes[badBid.adUnitCode].bids[ badBid.bidId || badBid.requestId ][0];
417
433
  if (bid) {
418
434
  bid.status = ERROR;
419
435
  bid.error = {
@@ -5,13 +5,13 @@
5
5
  * @requires module:modules/userId
6
6
  */
7
7
 
8
- import { parseUrl, buildUrl, triggerPixel, logInfo, hasDeviceAccess, generateUUID } from '../src/utils.js';
8
+ import {buildUrl, generateUUID, hasDeviceAccess, logInfo, parseUrl, triggerPixel} from '../src/utils.js';
9
9
  import {submodule} from '../src/hook.js';
10
- import { coppaDataHandler } from '../src/adapterManager.js';
10
+ import {coppaDataHandler} from '../src/adapterManager.js';
11
11
  import {getStorageManager} from '../src/storageManager.js';
12
12
 
13
- const GVLID = 887;
14
- export const storage = getStorageManager({gvlid: GVLID, moduleName: 'pubCommonId'});
13
+ const MODULE_TYPE = 'fpid-module';
14
+ export const storage = getStorageManager({moduleName: 'pubCommonId', moduleType: MODULE_TYPE});
15
15
  const COOKIE = 'cookie';
16
16
  const LOCAL_STORAGE = 'html5';
17
17
  const OPTOUT_NAME = '_pubcid_optout';
@@ -74,11 +74,6 @@ export const sharedIdSystemSubmodule = {
74
74
  */
75
75
  name: 'sharedId',
76
76
  aliasName: 'pubCommonId',
77
- /**
78
- * Vendor id of prebid
79
- * @type {Number}
80
- */
81
- gvlid: GVLID,
82
77
 
83
78
  /**
84
79
  * decode the stored id value for passing to bid requests
@@ -93,8 +88,7 @@ export const sharedIdSystemSubmodule = {
93
88
  return undefined;
94
89
  }
95
90
  logInfo(' Decoded value PubCommonId ' + value);
96
- const idObj = {'pubcid': value};
97
- return idObj;
91
+ return {'pubcid': value};
98
92
  },
99
93
  /**
100
94
  * performs action to obtain id
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- import {deepSetValue, getAdUnitSizes, isFn, isPlainObject, logWarn} from '../src/utils.js';
3
+ import {deepAccess, deepSetValue, getAdUnitSizes, isFn, isPlainObject, logWarn} from '../src/utils.js';
4
4
  import {registerBidder} from '../src/adapters/bidderFactory.js';
5
5
  import {BANNER, VIDEO} from '../src/mediaTypes.js';
6
6
  import {includes} from '../src/polyfill.js';
@@ -79,7 +79,16 @@ export const spec = {
79
79
  imps = this.buildVideoImpressions(adSizes, bid, tagIdOrPlacementId, pos, videoOrBannerKey);
80
80
  }
81
81
  if (imps.length > 0) {
82
- imps.forEach(i => openRtbBidRequest.imp.push(i));
82
+ imps.forEach(i => {
83
+ // Deeply add ext section to all imp[] for GPID, prebid slot id, and anything else down the line
84
+ const extSection = deepAccess(bid, 'ortb2Imp.ext');
85
+ if (extSection) {
86
+ deepSetValue(i, 'ext', extSection);
87
+ }
88
+
89
+ // Add imp[] to request object
90
+ openRtbBidRequest.imp.push(i);
91
+ });
83
92
  }
84
93
  });
85
94
 
@@ -9,7 +9,7 @@ import {getStorageManager} from '../src/storageManager.js';
9
9
  const BIDDER_CODE = 'taboola';
10
10
  const GVLID = 42;
11
11
  const CURRENCY = 'USD';
12
- export const END_POINT_URL = 'http://hb.bidder.taboola.com/TaboolaHBOpenRTBRequestHandlerServlet';
12
+ export const END_POINT_URL = 'https://hb.bidder.taboola.com/TaboolaHBOpenRTBRequestHandlerServlet';
13
13
  const USER_ID = 'user-id';
14
14
  const STORAGE_KEY = `taboola global:${USER_ID}`;
15
15
  const COOKIE_KEY = 'trc_cookie_storage';
@@ -151,15 +151,25 @@ export const USER_IDS_CONFIG = {
151
151
 
152
152
  // merkleId
153
153
  'merkleId': {
154
- source: 'merkleinc.com',
155
154
  atype: 3,
155
+ getSource: function(data) {
156
+ if (data?.ext?.ssp) {
157
+ return `${data.ext.ssp}.merkleinc.com`
158
+ }
159
+ return 'merkleinc.com'
160
+ },
156
161
  getValue: function(data) {
157
162
  return data.id;
158
163
  },
159
164
  getUidExt: function(data) {
160
- return (data && data.keyID) ? {
161
- keyID: data.keyID
162
- } : undefined;
165
+ if (data.keyID) {
166
+ return {
167
+ keyID: data.keyID
168
+ }
169
+ }
170
+ if (data.ext) {
171
+ return data.ext;
172
+ }
163
173
  }
164
174
  },
165
175
 
@@ -327,7 +337,8 @@ function createEidObject(userIdData, subModuleKey) {
327
337
  const conf = USER_IDS_CONFIG[subModuleKey];
328
338
  if (conf && userIdData) {
329
339
  let eid = {};
330
- eid.source = conf['source'];
340
+ eid.source = isFn(conf['getSource']) ? conf['getSource'](userIdData) : conf['source'];
341
+
331
342
  const value = isFn(conf['getValue']) ? conf['getValue'](userIdData) : userIdData;
332
343
  if (isStr(value)) {
333
344
  const uid = { id: value, atype: conf['atype'] };
@@ -357,10 +368,19 @@ function createEidObject(userIdData, subModuleKey) {
357
368
  // if any adapter does not want any particular userId to be passed then adapter can use Array.filter(e => e.source != 'tdid')
358
369
  export function createEidsArray(bidRequestUserId) {
359
370
  let eids = [];
371
+
360
372
  for (const subModuleKey in bidRequestUserId) {
361
373
  if (bidRequestUserId.hasOwnProperty(subModuleKey)) {
362
374
  if (subModuleKey === 'pubProvidedId') {
363
375
  eids = eids.concat(bidRequestUserId['pubProvidedId']);
376
+ } else if (Array.isArray(bidRequestUserId[subModuleKey])) {
377
+ bidRequestUserId[subModuleKey].forEach((config, index, arr) => {
378
+ const eid = createEidObject(config, subModuleKey);
379
+
380
+ if (eid) {
381
+ eids.push(eid);
382
+ }
383
+ })
364
384
  } else {
365
385
  const eid = createEidObject(bidRequestUserId[subModuleKey], subModuleKey);
366
386
  if (eid) {
@@ -152,7 +152,7 @@ import {
152
152
  isEmpty
153
153
  } from '../../src/utils.js';
154
154
  import {getPPID as coreGetPPID} from '../../src/adserver.js';
155
- import {promiseControls} from '../../src/utils/promise.js';
155
+ import {defer, GreedyPromise} from '../../src/utils/promise.js';
156
156
 
157
157
  const MODULE_NAME = 'User ID';
158
158
  const COOKIE = 'cookie';
@@ -523,15 +523,11 @@ function addIdDataToAdUnitBids(adUnits, submodules) {
523
523
  });
524
524
  }
525
525
 
526
- function delayFor(ms) {
527
- return new Promise((resolve) => setTimeout(resolve, ms));
528
- }
529
-
530
526
  const INIT_CANCELED = {};
531
527
 
532
- function idSystemInitializer({delay = delayFor} = {}) {
533
- const startInit = promiseControls();
534
- const startCallbacks = promiseControls();
528
+ function idSystemInitializer({delay = GreedyPromise.timeout} = {}) {
529
+ const startInit = defer();
530
+ const startCallbacks = defer();
535
531
  let cancel;
536
532
  let initialized = false;
537
533
 
@@ -539,8 +535,8 @@ function idSystemInitializer({delay = delayFor} = {}) {
539
535
  if (cancel != null) {
540
536
  cancel.reject(INIT_CANCELED);
541
537
  }
542
- cancel = promiseControls();
543
- return Promise.race([promise, cancel.promise]);
538
+ cancel = defer();
539
+ return GreedyPromise.race([promise, cancel.promise]);
544
540
  }
545
541
 
546
542
  // grab a reference to global vars so that the promise chains remain isolated;
@@ -559,7 +555,7 @@ function idSystemInitializer({delay = delayFor} = {}) {
559
555
  }
560
556
 
561
557
  let done = cancelAndTry(
562
- Promise.all([hooksReady, startInit.promise])
558
+ GreedyPromise.all([hooksReady, startInit.promise])
563
559
  .then(() => gdprDataHandler.promise)
564
560
  .then(checkRefs((consentData) => {
565
561
  initSubmodules(initModules, allModules, consentData);
@@ -568,7 +564,7 @@ function idSystemInitializer({delay = delayFor} = {}) {
568
564
  .then(checkRefs(() => {
569
565
  const modWithCb = initModules.filter(item => isFn(item.callback));
570
566
  if (modWithCb.length) {
571
- return new Promise((resolve) => processSubmoduleCallbacks(modWithCb, resolve));
567
+ return new GreedyPromise((resolve) => processSubmoduleCallbacks(modWithCb, resolve));
572
568
  }
573
569
  }))
574
570
  );
@@ -592,7 +588,7 @@ function idSystemInitializer({delay = delayFor} = {}) {
592
588
  });
593
589
  }
594
590
  }
595
- if (refresh) {
591
+ if (refresh && initialized) {
596
592
  done = cancelAndTry(
597
593
  done
598
594
  .catch(() => null)
@@ -607,7 +603,7 @@ function idSystemInitializer({delay = delayFor} = {}) {
607
603
  return sm.callback != null;
608
604
  });
609
605
  if (cbModules.length) {
610
- return new Promise((resolve) => processSubmoduleCallbacks(cbModules, resolve));
606
+ return new GreedyPromise((resolve) => processSubmoduleCallbacks(cbModules, resolve));
611
607
  }
612
608
  }))
613
609
  );
@@ -640,8 +636,8 @@ function getPPID() {
640
636
  * @param {Object} reqBidsConfigObj required; This is the same param that's used in pbjs.requestBids.
641
637
  * @param {function} fn required; The next function in the chain, used by hook.js
642
638
  */
643
- export function requestBidsHook(fn, reqBidsConfigObj, {delay = delayFor} = {}) {
644
- Promise.race([
639
+ export function requestBidsHook(fn, reqBidsConfigObj, {delay = GreedyPromise.timeout} = {}) {
640
+ GreedyPromise.race([
645
641
  getUserIdsAsync(),
646
642
  delay(auctionDelay)
647
643
  ]).then(() => {
@@ -786,7 +782,16 @@ function refreshUserIds({submoduleNames} = {}, callback) {
786
782
  */
787
783
 
788
784
  function getUserIdsAsync() {
789
- return initIdSystem().then(() => getUserIds(), (e) => e === INIT_CANCELED ? getUserIdsAsync() : Promise.reject(e));
785
+ return initIdSystem().then(
786
+ () => getUserIds(),
787
+ (e) =>
788
+ e === INIT_CANCELED
789
+ // there's a pending refresh - because GreedyPromise runs this synchronously, we are now in the middle
790
+ // of canceling the previous init, before the refresh logic has had a chance to run.
791
+ // Use a "normal" Promise to clear the stack and let it complete (or this will just recurse infinitely)
792
+ ? Promise.resolve().then(getUserIdsAsync)
793
+ : GreedyPromise.reject(e)
794
+ );
790
795
  }
791
796
 
792
797
  /**
@@ -933,6 +938,8 @@ function updateSubmodules() {
933
938
  return;
934
939
  }
935
940
  // do this to avoid reprocessing submodules
941
+ // TODO: the logic does not match the comment - addedSubmodules is always a copy of submoduleRegistry
942
+ // (if it did it would not be correct - it's not enough to find new modules, as others may have been removed or changed)
936
943
  const addedSubmodules = submoduleRegistry.filter(i => !find(submodules, j => j.name === i.name));
937
944
 
938
945
  submodules.splice(0, submodules.length);
@@ -968,6 +975,17 @@ export function attachIdSystem(submodule) {
968
975
  if (!find(submoduleRegistry, i => i.name === submodule.name)) {
969
976
  submoduleRegistry.push(submodule);
970
977
  updateSubmodules();
978
+ // TODO: a test case wants this to work even if called after init (the setConfig({userId}))
979
+ // so we trigger a refresh. But is that even possible outside of tests?
980
+ initIdSystem({refresh: true, submoduleNames: [submodule.name]});
981
+ }
982
+ }
983
+
984
+ function normalizePromise(fn) {
985
+ // for public methods that return promises, make sure we return a "normal" one - to avoid
986
+ // exposing confusing stack traces
987
+ return function() {
988
+ return Promise.resolve(fn.apply(this, arguments));
971
989
  }
972
990
  }
973
991
 
@@ -976,7 +994,7 @@ export function attachIdSystem(submodule) {
976
994
  * so a callback is added to fire after the consentManagement module.
977
995
  * @param {{getConfig:function}} config
978
996
  */
979
- export function init(config, {delay = delayFor} = {}) {
997
+ export function init(config, {delay = GreedyPromise.timeout} = {}) {
980
998
  ppidSource = undefined;
981
999
  submodules = [];
982
1000
  configRegistry = [];
@@ -1021,10 +1039,10 @@ export function init(config, {delay = delayFor} = {}) {
1021
1039
  // exposing getUserIds function in global-name-space so that userIds stored in Prebid can be used by external codes.
1022
1040
  (getGlobal()).getUserIds = getUserIds;
1023
1041
  (getGlobal()).getUserIdsAsEids = getUserIdsAsEids;
1024
- (getGlobal()).getEncryptedEidsForSource = getEncryptedEidsForSource;
1042
+ (getGlobal()).getEncryptedEidsForSource = normalizePromise(getEncryptedEidsForSource);
1025
1043
  (getGlobal()).registerSignalSources = registerSignalSources;
1026
- (getGlobal()).refreshUserIds = refreshUserIds;
1027
- (getGlobal()).getUserIdsAsync = getUserIdsAsync;
1044
+ (getGlobal()).refreshUserIds = normalizePromise(refreshUserIds);
1045
+ (getGlobal()).getUserIdsAsync = normalizePromise(getUserIdsAsync);
1028
1046
  (getGlobal()).getUserIdsAsEidBySource = getUserIdsAsEidBySource;
1029
1047
  }
1030
1048
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prebid.js",
3
- "version": "6.28.0",
3
+ "version": "6.29.2",
4
4
  "description": "Header Bidding Management Library",
5
5
  "main": "src/prebid.js",
6
6
  "scripts": {
package/src/auction.js CHANGED
@@ -76,6 +76,7 @@ import {bidderSettings} from './bidderSettings.js';
76
76
  import * as events from './events.js'
77
77
  import adapterManager from './adapterManager.js';
78
78
  import CONSTANTS from './constants.json';
79
+ import {GreedyPromise} from './utils/promise.js';
79
80
 
80
81
  const { syncUsers } = userSync;
81
82
 
@@ -375,9 +376,9 @@ export function auctionCallbacks(auctionDone, auctionInstance, {index = auctionM
375
376
 
376
377
  function waitFor(requestId, result) {
377
378
  if (ready[requestId] == null) {
378
- ready[requestId] = Promise.resolve();
379
+ ready[requestId] = GreedyPromise.resolve();
379
380
  }
380
- ready[requestId] = ready[requestId].then(() => Promise.resolve(result).catch(() => {}))
381
+ ready[requestId] = ready[requestId].then(() => GreedyPromise.resolve(result).catch(() => {}))
381
382
  }
382
383
 
383
384
  function guard(bidderRequest, fn) {
@@ -389,9 +390,9 @@ export function auctionCallbacks(auctionDone, auctionInstance, {index = auctionM
389
390
  const wait = ready[bidderRequest.bidderRequestId];
390
391
  const orphanWait = ready['']; // also wait for "orphan" responses that are not associated with any request
391
392
  if ((wait != null || orphanWait != null) && timeRemaining > 0) {
392
- Promise.race([
393
- new Promise((resolve) => setTimeout(resolve, timeRemaining)),
394
- Promise.resolve(orphanWait).then(() => wait)
393
+ GreedyPromise.race([
394
+ GreedyPromise.timeout(timeRemaining),
395
+ GreedyPromise.resolve(orphanWait).then(() => wait)
395
396
  ]).then(fn);
396
397
  } else {
397
398
  fn();
@@ -1,10 +1,10 @@
1
1
  import {isStr, timestamp} from './utils.js';
2
+ import {defer, GreedyPromise} from './utils/promise.js';
2
3
 
3
4
  export class ConsentHandler {
4
5
  #enabled;
5
6
  #data;
6
- #promise;
7
- #resolve;
7
+ #defer;
8
8
  #ready;
9
9
  generatedTime;
10
10
 
@@ -12,17 +12,17 @@ export class ConsentHandler {
12
12
  this.reset();
13
13
  }
14
14
 
15
+ #resolve(data) {
16
+ this.#ready = true;
17
+ this.#data = data;
18
+ this.#defer.resolve(data);
19
+ }
20
+
15
21
  /**
16
22
  * reset this handler (mainly for tests)
17
23
  */
18
24
  reset() {
19
- this.#promise = new Promise((resolve) => {
20
- this.#resolve = (data) => {
21
- this.#ready = true;
22
- this.#data = data;
23
- resolve(data);
24
- };
25
- });
25
+ this.#defer = defer();
26
26
  this.#enabled = false;
27
27
  this.#data = null;
28
28
  this.#ready = false;
@@ -56,12 +56,12 @@ export class ConsentHandler {
56
56
  */
57
57
  get promise() {
58
58
  if (this.#ready) {
59
- return Promise.resolve(this.#data);
59
+ return GreedyPromise.resolve(this.#data);
60
60
  }
61
61
  if (!this.#enabled) {
62
62
  this.#resolve(null);
63
63
  }
64
- return this.#promise;
64
+ return this.#defer.promise;
65
65
  }
66
66
 
67
67
  setConsentData(data, time = timestamp()) {
package/src/hook.js CHANGED
@@ -1,11 +1,11 @@
1
1
  import funHooks from 'fun-hooks/no-eval/index.js';
2
- import {promiseControls} from './utils/promise.js';
2
+ import {defer} from './utils/promise.js';
3
3
 
4
4
  export let hook = funHooks({
5
5
  ready: funHooks.SYNC | funHooks.ASYNC | funHooks.QUEUE
6
6
  });
7
7
 
8
- const readyCtl = promiseControls();
8
+ const readyCtl = defer();
9
9
  hook.ready = (() => {
10
10
  const ready = hook.ready;
11
11
  return function () {
@@ -48,7 +48,7 @@ export function newStorageManager({gvlid, moduleName, bidderCode, moduleType} =
48
48
  let hookDetails = {
49
49
  hasEnforcementHook: false
50
50
  }
51
- validateStorageEnforcement(gvlid, bidderCode || moduleName, hookDetails, function(result) {
51
+ validateStorageEnforcement(gvlid, bidderCode || moduleName, moduleType, hookDetails, function(result) {
52
52
  if (result && result.hasEnforcementHook) {
53
53
  value = cb(result);
54
54
  } else {
@@ -303,7 +303,7 @@ export function newStorageManager({gvlid, moduleName, bidderCode, moduleType} =
303
303
  /**
304
304
  * This hook validates the storage enforcement if gdprEnforcement module is included
305
305
  */
306
- export const validateStorageEnforcement = hook('async', function(gvlid, moduleName, hookDetails, callback) {
306
+ export const validateStorageEnforcement = hook('async', function(gvlid, moduleName, moduleType, hookDetails, callback) {
307
307
  callback(hookDetails);
308
308
  }, 'validateStorageEnforcement');
309
309
 
@@ -322,12 +322,13 @@ export function getCoreStorageManager(moduleName) {
322
322
  * @param {Number=} gvlid? Vendor id - required for proper GDPR integration
323
323
  * @param {string=} bidderCode? - required for bid adapters
324
324
  * @param {string=} moduleName? module name
325
+ * @param {string=} moduleType? module type
325
326
  */
326
- export function getStorageManager({gvlid, moduleName, bidderCode} = {}) {
327
+ export function getStorageManager({gvlid, moduleName, bidderCode, moduleType} = {}) {
327
328
  if (arguments.length > 1 || (arguments.length > 0 && !isPlainObject(arguments[0]))) {
328
329
  throw new Error('Invalid invocation for getStorageManager')
329
330
  }
330
- return newStorageManager({gvlid, moduleName, bidderCode});
331
+ return newStorageManager({gvlid, moduleName, bidderCode, moduleType});
331
332
  }
332
333
 
333
334
  export function resetData() {