didomi-iabtcf-core
Advanced tools
Comparing version 1.1.0-2 to 1.1.4-1
import { Vector } from '../../model'; | ||
export declare class VendorVectorEncoder { | ||
static encode(value: Vector): string; | ||
static decode(value: string): Vector; | ||
static decode(value: string, version?: number): Vector; | ||
private static buildRangeEncoding; | ||
} |
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var model_1=require("../../model"),__1=require("../"),IntEncoder_1=require("./IntEncoder"),BooleanEncoder_1=require("./BooleanEncoder"),FixedVectorEncoder_1=require("./FixedVectorEncoder"),VectorEncodingType_1=require("./VectorEncodingType"),VendorVectorEncoder=function(){function e(){}return e.encode=function(e){var n,t=[],o=[],r=IntEncoder_1.IntEncoder.encode(e.maxId,__1.BitLength.maxId),d="",c=__1.BitLength.maxId+__1.BitLength.encodingType,_=c+e.maxId,i=2*__1.BitLength.vendorId+__1.BitLength.singleOrRange+__1.BitLength.numEntries,E=c+__1.BitLength.numEntries;return e.forEach((function(r,c){(d+=BooleanEncoder_1.BooleanEncoder.encode(r),(n=e.maxId>i&&E<_)&&r)&&(e.has(c+1)?0===o.length&&(o.push(c),E+=__1.BitLength.singleOrRange,E+=__1.BitLength.vendorId):(o.push(c),E+=__1.BitLength.vendorId,t.push(o),o=[]))})),n?(r+=VectorEncodingType_1.VectorEncodingType.RANGE+"",r+=this.buildRangeEncoding(t)):(r+=VectorEncodingType_1.VectorEncodingType.FIELD+"",r+=d),r},e.decode=function(e){var n,t=0,o=IntEncoder_1.IntEncoder.decode(e.substr(t,__1.BitLength.maxId),__1.BitLength.maxId);t+=__1.BitLength.maxId;var r=IntEncoder_1.IntEncoder.decode(e.charAt(t),__1.BitLength.encodingType);if(t+=__1.BitLength.encodingType,r===VectorEncodingType_1.VectorEncodingType.RANGE){n=new model_1.Vector;var d=IntEncoder_1.IntEncoder.decode(e.substr(t,__1.BitLength.numEntries),__1.BitLength.numEntries);t+=__1.BitLength.numEntries;for(var c=0;c<d;c++){var _=BooleanEncoder_1.BooleanEncoder.decode(e.charAt(t));t+=__1.BitLength.singleOrRange;var i=IntEncoder_1.IntEncoder.decode(e.substr(t,__1.BitLength.vendorId),__1.BitLength.vendorId);if(t+=__1.BitLength.vendorId,_){var E=IntEncoder_1.IntEncoder.decode(e.substr(t,__1.BitLength.vendorId),__1.BitLength.vendorId);t+=__1.BitLength.vendorId;for(var g=i;g<=E;g++)n.set(g)}else n.set(i)}}else{var h=e.substr(t,o);t+=o,n=FixedVectorEncoder_1.FixedVectorEncoder.decode(h,o)}return n.bitLength=t,n},e.buildRangeEncoding=function(e){var n=e.length,t=IntEncoder_1.IntEncoder.encode(n,__1.BitLength.numEntries);return e.forEach((function(e){var n=1===e.length;t+=BooleanEncoder_1.BooleanEncoder.encode(!n),t+=IntEncoder_1.IntEncoder.encode(e[0],__1.BitLength.vendorId),n||(t+=IntEncoder_1.IntEncoder.encode(e[1],__1.BitLength.vendorId))})),t},e}();exports.VendorVectorEncoder=VendorVectorEncoder; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var model_1=require("../../model"),__1=require("../"),IntEncoder_1=require("./IntEncoder"),BooleanEncoder_1=require("./BooleanEncoder"),FixedVectorEncoder_1=require("./FixedVectorEncoder"),VectorEncodingType_1=require("./VectorEncodingType"),errors_1=require("../../errors"),VendorVectorEncoder=function(){function e(){}return e.encode=function(e){var n,r=[],o=[],t=IntEncoder_1.IntEncoder.encode(e.maxId,__1.BitLength.maxId),d="",c=__1.BitLength.maxId+__1.BitLength.encodingType,_=c+e.maxId,i=2*__1.BitLength.vendorId+__1.BitLength.singleOrRange+__1.BitLength.numEntries,E=c+__1.BitLength.numEntries;return e.forEach((function(t,c){(d+=BooleanEncoder_1.BooleanEncoder.encode(t),(n=e.maxId>i&&E<_)&&t)&&(e.has(c+1)?0===o.length&&(o.push(c),E+=__1.BitLength.singleOrRange,E+=__1.BitLength.vendorId):(o.push(c),E+=__1.BitLength.vendorId,r.push(o),o=[]))})),n?(t+=VectorEncodingType_1.VectorEncodingType.RANGE+"",t+=this.buildRangeEncoding(r)):(t+=VectorEncodingType_1.VectorEncodingType.FIELD+"",t+=d),t},e.decode=function(e,n){var r,o=0,t=IntEncoder_1.IntEncoder.decode(e.substr(o,__1.BitLength.maxId),__1.BitLength.maxId);o+=__1.BitLength.maxId;var d=IntEncoder_1.IntEncoder.decode(e.charAt(o),__1.BitLength.encodingType);if(o+=__1.BitLength.encodingType,d===VectorEncodingType_1.VectorEncodingType.RANGE){if(r=new model_1.Vector,1===n){if("1"===e.substr(o,1))throw new errors_1.DecodingError("Unable to decode default consent=1");o++}var c=IntEncoder_1.IntEncoder.decode(e.substr(o,__1.BitLength.numEntries),__1.BitLength.numEntries);o+=__1.BitLength.numEntries;for(var _=0;_<c;_++){var i=BooleanEncoder_1.BooleanEncoder.decode(e.charAt(o));o+=__1.BitLength.singleOrRange;var E=IntEncoder_1.IntEncoder.decode(e.substr(o,__1.BitLength.vendorId),__1.BitLength.vendorId);if(o+=__1.BitLength.vendorId,i){var g=IntEncoder_1.IntEncoder.decode(e.substr(o,__1.BitLength.vendorId),__1.BitLength.vendorId);o+=__1.BitLength.vendorId;for(var a=E;a<=g;a++)r.set(a)}else r.set(E)}}else{var h=e.substr(o,t);o+=t,r=FixedVectorEncoder_1.FixedVectorEncoder.decode(h,t)}return r.bitLength=o,r},e.buildRangeEncoding=function(e){var n=e.length,r=IntEncoder_1.IntEncoder.encode(n,__1.BitLength.numEntries);return e.forEach((function(e){var n=1===e.length;r+=BooleanEncoder_1.BooleanEncoder.encode(!n),r+=IntEncoder_1.IntEncoder.encode(e[0],__1.BitLength.vendorId),n||(r+=IntEncoder_1.IntEncoder.encode(e[1],__1.BitLength.vendorId))})),r},e}();exports.VendorVectorEncoder=VendorVectorEncoder; |
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var Base64Url_1=require("./Base64Url"),BitLength_1=require("./BitLength"),field_1=require("./field"),sequence_1=require("./sequence"),errors_1=require("../errors"),Fields_1=require("../model/Fields"),model_1=require("../model"),SegmentEncoder=function(){function e(){}return e.encode=function(e,r){var n,i=this;try{n=this.fieldSequence[""+e.version][r]}catch(n){throw new errors_1.EncodingError("Unable to encode version: "+e.version+", segment: "+r)}var t="";return r!==model_1.Segment.CORE&&(t=field_1.IntEncoder.encode(model_1.SegmentIDs.KEY_TO_ID[r],BitLength_1.BitLength.segmentType)),n.forEach((function(n){var o=e[n],s=field_1.FieldEncoderMap[n],d=BitLength_1.BitLength[n];void 0===d&&i.isPublisherCustom(n)&&(d=+e[Fields_1.Fields.numCustomPurposes]);try{t+=s.encode(o,d)}catch(e){throw new errors_1.EncodingError("Error encoding "+r+"->"+n+": "+e.message)}})),Base64Url_1.Base64Url.encode(t)},e.decode=function(e,r,n){var i=this,t=Base64Url_1.Base64Url.decode(e),o=0;return n===model_1.Segment.CORE&&(r.version=field_1.IntEncoder.decode(t.substr(o,BitLength_1.BitLength[Fields_1.Fields.version]),BitLength_1.BitLength[Fields_1.Fields.version])),n!==model_1.Segment.CORE&&(o+=BitLength_1.BitLength.segmentType),this.fieldSequence[""+r.version][n].forEach((function(e){var n=field_1.FieldEncoderMap[e],s=BitLength_1.BitLength[e];if(void 0===s&&i.isPublisherCustom(e)&&(s=+r[Fields_1.Fields.numCustomPurposes]),0!==s){var d=t.substr(o,s);if(r[e]=n.decode(d,s),Number.isInteger(s))o+=s;else{if(!Number.isInteger(r[e].bitLength))throw new errors_1.DecodingError(e);o+=r[e].bitLength}}})),r},e.isPublisherCustom=function(e){return 0===e.indexOf("publisherCustom")},e.fieldSequence=new sequence_1.FieldSequence,e}();exports.SegmentEncoder=SegmentEncoder; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var Base64Url_1=require("./Base64Url"),BitLength_1=require("./BitLength"),field_1=require("./field"),sequence_1=require("./sequence"),errors_1=require("../errors"),Fields_1=require("../model/Fields"),model_1=require("../model"),SegmentEncoder=function(){function e(){}return e.encode=function(e,r){var n,i=this;try{n=this.fieldSequence[""+e.version][r]}catch(n){throw new errors_1.EncodingError("Unable to encode version: "+e.version+", segment: "+r)}var t="";return r!==model_1.Segment.CORE&&(t=field_1.IntEncoder.encode(model_1.SegmentIDs.KEY_TO_ID[r],BitLength_1.BitLength.segmentType)),n.forEach((function(n){var o=e[n],s=field_1.FieldEncoderMap[n],d=BitLength_1.BitLength[n];void 0===d&&i.isPublisherCustom(n)&&(d=+e[Fields_1.Fields.numCustomPurposes]);try{t+=s.encode(o,d)}catch(e){throw new errors_1.EncodingError("Error encoding "+r+"->"+n+": "+e.message)}})),Base64Url_1.Base64Url.encode(t)},e.decode=function(e,r,n){var i=this,t=Base64Url_1.Base64Url.decode(e),o=0;return n===model_1.Segment.CORE&&(r.version=field_1.IntEncoder.decode(t.substr(o,BitLength_1.BitLength[Fields_1.Fields.version]),BitLength_1.BitLength[Fields_1.Fields.version])),n!==model_1.Segment.CORE&&(o+=BitLength_1.BitLength.segmentType),this.fieldSequence[""+r.version][n].forEach((function(e){var n=field_1.FieldEncoderMap[e],s=BitLength_1.BitLength[e];if(void 0===s&&i.isPublisherCustom(e)&&(s=+r[Fields_1.Fields.numCustomPurposes]),0!==s){var d=t.substr(o,s);if(n===field_1.VendorVectorEncoder?r[e]=n.decode(d,r.version):r[e]=n.decode(d,s),Number.isInteger(s))o+=s;else{if(!Number.isInteger(r[e].bitLength))throw new errors_1.DecodingError(e);o+=r[e].bitLength}}})),r},e.isPublisherCustom=function(e){return 0===e.indexOf("publisherCustom")},e.fieldSequence=new sequence_1.FieldSequence,e}();exports.SegmentEncoder=SegmentEncoder; |
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var errors_1=require("../errors"),SemanticPreEncoder=function(){function e(){}return e.process=function(e,r){var o,n,s=e.gvl;if(!s)throw new errors_1.EncodingError("Unable to encode TCModel without a GVL");if(!s.isReady)throw new errors_1.EncodingError("Unable to encode TCModel tcModel.gvl.readyPromise is not resolved");(e=e.clone()).consentLanguage=s.language.toUpperCase(),(null===(o=r)||void 0===o?void 0:o.version)>0&&(null===(n=r)||void 0===n?void 0:n.version)<=this.processor.length?e.version=r.version:e.version=this.processor.length;var t=e.version-1;if(!this.processor[t])throw new errors_1.EncodingError("Invalid version: "+e.version);return this.processor[t](e,s)},e.processor=[function(e){return e},function(e,r){e.publisherRestrictions.gvl=r,e.purposeLegitimateInterests.unset(1);var o=new Map;return o.set(e.vendorLegitimateInterests,"legIntPurposes"),o.set(e.vendorConsents,"purposes"),o.forEach((function(e,o){o.forEach((function(n,s){var t=r.vendors[s];(!t||n&&0===t[e].length)&&o.unset(s)}))})),e.vendorsDisclosed.set(r.vendors),e}],e}();exports.SemanticPreEncoder=SemanticPreEncoder; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var errors_1=require("../errors"),model_1=require("../model"),SemanticPreEncoder=function(){function e(){}return e.process=function(e,r){var o,s,n=e.gvl;if(!n)throw new errors_1.EncodingError("Unable to encode TCModel without a GVL");if(!n.isReady)throw new errors_1.EncodingError("Unable to encode TCModel tcModel.gvl.readyPromise is not resolved");(e=e.clone()).consentLanguage=n.language.toUpperCase(),(null===(o=r)||void 0===o?void 0:o.version)>0&&(null===(s=r)||void 0===s?void 0:s.version)<=this.processor.length?e.version=r.version:e.version=this.processor.length;var t=e.version-1;if(!this.processor[t])throw new errors_1.EncodingError("Invalid version: "+e.version);return this.processor[t](e,n)},e.processor=[function(e){return e},function(e,r){e.publisherRestrictions.gvl=r,e.purposeLegitimateInterests.unset(1);var o=new Map;return o.set("legIntPurposes",e.vendorLegitimateInterests),o.set("purposes",e.vendorConsents),o.forEach((function(o,s){o.forEach((function(n,t){if(n){var i=r.vendors[t];if(!i||i.deletedDate)o.unset(t);else if(0===i[s].length)if(e.isServiceSpecific)if(0===i.flexiblePurposes.length)o.unset(t);else{for(var c=e.publisherRestrictions.getRestrictions(t),l=!1,u=0,d=c.length;u<d&&!l;u++)l=c[u].restrictionType===model_1.RestrictionType.REQUIRE_CONSENT&&"purposes"===s||c[u].restrictionType===model_1.RestrictionType.REQUIRE_LI&&"legIntPurposes"===s;l||o.unset(t)}else o.unset(t)}}))})),e.vendorsDisclosed.set(r.vendors),e}],e}();exports.SemanticPreEncoder=SemanticPreEncoder; |
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var ConsentLanguages=function(){function e(){}return e.prototype.has=function(n){return e.langSet.has(n)},e.prototype.forEach=function(n){e.langSet.forEach(n)},Object.defineProperty(e.prototype,"size",{get:function(){return e.langSet.size},enumerable:!0,configurable:!0}),e.langSet=new Set(["BG","CA","CS","DA","DE","EL","EN","ES","ET","FI","FR","HR","HU","IT","LT","LV","MT","NL","NO","PL","PT","RO","RU","SK","SL","SV","ZH"]),e}();exports.ConsentLanguages=ConsentLanguages; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var ConsentLanguages=function(){function e(){}return e.prototype.has=function(n){return e.langSet.has(n)},e.prototype.forEach=function(n){e.langSet.forEach(n)},Object.defineProperty(e.prototype,"size",{get:function(){return e.langSet.size},enumerable:!0,configurable:!0}),e.langSet=new Set(["BG","CA","CS","DA","DE","EL","EN","ES","ET","FI","FR","HR","HU","IT","JA","LT","LV","MT","NL","NO","PL","PT","RO","RU","SK","SL","SV","TR","ZH"]),e}();exports.ConsentLanguages=ConsentLanguages; |
@@ -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)t.hasOwnProperty(r)&&(e[r]=t[r])})(t,r)};return function(t,r){function o(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(o.prototype=r.prototype,new o)}}();Object.defineProperty(exports,"__esModule",{value:!0});var PurposeRestriction_1=require("./PurposeRestriction"),BinarySearchTree_1=require("./BinarySearchTree"),RestrictionType_1=require("./RestrictionType"),Cloneable_1=require("../Cloneable"),PurposeRestrictionVector=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.bitLength=0,t.map=new Map,t}return __extends(t,e),t.prototype.has=function(e){return this.map.has(e)},t.prototype.isOkToHave=function(e,t,r){var o,i=r.toString(),n=!0;if(null===(o=this.gvl)||void 0===o?void 0:o.vendors)if(this.gvl.vendors[i]){var s=this.gvl.vendors[i];if(e===RestrictionType_1.RestrictionType.NOT_ALLOWED)n=s.legIntPurposes.includes(t)||s.purposes.includes(t);else if(s.flexiblePurposes.length)switch(e){case RestrictionType_1.RestrictionType.REQUIRE_CONSENT:n=s.flexiblePurposes.includes(t)&&s.legIntPurposes.includes(t);case RestrictionType_1.RestrictionType.REQUIRE_LI:n=s.flexiblePurposes.includes(t)&&s.purposes.includes(t)}}else n=!1;return n},t.prototype.add=function(e,t){var r=this;if(this.isOkToHave(t.restrictionType,t.purposeId,e)){var o=t.hash;this.has(o)||(this.map.set(o,new BinarySearchTree_1.BinarySearchTree),this.bitLength=0),this.getRestrictions(e).forEach((function(o){o.purposeId===t.purposeId&&r.remove(e,o)})),this.map.get(o).add(e)}},t.prototype.getVendors=function(e){var t=[];if(e){var r=e.hash;this.has(r)&&(t=this.map.get(r).get())}else{var o=new Set;this.map.forEach((function(e){e.get().forEach((function(e){o.add(e)}))})),t=Array.from(o)}return t},t.prototype.getRestrictionType=function(e,t){var r;return this.getRestrictions(e).forEach((function(e){e.purposeId===t&&(void 0===r||r>e.restrictionType)&&(r=e.restrictionType)})),r},t.prototype.vendorHasRestriction=function(e,t){for(var r=!1,o=this.getRestrictions(e),i=0;i<o.length&&!r;i++)r=t.isSameAs(o[i]);return r},t.prototype.getMaxVendorId=function(){var e=0;return this.map.forEach((function(t){e=Math.max(t.max(),e)})),e},t.prototype.getRestrictions=function(e){var t=[];return this.map.forEach((function(r,o){e?r.contains(e)&&t.push(PurposeRestriction_1.PurposeRestriction.unHash(o)):t.push(PurposeRestriction_1.PurposeRestriction.unHash(o))})),t},t.prototype.getPurposes=function(){var e=new Set;return this.map.forEach((function(t,r){e.add(PurposeRestriction_1.PurposeRestriction.unHash(r).purposeId)})),Array.from(e)},t.prototype.remove=function(e,t){var r=t.hash,o=this.map.get(r);o&&(o.remove(e),o.isEmpty()&&(this.map.delete(r),this.bitLength=0))},Object.defineProperty(t.prototype,"gvl",{get:function(){return this.gvl_},set:function(e){var t=this;this.gvl_||(this.gvl_=e,this.map.forEach((function(e,r){var o=PurposeRestriction_1.PurposeRestriction.unHash(r);e.get().forEach((function(r){t.isOkToHave(o.restrictionType,o.purposeId,r)||e.remove(r)}))})))},enumerable:!0,configurable:!0}),t.prototype.isEmpty=function(){return 0===this.map.size},Object.defineProperty(t.prototype,"numRestrictions",{get:function(){return this.map.size},enumerable:!0,configurable:!0}),t}(Cloneable_1.Cloneable);exports.PurposeRestrictionVector=PurposeRestrictionVector; | ||
"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)t.hasOwnProperty(r)&&(e[r]=t[r])})(t,r)};return function(t,r){function i(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(i.prototype=r.prototype,new i)}}();Object.defineProperty(exports,"__esModule",{value:!0});var PurposeRestriction_1=require("./PurposeRestriction"),BinarySearchTree_1=require("./BinarySearchTree"),RestrictionType_1=require("./RestrictionType"),Cloneable_1=require("../Cloneable"),PurposeRestrictionVector=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.bitLength=0,t.map=new Map,t}return __extends(t,e),t.prototype.has=function(e){return this.map.has(e)},t.prototype.isOkToHave=function(e,t,r){var i,o=!0;if(null===(i=this.gvl)||void 0===i?void 0:i.vendors){var n=this.gvl.vendors[r];if(n)if(e===RestrictionType_1.RestrictionType.NOT_ALLOWED)o=n.legIntPurposes.includes(t)||n.purposes.includes(t);else if(n.flexiblePurposes.length)switch(e){case RestrictionType_1.RestrictionType.REQUIRE_CONSENT:o=n.flexiblePurposes.includes(t)&&n.legIntPurposes.includes(t);break;case RestrictionType_1.RestrictionType.REQUIRE_LI:o=n.flexiblePurposes.includes(t)&&n.purposes.includes(t)}else o=!1;else o=!1}return o},t.prototype.add=function(e,t){if(this.isOkToHave(t.restrictionType,t.purposeId,e)){var r=t.hash;this.has(r)||(this.map.set(r,new BinarySearchTree_1.BinarySearchTree),this.bitLength=0),this.map.get(r).add(e)}},t.prototype.getVendors=function(e){var t=[];if(e){var r=e.hash;this.has(r)&&(t=this.map.get(r).get())}else{var i=new Set;this.map.forEach((function(e){e.get().forEach((function(e){i.add(e)}))})),t=Array.from(i)}return t},t.prototype.getRestrictionType=function(e,t){var r;return this.getRestrictions(e).forEach((function(e){e.purposeId===t&&(void 0===r||r>e.restrictionType)&&(r=e.restrictionType)})),r},t.prototype.vendorHasRestriction=function(e,t){for(var r=!1,i=this.getRestrictions(e),o=0;o<i.length&&!r;o++)r=t.isSameAs(i[o]);return r},t.prototype.getMaxVendorId=function(){var e=0;return this.map.forEach((function(t){e=Math.max(t.max(),e)})),e},t.prototype.getRestrictions=function(e){var t=[];return this.map.forEach((function(r,i){e?r.contains(e)&&t.push(PurposeRestriction_1.PurposeRestriction.unHash(i)):t.push(PurposeRestriction_1.PurposeRestriction.unHash(i))})),t},t.prototype.getPurposes=function(){var e=new Set;return this.map.forEach((function(t,r){e.add(PurposeRestriction_1.PurposeRestriction.unHash(r).purposeId)})),Array.from(e)},t.prototype.remove=function(e,t){var r=t.hash,i=this.map.get(r);i&&(i.remove(e),i.isEmpty()&&(this.map.delete(r),this.bitLength=0))},Object.defineProperty(t.prototype,"gvl",{get:function(){return this.gvl_},set:function(e){var t=this;this.gvl_||(this.gvl_=e,this.map.forEach((function(e,r){var i=PurposeRestriction_1.PurposeRestriction.unHash(r);e.get().forEach((function(r){t.isOkToHave(i.restrictionType,i.purposeId,r)||e.remove(r)}))})))},enumerable:!0,configurable:!0}),t.prototype.isEmpty=function(){return 0===this.map.size},Object.defineProperty(t.prototype,"numRestrictions",{get:function(){return this.map.size},enumerable:!0,configurable:!0}),t}(Cloneable_1.Cloneable);exports.PurposeRestrictionVector=PurposeRestrictionVector; |
@@ -8,3 +8,3 @@ import { Cloneable } from '../Cloneable'; | ||
*/ | ||
declare class Vector extends Cloneable<Vector> implements Iterable<IdBoolTuple> { | ||
export declare class Vector extends Cloneable<Vector> implements Iterable<IdBoolTuple> { | ||
/** | ||
@@ -16,8 +16,12 @@ * if this originatd from an encoded string we'll need a place to store the | ||
private maxId_; | ||
/** | ||
* keep a set for faster lookup | ||
*/ | ||
private set_; | ||
[Symbol.iterator](): Iterator<IdBoolTuple>; | ||
/** | ||
* values() | ||
* | ||
* @return {IterableIterator<number>} - returns an iterator of the positive | ||
* values in the set | ||
*/ | ||
values(): IterableIterator<number>; | ||
/** | ||
* maxId | ||
@@ -70,2 +74,2 @@ * | ||
} | ||
export { Vector }; | ||
export {}; |
@@ -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)e.hasOwnProperty(r)&&(t[r]=e[r])})(e,r)};return function(e,r){function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),__generator=this&&this.__generator||function(t,e){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(t){i=[6,t],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}},__values=this&&this.__values||function(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(exports,"__esModule",{value:!0});var Cloneable_1=require("../Cloneable"),errors_1=require("../errors"),Vector=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.bitLength=0,e.maxId_=0,e.set_=new Set,e}return __extends(e,t),e.prototype[Symbol.iterator]=function(){var t;return __generator(this,(function(e){switch(e.label){case 0:t=1,e.label=1;case 1:return t<=this.maxId?[4,[t,this.has(t)]]:[3,4];case 2:e.sent(),e.label=3;case 3:return t++,[3,1];case 4:return[2]}}))},Object.defineProperty(e.prototype,"maxId",{get:function(){return this.maxId_},enumerable:!0,configurable:!0}),e.prototype.has=function(t){return this.set_.has(t)},e.prototype.unset=function(t){var e=this;Array.isArray(t)?t.forEach((function(t){return e.unset(t)})):"object"==typeof t?this.unset(Object.keys(t).map((function(t){return+t}))):(this.set_.delete(t),this.bitLength=0,t===this.maxId&&(this.maxId_=0,this.set_.forEach((function(t){e.maxId_=Math.max(e.maxId,t)}))))},e.prototype.isIntMap=function(t){var e=this,r="object"==typeof t;return r=r&&Object.keys(t).every((function(r){var n=Number.isInteger(parseInt(r,10));return n=(n=n&&e.isValidNumber(t[r].id))&&void 0!==t[r].name}))},e.prototype.isValidNumber=function(t){return parseInt(t,10)>0},e.prototype.isSet=function(t){var e=!1;return t instanceof Set&&(e=Array.from(t).every(this.isValidNumber)),e},e.prototype.set=function(t){var e=this;if(Array.isArray(t))t.forEach((function(t){return e.set(t)}));else if(this.isSet(t))this.set(Array.from(t));else if(this.isIntMap(t))this.set(Object.keys(t).map((function(t){return+t})));else{if(!this.isValidNumber(t))throw new errors_1.TCModelError("set()",t,"must be positive integer array, positive integer, Set<number>, or IntMap");this.set_.add(t),this.maxId_=Math.max(this.maxId,t),this.bitLength=0}},e.prototype.empty=function(){this.set_=new Set},e.prototype.forEach=function(t){var e,r;try{for(var n=__values(this),o=n.next();!o.done;o=n.next()){var i=o.value;t(i[1],i[0])}}catch(t){e={error:t}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(e)throw e.error}}},Object.defineProperty(e.prototype,"size",{get:function(){return this.set_.size},enumerable:!0,configurable:!0}),e.prototype.setAll=function(t){this.set(t)},e}(Cloneable_1.Cloneable);exports.Vector=Vector; | ||
"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)e.hasOwnProperty(r)&&(t[r]=e[r])})(e,r)};return function(e,r){function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),__generator=this&&this.__generator||function(t,e){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,n=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}};Object.defineProperty(exports,"__esModule",{value:!0});var Cloneable_1=require("../Cloneable"),errors_1=require("../errors"),Vector=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.bitLength=0,e.maxId_=0,e.set_=new Set,e}return __extends(e,t),e.prototype[Symbol.iterator]=function(){var t;return __generator(this,(function(e){switch(e.label){case 0:t=1,e.label=1;case 1:return t<=this.maxId?[4,[t,this.has(t)]]:[3,4];case 2:e.sent(),e.label=3;case 3:return t++,[3,1];case 4:return[2]}}))},e.prototype.values=function(){return this.set_.values()},Object.defineProperty(e.prototype,"maxId",{get:function(){return this.maxId_},enumerable:!0,configurable:!0}),e.prototype.has=function(t){return this.set_.has(t)},e.prototype.unset=function(t){var e=this;Array.isArray(t)?t.forEach((function(t){return e.unset(t)})):"object"==typeof t?this.unset(Object.keys(t).map((function(t){return+t}))):(this.set_.delete(t),this.bitLength=0,t===this.maxId&&(this.maxId_=0,this.set_.forEach((function(t){e.maxId_=Math.max(e.maxId,t)}))))},e.prototype.isIntMap=function(t){var e=this,r="object"==typeof t;return r=r&&Object.keys(t).every((function(r){var n=Number.isInteger(parseInt(r,10));return n=(n=n&&e.isValidNumber(t[r].id))&&void 0!==t[r].name}))},e.prototype.isValidNumber=function(t){return parseInt(t,10)>0},e.prototype.isSet=function(t){var e=!1;return t instanceof Set&&(e=Array.from(t).every(this.isValidNumber)),e},e.prototype.set=function(t){var e=this;if(Array.isArray(t))t.forEach((function(t){return e.set(t)}));else if(this.isSet(t))this.set(Array.from(t));else if(this.isIntMap(t))this.set(Object.keys(t).map((function(t){return+t})));else{if(!this.isValidNumber(t))throw new errors_1.TCModelError("set()",t,"must be positive integer array, positive integer, Set<number>, or IntMap");this.set_.add(t),this.maxId_=Math.max(this.maxId,t),this.bitLength=0}},e.prototype.empty=function(){this.set_=new Set},e.prototype.forEach=function(t){for(var e=1;e<=this.maxId;e++)t(this.has(e),e)},Object.defineProperty(e.prototype,"size",{get:function(){return this.set_.size},enumerable:!0,configurable:!0}),e.prototype.setAll=function(t){this.set(t)},e}(Cloneable_1.Cloneable);exports.Vector=Vector; |
{ | ||
"name": "didomi-iabtcf-core", | ||
"version": "1.1.0-2", | ||
"version": "1.1.4-1", | ||
"description": "Ensures consistent encoding and decoding of TC Signals for the iab. Transparency and Consent Framework (TCF).", | ||
@@ -17,10 +17,9 @@ "author": "Chris Paterson <tcf@chrispaterson.io>", | ||
"lint": "eslint `find test src -name '*.ts'`", | ||
"debug": "yarn test --no-timeouts --inspect-brk", | ||
"debug": "ndb mocha --no-timeouts", | ||
"serve:cov": "npx http-server ./coverage/", | ||
"test": "mocha `find test -name '*.test.ts'`", | ||
"test:cov": "rm -rf coverage; nyc --reporter=html mocha `find test -name '*.test.ts'`", | ||
"test:lcov": "nyc --reporter=lcov mocha `find test -name '*.test.ts'`" | ||
"test": "mocha", | ||
"test-cov": "rm -rf coverage; nyc --reporter=html mocha" | ||
}, | ||
"devDependencies": { | ||
"didomi-iabtcf-testing": "1.1.0-2", | ||
"didomi-iabtcf-testing": "1.1.4-1", | ||
"@istanbuljs/nyc-config-typescript": "^0.1.3", | ||
@@ -38,2 +37,3 @@ "@types/sinon": "^7.0.13", | ||
"mocha-lcov-reporter": "^1.3.0", | ||
"ndb": "^1.1.5", | ||
"nyc": "^14.1.1", | ||
@@ -40,0 +40,0 @@ "sinon": "^7.3.2", |
[![NPM version](https://img.shields.io/npm/v/didomi-iabtcf-core.svg?style=flat-square)](https://www.npmjs.com/package/didomi-iabtcf-core) | ||
[![npm module downloads per month](http://img.shields.io/npm/dm/didomi-iabtcf-core.svg?style=flat)](https://www.npmjs.org/package/didomi-iabtcf-core) | ||
[![Build](https://travis-ci.org/chrispaterson/iabtcf.svg?branch=master)](https://travis-ci.org/chrispaterson/iabtcf) | ||
[![Coverage Status](https://coveralls.io/repos/github/chrispaterson/iabtcf/badge.svg?branch=master)](https://coveralls.io/github/chrispaterson/iabtcf?branch=master) | ||
[![InteractiveAdvertisingBureau](https://circleci.com/gh/InteractiveAdvertisingBureau/iabtcf-es.svg?style=shield)](https://circleci.com/gh/InteractiveAdvertisingBureau/iabtcf-es) | ||
@@ -74,4 +73,2 @@ # didomi-iabtcf-core | ||
[API Docs](https://www.iabtcf.com/api/core/classes/tcmodel.html) | ||
### Creating a new TCModel | ||
@@ -113,25 +110,25 @@ | ||
The [`TCModel`](https://www.iabtcf.com/api/core/classes/tcmodel.html) leverages a [`Set`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set) style [`Vector`](https://www.iabtcf.com/api/core/classes/vector.html) data structure to set consents, optins, allowed, disclosed, and legitimate interest establishment. Properties that leverage this data structure are: | ||
The `TCModel` leverages a [`Set`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set) style `Vector` data structure to set consents, optins, allowed, disclosed, and legitimate interest establishment. Properties that leverage this data structure are: | ||
- **Vendors** | ||
- [`vendorConsents`](https://www.iabtcf.com/api/core/classes/tcmodel.html#vendorconsents) | ||
- [`vendorLegitimateInterest`](https://www.iabtcf.com/api/core/classes/tcmodel.html#vendorlegitimateinterest) | ||
- [`vendorsAllowed`](https://www.iabtcf.com/api/core/classes/tcmodel.html#vendorsallowed) | ||
- [`vendorsDisclosed`](https://www.iabtcf.com/api/core/classes/tcmodel.html#vendorsdisclosed) | ||
- `vendorConsents` | ||
- `vendorLegitimateInterests` | ||
- `vendorsAllowed` | ||
- `vendorsDisclosed` | ||
- **Global Purposes** | ||
- [`purposeConsents`](https://www.iabtcf.com/api/core/classes/tcmodel.html#purposeconsents) | ||
- [`purposeLegitimateInterest`](https://www.iabtcf.com/api/core/classes/tcmodel.html#legitimateinterest) | ||
- `purposeConsents` | ||
- `purposeLegitimateInterests` | ||
- **Special Feature Opt-Ins** | ||
- [`specialFeatureOptIns`](https://www.iabtcf.com/api/core/classes/tcmodel.html#specialfeatureoptins) | ||
- `specialFeatureOptIns` | ||
- **Publisher** | ||
- [`publisherConsents`](https://www.iabtcf.com/api/core/classes/tcmodel.html#publisherconsents) | ||
- [`publisherCustomConsents`](https://www.iabtcf.com/api/core/classes/tcmodel.html#publishercustomconsents) | ||
- [`publisherLegitimateInterest`](https://www.iabtcf.com/api/core/classes/tcmodel.html#publisherlegitimateinterest) | ||
- [`publisherCustomLegitimateInterest`](https://www.iabtcf.com/api/core/classes/tcmodel.html#publishercustomlegitimateInterest) | ||
- [`publisherRestrictions`](https://www.iabtcf.com/api/core/classes/tcmodel.html#publisherrestrictions) | ||
- This Vector is a special [`PurposeRestrictionVector`](https://www.iabtcf.com/api/core/classes/purposerestrictionvector.html) of [`PurposeRestrictions`](https://www.iabtcf.com/api/core/classes/purposerestriction.html) | ||
- `publisherConsents` | ||
- `publisherCustomConsents` | ||
- `publisherLegitimateInterests` | ||
- `publisherCustomLegitimateInterests` | ||
- `publisherRestrictions` | ||
- This Vector is a special `PurposeRestrictionVector` of `PurposeRestrictions` | ||
**Example with `vendorConsents`** | ||
The `vendorConsents` property on the `TCModel` is a [`Vector`](https://www.iabtcf.com/api/core/classes/vector.html). This example illustrates the methods of a [`Vector`](https://www.iabtcf.com/api/core/classes/vector.html). With the exception of the `publisherRestrictions`, which implements a different type of [`PurposeRestrictionVector`](https://www.iabtcf.com/api/core/classes/purposerestrictionvector.html), all of the above Vectors will have this interface and functionality. | ||
The `vendorConsents` property on the `TCModel` is a `Vector`. This example illustrates the methods of a `Vector`. With the exception of the `publisherRestrictions`, which implements a different type of `PurposeRestrictionVector`, all of the above Vectors will have this interface and functionality. | ||
@@ -175,3 +172,3 @@ ```javascript | ||
A [Publisher Restriction](https://github.com/InteractiveAdvertisingBureau/GDPR-Transparency-and-Consent-Framework/blob/master/TCFv2/IAB%20Tech%20Lab%20-%20Consent%20string%20and%20vendor%20list%20formats%20v2.md#what-are-publisher-restrictions) is a restriction placed on a Vendor by a publisher limiting the purposes for which that Vendor is allowed to process personal data. The `TCModel.publisherRestrictions` is an instance of the [`PurposeRestrictionVector`](https://www.iabtcf.com/api/core/classes/purposerestrictionvector.html), which is a vector containing [`PurposeRestrictions`](https://www.iabtcf.com/api/core/classes/purposerestriction.html)'s. | ||
A [Publisher Restriction](https://github.com/InteractiveAdvertisingBureau/GDPR-Transparency-and-Consent-Framework/blob/master/TCFv2/IAB%20Tech%20Lab%20-%20Consent%20string%20and%20vendor%20list%20formats%20v2.md#what-are-publisher-restrictions) is a restriction placed on a Vendor by a publisher limiting the purposes for which that Vendor is allowed to process personal data. The `TCModel.publisherRestrictions` is an instance of the `PurposeRestrictionVector`, which is a vector containing `PurposeRestrictions`'s. | ||
@@ -199,3 +196,2 @@ **Example of setting publisher restrictions** | ||
- [API Docs](https://www.iabtcf.com/api/core/classes/gvl.html) | ||
- [Autoload latest vendor-list.json](#autoload-latest-vendor-listjson) | ||
@@ -348,3 +344,3 @@ - [Autoload specific vendor-list.json](#autoload-specific-vendor-listjson) | ||
All 6 grouping methods return an [IntMap](https://www.iabtcf.com/api/core/interfaces/intmap.html)<[Vendor](https://www.iabtcf.com/api/core/interfaces/vendor.html)> object | ||
All 6 grouping methods return an `IntMap<Vendor>` object | ||
@@ -395,4 +391,2 @@ ```javascript | ||
[API Docs](https://www.iabtcf.com/api/core/classes/tcstring.html) | ||
- [Decode](#decode-an-iab-tc-string) | ||
@@ -399,0 +393,0 @@ - [Encode](#encode-an-iab-tc-string) |
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
1371
139817
22
484