@didomi/iabtcf-core
Advanced tools
Comparing version 1.6.1 to 1.6.2
import { Cloneable } from './Cloneable.js'; | ||
import { GVLError } from './errors/index.js'; | ||
import { ConsentLanguages, IntMap } from './model/index.js'; | ||
import { Feature, Purpose, Stack, Vendor, VendorList } from './model/gvl/index.js'; | ||
import { Feature, Purpose, Stack, Vendor, VendorList, DataCategory } from './model/gvl/index.js'; | ||
export declare type VersionOrVendorList = string | number | VendorList; | ||
@@ -168,2 +168,6 @@ /** | ||
stacks: IntMap<Stack>; | ||
/** | ||
* @param {IntMap<DataCategory>} a collection of [[DataCategory]]s | ||
*/ | ||
dataCategories?: IntMap<DataCategory>; | ||
private lang_; | ||
@@ -205,2 +209,16 @@ private isLatest; | ||
getJson(): VendorList; | ||
private cloneSpecialFeatures; | ||
private cloneFeatures; | ||
private cloneStacks; | ||
private cloneDataCategories; | ||
private cloneSpecialPurposes; | ||
private clonePurposes; | ||
private static clonePurpose; | ||
private static cloneFeature; | ||
private static cloneDataCategory; | ||
private static cloneStack; | ||
private static cloneDataRetention; | ||
private static cloneVendorUrls; | ||
private static cloneVendor; | ||
private cloneVendors; | ||
/** | ||
@@ -207,0 +225,0 @@ * changeLanguage - retrieves the purpose language translation and sets the |
@@ -1,1 +0,1 @@ | ||
"use strict";var __extends=this&&this.__extends||function(){var e=function(t,r){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])})(t,r)};return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),__awaiter=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(s,o){function i(e){try{u(n.next(e))}catch(e){o(e)}}function a(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?s(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,a)}u((n=n.apply(e,t||[])).next())}))},__generator=this&&this.__generator||function(e,t){var r,n,s,o,i={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(s=2&o[0]?n.return:o[0]?n.throw||((s=n.return)&&s.call(n),0):n.next)&&!(s=s.call(n,o[1])).done)return s;switch(n=0,s&&(o=[2&o[0],s.value]),o[0]){case 0:case 1:s=o;break;case 4:return i.label++,{value:o[1],done:!1};case 5:i.label++,n=o[1],o=[0];continue;case 7:o=i.ops.pop(),i.trys.pop();continue;default:if(!(s=i.trys,(s=s.length>0&&s[s.length-1])||6!==o[0]&&2!==o[0])){i=0;continue}if(3===o[0]&&(!s||o[1]>s[0]&&o[1]<s[3])){i.label=o[1];break}if(6===o[0]&&i.label<s[1]){i.label=s[1],s=o;break}if(s&&i.label<s[2]){i.label=s[2],i.ops.push(o);break}s[2]&&i.ops.pop(),i.trys.pop();continue}o=t.call(e,i)}catch(e){o=[6,e],n=0}finally{r=s=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.GVL=void 0;var Cloneable_js_1=require("./Cloneable.js"),index_js_1=require("./errors/index.js"),Json_js_1=require("./Json.js"),index_js_2=require("./model/index.js"),GVL=function(e){function t(r){var n=e.call(this)||this;n.isReady_=!1,n.isLatest=!1;var s=t.baseUrl;if(n.lang_=t.DEFAULT_LANGUAGE,n.isVendorList(r))n.populate(r),n.readyPromise=Promise.resolve();else{if(!s)throw new index_js_1.GVLError("must specify GVL.baseUrl before loading GVL json");if(r>0){var o=r;t.CACHE.has(o)?(n.populate(t.CACHE.get(o)),n.readyPromise=Promise.resolve()):(s+=t.versionedFilename.replace("[VERSION]",String(o)),n.readyPromise=n.fetchJson(s))}else t.CACHE.has(t.LATEST_CACHE_KEY)?(n.populate(t.CACHE.get(t.LATEST_CACHE_KEY)),n.readyPromise=Promise.resolve()):(n.isLatest=!0,n.readyPromise=n.fetchJson(s+t.latestFilename))}return n}return __extends(t,e),Object.defineProperty(t,"baseUrl",{get:function(){return this.baseUrl_},set:function(e){if(/^https?:\/\/vendorlist\.consensu\.org\//.test(e))throw new index_js_1.GVLError("Invalid baseUrl! You may not pull directly from vendorlist.consensu.org and must provide your own cache");e.length>0&&"/"!==e[e.length-1]&&(e+="/"),this.baseUrl_=e},enumerable:!1,configurable:!0}),t.emptyLanguageCache=function(e){var r=!1;return void 0===e&&t.LANGUAGE_CACHE.size>0?(t.LANGUAGE_CACHE=new Map,r=!0):"string"==typeof e&&this.consentLanguages.has(e.toUpperCase())&&(t.LANGUAGE_CACHE.delete(e.toUpperCase()),r=!0),r},t.emptyCache=function(e){var r=!1;return Number.isInteger(e)&&e>=0?(t.CACHE.delete(e),r=!0):void 0===e&&(t.CACHE=new Map,r=!0),r},t.prototype.cacheLanguage=function(){t.LANGUAGE_CACHE.has(this.lang_)||t.LANGUAGE_CACHE.set(this.lang_,{purposes:this.purposes,specialPurposes:this.specialPurposes,features:this.features,specialFeatures:this.specialFeatures,stacks:this.stacks})},t.prototype.fetchJson=function(e){return __awaiter(this,void 0,void 0,(function(){var t,r;return __generator(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),t=this.populate,[4,Json_js_1.Json.fetch(e)];case 1:return t.apply(this,[n.sent()]),[3,3];case 2:throw r=n.sent(),new index_js_1.GVLError(r.message);case 3:return[2]}}))}))},t.prototype.getJson=function(){return JSON.parse(JSON.stringify({gvlSpecificationVersion:this.gvlSpecificationVersion,vendorListVersion:this.vendorListVersion,tcfPolicyVersion:this.tcfPolicyVersion,lastUpdated:this.lastUpdated,purposes:this.purposes,specialPurposes:this.specialPurposes,features:this.features,specialFeatures:this.specialFeatures,stacks:this.stacks,vendors:this.fullVendorList}))},t.prototype.changeLanguage=function(e){return __awaiter(this,void 0,void 0,(function(){var r,n,s,o,i;return __generator(this,(function(a){switch(a.label){case 0:if(r=e.toUpperCase(),!t.consentLanguages.has(r))return[3,6];if(r===this.lang_)return[3,5];if(this.lang_=r,!t.LANGUAGE_CACHE.has(r))return[3,1];for(s in n=t.LANGUAGE_CACHE.get(r))n.hasOwnProperty(s)&&(this[s]=n[s]);return[3,5];case 1:o=t.baseUrl+t.languageFilename.replace("[LANG]",e),a.label=2;case 2:return a.trys.push([2,4,,5]),[4,this.fetchJson(o)];case 3:return a.sent(),this.cacheLanguage(),[3,5];case 4:throw i=a.sent(),new index_js_1.GVLError("unable to load language: "+i.message);case 5:return[3,7];case 6:throw new index_js_1.GVLError("unsupported language ".concat(e));case 7:return[2]}}))}))},Object.defineProperty(t.prototype,"language",{get:function(){return this.lang_},enumerable:!1,configurable:!0}),t.prototype.isVendorList=function(e){return void 0!==e&&void 0!==e.vendors},t.prototype.populate=function(e){this.purposes=e.purposes,this.specialPurposes=e.specialPurposes,this.features=e.features,this.specialFeatures=e.specialFeatures,this.stacks=e.stacks,this.isVendorList(e)&&(this.gvlSpecificationVersion=e.gvlSpecificationVersion,this.tcfPolicyVersion=e.tcfPolicyVersion,this.vendorListVersion=e.vendorListVersion,this.lastUpdated=e.lastUpdated,"string"==typeof this.lastUpdated&&(this.lastUpdated=new Date(this.lastUpdated)),this.vendors_=e.vendors,this.fullVendorList=e.vendors,this.mapVendors(),this.isReady_=!0,this.isLatest&&t.CACHE.set(t.LATEST_CACHE_KEY,this.getJson()),t.CACHE.has(this.vendorListVersion)||t.CACHE.set(this.vendorListVersion,this.getJson())),this.cacheLanguage()},t.prototype.mapVendors=function(e){var t=this;this.byPurposeVendorMap={},this.bySpecialPurposeVendorMap={},this.byFeatureVendorMap={},this.bySpecialFeatureVendorMap={},Object.keys(this.purposes).forEach((function(e){t.byPurposeVendorMap[e]={legInt:new Set,consent:new Set,flexible:new Set}})),Object.keys(this.specialPurposes).forEach((function(e){t.bySpecialPurposeVendorMap[e]=new Set})),Object.keys(this.features).forEach((function(e){t.byFeatureVendorMap[e]=new Set})),Object.keys(this.specialFeatures).forEach((function(e){t.bySpecialFeatureVendorMap[e]=new Set})),Array.isArray(e)||(e=Object.keys(this.fullVendorList).map((function(e){return+e}))),this.vendorIds=new Set(e),this.vendors_=e.reduce((function(e,r){var n=t.vendors_[String(r)];return n&&void 0===n.deletedDate&&(n.purposes.forEach((function(e){t.byPurposeVendorMap[String(e)].consent.add(r)})),n.specialPurposes.forEach((function(e){t.bySpecialPurposeVendorMap[String(e)].add(r)})),n.legIntPurposes.forEach((function(e){t.byPurposeVendorMap[String(e)].legInt.add(r)})),n.flexiblePurposes&&n.flexiblePurposes.forEach((function(e){t.byPurposeVendorMap[String(e)].flexible.add(r)})),n.features.forEach((function(e){t.byFeatureVendorMap[String(e)].add(r)})),n.specialFeatures.forEach((function(e){t.bySpecialFeatureVendorMap[String(e)].add(r)})),e[r]=n),e}),{})},t.prototype.getFilteredVendors=function(e,t,r,n){var s=this,o=e.charAt(0).toUpperCase()+e.slice(1),i={};return("purpose"===e&&r?this["by"+o+"VendorMap"][String(t)][r]:this["by"+(n?"Special":"")+o+"VendorMap"][String(t)]).forEach((function(e){i[String(e)]=s.vendors[String(e)]})),i},t.prototype.getVendorsWithConsentPurpose=function(e){return this.getFilteredVendors("purpose",e,"consent")},t.prototype.getVendorsWithLegIntPurpose=function(e){return this.getFilteredVendors("purpose",e,"legInt")},t.prototype.getVendorsWithFlexiblePurpose=function(e){return this.getFilteredVendors("purpose",e,"flexible")},t.prototype.getVendorsWithSpecialPurpose=function(e){return this.getFilteredVendors("purpose",e,void 0,!0)},t.prototype.getVendorsWithFeature=function(e){return this.getFilteredVendors("feature",e)},t.prototype.getVendorsWithSpecialFeature=function(e){return this.getFilteredVendors("feature",e,void 0,!0)},Object.defineProperty(t.prototype,"vendors",{get:function(){return this.vendors_},enumerable:!1,configurable:!0}),t.prototype.narrowVendorsTo=function(e){this.mapVendors(e)},Object.defineProperty(t.prototype,"isReady",{get:function(){return this.isReady_},enumerable:!1,configurable:!0}),t.prototype.clone=function(){var e=new t(this.getJson());return this.lang_!==t.DEFAULT_LANGUAGE&&e.changeLanguage(this.lang_),e},t.isInstanceOf=function(e){return"object"==typeof e&&"function"==typeof e.narrowVendorsTo},t.LANGUAGE_CACHE=new Map,t.CACHE=new Map,t.LATEST_CACHE_KEY=0,t.DEFAULT_LANGUAGE="EN",t.consentLanguages=new index_js_2.ConsentLanguages,t.latestFilename="vendor-list.json",t.versionedFilename="archives/vendor-list-v[VERSION].json",t.languageFilename="purposes-[LANG].json",t}(Cloneable_js_1.Cloneable);exports.GVL=GVL; | ||
"use strict";var __extends=this&&this.__extends||function(){var e=function(t,r){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])})(t,r)};return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),__assign=this&&this.__assign||function(){return(__assign=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var s in t=arguments[r])Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e}).apply(this,arguments)},__awaiter=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(s,o){function i(e){try{l(n.next(e))}catch(e){o(e)}}function a(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,a)}l((n=n.apply(e,t||[])).next())}))},__generator=this&&this.__generator||function(e,t){var r,n,s,o,i={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(s=2&o[0]?n.return:o[0]?n.throw||((s=n.return)&&s.call(n),0):n.next)&&!(s=s.call(n,o[1])).done)return s;switch(n=0,s&&(o=[2&o[0],s.value]),o[0]){case 0:case 1:s=o;break;case 4:return i.label++,{value:o[1],done:!1};case 5:i.label++,n=o[1],o=[0];continue;case 7:o=i.ops.pop(),i.trys.pop();continue;default:if(!(s=i.trys,(s=s.length>0&&s[s.length-1])||6!==o[0]&&2!==o[0])){i=0;continue}if(3===o[0]&&(!s||o[1]>s[0]&&o[1]<s[3])){i.label=o[1];break}if(6===o[0]&&i.label<s[1]){i.label=s[1],s=o;break}if(s&&i.label<s[2]){i.label=s[2],i.ops.push(o);break}s[2]&&i.ops.pop(),i.trys.pop();continue}o=t.call(e,i)}catch(e){o=[6,e],n=0}finally{r=s=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}},__values=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(exports,"__esModule",{value:!0}),exports.GVL=void 0;var Cloneable_js_1=require("./Cloneable.js"),index_js_1=require("./errors/index.js"),Json_js_1=require("./Json.js"),index_js_2=require("./model/index.js"),GVL=function(e){function t(r){var n=e.call(this)||this;n.isReady_=!1,n.isLatest=!1;var s=t.baseUrl;if(n.lang_=t.DEFAULT_LANGUAGE,n.isVendorList(r))n.populate(r),n.readyPromise=Promise.resolve();else{if(!s)throw new index_js_1.GVLError("must specify GVL.baseUrl before loading GVL json");if(r>0){var o=r;t.CACHE.has(o)?(n.populate(t.CACHE.get(o)),n.readyPromise=Promise.resolve()):(s+=t.versionedFilename.replace("[VERSION]",String(o)),n.readyPromise=n.fetchJson(s))}else t.CACHE.has(t.LATEST_CACHE_KEY)?(n.populate(t.CACHE.get(t.LATEST_CACHE_KEY)),n.readyPromise=Promise.resolve()):(n.isLatest=!0,n.readyPromise=n.fetchJson(s+t.latestFilename))}return n}return __extends(t,e),Object.defineProperty(t,"baseUrl",{get:function(){return this.baseUrl_},set:function(e){if(/^https?:\/\/vendorlist\.consensu\.org\//.test(e))throw new index_js_1.GVLError("Invalid baseUrl! You may not pull directly from vendorlist.consensu.org and must provide your own cache");e.length>0&&"/"!==e[e.length-1]&&(e+="/"),this.baseUrl_=e},enumerable:!1,configurable:!0}),t.emptyLanguageCache=function(e){var r=!1;return void 0===e&&t.LANGUAGE_CACHE.size>0?(t.LANGUAGE_CACHE=new Map,r=!0):"string"==typeof e&&this.consentLanguages.has(e.toUpperCase())&&(t.LANGUAGE_CACHE.delete(e.toUpperCase()),r=!0),r},t.emptyCache=function(e){var r=!1;return Number.isInteger(e)&&e>=0?(t.CACHE.delete(e),r=!0):void 0===e&&(t.CACHE=new Map,r=!0),r},t.prototype.cacheLanguage=function(){t.LANGUAGE_CACHE.has(this.lang_)||t.LANGUAGE_CACHE.set(this.lang_,{purposes:this.purposes,specialPurposes:this.specialPurposes,features:this.features,specialFeatures:this.specialFeatures,stacks:this.stacks,dataCategories:this.dataCategories})},t.prototype.fetchJson=function(e){return __awaiter(this,void 0,void 0,(function(){var t,r;return __generator(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),t=this.populate,[4,Json_js_1.Json.fetch(e)];case 1:return t.apply(this,[n.sent()]),[3,3];case 2:throw r=n.sent(),new index_js_1.GVLError(r.message);case 3:return[2]}}))}))},t.prototype.getJson=function(){return __assign(__assign({gvlSpecificationVersion:this.gvlSpecificationVersion,vendorListVersion:this.vendorListVersion,tcfPolicyVersion:this.tcfPolicyVersion,lastUpdated:this.lastUpdated,purposes:this.clonePurposes(),specialPurposes:this.cloneSpecialPurposes(),features:this.cloneFeatures(),specialFeatures:this.cloneSpecialFeatures(),stacks:this.cloneStacks()},this.dataCategories?{dataCategories:this.cloneDataCategories()}:{}),{vendors:this.cloneVendors()})},t.prototype.cloneSpecialFeatures=function(){var e,r,n={};try{for(var s=__values(Object.keys(this.specialFeatures)),o=s.next();!o.done;o=s.next()){var i=o.value;n[i]=t.cloneFeature(this.specialFeatures[i])}}catch(t){e={error:t}}finally{try{o&&!o.done&&(r=s.return)&&r.call(s)}finally{if(e)throw e.error}}return n},t.prototype.cloneFeatures=function(){var e,r,n={};try{for(var s=__values(Object.keys(this.features)),o=s.next();!o.done;o=s.next()){var i=o.value;n[i]=t.cloneFeature(this.features[i])}}catch(t){e={error:t}}finally{try{o&&!o.done&&(r=s.return)&&r.call(s)}finally{if(e)throw e.error}}return n},t.prototype.cloneStacks=function(){var e,r,n={};try{for(var s=__values(Object.keys(this.stacks)),o=s.next();!o.done;o=s.next()){var i=o.value;n[i]=t.cloneStack(this.stacks[i])}}catch(t){e={error:t}}finally{try{o&&!o.done&&(r=s.return)&&r.call(s)}finally{if(e)throw e.error}}return n},t.prototype.cloneDataCategories=function(){var e,r,n={};try{for(var s=__values(Object.keys(this.dataCategories)),o=s.next();!o.done;o=s.next()){var i=o.value;n[i]=t.cloneDataCategory(this.dataCategories[i])}}catch(t){e={error:t}}finally{try{o&&!o.done&&(r=s.return)&&r.call(s)}finally{if(e)throw e.error}}return n},t.prototype.cloneSpecialPurposes=function(){var e,r,n={};try{for(var s=__values(Object.keys(this.specialPurposes)),o=s.next();!o.done;o=s.next()){var i=o.value;n[i]=t.clonePurpose(this.specialPurposes[i])}}catch(t){e={error:t}}finally{try{o&&!o.done&&(r=s.return)&&r.call(s)}finally{if(e)throw e.error}}return n},t.prototype.clonePurposes=function(){var e,r,n={};try{for(var s=__values(Object.keys(this.purposes)),o=s.next();!o.done;o=s.next()){var i=o.value;n[i]=t.clonePurpose(this.purposes[i])}}catch(t){e={error:t}}finally{try{o&&!o.done&&(r=s.return)&&r.call(s)}finally{if(e)throw e.error}}return n},t.clonePurpose=function(e){return __assign(__assign({id:e.id,name:e.name,description:e.description},e.descriptionLegal?{descriptionLegal:e.descriptionLegal}:{}),e.illustrations?{illustrations:Array.from(e.illustrations)}:{})},t.cloneFeature=function(e){return __assign(__assign({id:e.id,name:e.name,description:e.description},e.descriptionLegal?{descriptionLegal:e.descriptionLegal}:{}),e.illustrations?{illustrations:Array.from(e.illustrations)}:{})},t.cloneDataCategory=function(e){return{id:e.id,name:e.name,description:e.description}},t.cloneStack=function(e){return{id:e.id,name:e.name,description:e.description,purposes:Array.from(e.purposes),specialFeatures:Array.from(e.specialFeatures)}},t.cloneDataRetention=function(e){return __assign(__assign({},"number"==typeof e.stdRetention?{stdRetention:e.stdRetention}:{}),{purposes:__assign({},e.purposes),specialPurposes:__assign({},e.specialPurposes)})},t.cloneVendorUrls=function(e){return e.map((function(e){return __assign({langId:e.langId,privacy:e.privacy},e.legIntClaim?{legIntClaim:e.legIntClaim}:{})}))},t.cloneVendor=function(e){return __assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign({id:e.id,name:e.name,purposes:Array.from(e.purposes),legIntPurposes:Array.from(e.legIntPurposes),flexiblePurposes:Array.from(e.flexiblePurposes),specialPurposes:Array.from(e.specialPurposes),features:Array.from(e.features),specialFeatures:Array.from(e.specialFeatures)},e.overflow?{overflow:{httpGetLimit:e.overflow.httpGetLimit}}:{}),"number"==typeof e.cookieMaxAgeSeconds||null===e.cookieMaxAgeSeconds?{cookieMaxAgeSeconds:e.cookieMaxAgeSeconds}:{}),void 0!==e.usesCookies?{usesCookies:e.usesCookies}:{}),e.policyUrl?{policyUrl:e.policyUrl}:{}),void 0!==e.cookieRefresh?{cookieRefresh:e.cookieRefresh}:{}),void 0!==e.usesNonCookieAccess?{usesNonCookieAccess:e.usesNonCookieAccess}:{}),e.dataRetention?{dataRetention:this.cloneDataRetention(e.dataRetention)}:{}),e.urls?{urls:this.cloneVendorUrls(e.urls)}:{}),e.dataDeclaration?{dataDeclaration:Array.from(e.dataDeclaration)}:{}),e.deviceStorageDisclosureUrl?{deviceStorageDisclosureUrl:e.deviceStorageDisclosureUrl}:{}),e.deletedDate?{deletedDate:e.deletedDate}:{})},t.prototype.cloneVendors=function(){var e,r,n={};try{for(var s=__values(Object.keys(this.fullVendorList)),o=s.next();!o.done;o=s.next()){var i=o.value;n[i]=t.cloneVendor(this.fullVendorList[i])}}catch(t){e={error:t}}finally{try{o&&!o.done&&(r=s.return)&&r.call(s)}finally{if(e)throw e.error}}return n},t.prototype.changeLanguage=function(e){return __awaiter(this,void 0,void 0,(function(){var r,n,s,o,i;return __generator(this,(function(a){switch(a.label){case 0:if(r=e.toUpperCase(),!t.consentLanguages.has(r))return[3,6];if(r===this.lang_)return[3,5];if(this.lang_=r,!t.LANGUAGE_CACHE.has(r))return[3,1];for(s in n=t.LANGUAGE_CACHE.get(r))n.hasOwnProperty(s)&&(this[s]=n[s]);return[3,5];case 1:o=t.baseUrl+t.languageFilename.replace("[LANG]",e),a.label=2;case 2:return a.trys.push([2,4,,5]),[4,this.fetchJson(o)];case 3:return a.sent(),this.cacheLanguage(),[3,5];case 4:throw i=a.sent(),new index_js_1.GVLError("unable to load language: "+i.message);case 5:return[3,7];case 6:throw new index_js_1.GVLError("unsupported language ".concat(e));case 7:return[2]}}))}))},Object.defineProperty(t.prototype,"language",{get:function(){return this.lang_},enumerable:!1,configurable:!0}),t.prototype.isVendorList=function(e){return void 0!==e&&void 0!==e.vendors},t.prototype.populate=function(e){this.purposes=e.purposes,this.specialPurposes=e.specialPurposes,this.features=e.features,this.specialFeatures=e.specialFeatures,this.stacks=e.stacks,this.dataCategories=e.dataCategories,this.isVendorList(e)&&(this.gvlSpecificationVersion=e.gvlSpecificationVersion,this.tcfPolicyVersion=e.tcfPolicyVersion,this.vendorListVersion=e.vendorListVersion,this.lastUpdated=e.lastUpdated,"string"==typeof this.lastUpdated&&(this.lastUpdated=new Date(this.lastUpdated)),this.vendors_=e.vendors,this.fullVendorList=e.vendors,this.mapVendors(),this.isReady_=!0,this.isLatest&&t.CACHE.set(t.LATEST_CACHE_KEY,this.getJson()),t.CACHE.has(this.vendorListVersion)||t.CACHE.set(this.vendorListVersion,this.getJson())),this.cacheLanguage()},t.prototype.mapVendors=function(e){var t=this;this.byPurposeVendorMap={},this.bySpecialPurposeVendorMap={},this.byFeatureVendorMap={},this.bySpecialFeatureVendorMap={},Object.keys(this.purposes).forEach((function(e){t.byPurposeVendorMap[e]={legInt:new Set,consent:new Set,flexible:new Set}})),Object.keys(this.specialPurposes).forEach((function(e){t.bySpecialPurposeVendorMap[e]=new Set})),Object.keys(this.features).forEach((function(e){t.byFeatureVendorMap[e]=new Set})),Object.keys(this.specialFeatures).forEach((function(e){t.bySpecialFeatureVendorMap[e]=new Set})),Array.isArray(e)||(e=Object.keys(this.fullVendorList).map((function(e){return+e}))),this.vendorIds=new Set(e),this.vendors_=e.reduce((function(e,r){var n=t.vendors_[String(r)];return n&&void 0===n.deletedDate&&(n.purposes.forEach((function(e){t.byPurposeVendorMap[String(e)].consent.add(r)})),n.specialPurposes.forEach((function(e){t.bySpecialPurposeVendorMap[String(e)].add(r)})),n.legIntPurposes.forEach((function(e){t.byPurposeVendorMap[String(e)].legInt.add(r)})),n.flexiblePurposes&&n.flexiblePurposes.forEach((function(e){t.byPurposeVendorMap[String(e)].flexible.add(r)})),n.features.forEach((function(e){t.byFeatureVendorMap[String(e)].add(r)})),n.specialFeatures.forEach((function(e){t.bySpecialFeatureVendorMap[String(e)].add(r)})),e[r]=n),e}),{})},t.prototype.getFilteredVendors=function(e,t,r,n){var s=this,o=e.charAt(0).toUpperCase()+e.slice(1),i={};return("purpose"===e&&r?this["by"+o+"VendorMap"][String(t)][r]:this["by"+(n?"Special":"")+o+"VendorMap"][String(t)]).forEach((function(e){i[String(e)]=s.vendors[String(e)]})),i},t.prototype.getVendorsWithConsentPurpose=function(e){return this.getFilteredVendors("purpose",e,"consent")},t.prototype.getVendorsWithLegIntPurpose=function(e){return this.getFilteredVendors("purpose",e,"legInt")},t.prototype.getVendorsWithFlexiblePurpose=function(e){return this.getFilteredVendors("purpose",e,"flexible")},t.prototype.getVendorsWithSpecialPurpose=function(e){return this.getFilteredVendors("purpose",e,void 0,!0)},t.prototype.getVendorsWithFeature=function(e){return this.getFilteredVendors("feature",e)},t.prototype.getVendorsWithSpecialFeature=function(e){return this.getFilteredVendors("feature",e,void 0,!0)},Object.defineProperty(t.prototype,"vendors",{get:function(){return this.vendors_},enumerable:!1,configurable:!0}),t.prototype.narrowVendorsTo=function(e){this.mapVendors(e)},Object.defineProperty(t.prototype,"isReady",{get:function(){return this.isReady_},enumerable:!1,configurable:!0}),t.prototype.clone=function(){var e=new t(this.getJson());return this.lang_!==t.DEFAULT_LANGUAGE&&e.changeLanguage(this.lang_),e},t.isInstanceOf=function(e){return"object"==typeof e&&"function"==typeof e.narrowVendorsTo},t.LANGUAGE_CACHE=new Map,t.CACHE=new Map,t.LATEST_CACHE_KEY=0,t.DEFAULT_LANGUAGE="EN",t.consentLanguages=new index_js_2.ConsentLanguages,t.latestFilename="vendor-list.json",t.versionedFilename="archives/vendor-list-v[VERSION].json",t.languageFilename="purposes-[LANG].json",t}(Cloneable_js_1.Cloneable);exports.GVL=GVL; |
@@ -5,2 +5,3 @@ import { IntMap } from '../IntMap.js'; | ||
import { Stack } from './Stack.js'; | ||
import { DataCategory } from './DataCategory.js'; | ||
export interface Declarations { | ||
@@ -12,2 +13,3 @@ purposes: IntMap<Purpose>; | ||
stacks: IntMap<Stack>; | ||
dataCategories?: IntMap<DataCategory>; | ||
} |
import { GVLMapItem } from './GVLMapItem.js'; | ||
export interface Feature extends GVLMapItem { | ||
description: string; | ||
descriptionLegal: string; | ||
descriptionLegal?: string; | ||
illustrations?: string[]; | ||
} |
@@ -10,1 +10,2 @@ export * from './ByPurposeVendorMap.js'; | ||
export * from './VendorList.js'; | ||
export * from './DataCategory.js'; |
@@ -1,1 +0,1 @@ | ||
"use strict";var __createBinding=this&&this.__createBinding||(Object.create?function(e,r,t,o){void 0===o&&(o=t),Object.defineProperty(e,o,{enumerable:!0,get:function(){return r[t]}})}:function(e,r,t,o){void 0===o&&(o=t),e[o]=r[t]}),__exportStar=this&&this.__exportStar||function(e,r){for(var t in e)"default"===t||Object.prototype.hasOwnProperty.call(r,t)||__createBinding(r,e,t)};Object.defineProperty(exports,"__esModule",{value:!0}),__exportStar(require("./ByPurposeVendorMap.js"),exports),__exportStar(require("./Declarations.js"),exports),__exportStar(require("./Feature.js"),exports),__exportStar(require("./GVLMapItem.js"),exports),__exportStar(require("./IDSetMap.js"),exports),__exportStar(require("./Purpose.js"),exports),__exportStar(require("./Stack.js"),exports),__exportStar(require("./Vendor.js"),exports),__exportStar(require("./VendorList.js"),exports); | ||
"use strict";var __createBinding=this&&this.__createBinding||(Object.create?function(e,r,t,o){void 0===o&&(o=t),Object.defineProperty(e,o,{enumerable:!0,get:function(){return r[t]}})}:function(e,r,t,o){void 0===o&&(o=t),e[o]=r[t]}),__exportStar=this&&this.__exportStar||function(e,r){for(var t in e)"default"===t||Object.prototype.hasOwnProperty.call(r,t)||__createBinding(r,e,t)};Object.defineProperty(exports,"__esModule",{value:!0}),__exportStar(require("./ByPurposeVendorMap.js"),exports),__exportStar(require("./Declarations.js"),exports),__exportStar(require("./Feature.js"),exports),__exportStar(require("./GVLMapItem.js"),exports),__exportStar(require("./IDSetMap.js"),exports),__exportStar(require("./Purpose.js"),exports),__exportStar(require("./Stack.js"),exports),__exportStar(require("./Vendor.js"),exports),__exportStar(require("./VendorList.js"),exports),__exportStar(require("./DataCategory.js"),exports); |
import { GVLMapItem } from './GVLMapItem.js'; | ||
export interface Purpose extends GVLMapItem { | ||
description: string; | ||
descriptionLegal: string; | ||
descriptionLegal?: string; | ||
illustrations?: string[]; | ||
} |
import { GVLMapItem } from './GVLMapItem.js'; | ||
import { DataRetention } from './DataRetention.js'; | ||
import { VendorUrl } from './VendorUrl.js'; | ||
export interface Vendor extends GVLMapItem { | ||
@@ -9,3 +11,3 @@ purposes: number[]; | ||
specialFeatures: number[]; | ||
policyUrl: string; | ||
policyUrl?: string; | ||
usesCookies: boolean; | ||
@@ -20,2 +22,5 @@ cookieMaxAgeSeconds: number | null; | ||
}; | ||
dataRetention?: DataRetention; | ||
urls?: VendorUrl[]; | ||
dataDeclaration?: number[]; | ||
} |
@@ -1,1 +0,1 @@ | ||
"use strict";var __extends=this&&this.__extends||function(){var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(t,n)};return function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function s(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(s.prototype=n.prototype,new s)}}();Object.defineProperty(exports,"__esModule",{value:!0}),exports.TCModel=void 0;var Cloneable_js_1=require("./Cloneable.js"),index_js_1=require("./errors/index.js"),GVL_js_1=require("./GVL.js"),index_js_2=require("./model/index.js"),TCModel=function(e){function t(t){var n=e.call(this)||this;return n.isServiceSpecific_=!1,n.supportOOB_=!0,n.useNonStandardTexts_=!1,n.purposeOneTreatment_=!1,n.publisherCountryCode_="AA",n.version_=2,n.consentScreen_=0,n.policyVersion_=4,n.consentLanguage_="EN",n.cmpId_=0,n.cmpVersion_=0,n.vendorListVersion_=0,n.numCustomPurposes_=0,n.specialFeatureOptins=new index_js_2.Vector,n.purposeConsents=new index_js_2.Vector,n.purposeLegitimateInterests=new index_js_2.Vector,n.publisherConsents=new index_js_2.Vector,n.publisherLegitimateInterests=new index_js_2.Vector,n.publisherCustomConsents=new index_js_2.Vector,n.publisherCustomLegitimateInterests=new index_js_2.Vector,n.vendorConsents=new index_js_2.Vector,n.vendorLegitimateInterests=new index_js_2.Vector,n.vendorsDisclosed=new index_js_2.Vector,n.vendorsAllowed=new index_js_2.Vector,n.publisherRestrictions=new index_js_2.PurposeRestrictionVector,t&&(n.gvl=t),n.updated(),n}return __extends(t,e),Object.defineProperty(t.prototype,"gvl",{get:function(){return this.gvl_},set:function(e){GVL_js_1.GVL.isInstanceOf(e)||(e=new GVL_js_1.GVL(e)),this.gvl_=e,this.publisherRestrictions.gvl=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cmpId",{get:function(){return this.cmpId_},set:function(e){if(e=Number(e),!(Number.isInteger(e)&&e>1))throw new index_js_1.TCModelError("cmpId",e);this.cmpId_=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cmpVersion",{get:function(){return this.cmpVersion_},set:function(e){if(e=Number(e),!(Number.isInteger(e)&&e>-1))throw new index_js_1.TCModelError("cmpVersion",e);this.cmpVersion_=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"consentScreen",{get:function(){return this.consentScreen_},set:function(e){if(e=Number(e),!(Number.isInteger(e)&&e>-1))throw new index_js_1.TCModelError("consentScreen",e);this.consentScreen_=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"consentLanguage",{get:function(){return this.consentLanguage_},set:function(e){this.consentLanguage_=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"publisherCountryCode",{get:function(){return this.publisherCountryCode_},set:function(e){if(!/^([A-z]){2}$/.test(e))throw new index_js_1.TCModelError("publisherCountryCode",e);this.publisherCountryCode_=e.toUpperCase()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"vendorListVersion",{get:function(){return this.gvl?this.gvl.vendorListVersion:this.vendorListVersion_},set:function(e){if((e=Number(e)>>0)<0)throw new index_js_1.TCModelError("vendorListVersion",e);this.vendorListVersion_=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"policyVersion",{get:function(){return this.gvl?this.gvl.tcfPolicyVersion:this.policyVersion_},set:function(e){if(this.policyVersion_=parseInt(e,10),this.policyVersion_<0)throw new index_js_1.TCModelError("policyVersion",e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"version",{get:function(){return this.version_},set:function(e){this.version_=parseInt(e,10)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isServiceSpecific",{get:function(){return this.isServiceSpecific_},set:function(e){this.isServiceSpecific_=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"useNonStandardTexts",{get:function(){return this.useNonStandardTexts_},set:function(e){this.useNonStandardTexts_=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"supportOOB",{get:function(){return this.supportOOB_},set:function(e){this.supportOOB_=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"purposeOneTreatment",{get:function(){return this.purposeOneTreatment_},set:function(e){this.purposeOneTreatment_=e},enumerable:!1,configurable:!0}),t.prototype.setAllVendorConsents=function(){this.vendorConsents.set(this.gvl.vendors)},t.prototype.unsetAllVendorConsents=function(){this.vendorConsents.empty()},t.prototype.setAllVendorsDisclosed=function(){this.vendorsDisclosed.set(this.gvl.vendors)},t.prototype.unsetAllVendorsDisclosed=function(){this.vendorsDisclosed.empty()},t.prototype.setAllVendorsAllowed=function(){this.vendorsAllowed.set(this.gvl.vendors)},t.prototype.unsetAllVendorsAllowed=function(){this.vendorsAllowed.empty()},t.prototype.setAllVendorLegitimateInterests=function(){this.vendorLegitimateInterests.set(this.gvl.vendors)},t.prototype.unsetAllVendorLegitimateInterests=function(){this.vendorLegitimateInterests.empty()},t.prototype.setAllPurposeConsents=function(){this.purposeConsents.set(this.gvl.purposes)},t.prototype.unsetAllPurposeConsents=function(){this.purposeConsents.empty()},t.prototype.setAllPurposeLegitimateInterests=function(){this.purposeLegitimateInterests.set(this.gvl.purposes)},t.prototype.unsetAllPurposeLegitimateInterests=function(){this.purposeLegitimateInterests.empty()},t.prototype.setAllSpecialFeatureOptins=function(){this.specialFeatureOptins.set(this.gvl.specialFeatures)},t.prototype.unsetAllSpecialFeatureOptins=function(){this.specialFeatureOptins.empty()},t.prototype.setAll=function(){this.setAllVendorConsents(),this.setAllPurposeLegitimateInterests(),this.setAllSpecialFeatureOptins(),this.setAllPurposeConsents(),this.setAllVendorLegitimateInterests()},t.prototype.unsetAll=function(){this.unsetAllVendorConsents(),this.unsetAllPurposeLegitimateInterests(),this.unsetAllSpecialFeatureOptins(),this.unsetAllPurposeConsents(),this.unsetAllVendorLegitimateInterests()},Object.defineProperty(t.prototype,"numCustomPurposes",{get:function(){var e=this.numCustomPurposes_;if("object"==typeof this.customPurposes){var t=Object.keys(this.customPurposes).sort((function(e,t){return Number(e)-Number(t)}));e=parseInt(t.pop(),10)}return e},set:function(e){if(this.numCustomPurposes_=parseInt(e,10),this.numCustomPurposes_<0)throw new index_js_1.TCModelError("numCustomPurposes",e)},enumerable:!1,configurable:!0}),t.prototype.updated=function(){var e=new Date,t=new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()));this.created=t,this.lastUpdated=t},t.consentLanguages=GVL_js_1.GVL.consentLanguages,t}(Cloneable_js_1.Cloneable);exports.TCModel=TCModel; | ||
"use strict";var __extends=this&&this.__extends||function(){var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(t,n)};return function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function s(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(s.prototype=n.prototype,new s)}}();Object.defineProperty(exports,"__esModule",{value:!0}),exports.TCModel=void 0;var Cloneable_js_1=require("./Cloneable.js"),index_js_1=require("./errors/index.js"),GVL_js_1=require("./GVL.js"),index_js_2=require("./model/index.js"),TCModel=function(e){function t(t){var n=e.call(this)||this;return n.isServiceSpecific_=!1,n.supportOOB_=!0,n.useNonStandardTexts_=!1,n.purposeOneTreatment_=!1,n.publisherCountryCode_="AA",n.version_=2,n.consentScreen_=0,n.policyVersion_=5,n.consentLanguage_="EN",n.cmpId_=0,n.cmpVersion_=0,n.vendorListVersion_=0,n.numCustomPurposes_=0,n.specialFeatureOptins=new index_js_2.Vector,n.purposeConsents=new index_js_2.Vector,n.purposeLegitimateInterests=new index_js_2.Vector,n.publisherConsents=new index_js_2.Vector,n.publisherLegitimateInterests=new index_js_2.Vector,n.publisherCustomConsents=new index_js_2.Vector,n.publisherCustomLegitimateInterests=new index_js_2.Vector,n.vendorConsents=new index_js_2.Vector,n.vendorLegitimateInterests=new index_js_2.Vector,n.vendorsDisclosed=new index_js_2.Vector,n.vendorsAllowed=new index_js_2.Vector,n.publisherRestrictions=new index_js_2.PurposeRestrictionVector,t&&(n.gvl=t),n.updated(),n}return __extends(t,e),Object.defineProperty(t.prototype,"gvl",{get:function(){return this.gvl_},set:function(e){GVL_js_1.GVL.isInstanceOf(e)||(e=new GVL_js_1.GVL(e)),this.gvl_=e,this.publisherRestrictions.gvl=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cmpId",{get:function(){return this.cmpId_},set:function(e){if(e=Number(e),!(Number.isInteger(e)&&e>1))throw new index_js_1.TCModelError("cmpId",e);this.cmpId_=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cmpVersion",{get:function(){return this.cmpVersion_},set:function(e){if(e=Number(e),!(Number.isInteger(e)&&e>-1))throw new index_js_1.TCModelError("cmpVersion",e);this.cmpVersion_=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"consentScreen",{get:function(){return this.consentScreen_},set:function(e){if(e=Number(e),!(Number.isInteger(e)&&e>-1))throw new index_js_1.TCModelError("consentScreen",e);this.consentScreen_=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"consentLanguage",{get:function(){return this.consentLanguage_},set:function(e){this.consentLanguage_=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"publisherCountryCode",{get:function(){return this.publisherCountryCode_},set:function(e){if(!/^([A-z]){2}$/.test(e))throw new index_js_1.TCModelError("publisherCountryCode",e);this.publisherCountryCode_=e.toUpperCase()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"vendorListVersion",{get:function(){return this.gvl?this.gvl.vendorListVersion:this.vendorListVersion_},set:function(e){if((e=Number(e)>>0)<0)throw new index_js_1.TCModelError("vendorListVersion",e);this.vendorListVersion_=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"policyVersion",{get:function(){return this.gvl?this.gvl.tcfPolicyVersion:this.policyVersion_},set:function(e){if(this.policyVersion_=parseInt(e,10),this.policyVersion_<0)throw new index_js_1.TCModelError("policyVersion",e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"version",{get:function(){return this.version_},set:function(e){this.version_=parseInt(e,10)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isServiceSpecific",{get:function(){return this.isServiceSpecific_},set:function(e){this.isServiceSpecific_=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"useNonStandardTexts",{get:function(){return this.useNonStandardTexts_},set:function(e){this.useNonStandardTexts_=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"supportOOB",{get:function(){return this.supportOOB_},set:function(e){this.supportOOB_=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"purposeOneTreatment",{get:function(){return this.purposeOneTreatment_},set:function(e){this.purposeOneTreatment_=e},enumerable:!1,configurable:!0}),t.prototype.setAllVendorConsents=function(){this.vendorConsents.set(this.gvl.vendors)},t.prototype.unsetAllVendorConsents=function(){this.vendorConsents.empty()},t.prototype.setAllVendorsDisclosed=function(){this.vendorsDisclosed.set(this.gvl.vendors)},t.prototype.unsetAllVendorsDisclosed=function(){this.vendorsDisclosed.empty()},t.prototype.setAllVendorsAllowed=function(){this.vendorsAllowed.set(this.gvl.vendors)},t.prototype.unsetAllVendorsAllowed=function(){this.vendorsAllowed.empty()},t.prototype.setAllVendorLegitimateInterests=function(){this.vendorLegitimateInterests.set(this.gvl.vendors)},t.prototype.unsetAllVendorLegitimateInterests=function(){this.vendorLegitimateInterests.empty()},t.prototype.setAllPurposeConsents=function(){this.purposeConsents.set(this.gvl.purposes)},t.prototype.unsetAllPurposeConsents=function(){this.purposeConsents.empty()},t.prototype.setAllPurposeLegitimateInterests=function(){this.purposeLegitimateInterests.set(this.gvl.purposes)},t.prototype.unsetAllPurposeLegitimateInterests=function(){this.purposeLegitimateInterests.empty()},t.prototype.setAllSpecialFeatureOptins=function(){this.specialFeatureOptins.set(this.gvl.specialFeatures)},t.prototype.unsetAllSpecialFeatureOptins=function(){this.specialFeatureOptins.empty()},t.prototype.setAll=function(){this.setAllVendorConsents(),this.setAllPurposeLegitimateInterests(),this.setAllSpecialFeatureOptins(),this.setAllPurposeConsents(),this.setAllVendorLegitimateInterests()},t.prototype.unsetAll=function(){this.unsetAllVendorConsents(),this.unsetAllPurposeLegitimateInterests(),this.unsetAllSpecialFeatureOptins(),this.unsetAllPurposeConsents(),this.unsetAllVendorLegitimateInterests()},Object.defineProperty(t.prototype,"numCustomPurposes",{get:function(){var e=this.numCustomPurposes_;if("object"==typeof this.customPurposes){var t=Object.keys(this.customPurposes).sort((function(e,t){return Number(e)-Number(t)}));e=parseInt(t.pop(),10)}return e},set:function(e){if(this.numCustomPurposes_=parseInt(e,10),this.numCustomPurposes_<0)throw new index_js_1.TCModelError("numCustomPurposes",e)},enumerable:!1,configurable:!0}),t.prototype.updated=function(){var e=new Date,t=new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()));this.created=t,this.lastUpdated=t},t.consentLanguages=GVL_js_1.GVL.consentLanguages,t}(Cloneable_js_1.Cloneable);exports.TCModel=TCModel; |
import { Cloneable } from './Cloneable.js'; | ||
import { GVLError } from './errors/index.js'; | ||
import { ConsentLanguages, IntMap } from './model/index.js'; | ||
import { Feature, Purpose, Stack, Vendor, VendorList } from './model/gvl/index.js'; | ||
import { Feature, Purpose, Stack, Vendor, VendorList, DataCategory } from './model/gvl/index.js'; | ||
export declare type VersionOrVendorList = string | number | VendorList; | ||
@@ -168,2 +168,6 @@ /** | ||
stacks: IntMap<Stack>; | ||
/** | ||
* @param {IntMap<DataCategory>} a collection of [[DataCategory]]s | ||
*/ | ||
dataCategories?: IntMap<DataCategory>; | ||
private lang_; | ||
@@ -205,2 +209,16 @@ private isLatest; | ||
getJson(): VendorList; | ||
private cloneSpecialFeatures; | ||
private cloneFeatures; | ||
private cloneStacks; | ||
private cloneDataCategories; | ||
private cloneSpecialPurposes; | ||
private clonePurposes; | ||
private static clonePurpose; | ||
private static cloneFeature; | ||
private static cloneDataCategory; | ||
private static cloneStack; | ||
private static cloneDataRetention; | ||
private static cloneVendorUrls; | ||
private static cloneVendor; | ||
private cloneVendors; | ||
/** | ||
@@ -207,0 +225,0 @@ * changeLanguage - retrieves the purpose language translation and sets the |
@@ -180,2 +180,6 @@ import { Cloneable } from './Cloneable.js'; | ||
stacks; | ||
/** | ||
* @param {IntMap<DataCategory>} a collection of [[DataCategory]]s | ||
*/ | ||
dataCategories; | ||
lang_; | ||
@@ -283,2 +287,3 @@ isLatest = false; | ||
stacks: this.stacks, | ||
dataCategories: this.dataCategories, | ||
}); | ||
@@ -303,3 +308,3 @@ } | ||
getJson() { | ||
return JSON.parse(JSON.stringify({ | ||
return { | ||
gvlSpecificationVersion: this.gvlSpecificationVersion, | ||
@@ -309,10 +314,131 @@ vendorListVersion: this.vendorListVersion, | ||
lastUpdated: this.lastUpdated, | ||
purposes: this.purposes, | ||
specialPurposes: this.specialPurposes, | ||
features: this.features, | ||
specialFeatures: this.specialFeatures, | ||
stacks: this.stacks, | ||
vendors: this.fullVendorList, | ||
purposes: this.clonePurposes(), | ||
specialPurposes: this.cloneSpecialPurposes(), | ||
features: this.cloneFeatures(), | ||
specialFeatures: this.cloneSpecialFeatures(), | ||
stacks: this.cloneStacks(), | ||
...(this.dataCategories ? { dataCategories: this.cloneDataCategories() } : {}), | ||
vendors: this.cloneVendors(), | ||
}; | ||
} | ||
cloneSpecialFeatures() { | ||
const features = {}; | ||
for (const featureId of Object.keys(this.specialFeatures)) { | ||
features[featureId] = GVL.cloneFeature(this.specialFeatures[featureId]); | ||
} | ||
return features; | ||
} | ||
cloneFeatures() { | ||
const features = {}; | ||
for (const featureId of Object.keys(this.features)) { | ||
features[featureId] = GVL.cloneFeature(this.features[featureId]); | ||
} | ||
return features; | ||
} | ||
cloneStacks() { | ||
const stacks = {}; | ||
for (const stackId of Object.keys(this.stacks)) { | ||
stacks[stackId] = GVL.cloneStack(this.stacks[stackId]); | ||
} | ||
return stacks; | ||
} | ||
cloneDataCategories() { | ||
const dataCategories = {}; | ||
for (const dataCategoryId of Object.keys(this.dataCategories)) { | ||
dataCategories[dataCategoryId] = GVL.cloneDataCategory(this.dataCategories[dataCategoryId]); | ||
} | ||
return dataCategories; | ||
} | ||
cloneSpecialPurposes() { | ||
const purposes = {}; | ||
for (const purposeId of Object.keys(this.specialPurposes)) { | ||
purposes[purposeId] = GVL.clonePurpose(this.specialPurposes[purposeId]); | ||
} | ||
return purposes; | ||
} | ||
clonePurposes() { | ||
const purposes = {}; | ||
for (const purposeId of Object.keys(this.purposes)) { | ||
purposes[purposeId] = GVL.clonePurpose(this.purposes[purposeId]); | ||
} | ||
return purposes; | ||
} | ||
static clonePurpose(purpose) { | ||
return { | ||
id: purpose.id, | ||
name: purpose.name, | ||
description: purpose.description, | ||
...(purpose.descriptionLegal ? { descriptionLegal: purpose.descriptionLegal } : {}), | ||
...(purpose.illustrations ? { illustrations: Array.from(purpose.illustrations) } : {}), | ||
}; | ||
} | ||
static cloneFeature(feature) { | ||
return { | ||
id: feature.id, | ||
name: feature.name, | ||
description: feature.description, | ||
...(feature.descriptionLegal ? { descriptionLegal: feature.descriptionLegal } : {}), | ||
...(feature.illustrations ? { illustrations: Array.from(feature.illustrations) } : {}), | ||
}; | ||
} | ||
static cloneDataCategory(dataCategory) { | ||
return { | ||
id: dataCategory.id, | ||
name: dataCategory.name, | ||
description: dataCategory.description, | ||
}; | ||
} | ||
static cloneStack(stack) { | ||
return { | ||
id: stack.id, | ||
name: stack.name, | ||
description: stack.description, | ||
purposes: Array.from(stack.purposes), | ||
specialFeatures: Array.from(stack.specialFeatures), | ||
}; | ||
} | ||
static cloneDataRetention(dataRetention) { | ||
return { | ||
...(typeof dataRetention.stdRetention === 'number' ? { stdRetention: dataRetention.stdRetention } : {}), | ||
purposes: { ...dataRetention.purposes }, | ||
specialPurposes: { ...dataRetention.specialPurposes }, | ||
}; | ||
} | ||
static cloneVendorUrls(urls) { | ||
return urls.map((url) => ({ | ||
langId: url.langId, | ||
privacy: url.privacy, | ||
...(url.legIntClaim ? { legIntClaim: url.legIntClaim } : {}), | ||
})); | ||
} | ||
static cloneVendor(vendor) { | ||
return { | ||
id: vendor.id, | ||
name: vendor.name, | ||
purposes: Array.from(vendor.purposes), | ||
legIntPurposes: Array.from(vendor.legIntPurposes), | ||
flexiblePurposes: Array.from(vendor.flexiblePurposes), | ||
specialPurposes: Array.from(vendor.specialPurposes), | ||
features: Array.from(vendor.features), | ||
specialFeatures: Array.from(vendor.specialFeatures), | ||
...(vendor.overflow ? { overflow: { httpGetLimit: vendor.overflow.httpGetLimit } } : {}), | ||
...(typeof vendor.cookieMaxAgeSeconds === 'number' || vendor.cookieMaxAgeSeconds === null ? { cookieMaxAgeSeconds: vendor.cookieMaxAgeSeconds } : {}), | ||
...(vendor.usesCookies !== undefined ? { usesCookies: vendor.usesCookies } : {}), | ||
...(vendor.policyUrl ? { policyUrl: vendor.policyUrl } : {}), | ||
...(vendor.cookieRefresh !== undefined ? { cookieRefresh: vendor.cookieRefresh } : {}), | ||
...(vendor.usesNonCookieAccess !== undefined ? { usesNonCookieAccess: vendor.usesNonCookieAccess } : {}), | ||
...(vendor.dataRetention ? { dataRetention: this.cloneDataRetention(vendor.dataRetention) } : {}), | ||
...(vendor.urls ? { urls: this.cloneVendorUrls(vendor.urls) } : {}), | ||
...(vendor.dataDeclaration ? { dataDeclaration: Array.from(vendor.dataDeclaration) } : {}), | ||
...(vendor.deviceStorageDisclosureUrl ? { deviceStorageDisclosureUrl: vendor.deviceStorageDisclosureUrl } : {}), | ||
...(vendor.deletedDate ? { deletedDate: vendor.deletedDate } : {}), | ||
}; | ||
} | ||
cloneVendors() { | ||
const vendors = {}; | ||
for (const vendorId of Object.keys(this.fullVendorList)) { | ||
vendors[vendorId] = GVL.cloneVendor(this.fullVendorList[vendorId]); | ||
} | ||
return vendors; | ||
} | ||
/** | ||
@@ -372,2 +498,3 @@ * changeLanguage - retrieves the purpose language translation and sets the | ||
this.stacks = gvlObject.stacks; | ||
this.dataCategories = gvlObject.dataCategories; | ||
if (this.isVendorList(gvlObject)) { | ||
@@ -374,0 +501,0 @@ this.gvlSpecificationVersion = gvlObject.gvlSpecificationVersion; |
@@ -5,2 +5,3 @@ import { IntMap } from '../IntMap.js'; | ||
import { Stack } from './Stack.js'; | ||
import { DataCategory } from './DataCategory.js'; | ||
export interface Declarations { | ||
@@ -12,2 +13,3 @@ purposes: IntMap<Purpose>; | ||
stacks: IntMap<Stack>; | ||
dataCategories?: IntMap<DataCategory>; | ||
} |
import { GVLMapItem } from './GVLMapItem.js'; | ||
export interface Feature extends GVLMapItem { | ||
description: string; | ||
descriptionLegal: string; | ||
descriptionLegal?: string; | ||
illustrations?: string[]; | ||
} |
@@ -10,1 +10,2 @@ export * from './ByPurposeVendorMap.js'; | ||
export * from './VendorList.js'; | ||
export * from './DataCategory.js'; |
@@ -11,1 +11,2 @@ // created from 'create-ts-index' | ||
export * from './VendorList.js'; | ||
export * from './DataCategory.js'; |
import { GVLMapItem } from './GVLMapItem.js'; | ||
export interface Purpose extends GVLMapItem { | ||
description: string; | ||
descriptionLegal: string; | ||
descriptionLegal?: string; | ||
illustrations?: string[]; | ||
} |
import { GVLMapItem } from './GVLMapItem.js'; | ||
import { DataRetention } from './DataRetention.js'; | ||
import { VendorUrl } from './VendorUrl.js'; | ||
export interface Vendor extends GVLMapItem { | ||
@@ -9,3 +11,3 @@ purposes: number[]; | ||
specialFeatures: number[]; | ||
policyUrl: string; | ||
policyUrl?: string; | ||
usesCookies: boolean; | ||
@@ -20,2 +22,5 @@ cookieMaxAgeSeconds: number | null; | ||
}; | ||
dataRetention?: DataRetention; | ||
urls?: VendorUrl[]; | ||
dataDeclaration?: number[]; | ||
} |
@@ -17,3 +17,3 @@ import { Cloneable } from './Cloneable.js'; | ||
consentScreen_ = 0; | ||
policyVersion_ = 4; | ||
policyVersion_ = 5; | ||
consentLanguage_ = 'EN'; | ||
@@ -20,0 +20,0 @@ cmpId_ = 0; |
{ | ||
"name": "@didomi/iabtcf-core", | ||
"version": "1.6.1", | ||
"version": "1.6.2", | ||
"description": "Ensures consistent encoding and decoding of TC Signals for the iab. Transparency and Consent Framework (TCF).", | ||
@@ -31,3 +31,3 @@ "author": "Chris Paterson <tcf@chrispaterson.io>", | ||
"devDependencies": { | ||
"@didomi/iabtcf-testing": "1.5.6", | ||
"@didomi/iabtcf-testing": "1.6.1", | ||
"@istanbuljs/nyc-config-typescript": "^0.1.3", | ||
@@ -34,0 +34,0 @@ "@types/sinon": "^10.0.11", |
324223
233
5895