How to use @iabtcf/core - 10 common examples

To help you get started, we’ve selected a few @iabtcf/core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github InteractiveAdvertisingBureau / iabtcf-es / modules / testing / src / GVLFactory.ts View on Github external
public static getLatest(): GVL {

    return new GVL(require('./vendorlist/vendor-list.json'));

  }
github InteractiveAdvertisingBureau / iabtcf-es / modules / testing / src / TCModelFactory.ts View on Github external
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;
      }
github InteractiveAdvertisingBureau / iabtcf-es / modules / testing / src / TCModelFactory.ts View on Github external
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));
github InteractiveAdvertisingBureau / iabtcf-es / modules / testing / src / GVLFactory.ts View on Github external
public static getVersion(version: number): GVL {

    return new GVL(require(`./vendorlist/vendor-list-v${version}.json`));

  }
github InteractiveAdvertisingBureau / iabtcf-es / modules / testing / src / TCModelFactory.ts View on Github external
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));
github InteractiveAdvertisingBureau / iabtcf-es / modules / cli / src / index.ts View on Github external
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);
github InteractiveAdvertisingBureau / iabtcf-es / modules / cmpapi / src / command / commands / GetVendorListCommand.ts View on Github external
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));

  }
github InteractiveAdvertisingBureau / iabtcf-es / modules / cmpapi / src / command / GetVendorListCommand.ts View on Github external
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();
github InteractiveAdvertisingBureau / iabtcf-es / modules / cmpapi / src / command / GetVendorListCommand.ts View on Github external
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);

    }

  }
github InteractiveAdvertisingBureau / iabtcf-es / modules / tools / src / components / pages / TCStringEncode.vue.ts View on Github external
public constructor() {

    super();

    this.tcmodel = new TCModel();
    this.tcmodel.setCMPManifest(new CMPManifest());
    this.cmpManifest = this.tcmodel.getCMPManifest();

  }

@iabtcf/core

Ensures consistent encoding and decoding of TC Signals for the iab. Transparency and Consent Framework (TCF).

Apache-2.0
Latest version published 2 years ago

Package Health Score

62 / 100
Full package analysis