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

@iabtcf/cmpapi

Package Overview
Dependencies
Maintainers
1
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.1.0-0 to 1.1.0-1

2

lib/CallResponder.js

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

"use strict";var __read=this&&this.__read||function(o,e){var n="function"==typeof Symbol&&o[Symbol.iterator];if(!n)return o;var t,a,i=n.call(o),s=[];try{for(;(void 0===e||e-- >0)&&!(t=i.next()).done;)s.push(t.value)}catch(o){a={error:o}}finally{try{t&&!t.done&&(n=i.return)&&n.call(i)}finally{if(a)throw a.error}}return s},__spread=this&&this.__spread||function(){for(var o=[],e=0;e<arguments.length;e++)o=o.concat(__read(arguments[e]));return o};Object.defineProperty(exports,"__esModule",{value:!0});var command_1=require("./command"),CommandMap_1=require("./command/CommandMap"),CmpApiModel_1=require("./CmpApiModel"),Disabled_1=require("./response/Disabled"),SupportedVersions_1=require("./SupportedVersions");exports.API_KEY="__tcfapi";var CallResponder=function(){function o(o){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,e,n){for(var t,a=[],i=3;i<arguments.length;i++)a[i-3]=arguments[i];if("string"!=typeof o)n(null,!1);else if(SupportedVersions_1.SupportedVersions.has(e)){if("function"!=typeof n)throw new Error("invalid callback function");CmpApiModel_1.CmpApiModel.disabled?n(new Disabled_1.Disabled,!1):this.isCustomCommand(o)||this.isBuiltInCommand(o)?this.isCustomCommand(o)&&!this.isBuiltInCommand(o)?(t=this.customCommands)[o].apply(t,__spread([n],a)):o===command_1.TCFCommand.PING?this.isCustomCommand(o)?new CommandMap_1.CommandMap[o](this.customCommands[o],a[0],null,n):new CommandMap_1.CommandMap[o](n,a[0]):CmpApiModel_1.CmpApiModel.tcModel?this.isCustomCommand(o)&&this.isBuiltInCommand(o)?new CommandMap_1.CommandMap[o](this.customCommands[o],a[0],null,n):new CommandMap_1.CommandMap[o](n,a[0]):this.callQueue.push(__spread([o,e,n],a)):n(null,!1)}else n(null,!1)},o.prototype.purgeQueuedCalls=function(){var o=this.apiCall.bind(this),e=this.callQueue;this.callQueue=[],e.forEach((function(e){o.apply(void 0,__spread(e))}))},o.prototype.isCustomCommand=function(o){return this.customCommands&&"function"==typeof this.customCommands[o]},o.prototype.isBuiltInCommand=function(o){return void 0!==CommandMap_1.CommandMap[o]},o}();exports.CallResponder=CallResponder;
"use strict";var __read=this&&this.__read||function(o,e){var n="function"==typeof Symbol&&o[Symbol.iterator];if(!n)return o;var t,a,i=n.call(o),s=[];try{for(;(void 0===e||e-- >0)&&!(t=i.next()).done;)s.push(t.value)}catch(o){a={error:o}}finally{try{t&&!t.done&&(n=i.return)&&n.call(i)}finally{if(a)throw a.error}}return s},__spread=this&&this.__spread||function(){for(var o=[],e=0;e<arguments.length;e++)o=o.concat(__read(arguments[e]));return o};Object.defineProperty(exports,"__esModule",{value:!0});var command_1=require("./command"),CommandMap_1=require("./command/CommandMap"),CmpApiModel_1=require("./CmpApiModel"),Disabled_1=require("./response/Disabled"),SupportedVersions_1=require("./SupportedVersions");exports.API_KEY="__tcfapi";var CallResponder=function(){function o(o){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,e,n){for(var t,a=[],i=3;i<arguments.length;i++)a[i-3]=arguments[i];if("string"!=typeof o)n(null,!1);else if(SupportedVersions_1.SupportedVersions.has(e)){if("function"!=typeof n)throw new Error("invalid callback function");CmpApiModel_1.CmpApiModel.disabled?n(new Disabled_1.Disabled,!1):this.isCustomCommand(o)||this.isBuiltInCommand(o)?this.isCustomCommand(o)&&!this.isBuiltInCommand(o)?(t=this.customCommands)[o].apply(t,__spread([n],a)):o===command_1.TCFCommand.PING?this.isCustomCommand(o)?new CommandMap_1.CommandMap[o](this.customCommands[o],a[0],null,n):new CommandMap_1.CommandMap[o](n,a[0]):void 0===CmpApiModel_1.CmpApiModel.tcModel?this.callQueue.push(__spread([o,e,n],a)):this.isCustomCommand(o)&&this.isBuiltInCommand(o)?new CommandMap_1.CommandMap[o](this.customCommands[o],a[0],null,n):new CommandMap_1.CommandMap[o](n,a[0]):n(null,!1)}else n(null,!1)},o.prototype.purgeQueuedCalls=function(){var o=this.apiCall.bind(this),e=this.callQueue;this.callQueue=[],e.forEach((function(e){o.apply(void 0,__spread(e))}))},o.prototype.isCustomCommand=function(o){return this.customCommands&&"function"==typeof this.customCommands[o]},o.prototype.isBuiltInCommand=function(o){return void 0!==CommandMap_1.CommandMap[o]},o}();exports.CallResponder=CallResponder;
{
"name": "@iabtcf/cmpapi",
"version": "1.1.0-0",
"version": "1.1.0-1",
"description": "Ensures other in-page digital marketing technologies have access to CMP transparency and consent information for the iab. Transparency and Consent Framework (TCF).",

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

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

@@ -31,0 +31,0 @@ "@types/mocha": "^5.2.7",

@@ -139,3 +139,3 @@ [![NPM version](https://img.shields.io/npm/v/@iabtcf/cmpapi.svg?style=flat-square)](https://www.npmjs.com/package/@iabtcf/cmpapi)

### Example
**Example**
````javascript

@@ -182,1 +182,29 @@

````
### Built-In and Custom Commands
Beginning in 1.1.0, if a custom command is defined that overlaps with a built-in command (`"ping"`, `"getTCData"`, `"getInAppTCData"`, `"getVendorList"`) then the custom command will act as a "middleware" being passed the built-in command's response and expected to pass along the response when finished.
**Example**
````javascript
import {CmpApi} from '@iabtcf/cmpapi';
const cmpApi = new CmpApi(1, 3, false, {
'getTCData': (next, tcData) => {
// tcData will be constructed via the TC string and can be added to here
tcData.reallyImportantExtraProperty = true;
// pass data along
next(tcData);
},
});
````
**Note**: If the `next()` function is not called with the `TCData` object, then the caller's callback will not be executed.
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