Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public static getLatest(): GVL {
return new GVL(require('./vendorlist/vendor-list.json'));
}
public static noGVL(): TCModel {
const latestGVL = GVLFactory.getLatest();
const numPurposes = Object.keys(latestGVL.purposes).length;
const numVendors = Object.keys(latestGVL.vendors).length;
const numSpecialFeatures = Object.keys(latestGVL.specialFeatures).length;
const tcModel = new TCModel();
tcModel.cmpId = makeRandomInt(2,100);
tcModel.cmpVersion = makeRandomInt(1,10);
tcModel.consentScreen = makeRandomInt(1,5);
tcModel.isServiceSpecific = !!makeRandomInt(0,1);
tcModel.vendorListVersion = makeRandomInt(1, latestGVL.vendorListVersion);
let counter = 0;
const rand = makeRandomInt(1, TCModel.consentLanguages.size);
TCModel.consentLanguages.forEach((lang: string): void => {
counter ++;
if(counter === rand) {
tcModel.consentLanguage = lang;
}
const latestGVL = GVLFactory.getLatest();
const numPurposes = Object.keys(latestGVL.purposes).length;
const numVendors = Object.keys(latestGVL.vendors).length;
const numSpecialFeatures = Object.keys(latestGVL.specialFeatures).length;
const tcModel = new TCModel();
tcModel.cmpId = makeRandomInt(2,100);
tcModel.cmpVersion = makeRandomInt(1,10);
tcModel.consentScreen = makeRandomInt(1,5);
tcModel.isServiceSpecific = !!makeRandomInt(0,1);
tcModel.vendorListVersion = makeRandomInt(1, latestGVL.vendorListVersion);
let counter = 0;
const rand = makeRandomInt(1, TCModel.consentLanguages.size);
TCModel.consentLanguages.forEach((lang: string): void => {
counter ++;
if(counter === rand) {
tcModel.consentLanguage = lang;
}
});
tcModel.publisherCountryCode = String.fromCharCode(makeRandomInt(65, 90)) + String.fromCharCode(makeRandomInt(65, 90));
const now = (new Date()).getTime();
const GDPRMageddon = 1576883249;
tcModel.created = new Date(makeRandomInt(GDPRMageddon, now));
tcModel.lastUpdated = new Date(makeRandomInt(tcModel.created.getTime(), now));
public static getVersion(version: number): GVL {
return new GVL(require(`./vendorlist/vendor-list-v${version}.json`));
}
const numPurposes = Object.keys(latestGVL.purposes).length;
const numVendors = Object.keys(latestGVL.vendors).length;
const numSpecialFeatures = Object.keys(latestGVL.specialFeatures).length;
const tcModel = new TCModel();
tcModel.cmpId = makeRandomInt(2,100);
tcModel.cmpVersion = makeRandomInt(1,10);
tcModel.consentScreen = makeRandomInt(1,5);
tcModel.isServiceSpecific = !!makeRandomInt(0,1);
tcModel.vendorListVersion = makeRandomInt(1, latestGVL.vendorListVersion);
let counter = 0;
const rand = makeRandomInt(1, TCModel.consentLanguages.size);
TCModel.consentLanguages.forEach((lang: string): void => {
counter ++;
if(counter === rand) {
tcModel.consentLanguage = lang;
}
});
tcModel.publisherCountryCode = String.fromCharCode(makeRandomInt(65, 90)) + String.fromCharCode(makeRandomInt(65, 90));
const now = (new Date()).getTime();
const GDPRMageddon = 1576883249;
tcModel.created = new Date(makeRandomInt(GDPRMageddon, now));
tcModel.lastUpdated = new Date(makeRandomInt(tcModel.created.getTime(), now));
break;
case 'number':
console.log(`${indentString}${key}: ${value}\x1b[0m`);
break;
}
};
if (encoded) {
print('encoded', encoded);
try {
const tcModel = TCString.decode(encoded);
print('version', tcModel.version);
print('cmpId', tcModel.cmpId);
print('cmpVersion', tcModel.cmpVersion);
print('consentScreen', tcModel.consentScreen);
print('consentLanguage', tcModel.consentLanguage);
print('created', tcModel.created);
print('lastUpdated', tcModel.lastUpdated);
print('policyVersion', tcModel.policyVersion);
print('isServiceSpecific', tcModel.isServiceSpecific);
print('useNonStandardStacks', tcModel.useNonStandardStacks);
print('purposeOneTreatment', tcModel.purposeOneTreatment);
print('publisherCountryCode', tcModel.publisherCountryCode);
print('supportOOB', tcModel.supportOOB);
print('vendorListVersion', tcModel.vendorListVersion);
print('purposeConsents', tcModel.purposeConsents);
print('purposeLegitimateInterest', tcModel.purposeLegitimateInterest);
public execute(): void {
/**
* Return a clone of the current GVL if no param/version was used. Otherwise, create a new GVL with the
* specific version.
*/
const _gvl: GVL = this.param ? new GVL(this.param as string | number) : this.cmpData.getTcModel().gvl.clone();
_gvl.readyPromise.then(() => {
const gvl = new GlobalVendorListBldr(_gvl);
this.setBaseReturnFields(gvl);
(this.callback.function as VendorListCallback)(gvl.buildResponse(), true);
}, ((reason) => this.callback.fail(reason))).catch((reason) => this.callback.fail(reason));
}
protected success(): void {
let gvl: GVL;
const callback = this.callback as VendorListCallback;
if (!this.param) {
const tcModel = CmpApiModel.tcModel as TCModel;
if (tcModel.gvl) {
callback(tcModel.gvl.getJson(), true);
} else {
tcModel.gvl = new GVL(tcModel.vendorListVersion);
tcModel.gvl.readyPromise.then(() => {
callback(tcModel.gvl.getJson(), true);
}, this.fail).catch(this.fail);
}
} else {
gvl = new GVL(this.param);
const woops = (): void => {
this.fail();
callback(tcModel.gvl.getJson(), true);
} else {
tcModel.gvl = new GVL(tcModel.vendorListVersion);
tcModel.gvl.readyPromise.then(() => {
callback(tcModel.gvl.getJson(), true);
}, this.fail).catch(this.fail);
}
} else {
gvl = new GVL(this.param);
const woops = (): void => {
this.fail();
};
gvl.readyPromise.then(() => {
callback(gvl.getJson(), true);
}, woops).catch(woops);
}
}
public constructor() {
super();
this.tcmodel = new TCModel();
this.tcmodel.setCMPManifest(new CMPManifest());
this.cmpManifest = this.tcmodel.getCMPManifest();
}