UNPKG

@didomi/iabtcf-cmpapi

Version:

Ensures other in-page digital marketing technologies have access to CMP transparency and consent information for the iab. Transparency and Consent Framework (TCF).

38 lines (37 loc) 1.28 kB
import { CmpStatus, DisplayStatus } from './status/index.js'; import { EventListenerQueue } from './EventListenerQueue.js'; import { Cache } from './Cache.js'; /** * Class holds shareable data across cmp api and provides change event listener for TcModel. * Within the context of the CmpApi, this class acts much like a global state or database, * where CmpApi sets data and Commands read the data. */ export class CmpApiModel { static apiVersion = '2'; static tcfPolicyVersion; static eventQueue = new EventListenerQueue(); static cmpStatus = CmpStatus.LOADING; static disabled = false; static displayStatus = DisplayStatus.HIDDEN; static cmpId; static cmpVersion; static eventStatus; static gdprApplies; static tcModel; static tcString; static restrictionsCache = new Cache(); 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 = CmpStatus.LOADING; this.disabled = false; this.displayStatus = DisplayStatus.HIDDEN; this.eventQueue.clear(); this.restrictionsCache.clear(); } }