Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@iabtcf/cmpapi

Package Overview
Dependencies
Maintainers
2
Versions
88
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@iabtcf/cmpapi - npm Package Compare versions

Comparing version 1.5.3 to 1.5.4-0

2

lib/cjs/CallResponder.js

@@ -1,1 +0,1 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.CallResponder=exports.API_KEY=void 0;const index_js_1=require("./command/index.js"),CommandMap_js_1=require("./command/CommandMap.js"),CmpApiModel_js_1=require("./CmpApiModel.js"),Disabled_js_1=require("./response/Disabled.js"),SupportedVersions_js_1=require("./SupportedVersions.js");exports.API_KEY="__tcfapi";class CallResponder{constructor(s){if(s){let o=index_js_1.TCFCommand.ADD_EVENT_LISTENER;if(null==s?void 0:s[o])throw new Error(`Built-In Custom Commmand for ${o} not allowed: Use ${index_js_1.TCFCommand.GET_TC_DATA} instead`);if(o=index_js_1.TCFCommand.REMOVE_EVENT_LISTENER,null==s?void 0:s[o])throw new Error(`Built-In Custom Commmand for ${o} not allowed`);(null==s?void 0:s[index_js_1.TCFCommand.GET_TC_DATA])&&(s[index_js_1.TCFCommand.ADD_EVENT_LISTENER]=s[index_js_1.TCFCommand.GET_TC_DATA],s[index_js_1.TCFCommand.REMOVE_EVENT_LISTENER]=s[index_js_1.TCFCommand.GET_TC_DATA]),this.customCommands=s}try{this.callQueue=window[exports.API_KEY]()||[]}catch(s){this.callQueue=[]}finally{window[exports.API_KEY]=this.apiCall.bind(this),this.purgeQueuedCalls()}}apiCall(s,o,e,...n){if("string"!=typeof s)e(null,!1);else if(SupportedVersions_js_1.SupportedVersions.has(o)){if("function"!=typeof e)throw new Error("invalid callback function");CmpApiModel_js_1.CmpApiModel.disabled?e(new Disabled_js_1.Disabled,!1):this.isCustomCommand(s)||this.isBuiltInCommand(s)?this.isCustomCommand(s)&&!this.isBuiltInCommand(s)?this.customCommands[s](e,...n):s===index_js_1.TCFCommand.PING?this.isCustomCommand(s)?new CommandMap_js_1.CommandMap[s](this.customCommands[s],n[0],null,e):new CommandMap_js_1.CommandMap[s](e,n[0]):void 0===CmpApiModel_js_1.CmpApiModel.tcModel?this.callQueue.push([s,o,e,...n]):this.isCustomCommand(s)&&this.isBuiltInCommand(s)?new CommandMap_js_1.CommandMap[s](this.customCommands[s],n[0],null,e):new CommandMap_js_1.CommandMap[s](e,n[0]):e(null,!1)}else e(null,!1)}purgeQueuedCalls(){const s=this.callQueue;this.callQueue=[],s.forEach(s=>{window[exports.API_KEY](...s)})}isCustomCommand(s){return this.customCommands&&"function"==typeof this.customCommands[s]}isBuiltInCommand(s){return void 0!==CommandMap_js_1.CommandMap[s]}}exports.CallResponder=CallResponder;
"use strict";var __read=this&&this.__read||function(o,n){var e="function"==typeof Symbol&&o[Symbol.iterator];if(!e)return o;var s,a,i=e.call(o),t=[];try{for(;(void 0===n||n-- >0)&&!(s=i.next()).done;)t.push(s.value)}catch(o){a={error:o}}finally{try{s&&!s.done&&(e=i.return)&&e.call(i)}finally{if(a)throw a.error}}return t},__spreadArray=this&&this.__spreadArray||function(o,n,e){if(e||2===arguments.length)for(var s,a=0,i=n.length;a<i;a++)!s&&a in n||(s||(s=Array.prototype.slice.call(n,0,a)),s[a]=n[a]);return o.concat(s||Array.prototype.slice.call(n))};Object.defineProperty(exports,"__esModule",{value:!0}),exports.CallResponder=exports.API_KEY=void 0;var index_js_1=require("./command/index.js"),CommandMap_js_1=require("./command/CommandMap.js"),CmpApiModel_js_1=require("./CmpApiModel.js"),Disabled_js_1=require("./response/Disabled.js"),SupportedVersions_js_1=require("./SupportedVersions.js");exports.API_KEY="__tcfapi";var CallResponder=function(){function o(o){if(o){var n=index_js_1.TCFCommand.ADD_EVENT_LISTENER;if(null==o?void 0:o[n])throw new Error("Built-In Custom Commmand for ".concat(n," not allowed: Use ").concat(index_js_1.TCFCommand.GET_TC_DATA," instead"));if(n=index_js_1.TCFCommand.REMOVE_EVENT_LISTENER,null==o?void 0:o[n])throw new Error("Built-In Custom Commmand for ".concat(n," not allowed"));(null==o?void 0:o[index_js_1.TCFCommand.GET_TC_DATA])&&(o[index_js_1.TCFCommand.ADD_EVENT_LISTENER]=o[index_js_1.TCFCommand.GET_TC_DATA],o[index_js_1.TCFCommand.REMOVE_EVENT_LISTENER]=o[index_js_1.TCFCommand.GET_TC_DATA]),this.customCommands=o}try{this.callQueue=window[exports.API_KEY]()||[]}catch(o){this.callQueue=[]}finally{window[exports.API_KEY]=this.apiCall.bind(this),this.purgeQueuedCalls()}}return o.prototype.apiCall=function(o,n,e){for(var s,a=[],i=3;i<arguments.length;i++)a[i-3]=arguments[i];if("string"!=typeof o)e(null,!1);else if(SupportedVersions_js_1.SupportedVersions.has(n)){if("function"!=typeof e)throw new Error("invalid callback function");CmpApiModel_js_1.CmpApiModel.disabled?e(new Disabled_js_1.Disabled,!1):this.isCustomCommand(o)||this.isBuiltInCommand(o)?this.isCustomCommand(o)&&!this.isBuiltInCommand(o)?(s=this.customCommands)[o].apply(s,__spreadArray([e],__read(a),!1)):o===index_js_1.TCFCommand.PING?this.isCustomCommand(o)?new CommandMap_js_1.CommandMap[o](this.customCommands[o],a[0],null,e):new CommandMap_js_1.CommandMap[o](e,a[0]):void 0===CmpApiModel_js_1.CmpApiModel.tcModel?this.callQueue.push(__spreadArray([o,n,e],__read(a),!1)):this.isCustomCommand(o)&&this.isBuiltInCommand(o)?new CommandMap_js_1.CommandMap[o](this.customCommands[o],a[0],null,e):new CommandMap_js_1.CommandMap[o](e,a[0]):e(null,!1)}else e(null,!1)},o.prototype.purgeQueuedCalls=function(){var o=this.callQueue;this.callQueue=[],o.forEach((function(o){window[exports.API_KEY].apply(window,__spreadArray([],__read(o),!1))}))},o.prototype.isCustomCommand=function(o){return this.customCommands&&"function"==typeof this.customCommands[o]},o.prototype.isBuiltInCommand=function(o){return void 0!==CommandMap_js_1.CommandMap[o]},o}();exports.CallResponder=CallResponder;

@@ -1,1 +0,1 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.CmpApi=void 0;const CmpApiModel_js_1=require("./CmpApiModel.js"),index_js_1=require("./status/index.js"),CallResponder_js_1=require("./CallResponder.js"),core_1=require("@iabtcf/core");class CmpApi{constructor(p,e,i=!1,d){this.numUpdates=0,this.throwIfInvalidInt(p,"cmpId",2),this.throwIfInvalidInt(e,"cmpVersion",0),CmpApiModel_js_1.CmpApiModel.cmpId=p,CmpApiModel_js_1.CmpApiModel.cmpVersion=e,CmpApiModel_js_1.CmpApiModel.tcfPolicyVersion=2,this.isServiceSpecific=!!i,this.callResponder=new CallResponder_js_1.CallResponder(d)}throwIfInvalidInt(p,e,i){if(!("number"==typeof p&&Number.isInteger(p)&&p>=i))throw new Error(`Invalid ${e}: ${p}`)}update(p,e=!1){if(CmpApiModel_js_1.CmpApiModel.disabled)throw new Error("CmpApi Disabled");CmpApiModel_js_1.CmpApiModel.cmpStatus=index_js_1.CmpStatus.LOADED,e?(CmpApiModel_js_1.CmpApiModel.displayStatus=index_js_1.DisplayStatus.VISIBLE,CmpApiModel_js_1.CmpApiModel.eventStatus=index_js_1.EventStatus.CMP_UI_SHOWN):void 0===CmpApiModel_js_1.CmpApiModel.tcModel?(CmpApiModel_js_1.CmpApiModel.displayStatus=index_js_1.DisplayStatus.DISABLED,CmpApiModel_js_1.CmpApiModel.eventStatus=index_js_1.EventStatus.TC_LOADED):(CmpApiModel_js_1.CmpApiModel.displayStatus=index_js_1.DisplayStatus.HIDDEN,CmpApiModel_js_1.CmpApiModel.eventStatus=index_js_1.EventStatus.USER_ACTION_COMPLETE),CmpApiModel_js_1.CmpApiModel.gdprApplies=null!==p,CmpApiModel_js_1.CmpApiModel.gdprApplies?(""===p?(CmpApiModel_js_1.CmpApiModel.tcModel=new core_1.TCModel,CmpApiModel_js_1.CmpApiModel.tcModel.cmpId=CmpApiModel_js_1.CmpApiModel.cmpId,CmpApiModel_js_1.CmpApiModel.tcModel.cmpVersion=CmpApiModel_js_1.CmpApiModel.cmpVersion):CmpApiModel_js_1.CmpApiModel.tcModel=core_1.TCString.decode(p),CmpApiModel_js_1.CmpApiModel.tcModel.isServiceSpecific=this.isServiceSpecific,CmpApiModel_js_1.CmpApiModel.tcfPolicyVersion=Number(CmpApiModel_js_1.CmpApiModel.tcModel.policyVersion),CmpApiModel_js_1.CmpApiModel.tcString=p):CmpApiModel_js_1.CmpApiModel.tcModel=null,0===this.numUpdates?this.callResponder.purgeQueuedCalls():CmpApiModel_js_1.CmpApiModel.eventQueue.exec(),this.numUpdates++}disable(){CmpApiModel_js_1.CmpApiModel.disabled=!0,CmpApiModel_js_1.CmpApiModel.cmpStatus=index_js_1.CmpStatus.ERROR}}exports.CmpApi=CmpApi;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.CmpApi=void 0;var CmpApiModel_js_1=require("./CmpApiModel.js"),index_js_1=require("./status/index.js"),CallResponder_js_1=require("./CallResponder.js"),core_1=require("@iabtcf/core"),CmpApi=function(){function p(p,e,i,o){void 0===i&&(i=!1),this.numUpdates=0,this.throwIfInvalidInt(p,"cmpId",2),this.throwIfInvalidInt(e,"cmpVersion",0),CmpApiModel_js_1.CmpApiModel.cmpId=p,CmpApiModel_js_1.CmpApiModel.cmpVersion=e,CmpApiModel_js_1.CmpApiModel.tcfPolicyVersion=2,this.isServiceSpecific=!!i,this.callResponder=new CallResponder_js_1.CallResponder(o)}return p.prototype.throwIfInvalidInt=function(p,e,i){if(!("number"==typeof p&&Number.isInteger(p)&&p>=i))throw new Error("Invalid ".concat(e,": ").concat(p))},p.prototype.update=function(p,e){if(void 0===e&&(e=!1),CmpApiModel_js_1.CmpApiModel.disabled)throw new Error("CmpApi Disabled");CmpApiModel_js_1.CmpApiModel.cmpStatus=index_js_1.CmpStatus.LOADED,e?(CmpApiModel_js_1.CmpApiModel.displayStatus=index_js_1.DisplayStatus.VISIBLE,CmpApiModel_js_1.CmpApiModel.eventStatus=index_js_1.EventStatus.CMP_UI_SHOWN):void 0===CmpApiModel_js_1.CmpApiModel.tcModel?(CmpApiModel_js_1.CmpApiModel.displayStatus=index_js_1.DisplayStatus.DISABLED,CmpApiModel_js_1.CmpApiModel.eventStatus=index_js_1.EventStatus.TC_LOADED):(CmpApiModel_js_1.CmpApiModel.displayStatus=index_js_1.DisplayStatus.HIDDEN,CmpApiModel_js_1.CmpApiModel.eventStatus=index_js_1.EventStatus.USER_ACTION_COMPLETE),CmpApiModel_js_1.CmpApiModel.gdprApplies=null!==p,CmpApiModel_js_1.CmpApiModel.gdprApplies?(""===p?(CmpApiModel_js_1.CmpApiModel.tcModel=new core_1.TCModel,CmpApiModel_js_1.CmpApiModel.tcModel.cmpId=CmpApiModel_js_1.CmpApiModel.cmpId,CmpApiModel_js_1.CmpApiModel.tcModel.cmpVersion=CmpApiModel_js_1.CmpApiModel.cmpVersion):CmpApiModel_js_1.CmpApiModel.tcModel=core_1.TCString.decode(p),CmpApiModel_js_1.CmpApiModel.tcModel.isServiceSpecific=this.isServiceSpecific,CmpApiModel_js_1.CmpApiModel.tcfPolicyVersion=Number(CmpApiModel_js_1.CmpApiModel.tcModel.policyVersion),CmpApiModel_js_1.CmpApiModel.tcString=p):CmpApiModel_js_1.CmpApiModel.tcModel=null,0===this.numUpdates?this.callResponder.purgeQueuedCalls():CmpApiModel_js_1.CmpApiModel.eventQueue.exec(),this.numUpdates++},p.prototype.disable=function(){CmpApiModel_js_1.CmpApiModel.disabled=!0,CmpApiModel_js_1.CmpApiModel.cmpStatus=index_js_1.CmpStatus.ERROR},p}();exports.CmpApi=CmpApi;

@@ -1,1 +0,1 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.CmpApiModel=void 0;const index_js_1=require("./status/index.js"),EventListenerQueue_js_1=require("./EventListenerQueue.js");class CmpApiModel{static reset(){delete this.cmpId,delete this.cmpVersion,delete this.eventStatus,delete this.gdprApplies,delete this.tcModel,delete this.tcString,delete this.tcfPolicyVersion,this.cmpStatus=index_js_1.CmpStatus.LOADING,this.disabled=!1,this.displayStatus=index_js_1.DisplayStatus.HIDDEN,this.eventQueue.clear()}}exports.CmpApiModel=CmpApiModel,CmpApiModel.apiVersion="2",CmpApiModel.eventQueue=new EventListenerQueue_js_1.EventListenerQueue,CmpApiModel.cmpStatus=index_js_1.CmpStatus.LOADING,CmpApiModel.disabled=!1,CmpApiModel.displayStatus=index_js_1.DisplayStatus.HIDDEN;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.CmpApiModel=void 0;var index_js_1=require("./status/index.js"),EventListenerQueue_js_1=require("./EventListenerQueue.js"),CmpApiModel=function(){function e(){}return e.reset=function(){delete this.cmpId,delete this.cmpVersion,delete this.eventStatus,delete this.gdprApplies,delete this.tcModel,delete this.tcString,delete this.tcfPolicyVersion,this.cmpStatus=index_js_1.CmpStatus.LOADING,this.disabled=!1,this.displayStatus=index_js_1.DisplayStatus.HIDDEN,this.eventQueue.clear()},e.apiVersion="2",e.eventQueue=new EventListenerQueue_js_1.EventListenerQueue,e.cmpStatus=index_js_1.CmpStatus.LOADING,e.disabled=!1,e.displayStatus=index_js_1.DisplayStatus.HIDDEN,e}();exports.CmpApiModel=CmpApiModel;

@@ -1,1 +0,1 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.AddEventListenerCommand=void 0;const CmpApiModel_js_1=require("../CmpApiModel.js"),GetTCDataCommand_js_1=require("./GetTCDataCommand.js");class AddEventListenerCommand extends GetTCDataCommand_js_1.GetTCDataCommand{respond(){this.listenerId=CmpApiModel_js_1.CmpApiModel.eventQueue.add({callback:this.callback,param:this.param,next:this.next}),super.respond()}}exports.AddEventListenerCommand=AddEventListenerCommand;
"use strict";var __extends=this&&this.__extends||function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function o(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(o.prototype=n.prototype,new o)}}();Object.defineProperty(exports,"__esModule",{value:!0}),exports.AddEventListenerCommand=void 0;var CmpApiModel_js_1=require("../CmpApiModel.js"),GetTCDataCommand_js_1=require("./GetTCDataCommand.js"),AddEventListenerCommand=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.respond=function(){this.listenerId=CmpApiModel_js_1.CmpApiModel.eventQueue.add({callback:this.callback,param:this.param,next:this.next}),t.prototype.respond.call(this)},e}(GetTCDataCommand_js_1.GetTCDataCommand);exports.AddEventListenerCommand=AddEventListenerCommand;

@@ -1,1 +0,1 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Command=void 0;class Command{constructor(t,s,e,a){this.success=!0,Object.assign(this,{callback:t,listenerId:e,param:s,next:a});try{this.respond()}catch(t){this.invokeCallback(null)}}invokeCallback(t){const s=null!==t;"function"==typeof this.next?this.callback(this.next,t,s):this.callback(t,s)}}exports.Command=Command;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Command=void 0;var Command=function(){function t(t,e,n,a){this.success=!0,Object.assign(this,{callback:t,listenerId:n,param:e,next:a});try{this.respond()}catch(t){this.invokeCallback(null)}}return t.prototype.invokeCallback=function(t){var e=null!==t;"function"==typeof this.next?this.callback(this.next,t,e):this.callback(t,e)},t}();exports.Command=Command;

@@ -1,1 +0,1 @@

"use strict";var _a,_b,_c,_d,_e,_f;Object.defineProperty(exports,"__esModule",{value:!0}),exports.CommandMap=void 0;const PingCommand_js_1=require("./PingCommand.js"),GetTCDataCommand_js_1=require("./GetTCDataCommand.js"),GetInAppTCDataCommand_js_1=require("./GetInAppTCDataCommand.js"),GetVendorListCommand_js_1=require("./GetVendorListCommand.js"),AddEventListenerCommand_js_1=require("./AddEventListenerCommand.js"),RemoveEventListenerCommand_js_1=require("./RemoveEventListenerCommand.js"),TCFCommand_js_1=require("./TCFCommand.js");class CommandMap{}exports.CommandMap=CommandMap,_a=TCFCommand_js_1.TCFCommand.PING,_b=TCFCommand_js_1.TCFCommand.GET_TC_DATA,_c=TCFCommand_js_1.TCFCommand.GET_IN_APP_TC_DATA,_d=TCFCommand_js_1.TCFCommand.GET_VENDOR_LIST,_e=TCFCommand_js_1.TCFCommand.ADD_EVENT_LISTENER,_f=TCFCommand_js_1.TCFCommand.REMOVE_EVENT_LISTENER,CommandMap[_a]=PingCommand_js_1.PingCommand,CommandMap[_b]=GetTCDataCommand_js_1.GetTCDataCommand,CommandMap[_c]=GetInAppTCDataCommand_js_1.GetInAppTCDataCommand,CommandMap[_d]=GetVendorListCommand_js_1.GetVendorListCommand,CommandMap[_e]=AddEventListenerCommand_js_1.AddEventListenerCommand,CommandMap[_f]=RemoveEventListenerCommand_js_1.RemoveEventListenerCommand;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.CommandMap=void 0;var PingCommand_js_1=require("./PingCommand.js"),GetTCDataCommand_js_1=require("./GetTCDataCommand.js"),GetInAppTCDataCommand_js_1=require("./GetInAppTCDataCommand.js"),GetVendorListCommand_js_1=require("./GetVendorListCommand.js"),AddEventListenerCommand_js_1=require("./AddEventListenerCommand.js"),RemoveEventListenerCommand_js_1=require("./RemoveEventListenerCommand.js"),TCFCommand_js_1=require("./TCFCommand.js"),CommandMap=function(){function m(){}var n,e,C,a,o,d;return n=TCFCommand_js_1.TCFCommand.PING,e=TCFCommand_js_1.TCFCommand.GET_TC_DATA,C=TCFCommand_js_1.TCFCommand.GET_IN_APP_TC_DATA,a=TCFCommand_js_1.TCFCommand.GET_VENDOR_LIST,o=TCFCommand_js_1.TCFCommand.ADD_EVENT_LISTENER,d=TCFCommand_js_1.TCFCommand.REMOVE_EVENT_LISTENER,m[n]=PingCommand_js_1.PingCommand,m[e]=GetTCDataCommand_js_1.GetTCDataCommand,m[C]=GetInAppTCDataCommand_js_1.GetInAppTCDataCommand,m[a]=GetVendorListCommand_js_1.GetVendorListCommand,m[o]=AddEventListenerCommand_js_1.AddEventListenerCommand,m[d]=RemoveEventListenerCommand_js_1.RemoveEventListenerCommand,m}();exports.CommandMap=CommandMap;

@@ -1,1 +0,1 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.GetInAppTCDataCommand=void 0;const GetTCDataCommand_js_1=require("./GetTCDataCommand.js"),index_js_1=require("../response/index.js");class GetInAppTCDataCommand extends GetTCDataCommand_js_1.GetTCDataCommand{respond(){this.throwIfParamInvalid(),this.invokeCallback(new index_js_1.InAppTCData(this.param))}}exports.GetInAppTCDataCommand=GetInAppTCDataCommand;
"use strict";var __extends=this&&this.__extends||function(){var t=function(n,e){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])})(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function o(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(o.prototype=e.prototype,new o)}}();Object.defineProperty(exports,"__esModule",{value:!0}),exports.GetInAppTCDataCommand=void 0;var GetTCDataCommand_js_1=require("./GetTCDataCommand.js"),index_js_1=require("../response/index.js"),GetInAppTCDataCommand=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return __extends(n,t),n.prototype.respond=function(){this.throwIfParamInvalid(),this.invokeCallback(new index_js_1.InAppTCData(this.param))},n}(GetTCDataCommand_js_1.GetTCDataCommand);exports.GetInAppTCDataCommand=GetInAppTCDataCommand;

@@ -1,1 +0,1 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.GetTCDataCommand=void 0;const Command_js_1=require("./Command.js"),index_js_1=require("../response/index.js");class GetTCDataCommand extends Command_js_1.Command{respond(){this.throwIfParamInvalid(),this.invokeCallback(new index_js_1.TCData(this.param,this.listenerId))}throwIfParamInvalid(){if(!(void 0===this.param||Array.isArray(this.param)&&this.param.every(Number.isInteger)))throw new Error("Invalid Parameter")}}exports.GetTCDataCommand=GetTCDataCommand;
"use strict";var __extends=this&&this.__extends||function(){var t=function(r,e){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,r){t.__proto__=r}||function(t,r){for(var e in r)Object.prototype.hasOwnProperty.call(r,e)&&(t[e]=r[e])})(r,e)};return function(r,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=r}t(r,e),r.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}();Object.defineProperty(exports,"__esModule",{value:!0}),exports.GetTCDataCommand=void 0;var Command_js_1=require("./Command.js"),index_js_1=require("../response/index.js"),GetTCDataCommand=function(t){function r(){return null!==t&&t.apply(this,arguments)||this}return __extends(r,t),r.prototype.respond=function(){this.throwIfParamInvalid(),this.invokeCallback(new index_js_1.TCData(this.param,this.listenerId))},r.prototype.throwIfParamInvalid=function(){if(!(void 0===this.param||Array.isArray(this.param)&&this.param.every(Number.isInteger)))throw new Error("Invalid Parameter")},r}(Command_js_1.Command);exports.GetTCDataCommand=GetTCDataCommand;

@@ -1,1 +0,1 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.GetVendorListCommand=void 0;const CmpApiModel_js_1=require("../CmpApiModel.js"),Command_js_1=require("./Command.js"),core_1=require("@iabtcf/core");class GetVendorListCommand extends Command_js_1.Command{respond(){const e=CmpApiModel_js_1.CmpApiModel.tcModel,o=e.vendorListVersion;let s;void 0===this.param&&(this.param=o),s=this.param===o&&e.gvl?e.gvl:new core_1.GVL(this.param),s.readyPromise.then(()=>{this.invokeCallback(s.getJson())})}}exports.GetVendorListCommand=GetVendorListCommand;
"use strict";var __extends=this&&this.__extends||function(){var t=function(e,o){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o])})(e,o)};return function(e,o){if("function"!=typeof o&&null!==o)throw new TypeError("Class extends value "+String(o)+" is not a constructor or null");function r(){this.constructor=e}t(e,o),e.prototype=null===o?Object.create(o):(r.prototype=o.prototype,new r)}}();Object.defineProperty(exports,"__esModule",{value:!0}),exports.GetVendorListCommand=void 0;var CmpApiModel_js_1=require("../CmpApiModel.js"),Command_js_1=require("./Command.js"),core_1=require("@iabtcf/core"),GetVendorListCommand=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.respond=function(){var t,e=this,o=CmpApiModel_js_1.CmpApiModel.tcModel,r=o.vendorListVersion;void 0===this.param&&(this.param=r),(t=this.param===r&&o.gvl?o.gvl:new core_1.GVL(this.param)).readyPromise.then((function(){e.invokeCallback(t.getJson())}))},e}(Command_js_1.Command);exports.GetVendorListCommand=GetVendorListCommand;

@@ -1,1 +0,1 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.PingCommand=void 0;const index_js_1=require("../response/index.js"),Command_js_1=require("./Command.js");class PingCommand extends Command_js_1.Command{respond(){this.invokeCallback(new index_js_1.Ping)}}exports.PingCommand=PingCommand;
"use strict";var __extends=this&&this.__extends||function(){var n=function(t,o){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(n[o]=t[o])})(t,o)};return function(t,o){if("function"!=typeof o&&null!==o)throw new TypeError("Class extends value "+String(o)+" is not a constructor or null");function e(){this.constructor=t}n(t,o),t.prototype=null===o?Object.create(o):(e.prototype=o.prototype,new e)}}();Object.defineProperty(exports,"__esModule",{value:!0}),exports.PingCommand=void 0;var index_js_1=require("../response/index.js"),Command_js_1=require("./Command.js"),PingCommand=function(n){function t(){return null!==n&&n.apply(this,arguments)||this}return __extends(t,n),t.prototype.respond=function(){this.invokeCallback(new index_js_1.Ping)},t}(Command_js_1.Command);exports.PingCommand=PingCommand;

@@ -1,1 +0,1 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.RemoveEventListenerCommand=void 0;const CmpApiModel_js_1=require("../CmpApiModel.js"),Command_js_1=require("./Command.js");class RemoveEventListenerCommand extends Command_js_1.Command{respond(){this.invokeCallback(CmpApiModel_js_1.CmpApiModel.eventQueue.remove(this.param))}}exports.RemoveEventListenerCommand=RemoveEventListenerCommand;
"use strict";var __extends=this&&this.__extends||function(){var e=function(t,o){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])})(t,o)};return function(t,o){if("function"!=typeof o&&null!==o)throw new TypeError("Class extends value "+String(o)+" is not a constructor or null");function n(){this.constructor=t}e(t,o),t.prototype=null===o?Object.create(o):(n.prototype=o.prototype,new n)}}();Object.defineProperty(exports,"__esModule",{value:!0}),exports.RemoveEventListenerCommand=void 0;var CmpApiModel_js_1=require("../CmpApiModel.js"),Command_js_1=require("./Command.js"),RemoveEventListenerCommand=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t.prototype.respond=function(){this.invokeCallback(CmpApiModel_js_1.CmpApiModel.eventQueue.remove(this.param))},t}(Command_js_1.Command);exports.RemoveEventListenerCommand=RemoveEventListenerCommand;

@@ -1,1 +0,1 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.EventListenerQueue=void 0;const GetTCDataCommand_js_1=require("./command/GetTCDataCommand.js");class EventListenerQueue{constructor(){this.eventQueue=new Map,this.queueNumber=0}add(e){return this.eventQueue.set(this.queueNumber,e),this.queueNumber++}remove(e){return this.eventQueue.delete(e)}exec(){this.eventQueue.forEach((e,t)=>{new GetTCDataCommand_js_1.GetTCDataCommand(e.callback,e.param,t,e.next)})}clear(){this.queueNumber=0,this.eventQueue.clear()}get size(){return this.eventQueue.size}}exports.EventListenerQueue=EventListenerQueue;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.EventListenerQueue=void 0;var GetTCDataCommand_js_1=require("./command/GetTCDataCommand.js"),EventListenerQueue=function(){function e(){this.eventQueue=new Map,this.queueNumber=0}return e.prototype.add=function(e){return this.eventQueue.set(this.queueNumber,e),this.queueNumber++},e.prototype.remove=function(e){return this.eventQueue.delete(e)},e.prototype.exec=function(){this.eventQueue.forEach((function(e,t){new GetTCDataCommand_js_1.GetTCDataCommand(e.callback,e.param,t,e.next)}))},e.prototype.clear=function(){this.queueNumber=0,this.eventQueue.clear()},Object.defineProperty(e.prototype,"size",{get:function(){return this.eventQueue.size},enumerable:!1,configurable:!0}),e}();exports.EventListenerQueue=EventListenerQueue;

@@ -1,1 +0,1 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Disabled=void 0;const Response_js_1=require("./Response.js"),index_js_1=require("../status/index.js");class Disabled extends Response_js_1.Response{constructor(){super(...arguments),this.cmpStatus=index_js_1.CmpStatus.ERROR}}exports.Disabled=Disabled;
"use strict";var __extends=this&&this.__extends||function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();Object.defineProperty(exports,"__esModule",{value:!0}),exports.Disabled=void 0;var Response_js_1=require("./Response.js"),index_js_1=require("../status/index.js"),Disabled=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.cmpStatus=index_js_1.CmpStatus.ERROR,e}return __extends(e,t),e}(Response_js_1.Response);exports.Disabled=Disabled;

@@ -1,1 +0,1 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.InAppTCData=void 0;const TCData_js_1=require("./TCData.js");class InAppTCData extends TCData_js_1.TCData{constructor(t){super(t),delete this.outOfBand}createVectorField(t){return[...t].reduce((t,e)=>t+=e[1]?"1":"0","")}createRestrictions(t){const e={};if(t.numRestrictions>0){const r=t.getMaxVendorId();t.getRestrictions().forEach(t=>{e[t.purposeId.toString()]="_".repeat(r)});for(let s=0;s<r;s++){const r=s+1;t.getRestrictions(r).forEach(t=>{const r=t.restrictionType.toString(),o=t.purposeId.toString(),a=e[o].substr(0,s),n=e[o].substr(s+1);e[o]=a+r+n})}}return e}}exports.InAppTCData=InAppTCData;
"use strict";var __extends=this&&this.__extends||function(){var t=function(r,e){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,r){t.__proto__=r}||function(t,r){for(var e in r)Object.prototype.hasOwnProperty.call(r,e)&&(t[e]=r[e])})(r,e)};return function(r,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=r}t(r,e),r.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),__read=this&&this.__read||function(t,r){var e="function"==typeof Symbol&&t[Symbol.iterator];if(!e)return t;var n,o,a=e.call(t),i=[];try{for(;(void 0===r||r-- >0)&&!(n=a.next()).done;)i.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(e=a.return)&&e.call(a)}finally{if(o)throw o.error}}return i},__spreadArray=this&&this.__spreadArray||function(t,r,e){if(e||2===arguments.length)for(var n,o=0,a=r.length;o<a;o++)!n&&o in r||(n||(n=Array.prototype.slice.call(r,0,o)),n[o]=r[o]);return t.concat(n||Array.prototype.slice.call(r))};Object.defineProperty(exports,"__esModule",{value:!0}),exports.InAppTCData=void 0;var TCData_js_1=require("./TCData.js"),InAppTCData=function(t){function r(r){var e=t.call(this,r)||this;return delete e.outOfBand,e}return __extends(r,t),r.prototype.createVectorField=function(t){return __spreadArray([],__read(t),!1).reduce((function(t,r){return t+=r[1]?"1":"0"}),"")},r.prototype.createRestrictions=function(t){var r={};if(t.numRestrictions>0){var e=t.getMaxVendorId();t.getRestrictions().forEach((function(t){r[t.purposeId.toString()]="_".repeat(e)}));for(var n=function(e){var n=e+1;t.getRestrictions(n).forEach((function(t){var n=t.restrictionType.toString(),o=t.purposeId.toString(),a=r[o].substr(0,e),i=r[o].substr(e+1);r[o]=a+n+i}))},o=0;o<e;o++)n(o)}return r},r}(TCData_js_1.TCData);exports.InAppTCData=InAppTCData;

@@ -1,1 +0,1 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Ping=void 0;const CmpApiModel_js_1=require("../CmpApiModel.js"),Response_js_1=require("./Response.js");class Ping extends Response_js_1.Response{constructor(){super(),this.cmpLoaded=!0,this.cmpStatus=CmpApiModel_js_1.CmpApiModel.cmpStatus,this.displayStatus=CmpApiModel_js_1.CmpApiModel.displayStatus,this.apiVersion=String(CmpApiModel_js_1.CmpApiModel.apiVersion),CmpApiModel_js_1.CmpApiModel.tcModel&&CmpApiModel_js_1.CmpApiModel.tcModel.vendorListVersion&&(this.gvlVersion=+CmpApiModel_js_1.CmpApiModel.tcModel.vendorListVersion)}}exports.Ping=Ping;
"use strict";var __extends=this&&this.__extends||function(){var e=function(o,t){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,o){e.__proto__=o}||function(e,o){for(var t in o)Object.prototype.hasOwnProperty.call(o,t)&&(e[t]=o[t])})(o,t)};return function(o,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function p(){this.constructor=o}e(o,t),o.prototype=null===t?Object.create(t):(p.prototype=t.prototype,new p)}}();Object.defineProperty(exports,"__esModule",{value:!0}),exports.Ping=void 0;var CmpApiModel_js_1=require("../CmpApiModel.js"),Response_js_1=require("./Response.js"),Ping=function(e){function o(){var o=e.call(this)||this;return o.cmpLoaded=!0,o.cmpStatus=CmpApiModel_js_1.CmpApiModel.cmpStatus,o.displayStatus=CmpApiModel_js_1.CmpApiModel.displayStatus,o.apiVersion=String(CmpApiModel_js_1.CmpApiModel.apiVersion),CmpApiModel_js_1.CmpApiModel.tcModel&&CmpApiModel_js_1.CmpApiModel.tcModel.vendorListVersion&&(o.gvlVersion=+CmpApiModel_js_1.CmpApiModel.tcModel.vendorListVersion),o}return __extends(o,e),o}(Response_js_1.Response);exports.Ping=Ping;

@@ -1,1 +0,1 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Response=void 0;const CmpApiModel_js_1=require("../CmpApiModel.js");class Response{constructor(){this.cmpId=CmpApiModel_js_1.CmpApiModel.cmpId,this.cmpVersion=CmpApiModel_js_1.CmpApiModel.cmpVersion,this.gdprApplies=CmpApiModel_js_1.CmpApiModel.gdprApplies,this.tcfPolicyVersion=CmpApiModel_js_1.CmpApiModel.tcfPolicyVersion}}exports.Response=Response;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Response=void 0;var CmpApiModel_js_1=require("../CmpApiModel.js"),Response=function(){this.cmpId=CmpApiModel_js_1.CmpApiModel.cmpId,this.cmpVersion=CmpApiModel_js_1.CmpApiModel.cmpVersion,this.gdprApplies=CmpApiModel_js_1.CmpApiModel.gdprApplies,this.tcfPolicyVersion=CmpApiModel_js_1.CmpApiModel.tcfPolicyVersion};exports.Response=Response;

@@ -1,1 +0,1 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.TCData=void 0;const CmpApiModel_js_1=require("../CmpApiModel.js"),Response_js_1=require("./Response.js");class TCData extends Response_js_1.Response{constructor(e,t){if(super(),this.eventStatus=CmpApiModel_js_1.CmpApiModel.eventStatus,this.cmpStatus=CmpApiModel_js_1.CmpApiModel.cmpStatus,this.listenerId=t,CmpApiModel_js_1.CmpApiModel.gdprApplies){const t=CmpApiModel_js_1.CmpApiModel.tcModel;this.tcString=CmpApiModel_js_1.CmpApiModel.tcString,this.isServiceSpecific=t.isServiceSpecific,this.useNonStandardStacks=t.useNonStandardStacks,this.purposeOneTreatment=t.purposeOneTreatment,this.publisherCC=t.publisherCountryCode,this.outOfBand={allowedVendors:this.createVectorField(t.vendorsAllowed,e),disclosedVendors:this.createVectorField(t.vendorsDisclosed,e)},this.purpose={consents:this.createVectorField(t.purposeConsents),legitimateInterests:this.createVectorField(t.purposeLegitimateInterests)},this.vendor={consents:this.createVectorField(t.vendorConsents,e),legitimateInterests:this.createVectorField(t.vendorLegitimateInterests,e)},this.specialFeatureOptins=this.createVectorField(t.specialFeatureOptins),this.publisher={consents:this.createVectorField(t.publisherConsents),legitimateInterests:this.createVectorField(t.publisherLegitimateInterests),customPurpose:{consents:this.createVectorField(t.publisherCustomConsents),legitimateInterests:this.createVectorField(t.publisherCustomLegitimateInterests)},restrictions:this.createRestrictions(t.publisherRestrictions)}}}createRestrictions(e){const t={};if(e.numRestrictions>0){const s=e.getMaxVendorId();for(let i=1;i<=s;i++){const s=i.toString();e.getRestrictions(i).forEach(e=>{const i=e.purposeId.toString();t[i]||(t[i]={}),t[i][s]=e.restrictionType})}}return t}createVectorField(e,t){return t?t.reduce((t,s)=>(t[String(s)]=e.has(Number(s)),t),{}):[...e].reduce((e,t)=>(e[t[0].toString(10)]=t[1],e),{})}}exports.TCData=TCData;
"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 o(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(o.prototype=r.prototype,new o)}}(),__read=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var o,n,s=r.call(e),i=[];try{for(;(void 0===t||t-- >0)&&!(o=s.next()).done;)i.push(o.value)}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}return i},__spreadArray=this&&this.__spreadArray||function(e,t,r){if(r||2===arguments.length)for(var o,n=0,s=t.length;n<s;n++)!o&&n in t||(o||(o=Array.prototype.slice.call(t,0,n)),o[n]=t[n]);return e.concat(o||Array.prototype.slice.call(t))};Object.defineProperty(exports,"__esModule",{value:!0}),exports.TCData=void 0;var CmpApiModel_js_1=require("../CmpApiModel.js"),Response_js_1=require("./Response.js"),TCData=function(e){function t(t,r){var o=e.call(this)||this;if(o.eventStatus=CmpApiModel_js_1.CmpApiModel.eventStatus,o.cmpStatus=CmpApiModel_js_1.CmpApiModel.cmpStatus,o.listenerId=r,CmpApiModel_js_1.CmpApiModel.gdprApplies){var n=CmpApiModel_js_1.CmpApiModel.tcModel;o.tcString=CmpApiModel_js_1.CmpApiModel.tcString,o.isServiceSpecific=n.isServiceSpecific,o.useNonStandardStacks=n.useNonStandardStacks,o.purposeOneTreatment=n.purposeOneTreatment,o.publisherCC=n.publisherCountryCode,o.outOfBand={allowedVendors:o.createVectorField(n.vendorsAllowed,t),disclosedVendors:o.createVectorField(n.vendorsDisclosed,t)},o.purpose={consents:o.createVectorField(n.purposeConsents),legitimateInterests:o.createVectorField(n.purposeLegitimateInterests)},o.vendor={consents:o.createVectorField(n.vendorConsents,t),legitimateInterests:o.createVectorField(n.vendorLegitimateInterests,t)},o.specialFeatureOptins=o.createVectorField(n.specialFeatureOptins),o.publisher={consents:o.createVectorField(n.publisherConsents),legitimateInterests:o.createVectorField(n.publisherLegitimateInterests),customPurpose:{consents:o.createVectorField(n.publisherCustomConsents),legitimateInterests:o.createVectorField(n.publisherCustomLegitimateInterests)},restrictions:o.createRestrictions(n.publisherRestrictions)}}return o}return __extends(t,e),t.prototype.createRestrictions=function(e){var t={};if(e.numRestrictions>0)for(var r=e.getMaxVendorId(),o=function(r){var o=r.toString();e.getRestrictions(r).forEach((function(e){var r=e.purposeId.toString();t[r]||(t[r]={}),t[r][o]=e.restrictionType}))},n=1;n<=r;n++)o(n);return t},t.prototype.createVectorField=function(e,t){return t?t.reduce((function(t,r){return t[String(r)]=e.has(Number(r)),t}),{}):__spreadArray([],__read(e),!1).reduce((function(e,t){return e[t[0].toString(10)]=t[1],e}),{})},t}(Response_js_1.Response);exports.TCData=TCData;

@@ -1,1 +0,1 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SupportedVersions=void 0;class SupportedVersions{static has(e){return"string"==typeof e&&(e=Number(e)),this.set_.has(e)}}exports.SupportedVersions=SupportedVersions,SupportedVersions.set_=new Set([0,2,void 0,null]);
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SupportedVersions=void 0;var SupportedVersions=function(){function e(){}return e.has=function(e){return"string"==typeof e&&(e=Number(e)),this.set_.has(e)},e.set_=new Set([0,2,void 0,null]),e}();exports.SupportedVersions=SupportedVersions;
{
"name": "@iabtcf/cmpapi",
"version": "1.5.3",
"version": "1.5.4-0",
"description": "Ensures other in-page digital marketing technologies have access to CMP transparency and consent information for the iab. Transparency and Consent Framework (TCF).",

@@ -34,4 +34,4 @@ "author": "Chris Paterson <tcf@chrispaterson.io>",

"devDependencies": {
"@iabtcf/stub": "1.5.3",
"@iabtcf/testing": "1.5.3",
"@iabtcf/stub": "1.5.4-0",
"@iabtcf/testing": "1.5.4-0",
"@istanbuljs/nyc-config-typescript": "^0.1.3",

@@ -50,3 +50,3 @@ "@types/mocha": "^9.1.0",

"jscover": "^1.0.0",
"jsdom": "15.1.1",
"jsdom": "16.5.0",
"jsdom-global": "3.0.2",

@@ -60,3 +60,3 @@ "mocha": "^9.2.0",

"source-map-support": "^0.5.12",
"terser": "^4.6.3",
"terser": "^4.8.1",
"ts-node": "^10.5.0",

@@ -63,0 +63,0 @@ "typedoc": "^0.22.11",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc