| Optional. Default curation ids are specified for main bidders |
### Overriding data sharing function
-As indicated above, it is possible to provide your own bid augmentation
-functions. This is useful if you know a bid adapter's API supports segment
-fields which aren't specifically being added to request objects in the Prebid
-bid adapter.
-Please see the following example, which provides a function to modify bids for
-a bid adapter called ix and overrides the appnexus.
+As indicated above, it is possible to provide your own bid augmentation functions. This is useful if you know a bid adapter's API supports segment fields which aren't specifically being added to request objects in the Prebid bid adapter.
+Please see the following example, which provides a function to modify bids for a bid adapter called ix and overrides the appnexus.
data Object format for usage in this kind of function :
+
+```json
{
- "segments":[111111,222222],
- "contextual_categories":{"333333":100},
- "shared_taxonomy":{
- "27446":{ //CurationId
- "segments":[444444,555555],
- "contextual_categories":{"666666":100}
- }
- }
+ "segments": [
+ 111111,
+ 222222
+ ],
+ "segtaxid": null,
+ "cattaxid": null,
+ "contextual_categories": {
+ "333333": 100
+ },
+ "shared_taxonomy": {
+ "27440": {
+ "segments": [
+ 444444,
+ 555555
+ ],
+ "segtaxid": 552,
+ "cattaxid": 553,
+ "contextual_categories": {
+ "666666": 100
+ }
+ }
+ },
+ "global_taxonomy": {
+ "9998": {
+ "segments": [
+ 123,
+ 234
+ ],
+ "segtaxid": 4,
+ "cattaxid": 7,
+ "contextual_categories": {
+ "345": 100,
+ "456": 100
+ }
+ },
+ "9999": {
+ "segments": [
+ 12345,
+ 23456
+ ],
+ "segtaxid": 550,
+ "cattaxid": 551,
+ "contextual_categories": {
+ "34567": 100,
+ "45678": 100
+ }
+ }
+ }
}
-
```
+
+```javascript
function overrideAppnexus (adUnit, segmentsArray, dataObject, bid) {
- for (var i = 0; i < segmentsArray.length; i++) {
+ for (var i = 0; i < segmentsArray.length; i++) {
if (segmentsArray[i]) {
bid.params.user.segments.push(segmentsArray[i]);
}
}
}
-pbjs.setConfig(
- ...
+pbjs.setConfig({
+ // ...
realTimeData: {
auctionDelay: 1000,
dataProviders: [
@@ -134,18 +185,17 @@ pbjs.setConfig(
name: "SirdataRTDModule",
waitForIt: true,
params: {
- partnerId: 1,
+ partnerId: 1,
key: 1,
- setGptKeyValues: true,
- contextualMinRelevancyScore: 50, //Min score to keep contextual category in the bidders (0-100 scale)
- actualUrl: actual_url, //top location url, for contextual categories
+ setGptKeyValues: true,
+ contextualMinRelevancyScore: 50, //Min score to keep contextual category in the bidders (0-100 scale)
+ actualUrl: actual_url, //top location url, for contextual categories
bidders: [{
bidder: 'appnexus',
customFunction: overrideAppnexus,
curationId: '111'
},{
bidder: 'ix',
- sizeLimit: 1200, //specific to Index Exchange
customFunction: function(adUnit, segmentsArray, dataObject, bid) {
bid.params.contextual.push(dataObject.contextual_categories);
},
@@ -153,17 +203,19 @@ pbjs.setConfig(
}
}
]
- }
+ },
...
-}
+});
```
### Testing
To view an example of available segments returned by Sirdata's backends:
-`gulp serve --modules=rtdModule,sirdataRtdProvider,appnexusBidAdapter`
+```bash
+gulp serve --modules=rtdModule,sirdataRtdProvider,appnexusBidAdapter
+```
and then point your browser at:
-`http://localhost:9999/integrationExamples/gpt/sirdataRtdProvider_example.html`
\ No newline at end of file
+[http://localhost:9999/integrationExamples/gpt/sirdataRtdProvider_example.html]
diff --git a/test/spec/modules/sirdataRtdProvider_spec.js b/test/spec/modules/sirdataRtdProvider_spec.js
index fbb5967bc20..39962fc1664 100644
--- a/test/spec/modules/sirdataRtdProvider_spec.js
+++ b/test/spec/modules/sirdataRtdProvider_spec.js
@@ -1,21 +1,123 @@
-import {addSegmentData, getSegmentsAndCategories, sirdataSubmodule, setOrtb2} from 'modules/sirdataRtdProvider.js';
+import {
+ addSegmentData,
+ getSegmentsAndCategories,
+ getUidFromStorage,
+ loadCustomFunction,
+ mergeEuidsArrays,
+ onDataDeletionRequest,
+ onDocumentReady,
+ postContentForSemanticAnalysis,
+ removePII,
+ sanitizeContent,
+ setOrtb2,
+ setUidInStorage,
+ sirdataSubmodule
+} from 'modules/sirdataRtdProvider.js';
+import {expect} from 'chai';
+import {deepSetValue} from 'src/utils.js';
import {server} from 'test/mocks/xhr.js';
const responseHeader = {'Content-Type': 'application/json'};
describe('sirdataRtdProvider', function () {
- describe('sirdataSubmodule', function () {
+ describe('sirdata Submodule init', function () {
it('exists', function () {
expect(sirdataSubmodule.init).to.be.a('function');
});
it('successfully instantiates', function () {
- expect(sirdataSubmodule.init()).to.equal(true);
+ const moduleConfig = {
+ params: {
+ partnerId: 1,
+ key: 1,
+ }
+ };
+ expect(sirdataSubmodule.init(moduleConfig)).to.equal(true);
});
it('has the correct module name', function () {
expect(sirdataSubmodule.name).to.equal('SirdataRTDModule');
});
});
+ describe('Sanitize content', function () {
+ it('removes PII from content', function () {
+ let doc = document.implementation.createHTMLDocument('');
+ let div = doc.createElement('div');
+ div.className = 'test';
+ div.setAttribute('test', 'test');
+ div.textContent = 'My email is test@test.com, My bank account number is 123456789012, my SSN is 123-45-6789, and my credit card number is 1234 5678 9101 1121.Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.';
+ let div2 = doc.createElement('div');
+ let div3 = doc.createElement('div');
+ div3.innerText = 'hello';
+ div2.appendChild(div3);
+ div.appendChild(div2);
+ doc.body.appendChild(div);
+ const cleanedDom = removePII(doc.documentElement.innerHTML);
+ const sanitizedDom = sanitizeContent(doc);
+ expect(cleanedDom).to.equal('My email is , My bank account number is , my SSN is , and my credit card number is .Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
');
+ expect(sanitizedDom.documentElement.innerHTML).to.equal('My email is , My bank account number is , my SSN is , and my credit card number is .Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
');
+ });
+ });
+
+ describe('setUidInStorage', function () {
+ it('sets Id in Storage', function () {
+ setUidInStorage('123456789');
+ let val = getUidFromStorage();
+ expect(val).to.deep.equal([{source: 'sddan.com', uids: [{id: '123456789', atype: 1}]}]);
+ });
+ });
+
+ describe('mergeEuidsArrays', function () {
+ it('merges Euids Arrays', function () {
+ const object1 = [{source: 'sddan.com', uids: [{id: '123456789', atype: 1}]}];
+ const object2 = [{source: 'sddan.com', uids: [{id: '987654321', atype: 1}]}];
+ const object3 = mergeEuidsArrays(object1, object2);
+ expect(object3).to.deep.equal([{source: 'sddan.com', uids: [{id: '123456789', atype: 1}, {id: '987654321', atype: 1}]}]);
+ });
+ });
+
+ describe('onDocumentReady', function () {
+ it('on Document Ready function execution', function () {
+ const testString = '';
+ const testFunction = function() { return true; };
+ let resString;
+ try {
+ resString = onDocumentReady(testString);
+ } catch (e) {}
+ expect(resString).to.be.false;
+ let resFunction = onDocumentReady(testFunction);
+ expect(resFunction).to.be.true;
+ });
+ });
+
+ describe('postContentForSemanticAnalysis', function () {
+ it('gets content for analysis', function () {
+ let res = postContentForSemanticAnalysis('1223456', 'https://www.sirdata.com/');
+ let resEmpty = postContentForSemanticAnalysis('1223456', '');
+ expect(res).to.be.true;
+ expect(resEmpty).to.be.false;
+ });
+ });
+
+ describe('loadCustomFunction', function () {
+ it('load function', function () {
+ const res = loadCustomFunction(function(...args) { return true; }, {}, {}, {}, {});
+ expect(res).to.be.true;
+ });
+ });
+
+ describe('onDataDeletionRequest', function () {
+ it('destroy id', function () {
+ const moduleConfig = {
+ params: {
+ partnerId: 1,
+ key: 1,
+ }
+ };
+ const res = onDataDeletionRequest(moduleConfig);
+ expect(res).to.be.true;
+ });
+ });
+
describe('Add Segment Data', function () {
it('adds segment data', function () {
const firstConfig = {
@@ -25,9 +127,12 @@ describe('sirdataRtdProvider', function () {
setGptKeyValues: true,
gptCurationId: 27449,
contextualMinRelevancyScore: 50,
+ actualUrl: 'https://www.sirdata.com/',
+ cookieAccessGranted: true,
bidders: []
}
};
+ sirdataSubmodule.init(firstConfig);
let adUnits = [
{
@@ -68,13 +173,12 @@ describe('sirdataRtdProvider', function () {
'segtaxid': 4,
'cattaxid': 7,
'contextual_categories': {'345': 100, '456': 100}
- }
+ },
+ 'sddan_id': '123456789',
+ 'post_content_token': '987654321'
}
- };
-
- addSegmentData(firstReqBidsConfigObj, firstData, firstConfig, () => {
- });
-
+ }
+ addSegmentData(firstReqBidsConfigObj, firstData, adUnits, function() { return true; });
expect(firstReqBidsConfigObj.ortb2Fragments.global.user.data[0].ext.segtax).to.equal(4);
});
});
@@ -109,6 +213,7 @@ describe('sirdataRtdProvider', function () {
}]
}
};
+ sirdataSubmodule.init(config);
let reqBidsConfigObj = {
adUnits: [{
@@ -197,11 +302,13 @@ describe('sirdataRtdProvider', function () {
'cattaxid': 7,
'contextual_categories': {'345': 100, '456': 100}
}
- }
+ },
+ 'sddan_id': '123456789',
+ 'post_content_token': '987654321'
};
getSegmentsAndCategories(reqBidsConfigObj, () => {
- }, config, {});
+ }, {});
let request = server.requests[0];
request.respond(200, responseHeader, JSON.stringify(data));
@@ -228,16 +335,6 @@ describe('sirdataRtdProvider', function () {
describe('Set ortb2 for bidder', function () {
it('set ortb2 for a givent bidder', function () {
- const config = {
- params: {
- setGptKeyValues: false,
- contextualMinRelevancyScore: 50,
- bidders: [{
- bidder: 'appnexus',
- }]
- }
- };
-
let reqBidsConfigObj = {
adUnits: [{
bids: [{
@@ -252,22 +349,6 @@ describe('sirdataRtdProvider', function () {
}
};
- let data = {
- 'segments': [111111, 222222],
- 'segtaxid': null,
- 'cattaxid': null,
- 'contextual_categories': {'333333': 100},
- 'shared_taxonomy': {
- '27440': {
- 'segments': [444444, 555555],
- 'segtaxid': null,
- 'cattaxid': null,
- 'contextual_categories': {'666666': 100}
- }
- },
- 'global_taxonomy': {}
- };
-
window.googletag = window.googletag || {};
window.googletag.cmd = window.googletag.cmd || [];
From 0300f1cc17e8910ba9b6666e5d8fe5e635a6a480 Mon Sep 17 00:00:00 2001
From: nouchy <33549554+nouchy@users.noreply.github.com>
Date: Mon, 20 May 2024 22:26:46 +0200
Subject: [PATCH 02/11] multi-character sanitization
Modify regular expression to match comments containing newlines.
---
modules/sirdataRtdProvider.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/modules/sirdataRtdProvider.js b/modules/sirdataRtdProvider.js
index f30550cf623..d2319998522 100644
--- a/modules/sirdataRtdProvider.js
+++ b/modules/sirdataRtdProvider.js
@@ -318,7 +318,7 @@ export function sanitizeContent(content) {
// Clean any potential PII
content.documentElement.innerHTML = removePII(content.documentElement.innerHTML);
// Compress the content
- content.documentElement.innerHTML = content.documentElement.innerHTML.replace(/\s+/g, ' ').replace(/>\s+<').replace(//g, '');
+ content.documentElement.innerHTML = content.documentElement.innerHTML.replace(/\s+/g, ' ').replace(/>\s+<').replace(//g, '')
}
return content;
}
From 0eb83e5b84d7e712623ddaf64eea485dc6db0c48 Mon Sep 17 00:00:00 2001
From: nouchy <33549554+nouchy@users.noreply.github.com>
Date: Tue, 21 May 2024 09:56:10 +0200
Subject: [PATCH 03/11] recursively removing elements to avoid an HTML element
injection vulnerability
---
modules/sirdataRtdProvider.js | 25 ++++++++++++++++++++
test/spec/modules/sirdataRtdProvider_spec.js | 4 ++--
2 files changed, 27 insertions(+), 2 deletions(-)
diff --git a/modules/sirdataRtdProvider.js b/modules/sirdataRtdProvider.js
index d2319998522..afda5913d70 100644
--- a/modules/sirdataRtdProvider.js
+++ b/modules/sirdataRtdProvider.js
@@ -265,6 +265,31 @@ export function removePII(content) {
return content;
}
+/**
+ * Completely sanitizes the content by recursively removing unnecessary elements and PII until content is stable,
+ * to avoid an HTML element injection vulnerability.
+ * E.g. The string may not contain /g, '')
+
+ let htmlContent = content.documentElement.innerHTML;
+ // Remove HTML comments
+ // This regex removes HTML comments, including those that might not be properly closed
+ htmlContent = htmlContent.replace(/|$)/g, '');
+ // Remove multiple spaces
+ htmlContent = htmlContent.replace(/\s+/g, ' ');
+ // Remove spaces between tags
+ htmlContent = htmlContent.replace(/>\s+<');
+ // Assign the cleaned content
+ content.documentElement.innerHTML = htmlContent;
+
}
return content;
}
@@ -636,7 +621,7 @@ export function addSegmentData(reqBids, data, adUnits, onDone) {
// Global ortb2 SDA
if (!isEmpty(data.global_taxonomy)) {
for (let i in data.global_taxonomy) {
- let globalData = {'segments': [], 'categories': [], 'categories_score': []};
+ let globalData;
if (!isEmpty(data.global_taxonomy[i])) {
globalData = getSegAndCatsArray(data.global_taxonomy[i], params.contextualMinRelevancyScore, '');
if (!isEmpty(globalData)) {
diff --git a/test/spec/modules/sirdataRtdProvider_spec.js b/test/spec/modules/sirdataRtdProvider_spec.js
index 41a754b4b20..39962fc1664 100644
--- a/test/spec/modules/sirdataRtdProvider_spec.js
+++ b/test/spec/modules/sirdataRtdProvider_spec.js
@@ -1,6 +1,5 @@
import {
addSegmentData,
- completeSanitization,
getSegmentsAndCategories,
getUidFromStorage,
loadCustomFunction,
@@ -9,6 +8,7 @@ import {
onDocumentReady,
postContentForSemanticAnalysis,
removePII,
+ sanitizeContent,
setOrtb2,
setUidInStorage,
sirdataSubmodule
@@ -52,7 +52,7 @@ describe('sirdataRtdProvider', function () {
div.appendChild(div2);
doc.body.appendChild(div);
const cleanedDom = removePII(doc.documentElement.innerHTML);
- const sanitizedDom = completeSanitization(doc);
+ const sanitizedDom = sanitizeContent(doc);
expect(cleanedDom).to.equal('My email is , My bank account number is , my SSN is , and my credit card number is .Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
');
expect(sanitizedDom.documentElement.innerHTML).to.equal('My email is , My bank account number is , my SSN is , and my credit card number is .Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
');
});
From b8285174268837a01073dfde9304a7bdbcbb2036 Mon Sep 17 00:00:00 2001
From: nouchy <33549554+nouchy@users.noreply.github.com>
Date: Tue, 21 May 2024 22:39:16 +0200
Subject: [PATCH 08/11] Update sirdataRtdProvider.js
---
modules/sirdataRtdProvider.js | 1 -
1 file changed, 1 deletion(-)
diff --git a/modules/sirdataRtdProvider.js b/modules/sirdataRtdProvider.js
index 6c58585755a..0bd430309a1 100644
--- a/modules/sirdataRtdProvider.js
+++ b/modules/sirdataRtdProvider.js
@@ -329,7 +329,6 @@ export function sanitizeContent(content) {
htmlContent = htmlContent.replace(/>\s+<');
// Assign the cleaned content
content.documentElement.innerHTML = htmlContent;
-
}
return content;
}
From 0fea18126bcbe34c9b3c6bcc5aa507398b97f081 Mon Sep 17 00:00:00 2001
From: Bob
Date: Wed, 22 May 2024 11:21:35 +0200
Subject: [PATCH 09/11] fix missing moduleConfig param
---
modules/sirdataRtdProvider.js | 2 +-
test/spec/modules/sirdataRtdProvider_spec.js | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/modules/sirdataRtdProvider.js b/modules/sirdataRtdProvider.js
index 0bd430309a1..5cac1d0d6fe 100644
--- a/modules/sirdataRtdProvider.js
+++ b/modules/sirdataRtdProvider.js
@@ -339,7 +339,7 @@ export function sanitizeContent(content) {
* @param {function} onDone - The callback function to be called upon completion
* @param {Object} userConsent - The user consent information
*/
-export function getSegmentsAndCategories(reqBidsConfigObj, onDone, userConsent) {
+export function getSegmentsAndCategories(reqBidsConfigObj, onDone, moduleConfig, userConsent) {
logInfo(LOG_PREFIX, 'get Segments And Categories');
const adUnits = (reqBidsConfigObj && reqBidsConfigObj.adUnits) || getGlobal().adUnits;
if (!adUnits) {
diff --git a/test/spec/modules/sirdataRtdProvider_spec.js b/test/spec/modules/sirdataRtdProvider_spec.js
index 39962fc1664..9f6bb30e0b0 100644
--- a/test/spec/modules/sirdataRtdProvider_spec.js
+++ b/test/spec/modules/sirdataRtdProvider_spec.js
@@ -308,7 +308,7 @@ describe('sirdataRtdProvider', function () {
};
getSegmentsAndCategories(reqBidsConfigObj, () => {
- }, {});
+ }, {}, {});
let request = server.requests[0];
request.respond(200, responseHeader, JSON.stringify(data));
From 96e775229719e3ba7bb181f41b45c7294dfc7c7b Mon Sep 17 00:00:00 2001
From: nouchy <33549554+nouchy@users.noreply.github.com>
Date: Fri, 24 May 2024 13:46:32 +0200
Subject: [PATCH 10/11] Add filtering eids based on whitelist
---
modules/sirdataRtdProvider.js | 55 ++++++++++++++++++++++++++++++++---
modules/sirdataRtdProvider.md | 24 +++++++--------
2 files changed, 63 insertions(+), 16 deletions(-)
diff --git a/modules/sirdataRtdProvider.js b/modules/sirdataRtdProvider.js
index 5cac1d0d6fe..0ad3b891c40 100644
--- a/modules/sirdataRtdProvider.js
+++ b/modules/sirdataRtdProvider.js
@@ -63,6 +63,18 @@ const biddersId = { // Partner IDs mapping for different SSPs and DSPs
'zeta_global_ssp': 33385,
};
+const eidsProvidersMap = {
+ 'id5': 'id5-sync.com',
+ 'id5id': 'id5-sync.com',
+ 'id5_id': 'id5-sync.com',
+ 'pubprovided_id': 'pubProvidedId',
+ 'ppid': 'pubProvidedId',
+ 'first-id.fr': 'pubProvidedId',
+ 'sharedid': 'pubcid.org',
+ 'publishercommonid': 'pubcid.org',
+ 'pubcid.org': 'pubcid.org',
+}
+
// params
let params = {
partnerId: 1,
@@ -72,7 +84,7 @@ let params = {
setGptKeyValues: true,
contextualMinRelevancyScore: 30,
preprod: false,
- avoidPostEids: false,
+ authorizedEids: ['pubProvidedId', 'id5-sync.com', 'pubcid.org'],
avoidPostContent: false,
sirdataDomain: 'cookieless-data.com',
bidders: []
@@ -337,6 +349,7 @@ export function sanitizeContent(content) {
* Fetches segments and categories from Sirdata server and processes the response
* @param {Object} reqBidsConfigObj - The bids configuration object
* @param {function} onDone - The callback function to be called upon completion
+ * @param {Object} moduleConfig - The module Config
* @param {Object} userConsent - The user consent information
*/
export function getSegmentsAndCategories(reqBidsConfigObj, onDone, moduleConfig, userConsent) {
@@ -368,10 +381,31 @@ export function getSegmentsAndCategories(reqBidsConfigObj, onDone, moduleConfig,
privacySignals = `&gpp=${userConsent.gpp.gppString}${sid}`;
}
- // EUIDS from storage and sync global for graph
+ // Authorized EUIDS from storage and sync global for graph
euids = getUidFromStorage(); // Sirdata Id
- if (!params.avoidPostEids && typeof getGlobal().getUserIdsAsEids === 'function') {
- euids = mergeEuidsArrays(euids, getGlobal().getUserIdsAsEids()); // for graph id
+
+ if (!isEmpty(params.authorizedEids) && typeof getGlobal().getUserIds === 'function') {
+ let filteredEids = {};
+ const authorizedEids = params.authorizedEids;
+ const globalUserIds = getGlobal().getUserIds();
+ const globalUserIdsAsEids = getGlobal().getUserIdsAsEids();
+
+ const hasPubProvidedId = authorizedEids.indexOf('pubProvidedId') !== -1;
+
+ if (hasPubProvidedId && !isEmpty(globalUserIds.pubProvidedId)) { // Publisher allows pubProvidedId
+ filteredEids = mergeEuidsArrays(filteredEids, globalUserIds.pubProvidedId);
+ }
+
+ if (!hasPubProvidedId || authorizedEids.length > 1) { // Publisher allows other Id providers
+ const filteredGlobalEids = globalUserIdsAsEids.filter(entry => authorizedEids.includes(entry.source));
+ if (!isEmpty(filteredGlobalEids)) {
+ filteredEids = mergeEuidsArrays(filteredEids, filteredGlobalEids);
+ }
+ }
+
+ if (!isEmpty(filteredEids)) {
+ euids = mergeEuidsArrays(euids, filteredEids); // merge ids for graph id
+ }
}
}
@@ -699,6 +733,19 @@ export function addSegmentData(reqBids, data, adUnits, onDone) {
export function init(moduleConfig) {
logInfo(LOG_PREFIX, moduleConfig);
if (typeof (moduleConfig.params) !== 'object' || !moduleConfig.params.key) return false;
+ if (typeof (moduleConfig.params.authorizedEids) !== 'object' || !Array.isArray(moduleConfig.params.authorizedEids)) {
+ delete (moduleConfig.params.authorizedEids); // must be array of strings
+ } else {
+ // we need it if the publishers uses user Id module name instead of key or source
+ const resultSet = new Set(
+ moduleConfig.params.authorizedEids.map(item => {
+ const formattedItem = item.toLowerCase().replace(/\s+/g, '_'); // Normalize
+ return eidsProvidersMap[formattedItem] || formattedItem;
+ })
+ );
+ moduleConfig.params.authorizedEids = Array.from(resultSet);
+ }
+ if (typeof (moduleConfig.params.bidders) !== 'object' || !Array.isArray(moduleConfig.params.bidders)) delete (moduleConfig.params.bidders); // must be array of objects
delete (moduleConfig.params.sirdataDomain); // delete cookieless domain if specified => shouldn't be overridden by publisher
params = Object.assign({}, params, moduleConfig.params);
return true;
diff --git a/modules/sirdataRtdProvider.md b/modules/sirdataRtdProvider.md
index 3ffaba7ca02..750b3fa2550 100644
--- a/modules/sirdataRtdProvider.md
+++ b/modules/sirdataRtdProvider.md
@@ -85,18 +85,18 @@ pbjs.setConfig({
### Parameter Descriptions for the Sirdata Configuration Section
-| Name | Type | Description | Notes |
-|:-----------------------------------|:--------|:----------------------------------------------------------------------------------------------------------------------------------------|:---------------------------------------------------------------------------------------------------------|
-| name | String | Real time data module name | Mandatory. Always 'SirdataRTDModule' |
-| waitForIt | Boolean | Required to ensure that the auction is delayed until prefetch is complete | Optional. Default to false but recommended to true |
-| params | Object | Settings | Optional |
-| params.partnerId | Integer | Partner ID, required to get results and provided by Sirdata. Use 1 for tests and request your Id at | Mandatory. Default 1 |
-| params.key | Integer | Key linked to Partner ID, required to get results and provided by Sirdata. Use 1 for tests and request your key at | Mandatory. Default 1 |
-| params.setGptKeyValues | Boolean | Sets Targeting for GPT/GAM | Optional. Default to true |
-| params.avoidPostEids | Boolean | Block Eids usage for graph resolution | Optional. Default to false, and setting it to true results in lowest segment access |
-| params.avoidPostContent | Boolean | Block contextual data POST from user's device (a crawler is use instead) | Optional. Default to false, and setting it to true results in your content downloaded by Sirdata crawler |
-| params.contextualMinRelevancyScore | Integer | Min relevancy score to filter categories sent to the bidders (0-100 scale). Optional. Defaults to 30. |
-| params.bidders | Object | Bidders you want to supply your own data to (works only with your private data bought to Sirdata) | Optional |
+| Name | Type | Description | Notes |
+|:-----------------------------------|:--------------------------|:----------------------------------------------------------------------------------------------------------------------------------------|:---------------------------------------------------------------------------------------------------------|
+| name | String | Real time data module name | Mandatory. Always 'SirdataRTDModule' |
+| waitForIt | Boolean | Required to ensure that the auction is delayed until prefetch is complete | Optional. Default to false but recommended to true |
+| params | Object | Settings | Optional |
+| params.partnerId | Integer | Partner ID, required to get results and provided by Sirdata. Use 1 for tests and request your Id at | Mandatory. Default 1 |
+| params.key | Integer | Key linked to Partner ID, required to get results and provided by Sirdata. Use 1 for tests and request your key at | Mandatory. Default 1 |
+| params.setGptKeyValues | Boolean | Sets Targeting for GPT/GAM | Optional. Default to true |
+| params.authorizedEids | Array of String | List of authorised Eids for graph. Set [] to prevent all Eids usage | Optional. Default to : pubProvidedId, id5Id, uid, uid2, euid, czechAdId, netId, pubcid (sharedId) |
+| params.avoidPostContent | Boolean | Block contextual data POST from user's device (a crawler is use instead) | Optional. Default to false, and setting it to true results in your content downloaded by Sirdata crawler |
+| params.contextualMinRelevancyScore | Integer | Min relevancy score to filter categories sent to the bidders (0-100 scale). | Optional. Defaults to 30. |
+| params.bidders | Array of Object | Bidders you want to supply your own data to (works only with your private data bought to Sirdata) | Optional |
Bidders can receive common setting :
From b24baf952376e8d69ec7d3a772920835ebd03c4f Mon Sep 17 00:00:00 2001
From: nouchy <33549554+nouchy@users.noreply.github.com>
Date: Fri, 24 May 2024 13:50:56 +0200
Subject: [PATCH 11/11] fixe default Eids
---
modules/sirdataRtdProvider.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/modules/sirdataRtdProvider.md b/modules/sirdataRtdProvider.md
index 750b3fa2550..9e712e5fbd6 100644
--- a/modules/sirdataRtdProvider.md
+++ b/modules/sirdataRtdProvider.md
@@ -93,7 +93,7 @@ pbjs.setConfig({
| params.partnerId | Integer | Partner ID, required to get results and provided by Sirdata. Use 1 for tests and request your Id at | Mandatory. Default 1 |
| params.key | Integer | Key linked to Partner ID, required to get results and provided by Sirdata. Use 1 for tests and request your key at | Mandatory. Default 1 |
| params.setGptKeyValues | Boolean | Sets Targeting for GPT/GAM | Optional. Default to true |
-| params.authorizedEids | Array of String | List of authorised Eids for graph. Set [] to prevent all Eids usage | Optional. Default to : pubProvidedId, id5Id, uid, uid2, euid, czechAdId, netId, pubcid (sharedId) |
+| params.authorizedEids | Array of String | List of authorised Eids for graph. Set [] to prevent all Eids usage | Optional. Default to : ID5, pubProvidedId and sharedId |
| params.avoidPostContent | Boolean | Block contextual data POST from user's device (a crawler is use instead) | Optional. Default to false, and setting it to true results in your content downloaded by Sirdata crawler |
| params.contextualMinRelevancyScore | Integer | Min relevancy score to filter categories sent to the bidders (0-100 scale). | Optional. Defaults to 30. |
| params.bidders | Array of Object | Bidders you want to supply your own data to (works only with your private data bought to Sirdata) | Optional |