Skip to content

Commit

Permalink
TCF Purpose 1 enforcement (#5018)
Browse files Browse the repository at this point in the history
* TCF Purpose 1 enforcement

* some more unit tests and revert hello world page

* some updates and unit test

* remove unwanted comment

* Adapter updates and some refactoring

* add expires for ie11

* adding withCredentials false to appnexus adapter

* improving conditions

* improving conditions

* Including changes for liveintent

Co-authored-by: Jaimin Panchal <email@example.com>
  • Loading branch information
jaiminpanchal27 and Jaimin Panchal committed Mar 31, 2020
1 parent c1ccaf0 commit 3ee2c3d
Show file tree
Hide file tree
Showing 79 changed files with 1,598 additions and 521 deletions.
2 changes: 1 addition & 1 deletion integrationExamples/gpt/hello_world.html
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,4 @@ <h5>Div-1</h5>
</script>
</div>
</body>
</html>
</html>
1 change: 1 addition & 0 deletions modules/aardvarkBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export function resetUserSync() {

export const spec = {
code: BIDDER_CODE,
gvlid: 52,
aliases: ['adsparc', 'safereach'],

isBidRequestValid: function(bid) {
Expand Down
11 changes: 7 additions & 4 deletions modules/adagioBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {registerBidder} from '../src/adapters/bidderFactory.js';
import { loadExternalScript } from '../src/adloader.js'
import JSEncrypt from 'jsencrypt/bin/jsencrypt.js';
import sha256 from 'crypto-js/sha256.js';
import { getStorageManager } from '../src/storageManager.js';

const BIDDER_CODE = 'adagio';
const VERSION = '2.1.0';
Expand All @@ -12,6 +13,8 @@ const ENDPOINT = 'https://mp.4dex.io/prebid';
const SUPPORTED_MEDIA_TYPES = ['banner'];
const ADAGIO_TAG_URL = 'https://script.4dex.io/localstore.js';
const ADAGIO_LOCALSTORAGE_KEY = 'adagioScript';
const GVLID = 617;
const storage = getStorageManager(GVLID);

export const ADAGIO_PUBKEY = `-----BEGIN PUBLIC KEY-----
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC9el0+OEn6fvEh1RdVHQu4cnT0
Expand All @@ -22,7 +25,7 @@ pV6EP3MTLosuUEpLaQIDAQAB

export function getAdagioScript() {
try {
const ls = utils.getDataFromLocalStorage(ADAGIO_LOCALSTORAGE_KEY);
const ls = storage.getDataFromLocalStorage(ADAGIO_LOCALSTORAGE_KEY);

if (!ls) {
utils.logWarn('Adagio Script not found');
Expand All @@ -33,7 +36,7 @@ export function getAdagioScript() {

if (!hashRgx.test(ls)) {
utils.logWarn('No hash found in Adagio script');
utils.removeDataFromLocalStorage(ADAGIO_LOCALSTORAGE_KEY);
storage.removeDataFromLocalStorage(ADAGIO_LOCALSTORAGE_KEY);
} else {
const r = ls.match(hashRgx);
const hash = r[2];
Expand All @@ -47,7 +50,7 @@ export function getAdagioScript() {
Function(ls)(); // eslint-disable-line no-new-func
} else {
utils.logWarn('Invalid Adagio script found');
utils.removeDataFromLocalStorage(ADAGIO_LOCALSTORAGE_KEY);
storage.removeDataFromLocalStorage(ADAGIO_LOCALSTORAGE_KEY);
}
}
} catch (err) {
Expand Down Expand Up @@ -341,7 +344,7 @@ function _getGdprConsent(bidderRequest) {

export const spec = {
code: BIDDER_CODE,

gvlid: GVLID,
supportedMediaType: SUPPORTED_MEDIA_TYPES,

isBidRequestValid: function (bid) {
Expand Down
6 changes: 4 additions & 2 deletions modules/adkernelAdnAnalyticsAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ import adapterManager from '../src/adapterManager.js';
import {parse} from '../src/url.js';
import * as utils from '../src/utils.js';
import {ajax} from '../src/ajax.js';
import { getStorageManager } from '../src/storageManager.js';

const ANALYTICS_VERSION = '1.0.1';
const DEFAULT_QUEUE_TIMEOUT = 4000;
const DEFAULT_HOST = 'tag.adkernel.com';
const storageObj = getStorageManager();

const ADK_HB_EVENTS = {
AUCTION_INIT: 'auctionInit',
Expand Down Expand Up @@ -175,10 +177,10 @@ const ORGANIC = '(organic)';

export let storage = {
getItem: (name) => {
return utils.getDataFromLocalStorage(name);
return storageObj.getDataFromLocalStorage(name);
},
setItem: (name, value) => {
utils.setDataInLocalStorage(name, value);
storageObj.setDataInLocalStorage(name, value);
}
};

Expand Down
8 changes: 5 additions & 3 deletions modules/adspendBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import { ajax } from '../src/ajax.js'
import { config } from '../src/config.js';
import { registerBidder } from '../src/adapters/bidderFactory.js';
import { BANNER } from '../src/mediaTypes.js';
import { getStorageManager } from '../src/storageManager.js';

const storage = getStorageManager();
const BIDDER_CODE = 'adspend';
const BID_URL = 'https://rtb.com.ru/headerbidding-bid';
const SYNC_URL = 'https://rtb.com.ru/headerbidding-sync?uid={UUID}';
Expand Down Expand Up @@ -40,7 +42,7 @@ export const spec = {
bid.params.bidfloor &&
bid.crumbs.pubcid &&
utils.checkCookieSupport() &&
utils.cookiesAreEnabled()
storage.cookiesAreEnabled()
);
},

Expand Down Expand Up @@ -145,11 +147,11 @@ export const spec = {
}

const getUserID = () => {
const i = utils.getCookie(COOKIE_NAME);
const i = storage.getCookie(COOKIE_NAME);

if (i === null) {
const uuid = utils.generateUUID();
utils.setCookie(COOKIE_NAME, uuid);
storage.setCookie(COOKIE_NAME, uuid);
return uuid;
}
return i;
Expand Down
1 change: 1 addition & 0 deletions modules/adtelligentBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const syncsCache = {};

export const spec = {
code: BIDDER_CODE,
gvlid: 410,
aliases: ['onefiftytwomedia', 'selectmedia'],
supportedMediaTypes: [VIDEO, BANNER],
isBidRequestValid: function (bid) {
Expand Down
1 change: 1 addition & 0 deletions modules/aolBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ function resolveEndpointCode(bid) {

export const spec = {
code: AOL_BIDDERS_CODES.AOL,
gvlid: 25,
aliases: [AOL_BIDDERS_CODES.ONEMOBILE, AOL_BIDDERS_CODES.ONEDISPLAY],
supportedMediaTypes: [BANNER],
isBidRequestValid(bid) {
Expand Down
28 changes: 25 additions & 3 deletions modules/appnexusBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { auctionManager } from '../src/auctionManager.js';
import find from 'core-js/library/fn/array/find.js';
import includes from 'core-js/library/fn/array/includes.js';
import { OUTSTREAM, INSTREAM } from '../src/video.js';
import { getStorageManager } from '../src/storageManager.js';

const BIDDER_CODE = 'appnexus';
const URL = 'https://ib.adnxs.com/ut/v3/prebid';
Expand Down Expand Up @@ -38,9 +39,12 @@ const mappingFileUrl = 'https://acdn.adnxs.com/prebid/appnexus-mapping/mappings.
const SCRIPT_TAG_START = '<script';
const VIEWABILITY_URL_START = /\/\/cdn\.adnxs\.com\/v/;
const VIEWABILITY_FILE_NAME = 'trk.js';
const GVLID = 32;
const storage = getStorageManager(GVLID, BIDDER_CODE);

export const spec = {
code: BIDDER_CODE,
gvlid: GVLID,
aliases: ['appnexusAst', 'brealtime', 'emxdigital', 'pagescience', 'defymedia', 'gourmetads', 'matomy', 'featureforward', 'oftmedia', 'districtm', 'adasta'],
supportedMediaTypes: [BANNER, VIDEO, NATIVE],

Expand Down Expand Up @@ -93,7 +97,7 @@ export const spec = {
let debugObj = {};
let debugObjParams = {};
const debugCookieName = 'apn_prebid_debug';
const debugCookie = utils.getCookie(debugCookieName) || null;
const debugCookie = storage.getCookie(debugCookieName) || null;

if (debugCookie) {
try {
Expand Down Expand Up @@ -404,8 +408,24 @@ function getViewabilityScriptUrlFromPayload(viewJsPayload) {
return jsTrackerSrc;
}

function hasPurpose1Consent(bidderRequest) {
let result = true;
if (bidderRequest && bidderRequest.gdprConsent) {
if (bidderRequest.gdprConsent.gdprApplies && bidderRequest.gdprConsent.apiVersion === 2) {
result = !!(utils.deepAccess(bidderRequest.gdprConsent, `vendorData.vendor.consents.${GVLID}`));
}
}
return result;
}

function formatRequest(payload, bidderRequest) {
let request = [];
let options = {};
if (!hasPurpose1Consent(bidderRequest)) {
options = {
withCredentials: false
}
}

if (payload.tags.length > MAX_IMPS_PER_REQUEST) {
const clonedPayload = utils.deepClone(payload);
Expand All @@ -417,7 +437,8 @@ function formatRequest(payload, bidderRequest) {
method: 'POST',
url: URL,
data: payloadString,
bidderRequest
bidderRequest,
options
});
});
} else {
Expand All @@ -426,7 +447,8 @@ function formatRequest(payload, bidderRequest) {
method: 'POST',
url: URL,
data: payloadString,
bidderRequest
bidderRequest,
options
};
}

Expand Down
7 changes: 5 additions & 2 deletions modules/audigentRtdProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ import {getGlobal} from '../src/prebidGlobal.js';
import * as utils from '../src/utils.js';
import {submodule} from '../src/hook.js';
import {ajax} from '../src/ajax.js';
import { getStorageManager } from '../src/storageManager.js';

const storage = getStorageManager();

/** @type {string} */
const MODULE_NAME = 'realTimeData';
Expand All @@ -33,12 +36,12 @@ let _moduleParams = {};
*/

export function setData(data) {
utils.setDataInLocalStorage('__adgntseg', JSON.stringify(data));
storage.setDataInLocalStorage('__adgntseg', JSON.stringify(data));
}

function getSegments(adUnits, onDone) {
try {
let jsonData = utils.getDataFromLocalStorage('__adgntseg');
let jsonData = storage.getDataFromLocalStorage('__adgntseg');
if (jsonData) {
let data = JSON.parse(jsonData);
if (data.audigent_segments) {
Expand Down
5 changes: 4 additions & 1 deletion modules/bidfluenceBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import * as utils from '../src/utils.js';
import { registerBidder } from '../src/adapters/bidderFactory.js';
import { getStorageManager } from '../src/storageManager.js';

const storage = getStorageManager();
const BIDDER_CODE = 'bidfluence';

function stdTimezoneOffset(t) {
Expand Down Expand Up @@ -46,7 +49,7 @@ export const spec = {
var payload = {
v: '2.0',
azr: true,
ck: utils.cookiesAreEnabled(),
ck: storage.cookiesAreEnabled(),
re: refInfo ? refInfo.referer : '',
st: refInfo ? refInfo.stack : [],
tz: getBdfTz(new Date()),
Expand Down
5 changes: 4 additions & 1 deletion modules/browsiRtdProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ import * as utils from '../src/utils.js';
import {submodule} from '../src/hook.js';
import {ajaxBuilder} from '../src/ajax.js';
import {loadExternalScript} from '../src/adloader.js';
import { getStorageManager } from '../src/storageManager.js';

const storage = getStorageManager();

/** @type {string} */
const MODULE_NAME = 'realTimeData';
Expand Down Expand Up @@ -62,7 +65,7 @@ function collectData() {
const doc = win.document;
let browsiData = null;
try {
browsiData = utils.getDataFromLocalStorage('__brtd');
browsiData = storage.getDataFromLocalStorage('__brtd');
} catch (e) {
utils.logError('unable to parse __brtd');
}
Expand Down
10 changes: 6 additions & 4 deletions modules/categoryTranslation.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@
import { config } from '../src/config.js';
import { setupBeforeHookFnOnce, hook } from '../src/hook.js';
import { ajax } from '../src/ajax.js';
import { timestamp, logError, setDataInLocalStorage, getDataFromLocalStorage } from '../src/utils.js';
import { timestamp, logError } from '../src/utils.js';
import { addBidResponse } from '../src/auction.js';
import { getCoreStorageManager } from '../src/storageManager.js';

export const storage = getCoreStorageManager('categoryTranslation');
const DEFAULT_TRANSLATION_FILE_URL = 'https://cdn.jsdelivr.net/gh/prebid/category-mapping-file@1/freewheel-mapping.json';
const DEFAULT_IAB_TO_FW_MAPPING_KEY = 'iabToFwMappingkey';
const DEFAULT_IAB_TO_FW_MAPPING_KEY_PUB = 'iabToFwMappingkeyPub';
Expand All @@ -43,7 +45,7 @@ export function getAdserverCategoryHook(fn, adUnitCode, bid) {
let localStorageKey = (config.getConfig('brandCategoryTranslation.translationFile')) ? DEFAULT_IAB_TO_FW_MAPPING_KEY_PUB : DEFAULT_IAB_TO_FW_MAPPING_KEY;

if (bid.meta && !bid.meta.adServerCatId) {
let mapping = getDataFromLocalStorage(localStorageKey);
let mapping = storage.getDataFromLocalStorage(localStorageKey);
if (mapping) {
try {
mapping = JSON.parse(mapping);
Expand All @@ -65,15 +67,15 @@ export function getAdserverCategoryHook(fn, adUnitCode, bid) {

export function initTranslation(url, localStorageKey) {
setupBeforeHookFnOnce(addBidResponse, getAdserverCategoryHook, 50);
let mappingData = getDataFromLocalStorage(localStorageKey);
let mappingData = storage.getDataFromLocalStorage(localStorageKey);
if (!mappingData || timestamp() < mappingData.lastUpdated + refreshInDays * 24 * 60 * 60 * 1000) {
ajax(url,
{
success: (response) => {
try {
response = JSON.parse(response);
response['lastUpdated'] = timestamp();
setDataInLocalStorage(localStorageKey, JSON.stringify(response));
storage.setDataInLocalStorage(localStorageKey, JSON.stringify(response));
} catch (error) {
logError('Failed to parse translation mapping file');
}
Expand Down
5 changes: 4 additions & 1 deletion modules/ccxBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import * as utils from '../src/utils.js'
import { registerBidder } from '../src/adapters/bidderFactory.js'
import { config } from '../src/config.js'
import { getStorageManager } from '../src/storageManager.js';

const storage = getStorageManager();
const BIDDER_CODE = 'ccx'
const BID_URL = 'https://delivery.clickonometrics.pl/ortb/prebid/bid'
const SUPPORTED_VIDEO_PROTOCOLS = [2, 3, 5, 6]
Expand Down Expand Up @@ -170,7 +173,7 @@ export const spec = {
requestBody.site = _getSiteObj(bidderRequest)
requestBody.device = _getDeviceObj()
requestBody.id = bidderRequest.bids[0].auctionId
requestBody.ext = {'ce': (utils.cookiesAreEnabled() ? 1 : 0)}
requestBody.ext = {'ce': (storage.cookiesAreEnabled() ? 1 : 0)}

// Attaching GDPR Consent Params
if (bidderRequest && bidderRequest.gdprConsent) {
Expand Down
5 changes: 4 additions & 1 deletion modules/cedatoBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import * as utils from '../src/utils.js';
import { registerBidder } from '../src/adapters/bidderFactory.js';
import { BANNER, VIDEO } from '../src/mediaTypes.js';
import { getStorageManager } from '../src/storageManager.js';

const storage = getStorageManager();

const BIDDER_CODE = 'cedato';
const BID_URL = 'https://h.cedatoplayer.com/hb';
Expand All @@ -19,7 +22,7 @@ export const spec = {
bid.params &&
bid.params.player_id &&
utils.checkCookieSupport() &&
utils.cookiesAreEnabled()
storage.cookiesAreEnabled()
);
},

Expand Down
11 changes: 8 additions & 3 deletions modules/conversantBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import * as utils from '../src/utils.js';
import {registerBidder} from '../src/adapters/bidderFactory.js';
import { BANNER, VIDEO } from '../src/mediaTypes.js';
import { getStorageManager } from '../src/storageManager.js';

const GVLID = 24;
export const storage = getStorageManager(GVLID);

const BIDDER_CODE = 'conversant';
const URL = 'https://web.hb.ad.cpe.dotomi.com/s2s/header/24';

export const spec = {
code: BIDDER_CODE,
gvlid: GVLID,
aliases: ['cnvr'], // short code
supportedMediaTypes: [BANNER, VIDEO],

Expand Down Expand Up @@ -343,13 +348,13 @@ function readStoredValue(key) {
let storedValue;
try {
// check cookies first
storedValue = utils.getCookie(key);
storedValue = storage.getCookie(key);

if (!storedValue) {
// check expiration time before reading local storage
const storedValueExp = utils.getDataFromLocalStorage(`${key}_exp`);
const storedValueExp = storage.getDataFromLocalStorage(`${key}_exp`);
if (storedValueExp === '' || (storedValueExp && (new Date(storedValueExp)).getTime() - Date.now() > 0)) {
storedValue = utils.getDataFromLocalStorage(key);
storedValue = storage.getDataFromLocalStorage(key);
storedValue = storedValue ? decodeURIComponent(storedValue) : storedValue;
}
}
Expand Down
Loading

0 comments on commit 3ee2c3d

Please sign in to comment.