3.1.1 • Published 9 days ago

@iabgpp/cmpapi v3.1.1

Weekly downloads
-
License
Apache-2.0
Repository
-
Last release
9 days ago

@iabgpp/cmpapi

Encode/decode consent information with the IAB GPP Framework

(https://iabtechlab.com/gpp/)

Methods available to CMPs

constructor(cmpId: number, cmpVersion: number, customCommands?: CustomCommands)
fireEvent(eventName: string, value: any)
fireErrorEvent(value: string)
fireSectionChange(value: string)
getEventStatus()
setEventStatus(eventStatus: EventStatus)
getCmpStatus()
setCmpStatus(cmpStatus: CmpStatus)
getCmpDisplayStatus(): CmpDisplayStatus
setCmpDisplayStatus(cmpDisplayStatus: CmpDisplayStatus)
getApplicableSections(): number[]
setApplicableSections(applicableSections: number[]): void
getSignalStatus(): SignalStatus
setSignalStatus(signalStatus: SignalStatus): void
setGppString(encodedGppString: string): void
getGppString(): string
setSectionString(sectionName: string, encodedSectionString: string): void
setSectionStringById(sectionId: number, encodedSectionString: string): void
getSectionString(sectionName: string): string
getSectionStringById(sectionId: number): string
setFieldValue(sectionName: string, fieldName: string, value: any): void
setFieldValueBySectionId(sectionId: number, fieldName: string, value: any)
getFieldValue(sectionName: string, fieldName: string): any
getFieldValueBySectionId(sectionId: number, fieldName: string)
getSection(sectionName: string): any
getSectionById(sectionId: number): any
hasSection(sectionName: string): any
hasSectionId(sectionId: number): any
deleteSection(sectionName: string)
deleteSectionById(sectionId: number)
clear()
getObject()
getGvlFromVendorList(vendorList: VendorList): GVL
async getGvlFromUrl(gvlUrlConfig: GVLUrlConfig): Promise<GVL>

Commands available to consumers

__gpp("addEventListener", callback?, parameter?)
__gpp("getField", callback?, parameter?)
__gpp("getSection", callback?, parameter?)
__gpp("hasSection", callback?, parameter?)
__gpp("ping", callback?, parameter?)
__gpp("removeEventListener", callback?, parameter?)

CMP usage Example

<script>
  import {CmpApi} from '@iabgpp/cmpapi'; const cmpApi = new CmpApi(1, 3); cmpApi.setGppString(gppString);
  cmpApi.setFieldValue("uspv1", "OptOutSale", 0); cmpApi.fireUpdate("uspv1"); console.log(cmpApi.getGppString());
</script>

Consumer usage example

<script src="/js/stub/stub.js"></script>
<script>
  console.log(__gpp("ping"));

  __gpp("addEventListener", function (evt) {
    console.log("Received uspv1 event: " + evt);
    console.log(__gpp("getGPPString"));
  }, "uspv1");

  if(__gpp("hasSection", null, "tcfeuv2")) {
    console.log(__gpp("getSection", null, "tcfeuv2"));
  }

  if(__gpp("hasSection", null, "uspv1")) {
    console.log(__gpp("getField", null, "uspv1.OptOutSale"));
  }
</script>

Fields

Section NameSection IDFieldData Type/Value
tcfeuv22Version6 bit int. Value is 2.
tcfeuv22CreatedDatetime. Updated when fields are set
tcfeuv22LastUpdatedDatetime. Updated when fields are set
tcfeuv22CmpId12 bit int
tcfeuv22CmpVersion12 bit int
tcfeuv22ConsentScreen6 bit int
tcfeuv22ConsentLanguage2 character country code
tcfeuv22VendorListVersion12 bit int
tcfeuv22PolicyVersion6 bit int. Value is 2
tcfeuv22IsServiceSpecificBoolean
tcfeuv22UseNonStandardStacksBoolean
tcfeuv22SpecialFeatureOptinsBoolean array of size 12
tcfeuv22PurposeConsentsBoolean array of size 24
tcfeuv22PurposeLegitimateInterestsBoolean array of size 24
tcfeuv22PurposeOneTreatmentBoolean
tcfeuv22PublisherCountryCode2 character country code
tcfeuv22VendorConsentsInteger array of variable size
tcfeuv22VendorLegitimateInterestsInteger array of variable size
tcfeuv22PublisherRestrictionsInteger array of variable size
tcfeuv22PublisherPurposesSegmentType3 bit int. Value is 3
tcfeuv22PublisherConsentsBoolean array of size 24
tcfeuv22PublisherLegitimateInterestsBoolean array of size 24
tcfeuv22NumCustomPurposes6 bit int
tcfeuv22PublisherCustomConsentsBoolean array where size is set by the NumCustomPurposes field
tcfeuv22PublisherCustomLegitimateInterestsBoolean array where size is set by the NumCustomPurposes field
tcfeuv22VendorsAllowedSegmentType3 bit int. Value is 2
tcfeuv22VendorsAllowedInteger array of variable size
tcfeuv22VendorsDisclosedSegmentType3 bit int. Value is 1
tcfeuv22VendorsDisclosedInteger array of variable size
tcfcav15Version6 bit int. Value is 2.
tcfcav15CreatedDatetime. Updated when any fields are set
tcfcav15LastUpdatedDatetime. Updated when any fields are set
tcfcav15CmpId12 bit int
tcfcav15CmpVersion12 bit int
tcfcav15ConsentScreen6 bit int
tcfcav15ConsentLanguage2 character country code
tcfcav15VendorListVersion12 bit int
tcfcav15TcfPolicyVersion6 bit int. Value is 2.
tcfcav15UseNonStandardStacksBoolean
tcfcav15SpecialFeatureExpressConsentBoolean array of size 12
tcfcav15PurposesExpressConsentBoolean array of size 24
tcfcav15PurposesImpliedConsentBoolean array of size 24
tcfcav15VendorExpressConsentInteger array of variable size
tcfcav15VendorImpliedConsentInteger array of variable size
tcfcav15PubPurposesSegmentType3 bit int. Value is 3
tcfcav15PubPurposesExpressConsentBoolean array of size 24
tcfcav15PubPurposesImpliedConsentBoolean array of size 24
tcfcav15NumCustomPurposes6 bit int
tcfcav15CustomPurposesExpressConsentBoolean array where size is set by the NumCustomPurposes field
tcfcav15CustomPurposesImpliedConsentBoolean array where size is set by the NumCustomPurposes field
uspv16Version6 bit int. Value is 1
uspv16Notice2 bit int
uspv16OptOutSale2 bit int
uspv16LspaCovered2 bit int
usnat7Version6 bit int. Value is 1
usnat7SharingNotice2 bit int. 0=Not applicable, 1=Yes, 2=No
usnat7SaleOptOutNotice2 bit int. 0=Not applicable, 1=Yes, 2=No
usnat7SharingOptOutNotice2 bit int. 0=Not applicable, 1=Yes, 2=No
usnat7TargetedAdvertisingOptOutNotice2 bit int. 0=Not applicable, 1=Yes, 2=No
usnat7SensitiveDataProcessingOptOutNotice2 bit int. 0=Not applicable, 1=Yes, 2=No
usnat7SensitiveDataLimitUseNotice2 bit int. 0=Not applicable, 1=Yes, 2=No
usnat7SaleOptOut2 bit int. 0=Not applicable, 1=Yes, 2=No
usnat7SharingOptOut2 bit int. 0=Not applicable, 1=Yes, 2=No
usnat7TargetedAdvertisingOptOut2 bit int. 0=Not applicable, 1=Yes, 2=No
usnat7SensitiveDataProcessing2 bit int array of size 12. 0=Not applicable, 1=Yes, 2=No
usnat7KnownChildSensitiveDataConsents2 bit int array of size 2. 0=Not applicable, 1=Yes, 2=No
usnat7PersonalDataConsents2 bit int. 0=Not applicable, 1=Yes, 2=No
usnat7MspaCoveredTransaction2 bit int. 0=Not applicable, 1=Yes, 2=No
usnat7MspaOptOutOptionMode2 bit int. 0=Not applicable, 1=Yes, 2=No
usnat7MspaServiceProviderMode2 bit int. 0=Not applicable, 1=Yes, 2=No
usnat7GpcSegmentType2 bit int. Value is 1
usnat7GpcSegmentIncludedBoolean. Default is true
usnat7GpcBoolean
usca8Version6 bit int. Value is 1
usca8SaleOptOutNotice2 bit int. 0=Not applicable, 1=Yes, 2=No
usca8SharingOptOutNotice2 bit int. 0=Not applicable, 1=Yes, 2=No
usca8SensitiveDataLimitUseNotice2 bit int. 0=Not applicable, 1=Yes, 2=No
usca8SaleOptOut2 bit int. 0=Not applicable, 1=Yes, 2=No
usca8SharingOptOut2 bit int. 0=Not applicable, 1=Yes, 2=No
usca8SensitiveDataProcessing2 bit int array of size 9. 0=Not applicable, 1=Yes, 2=No
usca8KnownChildSensitiveDataConsents2 bit int array of size 2. 0=Not applicable, 1=Yes, 2=No
usca8PersonalDataConsents2 bit int. 0=Not applicable, 1=Yes, 2=No
usca8MspaCoveredTransaction2 bit int. 0=Not applicable, 1=Yes, 2=No
usca8MspaOptOutOptionMode2 bit int. 0=Not applicable, 1=Yes, 2=No
usca8MspaServiceProviderMode2 bit int. 0=Not applicable, 1=Yes, 2=No
usca8GpcSegmentType2 bit int. Value is 1
usca8GpcSegmentIncludedBoolean. Default is true
usca8GpcBoolean
usva9Version6 bit int. Value is 1
usva9SharingNotice2 bit int. 0=Not applicable, 1=Yes, 2=No
usva9SaleOptOutNotice2 bit int. 0=Not applicable, 1=Yes, 2=No
usva9TargetedAdvertisingOptOutNotice2 bit int. 0=Not applicable, 1=Yes, 2=No
usva9SaleOptOut2 bit int. 0=Not applicable, 1=Yes, 2=No
usva9TargetedAdvertisingOptOut2 bit int. 0=Not applicable, 1=Yes, 2=No
usva9SensitiveDataProcessing2 bit int array of size 8. 0=Not applicable, 1=Yes, 2=No
usva9KnownChildSensitiveDataConsents2 bit int. 0=Not applicable, 1=Yes, 2=No
usva9MspaCoveredTransaction2 bit int. 0=Not applicable, 1=Yes, 2=No
usva9MspaOptOutOptionMode2 bit int. 0=Not applicable, 1=Yes, 2=No
usva9MspaServiceProviderMode2 bit int. 0=Not applicable, 1=Yes, 2=No
usco10Version6 bit int. Value is 1
usco10SharingNotice2 bit int. 0=Not applicable, 1=Yes, 2=No
usco10SaleOptOutNotice2 bit int. 0=Not applicable, 1=Yes, 2=No
usco10TargetedAdvertisingOptOutNotice2 bit int. 0=Not applicable, 1=Yes, 2=No
usco10SaleOptOut2 bit int. 0=Not applicable, 1=Yes, 2=No
usco10TargetedAdvertisingOptOut2 bit int. 0=Not applicable, 1=Yes, 2=No
usco10SensitiveDataProcessing2 bit int array of size 7. 0=Not applicable, 1=Yes, 2=No
usco10KnownChildSensitiveDataConsents2 bit int. 0=Not applicable, 1=Yes, 2=No
usco10MspaCoveredTransaction2 bit int. 0=Not applicable, 1=Yes, 2=No
usco10MspaOptOutOptionMode2 bit int. 0=Not applicable, 1=Yes, 2=No
usco10MspaServiceProviderMode2 bit int. 0=Not applicable, 1=Yes, 2=No
usco10GpcSegmentType2 bit int. Value is 1
usco10GpcSegmentIncludedBoolean. Deafult is true
usco10GpcBoolean
usut11Version6 bit int. Value is 1
usut11SharingNotice2 bit int. 0=Not applicable, 1=Yes, 2=No
usut11SaleOptOutNotice2 bit int. 0=Not applicable, 1=Yes, 2=No
usut11TargetedAdvertisingOptOutNotice2 bit int. 0=Not applicable, 1=Yes, 2=No
usut11SensitiveDataProcessingOptOutNotice2 bit int. 0=Not applicable, 1=Yes, 2=No
usut11SaleOptOut2 bit int. 0=Not applicable, 1=Yes, 2=No
usut11TargetedAdvertisingOptOut2 bit int. 0=Not applicable, 1=Yes, 2=No
usut11SensitiveDataProcessing2 bit int array of size 8. 0=Not applicable, 1=Yes, 2=No
usut11KnownChildSensitiveDataConsents2 bit int. 0=Not applicable, 1=Yes, 2=No
usut11MspaCoveredTransaction2 bit int. 0=Not applicable, 1=Yes, 2=No
usut11MspaOptOutOptionMode2 bit int. 0=Not applicable, 1=Yes, 2=No
usut11MspaServiceProviderMode2 bit int. 0=Not applicable, 1=Yes, 2=No
usct12Version6 bit int. Value is 1
usct12SharingNotice2 bit int. 0=Not applicable, 1=Yes, 2=No
usct12SaleOptOutNotice2 bit int. 0=Not applicable, 1=Yes, 2=No
usct12TargetedAdvertisingOptOutNotice2 bit int. 0=Not applicable, 1=Yes, 2=No
usct12SaleOptOut2 bit int. 0=Not applicable, 1=Yes, 2=No
usct12TargetedAdvertisingOptOut2 bit int. 0=Not applicable, 1=Yes, 2=No
usct12SensitiveDataProcessing2 bit int array of size 8. 0=Not applicable, 1=Yes, 2=No
usct12KnownChildSensitiveDataConsents2 bit int array of size 3. 0=Not applicable, 1=Yes, 2=No
usct12MspaCoveredTransaction2 bit int. 0=Not applicable, 1=Yes, 2=No
usct12MspaOptOutOptionMode2 bit int. 0=Not applicable, 1=Yes, 2=No
usct12MspaServiceProviderMode2 bit int. 0=Not applicable, 1=Yes, 2=No
usct12GpcSegmentType2 bit int. Value is 1
usct12GpcSegmentIncludedBoolean. Default is true
usct12GpcBoolean

Example Usage / Encoder / Decoder

https://iabgpp.com

3.1.1

9 days ago

3.1.0

9 months ago

3.0.10

1 year ago

3.0.9

1 year ago

3.0.8

1 year ago

3.0.7

1 year ago

3.0.6

1 year ago

3.0.5

1 year ago

3.0.4

1 year ago

3.0.3

1 year ago

3.0.2

1 year ago