UNPKG

@iabtechlabtcf/core

Version:

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

338 lines (337 loc) 12.7 kB
import { Cloneable } from './Cloneable.js'; import { GVL } from './GVL.js'; import { ConsentLanguages, IntMap, PurposeRestrictionVector, Vector } from './model/index.js'; import { Purpose } from './model/gvl/index.js'; type StringOrNumber = number | string; export type TCModelPropType = number | Date | string | boolean | Vector | PurposeRestrictionVector; export declare class TCModel extends Cloneable<TCModel> { /** * Set of available consent languages published by the IAB */ static readonly consentLanguages: ConsentLanguages; private isServiceSpecific_; private supportOOB_; private useNonStandardTexts_; private purposeOneTreatment_; private publisherCountryCode_; private version_; private consentScreen_; private policyVersion_; private consentLanguage_; private cmpId_; private cmpVersion_; private vendorListVersion_; private numCustomPurposes_; private gvl_; created: Date; lastUpdated: Date; /** * The TCF designates certain Features as special, that is, a CMP must afford * the user a means to opt in to their use. These Special Features are * published and numbered in the GVL separately from normal Features. * Provides for up to 12 special features. */ readonly specialFeatureOptins: Vector; /** * Renamed from `PurposesAllowed` in TCF v1.1 * The user’s consent value for each Purpose established on the legal basis * of consent. Purposes are published in the Global Vendor List (see. [[GVL]]). */ readonly purposeConsents: Vector; /** * The user’s permission for each Purpose established on the legal basis of * legitimate interest. If the user has exercised right-to-object for a * purpose. */ readonly purposeLegitimateInterests: Vector; /** * The user’s consent value for each Purpose established on the legal basis * of consent, for the publisher. Purposes are published in the Global * Vendor List. */ readonly publisherConsents: Vector; /** * The user’s permission for each Purpose established on the legal basis of * legitimate interest. If the user has exercised right-to-object for a * purpose. */ readonly publisherLegitimateInterests: Vector; /** * The user’s consent value for each Purpose established on the legal basis * of consent, for the publisher. Purposes are published in the Global * Vendor List. */ readonly publisherCustomConsents: Vector; /** * The user’s permission for each Purpose established on the legal basis of * legitimate interest. If the user has exercised right-to-object for a * purpose that is established in the publisher's custom purposes. */ readonly publisherCustomLegitimateInterests: Vector; /** * set by a publisher if they wish to collect consent and LI Transparency for * purposes outside of the TCF */ customPurposes: IntMap<Purpose>; /** * Each [[Vendor]] is keyed by id. Their consent value is true if it is in * the Vector */ readonly vendorConsents: Vector; /** * Each [[Vendor]] is keyed by id. Whether their Legitimate Interests * Disclosures have been established is stored as boolean. * see: [[Vector]] */ readonly vendorLegitimateInterests: Vector; /** * The value included for disclosed vendors signals which vendors have been * disclosed to the user in the interface surfaced by the CMP. This section * content is required when writing a TC string to the global (consensu) * scope. When a CMP has read from and is updating a TC string from the * global consensu.org storage, the CMP MUST retain the existing disclosure * information and only add information for vendors that it has disclosed * that had not been disclosed by other CMPs in prior interactions with this * device/user agent. */ readonly vendorsDisclosed: Vector; /** * Signals which vendors the publisher permits to use OOB legal bases. */ readonly vendorsAllowed: Vector; readonly publisherRestrictions: PurposeRestrictionVector; /** * Constructs the TCModel. Passing a [[GVL]] is optional when constructing * as this TCModel may be constructed from decoding an existing encoded * TCString. * * @param {GVL} [gvl] */ constructor(gvl?: GVL); /** * sets the [[GVL]] with side effects of also setting the `vendorListVersion`, `policyVersion`, and `consentLanguage` * @param {GVL} gvl */ set gvl(gvl: GVL); /** * @return {GVL} the gvl instance set on this TCModel instance */ get gvl(): GVL; /** * @param {number} integer - A unique ID will be assigned to each Consent * Manager Provider (CMP) from the iab. * * @throws {TCModelError} if the value is not an integer greater than 1 as those are not valid. */ set cmpId(integer: StringOrNumber); get cmpId(): StringOrNumber; /** * Each change to an operating CMP should receive a * new version number, for logging proof of consent. CmpVersion defined by * each CMP. * * @param {number} integer * * @throws {TCModelError} if the value is not an integer greater than 1 as those are not valid. */ set cmpVersion(integer: StringOrNumber); get cmpVersion(): StringOrNumber; /** * The screen number is CMP and CmpVersion * specific, and is for logging proof of consent.(For example, a CMP could * keep records so that a publisher can request information about the context * in which consent was gathered.) * * @param {number} integer * * @throws {TCModelError} if the value is not an integer greater than 0 as those are not valid. */ set consentScreen(integer: StringOrNumber); get consentScreen(): StringOrNumber; /** * @param {string} lang - [two-letter ISO 639-1 language * code](http://www.loc.gov/standards/iso639-2/php/code_list.php) in which * the CMP UI was presented * * @throws {TCModelError} if the value is not a length-2 string of alpha characters */ set consentLanguage(lang: string); get consentLanguage(): string; /** * @param {string} countryCode - [two-letter ISO 3166-1 alpha-2 country * code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) of the publisher, * determined by the CMP-settings of the publisher. * * @throws {TCModelError} if the value is not a length-2 string of alpha characters */ set publisherCountryCode(countryCode: string); get publisherCountryCode(): string; /** * Version of the GVL used to create this TCModel. Global * Vendor List versions will be released periodically. * * @param {number} integer * * @throws {TCModelError} if the value is not an integer greater than 0 as those are not valid. */ set vendorListVersion(integer: StringOrNumber); get vendorListVersion(): StringOrNumber; /** * From the corresponding field in the GVL that was * used for obtaining consent. A new policy version invalidates existing * strings and requires CMPs to re-establish transparency and consent from * users. * * If a TCF policy version number is different from the one from the latest * GVL, the CMP must re-establish transparency and consent. * * @param {number} num - You do not need to set this. This comes * directly from the [[GVL]]. * */ set policyVersion(num: StringOrNumber); get policyVersion(): StringOrNumber; set version(num: StringOrNumber); get version(): StringOrNumber; /** * Whether the signals encoded in this TC String were from site-specific * storage `true` versus ‘global’ consensu.org shared storage `false`. A * string intended to be stored in global/shared scope but the CMP is unable * to store due to a user agent not accepting third-party cookies would be * considered site-specific `true`. * * @param {boolean} bool - value to set. Some changes to other fields in this * model will automatically change this value like adding publisher * restrictions. */ set isServiceSpecific(bool: boolean); get isServiceSpecific(): boolean; /** * Non-standard stacks means that a CMP is using publisher-customized stack * descriptions. Stacks (in terms of purposes in a stack) are pre-set by the * IAB. As are titles. Descriptions are pre-set, but publishers can customize * them. If they do, they need to set this bit to indicate that they've * customized descriptions. * * @param {boolean} bool - value to set */ set useNonStandardTexts(bool: boolean); get useNonStandardTexts(): boolean; /** * Whether or not this publisher supports OOB signaling. On Global TC String * OOB Vendors Disclosed will be included if the publish wishes to no allow * these vendors they should set this to false. * @param {boolean} bool - value to set */ set supportOOB(bool: boolean); get supportOOB(): boolean; /** * `false` There is no special Purpose 1 status. * Purpose 1 was disclosed normally (consent) as expected by Policy. `true` * Purpose 1 not disclosed at all. CMPs use PublisherCC to indicate the * publisher’s country of establishment to help Vendors determine whether the * vendor requires Purpose 1 consent. In global scope TC strings, this field * must always have a value of `false`. When a CMP encounters a global scope * string with `purposeOneTreatment=true` then that string should be * considered invalid and the CMP must re-establish transparency and consent. * * @param {boolean} bool */ set purposeOneTreatment(bool: boolean); get purposeOneTreatment(): boolean; /** * setAllVendorConsents - sets all vendors on the GVL Consent (true) * * @return {void} */ setAllVendorConsents(): void; /** * unsetAllVendorConsents - unsets all vendors on the GVL Consent (false) * * @return {void} */ unsetAllVendorConsents(): void; /** * setAllVendorsDisclosed - sets all vendors on the GVL Vendors Disclosed (true) * * @return {void} */ setAllVendorsDisclosed(): void; /** * unsetAllVendorsDisclosed - unsets all vendors on the GVL Consent (false) * * @return {void} */ unsetAllVendorsDisclosed(): void; /** * setAllVendorsAllowed - sets all vendors on the GVL Consent (true) * * @return {void} */ setAllVendorsAllowed(): void; /** * unsetAllVendorsAllowed - unsets all vendors on the GVL Consent (false) * * @return {void} */ unsetAllVendorsAllowed(): void; /** * setAllVendorLegitimateInterests - sets all vendors on the GVL LegitimateInterests (true) * * @return {void} */ setAllVendorLegitimateInterests(): void; /** * unsetAllVendorLegitimateInterests - unsets all vendors on the GVL LegitimateInterests (false) * * @return {void} */ unsetAllVendorLegitimateInterests(): void; /** * setAllPurposeConsents - sets all purposes on the GVL Consent (true) * * @return {void} */ setAllPurposeConsents(): void; /** * unsetAllPurposeConsents - unsets all purposes on the GVL Consent (false) * * @return {void} */ unsetAllPurposeConsents(): void; /** * setAllPurposeLegitimateInterests - sets all purposes on the GVL LI Transparency (true) * * @return {void} */ setAllPurposeLegitimateInterests(): void; /** * unsetAllPurposeLegitimateInterests - unsets all purposes on the GVL LI Transparency (false) * * @return {void} */ unsetAllPurposeLegitimateInterests(): void; /** * setAllSpecialFeatureOptins - sets all special featuresOptins on the GVL (true) * * @return {void} */ setAllSpecialFeatureOptins(): void; /** * unsetAllSpecialFeatureOptins - unsets all special featuresOptins on the GVL (true) * * @return {void} */ unsetAllSpecialFeatureOptins(): void; setAll(): void; unsetAll(): void; get numCustomPurposes(): StringOrNumber; set numCustomPurposes(num: StringOrNumber); /** * updated - updates the created and lastUpdated dates with a 'now' day-level UTC timestamp * * @return {void} */ updated(): void; } export {};