Skip to content

Commit

Permalink
Change to request DigiTrust ID "withCredentials". (#5013)
Browse files Browse the repository at this point in the history
Fix to other discovered issues of DigiTrust ID failing to write into userId system.
Adjust samples to call https pages in all cases for testing purposes.
  • Loading branch information
goosemanjack authored Mar 31, 2020
1 parent edb33f4 commit b95a2f6
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 11 deletions.
2 changes: 1 addition & 1 deletion integrationExamples/gpt/digitrust_Full.html
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
}());
var t = document.createElement('script');
t.async = false;
t.src = 'http://acdn.adnxs.com/cmp/cmp.bundle.js';
t.src = 'https://acdn.adnxs.com/cmp/cmp.bundle.js';
var tag = document.getElementsByTagName('head')[0];
tag.appendChild(t);
}
Expand Down
2 changes: 1 addition & 1 deletion integrationExamples/gpt/digitrust_Simple.html
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
}());
var t = document.createElement('script');
t.async = false;
t.src = 'http://acdn.adnxs.com/cmp/cmp.bundle.js';
t.src = 'https://acdn.adnxs.com/cmp/cmp.bundle.js';
var tag = document.getElementsByTagName('head')[0];
tag.appendChild(t);
}
Expand Down
2 changes: 1 addition & 1 deletion integrationExamples/gpt/digitrust_cmp_test.html
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,6 @@ <h2>DigiTrust Prebid Sample - No Framework</h2>
googletag.cmd.push(function () { googletag.display('test-div'); });
</script>
</div>
<script src="http://cmp-origin-release.digitru.st/1/cmp.bundle.js"></script>
<script src="https://cmp-origin-release.digitru.st/1/cmp.bundle.js"></script>
</body>
</html>
27 changes: 19 additions & 8 deletions modules/digiTrustIdSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,22 @@ var isFunc = function (fn) {
return typeof (fn) === 'function';
}

var _savedId = null; // closure variable for storing Id to avoid additional requests

function callApi(options) {
var ajaxOptions = {
method: 'GET',
withCredentials: true
};

ajax(
DT_ID_SVC,
{
success: options.success,
error: options.fail
},
null,
{
method: 'GET'
}
ajaxOptions
);
}

Expand Down Expand Up @@ -91,8 +96,6 @@ function writeDigiId(id) {
*
*/
function initDigitrustFacade(config) {
var _savedId = null; // closure variable for storing Id to avoid additional requests

clearTimeout(fallbackTimer);
fallbackTimer = 0;

Expand All @@ -116,7 +119,7 @@ function initDigitrustFacade(config) {
try {
inter.initCallback(idResponse);
} catch (ex) {
utils.logError('Exception in passed DigiTrust init callback');
utils.logError('Exception in passed DigiTrust init callback', ex);
}
}
}
Expand Down Expand Up @@ -146,9 +149,9 @@ function initDigitrustFacade(config) {
success: true
}
try {
writeDigiId(respText);
idResult.identity = JSON.parse(respText);
_savedId = idResult;
_savedId = idResult; // Save result to the cache variable
writeDigiId(respText);
} catch (ex) {
idResult.success = false;
delete idResult.identity;
Expand Down Expand Up @@ -253,6 +256,10 @@ var ResultWrapper = function (opts) {
*/
this.userIdCallback = function (callback) {
idSystemFn = callback;
if (me.idObj == null) {
me.idObj = _savedId;
}

if (me.idObj != null && isFunc(callback)) {
callback(wrapIdResult());
}
Expand All @@ -262,6 +269,10 @@ var ResultWrapper = function (opts) {
* Return a wrapped result formatted for userId system
*/
function wrapIdResult() {
if (me.idObj == null) {
me.idObj = _savedId;
}

if (me.idObj == null) {
return null;
}
Expand Down

0 comments on commit b95a2f6

Please sign in to comment.