Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add TCF2 Support for Invibes #5378

Merged
merged 3 commits into from
Jul 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 62 additions & 3 deletions modules/invibesBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import * as utils from '../src/utils.js';
import { registerBidder } from '../src/adapters/bidderFactory.js';
import { getStorageManager } from '../src/storageManager.js';
const storage = getStorageManager();

const CONSTANTS = {
BIDDER_CODE: 'invibes',
Expand All @@ -14,8 +13,11 @@ const CONSTANTS = {
INVIBES_VENDOR_ID: 436
};

const storage = getStorageManager(CONSTANTS.INVIBES_VENDOR_ID);

export const spec = {
aleksatr marked this conversation as resolved.
Show resolved Hide resolved
code: CONSTANTS.BIDDER_CODE,
gvlid: CONSTANTS.INVIBES_VENDOR_ID,
/**
* @param {object} bid
* @return boolean
Expand Down Expand Up @@ -364,13 +366,70 @@ function acceptPostMessage(e) {
}

function readGdprConsent(gdprConsent) {
if (gdprConsent && gdprConsent.vendorData && gdprConsent.vendorData.vendorConsents) {
return !!gdprConsent.vendorData.vendorConsents[CONSTANTS.INVIBES_VENDOR_ID.toString(10)] === true ? 2 : -2;
if (gdprConsent && gdprConsent.vendorData) {
if (!gdprConsent.vendorData.gdprApplies || gdprConsent.vendorData.hasGlobalConsent) {
return 2;
}

let purposeConsents = getPurposeConsents(gdprConsent.vendorData);

if (purposeConsents == null) { return 0; }
let properties = Object.keys(purposeConsents);
let purposeConsentsCounter = getPurposeConsentsCounter(gdprConsent.vendorData);

if (properties.length < purposeConsentsCounter) {
return 0;
}

for (let i = 0; i < purposeConsentsCounter; i++) {
if (!purposeConsents[properties[i]] || purposeConsents[properties[i]] === 'false') { return 0; }
}

let vendorConsents = getVendorConsents(gdprConsent.vendorData);
if (vendorConsents == null || vendorConsents[CONSTANTS.INVIBES_VENDOR_ID.toString(10)] == null) {
return 4;
}

if (vendorConsents[CONSTANTS.INVIBES_VENDOR_ID.toString(10)] === false) { return 0; }

return 2;
}

return 0;
}

function getPurposeConsentsCounter(vendorData) {
if (vendorData.purpose && vendorData.purpose.consents) {
return 10;
}

return 5;
}

function getPurposeConsents(vendorData) {
if (vendorData.purpose && vendorData.purpose.consents) {
return vendorData.purpose.consents;
}

if (vendorData.purposeConsents) {
return vendorData.purposeConsents;
}

return null;
}

function getVendorConsents(vendorData) {
if (vendorData.vendor && vendorData.vendor.consents) {
return vendorData.vendor.consents;
}

if (vendorData.vendorConsents) {
return vendorData.vendorConsents;
}

return null;
}

const ivLogger = initLogger();

/// Local domain cookie management =====================
Expand Down
Loading