@iabtechlabtcf/core
Advanced tools
Comparing version 1.5.9 to 1.5.10
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.PurposeRestrictionVectorEncoder=void 0;var BitLength_js_1=require("../BitLength.js"),BooleanEncoder_js_1=require("./BooleanEncoder.js"),index_js_1=require("../../errors/index.js"),IntEncoder_js_1=require("./IntEncoder.js"),index_js_2=require("../../model/index.js"),PurposeRestrictionVectorEncoder=function(){function e(){}return e.encode=function(e){var n=IntEncoder_js_1.IntEncoder.encode(e.numRestrictions,BitLength_js_1.BitLength.numRestrictions);if(!e.isEmpty()){var t=Array.from(e.gvl.vendorIds),r=function(e,n){var r=t.indexOf(e);return t.indexOf(n)-r>1};e.getRestrictions().forEach((function(t){n+=IntEncoder_js_1.IntEncoder.encode(t.purposeId,BitLength_js_1.BitLength.purposeId),n+=IntEncoder_js_1.IntEncoder.encode(t.restrictionType,BitLength_js_1.BitLength.restrictionType);for(var o=e.getVendors(t),i=o.length,s=0,d=0,_="",c=0;c<i;c++){var g=o[c];if(0===d&&(s++,d=g),c===i-1||r(g,o[c+1])){var B=!(g===d);_+=BooleanEncoder_js_1.BooleanEncoder.encode(B),_+=IntEncoder_js_1.IntEncoder.encode(d,BitLength_js_1.BitLength.vendorId),B&&(_+=IntEncoder_js_1.IntEncoder.encode(g,BitLength_js_1.BitLength.vendorId)),d=0}}n+=IntEncoder_js_1.IntEncoder.encode(s,BitLength_js_1.BitLength.numEntries),n+=_}))}return n},e.decode=function(e){var n=0,t=new index_js_2.PurposeRestrictionVector,r=IntEncoder_js_1.IntEncoder.decode(e.substr(n,BitLength_js_1.BitLength.numRestrictions),BitLength_js_1.BitLength.numRestrictions);n+=BitLength_js_1.BitLength.numRestrictions;for(var o=0;o<r;o++){var i=IntEncoder_js_1.IntEncoder.decode(e.substr(n,BitLength_js_1.BitLength.purposeId),BitLength_js_1.BitLength.purposeId);n+=BitLength_js_1.BitLength.purposeId;var s=IntEncoder_js_1.IntEncoder.decode(e.substr(n,BitLength_js_1.BitLength.restrictionType),BitLength_js_1.BitLength.restrictionType);n+=BitLength_js_1.BitLength.restrictionType;var d=new index_js_2.PurposeRestriction(i,s),_=IntEncoder_js_1.IntEncoder.decode(e.substr(n,BitLength_js_1.BitLength.numEntries),BitLength_js_1.BitLength.numEntries);n+=BitLength_js_1.BitLength.numEntries;for(var c=function(r){var o=BooleanEncoder_js_1.BooleanEncoder.decode(e.substr(n,BitLength_js_1.BitLength.anyBoolean));n+=BitLength_js_1.BitLength.anyBoolean;var i=IntEncoder_js_1.IntEncoder.decode(e.substr(n,BitLength_js_1.BitLength.vendorId),BitLength_js_1.BitLength.vendorId);if(n+=BitLength_js_1.BitLength.vendorId,o){var s=IntEncoder_js_1.IntEncoder.decode(e.substr(n,BitLength_js_1.BitLength.vendorId),BitLength_js_1.BitLength.vendorId);if(n+=BitLength_js_1.BitLength.vendorId,s<i)throw new index_js_1.DecodingError("Invalid RangeEntry: endVendorId ".concat(s," is less than ").concat(i));var _=Array.from({length:s-i+1},(function(e,n){return i+n}));t.restrictPurposeToLegalBasis(d,_)}else t.restrictPurposeToLegalBasis(d,[i])},g=0;g<_;g++)c()}return t.bitLength=n,t},e}();exports.PurposeRestrictionVectorEncoder=PurposeRestrictionVectorEncoder; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.PurposeRestrictionVectorEncoder=void 0;var BitLength_js_1=require("../BitLength.js"),BooleanEncoder_js_1=require("./BooleanEncoder.js"),index_js_1=require("../../errors/index.js"),IntEncoder_js_1=require("./IntEncoder.js"),index_js_2=require("../../model/index.js"),PurposeRestrictionVectorEncoder=function(){function e(){}return e.encode=function(e){var n=IntEncoder_js_1.IntEncoder.encode(e.numRestrictions,BitLength_js_1.BitLength.numRestrictions);if(!e.isEmpty()){var t=function(n,t){for(var r=n+1;r<=t;r++)if(e.gvl.vendorIds.has(r))return r;return n};e.getRestrictions().forEach((function(r){n+=IntEncoder_js_1.IntEncoder.encode(r.purposeId,BitLength_js_1.BitLength.purposeId),n+=IntEncoder_js_1.IntEncoder.encode(r.restrictionType,BitLength_js_1.BitLength.restrictionType);for(var o=e.getVendors(r),i=o.length,s=0,d=0,_="",c=0;c<i;c++){var B=o[c];if(0===d&&(s++,d=B),c===i-1||o[c+1]>t(B,o[i-1])){var g=!(B===d);_+=BooleanEncoder_js_1.BooleanEncoder.encode(g),_+=IntEncoder_js_1.IntEncoder.encode(d,BitLength_js_1.BitLength.vendorId),g&&(_+=IntEncoder_js_1.IntEncoder.encode(B,BitLength_js_1.BitLength.vendorId)),d=0}}n+=IntEncoder_js_1.IntEncoder.encode(s,BitLength_js_1.BitLength.numEntries),n+=_}))}return n},e.decode=function(e){var n=0,t=new index_js_2.PurposeRestrictionVector,r=IntEncoder_js_1.IntEncoder.decode(e.substr(n,BitLength_js_1.BitLength.numRestrictions),BitLength_js_1.BitLength.numRestrictions);n+=BitLength_js_1.BitLength.numRestrictions;for(var o=0;o<r;o++){var i=IntEncoder_js_1.IntEncoder.decode(e.substr(n,BitLength_js_1.BitLength.purposeId),BitLength_js_1.BitLength.purposeId);n+=BitLength_js_1.BitLength.purposeId;var s=IntEncoder_js_1.IntEncoder.decode(e.substr(n,BitLength_js_1.BitLength.restrictionType),BitLength_js_1.BitLength.restrictionType);n+=BitLength_js_1.BitLength.restrictionType;var d=new index_js_2.PurposeRestriction(i,s),_=IntEncoder_js_1.IntEncoder.decode(e.substr(n,BitLength_js_1.BitLength.numEntries),BitLength_js_1.BitLength.numEntries);n+=BitLength_js_1.BitLength.numEntries;for(var c=0;c<_;c++){var B=BooleanEncoder_js_1.BooleanEncoder.decode(e.substr(n,BitLength_js_1.BitLength.anyBoolean));n+=BitLength_js_1.BitLength.anyBoolean;var g=IntEncoder_js_1.IntEncoder.decode(e.substr(n,BitLength_js_1.BitLength.vendorId),BitLength_js_1.BitLength.vendorId);if(n+=BitLength_js_1.BitLength.vendorId,B){var h=IntEncoder_js_1.IntEncoder.decode(e.substr(n,BitLength_js_1.BitLength.vendorId),BitLength_js_1.BitLength.vendorId);if(n+=BitLength_js_1.BitLength.vendorId,h<g)throw new index_js_1.DecodingError("Invalid RangeEntry: endVendorId ".concat(h," is less than ").concat(g));for(var L=g;L<=h;L++)t.add(L,d)}else t.add(g,d)}}return t.bitLength=n,t},e}();exports.PurposeRestrictionVectorEncoder=PurposeRestrictionVectorEncoder; |
@@ -31,6 +31,5 @@ import { PurposeRestriction } from './PurposeRestriction.js'; | ||
* @param {PurposeRestriction} purposeRestriction | ||
* @param {number[]|null|undefined} vendorsIds | ||
* @return {void} | ||
*/ | ||
restrictPurposeToLegalBasis(purposeRestriction: PurposeRestriction, vendorsIds?: number[]): void; | ||
restrictPurposeToLegalBasis(purposeRestriction: PurposeRestriction): void; | ||
/** | ||
@@ -37,0 +36,0 @@ * getVendors - returns array of vendor ids optionally narrowed by a given |
@@ -1,1 +0,1 @@ | ||
"use strict";var __extends=this&&this.__extends||function(){var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(e,r)};return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function o(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(o.prototype=r.prototype,new o)}}(),__values=this&&this.__values||function(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],o=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&o>=t.length&&(t=void 0),{value:t&&t[o++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(exports,"__esModule",{value:!0}),exports.PurposeRestrictionVector=void 0;var PurposeRestriction_js_1=require("./PurposeRestriction.js"),RestrictionType_js_1=require("./RestrictionType.js"),Cloneable_js_1=require("../Cloneable.js"),PurposeRestrictionVector=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.bitLength=0,e.map=new Map,e}return __extends(e,t),e.prototype.has=function(t){return this.map.has(t)},e.prototype.isOkToHave=function(t,e,r){var o,i=!0;if(null===(o=this.gvl)||void 0===o?void 0:o.vendors){var n=this.gvl.vendors[r];if(n)if(t===RestrictionType_js_1.RestrictionType.NOT_ALLOWED)i=n.legIntPurposes.includes(e)||n.purposes.includes(e);else if(n.flexiblePurposes.length)switch(t){case RestrictionType_js_1.RestrictionType.REQUIRE_CONSENT:i=n.flexiblePurposes.includes(e)&&n.legIntPurposes.includes(e);break;case RestrictionType_js_1.RestrictionType.REQUIRE_LI:i=n.flexiblePurposes.includes(e)&&n.purposes.includes(e)}else i=!1;else i=!1}return i},e.prototype.add=function(t,e){if(this.isOkToHave(e.restrictionType,e.purposeId,t)){var r=e.hash;this.has(r)||(this.map.set(r,new Set),this.bitLength=0),this.map.get(r).add(t)}},e.prototype.restrictPurposeToLegalBasis=function(t,e){var r,o;void 0===e&&(e=Array.from(this.gvl.vendorIds));var i=t.hash;if(this.has(i)){var n=this.map.get(i);try{for(var s=__values(e),a=s.next();!a.done;a=s.next()){var u=a.value;n.add(u)}}catch(t){r={error:t}}finally{try{a&&!a.done&&(o=s.return)&&o.call(s)}finally{if(r)throw r.error}}}else this.map.set(i,new Set(e)),this.bitLength=0},e.prototype.getVendors=function(t){var e=[];if(t){var r=t.hash;this.has(r)&&(e=Array.from(this.map.get(r)))}else{var o=new Set;this.map.forEach((function(t){Array.from(t).forEach((function(t){o.add(t)}))})),e=Array.from(o)}return e.sort((function(t,e){return t-e}))},e.prototype.getRestrictionType=function(t,e){var r;return this.getRestrictions(t).forEach((function(t){t.purposeId===e&&(void 0===r||r>t.restrictionType)&&(r=t.restrictionType)})),r},e.prototype.vendorHasRestriction=function(t,e){for(var r=!1,o=this.getRestrictions(t),i=0;i<o.length&&!r;i++)r=e.isSameAs(o[i]);return r},e.prototype.getMaxVendorId=function(){var t=0;return this.map.forEach((function(e){var r=Array.from(e);t=Math.max(r[r.length-1],t)})),t},e.prototype.getRestrictions=function(t){var e=[];return this.map.forEach((function(r,o){t?r.has(t)&&e.push(PurposeRestriction_js_1.PurposeRestriction.unHash(o)):e.push(PurposeRestriction_js_1.PurposeRestriction.unHash(o))})),e},e.prototype.getPurposes=function(){var t=new Set;return this.map.forEach((function(e,r){t.add(PurposeRestriction_js_1.PurposeRestriction.unHash(r).purposeId)})),Array.from(t)},e.prototype.remove=function(t,e){var r=e.hash,o=this.map.get(r);o&&(o.delete(t),0==o.size&&(this.map.delete(r),this.bitLength=0))},Object.defineProperty(e.prototype,"gvl",{get:function(){return this.gvl_},set:function(t){var e=this;this.gvl_||(this.gvl_=t,this.map.forEach((function(t,r){var o=PurposeRestriction_js_1.PurposeRestriction.unHash(r);Array.from(t).forEach((function(r){e.isOkToHave(o.restrictionType,o.purposeId,r)||t.delete(r)}))})))},enumerable:!1,configurable:!0}),e.prototype.isEmpty=function(){return 0===this.map.size},Object.defineProperty(e.prototype,"numRestrictions",{get:function(){return this.map.size},enumerable:!1,configurable:!0}),e}(Cloneable_js_1.Cloneable);exports.PurposeRestrictionVector=PurposeRestrictionVector; | ||
"use strict";var __extends=this&&this.__extends||function(){var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(e,r)};return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function o(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(o.prototype=r.prototype,new o)}}(),__read=this&&this.__read||function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var o,s,i=r.call(t),n=[];try{for(;(void 0===e||e-- >0)&&!(o=i.next()).done;)n.push(o.value)}catch(t){s={error:t}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(s)throw s.error}}return n},__spreadArray=this&&this.__spreadArray||function(t,e,r){if(r||2===arguments.length)for(var o,s=0,i=e.length;s<i;s++)!o&&s in e||(o||(o=Array.prototype.slice.call(e,0,s)),o[s]=e[s]);return t.concat(o||Array.prototype.slice.call(e))};Object.defineProperty(exports,"__esModule",{value:!0}),exports.PurposeRestrictionVector=void 0;var PurposeRestriction_js_1=require("./PurposeRestriction.js"),RestrictionType_js_1=require("./RestrictionType.js"),Cloneable_js_1=require("../Cloneable.js"),PurposeRestrictionVector=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.bitLength=0,e.map=new Map,e}return __extends(e,t),e.prototype.has=function(t){return this.map.has(t)},e.prototype.isOkToHave=function(t,e,r){var o,s=!0;if(null===(o=this.gvl)||void 0===o?void 0:o.vendors){var i=this.gvl.vendors[r];if(i)if(t===RestrictionType_js_1.RestrictionType.NOT_ALLOWED)s=i.legIntPurposes.includes(e)||i.purposes.includes(e);else if(i.flexiblePurposes.length)switch(t){case RestrictionType_js_1.RestrictionType.REQUIRE_CONSENT:s=i.flexiblePurposes.includes(e)&&i.legIntPurposes.includes(e);break;case RestrictionType_js_1.RestrictionType.REQUIRE_LI:s=i.flexiblePurposes.includes(e)&&i.purposes.includes(e)}else s=!1;else s=!1}return s},e.prototype.add=function(t,e){if(this.isOkToHave(e.restrictionType,e.purposeId,t)){var r=e.hash;this.has(r)||(this.map.set(r,new Set),this.bitLength=0),this.map.get(r).add(t)}},e.prototype.restrictPurposeToLegalBasis=function(t){var e=Array.from(this.gvl.vendorIds),r=t.hash,o=e[e.length-1],s=__spreadArray([],__read(Array(o).keys()),!1).map((function(t){return t+1}));if(this.has(r))for(var i=1;i<=o;i++)this.map.get(r).add(i);else this.map.set(r,new Set(s)),this.bitLength=0},e.prototype.getVendors=function(t){var e=[];if(t){var r=t.hash;this.has(r)&&(e=Array.from(this.map.get(r)))}else{var o=new Set;this.map.forEach((function(t){t.forEach((function(t){o.add(t)}))})),e=Array.from(o)}return e.sort((function(t,e){return t-e}))},e.prototype.getRestrictionType=function(t,e){var r;return this.getRestrictions(t).forEach((function(t){t.purposeId===e&&(void 0===r||r>t.restrictionType)&&(r=t.restrictionType)})),r},e.prototype.vendorHasRestriction=function(t,e){for(var r=!1,o=this.getRestrictions(t),s=0;s<o.length&&!r;s++)r=e.isSameAs(o[s]);return r},e.prototype.getMaxVendorId=function(){var t=0;return this.map.forEach((function(e){t=Math.max(Array.from(e)[e.size-1],t)})),t},e.prototype.getRestrictions=function(t){var e=[];return this.map.forEach((function(r,o){t?r.has(t)&&e.push(PurposeRestriction_js_1.PurposeRestriction.unHash(o)):e.push(PurposeRestriction_js_1.PurposeRestriction.unHash(o))})),e},e.prototype.getPurposes=function(){var t=new Set;return this.map.forEach((function(e,r){t.add(PurposeRestriction_js_1.PurposeRestriction.unHash(r).purposeId)})),Array.from(t)},e.prototype.remove=function(t,e){var r=e.hash,o=this.map.get(r);o&&(o.delete(t),0==o.size&&(this.map.delete(r),this.bitLength=0))},Object.defineProperty(e.prototype,"gvl",{get:function(){return this.gvl_},set:function(t){var e=this;this.gvl_||(this.gvl_=t,this.map.forEach((function(t,r){var o=PurposeRestriction_js_1.PurposeRestriction.unHash(r);Array.from(t).forEach((function(r){e.isOkToHave(o.restrictionType,o.purposeId,r)||t.delete(r)}))})))},enumerable:!1,configurable:!0}),e.prototype.isEmpty=function(){return 0===this.map.size},Object.defineProperty(e.prototype,"numRestrictions",{get:function(){return this.map.size},enumerable:!1,configurable:!0}),e}(Cloneable_js_1.Cloneable);exports.PurposeRestrictionVector=PurposeRestrictionVector; |
@@ -12,8 +12,9 @@ import { BitLength } from '../BitLength.js'; | ||
if (!prVector.isEmpty()) { | ||
const gvlVendorIds = Array.from(prVector.gvl.vendorIds); | ||
const gvlHasVendorBetween = (vendorId, nextVendorId) => { | ||
const firstIndex = gvlVendorIds.indexOf(vendorId); | ||
const nextIndex = gvlVendorIds.indexOf(nextVendorId); | ||
const res = nextIndex - firstIndex; | ||
return res > 1; | ||
const nextGvlVendor = (vendorId, lastVendorId) => { | ||
for (let nextId = vendorId + 1; nextId <= lastVendorId; nextId++) { | ||
if (prVector.gvl.vendorIds.has(nextId)) { | ||
return nextId; | ||
} | ||
} | ||
return vendorId; | ||
}; | ||
@@ -44,3 +45,3 @@ // create each restriction group | ||
*/ | ||
if (i === len - 1 || gvlHasVendorBetween(vendorId, vendors[i + 1])) { | ||
if (i === len - 1 || vendors[i + 1] > nextGvlVendor(vendorId, vendors[len - 1])) { | ||
/** | ||
@@ -98,8 +99,8 @@ * it's a range entry if we've got something other than the start | ||
} | ||
// required to preserve the default behavior (includes also vendors ids that doesn't exist) | ||
const vendorIds = Array.from({ length: endVendorId - startOrOnlyVendorId + 1 }, (_, index) => startOrOnlyVendorId + index); | ||
vector.restrictPurposeToLegalBasis(purposeRestriction, vendorIds); | ||
for (let k = startOrOnlyVendorId; k <= endVendorId; k++) { | ||
vector.add(k, purposeRestriction); | ||
} | ||
} | ||
else { | ||
vector.restrictPurposeToLegalBasis(purposeRestriction, [startOrOnlyVendorId]); | ||
vector.add(startOrOnlyVendorId, purposeRestriction); | ||
} | ||
@@ -106,0 +107,0 @@ } |
@@ -31,6 +31,5 @@ import { PurposeRestriction } from './PurposeRestriction.js'; | ||
* @param {PurposeRestriction} purposeRestriction | ||
* @param {number[]|null|undefined} vendorsIds | ||
* @return {void} | ||
*/ | ||
restrictPurposeToLegalBasis(purposeRestriction: PurposeRestriction, vendorsIds?: number[]): void; | ||
restrictPurposeToLegalBasis(purposeRestriction: PurposeRestriction): void; | ||
/** | ||
@@ -37,0 +36,0 @@ * getVendors - returns array of vendor ids optionally narrowed by a given |
@@ -41,6 +41,6 @@ import { PurposeRestriction } from './PurposeRestriction.js'; | ||
/** | ||
* If the vendor has the purposeId in flexiblePurposes and it is | ||
* listed as a legitimate interest purpose we can set the | ||
* override to require consent. | ||
*/ | ||
* If the vendor has the purposeId in flexiblePurposes and it is | ||
* listed as a legitimate interest purpose we can set the | ||
* override to require consent. | ||
*/ | ||
case RestrictionType.REQUIRE_CONSENT: | ||
@@ -97,14 +97,18 @@ result = (vendor.flexiblePurposes.includes(purposeId) && vendor.legIntPurposes.includes(purposeId)); | ||
* @param {PurposeRestriction} purposeRestriction | ||
* @param {number[]|null|undefined} vendorsIds | ||
* @return {void} | ||
*/ | ||
restrictPurposeToLegalBasis(purposeRestriction, vendorsIds = Array.from(this.gvl.vendorIds)) { | ||
restrictPurposeToLegalBasis(purposeRestriction) { | ||
const vendors = Array.from(this.gvl.vendorIds); | ||
const hash = purposeRestriction.hash; | ||
const lastEntry = vendors[vendors.length - 1]; | ||
/** | ||
* Create an ordered array of vendor IDs from `1` (the minimum value for Vendor ID) to `lastEntry` | ||
*/ | ||
const values = [...Array(lastEntry).keys()].map((i) => i + 1); | ||
if (!this.has(hash)) { | ||
this.map.set(hash, new Set(vendorsIds)); | ||
this.map.set(hash, new Set(values)); // use static method `build` to create a `BST` from the ordered array of IDs | ||
this.bitLength = 0; | ||
} | ||
else { | ||
const currentMap = this.map.get(hash); | ||
for (const vendorId of vendorsIds) { | ||
for (let i = 1; i <= lastEntry; i++) { | ||
/** | ||
@@ -115,3 +119,3 @@ * Previously I had a check here to remove a duplicate value, but because | ||
*/ | ||
currentMap.add(vendorId); | ||
this.map.get(hash).add(i); | ||
} | ||
@@ -140,4 +144,4 @@ } | ||
const vendorSet = new Set(); | ||
this.map.forEach((vendorIds) => { | ||
Array.from(vendorIds).forEach((vendorId) => { | ||
this.map.forEach((set) => { | ||
set.forEach((vendorId) => { | ||
vendorSet.add(vendorId); | ||
@@ -185,26 +189,25 @@ }); | ||
getMaxVendorId() { | ||
let result = 0; | ||
this.map.forEach((purposeRestrictionVendorIds) => { | ||
const vendorIds = Array.from(purposeRestrictionVendorIds); | ||
result = Math.max(vendorIds[vendorIds.length - 1], result); | ||
let retr = 0; | ||
this.map.forEach((set) => { | ||
retr = Math.max(Array.from(set)[set.size - 1], retr); | ||
}); | ||
return result; | ||
return retr; | ||
} | ||
getRestrictions(vendorId) { | ||
const result = []; | ||
this.map.forEach((vendorIds, hash) => { | ||
const retr = []; | ||
this.map.forEach((set, hash) => { | ||
if (vendorId) { | ||
if (vendorIds.has(vendorId)) { | ||
result.push(PurposeRestriction.unHash(hash)); | ||
if (set.has(vendorId)) { | ||
retr.push(PurposeRestriction.unHash(hash)); | ||
} | ||
} | ||
else { | ||
result.push(PurposeRestriction.unHash(hash)); | ||
retr.push(PurposeRestriction.unHash(hash)); | ||
} | ||
}); | ||
return result; | ||
return retr; | ||
} | ||
getPurposes() { | ||
const purposeIds = new Set(); | ||
this.map.forEach((vendorIds, hash) => { | ||
this.map.forEach((set, hash) => { | ||
purposeIds.add(PurposeRestriction.unHash(hash).purposeId); | ||
@@ -223,7 +226,7 @@ }); | ||
const hash = purposeRestriction.hash; | ||
const vendorIds = this.map.get(hash); | ||
if (vendorIds) { | ||
vendorIds.delete(vendorId); | ||
const set = this.map.get(hash); | ||
if (set) { | ||
set.delete(vendorId); | ||
// if it's empty let's delete the key so it doesn't show up empty | ||
if (vendorIds.size == 0) { | ||
if (set.size == 0) { | ||
this.map.delete(hash); | ||
@@ -247,8 +250,8 @@ this.bitLength = 0; | ||
*/ | ||
this.map.forEach((vendorIds, hash) => { | ||
this.map.forEach((set, hash) => { | ||
const purposeRestriction = PurposeRestriction.unHash(hash); | ||
const vendors = Array.from(vendorIds); | ||
const vendors = Array.from(set); | ||
vendors.forEach((vendorId) => { | ||
if (!this.isOkToHave(purposeRestriction.restrictionType, purposeRestriction.purposeId, vendorId)) { | ||
vendorIds.delete(vendorId); | ||
set.delete(vendorId); | ||
} | ||
@@ -255,0 +258,0 @@ }); |
{ | ||
"name": "@iabtechlabtcf/core", | ||
"version": "1.5.9", | ||
"version": "1.5.10", | ||
"description": "Ensures consistent encoding and decoding of TC Signals for the iab. Transparency and Consent Framework (TCF).", | ||
@@ -28,6 +28,7 @@ "author": "Mayank Mishra <mayank@iabtechlab.com>", | ||
"test": "mocha", | ||
"test-cov": "rm -rf coverage; nyc --reporter=html mocha" | ||
"test-cov": "rm -rf coverage; nyc --reporter=html mocha", | ||
"test-ci": "mocha --reporter mocha-junit-reporter" | ||
}, | ||
"devDependencies": { | ||
"@iabtechlabtcf/testing": "1.5.9", | ||
"@iabtechlabtcf/testing": "1.5.10", | ||
"@istanbuljs/nyc-config-typescript": "^0.1.3", | ||
@@ -34,0 +35,0 @@ "@types/sinon": "^10.0.11", |
[![NPM version](https://img.shields.io/npm/v/@iabtechlabtcf/core.svg?style=flat-square)](https://www.npmjs.com/package/@iabtechlabtcf/core) | ||
[![npm module downloads per month](http://img.shields.io/npm/dm/@iabtechlabtcf/core.svg?style=flat)](https://www.npmjs.org/package/@iabtechlabtcf/core) | ||
[![InteractiveAdvertisingBureau](https://circleci.com/gh/InteractiveAdvertisingBureau/iabtechlabtcf-es.svg?style=shield)](https://circleci.com/gh/InteractiveAdvertisingBureau/iabtechlabtcf-es) | ||
[![InteractiveAdvertisingBureau](https://circleci.com/gh/InteractiveAdvertisingBureau/iabtcf-es.svg?style=shield)](https://circleci.com/gh/InteractiveAdvertisingBureau/iabtcf-es) | ||
@@ -5,0 +5,0 @@ # @iabtechlabtcf/core |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5758
313985