diff --git a/dist/dt.html b/dist/dt.html
index 0e99baf..96a83a9 100644
--- a/dist/dt.html
+++ b/dist/dt.html
@@ -115,7 +115,7 @@
sendMessage(digiTrustUserJSON);
});
} catch (e) {
- log.error('Failure encrypting DigiTrust Identity', e);
+ log.warn('Failure encrypting DigiTrust Identity', e);
if (dt.util.isChrome()) {
var cryptoObj = dt.util.getBrowserCrypto();
if (cryptoObj.subtle == null) {
diff --git a/documentation/README_development.md b/documentation/README_development.md
index 5bd83de..4b7413d 100644
--- a/documentation/README_development.md
+++ b/documentation/README_development.md
@@ -57,23 +57,19 @@ To verify the current release version, consult this URL https://cdn.digitru.st/p
test page Prebid.js/integrationExamples/gpt/digitrust_Full.html and type `DigiTrust.version` in the debug console.
1. Update `version` in `package.json`
-2. Update `digitrustHostPath`, `digitrustRedirect`, and `digitrustIframe` in the `prod` section of `src/config/general.json`
- to match the new version number in the URL path.
-3. Update `digitrustHostPath`, `digitrustRedirect`, and `digitrustIframe` to the most recent prior
- release version in the `build` section of `src/config/general.json`
-4. Build with command `yarn build`
-5. Commit and push your changes to master branch
-6. git checkout candidate
-7. git pull
-8. git merge --no-ff master
-9. git tag candidate-1.5.37 (update to your version number as set in step 1)
-10. git push --follow-tags (and then wait to confirm CircleCI build is successful)
-11. git push --force origin candidate-1.5.37:release (then wait for successful CircleCI build)
-12. git checkout master
-13. git tag v1.5.37
-14. git push origin v1.5.37
-15. Go to project site on Github and draft a new release
-16. Reflect release notes in the `Release Notes` wiki page at https://github.com/digi-trust/dt-cdn/wiki/Release-Notes
+2. Build with command `yarn build`
+3. Commit and push your changes to master branch
+4. git checkout candidate
+5. git pull
+6. git merge --no-ff master
+7. git tag v1.5.39 (update to your version number as set in step 1)
+8. git push --follow-tags (and then wait to confirm CircleCI build is successful)
+9. git push --force origin v1.5.39:release (then wait for successful CircleCI build)
+10. git checkout master
+11. git tag v1.5.37
+12. git push origin v1.5.37
+13. Go to project site on Github and draft a new release
+14. Reflect release notes in the `Release Notes` wiki page at https://github.com/digi-trust/dt-cdn/wiki/Release-Notes
## Development Roadmap Notes
diff --git a/package.json b/package.json
index 1a5ff0a..c167a37 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "digitrust",
- "version": "1.5.40",
+ "version": "1.5.41",
"description": "Package for a universal ID for registered ad servers",
"main": "dist/digitrust.min.js",
"scripts": {
diff --git a/pages/dt.html b/pages/dt.html
index 0e99baf..96a83a9 100644
--- a/pages/dt.html
+++ b/pages/dt.html
@@ -115,7 +115,7 @@
sendMessage(digiTrustUserJSON);
});
} catch (e) {
- log.error('Failure encrypting DigiTrust Identity', e);
+ log.warn('Failure encrypting DigiTrust Identity', e);
if (dt.util.isChrome()) {
var cryptoObj = dt.util.getBrowserCrypto();
if (cryptoObj.subtle == null) {
diff --git a/src/config/GeneralConfig.js b/src/config/GeneralConfig.js
new file mode 100644
index 0000000..c5813c4
--- /dev/null
+++ b/src/config/GeneralConfig.js
@@ -0,0 +1,193 @@
+'use strict';
+
+/**
+ * GeneralConfig
+ * @module
+ *
+ * @description Configuration settings for various environments.
+ * Adapted from general.json to avoid errors with manual version number updates.
+ * @author Chris Cole
+ *
+ * */
+
+var VERSION = require('../_version.js');
+
+// Add an explicit value here to control how builds verify during the build automation testing.
+// Normally a build assumes one version prior. This can be used to specify a build number for
+// testing purposes in the CircleCI build. Leave null for default behavior
+var BUILD_VERSION_OVERRIDE = null;
+
+var VARIABLE_CURRENT_VERSION = "%CURRENT_VERSION%";
+var VARIABLE_PRIOR_VERSION = "%PRIOR_VERSION%";
+
+var configJson = {
+ "prod": {
+ "urls": {
+ "digitrustHostPath": "https://cdn.digitru.st/prod/%CURRENT_VERSION%/",
+ "digitrustRedirect": "https://cdn.digitru.st/prod/%CURRENT_VERSION%/redirect.html",
+ "digitrustIframe": "https://cdn.digitru.st/prod/%CURRENT_VERSION%/dt.html",
+ "digitrustIdService": "https://cdn-cf.digitru.st/id/v1",
+ "optoutInfo": "http://www.digitru.st/about-this-notice/",
+ "adblockCheck": "http://stats.aws.rubiconproject.com/"
+ },
+ "redirectInterval": {
+ "exp": 7
+ },
+ "cookie": {
+ "version": 2,
+ "producer": "1CrsdUNAo6",
+ "publisher": {
+ "domainKeyValue": "",
+ "pathKeyValue": "path=/;",
+ "maxAgeMiliseconds": 604800000,
+ "userObjectKey": "DigiTrust.v1.identity"
+ },
+ "digitrust": {
+ "domainKeyValue": "domain=.digitru.st;",
+ "pathKeyValue": "path=/;",
+ "maxAgeMiliseconds": 31536000000,
+ "userObjectKey": "DigiTrust.v1.identity",
+ "resetKey": "DeleteEverything",
+ "challenge": "DTChal",
+ "optout": "optout",
+ "optoutUser": {
+ "id": "",
+ "privacy": {
+ "optout": true
+ }
+ },
+ "errorUser": {
+ "error": true
+ }
+ }
+ },
+ "iframe": {
+ "timeoutDuration": 10000,
+ "postMessageOrigin": "https://cdn.digitru.st"
+ },
+ "crypto": {
+ "serverCryptoRate": 0.0
+ },
+ "logging": {
+ "enable": false,
+ "level": "ERROR"
+ },
+ "gvlVendorId": 64
+ },
+ "build": {
+ "urls": {
+ "digitrustHostPath": "https://cdn.digitru.st/prod/%PRIOR_VERSION%/",
+ "digitrustRedirect": "https://cdn.digitru.st/prod/%PRIOR_VERSION%/redirect.html",
+ "digitrustIframe": "https://cdn.digitru.st/prod/%PRIOR_VERSION%/dt.html",
+ "digitrustIdService": "https://cdn-cf.digitru.st/id/v1",
+ "optoutInfo": "http://www.digitru.st/about-this-notice/",
+ "adblockCheck": "http://stats.aws.rubiconproject.com/"
+ }
+ },
+ "local": {
+ "urls": {
+ "digitrustHostPath": "//localhost/dist/",
+ "digitrustRedirect": "//localhost/dist/redirect.html",
+ "digitrustIframe": "//local.digitru.st/dist/dt_debug.html",
+ "digitrustIdService": "http://local.digitru.st/misc/faked_id_service_v1.json",
+ "optoutInfo": "//localhost/dist/info.html",
+ "adblockCheck": "//stats.aws.rubiconproject.com/"
+ },
+ "iframe": {
+ "timeoutDuration": 10000,
+ "postMessageOrigin": "http://local.digitru.st"
+ },
+ "crypto": {
+ "serverCryptoRate": 1.0
+ },
+ "logging": {
+ "level": "DEBUG"
+ },
+ "gvlVendorId": 64
+ }
+}
+
+
+// =============================== METHODS TO RETURN SNAPSHOT OF CONFIG ======================
+
+/**
+ * Calculates the current version and previous version for purposes of file paths
+ * in config.
+ * @param {String} ver a package version number
+ * @param {any} prevVer optional override to previous version for build purposes
+ */
+function computeVersions(ver, prevVer) {
+ ver = ver || VERSION;
+
+ var result = {
+ current: null,
+ prior: null
+ };
+
+ var currentVersion, prevVersion;
+ var verParts = ver.split('.');
+ var prevMinor = parseInt(verParts[verParts.length - 1]);
+
+ if (prevVer == null && BUILD_VERSION_OVERRIDE == null) {
+ if (isNaN(prevMinor)) {
+ prevMinor = 0;
+ }
+ else {
+ prevMinor = prevMinor - 1;
+ }
+
+ currentVersion = ver;
+ verParts[verParts.length - 1] = new String(prevMinor);
+
+ prevVersion = verParts.join('.');
+ }
+ else {
+ if (prevVer != null) {
+ prevVersion = prevVer;
+ }
+ else if (BUILD_VERSION_OVERRIDE != null) {
+ prevVersion = BUILD_VERSION_OVERRIDE;
+ }
+ }
+
+ result.current = currentVersion;
+ result.prior = prevVersion;
+
+ return result;
+}
+
+function replaceUrlVariables(urlObj, variable, value) {
+ var key, val;
+ // Replace known URL values
+ for (key in urlObj) {
+ if (urlObj.hasOwnProperty(key)) {
+ val = urlObj[key];
+ if (val.indexOf(variable) > -1) {
+ urlObj[key] = val.replace(variable, value);
+ }
+ }
+ }
+}
+
+/**
+ * Returns the full configuration JSON with adjustments applied for version numbering
+ * @function
+ *
+ * */
+function getFullConfig(ver, prevVersion) {
+ ver = ver || VERSION;
+
+ var versionResult = computeVersions(ver, prevVersion);
+
+ var config = configJson;
+ replaceUrlVariables(config.prod.urls, VARIABLE_CURRENT_VERSION, versionResult.current);
+ replaceUrlVariables(config.build.urls, VARIABLE_PRIOR_VERSION, versionResult.prior);
+
+ return config;
+}
+
+
+module.exports = {
+ getFullConfig: getFullConfig,
+ computeVersions: computeVersions
+}
diff --git a/src/config/general.json b/src/config/general.json
deleted file mode 100644
index 01b89a8..0000000
--- a/src/config/general.json
+++ /dev/null
@@ -1,86 +0,0 @@
-{
- "prod": {
- "urls": {
- "digitrustHostPath": "https://cdn.digitru.st/prod/1.5.40/",
- "digitrustRedirect": "https://cdn.digitru.st/prod/1.5.40/redirect.html",
- "digitrustIframe": "https://cdn.digitru.st/prod/1.5.40/dt.html",
- "digitrustIdService": "https://cdn-cf.digitru.st/id/v1",
- "optoutInfo": "http://www.digitru.st/about-this-notice/",
- "adblockCheck": "http://stats.aws.rubiconproject.com/"
- },
- "redirectInterval": {
- "exp": 7
- },
- "cookie": {
- "version": 2,
- "producer": "1CrsdUNAo6",
- "publisher": {
- "domainKeyValue": "",
- "pathKeyValue": "path=/;",
- "maxAgeMiliseconds": 604800000,
- "userObjectKey": "DigiTrust.v1.identity"
- },
- "digitrust": {
- "domainKeyValue": "domain=.digitru.st;",
- "pathKeyValue": "path=/;",
- "maxAgeMiliseconds": 31536000000,
- "userObjectKey": "DigiTrust.v1.identity",
- "resetKey": "DeleteEverything",
- "challenge": "DTChal",
- "optout": "optout",
- "optoutUser": {
- "id": "",
- "privacy": {
- "optout": true
- }
- },
- "errorUser": {
- "error": true
- }
- }
- },
- "iframe": {
- "timeoutDuration": 10000,
- "postMessageOrigin": "https://cdn.digitru.st"
- },
- "crypto": {
- "serverCryptoRate": 0.0
- },
- "logging": {
- "enable": false,
- "level": "ERROR"
- },
- "gvlVendorId": 64
- },
- "build": {
- "urls": {
- "digitrustHostPath": "https://cdn.digitru.st/prod/1.5.36/",
- "digitrustRedirect": "https://cdn.digitru.st/prod/1.5.36/redirect.html",
- "digitrustIframe": "https://cdn.digitru.st/prod/1.5.36/dt.html",
- "digitrustIdService": "https://cdn-cf.digitru.st/id/v1",
- "optoutInfo": "http://www.digitru.st/about-this-notice/",
- "adblockCheck": "http://stats.aws.rubiconproject.com/"
- }
- },
- "local": {
- "urls": {
- "digitrustHostPath": "//localhost/dist/",
- "digitrustRedirect": "//localhost/dist/redirect.html",
- "digitrustIframe": "//local.digitru.st/dist/dt_debug.html",
- "digitrustIdService": "http://local.digitru.st/misc/faked_id_service_v1.json",
- "optoutInfo": "//localhost/dist/info.html",
- "adblockCheck": "//stats.aws.rubiconproject.com/"
- },
- "iframe": {
- "timeoutDuration": 10000,
- "postMessageOrigin": "http://local.digitru.st"
- },
- "crypto": {
- "serverCryptoRate": 1.0
- },
- "logging": {
- "level": "DEBUG"
- },
- "gvlVendorId": 64
- }
-}
diff --git a/src/modules/ConfigLoader.js b/src/modules/ConfigLoader.js
index 0fd33fa..2cfdbb4 100644
--- a/src/modules/ConfigLoader.js
+++ b/src/modules/ConfigLoader.js
@@ -10,7 +10,7 @@
* */
var buildEnv = require('../config/env.json').current;
-var genConfig = require('../config/general.json');
+var genConfig = require('../config/GeneralConfig').getFullConfig();
var activeConfig = genConfig[buildEnv];
var helpers = require('./helpers');
var myConfig;
diff --git a/src/modules/DigiTrustCookie.js b/src/modules/DigiTrustCookie.js
index 3e0b877..26f501c 100644
--- a/src/modules/DigiTrustCookie.js
+++ b/src/modules/DigiTrustCookie.js
@@ -28,7 +28,7 @@ var _setCookie = function (cookieKV, expiresKV, domainKV, pathKV) {
if (str.substr(str.length - 1) != ';') {
str += ';'
}
- str += "SameSite=none;";
+ str += "SameSite=None; Secure;";
document.cookie = str;
};
@@ -78,7 +78,7 @@ DigiTrustCookie.getIdentityCookieJSON = function (cookieKey) {
try {
localUserCookieJSON = DigiTrustCookie.unobfuscateCookieValue(localUserCookie);
} catch (e) {
- log.warn('error decrypting user cookie - generating new identity')
+ log.warn('error parsing user cookie - generating new identity')
localUserCookieJSON = {
id: helpers.generateUserId(),
version: getConfig().getValue('cookie.version'),
diff --git a/test/jest/configLoader.test.js b/test/jest/configLoader.test.js
index 7b520fe..fa5d317 100644
--- a/test/jest/configLoader.test.js
+++ b/test/jest/configLoader.test.js
@@ -1,4 +1,5 @@
const config = require('../../src/modules/ConfigLoader');
+const generalConfig = require('../../src/config/GeneralConfig');
beforeEach(() => {
config.reset();
@@ -25,3 +26,13 @@ test('load-new-config', () => {
});
+test('version Calculations with base only', () => {
+ var baseVersion = "1.5.31";
+
+ var result = generalConfig.computeVersions(baseVersion);
+
+ expect(result.current).toBe(baseVersion);
+ expect(result.prior).toBe("1.5.30");
+
+});
+