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

consent-string

Package Overview
Dependencies
Maintainers
2
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

consent-string - npm Package Compare versions

Comparing version 1.2.3 to 1.2.4

191

dist/consent-string.js

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

'use strict';
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };

@@ -5,2 +7,147 @@

var _arrayFrom = Array.from || function () {
var isCallable = function isCallable(fn) {
return typeof fn === 'function';
};
var toInteger = function toInteger(value) {
var number = Number(value);
if (isNaN(number)) {
return 0;
}
if (number === 0 || !isFinite(number)) {
return number;
}
return (number > 0 ? 1 : -1) * Math.floor(Math.abs(number));
};
var maxSafeInteger = Math.pow(2, 53) - 1;
var toLength = function toLength(value) {
var len = toInteger(value);
return Math.min(Math.max(len, 0), maxSafeInteger);
};
var iteratorProp = function iteratorProp(value) {
if (value != null) {
if (['string', 'number', 'boolean', 'symbol'].indexOf(typeof value === 'undefined' ? 'undefined' : _typeof(value)) > -1) {
return Symbol.iterator;
} else if (typeof Symbol !== 'undefined' && 'iterator' in Symbol && Symbol.iterator in value) {
return Symbol.iterator;
} else if ('@@iterator' in value) {
return '@@iterator';
}
}
};
var getMethod = function getMethod(O, P) {
if (O != null && P != null) {
var func = O[P];
if (func == null) {
return void 0;
}
if (!isCallable(func)) {
throw new TypeError(func + " is not a function");
}
return func;
}
};
var iteratorStep = function iteratorStep(iterator) {
var result = iterator.next();
var done = Boolean(result.done);
if (done) {
return false;
}
return result;
};
return function from(items) {
"use strict";
var C = this;
var mapFn = arguments.length > 1 ? arguments[1] : void 0;
var T;
if (typeof mapFn !== 'undefined') {
if (!isCallable(mapFn)) {
throw new TypeError('Array.from: when provided, the second argument must be a function');
}
if (arguments.length > 2) {
T = arguments[2];
}
}
var A, k;
var usingIterator = getMethod(items, iteratorProp(items));
if (usingIterator !== void 0) {
A = isCallable(C) ? Object(new C()) : [];
var iterator = usingIterator.call(items);
if (iterator == null) {
throw new TypeError("Array.from requires an array-like or iterable object");
}
k = 0;
var next, nextValue;
while (true) {
next = iteratorStep(iterator);
if (!next) {
A.length = k;
return A;
}
nextValue = next.value;
if (mapFn) {
A[k] = mapFn.call(T, nextValue, k);
} else {
A[k] = nextValue;
}
k++;
}
} else {
var arrayLike = Object(items);
if (items == null) {
throw new TypeError("Array.from requires an array-like object - not null or undefined");
}
var len = toLength(arrayLike.length);
A = isCallable(C) ? Object(new C(len)) : new Array(len);
k = 0;
var kValue;
while (k < len) {
kValue = arrayLike[k];
if (mapFn) {
A[k] = mapFn.call(T, kValue, k);
} else {
A[k] = kValue;
}
k++;
}
A.length = len;
}
return A;
};
}();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

@@ -14,2 +161,5 @@

var _require3 = require('./utils/definitions'),
vendorVersionMap = _require3.vendorVersionMap;
/**

@@ -141,9 +291,36 @@ * Regular expression for validating

/**
* Get the version number that this consent string specification adheres to
* Get the web-safe, base64-encoded metadata string
*
* @return {integer} Version number of consent string specification
* @return {string} Web-safe, base64-encoded metadata string
*/
}, {
key: 'getMetadataString',
value: function getMetadataString() {
return encodeConsentString({
version: this.getVersion(),
created: this.created,
lastUpdated: this.lastUpdated,
cmpId: this.cmpId,
cmpVersion: this.cmpVersion,
consentScreen: this.consentScreen,
vendorListVersion: this.vendorListVersion
});
}
/**
* Decode the web-safe, base64-encoded metadata string
* @param {string} encodedMetadata Web-safe, base64-encoded metadata string
* @return {object} decoded metadata
*/
}, {
key: 'getVersion',
/**
* Get the version number that this consent string specification adheres to
*
* @return {integer} Version number of consent string specification
*/
value: function getVersion() {

@@ -428,2 +605,12 @@ return this.version;

}
}], [{
key: 'decodeMetadataString',
value: function decodeMetadataString(encodedMetadata) {
var decodedString = decodeConsentString(encodedMetadata);
var metadata = {};
vendorVersionMap[decodedString.version].metadataFields.forEach(function (field) {
metadata[field] = decodedString[field];
});
return metadata;
}
}]);

@@ -430,0 +617,0 @@

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

'use strict';
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
var _arrayFrom = Array.from || function () {
var isCallable = function isCallable(fn) {
return typeof fn === 'function';
};
var toInteger = function toInteger(value) {
var number = Number(value);
if (isNaN(number)) {
return 0;
}
if (number === 0 || !isFinite(number)) {
return number;
}
return (number > 0 ? 1 : -1) * Math.floor(Math.abs(number));
};
var maxSafeInteger = Math.pow(2, 53) - 1;
var toLength = function toLength(value) {
var len = toInteger(value);
return Math.min(Math.max(len, 0), maxSafeInteger);
};
var iteratorProp = function iteratorProp(value) {
if (value != null) {
if (['string', 'number', 'boolean', 'symbol'].indexOf(typeof value === 'undefined' ? 'undefined' : _typeof(value)) > -1) {
return Symbol.iterator;
} else if (typeof Symbol !== 'undefined' && 'iterator' in Symbol && Symbol.iterator in value) {
return Symbol.iterator;
} else if ('@@iterator' in value) {
return '@@iterator';
}
}
};
var getMethod = function getMethod(O, P) {
if (O != null && P != null) {
var func = O[P];
if (func == null) {
return void 0;
}
if (!isCallable(func)) {
throw new TypeError(func + " is not a function");
}
return func;
}
};
var iteratorStep = function iteratorStep(iterator) {
var result = iterator.next();
var done = Boolean(result.done);
if (done) {
return false;
}
return result;
};
return function from(items) {
"use strict";
var C = this;
var mapFn = arguments.length > 1 ? arguments[1] : void 0;
var T;
if (typeof mapFn !== 'undefined') {
if (!isCallable(mapFn)) {
throw new TypeError('Array.from: when provided, the second argument must be a function');
}
if (arguments.length > 2) {
T = arguments[2];
}
}
var A, k;
var usingIterator = getMethod(items, iteratorProp(items));
if (usingIterator !== void 0) {
A = isCallable(C) ? Object(new C()) : [];
var iterator = usingIterator.call(items);
if (iterator == null) {
throw new TypeError("Array.from requires an array-like or iterable object");
}
k = 0;
var next, nextValue;
while (true) {
next = iteratorStep(iterator);
if (!next) {
A.length = k;
return A;
}
nextValue = next.value;
if (mapFn) {
A[k] = mapFn.call(T, nextValue, k);
} else {
A[k] = nextValue;
}
k++;
}
} else {
var arrayLike = Object(items);
if (items == null) {
throw new TypeError("Array.from requires an array-like object - not null or undefined");
}
var len = toLength(arrayLike.length);
A = isCallable(C) ? Object(new C(len)) : new Array(len);
k = 0;
var kValue;
while (k < len) {
kValue = arrayLike[k];
if (mapFn) {
A[k] = mapFn.call(T, kValue, k);
} else {
A[k] = kValue;
}
k++;
}
A.length = len;
}
return A;
};
}();
var _require = require('./utils/bits'),

@@ -2,0 +151,0 @@ decodeBitsToIds = _require.decodeBitsToIds,

@@ -0,5 +1,154 @@

'use strict';
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
var _arrayFrom = Array.from || function () {
var isCallable = function isCallable(fn) {
return typeof fn === 'function';
};
var toInteger = function toInteger(value) {
var number = Number(value);
if (isNaN(number)) {
return 0;
}
if (number === 0 || !isFinite(number)) {
return number;
}
return (number > 0 ? 1 : -1) * Math.floor(Math.abs(number));
};
var maxSafeInteger = Math.pow(2, 53) - 1;
var toLength = function toLength(value) {
var len = toInteger(value);
return Math.min(Math.max(len, 0), maxSafeInteger);
};
var iteratorProp = function iteratorProp(value) {
if (value != null) {
if (['string', 'number', 'boolean', 'symbol'].indexOf(typeof value === 'undefined' ? 'undefined' : _typeof(value)) > -1) {
return Symbol.iterator;
} else if (typeof Symbol !== 'undefined' && 'iterator' in Symbol && Symbol.iterator in value) {
return Symbol.iterator;
} else if ('@@iterator' in value) {
return '@@iterator';
}
}
};
var getMethod = function getMethod(O, P) {
if (O != null && P != null) {
var func = O[P];
if (func == null) {
return void 0;
}
if (!isCallable(func)) {
throw new TypeError(func + " is not a function");
}
return func;
}
};
var iteratorStep = function iteratorStep(iterator) {
var result = iterator.next();
var done = Boolean(result.done);
if (done) {
return false;
}
return result;
};
return function from(items) {
"use strict";
var C = this;
var mapFn = arguments.length > 1 ? arguments[1] : void 0;
var T;
if (typeof mapFn !== 'undefined') {
if (!isCallable(mapFn)) {
throw new TypeError('Array.from: when provided, the second argument must be a function');
}
if (arguments.length > 2) {
T = arguments[2];
}
}
var A, k;
var usingIterator = getMethod(items, iteratorProp(items));
if (usingIterator !== void 0) {
A = isCallable(C) ? Object(new C()) : [];
var iterator = usingIterator.call(items);
if (iterator == null) {
throw new TypeError("Array.from requires an array-like or iterable object");
}
k = 0;
var next, nextValue;
while (true) {
next = iteratorStep(iterator);
if (!next) {
A.length = k;
return A;
}
nextValue = next.value;
if (mapFn) {
A[k] = mapFn.call(T, nextValue, k);
} else {
A[k] = nextValue;
}
k++;
}
} else {
var arrayLike = Object(items);
if (items == null) {
throw new TypeError("Array.from requires an array-like object - not null or undefined");
}
var len = toLength(arrayLike.length);
A = isCallable(C) ? Object(new C(len)) : new Array(len);
k = 0;
var kValue;
while (k < len) {
kValue = arrayLike[k];
if (mapFn) {
A[k] = mapFn.call(T, kValue, k);
} else {
A[k] = kValue;
}
k++;
}
A.length = len;
}
return A;
};
}();
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return _arrayFrom(arr); } }
var _require = require('./utils/bits'),

@@ -41,3 +190,3 @@ encodeToBase64 = _require.encodeToBase64,

return id;
})), _toConsumableArray(Array.from(allowedPurposeIds))));
})), _toConsumableArray(_arrayFrom(allowedPurposeIds))));

@@ -44,0 +193,0 @@ var purposeString = '';

@@ -37,3 +37,5 @@ // Type definitions for consent-string

static decodeMetadataString(encodedMetadata:string): object;
public getConsentString(updateDate?:boolean): string;
public getMetadataString(): string;
public getVersion(): number;

@@ -40,0 +42,0 @@ public getVendorListVersion(): number;

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

'use strict';
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
var _arrayFrom = Array.from || function () {
var isCallable = function isCallable(fn) {
return typeof fn === 'function';
};
var toInteger = function toInteger(value) {
var number = Number(value);
if (isNaN(number)) {
return 0;
}
if (number === 0 || !isFinite(number)) {
return number;
}
return (number > 0 ? 1 : -1) * Math.floor(Math.abs(number));
};
var maxSafeInteger = Math.pow(2, 53) - 1;
var toLength = function toLength(value) {
var len = toInteger(value);
return Math.min(Math.max(len, 0), maxSafeInteger);
};
var iteratorProp = function iteratorProp(value) {
if (value != null) {
if (['string', 'number', 'boolean', 'symbol'].indexOf(typeof value === 'undefined' ? 'undefined' : _typeof(value)) > -1) {
return Symbol.iterator;
} else if (typeof Symbol !== 'undefined' && 'iterator' in Symbol && Symbol.iterator in value) {
return Symbol.iterator;
} else if ('@@iterator' in value) {
return '@@iterator';
}
}
};
var getMethod = function getMethod(O, P) {
if (O != null && P != null) {
var func = O[P];
if (func == null) {
return void 0;
}
if (!isCallable(func)) {
throw new TypeError(func + " is not a function");
}
return func;
}
};
var iteratorStep = function iteratorStep(iterator) {
var result = iterator.next();
var done = Boolean(result.done);
if (done) {
return false;
}
return result;
};
return function from(items) {
"use strict";
var C = this;
var mapFn = arguments.length > 1 ? arguments[1] : void 0;
var T;
if (typeof mapFn !== 'undefined') {
if (!isCallable(mapFn)) {
throw new TypeError('Array.from: when provided, the second argument must be a function');
}
if (arguments.length > 2) {
T = arguments[2];
}
}
var A, k;
var usingIterator = getMethod(items, iteratorProp(items));
if (usingIterator !== void 0) {
A = isCallable(C) ? Object(new C()) : [];
var iterator = usingIterator.call(items);
if (iterator == null) {
throw new TypeError("Array.from requires an array-like or iterable object");
}
k = 0;
var next, nextValue;
while (true) {
next = iteratorStep(iterator);
if (!next) {
A.length = k;
return A;
}
nextValue = next.value;
if (mapFn) {
A[k] = mapFn.call(T, nextValue, k);
} else {
A[k] = nextValue;
}
k++;
}
} else {
var arrayLike = Object(items);
if (items == null) {
throw new TypeError("Array.from requires an array-like object - not null or undefined");
}
var len = toLength(arrayLike.length);
A = isCallable(C) ? Object(new C(len)) : new Array(len);
k = 0;
var kValue;
while (k < len) {
kValue = arrayLike[k];
if (mapFn) {
A[k] = mapFn.call(T, kValue, k);
} else {
A[k] = kValue;
}
k++;
}
A.length = len;
}
return A;
};
}();
var _require = require('./consent-string'),

@@ -2,0 +151,0 @@ ConsentString = _require.ConsentString;

@@ -1,3 +0,152 @@

function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
'use strict';
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
var _arrayFrom = Array.from || function () {
var isCallable = function isCallable(fn) {
return typeof fn === 'function';
};
var toInteger = function toInteger(value) {
var number = Number(value);
if (isNaN(number)) {
return 0;
}
if (number === 0 || !isFinite(number)) {
return number;
}
return (number > 0 ? 1 : -1) * Math.floor(Math.abs(number));
};
var maxSafeInteger = Math.pow(2, 53) - 1;
var toLength = function toLength(value) {
var len = toInteger(value);
return Math.min(Math.max(len, 0), maxSafeInteger);
};
var iteratorProp = function iteratorProp(value) {
if (value != null) {
if (['string', 'number', 'boolean', 'symbol'].indexOf(typeof value === 'undefined' ? 'undefined' : _typeof(value)) > -1) {
return Symbol.iterator;
} else if (typeof Symbol !== 'undefined' && 'iterator' in Symbol && Symbol.iterator in value) {
return Symbol.iterator;
} else if ('@@iterator' in value) {
return '@@iterator';
}
}
};
var getMethod = function getMethod(O, P) {
if (O != null && P != null) {
var func = O[P];
if (func == null) {
return void 0;
}
if (!isCallable(func)) {
throw new TypeError(func + " is not a function");
}
return func;
}
};
var iteratorStep = function iteratorStep(iterator) {
var result = iterator.next();
var done = Boolean(result.done);
if (done) {
return false;
}
return result;
};
return function from(items) {
"use strict";
var C = this;
var mapFn = arguments.length > 1 ? arguments[1] : void 0;
var T;
if (typeof mapFn !== 'undefined') {
if (!isCallable(mapFn)) {
throw new TypeError('Array.from: when provided, the second argument must be a function');
}
if (arguments.length > 2) {
T = arguments[2];
}
}
var A, k;
var usingIterator = getMethod(items, iteratorProp(items));
if (usingIterator !== void 0) {
A = isCallable(C) ? Object(new C()) : [];
var iterator = usingIterator.call(items);
if (iterator == null) {
throw new TypeError("Array.from requires an array-like or iterable object");
}
k = 0;
var next, nextValue;
while (true) {
next = iteratorStep(iterator);
if (!next) {
A.length = k;
return A;
}
nextValue = next.value;
if (mapFn) {
A[k] = mapFn.call(T, nextValue, k);
} else {
A[k] = nextValue;
}
k++;
}
} else {
var arrayLike = Object(items);
if (items == null) {
throw new TypeError("Array.from requires an array-like object - not null or undefined");
}
var len = toLength(arrayLike.length);
A = isCallable(C) ? Object(new C(len)) : new Array(len);
k = 0;
var kValue;
while (k < len) {
kValue = arrayLike[k];
if (mapFn) {
A[k] = mapFn.call(T, kValue, k);
} else {
A[k] = kValue;
}
k++;
}
A.length = len;
}
return A;
};
}();
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return _arrayFrom(arr); } }
/* eslint no-use-before-define: off */

@@ -4,0 +153,0 @@

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

'use strict';
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
var _arrayFrom = Array.from || function () {
var isCallable = function isCallable(fn) {
return typeof fn === 'function';
};
var toInteger = function toInteger(value) {
var number = Number(value);
if (isNaN(number)) {
return 0;
}
if (number === 0 || !isFinite(number)) {
return number;
}
return (number > 0 ? 1 : -1) * Math.floor(Math.abs(number));
};
var maxSafeInteger = Math.pow(2, 53) - 1;
var toLength = function toLength(value) {
var len = toInteger(value);
return Math.min(Math.max(len, 0), maxSafeInteger);
};
var iteratorProp = function iteratorProp(value) {
if (value != null) {
if (['string', 'number', 'boolean', 'symbol'].indexOf(typeof value === 'undefined' ? 'undefined' : _typeof(value)) > -1) {
return Symbol.iterator;
} else if (typeof Symbol !== 'undefined' && 'iterator' in Symbol && Symbol.iterator in value) {
return Symbol.iterator;
} else if ('@@iterator' in value) {
return '@@iterator';
}
}
};
var getMethod = function getMethod(O, P) {
if (O != null && P != null) {
var func = O[P];
if (func == null) {
return void 0;
}
if (!isCallable(func)) {
throw new TypeError(func + " is not a function");
}
return func;
}
};
var iteratorStep = function iteratorStep(iterator) {
var result = iterator.next();
var done = Boolean(result.done);
if (done) {
return false;
}
return result;
};
return function from(items) {
"use strict";
var C = this;
var mapFn = arguments.length > 1 ? arguments[1] : void 0;
var T;
if (typeof mapFn !== 'undefined') {
if (!isCallable(mapFn)) {
throw new TypeError('Array.from: when provided, the second argument must be a function');
}
if (arguments.length > 2) {
T = arguments[2];
}
}
var A, k;
var usingIterator = getMethod(items, iteratorProp(items));
if (usingIterator !== void 0) {
A = isCallable(C) ? Object(new C()) : [];
var iterator = usingIterator.call(items);
if (iterator == null) {
throw new TypeError("Array.from requires an array-like or iterable object");
}
k = 0;
var next, nextValue;
while (true) {
next = iteratorStep(iterator);
if (!next) {
A.length = k;
return A;
}
nextValue = next.value;
if (mapFn) {
A[k] = mapFn.call(T, nextValue, k);
} else {
A[k] = nextValue;
}
k++;
}
} else {
var arrayLike = Object(items);
if (items == null) {
throw new TypeError("Array.from requires an array-like object - not null or undefined");
}
var len = toLength(arrayLike.length);
A = isCallable(C) ? Object(new C(len)) : new Array(len);
k = 0;
var kValue;
while (k < len) {
kValue = arrayLike[k];
if (mapFn) {
A[k] = mapFn.call(T, kValue, k);
} else {
A[k] = kValue;
}
k++;
}
A.length = len;
}
return A;
};
}();
/**

@@ -18,2 +167,3 @@ * Number of bits for encoding the version integer

version: 1,
metadataFields: ['version', 'created', 'lastUpdated', 'cmpId', 'cmpVersion', 'consentScreen', 'vendorListVersion'],
fields: [{ name: 'version', type: 'int', numBits: 6 }, { name: 'created', type: 'date', numBits: 36 }, { name: 'lastUpdated', type: 'date', numBits: 36 }, { name: 'cmpId', type: 'int', numBits: 12 }, { name: 'cmpVersion', type: 'int', numBits: 12 }, { name: 'consentScreen', type: 'int', numBits: 6 }, { name: 'consentLanguage', type: 'language', numBits: 12 }, { name: 'vendorListVersion', type: 'int', numBits: 12 }, { name: 'purposeIdBitString', type: 'bits', numBits: 24 }, { name: 'maxVendorId', type: 'int', numBits: 16 }, { name: 'isRange', type: 'bool', numBits: 1 }, {

@@ -20,0 +170,0 @@ name: 'vendorIdBitString',

{
"name": "consent-string",
"version": "1.2.3",
"version": "1.2.4",
"description": "Encode and decode web-safe base64 consent information with the IAB EU's GDPR Transparency and Consent Framework",

@@ -34,2 +34,9 @@ "homepage": "https://github.com/InteractiveAdvertisingBureau/Consent-String-SDK-JS",

"babel-cli": "^6.26.0",
"@59naga/babel-plugin-transform-array-from": "0.0.0",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-es2015-arrow-functions": "^6.22.0",
"babel-plugin-transform-es2015-classes": "^6.24.1",
"babel-plugin-transform-es2015-destructuring": "^6.23.0",
"babel-plugin-transform-es2015-modules-commonjs": "^6.26.2",
"babel-plugin-transform-es2015-object-super": "^6.24.1",
"babel-plugin-transform-object-rest-spread": "^6.26.0",

@@ -36,0 +43,0 @@ "babel-preset-env": "^1.6.1",

@@ -30,2 +30,13 @@ # Transparency and Consent Framework: Consent String SDK (JavaScript)

## Terms
| Term | Meaning |
| --- | --- |
| IAB | Interactive Advertising Bureau |
| TCF | Transparency and Consent Framework |
| Vendor ID | Refers to IAB EU hosted Global Vendor List id defined by the TCF |
| Consent String | Refers to IAB EU Base64 encoded bit string representing user preference in the TCF |
| CMP | "Consent Management Provider" as specified by the TCF -- ie. a javascript widget that captures users consent preferences and displays advertising information and vendors. |
| Consent Screen | CMP Screen in which consent was confirmed. A proprietary number to each CMP that is arbitrary. |
## Installation

@@ -143,4 +154,178 @@

The documentation for the API exposed by this library is available here: https://didomi.github.io/consent-string/
#### constructor
Constructs new object
```javascript
// @param str is the web-safe base64 encoded consent string or null (no parameter)
constructor( str = null )
```
---
#### getConsentString()
Gets the consent string either new one created or one passed in on construction.
```javascript
// @return web-safe base64 encoded consent string
getConsentString()
```
---
#### getMetadataString()
Gets the metadata string as defined in the response to the getVendorConsents method (ie binary string that includes only header information like consent string version, timestamps, cmp ID, etc. but no purposes/consents information).
```javascript
// @return web-safe base64 encoded metadata string
getMetadataString()
```
---
#### ConsentString.decodeMetadataString() (Static Method)
Decodes the metadata string.
```javascript
// @return object with metadata fields
ConsentString.decodeMetadataString(encodedMetadataString)
```
---
#### getVersion()
The version number in which this consent string specification adheres to
```javascript
// @return integer version number of consent string specification
getVersion()
```
---
#### getVendorListVersion()
Returns either the vendor list version set by `setGlobalVendorList` or whatever was previously set as the consent string when the object was created
```javascript
// @return integer version number of vendor list version
getVendorListVersion()
```
---
#### setGlobalVendorList( gvlObject )
Sets the global vendor list object. Generally this would be the parsed JSON that comes from the IAB hosted Global Vendor List.
```javascript
// @param gvlObject is the parsed JSON that conforms to the IAB EU TCF Vendor List Specification
setGlobalVendorList( gvlObject )
```
---
#### setCmpId( cmpId )
Sets CMP ID number that is assigned to your CMP from the IAB EU. A unique ID will be assigned to each Consent Manager Provider
```javascript
// @param cmpId the id for the cmp setting the consent string values.
setCmpId( cmpId )
```
---
#### getCmpId()
Get the ID of the CMP from the consent string
```javascript
// @return CMP id
getCmpId()
```
---
#### setCmpVersion( version )
Sets the version of the CMP code that created or updated the consent string
```javascript
// @param version - CMP version
setCmpVersion( version )
```
---
#### getCmpVersion()
The version of the CMP code that created or updated the consent string
```javascript
// @return version CMP version
getCmpVersion()
```
---
#### setConsentScreen( screenId )
Sets the consent screen id. The screen number is CMP and CMP Version specific, and is for logging proof of consent
```javascript
// @param screenId id for the screen in which the consent values were confirmed
setConsentScreen( screenId )
```
---
#### getConsentScreen()
The screen number is CMP and CmpVersion specific, and is for logging proof of consent
```javascript
// @return screenId id for the screen in which the consent values were confirmed
getConsentScreen()
```
---
#### setConsentLanguage( language )
Sets consent language. Two-letter ISO639-1 language code that CMP asked for consent in
```javascript
// @param language two character ISO639-1 language code
setConsentLanguage( language )
```
---
#### getConsentLanguage()
gets consent language. Two-letter ISO639-1 language code that CMP asked for consent in
```javascript
// @return language two character ISO639-1 language code
getConsentLanguage()
```
---
#### setPurposesAllowed( purposeIdArray)
Sets the allowed purposes as an array of purpose ids
```javascript
// @param purposeIdArray variable length array of integers setting which purposes are allowed. If the id is in the array it’s allowed.
setPurposesAllowed( purposeIdArray)
```
---
#### getPurposesAllowed()
Gets an array of purposes allowed either set by `setPurposesAllowed` or whatever was previously set by the initializing consent string
```javascript
// @return variable length array of integers setting which purposes are allowed. If the id is in the array it’s allowed.
getPurposesAllowed()
```
---
#### setPurposeAllowed( purposeId, value )
Sets a single purpose by id and boolean value
```javascript
// @param purposeId the purpose id
// @param value the boolean value to set it to true for allowed false for not allowed
setPurposeAllowed( purposeId, value )
```
---
#### isPurposeAllowed( purposeId )
Gets a single purpose by id and returns boolean value
```javascript
// @param purposeId the purpose id
// @return boolean value true for allowed false for not allowed
isPurposeAllowed( purposeId )
```
---
#### setVendorAllowed( vendorId, valueBool )
Sets consent value for a vendor id
```javascript
// @param vendorId - vendor id to set consent value for
// @param value - the boolean value to set the consent to
setVendorAllowed( vendorId, valueBool )
```
---
#### isVendorAllowed( vendorId )
For determining if the vendor consent value bit is turned on or off for a particular vendor id.
```javascript
// @param vendorId vendor id to see if consent is allowed for
// @return boolean value of consent for that vendor id
isVendorAllowed( vendorId )
```
## About

@@ -147,0 +332,0 @@

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